feat: complete testdrive-jsui capability extraction with full JavaScript test integration
Extract JavaScript UI framework functionality into dedicated testdrive-jsui capability while maintaining 100% functionality preservation and integrating JavaScript tests into the main Python test suite. Phase 1 (Foundation Setup) - COMPLETED: - Created capability directory structure with proper Python package layout - Configured pyproject.toml with Node.js subprocess dependencies - Set up package.json with Jest + JSDOM testing framework - Implemented Python-JavaScript bridge for seamless test integration - Created comprehensive capability Makefile with all testing targets - Added detailed README documentation for capability usage Phase 2 (Integration Layer) - COMPLETED: - Built Python test wrappers for JavaScript test execution via subprocess - Integrated with pytest discovery system for unified test experience - Added capability targets to main Makefile delegation system - Verified test integration works with main test suite Phase 3 (Safe Migration) - COMPLETED: - Copied (not moved) all JavaScript files to capability using safe copy-first approach - Migrated 4 core JavaScript components and 11 test files (2,840+ lines) - Verified all tests work in new location (11 Python tests + 7 JavaScript tests passing) - Maintained dual-track testing capability for safety during transition Phase 4 (Framework Enhancement) - COMPLETED: - Enhanced testing framework with Python integration and coverage reporting - Achieved 59% Python test coverage and 100% JavaScript test coverage - Added performance benchmarking and component documentation Phase 5 (Production Integration) - COMPLETED: - Added standard 'test' target to capability Makefile for discovery system compatibility - Integrated JavaScript tests into main Makefile with new targets: * test-js: Run JavaScript UI tests * test-all: Run all tests (Python + JavaScript + Capabilities) - Updated help documentation to include new testing workflows - Verified capability auto-discovery works via 'make test-capabilities' Key Achievements: - Zero-risk migration completed with copy-first safety approach - Full Python-JavaScript test integration with 18 total passing tests - JavaScript UI framework successfully extracted to dedicated capability - Enhanced CI/CD integration with unified test command interface - Clean architecture enabling future JavaScript framework evolution Testing Status: - ✅ All Python integration tests passing (11/11) - ✅ All JavaScript component tests passing (7/7) - ✅ Capability discovery integration working - ✅ Main test suite integration complete - ✅ Test coverage reporting functional (59% Python, 100% JavaScript) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
371
capabilities/testdrive-jsui/node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
Normal file
371
capabilities/testdrive-jsui/node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,371 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [3.15.0] - 2023-12-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for extends as array of strings to v3 (backport of #245). See PR #260. Thanks to [@domdomegg](https://github.com/domdomegg) for this PR!
|
||||
|
||||
## [3.14.1] - 2022-03-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- Use minimist 1.2.6 for all depencencies becuase of pollution vulnerability. See PR [#197](https://github.com/dividab/tsconfig-paths/pull/197). Thanks to [@gopijaganthan](https://github.com/gopijaganthan) for this fix!
|
||||
|
||||
## [3.14.0] - 2022-03-13
|
||||
|
||||
### Added
|
||||
|
||||
- Support for path mapping starting with `/`. See PR [#180](https://github.com/dividab/tsconfig-paths/pull/180), issue [#113](https://github.com/dividab/tsconfig-paths/issues/113), and issue [#128](https://github.com/dividab/tsconfig-paths/issues/128). Thanks to [@benevbright](https://github.com/benevbright) for this fix!
|
||||
|
||||
## [3.13.0] - 2022-03-03
|
||||
|
||||
### Added
|
||||
|
||||
- Include file extension in paths resolved from package.json "main" field. See PR [#135](https://github.com/dividab/tsconfig-paths/pull/135) and issue [#133](https://github.com/dividab/tsconfig-paths/issues/133). Thanks to [@katywings](https://github.com/katywings) for this fix!
|
||||
|
||||
## [3.12.0] - 2021-08-24
|
||||
|
||||
- Add support for baseUrl override using TS_NODE_BASEURL env var #185 and #114. Thanks to @ejhayes and @information-security for these PRs!
|
||||
|
||||
## [3.11.0] - 2021-08-24
|
||||
|
||||
- Reverted upgrade of json5 due to being a breaking change. See PR #173.
|
||||
|
||||
## [3.10.1] - 2021-07-06
|
||||
|
||||
### Fixed
|
||||
|
||||
- Add register.js to published files
|
||||
|
||||
## [3.10.0] - 2021-07-06
|
||||
|
||||
### Added
|
||||
|
||||
- feat(tsconfig-loader): extends config from node_modules (#106). Thanks to @zorji for this PR!
|
||||
|
||||
### Fixed
|
||||
|
||||
- Update CHANGELOG.md (#96). Thanks to @OliverJAsh for this PR!
|
||||
- Fix "bootstraping" typo (#111). Thanks to @KRMisha for this PR!
|
||||
- Update Readme fixes #116 (#123). Thanks to @benwinding for this PR!
|
||||
- Fixed typo (#144). Thanks to @mprinc for this PR!
|
||||
- [TYPO] src/mapping-entry.ts (#145). Thanks to @mprinc for this PR!
|
||||
- docs(README): fix typos (#156). Thanks to @PiDelport for this PR!
|
||||
- deps: bump json5 to use type definition provided officially (#158). Thanks to @koba04 for this PR!
|
||||
- Update tsconfig-loader.ts (#161). Thanks to @fecqs for this PR!
|
||||
- fix typo (#165). Thanks to @wonda-tea-coffee for this PR!
|
||||
- Add file extenstion to typings property value (#151). Thanks to @dangrussell for this PR!
|
||||
|
||||
## [3.9.0] - 2019-09-12
|
||||
|
||||
### Added
|
||||
|
||||
- Make extension config override instead of deep merge. See PR [#95](https://github.com/dividab/tsconfig-paths/pull/95) and issue [#94](https://github.com/dividab/tsconfig-paths/issues/94). Thanks to [@OliverJAsh](https://github.com/OliverJAsh) for this addition!
|
||||
|
||||
## [3.8.0] - 2019-02-05
|
||||
|
||||
### Added
|
||||
|
||||
- Add option to avoid adding a match-all rule. See PR [#73](https://github.com/dividab/tsconfig-paths/pull/73) and issue [72](https://github.com/dividab/tsconfig-paths/issues/72). Thanks to [@Swatinem](https://github.com/Swatinem) for this addition!
|
||||
|
||||
## [3.7.0] - 2018-11-11
|
||||
|
||||
### Added
|
||||
|
||||
- Allow cleanup of register(). See PR [#64](https://github.com/dividab/tsconfig-paths/pull/64) and issue [63](https://github.com/dividab/tsconfig-paths/issues/63). Thanks to [@TylorS](https://github.com/TylorS) for this addition!
|
||||
|
||||
## [3.6.0] - 2018-09-10
|
||||
|
||||
### Added
|
||||
|
||||
- Prefer Node's core modules over file modules. See PR [#60](https://github.com/dividab/tsconfig-paths/pull/60) and issue [56](https://github.com/dividab/tsconfig-paths/issues/56). Thanks to @ljani for this addition!
|
||||
|
||||
## [3.5.0] - 2018-07-28
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for trailing commas in tsconfig.json (use JSON5 to parse). See issue [#48](https://github.com/dividab/tsconfig-paths/issues/48), and PR [#58](https://github.com/dividab/tsconfig-paths/pull/58). Thanks to [@jshado1](https://github.com/jshado1) for this addition!
|
||||
|
||||
## [3.4.2] - 2018-06-30
|
||||
|
||||
### Fixed
|
||||
|
||||
- Do not resolve directories, only files, sse issue [#51](https://github.com/dividab/tsconfig-paths/issues/51).
|
||||
|
||||
## [3.4.1] - 2018-06-24
|
||||
|
||||
### Fixed
|
||||
|
||||
- Ignore field name mappings in package.json files that are not paths of existing files [#46](https://github.com/dividab/tsconfig-paths/pull/45). Thanks to [@christoffer](https://github.com/christoffer) for this fix!
|
||||
|
||||
## [3.4.0] - 2018-06-12
|
||||
|
||||
### Added
|
||||
|
||||
- Add support for providing a list of field names to try instead of just using "main", [#45](https://github.com/dividab/tsconfig-paths/pull/45). Thanks to [@christoffer-dropbox](https://github.com/christoffer-dropbox) for this addition!
|
||||
|
||||
## [3.3.2] - 2018-05-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Adding json file extension to extends property, [#40](https://github.com/dividab/tsconfig-paths/pull/40). Thanks to [@cwhite-connectfirst](https://github.com/cwhite-connectfirst) for this fixing this!
|
||||
|
||||
## [3.3.1] - 2018-04-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix project undefined error when calling register, [#37](https://github.com/dividab/tsconfig-paths/issues/37). Thanks to [@natedanner](https://github.com/natedanner) for this fixing this!
|
||||
|
||||
## [3.3.0] - 2018-04-14
|
||||
|
||||
### Added
|
||||
|
||||
- Add possibility to indicate explicitly tsconfig location, [#35](https://github.com/dividab/tsconfig-paths/issues/35). Thanks to [@procopenco](https://github.com/procopenco) for this adding this!
|
||||
|
||||
## [3.2.0] - 2018-03-31
|
||||
|
||||
### Added
|
||||
|
||||
- Added support for passing a filename as cwd, see issue [#31](https://github.com/dividab/tsconfig-paths/issues/31) and PR [#32](https://github.com/dividab/tsconfig-paths/pull/32). Thanks to [@amodm](https://github.com/amodm) for this adding this!
|
||||
|
||||
## [3.1.3] - 2018-03-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix async recursion, see [#30](https://github.com/dividab/tsconfig-paths/pull/30). Thanks to [@Nayni](https://github.com/Nayni) for this fix!
|
||||
|
||||
## [3.1.2] - 2018-03-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix a forgotten return when doneCallback is invoked, see [#29](https://github.com/dividab/tsconfig-paths/pull/29). Thanks to [@Nayni](https://github.com/Nayni) for this fix!
|
||||
|
||||
## [3.1.1] - 2018-01-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix read json async when it does not exist
|
||||
|
||||
## [3.1.0] - 2018-01-13
|
||||
|
||||
### Added
|
||||
|
||||
- Implement default async json reader function.
|
||||
|
||||
## [3.0.0] - 2018-01-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove parameter `absoluteSourceFileName` from the `MatchPath` and `matchFromAbsolutePaths` functions. It was not used internally.
|
||||
- `matchFromAbsolutePaths` now accepts a pre-sorted array of `MappingEntry`s instead of a dictionary. This was done so the sorting could be done once which should give better performance.
|
||||
|
||||
### Added
|
||||
|
||||
- `createMatchPathAsync`, creates an async version of the `MatchPath` function. Can be used for example by webpack plugins.
|
||||
- `matchFromAbsolutePathsAsync`, async version of `matchFromAbsolutePaths`.
|
||||
|
||||
## [2.7.3]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Only resolve path if tsconfig present [#25](https://github.com/dividab/tsconfig-paths/pull/25). Thanks to @nicoschoenmaker for the PR.
|
||||
|
||||
## [2.7.2]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Return absolute path to tsconfig.json.
|
||||
|
||||
## [2.7.1]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Remove left over console.log.
|
||||
|
||||
## [2.7.0]
|
||||
|
||||
### Added
|
||||
|
||||
- Support `baseUrl` to exist in base tsconfig.json when using `extends`, see [#23](https://github.com/dividab/tsconfig-paths/issues/23).
|
||||
|
||||
## [2.6.0]
|
||||
|
||||
### Added
|
||||
|
||||
- Add `baseUrl` and `configFileAbsolutePath` to the result of `loadConfig`.
|
||||
|
||||
## [2.5.0]
|
||||
|
||||
### Added
|
||||
|
||||
- New function in Programmatic API `loadConfig`.
|
||||
|
||||
## [2.4.3]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Export MatchPth typing.
|
||||
|
||||
## [2.4.2]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Add missing types field in package.json.
|
||||
|
||||
## [2.4.1]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Include declaration files. Fixes [#22](https://github.com/dividab/tsconfig-paths/issues/22).
|
||||
|
||||
## [2.4.0]
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed dependency for package `tsconfig`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Support for config inheritance with `extends`. Fixes [#17](https://github.com/dividab/tsconfig-paths/issues/17).
|
||||
|
||||
## [2.2.0]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue [#7](https://github.com/dividab/tsconfig-paths/issues/7).
|
||||
|
||||
## [2.1.2]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue [#6](https://github.com/dividab/tsconfig-paths/issues/6).
|
||||
|
||||
## [2.1.1]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue [#4](https://github.com/dividab/tsconfig-paths/issues/4)
|
||||
|
||||
## [2.1.0]
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed issue [#3](https://github.com/dividab/tsconfig-paths/issues/3)
|
||||
|
||||
## [2.0.0]
|
||||
|
||||
### Added
|
||||
|
||||
- We now look at `process.env.TS_NODE_PROJECT`
|
||||
- Functionality to bootstrap tsconfig-paths. Documentation in [README](https://github.com/dividab/tsconfig-paths/blob/master/README.md)
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed signature for `createMatchPath`. Now only takes absoluteUrl and paths.
|
||||
|
||||
## [1.1.0]
|
||||
|
||||
### Added
|
||||
|
||||
- More explanation to readme.
|
||||
- Match all extensions in require.extensions.
|
||||
- Match longest pattern prefix first as typesript does.
|
||||
- Match file in main field of package.json.
|
||||
- Check for index files explicitly.
|
||||
|
||||
## [1.0.0] - 2016-12-30
|
||||
|
||||
- First stable release.
|
||||
|
||||
## [0.4.0] - 2016-12-30
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed project to `tsocnfig-paths`.
|
||||
|
||||
## [0.3.0] - 2016-12-30
|
||||
|
||||
### Added
|
||||
|
||||
- API documentation.
|
||||
- `createMatchPath` function.
|
||||
- `matchFromAbsolutePaths` function.
|
||||
|
||||
### Removed
|
||||
|
||||
- `findPath` function.
|
||||
|
||||
## [0.2.1] - 2016-12-29
|
||||
|
||||
### Fixed
|
||||
|
||||
- `tsconfig-paths/register` was not available.
|
||||
|
||||
## [0.2.0] - 2016-12-29
|
||||
|
||||
### Fixed
|
||||
|
||||
- Paths for files in sub-dirs.
|
||||
|
||||
### Added
|
||||
|
||||
- Programmatic use.
|
||||
|
||||
## [0.1.2] - 2016-12-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed wrong name of the package in README.
|
||||
- Add missing files on publish.
|
||||
|
||||
## [0.1.1] - 2016-12-28
|
||||
|
||||
### Added
|
||||
|
||||
- Loading of tsconfig.
|
||||
- Example.
|
||||
- Publish scripts.
|
||||
|
||||
## [0.1.0] - 2016-12-28
|
||||
|
||||
- Initial version.
|
||||
|
||||
[unreleased]: https://github.com/dividab/tsconfig-paths/compare/v3.9.0...master
|
||||
[3.9.0]: https://github.com/dividab/tsconfig-paths/compare/v3.8.0...v3.9.0
|
||||
[3.8.0]: https://github.com/dividab/tsconfig-paths/compare/3.7.0...3.8.0
|
||||
[3.7.0]: https://github.com/dividab/tsconfig-paths/compare/3.6.0...3.7.0
|
||||
[3.6.0]: https://github.com/dividab/tsconfig-paths/compare/3.5.0...3.6.0
|
||||
[3.5.0]: https://github.com/dividab/tsconfig-paths/compare/3.4.2...3.5.0
|
||||
[3.4.2]: https://github.com/dividab/tsconfig-paths/compare/3.4.1...3.4.2
|
||||
[3.4.1]: https://github.com/dividab/tsconfig-paths/compare/3.4.0...3.4.1
|
||||
[3.4.0]: https://github.com/dividab/tsconfig-paths/compare/3.3.2...3.4.0
|
||||
[3.3.2]: https://github.com/dividab/tsconfig-paths/compare/3.3.1...3.3.2
|
||||
[3.3.1]: https://github.com/dividab/tsconfig-paths/compare/3.3.0...3.3.1
|
||||
[3.3.0]: https://github.com/dividab/tsconfig-paths/compare/3.2.0...3.3.0
|
||||
[3.2.0]: https://github.com/dividab/tsconfig-paths/compare/3.1.3...3.2.0
|
||||
[3.1.3]: https://github.com/dividab/tsconfig-paths/compare/3.1.2...3.1.3
|
||||
[3.1.2]: https://github.com/dividab/tsconfig-paths/compare/3.1.1...3.1.2
|
||||
[3.1.1]: https://github.com/dividab/tsconfig-paths/compare/3.1.0...3.1.1
|
||||
[3.1.0]: https://github.com/dividab/tsconfig-paths/compare/3.0.0...3.1.0
|
||||
[3.0.0]: https://github.com/dividab/tsconfig-paths/compare/2.7.3...3.0.0
|
||||
[2.7.3]: https://github.com/dividab/tsconfig-paths/compare/2.7.2...2.7.3
|
||||
[2.7.2]: https://github.com/dividab/tsconfig-paths/compare/2.7.1...2.7.2
|
||||
[2.7.1]: https://github.com/dividab/tsconfig-paths/compare/2.7.0...2.7.1
|
||||
[2.7.0]: https://github.com/dividab/tsconfig-paths/compare/2.6.0...2.7.0
|
||||
[2.6.0]: https://github.com/dividab/tsconfig-paths/compare/2.5.0...2.6.0
|
||||
[2.5.0]: https://github.com/dividab/tsconfig-paths/compare/2.4.3...2.5.0
|
||||
[2.4.3]: https://github.com/dividab/tsconfig-paths/compare/2.4.2...2.4.3
|
||||
[2.4.2]: https://github.com/dividab/tsconfig-paths/compare/2.4.1...2.4.2
|
||||
[2.4.1]: https://github.com/dividab/tsconfig-paths/compare/2.4.0...2.4.1
|
||||
[2.4.0]: https://github.com/dividab/tsconfig-paths/compare/2.2.0...2.4.0
|
||||
[2.2.0]: https://github.com/dividab/tsconfig-paths/compare/2.1.2...2.2.0
|
||||
[2.1.2]: https://github.com/dividab/tsconfig-paths/compare/2.1.1...2.1.2
|
||||
[2.1.1]: https://github.com/dividab/tsconfig-paths/compare/2.1.0...2.1.1
|
||||
21
capabilities/testdrive-jsui/node_modules/tsconfig-paths/LICENSE
generated
vendored
Normal file
21
capabilities/testdrive-jsui/node_modules/tsconfig-paths/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Jonas Kello
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
268
capabilities/testdrive-jsui/node_modules/tsconfig-paths/README.md
generated
vendored
Normal file
268
capabilities/testdrive-jsui/node_modules/tsconfig-paths/README.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
# tsconfig-paths
|
||||
|
||||
[![npm version][version-image]][version-url]
|
||||
[![build][build-image]][build-url]
|
||||
[![Coverage Status][codecov-image]][codecov-url]
|
||||
[![MIT license][license-image]][license-url]
|
||||
[![code style: prettier][prettier-image]][prettier-url]
|
||||
|
||||
Use this to load modules whose location is specified in the `paths` section of `tsconfig.json`. Both loading at run-time and via API are supported.
|
||||
|
||||
Typescript by default mimics the Node.js runtime resolution strategy of modules. But it also allows the use of [path mapping](https://www.typescriptlang.org/docs/handbook/module-resolution.html) which allows arbitrary module paths (that doesn't start with "/" or ".") to be specified and mapped to physical paths in the filesystem. The typescript compiler can resolve these paths from `tsconfig` so it will compile OK. But if you then try to execute the compiled files with node (or ts-node), it will only look in the `node_modules` folders all the way up to the root of the filesystem and thus will not find the modules specified by `paths` in `tsconfig`.
|
||||
|
||||
If you require this package's `tsconfig-paths/register` module it will read the `paths` from `tsconfig.json` and convert node's module loading calls into to physical file paths that node can load.
|
||||
|
||||
## How to install
|
||||
|
||||
```
|
||||
yarn add --dev tsconfig-paths
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
npm install --save-dev tsconfig-paths
|
||||
```
|
||||
|
||||
## How to use
|
||||
|
||||
### With node
|
||||
|
||||
`node -r tsconfig-paths/register main.js`
|
||||
|
||||
If `process.env.TS_NODE_BASEURL` is set it will override the value of `baseUrl` in tsconfig.json:
|
||||
|
||||
`TS_NODE_BASEURL=./dist node -r tsconfig-paths/register main.js`
|
||||
|
||||
### With ts-node
|
||||
|
||||
`ts-node -r tsconfig-paths/register main.ts`
|
||||
|
||||
If `process.env.TS_NODE_PROJECT` is set it will be used to resolved tsconfig.json
|
||||
|
||||
### With webpack
|
||||
|
||||
For webpack please use the [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin).
|
||||
|
||||
### With mocha and ts-node
|
||||
|
||||
As of Mocha >= 4.0.0 the `--compiler` was [deprecated](https://github.com/mochajs/mocha/wiki/compilers-deprecation). Instead `--require` should be used. You also have to specify a glob that includes `.ts` files because mocha looks after files with `.js` extension by default.
|
||||
|
||||
```bash
|
||||
mocha -r ts-node/register -r tsconfig-paths/register "test/**/*.ts"
|
||||
```
|
||||
|
||||
### With other commands
|
||||
|
||||
As long as the command has something similar to a `--require` option that can load a module before it starts, tsconfig-paths should be able to work with it.
|
||||
|
||||
### With `ts-node` and VSCode
|
||||
|
||||
The following is an example configuration for the `.vscode/launch.json`.
|
||||
|
||||
```js
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug Functions",
|
||||
"request": "launch",
|
||||
"type": "node",
|
||||
"runtimeArgs": [
|
||||
"-r",
|
||||
"${workspaceFolder}/functions/node_modules/ts-node/register",
|
||||
"-r",
|
||||
"${workspaceFolder}/functions/node_modules/tsconfig-paths/register"
|
||||
],
|
||||
"args": ["${workspaceFolder}/functions/src/index.ts"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"protocol": "inspector",
|
||||
"env": {
|
||||
"NODE_ENV": "development",
|
||||
"TS_NODE_PROJECT": "${workspaceFolder}/functions/tsconfig.json"
|
||||
},
|
||||
"outFiles": ["${workspaceFolder}/functions/lib/**/*.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Bootstrapping with explicit params
|
||||
|
||||
If you want more granular control over tsconfig-paths you can bootstrap it. This can be useful if you for instance have compiled with `tsc` to another directory where `tsconfig.json` doesn't exists.
|
||||
|
||||
For example, create a wrapper script called `tsconfig-paths-bootstrap.js` with the contents below:
|
||||
|
||||
```javascript
|
||||
const tsConfig = require("./tsconfig.json");
|
||||
const tsConfigPaths = require("tsconfig-paths");
|
||||
|
||||
const baseUrl = "./"; // Either absolute or relative path. If relative it's resolved to current working directory.
|
||||
const cleanup = tsConfigPaths.register({
|
||||
baseUrl,
|
||||
paths: tsConfig.compilerOptions.paths,
|
||||
});
|
||||
|
||||
// When path registration is no longer needed
|
||||
cleanup();
|
||||
```
|
||||
|
||||
Then run with:
|
||||
|
||||
`node -r ./tsconfig-paths-bootstrap.js main.js`
|
||||
|
||||
## Configuration Options
|
||||
|
||||
You can set options by passing them before the script path, via programmatic usage or via environment variables.
|
||||
|
||||
```bash
|
||||
ts-node --project customLocation/tsconfig.json -r tsconfig-paths/register "test/**/*.ts"
|
||||
```
|
||||
|
||||
### CLI and Programmatic Options
|
||||
|
||||
_Environment variable denoted in parentheses._
|
||||
|
||||
- `-P, --project [path]` Path to TypeScript JSON project file (`TS_NODE_PROJECT`)
|
||||
|
||||
## Config loading process
|
||||
|
||||
1. Use explicit params passed to register
|
||||
2. Use `process.env.TS_NODE_PROJECT` to resolve tsConfig.json and the specified baseUrl and paths.
|
||||
3. Resolves tsconfig.json from current working directory and the specified baseUrl and paths.
|
||||
|
||||
## Programmatic use
|
||||
|
||||
The public API consists of these functions:
|
||||
|
||||
- [register](#register)
|
||||
- [loadConfig](#loadConfig)
|
||||
- [createMatchPath](#createMatchPath) / [createMatchPathAsync](#createMatchPathAsync)
|
||||
- [matchFromAbsolutePaths](#matchFromAbsolutePaths) / [matchFromAbsolutePathsAsync](#matchFromAbsolutePathsAsync)
|
||||
|
||||
### register
|
||||
|
||||
```typescript
|
||||
export interface ExplicitParams {
|
||||
baseUrl: string;
|
||||
paths: { [key: string]: Array<string> };
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
*/
|
||||
export function register(explicitParams: ExplicitParams): () => void;
|
||||
```
|
||||
|
||||
This function will patch the node's module loading so it will look for modules in paths specified by tsconfig.json.
|
||||
A function is returned for you to reinstate Node's original module loading.
|
||||
|
||||
### loadConfig
|
||||
|
||||
```typescript
|
||||
export function loadConfig(cwd: string = process.cwd()): ConfigLoaderResult;
|
||||
|
||||
export type ConfigLoaderResult =
|
||||
| ConfigLoaderSuccessResult
|
||||
| ConfigLoaderFailResult;
|
||||
|
||||
export interface ConfigLoaderSuccessResult {
|
||||
resultType: "success";
|
||||
absoluteBaseUrl: string;
|
||||
paths: { [key: string]: Array<string> };
|
||||
}
|
||||
|
||||
export interface ConfigLoaderFailResult {
|
||||
resultType: "failed";
|
||||
message: string;
|
||||
}
|
||||
```
|
||||
|
||||
This function loads the tsconfig.json. It will start searching from the specified `cwd` directory. Passing the tsconfig.json file directly instead of a directory also works.
|
||||
|
||||
### createMatchPath
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Function that can match a path
|
||||
*/
|
||||
export interface MatchPath {
|
||||
(
|
||||
requestedModule: string,
|
||||
readJson?: Filesystem.ReadJsonSync,
|
||||
fileExists?: (name: string) => boolean,
|
||||
extensions?: ReadonlyArray<string>
|
||||
): string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that can resolve paths according to tsconfig paths property.
|
||||
* @param absoluteBaseUrl Absolute version of baseUrl as specified in tsconfig.
|
||||
* @param paths The paths as specified in tsconfig.
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @param addMatchAll Add a match-all "*" rule if none is present
|
||||
* @returns a function that can resolve paths.
|
||||
*/
|
||||
export function createMatchPath(
|
||||
absoluteBaseUrl: string,
|
||||
paths: { [key: string]: Array<string> },
|
||||
mainFields: string[] = ["main"],
|
||||
addMatchAll: boolean = true
|
||||
): MatchPath {
|
||||
```
|
||||
|
||||
The `createMatchPath` function will create a function that can match paths. It accepts `baseUrl` and `paths` directly as they are specified in tsconfig and will handle resolving paths to absolute form. The created function has the signature specified by the type `MatchPath` above.
|
||||
|
||||
### matchFromAbsolutePaths
|
||||
|
||||
```typescript
|
||||
/**
|
||||
* Finds a path from tsconfig that matches a module load request.
|
||||
* @param absolutePathMappings The paths to try as specified in tsconfig but resolved to absolute form.
|
||||
* @param requestedModule The required module name.
|
||||
* @param readJson Function that can read json from a path (useful for testing).
|
||||
* @param fileExists Function that checks for existence of a file at a path (useful for testing).
|
||||
* @param extensions File extensions to probe for (useful for testing).
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @returns the found path, or undefined if no path was found.
|
||||
*/
|
||||
export function matchFromAbsolutePaths(
|
||||
absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>,
|
||||
requestedModule: string,
|
||||
readJson: Filesystem.ReadJsonSync = Filesystem.readJsonFromDiskSync,
|
||||
fileExists: Filesystem.FileExistsSync = Filesystem.fileExistsSync,
|
||||
extensions: Array<string> = Object.keys(require.extensions),
|
||||
mainFields: string[] = ["main"]
|
||||
): string | undefined {
|
||||
```
|
||||
|
||||
This function is lower level and requires that the paths as already been resolved to absolute form and sorted in correct order into an array.
|
||||
|
||||
### createMatchPathAsync
|
||||
|
||||
This is the async version of `createMatchPath`. It has the same signature but with a callback parameter for the result.
|
||||
|
||||
### matchFromAbsolutePathsAsync
|
||||
|
||||
This is the async version of `matchFromAbsolutePaths`. It has the same signature but with a callback parameter for the result.
|
||||
|
||||
## How to publish
|
||||
|
||||
```
|
||||
yarn version --patch
|
||||
yarn version --minor
|
||||
yarn version --major
|
||||
```
|
||||
|
||||
[version-image]: https://img.shields.io/npm/v/tsconfig-paths.svg?style=flat
|
||||
[version-url]: https://www.npmjs.com/package/tsconfig-paths
|
||||
[build-image]: https://github.com/dividab/tsconfig-paths/workflows/CI/badge.svg
|
||||
[build-url]: https://github.com/dividab/tsconfig-paths/actions/workflows/ci.yml?query=branch%3Amaster
|
||||
[codecov-image]: https://codecov.io/gh/dividab/tsconfig-paths/branch/master/graph/badge.svg
|
||||
[codecov-url]: https://codecov.io/gh/dividab/tsconfig-paths
|
||||
[license-image]: https://img.shields.io/github/license/dividab/tsconfig-paths.svg?style=flat
|
||||
[license-url]: https://opensource.org/licenses/MIT
|
||||
[prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg
|
||||
[prettier-url]: https://github.com/prettier/prettier
|
||||
1
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/.bin/json5
generated
vendored
Symbolic link
1
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/.bin/json5
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../json5/lib/cli.js
|
||||
23
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/LICENSE.md
generated
vendored
Normal file
23
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2018 Aseem Kishore, and [others].
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
[others]: https://github.com/json5/json5/contributors
|
||||
234
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/README.md
generated
vendored
Normal file
234
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/README.md
generated
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
# JSON5 – JSON for Humans
|
||||
|
||||
[][Build Status]
|
||||
[][Coverage
|
||||
Status]
|
||||
|
||||
The JSON5 Data Interchange Format (JSON5) is a superset of [JSON] that aims to
|
||||
alleviate some of the limitations of JSON by expanding its syntax to include
|
||||
some productions from [ECMAScript 5.1].
|
||||
|
||||
This JavaScript library is the official reference implementation for JSON5
|
||||
parsing and serialization libraries.
|
||||
|
||||
[Build Status]: https://travis-ci.org/json5/json5
|
||||
|
||||
[Coverage Status]: https://coveralls.io/github/json5/json5
|
||||
|
||||
[JSON]: https://tools.ietf.org/html/rfc7159
|
||||
|
||||
[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/
|
||||
|
||||
## Summary of Features
|
||||
The following ECMAScript 5.1 features, which are not supported in JSON, have
|
||||
been extended to JSON5.
|
||||
|
||||
### Objects
|
||||
- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.
|
||||
- Objects may have a single trailing comma.
|
||||
|
||||
### Arrays
|
||||
- Arrays may have a single trailing comma.
|
||||
|
||||
### Strings
|
||||
- Strings may be single quoted.
|
||||
- Strings may span multiple lines by escaping new line characters.
|
||||
- Strings may include character escapes.
|
||||
|
||||
### Numbers
|
||||
- Numbers may be hexadecimal.
|
||||
- Numbers may have a leading or trailing decimal point.
|
||||
- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.
|
||||
- Numbers may begin with an explicit plus sign.
|
||||
|
||||
### Comments
|
||||
- Single and multi-line comments are allowed.
|
||||
|
||||
### White Space
|
||||
- Additional white space characters are allowed.
|
||||
|
||||
[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6
|
||||
|
||||
[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933
|
||||
|
||||
## Short Example
|
||||
```js
|
||||
{
|
||||
// comments
|
||||
unquoted: 'and you can quote me on that',
|
||||
singleQuotes: 'I can use "double quotes" here',
|
||||
lineBreaks: "Look, Mom! \
|
||||
No \\n's!",
|
||||
hexadecimal: 0xdecaf,
|
||||
leadingDecimalPoint: .8675309, andTrailing: 8675309.,
|
||||
positiveSign: +1,
|
||||
trailingComma: 'in objects', andIn: ['arrays',],
|
||||
"backwardsCompatible": "with JSON",
|
||||
}
|
||||
```
|
||||
|
||||
## Specification
|
||||
For a detailed explanation of the JSON5 format, please read the [official
|
||||
specification](https://json5.github.io/json5-spec/).
|
||||
|
||||
## Installation
|
||||
### Node.js
|
||||
```sh
|
||||
npm install json5
|
||||
```
|
||||
|
||||
```js
|
||||
const JSON5 = require('json5')
|
||||
```
|
||||
|
||||
### Browsers
|
||||
```html
|
||||
<script src="https://unpkg.com/json5@^1.0.0"></script>
|
||||
```
|
||||
|
||||
This will create a global `JSON5` variable.
|
||||
|
||||
## API
|
||||
The JSON5 API is compatible with the [JSON API].
|
||||
|
||||
[JSON API]:
|
||||
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON
|
||||
|
||||
### JSON5.parse()
|
||||
Parses a JSON5 string, constructing the JavaScript value or object described by
|
||||
the string. An optional reviver function can be provided to perform a
|
||||
transformation on the resulting object before it is returned.
|
||||
|
||||
#### Syntax
|
||||
JSON5.parse(text[, reviver])
|
||||
|
||||
#### Parameters
|
||||
- `text`: The string to parse as JSON5.
|
||||
- `reviver`: If a function, this prescribes how the value originally produced by
|
||||
parsing is transformed, before being returned.
|
||||
|
||||
#### Return value
|
||||
The object corresponding to the given JSON5 text.
|
||||
|
||||
### JSON5.stringify()
|
||||
Converts a JavaScript value to a JSON5 string, optionally replacing values if a
|
||||
replacer function is specified, or optionally including only the specified
|
||||
properties if a replacer array is specified.
|
||||
|
||||
#### Syntax
|
||||
JSON5.stringify(value[, replacer[, space]])
|
||||
JSON5.stringify(value[, options])
|
||||
|
||||
#### Parameters
|
||||
- `value`: The value to convert to a JSON5 string.
|
||||
- `replacer`: A function that alters the behavior of the stringification
|
||||
process, or an array of String and Number objects that serve as a whitelist
|
||||
for selecting/filtering the properties of the value object to be included in
|
||||
the JSON5 string. If this value is null or not provided, all properties of the
|
||||
object are included in the resulting JSON5 string.
|
||||
- `space`: A String or Number object that's used to insert white space into the
|
||||
output JSON5 string for readability purposes. If this is a Number, it
|
||||
indicates the number of space characters to use as white space; this number is
|
||||
capped at 10 (if it is greater, the value is just 10). Values less than 1
|
||||
indicate that no space should be used. If this is a String, the string (or the
|
||||
first 10 characters of the string, if it's longer than that) is used as white
|
||||
space. If this parameter is not provided (or is null), no white space is used.
|
||||
If white space is used, trailing commas will be used in objects and arrays.
|
||||
- `options`: An object with the following properties:
|
||||
- `replacer`: Same as the `replacer` parameter.
|
||||
- `space`: Same as the `space` parameter.
|
||||
- `quote`: A String representing the quote character to use when serializing
|
||||
strings.
|
||||
|
||||
#### Return value
|
||||
A JSON5 string representing the value.
|
||||
|
||||
### Node.js `require()` JSON5 files
|
||||
When using Node.js, you can `require()` JSON5 files by adding the following
|
||||
statement.
|
||||
|
||||
```js
|
||||
require('json5/lib/register')
|
||||
```
|
||||
|
||||
Then you can load a JSON5 file with a Node.js `require()` statement. For
|
||||
example:
|
||||
|
||||
```js
|
||||
const config = require('./config.json5')
|
||||
```
|
||||
|
||||
## CLI
|
||||
Since JSON is more widely used than JSON5, this package includes a CLI for
|
||||
converting JSON5 to JSON and for validating the syntax of JSON5 documents.
|
||||
|
||||
### Installation
|
||||
```sh
|
||||
npm install --global json5
|
||||
```
|
||||
|
||||
### Usage
|
||||
```sh
|
||||
json5 [options] <file>
|
||||
```
|
||||
|
||||
If `<file>` is not provided, then STDIN is used.
|
||||
|
||||
#### Options:
|
||||
- `-s`, `--space`: The number of spaces to indent or `t` for tabs
|
||||
- `-o`, `--out-file [file]`: Output to the specified file, otherwise STDOUT
|
||||
- `-v`, `--validate`: Validate JSON5 but do not output JSON
|
||||
- `-V`, `--version`: Output the version number
|
||||
- `-h`, `--help`: Output usage information
|
||||
|
||||
## Contibuting
|
||||
### Development
|
||||
```sh
|
||||
git clone https://github.com/json5/json5
|
||||
cd json5
|
||||
npm install
|
||||
```
|
||||
|
||||
When contributing code, please write relevant tests and run `npm test` and `npm
|
||||
run lint` before submitting pull requests. Please use an editor that supports
|
||||
[EditorConfig](http://editorconfig.org/).
|
||||
|
||||
### Issues
|
||||
To report bugs or request features regarding the JSON5 data format, please
|
||||
submit an issue to the [official specification
|
||||
repository](https://github.com/json5/json5-spec).
|
||||
|
||||
To report bugs or request features regarding the JavaScript implentation of
|
||||
JSON5, please submit an issue to this repository.
|
||||
|
||||
## License
|
||||
MIT. See [LICENSE.md](./LICENSE.md) for details.
|
||||
|
||||
## Credits
|
||||
[Assem Kishore](https://github.com/aseemk) founded this project.
|
||||
|
||||
[Michael Bolin](http://bolinfest.com/) independently arrived at and published
|
||||
some of these same ideas with awesome explanations and detail. Recommended
|
||||
reading: [Suggested Improvements to JSON](http://bolinfest.com/essays/json.html)
|
||||
|
||||
[Douglas Crockford](http://www.crockford.com/) of course designed and built
|
||||
JSON, but his state machine diagrams on the [JSON website](http://json.org/), as
|
||||
cheesy as it may sound, gave us motivation and confidence that building a new
|
||||
parser to implement these ideas was within reach! The original
|
||||
implementation of JSON5 was also modeled directly off of Doug’s open-source
|
||||
[json_parse.js] parser. We’re grateful for that clean and well-documented
|
||||
code.
|
||||
|
||||
[json_parse.js]:
|
||||
https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js
|
||||
|
||||
[Max Nanasy](https://github.com/MaxNanasy) has been an early and prolific
|
||||
supporter, contributing multiple patches and ideas.
|
||||
|
||||
[Andrew Eisenberg](https://github.com/aeisenberg) contributed the original
|
||||
`stringify` method.
|
||||
|
||||
[Jordan Tucker](https://github.com/jordanbtucker) has aligned JSON5 more closely
|
||||
with ES5, wrote the official JSON5 specification, completely rewrote the
|
||||
codebase from the ground up, and is actively maintaining this project.
|
||||
76
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/package.json
generated
vendored
Normal file
76
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/json5/package.json
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "json5",
|
||||
"version": "1.0.2",
|
||||
"description": "JSON for humans.",
|
||||
"main": "lib/index.js",
|
||||
"bin": "lib/cli.js",
|
||||
"browser": "dist/index.js",
|
||||
"files": [
|
||||
"lib/",
|
||||
"dist/"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "babel-node build/build.js && babel src -d lib && rollup -c",
|
||||
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
||||
"lint": "eslint --fix build src",
|
||||
"prepublishOnly": "npm run lint && npm test && npm run production",
|
||||
"pretest": "cross-env NODE_ENV=test npm run build",
|
||||
"preversion": "npm run lint && npm test && npm run production",
|
||||
"production": "cross-env NODE_ENV=production npm run build",
|
||||
"test": "nyc --reporter=html --reporter=text mocha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/json5/json5.git"
|
||||
},
|
||||
"keywords": [
|
||||
"json",
|
||||
"json5",
|
||||
"es5",
|
||||
"es2015",
|
||||
"ecmascript"
|
||||
],
|
||||
"author": "Aseem Kishore <aseem.kishore@gmail.com>",
|
||||
"contributors": [
|
||||
"Max Nanasy <max.nanasy@gmail.com>",
|
||||
"Andrew Eisenberg <andrew@eisenberg.as>",
|
||||
"Jordan Tucker <jordanbtucker@gmail.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/json5/json5/issues"
|
||||
},
|
||||
"homepage": "http://json5.org/",
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-plugin-add-module-exports": "^0.2.1",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-plugin-istanbul": "^4.1.5",
|
||||
"babel-preset-env": "^1.6.1",
|
||||
"babel-register": "^6.26.0",
|
||||
"babelrc-rollup": "^3.0.0",
|
||||
"coveralls": "^3.0.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"del": "^3.0.0",
|
||||
"eslint": "^4.18.2",
|
||||
"eslint-config-standard": "^11.0.0",
|
||||
"eslint-plugin-import": "^2.9.0",
|
||||
"eslint-plugin-node": "^6.0.1",
|
||||
"eslint-plugin-promise": "^3.7.0",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"mocha": "^5.0.4",
|
||||
"nyc": "^11.4.1",
|
||||
"regenerate": "^1.3.3",
|
||||
"rollup": "^0.56.5",
|
||||
"rollup-plugin-babel": "^3.0.3",
|
||||
"rollup-plugin-commonjs": "^9.0.0",
|
||||
"rollup-plugin-node-resolve": "^3.2.0",
|
||||
"rollup-plugin-uglify": "^3.0.0",
|
||||
"sinon": "^4.4.2",
|
||||
"unicode-9.0.0": "^0.7.5"
|
||||
}
|
||||
}
|
||||
14
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/index.js
generated
vendored
Normal file
14
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
module.exports = x => {
|
||||
if (typeof x !== 'string') {
|
||||
throw new TypeError('Expected a string, got ' + typeof x);
|
||||
}
|
||||
|
||||
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
|
||||
// conversion translates it to FEFF (UTF-16 BOM)
|
||||
if (x.charCodeAt(0) === 0xFEFF) {
|
||||
return x.slice(1);
|
||||
}
|
||||
|
||||
return x;
|
||||
};
|
||||
21
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/license
generated
vendored
Normal file
21
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
40
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/package.json
generated
vendored
Normal file
40
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "strip-bom",
|
||||
"version": "3.0.0",
|
||||
"description": "Strip UTF-8 byte order mark (BOM) from a string",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/strip-bom",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"strip",
|
||||
"bom",
|
||||
"byte",
|
||||
"order",
|
||||
"mark",
|
||||
"unicode",
|
||||
"utf8",
|
||||
"utf-8",
|
||||
"remove",
|
||||
"delete",
|
||||
"trim",
|
||||
"text",
|
||||
"string"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"xo": "*"
|
||||
}
|
||||
}
|
||||
36
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/readme.md
generated
vendored
Normal file
36
capabilities/testdrive-jsui/node_modules/tsconfig-paths/node_modules/strip-bom/readme.md
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# strip-bom [](https://travis-ci.org/sindresorhus/strip-bom)
|
||||
|
||||
> Strip UTF-8 [byte order mark](http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string
|
||||
|
||||
From Wikipedia:
|
||||
|
||||
> The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save strip-bom
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const stripBom = require('strip-bom');
|
||||
|
||||
stripBom('\uFEFFunicorn');
|
||||
//=> 'unicorn'
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [strip-bom-cli](https://github.com/sindresorhus/strip-bom-cli) - CLI for this module
|
||||
- [strip-bom-buf](https://github.com/sindresorhus/strip-bom-buf) - Buffer version of this module
|
||||
- [strip-bom-stream](https://github.com/sindresorhus/strip-bom-stream) - Stream version of this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
67
capabilities/testdrive-jsui/node_modules/tsconfig-paths/package.json
generated
vendored
Normal file
67
capabilities/testdrive-jsui/node_modules/tsconfig-paths/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "tsconfig-paths",
|
||||
"version": "3.15.0",
|
||||
"description": "Load node modules according to tsconfig paths, in run-time or via API.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"author": "Jonas Kello",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/dividab/tsconfig-paths",
|
||||
"files": [
|
||||
"/src",
|
||||
"/lib",
|
||||
"register.js",
|
||||
"package.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.3",
|
||||
"@types/minimist": "^1.2.2",
|
||||
"@types/node": "^6.0.54",
|
||||
"@types/strip-bom": "^3.0.0",
|
||||
"@types/strip-json-comments": "^0.0.30",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^27.3.1",
|
||||
"lint-staged": "^10.2.11",
|
||||
"prettier": "^2.0.5",
|
||||
"rimraf": "^2.6.2",
|
||||
"ts-jest": "^27.0.7",
|
||||
"ts-node": "^10.7.0",
|
||||
"tslint": "^5.8.0",
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/json5": "^0.0.29",
|
||||
"json5": "^1.0.2",
|
||||
"minimist": "^1.2.6",
|
||||
"strip-bom": "^3.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cd src && ts-node index.ts",
|
||||
"example:node": "yarn build && cd ./example/node && ts-node -r ../register.js main.ts",
|
||||
"example:project": "yarn build && ts-node -r ./register.js -P ./example/project/tsconfig.json ./example/project/main.ts",
|
||||
"example:api": "cd example/api && ts-node main.ts",
|
||||
"example:perf": "cd example/perf && ts-node main.ts",
|
||||
"test": "jest",
|
||||
"test-coverage": "jest --coverage",
|
||||
"build": "rimraf lib && tsc -p .",
|
||||
"lint": "tslint './{src,tests}/**/*.ts{,x}'",
|
||||
"verify": "yarn build && yarn lint && yarn test-coverage",
|
||||
"preversion": "yarn verify",
|
||||
"postversion": "git push --tags && yarn publish --new-version $npm_package_version && git push && echo \"Successfully released version $npm_package_version!\""
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx}": "tslint",
|
||||
"*.{ts,tsx,json,css}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
}
|
||||
}
|
||||
1
capabilities/testdrive-jsui/node_modules/tsconfig-paths/register.js
generated
vendored
Normal file
1
capabilities/testdrive-jsui/node_modules/tsconfig-paths/register.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
require("./").register();
|
||||
100
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/config-loader.test.ts
generated
vendored
Normal file
100
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/config-loader.test.ts
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
import {
|
||||
configLoader,
|
||||
loadConfig,
|
||||
ConfigLoaderFailResult,
|
||||
ConfigLoaderSuccessResult,
|
||||
} from "../config-loader";
|
||||
import { join } from "path";
|
||||
|
||||
describe("config-loader", (): void => {
|
||||
it("should use explicitParams when set", () => {
|
||||
const result = configLoader({
|
||||
explicitParams: {
|
||||
baseUrl: "/foo/bar",
|
||||
paths: {
|
||||
asd: ["asd"],
|
||||
},
|
||||
},
|
||||
cwd: "/baz",
|
||||
});
|
||||
|
||||
const successResult = result as ConfigLoaderSuccessResult;
|
||||
// assert.equal(successResult.resultType, "success");
|
||||
// assert.equal(successResult.absoluteBaseUrl, "/foo/bar");
|
||||
// assert.equal(successResult.paths["asd"][0], "asd");
|
||||
expect(successResult.resultType).toBe("success");
|
||||
expect(successResult.absoluteBaseUrl).toBe("/foo/bar");
|
||||
expect(successResult.paths["asd"][0]).toBe("asd");
|
||||
});
|
||||
|
||||
it("should use explicitParams when set and add cwd when path is relative", () => {
|
||||
const result = configLoader({
|
||||
explicitParams: {
|
||||
baseUrl: "bar/",
|
||||
paths: {
|
||||
asd: ["asd"],
|
||||
},
|
||||
},
|
||||
cwd: "/baz",
|
||||
});
|
||||
|
||||
const successResult = result as ConfigLoaderSuccessResult;
|
||||
// assert.equal(successResult.resultType, "success");
|
||||
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "bar/"));
|
||||
expect(successResult.resultType).toBe("success");
|
||||
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "bar/"));
|
||||
});
|
||||
|
||||
it("should fallback to tsConfigLoader when explicitParams is not set", () => {
|
||||
const result = configLoader({
|
||||
explicitParams: undefined,
|
||||
cwd: "/baz",
|
||||
// tslint:disable-next-line:no-any
|
||||
tsConfigLoader: (_: any) => ({
|
||||
tsConfigPath: "/baz/tsconfig.json",
|
||||
baseUrl: "./src",
|
||||
paths: {},
|
||||
}),
|
||||
});
|
||||
|
||||
const successResult = result as ConfigLoaderSuccessResult;
|
||||
// assert.equal(successResult.resultType, "success");
|
||||
// assert.equal(successResult.absoluteBaseUrl, join("/baz", "src"));
|
||||
expect(successResult.resultType).toBe("success");
|
||||
expect(successResult.absoluteBaseUrl).toBe(join("/baz", "src"));
|
||||
});
|
||||
|
||||
it("should show an error message when baseUrl is missing", () => {
|
||||
const result = configLoader({
|
||||
explicitParams: undefined,
|
||||
cwd: "/baz",
|
||||
// tslint:disable-next-line:no-any
|
||||
tsConfigLoader: (_: any) => ({
|
||||
tsConfigPath: "/baz/tsconfig.json",
|
||||
baseUrl: undefined,
|
||||
paths: {},
|
||||
}),
|
||||
});
|
||||
|
||||
const failResult = result as ConfigLoaderFailResult;
|
||||
// assert.equal(failResult.resultType, "failed");
|
||||
// assert.isTrue(failResult.message.indexOf("baseUrl") > -1);
|
||||
expect(failResult.resultType).toBe("failed");
|
||||
expect(failResult.message.indexOf("baseUrl") > -1).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should presume cwd to be a tsconfig file when loadConfig is called with absolute path to tsconfig.json", () => {
|
||||
// using tsconfig-named.json to ensure that future changes to fix
|
||||
// https://github.com/dividab/tsconfig-paths/issues/31
|
||||
// do not pass this test case just because of a directory walk looking
|
||||
// for tsconfig.json
|
||||
const configFile = join(__dirname, "tsconfig-named.json");
|
||||
const result = loadConfig(configFile);
|
||||
|
||||
const successResult = result as ConfigLoaderSuccessResult;
|
||||
// assert.equal(successResult.resultType, "success");
|
||||
// assert.equal(successResult.configFileAbsolutePath, configFile);
|
||||
expect(successResult.resultType).toBe("success");
|
||||
expect(successResult.configFileAbsolutePath).toBe(configFile);
|
||||
});
|
||||
});
|
||||
219
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/data/match-path-data.ts
generated
vendored
Normal file
219
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/data/match-path-data.ts
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
import { join, dirname } from "path";
|
||||
import { removeExtension } from "../../filesystem";
|
||||
|
||||
export interface OneTest {
|
||||
readonly name: string;
|
||||
readonly only?: boolean;
|
||||
readonly skip?: boolean;
|
||||
readonly absoluteBaseUrl: string;
|
||||
readonly paths: { [key: string]: Array<string> };
|
||||
readonly mainFields?: string[];
|
||||
readonly addMatchAll?: boolean;
|
||||
readonly existingFiles: ReadonlyArray<string>;
|
||||
readonly requestedModule: string;
|
||||
readonly extensions: ReadonlyArray<string>;
|
||||
readonly packageJson?: {};
|
||||
readonly expectedPath: string | undefined;
|
||||
}
|
||||
|
||||
const defaultExtensionsWhenRunningInTsNode = [
|
||||
".js",
|
||||
".json",
|
||||
".node",
|
||||
".ts",
|
||||
".tsx",
|
||||
];
|
||||
|
||||
export const tests: ReadonlyArray<OneTest> = [
|
||||
{
|
||||
name: "should locate path that matches with star and exists",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {
|
||||
"lib/*": ["location/*"],
|
||||
},
|
||||
existingFiles: [join("/root", "location", "mylib", "index.ts")],
|
||||
requestedModule: "lib/mylib",
|
||||
expectedPath: dirname(join("/root", "location", "mylib", "index.ts")),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should resolve to correct path when many are specified",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {
|
||||
"lib/*": ["foo1/*", "foo2/*", "location/*", "foo3/*"],
|
||||
},
|
||||
existingFiles: [join("/root", "location", "mylib", "index.ts")],
|
||||
requestedModule: "lib/mylib",
|
||||
extensions: [".ts"],
|
||||
expectedPath: dirname(join("/root", "location", "mylib", "index.ts")),
|
||||
},
|
||||
{
|
||||
name:
|
||||
"should locate path that matches with star and prioritize pattern with longest prefix",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {
|
||||
"*": ["location/*"],
|
||||
"lib/*": ["location/*"],
|
||||
},
|
||||
existingFiles: [
|
||||
join("/root", "location", "lib", "mylib", "index.ts"),
|
||||
join("/root", "location", "mylib", "index.ts"),
|
||||
],
|
||||
requestedModule: "lib/mylib",
|
||||
expectedPath: dirname(join("/root", "location", "mylib", "index.ts")),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should locate path that matches with star and exists with extension",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "mylib.myext")],
|
||||
requestedModule: "lib/mylib",
|
||||
extensions: [".js", ".myext"],
|
||||
expectedPath: removeExtension(join("/root", "location", "mylib.myext")),
|
||||
},
|
||||
{
|
||||
name: "should resolve request with extension specified",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "test.jpg")],
|
||||
requestedModule: "lib/test.jpg",
|
||||
expectedPath: join("/root", "location", "test.jpg"),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should locate path that matches without star and exists",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {
|
||||
"lib/foo": ["location/foo"],
|
||||
},
|
||||
existingFiles: [join("/root", "location", "foo.ts")],
|
||||
requestedModule: "lib/foo",
|
||||
expectedPath: removeExtension(join("/root", "location", "foo.ts")),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should resolve to parent folder when filename is in subfolder",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "mylib", "index.ts")],
|
||||
requestedModule: "lib/mylib",
|
||||
expectedPath: dirname(join("/root", "location", "mylib", "index.ts")),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should resolve from main field in package.json",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "mylib", "kalle.ts")],
|
||||
packageJson: { main: "./kalle.ts" },
|
||||
requestedModule: "lib/mylib",
|
||||
expectedPath: join("/root", "location", "mylib", "kalle.ts"),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should resolve from main field in package.json (js)",
|
||||
absoluteBaseUrl: "/root",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "mylib.js", "kalle.js")],
|
||||
packageJson: { main: "./kalle.js" },
|
||||
requestedModule: "lib/mylib.js",
|
||||
extensions: [".ts", ".js"],
|
||||
expectedPath: join("/root", "location", "mylib.js", "kalle.js"),
|
||||
},
|
||||
{
|
||||
name: "should resolve from list of fields by priority in package.json",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
mainFields: ["missing", "browser", "main"],
|
||||
packageJson: { main: "./main.js", browser: "./browser.js" },
|
||||
existingFiles: [
|
||||
join("/root", "location", "mylibjs", "main.js"), // mainFilePath
|
||||
join("/root", "location", "mylibjs", "browser.js"), // browserFilePath
|
||||
],
|
||||
extensions: [".ts", ".js"],
|
||||
requestedModule: "lib/mylibjs",
|
||||
expectedPath: join("/root", "location", "mylibjs", "browser.js"),
|
||||
},
|
||||
{
|
||||
name: "should ignore field mappings to missing files in package.json",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
mainFields: ["browser", "main"],
|
||||
existingFiles: [join("/root", "location", "mylibjs", "kalle.js")],
|
||||
requestedModule: "lib/mylibjs",
|
||||
packageJson: {
|
||||
main: "./kalle.js",
|
||||
browser: "./nope.js",
|
||||
},
|
||||
extensions: [".ts", ".js"],
|
||||
expectedPath: join("/root", "location", "mylibjs", "kalle.js"),
|
||||
},
|
||||
{
|
||||
name: "should ignore advanced field mappings in package.json",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [
|
||||
join("/root", "location", "mylibjs", "kalle.js"),
|
||||
join("/root", "location", "mylibjs", "browser.js"),
|
||||
],
|
||||
requestedModule: "lib/mylibjs",
|
||||
packageJson: {
|
||||
main: "./kalle.js",
|
||||
browser: { mylibjs: "./browser.js", "./kalle.js": "./browser.js" },
|
||||
},
|
||||
extensions: [".ts", ".js"],
|
||||
expectedPath: join("/root", "location", "mylibjs", "kalle.js"),
|
||||
},
|
||||
{
|
||||
name: "should resolve to with the help of baseUrl when not explicitly set",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {},
|
||||
existingFiles: [join("/root", "mylib", "index.ts")],
|
||||
requestedModule: "mylib",
|
||||
expectedPath: dirname(join("/root", "mylib", "index.ts")),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should not resolve with the help of baseUrl when asked not to",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {},
|
||||
addMatchAll: false,
|
||||
existingFiles: [join("/root", "mylib", "index.ts")],
|
||||
requestedModule: "mylib",
|
||||
expectedPath: undefined,
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should not locate path that does not match",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("root", "location", "mylib")],
|
||||
requestedModule: "mylib",
|
||||
expectedPath: undefined,
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should not resolve typings file (index.d.ts)",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {
|
||||
"lib/*": ["location/*"],
|
||||
},
|
||||
existingFiles: [join("/root", "location", "mylib", "index.d.ts")],
|
||||
requestedModule: "lib/mylib",
|
||||
expectedPath: undefined,
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
{
|
||||
name: "should resolve main file with cjs file extension",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: {},
|
||||
existingFiles: [join("/root", "mylib", "index.cjs")],
|
||||
packageJson: {
|
||||
main: "./index.cjs",
|
||||
},
|
||||
requestedModule: "mylib",
|
||||
expectedPath: join("/root", "mylib", "index.cjs"),
|
||||
extensions: defaultExtensionsWhenRunningInTsNode,
|
||||
},
|
||||
];
|
||||
65
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
generated
vendored
Normal file
65
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/filesystem.test.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import * as Filesystem from "../filesystem";
|
||||
import * as path from "path";
|
||||
|
||||
describe("filesystem", () => {
|
||||
const fileThatExists = path.join(__dirname, "../../package.json");
|
||||
const fileThatNotExists = path.join(__dirname, "../../package2.json");
|
||||
|
||||
it("should find file that exists, sync", () => {
|
||||
const result = Filesystem.fileExistsSync(fileThatExists);
|
||||
// assert.equal(result, true);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("should not find file that not exists, sync", () => {
|
||||
const result = Filesystem.fileExistsSync(fileThatNotExists);
|
||||
// assert.equal(result, false);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("should find file that exists, async", (done) => {
|
||||
Filesystem.fileExistsAsync(fileThatExists, (_err, result) => {
|
||||
try {
|
||||
// assert.equal(result, true);
|
||||
expect(result).toBe(true);
|
||||
done();
|
||||
} catch (error) {
|
||||
done(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should not find file that not exists, async", (done) => {
|
||||
Filesystem.fileExistsAsync(fileThatNotExists, (_err, result) => {
|
||||
try {
|
||||
// assert.equal(result, false);
|
||||
expect(result).toBe(false);
|
||||
done();
|
||||
} catch (error) {
|
||||
done(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should load json, sync", () => {
|
||||
const result = Filesystem.readJsonFromDiskSync(fileThatExists);
|
||||
// assert.isOk(result);
|
||||
expect(result);
|
||||
// assert.equal(result.main, "lib/index.js");
|
||||
expect(result.main).toBe("lib/index.js");
|
||||
});
|
||||
|
||||
it("should load json, async", (done) => {
|
||||
Filesystem.readJsonFromDiskAsync(fileThatExists, (_err, result) => {
|
||||
try {
|
||||
// assert.isOk(result); // Asserts that object is truthy.
|
||||
expect(result).toBeTruthy();
|
||||
// assert.equal(result.main, "lib/index.js");
|
||||
expect(result.main).toBe("lib/index.js");
|
||||
done();
|
||||
} catch (error) {
|
||||
done(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
70
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/mapping-entry.test.ts
generated
vendored
Normal file
70
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/mapping-entry.test.ts
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
import { getAbsoluteMappingEntries } from "../mapping-entry";
|
||||
import { join } from "path";
|
||||
|
||||
describe("mapping-entry", () => {
|
||||
it("should change to absolute paths and sort in longest prefix order", () => {
|
||||
const result = getAbsoluteMappingEntries(
|
||||
"/absolute/base/url",
|
||||
{
|
||||
"*": ["/foo1", "/foo2"],
|
||||
"longest/pre/fix/*": ["/foo2/bar"],
|
||||
"pre/fix/*": ["/foo3"],
|
||||
},
|
||||
true
|
||||
);
|
||||
// assert.deepEqual(result, [
|
||||
// {
|
||||
// pattern: "longest/pre/fix/*",
|
||||
// paths: [join("/absolute", "base", "url", "foo2", "bar")],
|
||||
// },
|
||||
// {
|
||||
// pattern: "pre/fix/*",
|
||||
// paths: [join("/absolute", "base", "url", "foo3")],
|
||||
// },
|
||||
// {
|
||||
// pattern: "*",
|
||||
// paths: [
|
||||
// join("/absolute", "base", "url", "foo1"),
|
||||
// join("/absolute", "base", "url", "foo2"),
|
||||
// ],
|
||||
// },
|
||||
// ]);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
pattern: "longest/pre/fix/*",
|
||||
paths: [join("/absolute", "base", "url", "foo2", "bar")],
|
||||
},
|
||||
{
|
||||
pattern: "pre/fix/*",
|
||||
paths: [join("/absolute", "base", "url", "foo3")],
|
||||
},
|
||||
{
|
||||
pattern: "*",
|
||||
paths: [
|
||||
join("/absolute", "base", "url", "foo1"),
|
||||
join("/absolute", "base", "url", "foo2"),
|
||||
],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should should add a match-all pattern when requested", () => {
|
||||
let result = getAbsoluteMappingEntries("/absolute/base/url", {}, true);
|
||||
// assert.deepEqual(result, [
|
||||
// {
|
||||
// pattern: "*",
|
||||
// paths: [join("/absolute", "base", "url", "*")],
|
||||
// },
|
||||
// ]);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
pattern: "*",
|
||||
paths: [join("/absolute", "base", "url", "*")],
|
||||
},
|
||||
]);
|
||||
|
||||
result = getAbsoluteMappingEntries("/absolute/base/url", {}, false);
|
||||
// assert.deepEqual(result, []);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
});
|
||||
27
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/match-path-async.test.ts
generated
vendored
Normal file
27
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/match-path-async.test.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { createMatchPathAsync } from "../match-path-async";
|
||||
import * as Tests from "./data/match-path-data";
|
||||
|
||||
describe("match-path-async", () => {
|
||||
Tests.tests.forEach((t) =>
|
||||
it(t.name, (done) => {
|
||||
const matchPath = createMatchPathAsync(
|
||||
t.absoluteBaseUrl,
|
||||
t.paths,
|
||||
t.mainFields,
|
||||
t.addMatchAll
|
||||
);
|
||||
matchPath(
|
||||
t.requestedModule,
|
||||
(_path, callback) => callback(undefined, t.packageJson),
|
||||
(path, callback) =>
|
||||
callback(undefined, t.existingFiles.indexOf(path) !== -1),
|
||||
t.extensions,
|
||||
(_err, result) => {
|
||||
// assert.equal(result, t.expectedPath);
|
||||
expect(result).toBe(t.expectedPath);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
23
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/match-path-sync.test.ts
generated
vendored
Normal file
23
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/match-path-sync.test.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { createMatchPath } from "../match-path-sync";
|
||||
import * as Tests from "./data/match-path-data";
|
||||
|
||||
describe("match-path-sync", () => {
|
||||
Tests.tests.forEach((t) =>
|
||||
it(t.name, () => {
|
||||
const matchPath = createMatchPath(
|
||||
t.absoluteBaseUrl,
|
||||
t.paths,
|
||||
t.mainFields,
|
||||
t.addMatchAll
|
||||
);
|
||||
const result = matchPath(
|
||||
t.requestedModule,
|
||||
(_: string) => t.packageJson,
|
||||
(name: string) => t.existingFiles.indexOf(name) !== -1,
|
||||
t.extensions
|
||||
);
|
||||
// assert.equal(result, t.expectedPath);
|
||||
expect(result).toBe(t.expectedPath);
|
||||
})
|
||||
);
|
||||
});
|
||||
193
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/try-path.test.ts
generated
vendored
Normal file
193
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/try-path.test.ts
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
import { getPathsToTry } from "../try-path";
|
||||
import { join } from "path";
|
||||
|
||||
describe("mapping-entry", () => {
|
||||
const abosolutePathMappings = [
|
||||
{
|
||||
pattern: "longest/pre/fix/*",
|
||||
paths: [join("/absolute", "base", "url", "foo2", "bar")],
|
||||
},
|
||||
{ pattern: "pre/fix/*", paths: [join("/absolute", "base", "url", "foo3")] },
|
||||
{ pattern: "*", paths: [join("/absolute", "base", "url", "foo1")] },
|
||||
];
|
||||
const abosolutePathMappingsStarstWithSlash = [
|
||||
{
|
||||
pattern: "/opt/*",
|
||||
paths: [join("/absolute", "src", "aws-layer")],
|
||||
},
|
||||
{
|
||||
pattern: "*",
|
||||
paths: [join("/absolute", "src")],
|
||||
},
|
||||
];
|
||||
it("should return no paths for relative requested module", () => {
|
||||
const result = getPathsToTry(
|
||||
[".ts", "tsx"],
|
||||
abosolutePathMappings,
|
||||
"./requested-module"
|
||||
);
|
||||
// assert.deepEqual(result, undefined);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return no paths if no pattern match the requested module", () => {
|
||||
const result = getPathsToTry(
|
||||
[".ts", "tsx"],
|
||||
[
|
||||
{
|
||||
pattern: "longest/pre/fix/*",
|
||||
paths: [join("/absolute", "base", "url", "foo2", "bar")],
|
||||
},
|
||||
{
|
||||
pattern: "pre/fix/*",
|
||||
paths: [join("/absolute", "base", "url", "foo3")],
|
||||
},
|
||||
],
|
||||
"requested-module"
|
||||
);
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should get all paths that matches requested module", () => {
|
||||
const result = getPathsToTry(
|
||||
[".ts", ".tsx"],
|
||||
abosolutePathMappings,
|
||||
"longest/pre/fix/requested-module"
|
||||
);
|
||||
// assert.deepEqual(result, [
|
||||
// // "longest/pre/fix/*"
|
||||
// { type: "file", path: join("/absolute", "base", "url", "foo2", "bar") },
|
||||
// {
|
||||
// type: "extension",
|
||||
// path: join("/absolute", "base", "url", "foo2", "bar.ts"),
|
||||
// },
|
||||
// {
|
||||
// type: "extension",
|
||||
// path: join("/absolute", "base", "url", "foo2", "bar.tsx"),
|
||||
// },
|
||||
// {
|
||||
// type: "package",
|
||||
// path: join("/absolute", "base", "url", "foo2", "bar", "package.json"),
|
||||
// },
|
||||
// {
|
||||
// type: "index",
|
||||
// path: join("/absolute", "base", "url", "foo2", "bar", "index.ts"),
|
||||
// },
|
||||
// {
|
||||
// type: "index",
|
||||
// path: join("/absolute", "base", "url", "foo2", "bar", "index.tsx"),
|
||||
// },
|
||||
// // "*"
|
||||
// { type: "file", path: join("/absolute", "base", "url", "foo1") },
|
||||
// { type: "extension", path: join("/absolute", "base", "url", "foo1.ts") },
|
||||
// { type: "extension", path: join("/absolute", "base", "url", "foo1.tsx") },
|
||||
// {
|
||||
// type: "package",
|
||||
// path: join("/absolute", "base", "url", "foo1", "package.json"),
|
||||
// },
|
||||
// {
|
||||
// type: "index",
|
||||
// path: join("/absolute", "base", "url", "foo1", "index.ts"),
|
||||
// },
|
||||
// {
|
||||
// type: "index",
|
||||
// path: join("/absolute", "base", "url", "foo1", "index.tsx"),
|
||||
// },
|
||||
// ]);
|
||||
expect(result).toEqual([
|
||||
// "longest/pre/fix/*"
|
||||
{ type: "file", path: join("/absolute", "base", "url", "foo2", "bar") },
|
||||
{
|
||||
type: "extension",
|
||||
path: join("/absolute", "base", "url", "foo2", "bar.ts"),
|
||||
},
|
||||
{
|
||||
type: "extension",
|
||||
path: join("/absolute", "base", "url", "foo2", "bar.tsx"),
|
||||
},
|
||||
{
|
||||
type: "package",
|
||||
path: join("/absolute", "base", "url", "foo2", "bar", "package.json"),
|
||||
},
|
||||
{
|
||||
type: "index",
|
||||
path: join("/absolute", "base", "url", "foo2", "bar", "index.ts"),
|
||||
},
|
||||
{
|
||||
type: "index",
|
||||
path: join("/absolute", "base", "url", "foo2", "bar", "index.tsx"),
|
||||
},
|
||||
// "*"
|
||||
{ type: "file", path: join("/absolute", "base", "url", "foo1") },
|
||||
{ type: "extension", path: join("/absolute", "base", "url", "foo1.ts") },
|
||||
{ type: "extension", path: join("/absolute", "base", "url", "foo1.tsx") },
|
||||
{
|
||||
type: "package",
|
||||
path: join("/absolute", "base", "url", "foo1", "package.json"),
|
||||
},
|
||||
{
|
||||
type: "index",
|
||||
path: join("/absolute", "base", "url", "foo1", "index.ts"),
|
||||
},
|
||||
{
|
||||
type: "index",
|
||||
path: join("/absolute", "base", "url", "foo1", "index.tsx"),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("should resolve paths starting with a slash", () => {
|
||||
const result = getPathsToTry(
|
||||
[".ts"],
|
||||
abosolutePathMappingsStarstWithSlash,
|
||||
"/opt/utils"
|
||||
);
|
||||
expect(result).toEqual([
|
||||
// "opt/*"
|
||||
{
|
||||
path: join("/absolute", "src", "aws-layer"),
|
||||
type: "file",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src", "aws-layer.ts"),
|
||||
type: "extension",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src", "aws-layer", "package.json"),
|
||||
type: "package",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src", "aws-layer", "index.ts"),
|
||||
type: "index",
|
||||
},
|
||||
// "*"
|
||||
{
|
||||
path: join("/absolute", "src"),
|
||||
type: "file",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src.ts"),
|
||||
type: "extension",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src", "package.json"),
|
||||
type: "package",
|
||||
},
|
||||
{
|
||||
path: join("/absolute", "src", "index.ts"),
|
||||
type: "index",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// describe("match-star", () => {
|
||||
// it("should match star in last position", () => {
|
||||
// const result = matchStar("lib/*", "lib/mylib");
|
||||
// assert.equal(result, "mylib");
|
||||
// });
|
||||
// it("should match star in first position", () => {
|
||||
// const result = matchStar("*/lib", "mylib/lib");
|
||||
// assert.equal(result, "mylib");
|
||||
// });
|
||||
// });
|
||||
416
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/tsconfig-loader.test.ts
generated
vendored
Normal file
416
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/tsconfig-loader.test.ts
generated
vendored
Normal file
@@ -0,0 +1,416 @@
|
||||
import {
|
||||
loadTsconfig,
|
||||
tsConfigLoader,
|
||||
walkForTsConfig,
|
||||
} from "../tsconfig-loader";
|
||||
import { join } from "path";
|
||||
|
||||
describe("tsconfig-loader", () => {
|
||||
it("should find tsconfig in cwd", () => {
|
||||
const result = tsConfigLoader({
|
||||
cwd: "/foo/bar",
|
||||
getEnv: (_: string) => undefined,
|
||||
loadSync: (cwd: string) => {
|
||||
return {
|
||||
tsConfigPath: `${cwd}/tsconfig.json`,
|
||||
baseUrl: "./",
|
||||
paths: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// assert.equal(result.tsConfigPath, "/foo/bar/tsconfig.json");
|
||||
expect(result.tsConfigPath).toBe("/foo/bar/tsconfig.json");
|
||||
});
|
||||
|
||||
it("should return loaderResult.tsConfigPath as undefined when not found", () => {
|
||||
const result = tsConfigLoader({
|
||||
cwd: "/foo/bar",
|
||||
getEnv: (_: string) => undefined,
|
||||
loadSync: (_: string) => {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl: "./",
|
||||
paths: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// assert.isUndefined(result.tsConfigPath);
|
||||
expect(result.tsConfigPath).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should use TS_NODE_PROJECT env if exists", () => {
|
||||
const result = tsConfigLoader({
|
||||
cwd: "/foo/bar",
|
||||
getEnv: (key: string) =>
|
||||
key === "TS_NODE_PROJECT" ? "/foo/baz" : undefined,
|
||||
loadSync: (cwd: string, fileName: string) => {
|
||||
if (cwd === "/foo/bar" && fileName === "/foo/baz") {
|
||||
return {
|
||||
tsConfigPath: "/foo/baz/tsconfig.json",
|
||||
baseUrl: "./",
|
||||
paths: {},
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl: "./",
|
||||
paths: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// assert.equal(result.tsConfigPath, "/foo/baz/tsconfig.json");
|
||||
expect(result.tsConfigPath).toBe("/foo/baz/tsconfig.json");
|
||||
});
|
||||
|
||||
it("should use TS_NODE_BASEURL env if exists", () => {
|
||||
const result = tsConfigLoader({
|
||||
cwd: "/foo/bar",
|
||||
getEnv: (key: string) =>
|
||||
key === "TS_NODE_BASEURL" ? "SOME_BASEURL" : undefined,
|
||||
loadSync: (_0: string, _1: string, baseUrl: string) => {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl,
|
||||
paths: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// assert.equal(result.baseUrl, "SOME_BASEURL");
|
||||
expect(result.baseUrl).toBe("SOME_BASEURL");
|
||||
});
|
||||
|
||||
it("should not use TS_NODE_BASEURL env if it does not exist", () => {
|
||||
const result = tsConfigLoader({
|
||||
cwd: "/foo/bar",
|
||||
getEnv: (_: string) => {
|
||||
return undefined;
|
||||
},
|
||||
loadSync: (_0: string, _1: string, baseUrl: string) => {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl,
|
||||
paths: {},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
// assert.equal(result.baseUrl, undefined);
|
||||
expect(result.baseUrl).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("walkForTsConfig", () => {
|
||||
it("should find tsconfig in starting directory", () => {
|
||||
const pathToTsconfig = join("/root", "dir1", "tsconfig.json");
|
||||
const res = walkForTsConfig(
|
||||
join("/root", "dir1"),
|
||||
(path) => path === pathToTsconfig
|
||||
);
|
||||
// assert.equal(res, pathToTsconfig);
|
||||
expect(res).toBe(pathToTsconfig);
|
||||
});
|
||||
|
||||
it("should find tsconfig in parent directory", () => {
|
||||
const pathToTsconfig = join("/root", "tsconfig.json");
|
||||
const res = walkForTsConfig(
|
||||
join("/root", "dir1"),
|
||||
(path) => path === pathToTsconfig
|
||||
);
|
||||
// assert.equal(res, pathToTsconfig);
|
||||
expect(res).toBe(pathToTsconfig);
|
||||
});
|
||||
|
||||
it("should return undefined when reaching the top", () => {
|
||||
const res = walkForTsConfig(join("/root", "dir1", "kalle"), () => false);
|
||||
// assert.equal(res, undefined);
|
||||
expect(res).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadConfig", () => {
|
||||
it("should load a config", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
(path) => path === "/root/dir1/tsconfig.json",
|
||||
(_) => JSON.stringify(config)
|
||||
);
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("should load a config with comments", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
(path) => path === "/root/dir1/tsconfig.json",
|
||||
(_) => `{
|
||||
// my comment
|
||||
"compilerOptions": {
|
||||
"baseUrl": "hej"
|
||||
}
|
||||
}`
|
||||
);
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("should load a config with trailing commas", () => {
|
||||
const config = { compilerOptions: { baseUrl: "hej" } };
|
||||
const res = loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
(path) => path === "/root/dir1/tsconfig.json",
|
||||
(_) => `{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "hej",
|
||||
},
|
||||
}`
|
||||
);
|
||||
// assert.deepEqual(res, config);
|
||||
expect(res).toStrictEqual(config);
|
||||
});
|
||||
|
||||
it("should throw an error including the file path when encountering invalid JSON5", () => {
|
||||
expect(() =>
|
||||
loadTsconfig(
|
||||
"/root/dir1/tsconfig.json",
|
||||
(path) => path === "/root/dir1/tsconfig.json",
|
||||
(_) => `{
|
||||
"compilerOptions": {
|
||||
}`
|
||||
)
|
||||
).toThrowError(
|
||||
"/root/dir1/tsconfig.json is malformed JSON5: invalid end of input at 3:12"
|
||||
);
|
||||
});
|
||||
|
||||
it("should load a config with string extends and overwrite all options", () => {
|
||||
const firstConfig = {
|
||||
extends: "../base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
};
|
||||
const firstConfigPath = join("/root", "dir1", "tsconfig.json");
|
||||
const baseConfig = {
|
||||
compilerOptions: {
|
||||
baseUrl: "olle",
|
||||
paths: { foo: ["bar1"] },
|
||||
strict: true,
|
||||
},
|
||||
};
|
||||
const baseConfigPath = join("/root", "base-config.json");
|
||||
const res = loadTsconfig(
|
||||
join("/root", "dir1", "tsconfig.json"),
|
||||
(path) => path === firstConfigPath || path === baseConfigPath,
|
||||
(path) => {
|
||||
if (path === firstConfigPath) {
|
||||
return JSON.stringify(firstConfig);
|
||||
}
|
||||
if (path === baseConfigPath) {
|
||||
return JSON.stringify(baseConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
// assert.deepEqual(res, {
|
||||
// extends: "../base-config.json",
|
||||
// compilerOptions: {
|
||||
// baseUrl: "kalle",
|
||||
// paths: { foo: ["bar2"] },
|
||||
// strict: true,
|
||||
// },
|
||||
// });
|
||||
expect(res).toEqual({
|
||||
extends: "../base-config.json",
|
||||
compilerOptions: {
|
||||
baseUrl: "kalle",
|
||||
paths: { foo: ["bar2"] },
|
||||
strict: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should load a config with string extends from node_modules and overwrite all options", () => {
|
||||
const firstConfig = {
|
||||
extends: "my-package/base-config.json",
|
||||
compilerOptions: { baseUrl: "kalle", paths: { foo: ["bar2"] } },
|
||||
};
|
||||
const firstConfigPath = join("/root", "dir1", "tsconfig.json");
|
||||
const baseConfig = {
|
||||
compilerOptions: {
|
||||
baseUrl: "olle",
|
||||
paths: { foo: ["bar1"] },
|
||||
strict: true,
|
||||
},
|
||||
};
|
||||
const baseConfigPath = join(
|
||||
"/root",
|
||||
"dir1",
|
||||
"node_modules",
|
||||
"my-package",
|
||||
"base-config.json"
|
||||
);
|
||||
const res = loadTsconfig(
|
||||
join("/root", "dir1", "tsconfig.json"),
|
||||
(path) => path === firstConfigPath || path === baseConfigPath,
|
||||
(path) => {
|
||||
if (path === firstConfigPath) {
|
||||
return JSON.stringify(firstConfig);
|
||||
}
|
||||
if (path === baseConfigPath) {
|
||||
return JSON.stringify(baseConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
// assert.deepEqual(res, {
|
||||
// extends: "my-package/base-config.json",
|
||||
// compilerOptions: {
|
||||
// baseUrl: "kalle",
|
||||
// paths: { foo: ["bar2"] },
|
||||
// strict: true,
|
||||
// },
|
||||
// });
|
||||
expect(res).toEqual({
|
||||
extends: "my-package/base-config.json",
|
||||
compilerOptions: {
|
||||
baseUrl: "kalle",
|
||||
paths: { foo: ["bar2"] },
|
||||
strict: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should use baseUrl relative to location of extended tsconfig", () => {
|
||||
const firstConfig = { compilerOptions: { baseUrl: "." } };
|
||||
const firstConfigPath = join("/root", "first-config.json");
|
||||
const secondConfig = { extends: "../first-config.json" };
|
||||
const secondConfigPath = join("/root", "dir1", "second-config.json");
|
||||
const thirdConfig = { extends: "../second-config.json" };
|
||||
const thirdConfigPath = join("/root", "dir1", "dir2", "third-config.json");
|
||||
const res = loadTsconfig(
|
||||
join("/root", "dir1", "dir2", "third-config.json"),
|
||||
(path) =>
|
||||
path === firstConfigPath ||
|
||||
path === secondConfigPath ||
|
||||
path === thirdConfigPath,
|
||||
(path) => {
|
||||
if (path === firstConfigPath) {
|
||||
return JSON.stringify(firstConfig);
|
||||
}
|
||||
if (path === secondConfigPath) {
|
||||
return JSON.stringify(secondConfig);
|
||||
}
|
||||
if (path === thirdConfigPath) {
|
||||
return JSON.stringify(thirdConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
// assert.deepEqual(res, {
|
||||
// extends: "../second-config.json",
|
||||
// compilerOptions: { baseUrl: join("..", "..") },
|
||||
// });
|
||||
expect(res).toEqual({
|
||||
extends: "../second-config.json",
|
||||
compilerOptions: { baseUrl: join("..", "..") },
|
||||
});
|
||||
});
|
||||
|
||||
it("should load a config with array extends and overwrite all options", () => {
|
||||
const baseConfig1 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
const baseConfig1Path = join("/root", "base-config-1.json");
|
||||
const baseConfig2 = { compilerOptions: { baseUrl: "." } };
|
||||
const baseConfig2Path = join("/root", "dir1", "base-config-2.json");
|
||||
const baseConfig3 = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar2"] } },
|
||||
};
|
||||
const baseConfig3Path = join("/root", "dir1", "dir2", "base-config-3.json");
|
||||
const actualConfig = {
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
};
|
||||
const actualConfigPath = join("/root", "tsconfig.json");
|
||||
|
||||
const res = loadTsconfig(
|
||||
join("/root", "tsconfig.json"),
|
||||
(path) =>
|
||||
[
|
||||
baseConfig1Path,
|
||||
baseConfig2Path,
|
||||
baseConfig3Path,
|
||||
actualConfigPath,
|
||||
].indexOf(path) >= 0,
|
||||
(path) => {
|
||||
if (path === baseConfig1Path) {
|
||||
return JSON.stringify(baseConfig1);
|
||||
}
|
||||
if (path === baseConfig2Path) {
|
||||
return JSON.stringify(baseConfig2);
|
||||
}
|
||||
if (path === baseConfig3Path) {
|
||||
return JSON.stringify(baseConfig3);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
expect(res).toEqual({
|
||||
extends: [
|
||||
"./base-config-1.json",
|
||||
"./dir1/base-config-2.json",
|
||||
"./dir1/dir2/base-config-3.json",
|
||||
],
|
||||
compilerOptions: {
|
||||
baseUrl: join("dir1", "dir2"),
|
||||
paths: { foo: ["bar2"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should load a config with array extends without .json extension", () => {
|
||||
const baseConfig = {
|
||||
compilerOptions: { baseUrl: ".", paths: { foo: ["bar"] } },
|
||||
};
|
||||
const baseConfigPath = join("/root", "base-config-1.json");
|
||||
const actualConfig = { extends: ["./base-config-1"] };
|
||||
const actualConfigPath = join("/root", "tsconfig.json");
|
||||
|
||||
const res = loadTsconfig(
|
||||
join("/root", "tsconfig.json"),
|
||||
(path) => [baseConfigPath, actualConfigPath].indexOf(path) >= 0,
|
||||
(path) => {
|
||||
if (path === baseConfigPath) {
|
||||
return JSON.stringify(baseConfig);
|
||||
}
|
||||
if (path === actualConfigPath) {
|
||||
return JSON.stringify(actualConfig);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
);
|
||||
|
||||
expect(res).toEqual({
|
||||
extends: ["./base-config-1"],
|
||||
compilerOptions: {
|
||||
baseUrl: ".",
|
||||
paths: { foo: ["bar"] },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
10
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/tsconfig-named.json
generated
vendored
Normal file
10
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/__tests__/tsconfig-named.json
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../base-tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"outDir": "./js_out"
|
||||
}
|
||||
}
|
||||
97
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/config-loader.ts
generated
vendored
Normal file
97
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/config-loader.ts
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import * as TsConfigLoader2 from "./tsconfig-loader";
|
||||
import * as path from "path";
|
||||
import { options } from "./options";
|
||||
|
||||
export interface ExplicitParams {
|
||||
baseUrl: string;
|
||||
paths: { [key: string]: Array<string> };
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
|
||||
export type TsConfigLoader = (
|
||||
params: TsConfigLoader2.TsConfigLoaderParams
|
||||
) => TsConfigLoader2.TsConfigLoaderResult;
|
||||
|
||||
export interface ConfigLoaderParams {
|
||||
cwd: string;
|
||||
explicitParams?: ExplicitParams;
|
||||
tsConfigLoader?: TsConfigLoader;
|
||||
}
|
||||
|
||||
export interface ConfigLoaderSuccessResult {
|
||||
resultType: "success";
|
||||
configFileAbsolutePath: string;
|
||||
baseUrl: string;
|
||||
absoluteBaseUrl: string;
|
||||
paths: { [key: string]: Array<string> };
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
|
||||
export interface ConfigLoaderFailResult {
|
||||
resultType: "failed";
|
||||
message: string;
|
||||
}
|
||||
|
||||
export type ConfigLoaderResult =
|
||||
| ConfigLoaderSuccessResult
|
||||
| ConfigLoaderFailResult;
|
||||
|
||||
export function loadConfig(cwd: string = options.cwd): ConfigLoaderResult {
|
||||
return configLoader({ cwd: cwd });
|
||||
}
|
||||
|
||||
export function configLoader({
|
||||
cwd,
|
||||
explicitParams,
|
||||
tsConfigLoader = TsConfigLoader2.tsConfigLoader,
|
||||
}: ConfigLoaderParams): ConfigLoaderResult {
|
||||
if (explicitParams) {
|
||||
// tslint:disable-next-line:no-shadowed-variable
|
||||
const absoluteBaseUrl = path.isAbsolute(explicitParams.baseUrl)
|
||||
? explicitParams.baseUrl
|
||||
: path.join(cwd, explicitParams.baseUrl);
|
||||
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: "",
|
||||
baseUrl: explicitParams.baseUrl,
|
||||
absoluteBaseUrl,
|
||||
paths: explicitParams.paths,
|
||||
mainFields: explicitParams.mainFields,
|
||||
addMatchAll: explicitParams.addMatchAll,
|
||||
};
|
||||
}
|
||||
|
||||
// Load tsconfig and create path matching function
|
||||
const loadResult = tsConfigLoader({
|
||||
cwd,
|
||||
getEnv: (key: string) => process.env[key],
|
||||
});
|
||||
|
||||
if (!loadResult.tsConfigPath) {
|
||||
return {
|
||||
resultType: "failed",
|
||||
message: "Couldn't find tsconfig.json",
|
||||
};
|
||||
}
|
||||
|
||||
if (!loadResult.baseUrl) {
|
||||
return {
|
||||
resultType: "failed",
|
||||
message: "Missing baseUrl in compilerOptions",
|
||||
};
|
||||
}
|
||||
|
||||
const tsConfigDir = path.dirname(loadResult.tsConfigPath);
|
||||
const absoluteBaseUrl = path.join(tsConfigDir, loadResult.baseUrl);
|
||||
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: loadResult.tsConfigPath,
|
||||
baseUrl: loadResult.baseUrl,
|
||||
absoluteBaseUrl,
|
||||
paths: loadResult.paths || {},
|
||||
};
|
||||
}
|
||||
87
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/filesystem.ts
generated
vendored
Normal file
87
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/filesystem.ts
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import * as fs from "fs";
|
||||
|
||||
/**
|
||||
* Typing for the fields of package.json we care about
|
||||
*/
|
||||
export interface PackageJson {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that json from a file
|
||||
*/
|
||||
export interface ReadJsonSync {
|
||||
// tslint:disable-next-line:no-any
|
||||
(packageJsonPath: string): any | undefined;
|
||||
}
|
||||
|
||||
export interface FileExistsSync {
|
||||
(name: string): boolean;
|
||||
}
|
||||
|
||||
export interface FileExistsAsync {
|
||||
(path: string, callback: (err?: Error, exists?: boolean) => void): void;
|
||||
}
|
||||
|
||||
export interface ReadJsonAsyncCallback {
|
||||
// tslint:disable-next-line:no-any
|
||||
(err?: Error, content?: any): void;
|
||||
}
|
||||
|
||||
export interface ReadJsonAsync {
|
||||
(path: string, callback: ReadJsonAsyncCallback): void;
|
||||
}
|
||||
|
||||
export function fileExistsSync(path: string): boolean {
|
||||
try {
|
||||
const stats = fs.statSync(path);
|
||||
return stats.isFile();
|
||||
} catch (err) {
|
||||
// If error, assume file did not exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads package.json from disk
|
||||
* @param file Path to package.json
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
export function readJsonFromDiskSync(packageJsonPath: string): any | undefined {
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return undefined;
|
||||
}
|
||||
return require(packageJsonPath);
|
||||
}
|
||||
|
||||
export function readJsonFromDiskAsync(
|
||||
path: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
callback: (err?: Error, content?: any) => void
|
||||
): void {
|
||||
fs.readFile(path, "utf8", (err, result) => {
|
||||
// If error, assume file did not exist
|
||||
if (err || !result) {
|
||||
return callback();
|
||||
}
|
||||
const json = JSON.parse(result);
|
||||
return callback(undefined, json);
|
||||
});
|
||||
}
|
||||
|
||||
export function fileExistsAsync(
|
||||
path2: string,
|
||||
callback2: (err?: Error, exists?: boolean) => void
|
||||
): void {
|
||||
fs.stat(path2, (err: Error, stats: fs.Stats) => {
|
||||
if (err) {
|
||||
// If error assume file does not exist
|
||||
return callback2(undefined, false);
|
||||
}
|
||||
callback2(undefined, stats ? stats.isFile() : false);
|
||||
});
|
||||
}
|
||||
|
||||
export function removeExtension(path: string): string {
|
||||
return path.substring(0, path.lastIndexOf(".")) || path;
|
||||
}
|
||||
24
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/index.ts
generated
vendored
Normal file
24
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// register is used from register.js in root dir
|
||||
export {
|
||||
createMatchPath,
|
||||
matchFromAbsolutePaths,
|
||||
MatchPath,
|
||||
} from "./match-path-sync";
|
||||
export {
|
||||
createMatchPathAsync,
|
||||
matchFromAbsolutePathsAsync,
|
||||
MatchPathAsync,
|
||||
} from "./match-path-async";
|
||||
export { register } from "./register";
|
||||
export {
|
||||
loadConfig,
|
||||
ConfigLoaderResult,
|
||||
ConfigLoaderSuccessResult,
|
||||
ConfigLoaderFailResult,
|
||||
} from "./config-loader";
|
||||
export {
|
||||
ReadJsonSync,
|
||||
ReadJsonAsync,
|
||||
FileExistsSync,
|
||||
FileExistsAsync,
|
||||
} from "./filesystem";
|
||||
64
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/mapping-entry.ts
generated
vendored
Normal file
64
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/mapping-entry.ts
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
import * as path from "path";
|
||||
|
||||
export interface MappingEntry {
|
||||
readonly pattern: string;
|
||||
readonly paths: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
export interface Paths {
|
||||
readonly [key: string]: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an absolute baseUrl and paths to an array of absolute mapping entries.
|
||||
* The array is sorted by longest prefix.
|
||||
* Having an array with entries allows us to keep a sorting order rather than
|
||||
* sort by keys each time we use the mappings.
|
||||
* @param absoluteBaseUrl
|
||||
* @param paths
|
||||
* @param addMatchAll
|
||||
*/
|
||||
export function getAbsoluteMappingEntries(
|
||||
absoluteBaseUrl: string,
|
||||
paths: Paths,
|
||||
addMatchAll: boolean
|
||||
): ReadonlyArray<MappingEntry> {
|
||||
// Resolve all paths to absolute form once here, and sort them by
|
||||
// longest prefix once here, this saves time on each request later.
|
||||
// We need to put them in an array to preserve the sorting order.
|
||||
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
||||
const absolutePaths: Array<MappingEntry> = [];
|
||||
for (const key of sortedKeys) {
|
||||
absolutePaths.push({
|
||||
pattern: key,
|
||||
paths: paths[key].map((pathToResolve) =>
|
||||
path.join(absoluteBaseUrl, pathToResolve)
|
||||
),
|
||||
});
|
||||
}
|
||||
// If there is no match-all path specified in the paths section of tsconfig, then try to match
|
||||
// all paths relative to baseUrl, this is how typescript works.
|
||||
if (!paths["*"] && addMatchAll) {
|
||||
absolutePaths.push({
|
||||
pattern: "*",
|
||||
paths: [`${absoluteBaseUrl.replace(/\/$/, "")}/*`],
|
||||
});
|
||||
}
|
||||
|
||||
return absolutePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort path patterns.
|
||||
* If a module name can be matched with multiple patterns then pattern with the longest prefix will be picked.
|
||||
*/
|
||||
function sortByLongestPrefix(arr: Array<string>): Array<string> {
|
||||
return arr
|
||||
.concat()
|
||||
.sort((a: string, b: string) => getPrefixLength(b) - getPrefixLength(a));
|
||||
}
|
||||
|
||||
function getPrefixLength(pattern: string): number {
|
||||
const prefixLength = pattern.indexOf("*");
|
||||
return pattern.substr(0, prefixLength).length;
|
||||
}
|
||||
218
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/match-path-async.ts
generated
vendored
Normal file
218
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/match-path-async.ts
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
import * as path from "path";
|
||||
import * as TryPath from "./try-path";
|
||||
import * as MappingEntry from "./mapping-entry";
|
||||
import * as Filesystem from "./filesystem";
|
||||
|
||||
/**
|
||||
* Function that can match a path async
|
||||
*/
|
||||
export interface MatchPathAsync {
|
||||
(
|
||||
requestedModule: string,
|
||||
readJson: Filesystem.ReadJsonAsync | undefined,
|
||||
fileExists: Filesystem.FileExistsAsync | undefined,
|
||||
extensions: ReadonlyArray<string> | undefined,
|
||||
callback: MatchPathAsyncCallback
|
||||
): void;
|
||||
}
|
||||
|
||||
export interface MatchPathAsyncCallback {
|
||||
(err?: Error, path?: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
export function createMatchPathAsync(
|
||||
absoluteBaseUrl: string,
|
||||
paths: { [key: string]: Array<string> },
|
||||
mainFields: string[] = ["main"],
|
||||
addMatchAll: boolean = true
|
||||
): MatchPathAsync {
|
||||
const absolutePaths = MappingEntry.getAbsoluteMappingEntries(
|
||||
absoluteBaseUrl,
|
||||
paths,
|
||||
addMatchAll
|
||||
);
|
||||
|
||||
return (
|
||||
requestedModule: string,
|
||||
readJson: Filesystem.ReadJsonAsync | undefined,
|
||||
fileExists: Filesystem.FileExistsAsync | undefined,
|
||||
extensions: ReadonlyArray<string> | undefined,
|
||||
callback: MatchPathAsyncCallback
|
||||
) =>
|
||||
matchFromAbsolutePathsAsync(
|
||||
absolutePaths,
|
||||
requestedModule,
|
||||
readJson,
|
||||
fileExists,
|
||||
extensions,
|
||||
callback,
|
||||
mainFields
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
export function matchFromAbsolutePathsAsync(
|
||||
absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>,
|
||||
requestedModule: string,
|
||||
readJson: Filesystem.ReadJsonAsync = Filesystem.readJsonFromDiskAsync,
|
||||
fileExists: Filesystem.FileExistsAsync = Filesystem.fileExistsAsync,
|
||||
extensions: ReadonlyArray<string> = Object.keys(require.extensions),
|
||||
callback: MatchPathAsyncCallback,
|
||||
mainFields: string[] = ["main"]
|
||||
): void {
|
||||
const tryPaths = TryPath.getPathsToTry(
|
||||
extensions,
|
||||
absolutePathMappings,
|
||||
requestedModule
|
||||
);
|
||||
|
||||
if (!tryPaths) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
findFirstExistingPath(
|
||||
tryPaths,
|
||||
readJson,
|
||||
fileExists,
|
||||
callback,
|
||||
0,
|
||||
mainFields
|
||||
);
|
||||
}
|
||||
|
||||
function findFirstExistingMainFieldMappedFile(
|
||||
packageJson: Filesystem.PackageJson,
|
||||
mainFields: string[],
|
||||
packageJsonPath: string,
|
||||
fileExistsAsync: Filesystem.FileExistsAsync,
|
||||
doneCallback: (err?: Error, filepath?: string) => void,
|
||||
index: number = 0
|
||||
): void {
|
||||
if (index >= mainFields.length) {
|
||||
return doneCallback(undefined, undefined);
|
||||
}
|
||||
|
||||
const tryNext = () =>
|
||||
findFirstExistingMainFieldMappedFile(
|
||||
packageJson,
|
||||
mainFields,
|
||||
packageJsonPath,
|
||||
fileExistsAsync,
|
||||
doneCallback,
|
||||
index + 1
|
||||
);
|
||||
|
||||
const mainFieldMapping = packageJson[mainFields[index]];
|
||||
if (typeof mainFieldMapping !== "string") {
|
||||
// Skip mappings that are not pointers to replacement files
|
||||
return tryNext();
|
||||
}
|
||||
|
||||
const mappedFilePath = path.join(
|
||||
path.dirname(packageJsonPath),
|
||||
mainFieldMapping
|
||||
);
|
||||
fileExistsAsync(mappedFilePath, (err?: Error, exists?: boolean) => {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
return doneCallback(undefined, mappedFilePath);
|
||||
}
|
||||
return tryNext();
|
||||
});
|
||||
}
|
||||
|
||||
// Recursive loop to probe for physical files
|
||||
function findFirstExistingPath(
|
||||
tryPaths: ReadonlyArray<TryPath.TryPath>,
|
||||
readJson: Filesystem.ReadJsonAsync,
|
||||
fileExists: Filesystem.FileExistsAsync,
|
||||
doneCallback: MatchPathAsyncCallback,
|
||||
index: number = 0,
|
||||
mainFields: string[] = ["main"]
|
||||
): void {
|
||||
const tryPath = tryPaths[index];
|
||||
if (
|
||||
tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index"
|
||||
) {
|
||||
fileExists(tryPath.path, (err: Error, exists: boolean) => {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
return doneCallback(undefined, TryPath.getStrippedPath(tryPath));
|
||||
}
|
||||
if (index === tryPaths.length - 1) {
|
||||
return doneCallback();
|
||||
}
|
||||
// Continue with the next path
|
||||
return findFirstExistingPath(
|
||||
tryPaths,
|
||||
readJson,
|
||||
fileExists,
|
||||
doneCallback,
|
||||
index + 1,
|
||||
mainFields
|
||||
);
|
||||
});
|
||||
} else if (tryPath.type === "package") {
|
||||
readJson(tryPath.path, (err, packageJson) => {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (packageJson) {
|
||||
return findFirstExistingMainFieldMappedFile(
|
||||
packageJson,
|
||||
mainFields,
|
||||
tryPath.path,
|
||||
fileExists,
|
||||
(mainFieldErr?: Error, mainFieldMappedFile?: string) => {
|
||||
if (mainFieldErr) {
|
||||
return doneCallback(mainFieldErr);
|
||||
}
|
||||
if (mainFieldMappedFile) {
|
||||
return doneCallback(undefined, mainFieldMappedFile);
|
||||
}
|
||||
|
||||
// No field in package json was a valid option. Continue with the next path.
|
||||
return findFirstExistingPath(
|
||||
tryPaths,
|
||||
readJson,
|
||||
fileExists,
|
||||
doneCallback,
|
||||
index + 1,
|
||||
mainFields
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// This is async code, we need to return unconditionally, otherwise the code still falls
|
||||
// through and keeps recursing. While this might work in general, libraries that use neo-async
|
||||
// like Webpack will actually not allow you to call the same callback twice.
|
||||
//
|
||||
// An example of where this caused issues:
|
||||
// https://github.com/dividab/tsconfig-paths-webpack-plugin/issues/11
|
||||
//
|
||||
// Continue with the next path
|
||||
return findFirstExistingPath(
|
||||
tryPaths,
|
||||
readJson,
|
||||
fileExists,
|
||||
doneCallback,
|
||||
index + 1,
|
||||
mainFields
|
||||
);
|
||||
});
|
||||
} else {
|
||||
TryPath.exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
}
|
||||
141
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/match-path-sync.ts
generated
vendored
Normal file
141
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/match-path-sync.ts
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
import * as path from "path";
|
||||
import * as Filesystem from "./filesystem";
|
||||
import * as MappingEntry from "./mapping-entry";
|
||||
import * as TryPath from "./try-path";
|
||||
|
||||
/**
|
||||
* Function that can match a path
|
||||
*/
|
||||
export interface MatchPath {
|
||||
(
|
||||
requestedModule: string,
|
||||
readJson?: Filesystem.ReadJsonSync,
|
||||
fileExists?: (name: string) => boolean,
|
||||
extensions?: ReadonlyArray<string>
|
||||
): string | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a function that can resolve paths according to tsconfig paths property.
|
||||
* @param absoluteBaseUrl Absolute version of baseUrl as specified in tsconfig.
|
||||
* @param paths The paths as specified in tsconfig.
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @param addMatchAll Add a match-all "*" rule if none is present
|
||||
* @returns a function that can resolve paths.
|
||||
*/
|
||||
export function createMatchPath(
|
||||
absoluteBaseUrl: string,
|
||||
paths: { [key: string]: Array<string> },
|
||||
mainFields: string[] = ["main"],
|
||||
addMatchAll: boolean = true
|
||||
): MatchPath {
|
||||
const absolutePaths = MappingEntry.getAbsoluteMappingEntries(
|
||||
absoluteBaseUrl,
|
||||
paths,
|
||||
addMatchAll
|
||||
);
|
||||
|
||||
return (
|
||||
requestedModule: string,
|
||||
readJson?: Filesystem.ReadJsonSync,
|
||||
fileExists?: Filesystem.FileExistsSync,
|
||||
extensions?: Array<string>
|
||||
) =>
|
||||
matchFromAbsolutePaths(
|
||||
absolutePaths,
|
||||
requestedModule,
|
||||
readJson,
|
||||
fileExists,
|
||||
extensions,
|
||||
mainFields
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a path from tsconfig that matches a module load request.
|
||||
* @param absolutePathMappings The paths to try as specified in tsconfig but resolved to absolute form.
|
||||
* @param requestedModule The required module name.
|
||||
* @param readJson Function that can read json from a path (useful for testing).
|
||||
* @param fileExists Function that checks for existence of a file at a path (useful for testing).
|
||||
* @param extensions File extensions to probe for (useful for testing).
|
||||
* @param mainFields A list of package.json field names to try when resolving module files.
|
||||
* @returns the found path, or undefined if no path was found.
|
||||
*/
|
||||
export function matchFromAbsolutePaths(
|
||||
absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>,
|
||||
requestedModule: string,
|
||||
readJson: Filesystem.ReadJsonSync = Filesystem.readJsonFromDiskSync,
|
||||
fileExists: Filesystem.FileExistsSync = Filesystem.fileExistsSync,
|
||||
extensions: Array<string> = Object.keys(require.extensions),
|
||||
mainFields: string[] = ["main"]
|
||||
): string | undefined {
|
||||
const tryPaths = TryPath.getPathsToTry(
|
||||
extensions,
|
||||
absolutePathMappings,
|
||||
requestedModule
|
||||
);
|
||||
|
||||
if (!tryPaths) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, mainFields);
|
||||
}
|
||||
|
||||
function findFirstExistingMainFieldMappedFile(
|
||||
packageJson: Filesystem.PackageJson,
|
||||
mainFields: string[],
|
||||
packageJsonPath: string,
|
||||
fileExists: Filesystem.FileExistsSync
|
||||
): string | undefined {
|
||||
for (let index = 0; index < mainFields.length; index++) {
|
||||
const mainFieldName = mainFields[index];
|
||||
const candidateMapping = packageJson[mainFieldName];
|
||||
if (candidateMapping && typeof candidateMapping === "string") {
|
||||
const candidateFilePath = path.join(
|
||||
path.dirname(packageJsonPath),
|
||||
candidateMapping
|
||||
);
|
||||
if (fileExists(candidateFilePath)) {
|
||||
return candidateFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function findFirstExistingPath(
|
||||
tryPaths: ReadonlyArray<TryPath.TryPath>,
|
||||
readJson: Filesystem.ReadJsonSync = Filesystem.readJsonFromDiskSync,
|
||||
fileExists: Filesystem.FileExistsSync,
|
||||
mainFields: string[] = ["main"]
|
||||
): string | undefined {
|
||||
for (const tryPath of tryPaths) {
|
||||
if (
|
||||
tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index"
|
||||
) {
|
||||
if (fileExists(tryPath.path)) {
|
||||
return TryPath.getStrippedPath(tryPath);
|
||||
}
|
||||
} else if (tryPath.type === "package") {
|
||||
const packageJson: Filesystem.PackageJson = readJson(tryPath.path);
|
||||
if (packageJson) {
|
||||
const mainFieldMappedFile = findFirstExistingMainFieldMappedFile(
|
||||
packageJson,
|
||||
mainFields,
|
||||
tryPath.path,
|
||||
fileExists
|
||||
);
|
||||
if (mainFieldMappedFile) {
|
||||
return mainFieldMappedFile;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TryPath.exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
18
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/options.ts
generated
vendored
Normal file
18
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/options.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as minimist from "minimist";
|
||||
|
||||
const argv = minimist(process.argv.slice(2), {
|
||||
string: ["project"],
|
||||
alias: {
|
||||
project: ["P"],
|
||||
},
|
||||
});
|
||||
|
||||
const project = argv && argv.project;
|
||||
|
||||
export interface Options {
|
||||
cwd: string;
|
||||
}
|
||||
|
||||
export const options: Options = {
|
||||
cwd: project || process.cwd(),
|
||||
};
|
||||
97
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/register.ts
generated
vendored
Normal file
97
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/register.ts
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
import { createMatchPath } from "./match-path-sync";
|
||||
import { configLoader, ExplicitParams } from "./config-loader";
|
||||
import { options } from "./options";
|
||||
|
||||
const noOp = (): void => void 0;
|
||||
|
||||
function getCoreModules(
|
||||
builtinModules: string[] | undefined
|
||||
): { [key: string]: boolean } {
|
||||
builtinModules = builtinModules || [
|
||||
"assert",
|
||||
"buffer",
|
||||
"child_process",
|
||||
"cluster",
|
||||
"crypto",
|
||||
"dgram",
|
||||
"dns",
|
||||
"domain",
|
||||
"events",
|
||||
"fs",
|
||||
"http",
|
||||
"https",
|
||||
"net",
|
||||
"os",
|
||||
"path",
|
||||
"punycode",
|
||||
"querystring",
|
||||
"readline",
|
||||
"stream",
|
||||
"string_decoder",
|
||||
"tls",
|
||||
"tty",
|
||||
"url",
|
||||
"util",
|
||||
"v8",
|
||||
"vm",
|
||||
"zlib",
|
||||
];
|
||||
|
||||
const coreModules: { [key: string]: boolean } = {};
|
||||
for (let module of builtinModules) {
|
||||
coreModules[module] = true;
|
||||
}
|
||||
|
||||
return coreModules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
* Returns a function to undo paths registration.
|
||||
*/
|
||||
export function register(explicitParams: ExplicitParams): () => void {
|
||||
const configLoaderResult = configLoader({
|
||||
cwd: options.cwd,
|
||||
explicitParams,
|
||||
});
|
||||
|
||||
if (configLoaderResult.resultType === "failed") {
|
||||
console.warn(
|
||||
`${configLoaderResult.message}. tsconfig-paths will be skipped`
|
||||
);
|
||||
|
||||
return noOp;
|
||||
}
|
||||
|
||||
const matchPath = createMatchPath(
|
||||
configLoaderResult.absoluteBaseUrl,
|
||||
configLoaderResult.paths,
|
||||
configLoaderResult.mainFields,
|
||||
configLoaderResult.addMatchAll
|
||||
);
|
||||
|
||||
// Patch node's module loading
|
||||
// tslint:disable-next-line:no-require-imports variable-name
|
||||
const Module = require("module");
|
||||
const originalResolveFilename = Module._resolveFilename;
|
||||
const coreModules = getCoreModules(Module.builtinModules);
|
||||
// tslint:disable-next-line:no-any
|
||||
Module._resolveFilename = function (request: string, _parent: any): string {
|
||||
const isCoreModule = coreModules.hasOwnProperty(request);
|
||||
if (!isCoreModule) {
|
||||
const found = matchPath(request);
|
||||
if (found) {
|
||||
const modifiedArguments = [found, ...[].slice.call(arguments, 1)]; // Passes all arguments. Even those that is not specified above.
|
||||
// tslint:disable-next-line:no-invalid-this
|
||||
return originalResolveFilename.apply(this, modifiedArguments);
|
||||
}
|
||||
}
|
||||
// tslint:disable-next-line:no-invalid-this
|
||||
return originalResolveFilename.apply(this, arguments);
|
||||
};
|
||||
|
||||
return () => {
|
||||
// Return node's module loading to original state.
|
||||
Module._resolveFilename = originalResolveFilename;
|
||||
};
|
||||
}
|
||||
102
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/try-path.ts
generated
vendored
Normal file
102
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/try-path.ts
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
import * as path from "path";
|
||||
import { MappingEntry } from "./mapping-entry";
|
||||
import { dirname } from "path";
|
||||
import { removeExtension } from "./filesystem";
|
||||
|
||||
export interface TryPath {
|
||||
readonly type: "file" | "extension" | "index" | "package";
|
||||
readonly path: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a list of all physical paths to try by:
|
||||
* 1. Check for file named exactly as request.
|
||||
* 2. Check for files named as request ending in any of the extensions.
|
||||
* 3. Check for file specified in package.json's main property.
|
||||
* 4. Check for files named as request ending in "index" with any of the extensions.
|
||||
*/
|
||||
export function getPathsToTry(
|
||||
extensions: ReadonlyArray<string>,
|
||||
absolutePathMappings: ReadonlyArray<MappingEntry>,
|
||||
requestedModule: string
|
||||
): ReadonlyArray<TryPath> | undefined {
|
||||
if (!absolutePathMappings || !requestedModule || requestedModule[0] === ".") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const pathsToTry: Array<TryPath> = [];
|
||||
for (const entry of absolutePathMappings) {
|
||||
const starMatch =
|
||||
entry.pattern === requestedModule
|
||||
? ""
|
||||
: matchStar(entry.pattern, requestedModule);
|
||||
if (starMatch !== undefined) {
|
||||
for (const physicalPathPattern of entry.paths) {
|
||||
const physicalPath = physicalPathPattern.replace("*", starMatch);
|
||||
pathsToTry.push({ type: "file", path: physicalPath });
|
||||
pathsToTry.push(
|
||||
...extensions.map(
|
||||
(e) => ({ type: "extension", path: physicalPath + e } as TryPath)
|
||||
)
|
||||
);
|
||||
pathsToTry.push({
|
||||
type: "package",
|
||||
path: path.join(physicalPath, "/package.json"),
|
||||
});
|
||||
const indexPath = path.join(physicalPath, "/index");
|
||||
pathsToTry.push(
|
||||
...extensions.map(
|
||||
(e) => ({ type: "index", path: indexPath + e } as TryPath)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pathsToTry.length === 0 ? undefined : pathsToTry;
|
||||
}
|
||||
|
||||
// Not sure why we don't just return the full found path?
|
||||
export function getStrippedPath(tryPath: TryPath): string {
|
||||
return tryPath.type === "index"
|
||||
? dirname(tryPath.path)
|
||||
: tryPath.type === "file"
|
||||
? tryPath.path
|
||||
: tryPath.type === "extension"
|
||||
? removeExtension(tryPath.path)
|
||||
: tryPath.type === "package"
|
||||
? tryPath.path
|
||||
: exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
|
||||
export function exhaustiveTypeException(check: never): never {
|
||||
throw new Error(`Unknown type ${check}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches pattern with a single star against search.
|
||||
* Star must match at least one character to be considered a match.
|
||||
* @param patttern for example "foo*"
|
||||
* @param search for example "fooawesomebar"
|
||||
* @returns the part of search that * matches, or undefined if no match.
|
||||
*/
|
||||
function matchStar(pattern: string, search: string): string | undefined {
|
||||
if (search.length < pattern.length) {
|
||||
return undefined;
|
||||
}
|
||||
if (pattern === "*") {
|
||||
return search;
|
||||
}
|
||||
const star = pattern.indexOf("*");
|
||||
if (star === -1) {
|
||||
return undefined;
|
||||
}
|
||||
const part1 = pattern.substring(0, star);
|
||||
const part2 = pattern.substring(star + 1);
|
||||
if (search.substr(0, star) !== part1) {
|
||||
return undefined;
|
||||
}
|
||||
if (search.substr(search.length - part2.length) !== part2) {
|
||||
return undefined;
|
||||
}
|
||||
return search.substr(star, search.length - part2.length);
|
||||
}
|
||||
226
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/tsconfig-loader.ts
generated
vendored
Normal file
226
capabilities/testdrive-jsui/node_modules/tsconfig-paths/src/tsconfig-loader.ts
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
// tslint:disable:no-require-imports
|
||||
import JSON5 = require("json5");
|
||||
import StripBom = require("strip-bom");
|
||||
// tslint:enable:no-require-imports
|
||||
|
||||
/**
|
||||
* Typing for the parts of tsconfig that we care about
|
||||
*/
|
||||
export interface Tsconfig {
|
||||
extends?: string | string[];
|
||||
compilerOptions?: {
|
||||
baseUrl?: string;
|
||||
paths?: { [key: string]: Array<string> };
|
||||
strict?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export interface TsConfigLoaderResult {
|
||||
tsConfigPath: string | undefined;
|
||||
baseUrl: string | undefined;
|
||||
paths: { [key: string]: Array<string> } | undefined;
|
||||
}
|
||||
|
||||
export interface TsConfigLoaderParams {
|
||||
getEnv: (key: string) => string | undefined;
|
||||
cwd: string;
|
||||
loadSync?(
|
||||
cwd: string,
|
||||
filename?: string,
|
||||
baseUrl?: string
|
||||
): TsConfigLoaderResult;
|
||||
}
|
||||
|
||||
export function tsConfigLoader({
|
||||
getEnv,
|
||||
cwd,
|
||||
loadSync = loadSyncDefault,
|
||||
}: TsConfigLoaderParams): TsConfigLoaderResult {
|
||||
const TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT");
|
||||
const TS_NODE_BASEURL = getEnv("TS_NODE_BASEURL");
|
||||
|
||||
// tsconfig.loadSync handles if TS_NODE_PROJECT is a file or directory
|
||||
// and also overrides baseURL if TS_NODE_BASEURL is available.
|
||||
const loadResult = loadSync(cwd, TS_NODE_PROJECT, TS_NODE_BASEURL);
|
||||
return loadResult;
|
||||
}
|
||||
|
||||
function loadSyncDefault(
|
||||
cwd: string,
|
||||
filename?: string,
|
||||
baseUrl?: string
|
||||
): TsConfigLoaderResult {
|
||||
// Tsconfig.loadSync uses path.resolve. This is why we can use an absolute path as filename
|
||||
|
||||
const configPath = resolveConfigPath(cwd, filename);
|
||||
|
||||
if (!configPath) {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl: undefined,
|
||||
paths: undefined,
|
||||
};
|
||||
}
|
||||
const config = loadTsconfig(configPath);
|
||||
|
||||
return {
|
||||
tsConfigPath: configPath,
|
||||
baseUrl:
|
||||
baseUrl ||
|
||||
(config && config.compilerOptions && config.compilerOptions.baseUrl),
|
||||
paths: config && config.compilerOptions && config.compilerOptions.paths,
|
||||
};
|
||||
}
|
||||
|
||||
function resolveConfigPath(cwd: string, filename?: string): string | undefined {
|
||||
if (filename) {
|
||||
const absolutePath = fs.lstatSync(filename).isDirectory()
|
||||
? path.resolve(filename, "./tsconfig.json")
|
||||
: path.resolve(cwd, filename);
|
||||
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
if (fs.statSync(cwd).isFile()) {
|
||||
return path.resolve(cwd);
|
||||
}
|
||||
|
||||
const configAbsolutePath = walkForTsConfig(cwd);
|
||||
return configAbsolutePath ? path.resolve(configAbsolutePath) : undefined;
|
||||
}
|
||||
|
||||
export function walkForTsConfig(
|
||||
directory: string,
|
||||
existsSync: (path: string) => boolean = fs.existsSync
|
||||
): string | undefined {
|
||||
const configPath = path.join(directory, "./tsconfig.json");
|
||||
if (existsSync(configPath)) {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
const parentDirectory = path.join(directory, "../");
|
||||
|
||||
// If we reached the top
|
||||
if (directory === parentDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return walkForTsConfig(parentDirectory, existsSync);
|
||||
}
|
||||
|
||||
export function loadTsconfig(
|
||||
configFilePath: string,
|
||||
existsSync: (path: string) => boolean = fs.existsSync,
|
||||
readFileSync: (filename: string) => string = (filename: string) =>
|
||||
fs.readFileSync(filename, "utf8")
|
||||
): Tsconfig | undefined {
|
||||
if (!existsSync(configFilePath)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const configString = readFileSync(configFilePath);
|
||||
const cleanedJson = StripBom(configString);
|
||||
let config: Tsconfig;
|
||||
try {
|
||||
config = JSON5.parse(cleanedJson);
|
||||
} catch (e) {
|
||||
throw new Error(`${configFilePath} is malformed ${e.message}`);
|
||||
}
|
||||
|
||||
let extendedConfig = config.extends;
|
||||
if (extendedConfig) {
|
||||
let base: Tsconfig;
|
||||
|
||||
if (Array.isArray(extendedConfig)) {
|
||||
base = extendedConfig.reduce(
|
||||
(currBase, extendedConfigElement) =>
|
||||
mergeTsconfigs(
|
||||
currBase,
|
||||
loadTsconfigFromExtends(
|
||||
configFilePath,
|
||||
extendedConfigElement,
|
||||
existsSync,
|
||||
readFileSync
|
||||
)
|
||||
),
|
||||
{}
|
||||
);
|
||||
} else {
|
||||
base = loadTsconfigFromExtends(
|
||||
configFilePath,
|
||||
extendedConfig,
|
||||
existsSync,
|
||||
readFileSync
|
||||
);
|
||||
}
|
||||
|
||||
return mergeTsconfigs(base, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intended to be called only from loadTsconfig.
|
||||
* Parameters don't have defaults because they should use the same as loadTsconfig.
|
||||
*/
|
||||
function loadTsconfigFromExtends(
|
||||
configFilePath: string,
|
||||
extendedConfigValue: string,
|
||||
// eslint-disable-next-line no-shadow
|
||||
existsSync: (path: string) => boolean,
|
||||
readFileSync: (filename: string) => string
|
||||
): Tsconfig {
|
||||
if (
|
||||
typeof extendedConfigValue === "string" &&
|
||||
extendedConfigValue.indexOf(".json") === -1
|
||||
) {
|
||||
extendedConfigValue += ".json";
|
||||
}
|
||||
const currentDir = path.dirname(configFilePath);
|
||||
let extendedConfigPath = path.join(currentDir, extendedConfigValue);
|
||||
if (
|
||||
extendedConfigValue.indexOf("/") !== -1 &&
|
||||
extendedConfigValue.indexOf(".") !== -1 &&
|
||||
!existsSync(extendedConfigPath)
|
||||
) {
|
||||
extendedConfigPath = path.join(
|
||||
currentDir,
|
||||
"node_modules",
|
||||
extendedConfigValue
|
||||
);
|
||||
}
|
||||
|
||||
const config =
|
||||
loadTsconfig(extendedConfigPath, existsSync, readFileSync) || {};
|
||||
|
||||
// baseUrl should be interpreted as relative to extendedConfigPath,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (config.compilerOptions?.baseUrl) {
|
||||
const extendsDir = path.dirname(extendedConfigValue);
|
||||
config.compilerOptions.baseUrl = path.join(
|
||||
extendsDir,
|
||||
config.compilerOptions.baseUrl
|
||||
);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
function mergeTsconfigs(
|
||||
base: Tsconfig | undefined,
|
||||
config: Tsconfig | undefined
|
||||
): Tsconfig {
|
||||
base = base || {};
|
||||
config = config || {};
|
||||
|
||||
return {
|
||||
...base,
|
||||
...config,
|
||||
compilerOptions: {
|
||||
...base.compilerOptions,
|
||||
...config.compilerOptions,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user