initial commit of actions
This commit is contained in:
commit
949ece5785
44660 changed files with 12034344 additions and 0 deletions
8
github/codeql-action-v1/node_modules/tsconfig-paths/.nycrc.json
generated
vendored
Normal file
8
github/codeql-action-v1/node_modules/tsconfig-paths/.nycrc.json
generated
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"include": ["src/**/*.{ts,tsx}"],
|
||||
"exclude": ["src/register.ts"],
|
||||
"extension": [".ts", ".tsx"],
|
||||
"reporter": ["json"],
|
||||
"sourceMap": true,
|
||||
"all": true
|
||||
}
|
||||
307
github/codeql-action-v1/node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
Normal file
307
github/codeql-action-v1/node_modules/tsconfig-paths/CHANGELOG.md
generated
vendored
Normal file
|
|
@ -0,0 +1,307 @@
|
|||
# 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.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 extention 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/3.8.0...master
|
||||
[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
github/codeql-action-v1/node_modules/tsconfig-paths/LICENSE
generated
vendored
Normal file
21
github/codeql-action-v1/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.
|
||||
231
github/codeql-action-v1/node_modules/tsconfig-paths/README.md
generated
vendored
Normal file
231
github/codeql-action-v1/node_modules/tsconfig-paths/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
# tsconfig-paths
|
||||
|
||||
[![npm version][version-image]][version-url]
|
||||
[![travis build][travis-image]][travis-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 physcial 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`
|
||||
|
||||
### 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.
|
||||
|
||||
## Bootstraping 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.
|
||||
|
||||
```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 signare 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 existance 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 requries 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
|
||||
[travis-image]: https://travis-ci.com/dividab/tsconfig-paths.svg?branch=master&style=flat
|
||||
[travis-url]: https://travis-ci.com/dividab/tsconfig-paths
|
||||
[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
|
||||
33
github/codeql-action-v1/node_modules/tsconfig-paths/lib/config-loader.d.ts
generated
vendored
Normal file
33
github/codeql-action-v1/node_modules/tsconfig-paths/lib/config-loader.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import * as TsConfigLoader from "./tsconfig-loader";
|
||||
export interface ExplicitParams {
|
||||
baseUrl: string;
|
||||
paths: {
|
||||
[key: string]: Array<string>;
|
||||
};
|
||||
mainFields?: Array<string>;
|
||||
addMatchAll?: boolean;
|
||||
}
|
||||
export declare type TsConfigLoader = (params: TsConfigLoader.TsConfigLoaderParams) => TsConfigLoader.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 declare type ConfigLoaderResult = ConfigLoaderSuccessResult | ConfigLoaderFailResult;
|
||||
export declare function loadConfig(cwd?: string): ConfigLoaderResult;
|
||||
export declare function configLoader({ cwd, explicitParams, tsConfigLoader }: ConfigLoaderParams): ConfigLoaderResult;
|
||||
55
github/codeql-action-v1/node_modules/tsconfig-paths/lib/config-loader.js
generated
vendored
Normal file
55
github/codeql-action-v1/node_modules/tsconfig-paths/lib/config-loader.js
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var TsConfigLoader = require("./tsconfig-loader");
|
||||
var path = require("path");
|
||||
var options_1 = require("./options");
|
||||
function loadConfig(cwd) {
|
||||
if (cwd === void 0) { cwd = options_1.options.cwd; }
|
||||
return configLoader({ cwd: cwd });
|
||||
}
|
||||
exports.loadConfig = loadConfig;
|
||||
function configLoader(_a) {
|
||||
var cwd = _a.cwd, explicitParams = _a.explicitParams, _b = _a.tsConfigLoader, tsConfigLoader = _b === void 0 ? TsConfigLoader.tsConfigLoader : _b;
|
||||
if (explicitParams) {
|
||||
// tslint:disable-next-line:no-shadowed-variable
|
||||
var absoluteBaseUrl_1 = path.isAbsolute(explicitParams.baseUrl)
|
||||
? explicitParams.baseUrl
|
||||
: path.join(cwd, explicitParams.baseUrl);
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: "",
|
||||
baseUrl: explicitParams.baseUrl,
|
||||
absoluteBaseUrl: absoluteBaseUrl_1,
|
||||
paths: explicitParams.paths,
|
||||
mainFields: explicitParams.mainFields,
|
||||
addMatchAll: explicitParams.addMatchAll
|
||||
};
|
||||
}
|
||||
// Load tsconfig and create path matching function
|
||||
var loadResult = tsConfigLoader({
|
||||
cwd: cwd,
|
||||
getEnv: function (key) { return 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"
|
||||
};
|
||||
}
|
||||
var tsConfigDir = path.dirname(loadResult.tsConfigPath);
|
||||
var absoluteBaseUrl = path.join(tsConfigDir, loadResult.baseUrl);
|
||||
return {
|
||||
resultType: "success",
|
||||
configFileAbsolutePath: loadResult.tsConfigPath,
|
||||
baseUrl: loadResult.baseUrl,
|
||||
absoluteBaseUrl: absoluteBaseUrl,
|
||||
paths: loadResult.paths || {}
|
||||
};
|
||||
}
|
||||
exports.configLoader = configLoader;
|
||||
33
github/codeql-action-v1/node_modules/tsconfig-paths/lib/filesystem.d.ts
generated
vendored
Normal file
33
github/codeql-action-v1/node_modules/tsconfig-paths/lib/filesystem.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* 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 {
|
||||
(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 {
|
||||
(err?: Error, content?: any): void;
|
||||
}
|
||||
export interface ReadJsonAsync {
|
||||
(path: string, callback: ReadJsonAsyncCallback): void;
|
||||
}
|
||||
export declare function fileExistsSync(path: string): boolean;
|
||||
/**
|
||||
* Reads package.json from disk
|
||||
* @param file Path to package.json
|
||||
*/
|
||||
export declare function readJsonFromDiskSync(packageJsonPath: string): any | undefined;
|
||||
export declare function readJsonFromDiskAsync(path: string, callback: (err?: Error, content?: any) => void): void;
|
||||
export declare function fileExistsAsync(path2: string, callback2: (err?: Error, exists?: boolean) => void): void;
|
||||
export declare function removeExtension(path: string): string;
|
||||
53
github/codeql-action-v1/node_modules/tsconfig-paths/lib/filesystem.js
generated
vendored
Normal file
53
github/codeql-action-v1/node_modules/tsconfig-paths/lib/filesystem.js
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var fs = require("fs");
|
||||
function fileExistsSync(path) {
|
||||
try {
|
||||
var stats = fs.statSync(path);
|
||||
return stats.isFile();
|
||||
}
|
||||
catch (err) {
|
||||
// If error, assume file did not exist
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.fileExistsSync = fileExistsSync;
|
||||
/**
|
||||
* Reads package.json from disk
|
||||
* @param file Path to package.json
|
||||
*/
|
||||
// tslint:disable-next-line:no-any
|
||||
function readJsonFromDiskSync(packageJsonPath) {
|
||||
if (!fs.existsSync(packageJsonPath)) {
|
||||
return undefined;
|
||||
}
|
||||
return require(packageJsonPath);
|
||||
}
|
||||
exports.readJsonFromDiskSync = readJsonFromDiskSync;
|
||||
function readJsonFromDiskAsync(path,
|
||||
// tslint:disable-next-line:no-any
|
||||
callback) {
|
||||
fs.readFile(path, "utf8", function (err, result) {
|
||||
// If error, assume file did not exist
|
||||
if (err || !result) {
|
||||
return callback();
|
||||
}
|
||||
var json = JSON.parse(result);
|
||||
return callback(undefined, json);
|
||||
});
|
||||
}
|
||||
exports.readJsonFromDiskAsync = readJsonFromDiskAsync;
|
||||
function fileExistsAsync(path2, callback2) {
|
||||
fs.stat(path2, function (err, stats) {
|
||||
if (err) {
|
||||
// If error assume file does not exist
|
||||
return callback2(undefined, false);
|
||||
}
|
||||
callback2(undefined, stats ? stats.isFile() : false);
|
||||
});
|
||||
}
|
||||
exports.fileExistsAsync = fileExistsAsync;
|
||||
function removeExtension(path) {
|
||||
return path.substring(0, path.lastIndexOf(".")) || path;
|
||||
}
|
||||
exports.removeExtension = removeExtension;
|
||||
5
github/codeql-action-v1/node_modules/tsconfig-paths/lib/index.d.ts
generated
vendored
Normal file
5
github/codeql-action-v1/node_modules/tsconfig-paths/lib/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
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";
|
||||
13
github/codeql-action-v1/node_modules/tsconfig-paths/lib/index.js
generated
vendored
Normal file
13
github/codeql-action-v1/node_modules/tsconfig-paths/lib/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// register is used from register.js in root dir
|
||||
var match_path_sync_1 = require("./match-path-sync");
|
||||
exports.createMatchPath = match_path_sync_1.createMatchPath;
|
||||
exports.matchFromAbsolutePaths = match_path_sync_1.matchFromAbsolutePaths;
|
||||
var match_path_async_1 = require("./match-path-async");
|
||||
exports.createMatchPathAsync = match_path_async_1.createMatchPathAsync;
|
||||
exports.matchFromAbsolutePathsAsync = match_path_async_1.matchFromAbsolutePathsAsync;
|
||||
var register_1 = require("./register");
|
||||
exports.register = register_1.register;
|
||||
var config_loader_1 = require("./config-loader");
|
||||
exports.loadConfig = config_loader_1.loadConfig;
|
||||
17
github/codeql-action-v1/node_modules/tsconfig-paths/lib/mapping-entry.d.ts
generated
vendored
Normal file
17
github/codeql-action-v1/node_modules/tsconfig-paths/lib/mapping-entry.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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 declare function getAbsoluteMappingEntries(absoluteBaseUrl: string, paths: Paths, addMatchAll: boolean): ReadonlyArray<MappingEntry>;
|
||||
51
github/codeql-action-v1/node_modules/tsconfig-paths/lib/mapping-entry.js
generated
vendored
Normal file
51
github/codeql-action-v1/node_modules/tsconfig-paths/lib/mapping-entry.js
generated
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
function getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll) {
|
||||
// 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 preseve the sorting order.
|
||||
var sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
||||
var absolutePaths = [];
|
||||
for (var _i = 0, sortedKeys_1 = sortedKeys; _i < sortedKeys_1.length; _i++) {
|
||||
var key = sortedKeys_1[_i];
|
||||
absolutePaths.push({
|
||||
pattern: key,
|
||||
paths: paths[key].map(function (pathToResolve) {
|
||||
return 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;
|
||||
}
|
||||
exports.getAbsoluteMappingEntries = getAbsoluteMappingEntries;
|
||||
/**
|
||||
* 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) {
|
||||
return arr
|
||||
.concat()
|
||||
.sort(function (a, b) { return getPrefixLength(b) - getPrefixLength(a); });
|
||||
}
|
||||
function getPrefixLength(pattern) {
|
||||
var prefixLength = pattern.indexOf("*");
|
||||
return pattern.substr(0, prefixLength).length;
|
||||
}
|
||||
21
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-async.d.ts
generated
vendored
Normal file
21
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-async.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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 declare function createMatchPathAsync(absoluteBaseUrl: string, paths: {
|
||||
[key: string]: Array<string>;
|
||||
}, mainFields?: string[], addMatchAll?: boolean): MatchPathAsync;
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
export declare function matchFromAbsolutePathsAsync(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson: Filesystem.ReadJsonAsync | undefined, fileExists: Filesystem.FileExistsAsync | undefined, extensions: ReadonlyArray<string> | undefined, callback: MatchPathAsyncCallback, mainFields?: string[]): void;
|
||||
113
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-async.js
generated
vendored
Normal file
113
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-async.js
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var TryPath = require("./try-path");
|
||||
var MappingEntry = require("./mapping-entry");
|
||||
var Filesystem = require("./filesystem");
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
function createMatchPathAsync(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
if (addMatchAll === void 0) { addMatchAll = true; }
|
||||
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
||||
return function (requestedModule, readJson, fileExists, extensions, callback) {
|
||||
return matchFromAbsolutePathsAsync(absolutePaths, requestedModule, readJson, fileExists, extensions, callback, mainFields);
|
||||
};
|
||||
}
|
||||
exports.createMatchPathAsync = createMatchPathAsync;
|
||||
/**
|
||||
* See the sync version for docs.
|
||||
*/
|
||||
function matchFromAbsolutePathsAsync(absolutePathMappings, requestedModule, readJson, fileExists, extensions, callback, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskAsync; }
|
||||
if (fileExists === void 0) { fileExists = Filesystem.fileExistsAsync; }
|
||||
if (extensions === void 0) { extensions = Object.keys(require.extensions); }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
|
||||
if (!tryPaths) {
|
||||
return callback();
|
||||
}
|
||||
findFirstExistingPath(tryPaths, readJson, fileExists, callback, 0, mainFields);
|
||||
}
|
||||
exports.matchFromAbsolutePathsAsync = matchFromAbsolutePathsAsync;
|
||||
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index) {
|
||||
if (index === void 0) { index = 0; }
|
||||
if (index >= mainFields.length) {
|
||||
return doneCallback(undefined, undefined);
|
||||
}
|
||||
var tryNext = function () {
|
||||
return findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExistsAsync, doneCallback, index + 1);
|
||||
};
|
||||
var mainFieldMapping = packageJson[mainFields[index]];
|
||||
if (typeof mainFieldMapping !== "string") {
|
||||
// Skip mappings that are not pointers to replacement files
|
||||
return tryNext();
|
||||
}
|
||||
var mappedFilePath = path.join(path.dirname(packageJsonPath), mainFieldMapping);
|
||||
fileExistsAsync(mappedFilePath, function (err, exists) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
return doneCallback(undefined, mappedFilePath);
|
||||
}
|
||||
return tryNext();
|
||||
});
|
||||
}
|
||||
// Recursive loop to probe for physical files
|
||||
function findFirstExistingPath(tryPaths, readJson, fileExists, doneCallback, index, mainFields) {
|
||||
if (index === void 0) { index = 0; }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPath = tryPaths[index];
|
||||
if (tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index") {
|
||||
fileExists(tryPath.path, function (err, exists) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (exists) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
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, function (err, packageJson) {
|
||||
if (err) {
|
||||
return doneCallback(err);
|
||||
}
|
||||
if (packageJson) {
|
||||
return findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists, function (mainFieldErr, mainFieldMappedFile) {
|
||||
if (mainFieldErr) {
|
||||
return doneCallback(mainFieldErr);
|
||||
}
|
||||
if (mainFieldMappedFile) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return doneCallback(undefined, Filesystem.removeExtension(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);
|
||||
}
|
||||
}
|
||||
30
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-sync.d.ts
generated
vendored
Normal file
30
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-sync.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import * as Filesystem from "./filesystem";
|
||||
import * as MappingEntry from "./mapping-entry";
|
||||
/**
|
||||
* 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 declare function createMatchPath(absoluteBaseUrl: string, paths: {
|
||||
[key: string]: Array<string>;
|
||||
}, mainFields?: string[], addMatchAll?: boolean): MatchPath;
|
||||
/**
|
||||
* 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 existance 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 declare function matchFromAbsolutePaths(absolutePathMappings: ReadonlyArray<MappingEntry.MappingEntry>, requestedModule: string, readJson?: Filesystem.ReadJsonSync, fileExists?: Filesystem.FileExistsSync, extensions?: Array<string>, mainFields?: string[]): string | undefined;
|
||||
87
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-sync.js
generated
vendored
Normal file
87
github/codeql-action-v1/node_modules/tsconfig-paths/lib/match-path-sync.js
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var Filesystem = require("./filesystem");
|
||||
var MappingEntry = require("./mapping-entry");
|
||||
var TryPath = require("./try-path");
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function createMatchPath(absoluteBaseUrl, paths, mainFields, addMatchAll) {
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
if (addMatchAll === void 0) { addMatchAll = true; }
|
||||
var absolutePaths = MappingEntry.getAbsoluteMappingEntries(absoluteBaseUrl, paths, addMatchAll);
|
||||
return function (requestedModule, readJson, fileExists, extensions) {
|
||||
return matchFromAbsolutePaths(absolutePaths, requestedModule, readJson, fileExists, extensions, mainFields);
|
||||
};
|
||||
}
|
||||
exports.createMatchPath = createMatchPath;
|
||||
/**
|
||||
* 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 existance 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.
|
||||
*/
|
||||
function matchFromAbsolutePaths(absolutePathMappings, requestedModule, readJson, fileExists, extensions, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskSync; }
|
||||
if (fileExists === void 0) { fileExists = Filesystem.fileExistsSync; }
|
||||
if (extensions === void 0) { extensions = Object.keys(require.extensions); }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
var tryPaths = TryPath.getPathsToTry(extensions, absolutePathMappings, requestedModule);
|
||||
if (!tryPaths) {
|
||||
return undefined;
|
||||
}
|
||||
return findFirstExistingPath(tryPaths, readJson, fileExists, mainFields);
|
||||
}
|
||||
exports.matchFromAbsolutePaths = matchFromAbsolutePaths;
|
||||
function findFirstExistingMainFieldMappedFile(packageJson, mainFields, packageJsonPath, fileExists) {
|
||||
for (var index = 0; index < mainFields.length; index++) {
|
||||
var mainFieldName = mainFields[index];
|
||||
var candidateMapping = packageJson[mainFieldName];
|
||||
if (candidateMapping && typeof candidateMapping === "string") {
|
||||
var candidateFilePath = path.join(path.dirname(packageJsonPath), candidateMapping);
|
||||
if (fileExists(candidateFilePath)) {
|
||||
return candidateFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function findFirstExistingPath(tryPaths, readJson, fileExists, mainFields) {
|
||||
if (readJson === void 0) { readJson = Filesystem.readJsonFromDiskSync; }
|
||||
if (mainFields === void 0) { mainFields = ["main"]; }
|
||||
for (var _i = 0, tryPaths_1 = tryPaths; _i < tryPaths_1.length; _i++) {
|
||||
var tryPath = tryPaths_1[_i];
|
||||
if (tryPath.type === "file" ||
|
||||
tryPath.type === "extension" ||
|
||||
tryPath.type === "index") {
|
||||
if (fileExists(tryPath.path)) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return TryPath.getStrippedPath(tryPath);
|
||||
}
|
||||
}
|
||||
else if (tryPath.type === "package") {
|
||||
var packageJson = readJson(tryPath.path);
|
||||
if (packageJson) {
|
||||
var mainFieldMappedFile = findFirstExistingMainFieldMappedFile(packageJson, mainFields, tryPath.path, fileExists);
|
||||
if (mainFieldMappedFile) {
|
||||
// Not sure why we don't just return the full path? Why strip it?
|
||||
return Filesystem.removeExtension(mainFieldMappedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
TryPath.exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
4
github/codeql-action-v1/node_modules/tsconfig-paths/lib/options.d.ts
generated
vendored
Normal file
4
github/codeql-action-v1/node_modules/tsconfig-paths/lib/options.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
export interface Options {
|
||||
cwd: string;
|
||||
}
|
||||
export declare const options: Options;
|
||||
13
github/codeql-action-v1/node_modules/tsconfig-paths/lib/options.js
generated
vendored
Normal file
13
github/codeql-action-v1/node_modules/tsconfig-paths/lib/options.js
generated
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var minimist = require("minimist");
|
||||
var argv = minimist(process.argv.slice(2), {
|
||||
string: ["project"],
|
||||
alias: {
|
||||
project: ["P"]
|
||||
}
|
||||
});
|
||||
var project = argv && argv.project;
|
||||
exports.options = {
|
||||
cwd: project || process.cwd()
|
||||
};
|
||||
6
github/codeql-action-v1/node_modules/tsconfig-paths/lib/register.d.ts
generated
vendored
Normal file
6
github/codeql-action-v1/node_modules/tsconfig-paths/lib/register.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { ExplicitParams } from "./config-loader";
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
* Returns a function to undo paths registration.
|
||||
*/
|
||||
export declare function register(explicitParams: ExplicitParams): () => void;
|
||||
82
github/codeql-action-v1/node_modules/tsconfig-paths/lib/register.js
generated
vendored
Normal file
82
github/codeql-action-v1/node_modules/tsconfig-paths/lib/register.js
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var match_path_sync_1 = require("./match-path-sync");
|
||||
var config_loader_1 = require("./config-loader");
|
||||
var options_1 = require("./options");
|
||||
var noOp = function () { return void 0; };
|
||||
function getCoreModules(builtinModules) {
|
||||
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"
|
||||
];
|
||||
var coreModules = {};
|
||||
for (var _i = 0, builtinModules_1 = builtinModules; _i < builtinModules_1.length; _i++) {
|
||||
var module_1 = builtinModules_1[_i];
|
||||
coreModules[module_1] = true;
|
||||
}
|
||||
return coreModules;
|
||||
}
|
||||
/**
|
||||
* Installs a custom module load function that can adhere to paths in tsconfig.
|
||||
* Returns a function to undo paths registration.
|
||||
*/
|
||||
function register(explicitParams) {
|
||||
var configLoaderResult = config_loader_1.configLoader({
|
||||
cwd: options_1.options.cwd,
|
||||
explicitParams: explicitParams
|
||||
});
|
||||
if (configLoaderResult.resultType === "failed") {
|
||||
console.warn(configLoaderResult.message + ". tsconfig-paths will be skipped");
|
||||
return noOp;
|
||||
}
|
||||
var matchPath = match_path_sync_1.createMatchPath(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
|
||||
// Patch node's module loading
|
||||
// tslint:disable-next-line:no-require-imports variable-name
|
||||
var Module = require("module");
|
||||
var originalResolveFilename = Module._resolveFilename;
|
||||
var coreModules = getCoreModules(Module.builtinModules);
|
||||
// tslint:disable-next-line:no-any
|
||||
Module._resolveFilename = function (request, _parent) {
|
||||
var isCoreModule = coreModules.hasOwnProperty(request);
|
||||
if (!isCoreModule) {
|
||||
var found = matchPath(request);
|
||||
if (found) {
|
||||
var modifiedArguments = [found].concat([].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 function () {
|
||||
// Return node's module loading to original state.
|
||||
Module._resolveFilename = originalResolveFilename;
|
||||
};
|
||||
}
|
||||
exports.register = register;
|
||||
15
github/codeql-action-v1/node_modules/tsconfig-paths/lib/try-path.d.ts
generated
vendored
Normal file
15
github/codeql-action-v1/node_modules/tsconfig-paths/lib/try-path.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { MappingEntry } from "./mapping-entry";
|
||||
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 declare function getPathsToTry(extensions: ReadonlyArray<string>, absolutePathMappings: ReadonlyArray<MappingEntry>, requestedModule: string): ReadonlyArray<TryPath> | undefined;
|
||||
export declare function getStrippedPath(tryPath: TryPath): string;
|
||||
export declare function exhaustiveTypeException(check: never): never;
|
||||
91
github/codeql-action-v1/node_modules/tsconfig-paths/lib/try-path.js
generated
vendored
Normal file
91
github/codeql-action-v1/node_modules/tsconfig-paths/lib/try-path.js
generated
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var path_1 = require("path");
|
||||
var filesystem_1 = require("./filesystem");
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function getPathsToTry(extensions, absolutePathMappings, requestedModule) {
|
||||
if (!absolutePathMappings ||
|
||||
!requestedModule ||
|
||||
requestedModule[0] === "." ||
|
||||
requestedModule[0] === path.sep) {
|
||||
return undefined;
|
||||
}
|
||||
var pathsToTry = [];
|
||||
for (var _i = 0, absolutePathMappings_1 = absolutePathMappings; _i < absolutePathMappings_1.length; _i++) {
|
||||
var entry = absolutePathMappings_1[_i];
|
||||
var starMatch = entry.pattern === requestedModule
|
||||
? ""
|
||||
: matchStar(entry.pattern, requestedModule);
|
||||
if (starMatch !== undefined) {
|
||||
var _loop_1 = function (physicalPathPattern) {
|
||||
var physicalPath = physicalPathPattern.replace("*", starMatch);
|
||||
pathsToTry.push({ type: "file", path: physicalPath });
|
||||
pathsToTry.push.apply(pathsToTry, extensions.map(function (e) { return ({ type: "extension", path: physicalPath + e }); }));
|
||||
pathsToTry.push({
|
||||
type: "package",
|
||||
path: path.join(physicalPath, "/package.json")
|
||||
});
|
||||
var indexPath = path.join(physicalPath, "/index");
|
||||
pathsToTry.push.apply(pathsToTry, extensions.map(function (e) { return ({ type: "index", path: indexPath + e }); }));
|
||||
};
|
||||
for (var _a = 0, _b = entry.paths; _a < _b.length; _a++) {
|
||||
var physicalPathPattern = _b[_a];
|
||||
_loop_1(physicalPathPattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
return pathsToTry.length === 0 ? undefined : pathsToTry;
|
||||
}
|
||||
exports.getPathsToTry = getPathsToTry;
|
||||
// Not sure why we don't just return the full found path?
|
||||
function getStrippedPath(tryPath) {
|
||||
return tryPath.type === "index"
|
||||
? path_1.dirname(tryPath.path)
|
||||
: tryPath.type === "file"
|
||||
? tryPath.path
|
||||
: tryPath.type === "extension"
|
||||
? filesystem_1.removeExtension(tryPath.path)
|
||||
: tryPath.type === "package"
|
||||
? tryPath.path
|
||||
: exhaustiveTypeException(tryPath.type);
|
||||
}
|
||||
exports.getStrippedPath = getStrippedPath;
|
||||
function exhaustiveTypeException(check) {
|
||||
throw new Error("Unknown type " + check);
|
||||
}
|
||||
exports.exhaustiveTypeException = exhaustiveTypeException;
|
||||
/**
|
||||
* 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, search) {
|
||||
if (search.length < pattern.length) {
|
||||
return undefined;
|
||||
}
|
||||
if (pattern === "*") {
|
||||
return search;
|
||||
}
|
||||
var star = pattern.indexOf("*");
|
||||
if (star === -1) {
|
||||
return undefined;
|
||||
}
|
||||
var part1 = pattern.substring(0, star);
|
||||
var 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);
|
||||
}
|
||||
28
github/codeql-action-v1/node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
Normal file
28
github/codeql-action-v1/node_modules/tsconfig-paths/lib/tsconfig-loader.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Typing for the parts of tsconfig that we care about
|
||||
*/
|
||||
export interface Tsconfig {
|
||||
extends?: 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): TsConfigLoaderResult;
|
||||
}
|
||||
export declare function tsConfigLoader({ getEnv, cwd, loadSync }: TsConfigLoaderParams): TsConfigLoaderResult;
|
||||
export declare function walkForTsConfig(directory: string, existsSync?: (path: string) => boolean): string | undefined;
|
||||
export declare function loadTsconfig(configFilePath: string, existsSync?: (path: string) => boolean, readFileSync?: (filename: string) => string): Tsconfig | undefined;
|
||||
97
github/codeql-action-v1/node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
Normal file
97
github/codeql-action-v1/node_modules/tsconfig-paths/lib/tsconfig-loader.js
generated
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
"use strict";
|
||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var path = require("path");
|
||||
var fs = require("fs");
|
||||
// tslint:disable:no-require-imports
|
||||
var JSON5 = require("json5");
|
||||
var StripBom = require("strip-bom");
|
||||
function tsConfigLoader(_a) {
|
||||
var getEnv = _a.getEnv, cwd = _a.cwd, _b = _a.loadSync, loadSync = _b === void 0 ? loadSyncDefault : _b;
|
||||
var TS_NODE_PROJECT = getEnv("TS_NODE_PROJECT");
|
||||
// tsconfig.loadSync handles if TS_NODE_PROJECT is a file or directory
|
||||
var loadResult = loadSync(cwd, TS_NODE_PROJECT);
|
||||
return loadResult;
|
||||
}
|
||||
exports.tsConfigLoader = tsConfigLoader;
|
||||
function loadSyncDefault(cwd, filename) {
|
||||
// Tsconfig.loadSync uses path.resolve. This is why we can use an absolute path as filename
|
||||
var configPath = resolveConfigPath(cwd, filename);
|
||||
if (!configPath) {
|
||||
return {
|
||||
tsConfigPath: undefined,
|
||||
baseUrl: undefined,
|
||||
paths: undefined
|
||||
};
|
||||
}
|
||||
var config = loadTsconfig(configPath);
|
||||
return {
|
||||
tsConfigPath: configPath,
|
||||
baseUrl: config && config.compilerOptions && config.compilerOptions.baseUrl,
|
||||
paths: config && config.compilerOptions && config.compilerOptions.paths
|
||||
};
|
||||
}
|
||||
function resolveConfigPath(cwd, filename) {
|
||||
if (filename) {
|
||||
var 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);
|
||||
}
|
||||
var configAbsolutePath = walkForTsConfig(cwd);
|
||||
return configAbsolutePath ? path.resolve(configAbsolutePath) : undefined;
|
||||
}
|
||||
function walkForTsConfig(directory, existsSync) {
|
||||
if (existsSync === void 0) { existsSync = fs.existsSync; }
|
||||
var configPath = path.join(directory, "./tsconfig.json");
|
||||
if (existsSync(configPath)) {
|
||||
return configPath;
|
||||
}
|
||||
var parentDirectory = path.join(directory, "../");
|
||||
// If we reached the top
|
||||
if (directory === parentDirectory) {
|
||||
return undefined;
|
||||
}
|
||||
return walkForTsConfig(parentDirectory, existsSync);
|
||||
}
|
||||
exports.walkForTsConfig = walkForTsConfig;
|
||||
function loadTsconfig(configFilePath, existsSync, readFileSync) {
|
||||
if (existsSync === void 0) { existsSync = fs.existsSync; }
|
||||
if (readFileSync === void 0) { readFileSync = function (filename) {
|
||||
return fs.readFileSync(filename, "utf8");
|
||||
}; }
|
||||
if (!existsSync(configFilePath)) {
|
||||
return undefined;
|
||||
}
|
||||
var configString = readFileSync(configFilePath);
|
||||
var cleanedJson = StripBom(configString);
|
||||
var config = JSON5.parse(cleanedJson);
|
||||
var extendedConfig = config.extends;
|
||||
if (extendedConfig) {
|
||||
if (typeof extendedConfig === "string" &&
|
||||
extendedConfig.indexOf(".json") === -1) {
|
||||
extendedConfig += ".json";
|
||||
}
|
||||
var currentDir = path.dirname(configFilePath);
|
||||
var base = loadTsconfig(path.join(currentDir, extendedConfig), existsSync, readFileSync) || {};
|
||||
// baseUrl should be interpreted as relative to the base tsconfig,
|
||||
// but we need to update it so it is relative to the original tsconfig being loaded
|
||||
if (base && base.compilerOptions && base.compilerOptions.baseUrl) {
|
||||
var extendsDir = path.dirname(extendedConfig);
|
||||
base.compilerOptions.baseUrl = path.join(extendsDir, base.compilerOptions.baseUrl);
|
||||
}
|
||||
return __assign({}, base, config, { compilerOptions: __assign({}, base.compilerOptions, config.compilerOptions) });
|
||||
}
|
||||
return config;
|
||||
}
|
||||
exports.loadTsconfig = loadTsconfig;
|
||||
63
github/codeql-action-v1/node_modules/tsconfig-paths/package.json
generated
vendored
Normal file
63
github/codeql-action-v1/node_modules/tsconfig-paths/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"name": "tsconfig-paths",
|
||||
"version": "3.9.0",
|
||||
"description": "Load node modules according to tsconfig paths, in run-time or via API.",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index",
|
||||
"author": "Jonas Kello",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/dividab/tsconfig-paths",
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.1.4",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mocha": "^5.2.3",
|
||||
"@types/node": "^6.0.54",
|
||||
"@types/strip-bom": "^3.0.0",
|
||||
"@types/strip-json-comments": "^0.0.30",
|
||||
"chai": "^4.1.2",
|
||||
"codecov": "^3.1.0",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^4.3.0",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "^11.4.1",
|
||||
"prettier": "1.7.4",
|
||||
"rimraf": "^2.6.2",
|
||||
"shelljs": "^0.7.5",
|
||||
"ts-node": "^7.0.0",
|
||||
"tslint": "^5.8.0",
|
||||
"typescript": "^2.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/json5": "^0.0.29",
|
||||
"json5": "^1.0.1",
|
||||
"minimist": "^1.2.0",
|
||||
"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": "mocha",
|
||||
"build": "rimraf lib && tsc -p src",
|
||||
"build:test": "rimraf ./test/js_out && tsc -p test",
|
||||
"lint": "tslint './{src,tests}/**/*.ts{,x}'",
|
||||
"verify": "yarn build && yarn lint && yarn coverage",
|
||||
"coverage": "rimraf coverage .nyc_output && nyc yarn test",
|
||||
"report-coverage": "codecov -f coverage/*.json",
|
||||
"precommit": "lint-staged",
|
||||
"publish:major": "yarn build && node scripts/publish.js major",
|
||||
"publish:minor": "yarn build && node scripts/publish.js minor",
|
||||
"publish:patch": "yarn build && node scripts/publish.js patch",
|
||||
"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": [
|
||||
"tslint",
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
}
|
||||
}
|
||||
1
github/codeql-action-v1/node_modules/tsconfig-paths/register.js
generated
vendored
Normal file
1
github/codeql-action-v1/node_modules/tsconfig-paths/register.js
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
require('./').register();
|
||||
90
github/codeql-action-v1/node_modules/tsconfig-paths/test/config-loader-tests.ts
generated
vendored
Normal file
90
github/codeql-action-v1/node_modules/tsconfig-paths/test/config-loader-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
import { assert } from "chai";
|
||||
import {
|
||||
configLoader,
|
||||
loadConfig,
|
||||
ConfigLoaderFailResult,
|
||||
ConfigLoaderSuccessResult
|
||||
} from "../src/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");
|
||||
});
|
||||
|
||||
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/"));
|
||||
});
|
||||
|
||||
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"));
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
212
github/codeql-action-v1/node_modules/tsconfig-paths/test/data/match-path-data.ts
generated
vendored
Normal file
212
github/codeql-action-v1/node_modules/tsconfig-paths/test/data/match-path-data.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,212 @@
|
|||
import { join, dirname } from "path";
|
||||
import { removeExtension } from "../../src/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;
|
||||
}
|
||||
|
||||
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"))
|
||||
},
|
||||
{
|
||||
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"))
|
||||
},
|
||||
{
|
||||
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")
|
||||
},
|
||||
{
|
||||
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"))
|
||||
},
|
||||
{
|
||||
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"))
|
||||
},
|
||||
{
|
||||
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: removeExtension(
|
||||
join("/root", "location", "mylib", "kalle.ts")
|
||||
)
|
||||
},
|
||||
{
|
||||
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: removeExtension(
|
||||
join("/root", "location", "mylib.js", "kalle.js")
|
||||
)
|
||||
},
|
||||
{
|
||||
name:
|
||||
"should resolve from main field in package.json and correctly remove file extension",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("/root", "location", "mylibjs", "kalle.js")],
|
||||
packageJson: { main: "./kalle.js" },
|
||||
extensions: [".ts", ".js"],
|
||||
requestedModule: "lib/mylibjs",
|
||||
expectedPath: removeExtension(
|
||||
join("/root", "location", "mylibjs", "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: removeExtension(
|
||||
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: removeExtension(
|
||||
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: removeExtension(
|
||||
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"))
|
||||
},
|
||||
{
|
||||
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
|
||||
},
|
||||
{
|
||||
name: "should not locate path that does not match",
|
||||
absoluteBaseUrl: "/root/",
|
||||
paths: { "lib/*": ["location/*"] },
|
||||
existingFiles: [join("root", "location", "mylib")],
|
||||
requestedModule: "mylib",
|
||||
expectedPath: undefined
|
||||
},
|
||||
{
|
||||
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
|
||||
}
|
||||
];
|
||||
46
github/codeql-action-v1/node_modules/tsconfig-paths/test/filesystem-tests.ts
generated
vendored
Normal file
46
github/codeql-action-v1/node_modules/tsconfig-paths/test/filesystem-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import { assert } from "chai";
|
||||
import * as Filesystem from "../src/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);
|
||||
});
|
||||
|
||||
it("should not find file that not exists, sync", () => {
|
||||
const result = Filesystem.fileExistsSync(fileThatNotExists);
|
||||
assert.equal(result, false);
|
||||
});
|
||||
|
||||
it("should find file that exists, async", done => {
|
||||
Filesystem.fileExistsAsync(fileThatExists, (_err, result) => {
|
||||
assert.equal(result, true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should not find file that not exists, async", done => {
|
||||
Filesystem.fileExistsAsync(fileThatNotExists, (_err, result) => {
|
||||
assert.equal(result, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should load json, sync", () => {
|
||||
const result = Filesystem.readJsonFromDiskSync(fileThatExists);
|
||||
assert.isOk(result);
|
||||
assert.equal(result.main, "lib/index.js");
|
||||
});
|
||||
|
||||
it("should load json, async", done => {
|
||||
Filesystem.readJsonFromDiskAsync(fileThatExists, (_err, result) => {
|
||||
assert.isOk(result);
|
||||
assert.equal(result.main, "lib/index.js");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
47
github/codeql-action-v1/node_modules/tsconfig-paths/test/mapping-entry-test.ts
generated
vendored
Normal file
47
github/codeql-action-v1/node_modules/tsconfig-paths/test/mapping-entry-test.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { assert } from "chai";
|
||||
import { getAbsoluteMappingEntries } from "../src/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")
|
||||
]
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
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", "*")]
|
||||
}
|
||||
]);
|
||||
|
||||
result = getAbsoluteMappingEntries("/absolute/base/url", {}, false);
|
||||
assert.deepEqual(result, []);
|
||||
});
|
||||
});
|
||||
27
github/codeql-action-v1/node_modules/tsconfig-paths/test/match-path-async-tests.ts
generated
vendored
Normal file
27
github/codeql-action-v1/node_modules/tsconfig-paths/test/match-path-async-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { assert } from "chai";
|
||||
import { createMatchPathAsync } from "../src/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);
|
||||
done();
|
||||
}
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
23
github/codeql-action-v1/node_modules/tsconfig-paths/test/match-path-sync-tests.ts
generated
vendored
Normal file
23
github/codeql-action-v1/node_modules/tsconfig-paths/test/match-path-sync-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { assert } from "chai";
|
||||
import { createMatchPath } from "../src/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, // fileExists
|
||||
t.extensions
|
||||
);
|
||||
assert.equal(result, t.expectedPath);
|
||||
})
|
||||
);
|
||||
});
|
||||
3
github/codeql-action-v1/node_modules/tsconfig-paths/test/mocha.opts
generated
vendored
Normal file
3
github/codeql-action-v1/node_modules/tsconfig-paths/test/mocha.opts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
--require ts-node/register
|
||||
--recursive test/
|
||||
test/**/*.ts
|
||||
99
github/codeql-action-v1/node_modules/tsconfig-paths/test/try-path-tests.ts
generated
vendored
Normal file
99
github/codeql-action-v1/node_modules/tsconfig-paths/test/try-path-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { assert } from "chai";
|
||||
import { getPathsToTry } from "../src/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")] }
|
||||
];
|
||||
it("should return no paths for relative requested module", () => {
|
||||
const result = getPathsToTry(
|
||||
[".ts", "tsx"],
|
||||
abosolutePathMappings,
|
||||
"./requested-module"
|
||||
);
|
||||
assert.deepEqual(result, undefined);
|
||||
});
|
||||
|
||||
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"
|
||||
);
|
||||
assert.deepEqual(result, undefined);
|
||||
});
|
||||
|
||||
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")
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
// 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");
|
||||
// });
|
||||
// });
|
||||
203
github/codeql-action-v1/node_modules/tsconfig-paths/test/tsconfig-loader-tests.ts
generated
vendored
Normal file
203
github/codeql-action-v1/node_modules/tsconfig-paths/test/tsconfig-loader-tests.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
import { assert } from "chai";
|
||||
import {
|
||||
loadTsconfig,
|
||||
tsConfigLoader,
|
||||
walkForTsConfig
|
||||
} from "../src/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");
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
it("should return undefined when reaching the top", () => {
|
||||
const res = walkForTsConfig(join("/root", "dir1", "kalle"), () => false);
|
||||
assert.equal(res, undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loadConfig", () => {
|
||||
it("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);
|
||||
});
|
||||
|
||||
it("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);
|
||||
});
|
||||
|
||||
it("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);
|
||||
});
|
||||
|
||||
it("It should load a config with 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
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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("..", "..") }
|
||||
});
|
||||
});
|
||||
});
|
||||
10
github/codeql-action-v1/node_modules/tsconfig-paths/test/tsconfig-named.json
generated
vendored
Normal file
10
github/codeql-action-v1/node_modules/tsconfig-paths/test/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"
|
||||
}
|
||||
}
|
||||
9
github/codeql-action-v1/node_modules/tsconfig-paths/test/tsconfig.json
generated
vendored
Normal file
9
github/codeql-action-v1/node_modules/tsconfig-paths/test/tsconfig.json
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "../base-tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"outDir": "./js_out"
|
||||
}
|
||||
}
|
||||
88
github/codeql-action-v1/node_modules/tsconfig-paths/tslint.json
generated
vendored
Normal file
88
github/codeql-action-v1/node_modules/tsconfig-paths/tslint.json
generated
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{
|
||||
"rules": {
|
||||
"no-any": true,
|
||||
"no-internal-module": true,
|
||||
"no-namespace": true,
|
||||
"no-reference": true,
|
||||
"no-var-requires": true,
|
||||
"typedef": [true, "call-signature", "parameter", "property-declaration"],
|
||||
"typedef-whitespace": [
|
||||
true,
|
||||
{
|
||||
"call-signature": "nospace",
|
||||
"index-signature": "nospace",
|
||||
"parameter": "nospace",
|
||||
"property-declaration": "nospace",
|
||||
"variable-declaration": "nospace"
|
||||
},
|
||||
{
|
||||
"call-signature": "onespace",
|
||||
"index-signature": "onespace",
|
||||
"parameter": "onespace",
|
||||
"property-declaration": "onespace",
|
||||
"variable-declaration": "onespace"
|
||||
}
|
||||
],
|
||||
"curly": true,
|
||||
"forin": true,
|
||||
"label-position": true,
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-conditional-assignment": true,
|
||||
// "no-console": [
|
||||
// true,
|
||||
// "log"
|
||||
// ],
|
||||
"no-construct": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-variable": true,
|
||||
"no-empty": true,
|
||||
"no-eval": true,
|
||||
"no-invalid-this": true,
|
||||
// "no-null-keyword": true,
|
||||
"no-shadowed-variable": true,
|
||||
// "no-string-literal": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unsafe-finally": true,
|
||||
"no-unused-expression": true,
|
||||
"no-var-keyword": true,
|
||||
"radix": true,
|
||||
"switch-default": true,
|
||||
"triple-equals": true,
|
||||
"use-isnan": true,
|
||||
"eofline": true,
|
||||
"indent": [true, "spaces"],
|
||||
"max-file-line-count": [true, 800],
|
||||
"max-line-length": [true, 160],
|
||||
"no-default-export": true,
|
||||
"no-mergeable-namespace": true,
|
||||
"no-require-imports": true,
|
||||
"align": [true, "statements"],
|
||||
//"arrow-parens": true,
|
||||
"class-name": true,
|
||||
"jsdoc-format": true,
|
||||
"new-parens": true,
|
||||
"no-angle-bracket-type-assertion": true,
|
||||
"no-consecutive-blank-lines": [true, 1],
|
||||
"no-parameter-properties": true,
|
||||
// "object-literal-key-quotes": [
|
||||
// true,
|
||||
// "as-needed"
|
||||
// ],
|
||||
"one-line": [
|
||||
true,
|
||||
"check-catch",
|
||||
"check-finally",
|
||||
"check-else",
|
||||
"check-open-brace",
|
||||
"check-whitespace"
|
||||
],
|
||||
"one-variable-per-declaration": [true],
|
||||
"variable-name": [
|
||||
true,
|
||||
"ban-keywords",
|
||||
"check-format",
|
||||
"allow-leading-underscore"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue