This commit is contained in:
4
node_modules/ts-jest/.lintstagedrc
generated
vendored
Normal file
4
node_modules/ts-jest/.lintstagedrc
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"*.{js,cjs,mjs,jsx,ts,tsx}": ["eslint --fix"],
|
||||
"*.{yml,yaml,md}": ["prettier --write"]
|
||||
}
|
||||
1
node_modules/ts-jest/.ts-jest-digest
generated
vendored
Normal file
1
node_modules/ts-jest/.ts-jest-digest
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
58edfe49f3f9192570efa8fa26d9cbc324d1324e
|
||||
2032
node_modules/ts-jest/CHANGELOG.md
generated
vendored
Normal file
2032
node_modules/ts-jest/CHANGELOG.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
121
node_modules/ts-jest/CONTRIBUTING.md
generated
vendored
Normal file
121
node_modules/ts-jest/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
# Contributing
|
||||
|
||||
When contributing to this repository, please first discuss the change you wish to make via
|
||||
[discussion](https://github.com/kulshekhar/ts-jest/discussions) or [issue](https://github.com/kulshekhar/ts-jest/issues)
|
||||
with the owners of this repository before making a change.
|
||||
|
||||
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
||||
|
||||
## Workflow and Pull Requests
|
||||
|
||||
The team will monitor pull requests. We'll do our best to provide updates and feedback throughout the process.
|
||||
|
||||
_Before_ submitting a pull request, please make sure the following is done…
|
||||
|
||||
1. Fork the repo and create your branch from `main`. A guide on how to fork a repository: https://help.github.com/articles/fork-a-repo/
|
||||
|
||||
Open terminal (e.g. Terminal, iTerm, Git Bash or Git Shell) and type:
|
||||
|
||||
```sh-session
|
||||
$ git clone https://github.com/<your_username>/ts-jest
|
||||
$ cd ts-jest
|
||||
$ git checkout -b my_branch
|
||||
```
|
||||
|
||||
Note: Replace `<your_username>` with your GitHub username
|
||||
|
||||
2. `ts-jest` uses `npm` for running development scripts. If you haven't already done so, please [install npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
|
||||
|
||||
3. Make sure you have a compatible version of `node` installed (As of April 14th 2021, `v14.x` is recommended).
|
||||
|
||||
```sh
|
||||
node -v
|
||||
```
|
||||
|
||||
4. Run `npm ci`. `ts-jest` will automatically build source files into `dist/` after installing dependencies.
|
||||
|
||||
5. Ensure the test suite passes via `npm run test`.
|
||||
|
||||
### Testing
|
||||
|
||||
Code that is written needs to be tested to ensure that it achieves the desired behaviour. Tests either fall into a unit
|
||||
test or an integration test.
|
||||
|
||||
##### Unit tests
|
||||
|
||||
The unit test files are associated with source files which are in `src/`. If the scope of your work only requires a unit test,
|
||||
this is where you will write it in. Tests here usually don't require much if any setup.
|
||||
|
||||
##### Integration tests
|
||||
|
||||
There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this,
|
||||
you should write an integration test for your code. The integration tests reside within the `e2e` directory.
|
||||
Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself.
|
||||
The tests within this directory execute jest itself using `run-jest.ts` and assertions are usually made on one if not all
|
||||
the output of the following `status`, `stdout` and `stderr`. The other subdirectories within the `e2e` directory are
|
||||
where you will write the files that jest will run for your integration tests. Feel free to take a look at any of the tests
|
||||
in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done.
|
||||
|
||||
It is possible to run the integration test itself manually to inspect that the new behaviour is indeed correct.
|
||||
Here is a small code snippet of how to do just that. This is useful when debugging a failing test.
|
||||
|
||||
```bash
|
||||
$ cd e2e/test-utils
|
||||
$ node ../../node_modules/jest/bin/jest.js # It is possible to use node --inspect or ndb
|
||||
PASS __tests__/test-utils.spec.ts
|
||||
✓ stub (3ms)
|
||||
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 1 passed, 1 total
|
||||
Snapshots: 0 total
|
||||
Time: 0.232 s, estimated 1 s
|
||||
Ran all test suites.
|
||||
```
|
||||
|
||||
### Additional Workflow for any changes made to website or docs
|
||||
|
||||
If you are making changes to the website or documentation, test the `website` folder and run the server to check if your
|
||||
changes are being displayed accurately.
|
||||
|
||||
1. Locate to the `website` directory and install any website specific dependencies by typing in `npm ci`.
|
||||
2. Following steps are to be followed for this purpose from the root directory.
|
||||
```sh-session
|
||||
$ cd website # Only needed if you are not already in the website directory
|
||||
$ npm ci
|
||||
$ npm run lint-prettier # Please format markdown files
|
||||
$ npm run start
|
||||
```
|
||||
3. You can run a development server to check if the changes you made are being displayed accurately by running `npm run start` in the website directory.
|
||||
|
||||
The `ts-jest` website also offers documentation for older versions of `ts-jest`, which you can edit in `website/versioned_docs`.
|
||||
After making changes to the current documentation in `docs`, please check if any older versions of the documentation
|
||||
have a copy of the file where the change is also relevant and apply the changes to the `versioned_docs` as well.
|
||||
|
||||
## Bugs
|
||||
|
||||
### Where to Find Known Issues
|
||||
|
||||
We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we
|
||||
have an internal fix in progress. Before filing a new issue, try to make sure your problem doesn't already exist.
|
||||
|
||||
### Reporting New Issues
|
||||
|
||||
The best way to get your bug fixed is to provide a reduced test case. Please provide a public repository with a runnable example.
|
||||
|
||||
## How to Get in Touch
|
||||
|
||||
[`#testing` on Reactiflux](https://discord.gg/j6FKKQQrW9) or [our GitHub discussion](https://github.com/kulshekhar/ts-jest/discussions)
|
||||
|
||||
## Code Conventions
|
||||
|
||||
- 2 spaces for indentation (no tabs).
|
||||
- 120 character line length strongly preferred.
|
||||
- Prefer `'` over `"`.
|
||||
- ES6 syntax when possible.
|
||||
- Use [TypeScript](https://www.typescriptlang.org/).
|
||||
- No semicolon (`;`) required
|
||||
- Trailing commas,
|
||||
|
||||
## License
|
||||
|
||||
By contributing to `ts-jest`, you agree that your contributions will be licensed under its MIT license.
|
||||
21
node_modules/ts-jest/LICENSE.md
generated
vendored
Normal file
21
node_modules/ts-jest/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2025
|
||||
|
||||
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.
|
||||
74
node_modules/ts-jest/README.md
generated
vendored
Normal file
74
node_modules/ts-jest/README.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<h1 align="center">ts-jest</h1>
|
||||
|
||||
<p align="center">A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript.</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/v/ts-jest/latest.svg?style=flat-square" alt="NPM version" /> </a>
|
||||
<a href="https://www.npmjs.com/package/ts-jest"><img src="https://img.shields.io/npm/dm/ts-jest.svg?style=flat-square" alt="NPM downloads"/> </a>
|
||||
<a href="https://snyk.io/test/github/kulshekhar/ts-jest"><img src="https://snyk.io/test/github/kulshekhar/ts-jest/badge.svg?style=flat-square" alt="Known vulnerabilities"/> </a>
|
||||
<a href="https://coveralls.io/github/kulshekhar/ts-jest?branch=main"><img src="https://coveralls.io/repos/github/kulshekhar/ts-jest/badge.svg?branch=main" alt="Coverage status"/> </a>
|
||||
<a href="https://actions-badge.atrox.dev/kulshekhar/ts-jest/goto?ref=main"><img alt="GitHub actions" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fkulshekhar%2Fts-jest%2Fbadge%3Fref%3Dmain&style=flat-square" /> </a>
|
||||
<a href="https://github.com/kulshekhar/ts-jest/blob/main/LICENSE.md"><img src="https://img.shields.io/npm/l/ts-jest.svg?style=flat-square" alt="GitHub license"/> </a>
|
||||
<a href="https://gurubase.io/g/ts-jest"><img src="https://img.shields.io/badge/Gurubase-Ask%20ts--jest%20Guru-006BFF?style=flat-square" alt="Gurubase"/> </a>
|
||||
</p>
|
||||
|
||||
<img src="./icon.png" align="right" title="ts-jest Logo" width="128" height="128">
|
||||
|
||||
It supports all features of TypeScript including type-checking. [Read more about Babel7 + `preset-typescript` **vs** TypeScript (and `ts-jest`)](https://kulshekhar.github.io/ts-jest/docs/babel7-or-ts).
|
||||
|
||||
---
|
||||
|
||||
| We are not doing semantic versioning and `23.10` is a re-write, run `npm i -D ts-jest@"<23.10.0"` to go back to the previous version |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
|
||||
[<img src="./website/static/img/documentation.png" align="left" height="24"> View the online documentation (usage & technical)](https://kulshekhar.github.io/ts-jest)
|
||||
|
||||
[<img src="./website/static/img/discord.svg" align="left" height="24"> Ask for some help in the `Jest` Discord community](https://discord.gg/j6FKKQQrW9) or [`ts-jest` GitHub Discussion](https://github.com/kulshekhar/ts-jest/discussions)
|
||||
|
||||
[<img src="./website/static/img/troubleshooting.png" align="left" height="24"> Before reporting any issues, be sure to check the troubleshooting page](TROUBLESHOOTING.md)
|
||||
|
||||
[<img src="./website/static/img/pull-request.png" align="left" height="24"> We're looking for collaborators! Want to help improve `ts-jest`?](https://github.com/kulshekhar/ts-jest/issues/223)
|
||||
|
||||
---
|
||||
|
||||
## Getting Started
|
||||
|
||||
These instructions will get you setup to use `ts-jest` in your project. For more detailed documentation, please check [online documentation](https://kulshekhar.github.io/ts-jest).
|
||||
|
||||
| | using npm | using yarn |
|
||||
| ------------------: | ------------------------------ | ------------------------------------ |
|
||||
| **Prerequisites** | `npm i -D jest typescript` | `yarn add --dev jest typescript` |
|
||||
| **Installing** | `npm i -D ts-jest @types/jest` | `yarn add --dev ts-jest @types/jest` |
|
||||
| **Creating config** | `npx ts-jest config:init` | `yarn ts-jest config:init` |
|
||||
| **Running tests** | `npm test` or `npx jest` | `yarn test` or `yarn jest` |
|
||||
|
||||
## Built With
|
||||
|
||||
- [TypeScript](https://www.typescriptlang.org/) - JavaScript that scales
|
||||
- [Jest](https://jestjs.io/) - Delightful JavaScript Testing
|
||||
- [`ts-jest`](https://kulshekhar.github.io/ts-jest) - Jest [transformer](https://jestjs.io/docs/next/code-transformation#writing-custom-transformers) for TypeScript _(yes, `ts-jest` uses itself for its tests)_
|
||||
|
||||
## Contributing
|
||||
|
||||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
|
||||
|
||||
## Versioning
|
||||
|
||||
We **DO NOT** use [SemVer](https://semver.org/) for versioning. Though you can think about SemVer when reading our version, except our major number follows the one of Jest. For the versions available, see the [tags on this repository](https://github.com/kulshekhar/ts-jest/tags).
|
||||
|
||||
## Authors/maintainers
|
||||
|
||||
- **Kulshekhar Kabra** - [kulshekhar](https://github.com/kulshekhar)
|
||||
- **Gustav Wengel** - [GeeWee](https://github.com/GeeWee)
|
||||
- **Ahn** - [ahnpnl](https://github.com/ahnpnl)
|
||||
- **Huafu Gandon** - [huafu](https://github.com/huafu)
|
||||
|
||||
See also the list of [contributors](https://github.com/kulshekhar/ts-jest/contributors) who participated in this project.
|
||||
|
||||
## Supporters
|
||||
|
||||
- [JetBrains](https://www.jetbrains.com/?from=ts-jest) has been kind enough to support ts-jest with a [license for open source] (https://www.jetbrains.com/community/opensource/?from=ts-jest).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
|
||||
3
node_modules/ts-jest/TROUBLESHOOTING.md
generated
vendored
Normal file
3
node_modules/ts-jest/TROUBLESHOOTING.md
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# Troubleshooting
|
||||
|
||||
Troubleshooting guide have been moved to https://kulshekhar.github.io/ts-jest/docs/guides/troubleshooting
|
||||
3
node_modules/ts-jest/cli.js
generated
vendored
Executable file
3
node_modules/ts-jest/cli.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('./dist/cli').processArgv()
|
||||
6
node_modules/ts-jest/dist/cli/config/init.d.ts
generated
vendored
Normal file
6
node_modules/ts-jest/dist/cli/config/init.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* This has been written quickly. While trying to improve I realised it'd be better to have it in Jest...
|
||||
* ...and I saw a merged PR with `jest --init` tool!
|
||||
* TODO: see what's the best path for this
|
||||
*/
|
||||
export {};
|
||||
139
node_modules/ts-jest/dist/cli/config/init.js
generated
vendored
Normal file
139
node_modules/ts-jest/dist/cli/config/init.js
generated
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This has been written quickly. While trying to improve I realised it'd be better to have it in Jest...
|
||||
* ...and I saw a merged PR with `jest --init` tool!
|
||||
* TODO: see what's the best path for this
|
||||
*/
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const handlebars_1 = __importDefault(require("handlebars"));
|
||||
const json5_1 = require("json5");
|
||||
const create_jest_preset_1 = require("../../presets/create-jest-preset");
|
||||
const JEST_CONFIG_TEMPLATE = `const { {{ presetCreatorFn }} } = require("ts-jest");
|
||||
|
||||
const tsJestTransformCfg = {{ presetCreatorFn }}({{{ transformOpts }}}).transform;
|
||||
|
||||
/** @type {import("jest").Config} **/
|
||||
{{{ exportKind }}} {
|
||||
testEnvironment: "{{ testEnvironment }}",
|
||||
transform: {
|
||||
...tsJestTransformCfg,
|
||||
},
|
||||
};`;
|
||||
const ensureOnlyUsingDoubleQuotes = (str) => {
|
||||
return str
|
||||
.replace(/"'(.*?)'"/g, '"$1"')
|
||||
.replace(/'ts-jest'/g, '"ts-jest"')
|
||||
.replace(/'babel-jest'/g, '"babel-jest"');
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (args /* , logger: Logger */) => {
|
||||
const { tsconfig: askedTsconfig, force, jsdom, js: jsFilesProcessor, babel: shouldPostProcessWithBabel } = args;
|
||||
const file = args._[0]?.toString() ?? 'jest.config.js';
|
||||
const filePath = (0, path_1.join)(process.cwd(), file);
|
||||
const name = (0, path_1.basename)(file);
|
||||
const isPackageJsonConfig = name === 'package.json';
|
||||
const isJestConfigFileExisted = (0, fs_1.existsSync)(filePath);
|
||||
const pkgFile = isPackageJsonConfig ? filePath : (0, path_1.join)(process.cwd(), 'package.json');
|
||||
const isPackageJsonExisted = isPackageJsonConfig || (0, fs_1.existsSync)(pkgFile);
|
||||
const tsconfig = askedTsconfig === 'tsconfig.json' ? undefined : askedTsconfig;
|
||||
const pkgJsonContent = isPackageJsonExisted ? JSON.parse((0, fs_1.readFileSync)(pkgFile, 'utf8')) : {};
|
||||
if (shouldPostProcessWithBabel) {
|
||||
console.warn(`The option --babel is deprecated and will be removed in the next major version.` +
|
||||
` Please specify 'js' option value (see more with npx ts-jest help) if you wish 'ts-jest' to process 'js' with TypeScript API or Babel.`);
|
||||
}
|
||||
if (isPackageJsonConfig && !isJestConfigFileExisted) {
|
||||
throw new Error(`File ${file} does not exists.`);
|
||||
}
|
||||
else if (!isPackageJsonConfig && isJestConfigFileExisted && !force) {
|
||||
throw new Error(`Configuration file ${file} already exists.`);
|
||||
}
|
||||
if (!isPackageJsonConfig && !name.endsWith('.js')) {
|
||||
throw new TypeError(`Configuration file ${file} must be a .js file or the package.json.`);
|
||||
}
|
||||
if (isPackageJsonExisted && pkgJsonContent.jest) {
|
||||
if (force && !isPackageJsonConfig) {
|
||||
delete pkgJsonContent.jest;
|
||||
(0, fs_1.writeFileSync)(pkgFile, JSON.stringify(pkgJsonContent, undefined, ' '));
|
||||
}
|
||||
else if (!force) {
|
||||
throw new Error(`A Jest configuration is already set in ${pkgFile}.`);
|
||||
}
|
||||
}
|
||||
let body;
|
||||
const transformOpts = tsconfig
|
||||
? { tsconfig: `${(0, json5_1.stringify)(tsconfig)}` }
|
||||
: undefined;
|
||||
let transformConfig;
|
||||
if (isPackageJsonConfig) {
|
||||
if (jsFilesProcessor === 'babel' || shouldPostProcessWithBabel) {
|
||||
transformConfig = (0, create_jest_preset_1.createJsWithBabelPreset)(transformOpts);
|
||||
}
|
||||
else if (jsFilesProcessor === 'ts') {
|
||||
transformConfig = (0, create_jest_preset_1.createJsWithTsPreset)(transformOpts);
|
||||
}
|
||||
else {
|
||||
transformConfig = (0, create_jest_preset_1.createDefaultPreset)(transformOpts);
|
||||
}
|
||||
body = ensureOnlyUsingDoubleQuotes(JSON.stringify({
|
||||
...pkgJsonContent,
|
||||
jest: transformConfig,
|
||||
}, undefined, ' '));
|
||||
}
|
||||
else {
|
||||
let presetCreatorFn;
|
||||
if (jsFilesProcessor === 'babel' || shouldPostProcessWithBabel) {
|
||||
presetCreatorFn = 'createJsWithBabelPreset';
|
||||
}
|
||||
else if (jsFilesProcessor === 'ts') {
|
||||
presetCreatorFn = 'createJsWithTsPreset';
|
||||
}
|
||||
else {
|
||||
presetCreatorFn = 'createDefaultPreset';
|
||||
}
|
||||
const template = handlebars_1.default.compile(JEST_CONFIG_TEMPLATE);
|
||||
body = template({
|
||||
exportKind: pkgJsonContent.type === 'module' ? 'export default' : 'module.exports =',
|
||||
testEnvironment: jsdom ? 'jsdom' : 'node',
|
||||
presetCreatorFn,
|
||||
transformOpts: transformOpts ? ensureOnlyUsingDoubleQuotes(JSON.stringify(transformOpts, null, 2)) : undefined,
|
||||
});
|
||||
}
|
||||
(0, fs_1.writeFileSync)(filePath, body);
|
||||
process.stderr.write(`
|
||||
Jest configuration written to "${filePath}".
|
||||
`);
|
||||
};
|
||||
exports.run = run;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const help = async () => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest config:init [options] [<config-file>]
|
||||
|
||||
Arguments:
|
||||
<config-file> Can be a js or json Jest config file. If it is a
|
||||
package.json file, the configuration will be read from
|
||||
the "jest" property.
|
||||
Default: jest.config.js
|
||||
|
||||
Options:
|
||||
--force Discard any existing Jest config
|
||||
--js ts|babel Process '.js' files with ts-jest if 'ts' or with
|
||||
babel-jest if 'babel'
|
||||
--no-jest-preset Disable the use of Jest presets
|
||||
--tsconfig <file> Path to the tsconfig.json file
|
||||
--babel Enable using Babel to process 'js' resulted content from 'ts-jest' processing
|
||||
--jsdom Use 'jsdom' as test environment instead of 'node'
|
||||
`);
|
||||
};
|
||||
exports.help = help;
|
||||
1
node_modules/ts-jest/dist/cli/config/migrate.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/cli/config/migrate.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
177
node_modules/ts-jest/dist/cli/config/migrate.js
generated
vendored
Normal file
177
node_modules/ts-jest/dist/cli/config/migrate.js
generated
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
||||
const json5_1 = require("json5");
|
||||
const create_jest_preset_1 = require("../../presets/create-jest-preset");
|
||||
const backports_1 = require("../../utils/backports");
|
||||
const presets_1 = require("../helpers/presets");
|
||||
const migrateGlobalConfigToTransformConfig = (transformConfig, globalsTsJestConfig) => {
|
||||
if (transformConfig) {
|
||||
return Object.entries(transformConfig).reduce((previousValue, currentValue) => {
|
||||
const [key, transformOptions] = currentValue;
|
||||
if (typeof transformOptions === 'string' && transformOptions.includes('ts-jest')) {
|
||||
return {
|
||||
...previousValue,
|
||||
[key]: globalsTsJestConfig ? ['ts-jest', globalsTsJestConfig] : 'ts-jest',
|
||||
};
|
||||
}
|
||||
return {
|
||||
...previousValue,
|
||||
[key]: transformOptions,
|
||||
};
|
||||
}, {});
|
||||
}
|
||||
return {};
|
||||
};
|
||||
const migratePresetToTransformConfig = (transformConfig, preset, globalsTsJestConfig) => {
|
||||
if (preset) {
|
||||
const transformConfigFromPreset = preset.name === "ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */
|
||||
? (0, create_jest_preset_1.createJsWithTsPreset)(globalsTsJestConfig)
|
||||
: preset.name === "ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */
|
||||
? (0, create_jest_preset_1.createJsWithBabelPreset)(globalsTsJestConfig)
|
||||
: (0, create_jest_preset_1.createDefaultPreset)(globalsTsJestConfig);
|
||||
return {
|
||||
...transformConfig,
|
||||
...transformConfigFromPreset.transform,
|
||||
};
|
||||
}
|
||||
return transformConfig;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (args /* , logger: Logger*/) => {
|
||||
const nullLogger = (0, bs_logger_1.createLogger)({ targets: [] });
|
||||
const file = args._[0]?.toString();
|
||||
const filePath = (0, path_1.resolve)(process.cwd(), file);
|
||||
if (!(0, fs_1.existsSync)(filePath)) {
|
||||
throw new Error(`Configuration file ${file} does not exists.`);
|
||||
}
|
||||
const name = (0, path_1.basename)(file);
|
||||
const isPackage = name === 'package.json';
|
||||
if (!/\.(js|json)$/.test(name)) {
|
||||
throw new TypeError(`Configuration file ${file} must be a JavaScript or JSON file.`);
|
||||
}
|
||||
let actualConfig = require(filePath);
|
||||
if (isPackage) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
actualConfig = actualConfig.jest;
|
||||
}
|
||||
if (!actualConfig)
|
||||
actualConfig = {};
|
||||
// migrate
|
||||
// first we backport our options
|
||||
const migratedConfig = (0, backports_1.backportJestConfig)(nullLogger, actualConfig);
|
||||
let preset;
|
||||
if (migratedConfig.preset) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
preset = presets_1.allPresets[migratedConfig.preset] ?? presets_1.allPresets["ts-jest/presets/default" /* JestPresetNames.default */];
|
||||
}
|
||||
else {
|
||||
if (args.js) {
|
||||
preset = args.js === 'babel' ? presets_1.allPresets["ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */] : presets_1.allPresets["ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */];
|
||||
}
|
||||
else {
|
||||
preset = presets_1.allPresets["ts-jest/presets/default" /* JestPresetNames.default */];
|
||||
}
|
||||
}
|
||||
// check the extensions
|
||||
if (migratedConfig.moduleFileExtensions?.length && preset) {
|
||||
const presetValue = dedupSort(preset.value.moduleFileExtensions ?? []).join('::');
|
||||
const migratedValue = dedupSort(migratedConfig.moduleFileExtensions).join('::');
|
||||
if (presetValue === migratedValue) {
|
||||
delete migratedConfig.moduleFileExtensions;
|
||||
}
|
||||
}
|
||||
// there is a testRegex, remove our testMatch
|
||||
if (typeof migratedConfig.testRegex === 'string' || migratedConfig.testRegex?.length) {
|
||||
delete migratedConfig.testMatch;
|
||||
}
|
||||
// check the testMatch
|
||||
else if (migratedConfig.testMatch?.length &&
|
||||
preset &&
|
||||
Array.isArray(preset.value.testMatch) &&
|
||||
Array.isArray(migratedConfig.testMatch)) {
|
||||
const presetValue = dedupSort(preset.value.testMatch).join('::');
|
||||
const migratedValue = dedupSort(migratedConfig.testMatch).join('::');
|
||||
if (presetValue === migratedValue) {
|
||||
delete migratedConfig.testMatch;
|
||||
}
|
||||
}
|
||||
const globalsTsJestConfig = migratedConfig.globals?.['ts-jest'];
|
||||
migratedConfig.transform = migrateGlobalConfigToTransformConfig(migratedConfig.transform, globalsTsJestConfig);
|
||||
migratedConfig.transform = migratePresetToTransformConfig(migratedConfig.transform, preset, globalsTsJestConfig);
|
||||
cleanupConfig(actualConfig);
|
||||
cleanupConfig(migratedConfig);
|
||||
const before = (0, fast_json_stable_stringify_1.default)(actualConfig);
|
||||
const after = (0, fast_json_stable_stringify_1.default)(migratedConfig);
|
||||
if (after === before) {
|
||||
process.stderr.write(`
|
||||
No migration needed for given Jest configuration
|
||||
`);
|
||||
return;
|
||||
}
|
||||
const stringify = file.endsWith('.json') ? JSON.stringify : json5_1.stringify;
|
||||
const prefix = file.endsWith('.json') ? '"jest": ' : 'module.exports = ';
|
||||
// output new config
|
||||
process.stderr.write(`
|
||||
Migrated Jest configuration:
|
||||
`);
|
||||
process.stdout.write(`${prefix}${stringify(migratedConfig, undefined, ' ')}\n`);
|
||||
};
|
||||
exports.run = run;
|
||||
function cleanupConfig(config) {
|
||||
if (config.globals) {
|
||||
delete config.globals['ts-jest'];
|
||||
if (!Object.keys(config.globals).length) {
|
||||
delete config.globals;
|
||||
}
|
||||
}
|
||||
if (config.transform && !Object.keys(config.transform).length) {
|
||||
delete config.transform;
|
||||
}
|
||||
if (config.moduleFileExtensions) {
|
||||
config.moduleFileExtensions = dedupSort(config.moduleFileExtensions);
|
||||
if (!config.moduleFileExtensions.length)
|
||||
delete config.moduleFileExtensions;
|
||||
}
|
||||
if (config.testMatch && Array.isArray(config.testMatch)) {
|
||||
config.testMatch = dedupSort(config.testMatch);
|
||||
if (!config.testMatch.length)
|
||||
delete config.testMatch;
|
||||
}
|
||||
delete config.preset;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function dedupSort(arr) {
|
||||
return arr
|
||||
.filter((s, i, a) => a.findIndex((e) => s.toString() === e.toString()) === i)
|
||||
.sort((a, b) => (a.toString() > b.toString() ? 1 : a.toString() < b.toString() ? -1 : 0));
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const help = async () => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest config:migrate [options] <config-file>
|
||||
|
||||
Arguments:
|
||||
<config-file> Can be a js or json Jest config file. If it is a
|
||||
package.json file, the configuration will be read from
|
||||
the "jest" property.
|
||||
|
||||
Options:
|
||||
--js ts|babel Process .js files with ts-jest if 'ts' or with
|
||||
babel-jest if 'babel'
|
||||
--no-jest-preset Disable the use of Jest presets
|
||||
`);
|
||||
};
|
||||
exports.help = help;
|
||||
1
node_modules/ts-jest/dist/cli/help.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/cli/help.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
25
node_modules/ts-jest/dist/cli/help.js
generated
vendored
Normal file
25
node_modules/ts-jest/dist/cli/help.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.help = exports.run = void 0;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const run = async (_) => {
|
||||
process.stdout.write(`
|
||||
Usage:
|
||||
ts-jest command [options] [...args]
|
||||
|
||||
Commands:
|
||||
config:init Creates initial Jest configuration
|
||||
config:migrate Migrates a given Jest configuration
|
||||
help [command] Show this help, or help about a command
|
||||
|
||||
Example:
|
||||
ts-jest help config:migrate
|
||||
`);
|
||||
};
|
||||
exports.run = run;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.help = exports.run;
|
||||
1
node_modules/ts-jest/dist/cli/helpers/presets.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/cli/helpers/presets.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
41
node_modules/ts-jest/dist/cli/helpers/presets.js
generated
vendored
Normal file
41
node_modules/ts-jest/dist/cli/helpers/presets.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.jsWIthBabel = exports.jsWithTs = exports.defaults = exports.allPresets = void 0;
|
||||
const definePreset = (fullName) => ({
|
||||
fullName,
|
||||
get name() {
|
||||
return this.isDefault ? 'ts-jest' : fullName;
|
||||
},
|
||||
get label() {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
return fullName.split('/').pop();
|
||||
},
|
||||
get jsVarName() {
|
||||
return this.isDefault
|
||||
? 'defaults'
|
||||
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
fullName
|
||||
.split('/')
|
||||
.pop()
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
.replace(/\-([a-z])/g, (_, l) => l.toUpperCase());
|
||||
},
|
||||
get value() {
|
||||
return require(`../../../${fullName.replace(/^ts-jest\//, '')}/jest-preset`);
|
||||
},
|
||||
jsImport(varName = 'tsjPreset') {
|
||||
return `const { ${this.jsVarName}: ${varName} } = require('ts-jest/presets')`;
|
||||
},
|
||||
get isDefault() {
|
||||
return fullName === "ts-jest/presets/default" /* JestPresetNames.default */;
|
||||
},
|
||||
});
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
exports.allPresets = {};
|
||||
/** @internal */
|
||||
exports.defaults = (exports.allPresets["ts-jest/presets/default" /* JestPresetNames.default */] = definePreset("ts-jest/presets/default" /* JestPresetNames.default */));
|
||||
/** @internal */
|
||||
exports.jsWithTs = (exports.allPresets["ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */] = definePreset("ts-jest/presets/js-with-ts" /* JestPresetNames.jsWithTs */));
|
||||
/** @internal */
|
||||
exports.jsWIthBabel = (exports.allPresets["ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */] = definePreset("ts-jest/presets/js-with-babel" /* JestPresetNames.jsWIthBabel */));
|
||||
1
node_modules/ts-jest/dist/cli/index.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/cli/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
63
node_modules/ts-jest/dist/cli/index.js
generated
vendored
Normal file
63
node_modules/ts-jest/dist/cli/index.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.processArgv = processArgv;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
||||
const utils_1 = require("../utils");
|
||||
const VALID_COMMANDS = ['help', 'config:migrate', 'config:init'];
|
||||
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'cli', [bs_logger_1.LogContexts.application]: 'ts-jest' });
|
||||
async function cli(args) {
|
||||
const parsedArgv = (0, yargs_parser_1.default)(args, {
|
||||
boolean: ['dry-run', 'jest-preset', 'allow-js', 'diff', 'babel', 'force', 'jsdom'],
|
||||
string: ['tsconfig', 'js'],
|
||||
count: ['verbose'],
|
||||
alias: { verbose: ['v'] },
|
||||
default: { jestPreset: true, verbose: 0 },
|
||||
coerce: {
|
||||
js(val) {
|
||||
const res = val.trim().toLowerCase();
|
||||
if (!['babel', 'ts'].includes(res))
|
||||
throw new Error(`The 'js' option must be 'babel' or 'ts', given: '${val}'.`);
|
||||
return res;
|
||||
},
|
||||
},
|
||||
});
|
||||
// deprecated
|
||||
if (parsedArgv.allowJs != null) {
|
||||
if (parsedArgv.js)
|
||||
throw new Error("The 'allowJs' and 'js' options cannot be set together.");
|
||||
parsedArgv.js = parsedArgv.allowJs ? 'ts' : undefined;
|
||||
}
|
||||
let command = parsedArgv._.shift();
|
||||
const isHelp = command === 'help';
|
||||
if (isHelp)
|
||||
command = parsedArgv._.shift();
|
||||
if (!VALID_COMMANDS.includes(command))
|
||||
command = 'help';
|
||||
const { run, help } = require(`./${command.replace(/:/g, '/')}`);
|
||||
const cmd = isHelp && command !== 'help' ? help : run;
|
||||
return cmd(parsedArgv, logger);
|
||||
}
|
||||
const errorHasMessage = (err) => {
|
||||
if (typeof err !== 'object' || err === null)
|
||||
return false;
|
||||
return 'message' in err;
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
async function processArgv() {
|
||||
try {
|
||||
await cli(process.argv.slice(2));
|
||||
process.exit(0);
|
||||
}
|
||||
catch (err) {
|
||||
if (errorHasMessage(err)) {
|
||||
logger.fatal(err.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
node_modules/ts-jest/dist/config/index.d.ts
generated
vendored
Normal file
2
node_modules/ts-jest/dist/config/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './paths-to-module-name-mapper';
|
||||
export * from './types';
|
||||
18
node_modules/ts-jest/dist/config/index.js
generated
vendored
Normal file
18
node_modules/ts-jest/dist/config/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./paths-to-module-name-mapper"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
9
node_modules/ts-jest/dist/config/paths-to-module-name-mapper.d.ts
generated
vendored
Normal file
9
node_modules/ts-jest/dist/config/paths-to-module-name-mapper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { Config } from '@jest/types';
|
||||
import type { CompilerOptions } from 'typescript';
|
||||
type TsPathMapping = Exclude<CompilerOptions['paths'], undefined>;
|
||||
type JestPathMapping = Config.InitialOptions['moduleNameMapper'];
|
||||
export declare const pathsToModuleNameMapper: (mapping: TsPathMapping, { prefix, useESM }?: {
|
||||
prefix?: string;
|
||||
useESM?: boolean;
|
||||
}) => JestPathMapping;
|
||||
export {};
|
||||
52
node_modules/ts-jest/dist/config/paths-to-module-name-mapper.js
generated
vendored
Normal file
52
node_modules/ts-jest/dist/config/paths-to-module-name-mapper.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pathsToModuleNameMapper = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const utils_1 = require("../utils");
|
||||
const messages_1 = require("../utils/messages");
|
||||
// we don't need to escape all chars, so commented out is the real one
|
||||
// const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
const escapeRegex = (str) => str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
const logger = utils_1.rootLogger.child({ [bs_logger_1.LogContexts.namespace]: 'path-mapper' });
|
||||
const pathsToModuleNameMapper = (mapping, { prefix = '', useESM = false } = {}) => {
|
||||
const jestMap = {};
|
||||
for (const fromPath of Object.keys(mapping)) {
|
||||
const toPaths = mapping[fromPath];
|
||||
// check that we have only one target path
|
||||
if (toPaths.length === 0) {
|
||||
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has no target." /* Errors.NotMappingPathWithEmptyMap */, { path: fromPath }));
|
||||
continue;
|
||||
}
|
||||
// split with '*'
|
||||
const segments = fromPath.split(/\*/g);
|
||||
if (segments.length === 1) {
|
||||
const paths = toPaths.map((target) => {
|
||||
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
||||
return `${enrichedPrefix}${target}`;
|
||||
});
|
||||
const cjsPattern = `^${escapeRegex(fromPath)}$`;
|
||||
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
else if (segments.length === 2) {
|
||||
const paths = toPaths.map((target) => {
|
||||
const enrichedTarget = target.startsWith('./') && prefix !== '' ? target.substring(target.indexOf('/') + 1) : target;
|
||||
const enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? `${prefix}/` : prefix;
|
||||
return `${enrichedPrefix}${enrichedTarget.replace(/\*/g, '$1')}`;
|
||||
});
|
||||
if (useESM) {
|
||||
const esmPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}\\.js$`;
|
||||
jestMap[esmPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
const cjsPattern = `^${escapeRegex(segments[0])}(.*)${escapeRegex(segments[1])}$`;
|
||||
jestMap[cjsPattern] = paths.length === 1 ? paths[0] : paths;
|
||||
}
|
||||
else {
|
||||
logger.warn((0, messages_1.interpolate)("Not mapping \"{{path}}\" because it has more than one star (`*`)." /* Errors.NotMappingMultiStarPath */, { path: fromPath }));
|
||||
}
|
||||
}
|
||||
if (useESM) {
|
||||
jestMap['^(\\.{1,2}/.*)\\.js$'] = '$1';
|
||||
}
|
||||
return jestMap;
|
||||
};
|
||||
exports.pathsToModuleNameMapper = pathsToModuleNameMapper;
|
||||
2
node_modules/ts-jest/dist/config/types.d.ts
generated
vendored
Normal file
2
node_modules/ts-jest/dist/config/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { TsConfigJson } from 'type-fest';
|
||||
export type TsConfigCompilerOptionsJson = TsConfigJson.CompilerOptions;
|
||||
2
node_modules/ts-jest/dist/config/types.js
generated
vendored
Normal file
2
node_modules/ts-jest/dist/config/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
13
node_modules/ts-jest/dist/constants.d.ts
generated
vendored
Normal file
13
node_modules/ts-jest/dist/constants.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
export declare const LINE_FEED = "\n";
|
||||
export declare const DECLARATION_TYPE_EXT = ".d.ts";
|
||||
export declare const JS_JSX_EXTENSIONS: string[];
|
||||
export declare const TS_TSX_REGEX: RegExp;
|
||||
export declare const JS_JSX_REGEX: RegExp;
|
||||
export declare const TS_TRANSFORM_PATTERN = "^.+\\.tsx?$";
|
||||
export declare const ESM_TS_TRANSFORM_PATTERN = "^.+\\.m?tsx?$";
|
||||
export declare const TS_JS_TRANSFORM_PATTERN = "^.+\\.[tj]sx?$";
|
||||
export declare const ESM_TS_JS_TRANSFORM_PATTERN = "^.+\\.m?[tj]sx?$";
|
||||
export declare const JS_TRANSFORM_PATTERN = "^.+\\.jsx?$";
|
||||
export declare const ESM_JS_TRANSFORM_PATTERN = "^.+\\.m?jsx?$";
|
||||
export declare const TS_EXT_TO_TREAT_AS_ESM: string[];
|
||||
export declare const JS_EXT_TO_TREAT_AS_ESM: string[];
|
||||
22
node_modules/ts-jest/dist/constants.js
generated
vendored
Normal file
22
node_modules/ts-jest/dist/constants.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DEFAULT_JEST_TEST_MATCH = exports.JS_EXT_TO_TREAT_AS_ESM = exports.TS_EXT_TO_TREAT_AS_ESM = exports.ESM_JS_TRANSFORM_PATTERN = exports.JS_TRANSFORM_PATTERN = exports.ESM_TS_JS_TRANSFORM_PATTERN = exports.TS_JS_TRANSFORM_PATTERN = exports.ESM_TS_TRANSFORM_PATTERN = exports.TS_TRANSFORM_PATTERN = exports.JS_JSX_REGEX = exports.TS_TSX_REGEX = exports.JS_JSX_EXTENSIONS = exports.DECLARATION_TYPE_EXT = exports.LINE_FEED = void 0;
|
||||
exports.LINE_FEED = '\n';
|
||||
exports.DECLARATION_TYPE_EXT = '.d.ts';
|
||||
exports.JS_JSX_EXTENSIONS = ['.js', '.jsx'];
|
||||
exports.TS_TSX_REGEX = /\.[cm]?tsx?$/;
|
||||
exports.JS_JSX_REGEX = /\.[cm]?jsx?$/;
|
||||
exports.TS_TRANSFORM_PATTERN = '^.+\\.tsx?$';
|
||||
exports.ESM_TS_TRANSFORM_PATTERN = '^.+\\.m?tsx?$';
|
||||
exports.TS_JS_TRANSFORM_PATTERN = '^.+\\.[tj]sx?$';
|
||||
exports.ESM_TS_JS_TRANSFORM_PATTERN = '^.+\\.m?[tj]sx?$';
|
||||
exports.JS_TRANSFORM_PATTERN = '^.+\\.jsx?$';
|
||||
exports.ESM_JS_TRANSFORM_PATTERN = '^.+\\.m?jsx?$';
|
||||
// `extensionsToTreatAsEsm` will throw error with `.mjs`
|
||||
exports.TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts'];
|
||||
exports.JS_EXT_TO_TREAT_AS_ESM = ['.jsx'];
|
||||
/**
|
||||
* @internal
|
||||
* See https://jestjs.io/docs/en/configuration#testmatch-arraystring
|
||||
*/
|
||||
exports.DEFAULT_JEST_TEST_MATCH = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
|
||||
15
node_modules/ts-jest/dist/index.d.ts
generated
vendored
Normal file
15
node_modules/ts-jest/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TsJestTransformer } from './legacy/ts-jest-transformer';
|
||||
import type { TsJestTransformerOptions } from './types';
|
||||
export * from './config';
|
||||
export * from './constants';
|
||||
export * from './legacy/compiler';
|
||||
export * from './legacy/ts-jest-transformer';
|
||||
export * from './legacy/config/config-set';
|
||||
export * from './presets/create-jest-preset';
|
||||
export * from './raw-compiler-options';
|
||||
export * from './utils';
|
||||
export * from './types';
|
||||
declare const _default: {
|
||||
createTransformer(tsJestConfig?: TsJestTransformerOptions): TsJestTransformer;
|
||||
};
|
||||
export default _default;
|
||||
31
node_modules/ts-jest/dist/index.js
generated
vendored
Normal file
31
node_modules/ts-jest/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ts_jest_transformer_1 = require("./legacy/ts-jest-transformer");
|
||||
__exportStar(require("./config"), exports);
|
||||
__exportStar(require("./constants"), exports);
|
||||
__exportStar(require("./legacy/compiler"), exports);
|
||||
__exportStar(require("./legacy/ts-jest-transformer"), exports);
|
||||
__exportStar(require("./legacy/config/config-set"), exports);
|
||||
__exportStar(require("./presets/create-jest-preset"), exports);
|
||||
__exportStar(require("./raw-compiler-options"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
||||
__exportStar(require("./types"), exports);
|
||||
exports.default = {
|
||||
createTransformer(tsJestConfig) {
|
||||
return new ts_jest_transformer_1.TsJestTransformer(tsJestConfig);
|
||||
},
|
||||
};
|
||||
8
node_modules/ts-jest/dist/legacy/compiler/compiler-utils.d.ts
generated
vendored
Normal file
8
node_modules/ts-jest/dist/legacy/compiler/compiler-utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
|
||||
*/
|
||||
export declare const SOURCE_MAPPING_PREFIX = "sourceMappingURL=";
|
||||
/**
|
||||
* Update the output remapping the source map.
|
||||
*/
|
||||
export declare function updateOutput(outputText: string, normalizedFileName: string, sourceMap?: string): string;
|
||||
32
node_modules/ts-jest/dist/legacy/compiler/compiler-utils.js
generated
vendored
Normal file
32
node_modules/ts-jest/dist/legacy/compiler/compiler-utils.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SOURCE_MAPPING_PREFIX = void 0;
|
||||
exports.updateOutput = updateOutput;
|
||||
const utils_1 = require("../../utils");
|
||||
/**
|
||||
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
|
||||
*/
|
||||
exports.SOURCE_MAPPING_PREFIX = 'sourceMappingURL=';
|
||||
/**
|
||||
* Update the output remapping the source map.
|
||||
*/
|
||||
function updateOutput(outputText, normalizedFileName, sourceMap) {
|
||||
if (sourceMap) {
|
||||
const base64Map = Buffer.from(updateSourceMap(sourceMap, normalizedFileName), 'utf8').toString('base64');
|
||||
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`;
|
||||
// sourceMappingURL= prefix is always at the end of compiledOutput, using lastIndexOf should be the safest way to substring
|
||||
return (outputText.slice(0, outputText.lastIndexOf(exports.SOURCE_MAPPING_PREFIX) + exports.SOURCE_MAPPING_PREFIX.length) +
|
||||
sourceMapContent);
|
||||
}
|
||||
return outputText;
|
||||
}
|
||||
/**
|
||||
* Update the source map contents for improved output.
|
||||
*/
|
||||
const updateSourceMap = (sourceMapText, normalizedFileName) => {
|
||||
const sourceMap = JSON.parse(sourceMapText);
|
||||
sourceMap.file = normalizedFileName;
|
||||
sourceMap.sources = [normalizedFileName];
|
||||
delete sourceMap.sourceRoot;
|
||||
return (0, utils_1.stringify)(sourceMap);
|
||||
};
|
||||
2
node_modules/ts-jest/dist/legacy/compiler/index.d.ts
generated
vendored
Normal file
2
node_modules/ts-jest/dist/legacy/compiler/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './ts-compiler';
|
||||
export * from './ts-jest-compiler';
|
||||
18
node_modules/ts-jest/dist/legacy/compiler/index.js
generated
vendored
Normal file
18
node_modules/ts-jest/dist/legacy/compiler/index.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./ts-compiler"), exports);
|
||||
__exportStar(require("./ts-jest-compiler"), exports);
|
||||
27
node_modules/ts-jest/dist/legacy/compiler/ts-compiler.d.ts
generated
vendored
Normal file
27
node_modules/ts-jest/dist/legacy/compiler/ts-compiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Logger } from 'bs-logger';
|
||||
import { CompilerOptions, CustomTransformers, Program, TranspileOutput } from 'typescript';
|
||||
import type { StringMap, TsCompilerInstance, TsJestAstTransformer, TsJestCompileOptions, TTypeScript, CompiledOutput } from '../../types';
|
||||
import type { ConfigSet } from '../config/config-set';
|
||||
export declare class TsCompiler implements TsCompilerInstance {
|
||||
readonly configSet: ConfigSet;
|
||||
readonly runtimeCacheFS: StringMap;
|
||||
protected readonly _logger: Logger;
|
||||
protected readonly _ts: TTypeScript;
|
||||
protected readonly _initialCompilerOptions: CompilerOptions;
|
||||
protected _compilerOptions: CompilerOptions;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
private _runtimeCacheFS;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
private _fileContentCache;
|
||||
program: Program | undefined;
|
||||
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
||||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
||||
private fixupCompilerOptionsForModuleKind;
|
||||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
|
||||
protected _transpileOutput(fileContent: string, fileName: string): TranspileOutput;
|
||||
protected _makeTransformers(customTransformers: TsJestAstTransformer): CustomTransformers;
|
||||
}
|
||||
434
node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js
generated
vendored
Normal file
434
node_modules/ts-jest/dist/legacy/compiler/ts-compiler.js
generated
vendored
Normal file
@@ -0,0 +1,434 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsCompiler = void 0;
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const lodash_memoize_1 = __importDefault(require("lodash.memoize"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const constants_1 = require("../../constants");
|
||||
const transpile_module_1 = require("../../transpilers/typescript/transpile-module");
|
||||
const utils_1 = require("../../utils");
|
||||
const messages_1 = require("../../utils/messages");
|
||||
const compiler_utils_1 = require("./compiler-utils");
|
||||
const assertCompilerOptionsWithJestTransformMode = (compilerOptions, isEsmMode, logger) => {
|
||||
if (isEsmMode && compilerOptions.module === typescript_1.default.ModuleKind.CommonJS) {
|
||||
logger.error("The current compiler option \"module\" value is not suitable for Jest ESM mode. Please either use ES module kinds or Node16/NodeNext module kinds with \"type: module\" in package.json" /* Errors.InvalidModuleKindForEsm */);
|
||||
}
|
||||
};
|
||||
class TsCompiler {
|
||||
configSet;
|
||||
runtimeCacheFS;
|
||||
_logger;
|
||||
_ts;
|
||||
_initialCompilerOptions;
|
||||
_compilerOptions;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_runtimeCacheFS;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_fileContentCache;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_parsedTsConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_fileVersionCache;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_cachedReadFile;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_projectVersion = 1;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_languageService;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_moduleResolutionHost;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_moduleResolutionCache;
|
||||
program;
|
||||
constructor(configSet, runtimeCacheFS) {
|
||||
this.configSet = configSet;
|
||||
this.runtimeCacheFS = runtimeCacheFS;
|
||||
this._ts = configSet.compilerModule;
|
||||
this._logger = utils_1.rootLogger.child({ namespace: 'ts-compiler' });
|
||||
this._parsedTsConfig = this.configSet.parsedTsConfig;
|
||||
this._initialCompilerOptions = { ...this._parsedTsConfig.options };
|
||||
this._compilerOptions = { ...this._initialCompilerOptions };
|
||||
this._runtimeCacheFS = runtimeCacheFS;
|
||||
if (!this.configSet.isolatedModules) {
|
||||
this._fileContentCache = new Map();
|
||||
this._fileVersionCache = new Map();
|
||||
this._cachedReadFile = this._logger.wrap({
|
||||
namespace: 'ts:serviceHost',
|
||||
call: null,
|
||||
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
||||
}, 'readFile', (0, lodash_memoize_1.default)(this._ts.sys.readFile));
|
||||
/* istanbul ignore next */
|
||||
this._moduleResolutionHost = {
|
||||
fileExists: (0, lodash_memoize_1.default)(this._ts.sys.fileExists),
|
||||
readFile: this._cachedReadFile,
|
||||
directoryExists: (0, lodash_memoize_1.default)(this._ts.sys.directoryExists),
|
||||
getCurrentDirectory: () => this.configSet.cwd,
|
||||
realpath: this._ts.sys.realpath && (0, lodash_memoize_1.default)(this._ts.sys.realpath),
|
||||
getDirectories: (0, lodash_memoize_1.default)(this._ts.sys.getDirectories),
|
||||
useCaseSensitiveFileNames: () => this._ts.sys.useCaseSensitiveFileNames,
|
||||
};
|
||||
this._moduleResolutionCache = this._ts.createModuleResolutionCache(this.configSet.cwd, this._ts.sys.useCaseSensitiveFileNames ? (x) => x : (x) => x.toLowerCase(), this._compilerOptions);
|
||||
this._createLanguageService();
|
||||
}
|
||||
}
|
||||
getResolvedModules(fileContent, fileName, runtimeCacheFS) {
|
||||
// In watch mode, it is possible that the initial cacheFS becomes empty
|
||||
if (!this.runtimeCacheFS.size) {
|
||||
this._runtimeCacheFS = runtimeCacheFS;
|
||||
}
|
||||
this._logger.debug({ fileName }, 'getResolvedModules(): resolve direct imported module paths');
|
||||
const importedModulePaths = Array.from(new Set(this._getImportedModulePaths(fileContent, fileName)));
|
||||
this._logger.debug({ fileName }, 'getResolvedModules(): resolve nested imported module paths from directed imported module paths');
|
||||
importedModulePaths.forEach((importedModulePath) => {
|
||||
const resolvedFileContent = this._getFileContentFromCache(importedModulePath);
|
||||
importedModulePaths.push(...this._getImportedModulePaths(resolvedFileContent, importedModulePath).filter((modulePath) => !importedModulePaths.includes(modulePath)));
|
||||
});
|
||||
return importedModulePaths;
|
||||
}
|
||||
fixupCompilerOptionsForModuleKind(compilerOptions, isEsm) {
|
||||
const moduleResolution = this._ts.ModuleResolutionKind.Node10 ?? this._ts.ModuleResolutionKind.NodeJs;
|
||||
if (!isEsm) {
|
||||
return {
|
||||
...compilerOptions,
|
||||
module: this._ts.ModuleKind.CommonJS,
|
||||
moduleResolution,
|
||||
/**
|
||||
* This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
|
||||
*/
|
||||
customConditions: undefined,
|
||||
};
|
||||
}
|
||||
let moduleKind = compilerOptions.module ?? this._ts.ModuleKind.ESNext;
|
||||
let esModuleInterop = compilerOptions.esModuleInterop;
|
||||
if ((0, transpile_module_1.isModernNodeModuleKind)(moduleKind)) {
|
||||
esModuleInterop = true;
|
||||
moduleKind = this._ts.ModuleKind.ESNext;
|
||||
}
|
||||
return {
|
||||
...compilerOptions,
|
||||
module: moduleKind,
|
||||
esModuleInterop,
|
||||
moduleResolution,
|
||||
/**
|
||||
* This option is only supported in `Node16`/`NodeNext` and `Bundler` module, see https://www.typescriptlang.org/tsconfig/#customConditions
|
||||
*/
|
||||
customConditions: undefined,
|
||||
};
|
||||
}
|
||||
getCompiledOutput(fileContent, fileName, options) {
|
||||
const isEsmMode = this.configSet.useESM && options.supportsStaticESM;
|
||||
this._compilerOptions = this.fixupCompilerOptionsForModuleKind(this._initialCompilerOptions, isEsmMode);
|
||||
const moduleKind = this._initialCompilerOptions.module;
|
||||
const currentModuleKind = this._compilerOptions.module;
|
||||
if (this._languageService) {
|
||||
if (constants_1.JS_JSX_REGEX.test(fileName) && !this._compilerOptions.allowJs) {
|
||||
this._logger.warn({ fileName: fileName }, (0, messages_1.interpolate)("Got a `.js` file to compile while `allowJs` option is not set to `true` (file: {{path}}). To fix this:\n - if you want TypeScript to process JS files, set `allowJs` to `true` in your TypeScript config (usually tsconfig.json)\n - if you do not want TypeScript to process your `.js` files, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match `.js` files anymore" /* Errors.GotJsFileButAllowJsFalse */, { path: fileName }));
|
||||
return {
|
||||
code: fileContent,
|
||||
};
|
||||
}
|
||||
this._logger.debug({ fileName }, 'getCompiledOutput(): compiling using language service');
|
||||
// Must set memory cache before attempting to compile
|
||||
this._updateMemoryCache(fileContent, fileName, currentModuleKind === moduleKind);
|
||||
const output = this._languageService.getEmitOutput(fileName);
|
||||
const diagnostics = this.getDiagnostics(fileName);
|
||||
if ((0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
||||
this.configSet.raiseDiagnostics([
|
||||
{
|
||||
category: this._ts.DiagnosticCategory.Message,
|
||||
code: utils_1.TsJestDiagnosticCodes.ModernNodeModule,
|
||||
messageText: messages_1.Helps.UsingModernNodeResolution,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
},
|
||||
]);
|
||||
}
|
||||
if (!isEsmMode && diagnostics.length) {
|
||||
this.configSet.raiseDiagnostics(diagnostics, fileName, this._logger);
|
||||
if (options.watchMode) {
|
||||
this._logger.debug({ fileName }, '_doTypeChecking(): starting watch mode computing diagnostics');
|
||||
for (const entry of options.depGraphs.entries()) {
|
||||
const normalizedModuleNames = entry[1].resolvedModuleNames.map((moduleName) => (0, path_1.normalize)(moduleName));
|
||||
const fileToReTypeCheck = entry[0];
|
||||
if (normalizedModuleNames.includes(fileName) && this.configSet.shouldReportDiagnostics(fileToReTypeCheck)) {
|
||||
this._logger.debug({ fileToReTypeCheck }, '_doTypeChecking(): computing diagnostics using language service');
|
||||
this._updateMemoryCache(this._getFileContentFromCache(fileToReTypeCheck), fileToReTypeCheck);
|
||||
const importedModulesDiagnostics = [
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSemanticDiagnostics(fileToReTypeCheck),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSyntacticDiagnostics(fileToReTypeCheck),
|
||||
];
|
||||
// will raise or just warn diagnostics depending on config
|
||||
this.configSet.raiseDiagnostics(importedModulesDiagnostics, fileName, this._logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (output.emitSkipped) {
|
||||
if (constants_1.TS_TSX_REGEX.test(fileName)) {
|
||||
throw new Error((0, messages_1.interpolate)("Unable to process '{{file}}', please make sure that `outDir` in your tsconfig is neither `''` or `'.'`. You can also configure Jest config option `transformIgnorePatterns` to inform `ts-jest` to transform {{file}}" /* Errors.CannotProcessFile */, { file: fileName }));
|
||||
}
|
||||
else {
|
||||
this._logger.warn((0, messages_1.interpolate)("Unable to process '{{file}}', falling back to original file content. You can also configure Jest config option `transformIgnorePatterns` to ignore {{file}} from transformation or make sure that `outDir` in your tsconfig is neither `''` or `'.'`" /* Errors.CannotProcessFileReturnOriginal */, { file: fileName }));
|
||||
return {
|
||||
code: fileContent,
|
||||
};
|
||||
}
|
||||
}
|
||||
// Throw an error when requiring `.d.ts` files.
|
||||
if (!output.outputFiles.length) {
|
||||
throw new TypeError((0, messages_1.interpolate)("Unable to require `.d.ts` file for file: {{file}}.\nThis is usually the result of a faulty configuration or import. Make sure there is a `.js`, `.json` or another executable extension available alongside `{{file}}`." /* Errors.UnableToRequireDefinitionFile */, {
|
||||
file: (0, path_1.basename)(fileName),
|
||||
}));
|
||||
}
|
||||
const { outputFiles } = output;
|
||||
return this._compilerOptions.sourceMap
|
||||
? {
|
||||
code: (0, compiler_utils_1.updateOutput)(outputFiles[1].text, fileName, outputFiles[0].text),
|
||||
diagnostics,
|
||||
}
|
||||
: {
|
||||
code: (0, compiler_utils_1.updateOutput)(outputFiles[0].text, fileName),
|
||||
diagnostics,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._logger.debug({ fileName }, 'getCompiledOutput(): compiling as isolated module');
|
||||
assertCompilerOptionsWithJestTransformMode(this._initialCompilerOptions, isEsmMode, this._logger);
|
||||
const result = this._transpileOutput(fileContent, fileName);
|
||||
if (result.diagnostics && this.configSet.shouldReportDiagnostics(fileName)) {
|
||||
this.configSet.raiseDiagnostics(result.diagnostics, fileName, this._logger);
|
||||
}
|
||||
return {
|
||||
code: (0, compiler_utils_1.updateOutput)(result.outputText, fileName, result.sourceMapText),
|
||||
};
|
||||
}
|
||||
}
|
||||
_transpileOutput(fileContent, fileName) {
|
||||
/**
|
||||
* @deprecated
|
||||
*
|
||||
* This code path should be removed in the next major version to benefit from checking on compiler options
|
||||
*/
|
||||
if (!(0, transpile_module_1.isModernNodeModuleKind)(this._initialCompilerOptions.module)) {
|
||||
return this._ts.transpileModule(fileContent, {
|
||||
fileName,
|
||||
transformers: this._makeTransformers(this.configSet.resolvedTransformers),
|
||||
compilerOptions: this._compilerOptions,
|
||||
reportDiagnostics: this.configSet.shouldReportDiagnostics(fileName),
|
||||
});
|
||||
}
|
||||
return (0, transpile_module_1.tsTranspileModule)(fileContent, {
|
||||
fileName,
|
||||
transformers: (program) => {
|
||||
this.program = program;
|
||||
return this._makeTransformers(this.configSet.resolvedTransformers);
|
||||
},
|
||||
compilerOptions: this._initialCompilerOptions,
|
||||
reportDiagnostics: fileName ? this.configSet.shouldReportDiagnostics(fileName) : false,
|
||||
});
|
||||
}
|
||||
_makeTransformers(customTransformers) {
|
||||
return {
|
||||
before: customTransformers.before.map((beforeTransformer) => beforeTransformer.factory(this, beforeTransformer.options)),
|
||||
after: customTransformers.after.map((afterTransformer) => afterTransformer.factory(this, afterTransformer.options)),
|
||||
afterDeclarations: customTransformers.afterDeclarations.map((afterDeclarations) => afterDeclarations.factory(this, afterDeclarations.options)),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_createLanguageService() {
|
||||
// Initialize memory cache for typescript compiler
|
||||
this._parsedTsConfig.fileNames
|
||||
.filter((fileName) => constants_1.TS_TSX_REGEX.test(fileName) && !this.configSet.isTestFile(fileName))
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
.forEach((fileName) => this._fileVersionCache.set(fileName, 0));
|
||||
/* istanbul ignore next */
|
||||
const serviceHost = {
|
||||
useCaseSensitiveFileNames: () => this._ts.sys.useCaseSensitiveFileNames,
|
||||
getProjectVersion: () => String(this._projectVersion),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
getScriptFileNames: () => [...this._fileVersionCache.keys()],
|
||||
getScriptVersion: (fileName) => {
|
||||
const normalizedFileName = (0, path_1.normalize)(fileName);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const version = this._fileVersionCache.get(normalizedFileName);
|
||||
// We need to return `undefined` and not a string here because TypeScript will use
|
||||
// `getScriptVersion` and compare against their own version - which can be `undefined`.
|
||||
// If we don't return `undefined` it results in `undefined === "undefined"` and run
|
||||
// `createProgram` again (which is very slow). Using a `string` assertion here to avoid
|
||||
// TypeScript errors from the function signature (expects `(x: string) => string`).
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return version === undefined ? undefined : String(version);
|
||||
},
|
||||
getScriptSnapshot: (fileName) => {
|
||||
const normalizedFileName = (0, path_1.normalize)(fileName);
|
||||
const hit = this._isFileInCache(normalizedFileName);
|
||||
this._logger.trace({ normalizedFileName, cacheHit: hit }, 'getScriptSnapshot():', 'cache', hit ? 'hit' : 'miss');
|
||||
// Read file content from either memory cache or Jest runtime cache or fallback to file system read
|
||||
if (!hit) {
|
||||
const fileContent =
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.get(normalizedFileName) ??
|
||||
this._runtimeCacheFS.get(normalizedFileName) ??
|
||||
this._cachedReadFile?.(normalizedFileName) ??
|
||||
undefined;
|
||||
if (fileContent !== undefined) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.set(normalizedFileName, fileContent);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(normalizedFileName, 1);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const contents = this._fileContentCache.get(normalizedFileName);
|
||||
if (contents === undefined)
|
||||
return;
|
||||
return this._ts.ScriptSnapshot.fromString(contents);
|
||||
},
|
||||
fileExists: (0, lodash_memoize_1.default)(this._ts.sys.fileExists),
|
||||
readFile: this._cachedReadFile ?? this._ts.sys.readFile,
|
||||
readDirectory: (0, lodash_memoize_1.default)(this._ts.sys.readDirectory),
|
||||
getDirectories: (0, lodash_memoize_1.default)(this._ts.sys.getDirectories),
|
||||
directoryExists: (0, lodash_memoize_1.default)(this._ts.sys.directoryExists),
|
||||
realpath: this._ts.sys.realpath && (0, lodash_memoize_1.default)(this._ts.sys.realpath),
|
||||
getNewLine: () => constants_1.LINE_FEED,
|
||||
getCurrentDirectory: () => this.configSet.cwd,
|
||||
getCompilationSettings: () => this._compilerOptions,
|
||||
getDefaultLibFileName: () => this._ts.getDefaultLibFilePath(this._compilerOptions),
|
||||
getCustomTransformers: () => this._makeTransformers(this.configSet.resolvedTransformers),
|
||||
resolveModuleNames: (moduleNames, containingFile) => moduleNames.map((moduleName) => this._resolveModuleName(moduleName, containingFile).resolvedModule),
|
||||
};
|
||||
this._logger.debug('created language service');
|
||||
this._languageService = this._ts.createLanguageService(serviceHost, this._ts.createDocumentRegistry(this._ts.sys.useCaseSensitiveFileNames, this.configSet.cwd));
|
||||
this.program = this._languageService.getProgram();
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getFileContentFromCache(filePath) {
|
||||
const normalizedFilePath = (0, path_1.normalize)(filePath);
|
||||
let resolvedFileContent = this._runtimeCacheFS.get(normalizedFilePath);
|
||||
if (!resolvedFileContent) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolvedFileContent = this._moduleResolutionHost.readFile(normalizedFilePath);
|
||||
this._runtimeCacheFS.set(normalizedFilePath, resolvedFileContent);
|
||||
}
|
||||
return resolvedFileContent;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getImportedModulePaths(resolvedFileContent, containingFile) {
|
||||
return this._ts
|
||||
.preProcessFile(resolvedFileContent, true, true)
|
||||
.importedFiles.map((importedFile) => {
|
||||
const { resolvedModule } = this._resolveModuleName(importedFile.fileName, containingFile);
|
||||
/* istanbul ignore next already covered */
|
||||
const resolvedFileName = resolvedModule?.resolvedFileName;
|
||||
/* istanbul ignore next already covered */
|
||||
return resolvedFileName && !resolvedModule?.isExternalLibraryImport ? resolvedFileName : '';
|
||||
})
|
||||
.filter((resolveFileName) => !!resolveFileName);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_resolveModuleName(moduleNameToResolve, containingFile) {
|
||||
return this._ts.resolveModuleName(moduleNameToResolve, containingFile, this._compilerOptions,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._moduleResolutionHost,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._moduleResolutionCache);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_isFileInCache(fileName) {
|
||||
return (
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.has(fileName) &&
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.has(fileName) &&
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.get(fileName) !== 0);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_updateMemoryCache(contents, fileName, isModuleKindTheSame = true) {
|
||||
this._logger.debug({ fileName }, 'updateMemoryCache: update memory cache for language service');
|
||||
let shouldIncrementProjectVersion = false;
|
||||
const hit = this._isFileInCache(fileName);
|
||||
if (!hit) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(fileName, 1);
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const prevVersion = this._fileVersionCache.get(fileName);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const previousContents = this._fileContentCache.get(fileName);
|
||||
// Avoid incrementing cache when nothing has changed.
|
||||
if (previousContents !== contents) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileVersionCache.set(fileName, prevVersion + 1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this._fileContentCache.set(fileName, contents);
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
/**
|
||||
* When a file is from node_modules or referenced to a referenced project and jest wants to transform it, we need
|
||||
* to make sure that the Program is updated with this information
|
||||
*/
|
||||
if (!this._parsedTsConfig.fileNames.includes(fileName) || !isModuleKindTheSame) {
|
||||
shouldIncrementProjectVersion = true;
|
||||
}
|
||||
}
|
||||
if (shouldIncrementProjectVersion)
|
||||
this._projectVersion++;
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
getDiagnostics(fileName) {
|
||||
const diagnostics = [];
|
||||
if (this.configSet.shouldReportDiagnostics(fileName)) {
|
||||
this._logger.debug({ fileName }, '_doTypeChecking(): computing diagnostics using language service');
|
||||
// Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
|
||||
diagnostics.push(
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSemanticDiagnostics(fileName),
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...this._languageService.getSyntacticDiagnostics(fileName));
|
||||
}
|
||||
return diagnostics;
|
||||
}
|
||||
}
|
||||
exports.TsCompiler = TsCompiler;
|
||||
8
node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.d.ts
generated
vendored
Normal file
8
node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { CompilerInstance, CompiledOutput, StringMap, TsJestCompileOptions } from '../../types';
|
||||
import type { ConfigSet } from '../config/config-set';
|
||||
export declare class TsJestCompiler implements CompilerInstance {
|
||||
private readonly _compilerInstance;
|
||||
constructor(configSet: ConfigSet, runtimeCacheFS: StringMap);
|
||||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
||||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
|
||||
}
|
||||
18
node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js
generated
vendored
Normal file
18
node_modules/ts-jest/dist/legacy/compiler/ts-jest-compiler.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestCompiler = void 0;
|
||||
const ts_compiler_1 = require("./ts-compiler");
|
||||
class TsJestCompiler {
|
||||
_compilerInstance;
|
||||
constructor(configSet, runtimeCacheFS) {
|
||||
// Later we can add swc/esbuild or other typescript compiler instance here
|
||||
this._compilerInstance = new ts_compiler_1.TsCompiler(configSet, runtimeCacheFS);
|
||||
}
|
||||
getResolvedModules(fileContent, fileName, runtimeCacheFS) {
|
||||
return this._compilerInstance.getResolvedModules(fileContent, fileName, runtimeCacheFS);
|
||||
}
|
||||
getCompiledOutput(fileContent, fileName, options) {
|
||||
return this._compilerInstance.getCompiledOutput(fileContent, fileName, options);
|
||||
}
|
||||
}
|
||||
exports.TsJestCompiler = TsJestCompiler;
|
||||
36
node_modules/ts-jest/dist/legacy/config/config-set.d.ts
generated
vendored
Normal file
36
node_modules/ts-jest/dist/legacy/config/config-set.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { Logger } from 'bs-logger';
|
||||
import type * as ts from 'typescript';
|
||||
import type { TsConfigCompilerOptionsJson } from '../../config';
|
||||
import type { RawCompilerOptions } from '../../raw-compiler-options';
|
||||
import type { TsJestAstTransformer, TsJestTransformOptions, TTypeScript } from '../../types';
|
||||
export declare class ConfigSet {
|
||||
readonly parentLogger?: Logger | undefined;
|
||||
/**
|
||||
* Use by e2e, don't mark as internal
|
||||
*/
|
||||
readonly tsJestDigest: string;
|
||||
readonly logger: Logger;
|
||||
readonly compilerModule: TTypeScript;
|
||||
readonly isolatedModules: boolean;
|
||||
readonly cwd: string;
|
||||
readonly rootDir: string;
|
||||
cacheSuffix: string;
|
||||
tsCacheDir: string | undefined;
|
||||
parsedTsConfig: ts.ParsedCommandLine | Record<string, any>;
|
||||
resolvedTransformers: TsJestAstTransformer;
|
||||
useESM: boolean;
|
||||
constructor(jestConfig: TsJestTransformOptions['config'] | undefined, parentLogger?: Logger | undefined);
|
||||
/**
|
||||
* Load TypeScript configuration. Returns the parsed TypeScript config and any `tsconfig` options specified in ts-jest
|
||||
* Subclasses which extend `ConfigSet` can override the default behavior
|
||||
*/
|
||||
protected _resolveTsConfig(compilerOptions?: RawCompilerOptions | TsConfigCompilerOptionsJson, resolvedConfigFile?: string): Record<string, any>;
|
||||
isTestFile(fileName: string): boolean;
|
||||
shouldStringifyContent(filePath: string): boolean;
|
||||
raiseDiagnostics(diagnostics: ts.Diagnostic[], filePath?: string, logger?: Logger): void;
|
||||
shouldReportDiagnostics(filePath: string): boolean;
|
||||
resolvePath(inputPath: string, { throwIfMissing, nodeResolve }?: {
|
||||
throwIfMissing?: boolean;
|
||||
nodeResolve?: boolean;
|
||||
}): string;
|
||||
}
|
||||
621
node_modules/ts-jest/dist/legacy/config/config-set.js
generated
vendored
Normal file
621
node_modules/ts-jest/dist/legacy/config/config-set.js
generated
vendored
Normal file
@@ -0,0 +1,621 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ConfigSet = exports.TS_JEST_OUT_DIR = exports.IGNORE_DIAGNOSTIC_CODES = exports.MY_DIGEST = void 0;
|
||||
/**
|
||||
* This is the core of settings and so ts-jest.
|
||||
* Since configuration are used to create a good cache key, everything
|
||||
* depending on it is here. Fast jest relies on correct cache keys
|
||||
* depending on all settings that could affect the generated output.
|
||||
*
|
||||
* The big issue is that jest calls first `getCacheKey()` with stringified
|
||||
* version of the `jest.ProjectConfig`, and then later it calls `process()`
|
||||
* with the complete, object version of it.
|
||||
*/
|
||||
const fs_1 = require("fs");
|
||||
const module_1 = __importDefault(require("module"));
|
||||
const path_1 = require("path");
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const jest_util_1 = require("jest-util");
|
||||
const json5_1 = __importDefault(require("json5"));
|
||||
const constants_1 = require("../../constants");
|
||||
const hoistJestTransformer = __importStar(require("../../transformers/hoist-jest"));
|
||||
const utils_1 = require("../../utils");
|
||||
const backports_1 = require("../../utils/backports");
|
||||
const importer_1 = require("../../utils/importer");
|
||||
const messages_1 = require("../../utils/messages");
|
||||
const normalize_slashes_1 = require("../../utils/normalize-slashes");
|
||||
const sha1_1 = require("../../utils/sha1");
|
||||
const ts_error_1 = require("../../utils/ts-error");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.MY_DIGEST = (0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../../.ts-jest-digest'), 'utf8');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.IGNORE_DIAGNOSTIC_CODES = [
|
||||
6059, // "'rootDir' is expected to contain all source files."
|
||||
18002, // "The 'files' list in config file is empty."
|
||||
18003, // "No inputs were found in config file."
|
||||
];
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.TS_JEST_OUT_DIR = '$$ts-jest$$';
|
||||
const normalizeRegex = (pattern) => pattern ? (typeof pattern === 'string' ? pattern : pattern.source) : undefined;
|
||||
const toDiagnosticCode = (code) => code ? parseInt(`${code}`.trim().replace(/^TS/, ''), 10) ?? undefined : undefined;
|
||||
const toDiagnosticCodeList = (items, into = []) => {
|
||||
for (let item of items) {
|
||||
if (typeof item === 'string') {
|
||||
const children = item.trim().split(/\s*,\s*/g);
|
||||
if (children.length > 1) {
|
||||
toDiagnosticCodeList(children, into);
|
||||
continue;
|
||||
}
|
||||
item = children[0];
|
||||
}
|
||||
if (!item)
|
||||
continue;
|
||||
const code = toDiagnosticCode(item);
|
||||
if (code && !into.includes(code))
|
||||
into.push(code);
|
||||
}
|
||||
return into;
|
||||
};
|
||||
const requireFromString = (code, fileName) => {
|
||||
// @ts-expect-error `_nodeModulePaths` is not exposed in typing
|
||||
const paths = module_1.default._nodeModulePaths((0, path_1.dirname)(fileName));
|
||||
const parent = module.parent;
|
||||
const m = new module_1.default(fileName, parent);
|
||||
m.filename = fileName;
|
||||
m.paths = [].concat(paths);
|
||||
// @ts-expect-error `_compile` is not exposed in typing
|
||||
m._compile(code, fileName);
|
||||
const exports = m.exports;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
parent && parent.children && parent.children.splice(parent.children.indexOf(m), 1);
|
||||
return exports;
|
||||
};
|
||||
class ConfigSet {
|
||||
parentLogger;
|
||||
/**
|
||||
* Use by e2e, don't mark as internal
|
||||
*/
|
||||
tsJestDigest = exports.MY_DIGEST;
|
||||
logger;
|
||||
compilerModule;
|
||||
isolatedModules;
|
||||
cwd;
|
||||
rootDir;
|
||||
cacheSuffix;
|
||||
tsCacheDir;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
parsedTsConfig;
|
||||
resolvedTransformers = {
|
||||
before: [],
|
||||
after: [],
|
||||
afterDeclarations: [],
|
||||
};
|
||||
useESM = false;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
babelConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
babelJestTransformer;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_jestCfg;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_diagnostics;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_stringifyContentRegExp;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_matchablePatterns;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_matchTestFilePath;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_shouldIgnoreDiagnosticsForFile;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_overriddenCompilerOptions = {
|
||||
inlineSourceMap: false,
|
||||
declaration: false, // we don't want to create declaration files
|
||||
isolatedDeclarations: false, // we don't want to create declaration files
|
||||
noEmit: false, // set to true will make compiler API not emit any compiled results.
|
||||
// else istanbul related will be dropped
|
||||
removeComments: false,
|
||||
// to clear out else it's buggy
|
||||
out: undefined,
|
||||
outFile: undefined,
|
||||
composite: undefined, // see https://github.com/TypeStrong/ts-node/pull/657/files
|
||||
declarationDir: undefined,
|
||||
declarationMap: undefined,
|
||||
emitDeclarationOnly: undefined,
|
||||
sourceRoot: undefined,
|
||||
tsBuildInfoFile: undefined,
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
tsconfigFilePath;
|
||||
constructor(jestConfig, parentLogger) {
|
||||
this.parentLogger = parentLogger;
|
||||
this.logger = this.parentLogger
|
||||
? this.parentLogger.child({ [bs_logger_1.LogContexts.namespace]: 'config' })
|
||||
: utils_1.rootLogger.child({ namespace: 'config' });
|
||||
this._backportJestCfg(jestConfig ?? Object.create(null));
|
||||
this.cwd = (0, path_1.normalize)(this._jestCfg.cwd ?? process.cwd());
|
||||
this.rootDir = (0, path_1.normalize)(this._jestCfg.rootDir ?? this.cwd);
|
||||
const tsJestCfg = this._jestCfg.globals && this._jestCfg.globals['ts-jest'];
|
||||
const options = tsJestCfg ?? Object.create(null);
|
||||
// compiler module
|
||||
this.compilerModule = importer_1.importer.typescript("Using \"ts-jest\" requires this package to be installed." /* ImportReasons.TsJest */, options.compiler ?? 'typescript');
|
||||
this.logger.debug({ compilerModule: this.compilerModule }, 'normalized compiler module config via ts-jest option');
|
||||
this._setupConfigSet(options);
|
||||
this._matchablePatterns = [...this._jestCfg.testMatch, ...this._jestCfg.testRegex].filter((pattern) =>
|
||||
/**
|
||||
* jest config testRegex doesn't always deliver the correct RegExp object
|
||||
* See https://github.com/facebook/jest/issues/9778
|
||||
*/
|
||||
pattern instanceof RegExp || typeof pattern === 'string');
|
||||
if (!this._matchablePatterns.length) {
|
||||
this._matchablePatterns.push(...constants_1.DEFAULT_JEST_TEST_MATCH);
|
||||
}
|
||||
this._matchTestFilePath = (0, jest_util_1.globsToMatcher)(this._matchablePatterns.filter((pattern) => typeof pattern === 'string'));
|
||||
// isolatedModules
|
||||
if (options.isolatedModules) {
|
||||
this.parsedTsConfig.options.isolatedModules = true;
|
||||
if (this.tsconfigFilePath) {
|
||||
this.logger.warn((0, messages_1.interpolate)("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\" in {{tsconfigFilePath}} instead, see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithTsconfigPath */, {
|
||||
tsconfigFilePath: this.tsconfigFilePath,
|
||||
}));
|
||||
}
|
||||
else {
|
||||
this.logger.warn("\n The \"ts-jest\" config option \"isolatedModules\" is deprecated and will be removed in v30.0.0. Please use \"isolatedModules: true\", see https://www.typescriptlang.org/tsconfig/#isolatedModules\n " /* Deprecations.IsolatedModulesWithoutTsconfigPath */);
|
||||
}
|
||||
}
|
||||
this.isolatedModules = this.parsedTsConfig.options.isolatedModules ?? false;
|
||||
this._resolveTsCacheDir();
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_backportJestCfg(jestCfg) {
|
||||
const config = (0, backports_1.backportJestConfig)(this.logger, jestCfg);
|
||||
this.logger.debug({ jestConfig: config }, 'normalized jest config');
|
||||
this._jestCfg = {
|
||||
...config,
|
||||
testMatch: config.testMatch ?? constants_1.DEFAULT_JEST_TEST_MATCH,
|
||||
testRegex: config.testRegex ?? [],
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_setupConfigSet(options) {
|
||||
// useESM
|
||||
this.useESM = options.useESM ?? false;
|
||||
// babel config (for babel-jest) default is undefined so we don't need to have fallback like tsConfig
|
||||
if (!options.babelConfig) {
|
||||
this.logger.debug('babel is disabled');
|
||||
}
|
||||
else {
|
||||
const baseBabelCfg = { cwd: this.cwd };
|
||||
if (typeof options.babelConfig === 'string') {
|
||||
const babelCfgPath = this.resolvePath(options.babelConfig);
|
||||
const babelFileExtName = (0, path_1.extname)(options.babelConfig);
|
||||
if (babelFileExtName === '.js' || babelFileExtName === '.cjs') {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...require(babelCfgPath),
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...json5_1.default.parse((0, fs_1.readFileSync)(babelCfgPath, 'utf-8')),
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (typeof options.babelConfig === 'object') {
|
||||
this.babelConfig = {
|
||||
...baseBabelCfg,
|
||||
...options.babelConfig,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this.babelConfig = baseBabelCfg;
|
||||
}
|
||||
this.logger.debug({ babelConfig: this.babelConfig }, 'normalized babel config via ts-jest option');
|
||||
this.babelJestTransformer = importer_1.importer
|
||||
.babelJest("Using \"babel-jest\" requires this package to be installed." /* ImportReasons.BabelJest */)
|
||||
.createTransformer(this.babelConfig);
|
||||
this.logger.debug('created babel-jest transformer');
|
||||
}
|
||||
// diagnostics
|
||||
const diagnosticsOpt = options.diagnostics ?? true;
|
||||
const ignoreList = [...exports.IGNORE_DIAGNOSTIC_CODES];
|
||||
if (typeof diagnosticsOpt === 'object') {
|
||||
const { ignoreCodes } = diagnosticsOpt;
|
||||
if (ignoreCodes) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
Array.isArray(ignoreCodes) ? ignoreList.push(...ignoreCodes) : ignoreList.push(ignoreCodes);
|
||||
}
|
||||
this._diagnostics = {
|
||||
pretty: diagnosticsOpt.pretty ?? true,
|
||||
exclude: diagnosticsOpt.exclude ?? [],
|
||||
ignoreCodes: toDiagnosticCodeList(ignoreList),
|
||||
throws: !diagnosticsOpt.warnOnly,
|
||||
};
|
||||
}
|
||||
else {
|
||||
this._diagnostics = {
|
||||
ignoreCodes: diagnosticsOpt ? toDiagnosticCodeList(ignoreList) : [],
|
||||
exclude: [],
|
||||
pretty: true,
|
||||
throws: diagnosticsOpt,
|
||||
};
|
||||
}
|
||||
if (diagnosticsOpt) {
|
||||
this._shouldIgnoreDiagnosticsForFile = this._diagnostics.exclude.length
|
||||
? (0, jest_util_1.globsToMatcher)(this._diagnostics.exclude)
|
||||
: () => false;
|
||||
}
|
||||
else {
|
||||
this._shouldIgnoreDiagnosticsForFile = () => true;
|
||||
}
|
||||
this.logger.debug({ diagnostics: this._diagnostics }, 'normalized diagnostics config via ts-jest option');
|
||||
// tsconfig
|
||||
const tsconfigOpt = options.tsconfig;
|
||||
const configFilePath = typeof tsconfigOpt === 'string' ? this.resolvePath(tsconfigOpt) : undefined;
|
||||
this.parsedTsConfig = this._getAndResolveTsConfig(typeof tsconfigOpt === 'object' ? tsconfigOpt : undefined, configFilePath);
|
||||
// throw errors if any matching wanted diagnostics
|
||||
this.raiseDiagnostics(this.parsedTsConfig.errors, configFilePath);
|
||||
this.logger.debug({ tsconfig: this.parsedTsConfig }, 'normalized typescript config via ts-jest option');
|
||||
// transformers
|
||||
this.resolvedTransformers.before = [
|
||||
{
|
||||
factory: hoistJestTransformer.factory,
|
||||
name: hoistJestTransformer.name,
|
||||
version: hoistJestTransformer.version,
|
||||
},
|
||||
];
|
||||
const { astTransformers } = options;
|
||||
if (astTransformers) {
|
||||
const resolveTransformerFunc = (transformerPath) => {
|
||||
let transformerFunc;
|
||||
if ((0, path_1.extname)(transformerPath) === '.ts') {
|
||||
const compiledTransformer = importer_1.importer
|
||||
.esBuild("Using \"esbuild\" requires this package to be installed." /* ImportReasons.EsBuild */)
|
||||
.transformSync((0, fs_1.readFileSync)(transformerPath, 'utf-8'), {
|
||||
loader: 'ts',
|
||||
format: 'cjs',
|
||||
target: 'es2015',
|
||||
}).code;
|
||||
transformerFunc = requireFromString(compiledTransformer, transformerPath.replace('.ts', '.js'));
|
||||
}
|
||||
else {
|
||||
transformerFunc = require(transformerPath);
|
||||
}
|
||||
if (!transformerFunc.version) {
|
||||
this.logger.warn("The AST transformer {{file}} must have an `export const version = <your_transformer_version>`" /* Errors.MissingTransformerVersion */, { file: transformerPath });
|
||||
}
|
||||
if (!transformerFunc.name) {
|
||||
this.logger.warn("The AST transformer {{file}} must have an `export const name = <your_transformer_name>`" /* Errors.MissingTransformerName */, { file: transformerPath });
|
||||
}
|
||||
return transformerFunc;
|
||||
};
|
||||
const resolveTransformers = (transformers) => transformers.map((transformer) => {
|
||||
if (typeof transformer === 'string') {
|
||||
return resolveTransformerFunc(this.resolvePath(transformer, { nodeResolve: true }));
|
||||
}
|
||||
else {
|
||||
return {
|
||||
...resolveTransformerFunc(this.resolvePath(transformer.path, { nodeResolve: true })),
|
||||
options: transformer.options,
|
||||
};
|
||||
}
|
||||
});
|
||||
if (astTransformers.before) {
|
||||
/* istanbul ignore next (already covered in unit test) */
|
||||
this.resolvedTransformers.before?.push(...resolveTransformers(astTransformers.before));
|
||||
}
|
||||
if (astTransformers.after) {
|
||||
this.resolvedTransformers = {
|
||||
...this.resolvedTransformers,
|
||||
after: resolveTransformers(astTransformers.after),
|
||||
};
|
||||
}
|
||||
if (astTransformers.afterDeclarations) {
|
||||
this.resolvedTransformers = {
|
||||
...this.resolvedTransformers,
|
||||
afterDeclarations: resolveTransformers(astTransformers.afterDeclarations),
|
||||
};
|
||||
}
|
||||
}
|
||||
this.logger.debug({ customTransformers: this.resolvedTransformers }, 'normalized custom AST transformers via ts-jest option');
|
||||
// stringifyContentPathRegex
|
||||
if (options.stringifyContentPathRegex) {
|
||||
this._stringifyContentRegExp =
|
||||
typeof options.stringifyContentPathRegex === 'string'
|
||||
? new RegExp(normalizeRegex(options.stringifyContentPathRegex)) // eslint-disable-line @typescript-eslint/no-non-null-assertion
|
||||
: options.stringifyContentPathRegex;
|
||||
this.logger.debug({ stringifyContentPathRegex: this._stringifyContentRegExp }, 'normalized stringifyContentPathRegex config via ts-jest option');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_resolveTsCacheDir() {
|
||||
this.cacheSuffix = (0, sha1_1.sha1)((0, utils_1.stringify)({
|
||||
version: this.compilerModule.version,
|
||||
digest: this.tsJestDigest,
|
||||
babelConfig: this.babelConfig,
|
||||
tsconfig: {
|
||||
options: this.parsedTsConfig.options,
|
||||
raw: this.parsedTsConfig.raw,
|
||||
},
|
||||
isolatedModules: this.isolatedModules,
|
||||
diagnostics: this._diagnostics,
|
||||
transformers: Object.values(this.resolvedTransformers)
|
||||
.reduce((prevVal, currentVal) => [...prevVal, currentVal])
|
||||
.map((transformer) => `${transformer.name}-${transformer.version}`),
|
||||
}));
|
||||
if (!this._jestCfg.cache) {
|
||||
this.logger.debug('file caching disabled');
|
||||
}
|
||||
else {
|
||||
const res = (0, path_1.join)(this._jestCfg.cacheDirectory, 'ts-jest', this.cacheSuffix.substr(0, 2), this.cacheSuffix.substr(2));
|
||||
this.logger.debug({ cacheDirectory: res }, 'will use file caching');
|
||||
this.tsCacheDir = res;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
_getAndResolveTsConfig(compilerOptions, resolvedConfigFile) {
|
||||
const result = this._resolveTsConfig(compilerOptions, resolvedConfigFile);
|
||||
const { _overriddenCompilerOptions: forcedOptions } = this;
|
||||
const finalOptions = result.options;
|
||||
// Target ES2015 output by default (instead of ES3).
|
||||
if (finalOptions.target === undefined) {
|
||||
finalOptions.target = this.compilerModule.ScriptTarget.ES2015;
|
||||
}
|
||||
// check the module interoperability
|
||||
const target = finalOptions.target;
|
||||
// compute the default if not set
|
||||
const defaultModule = [this.compilerModule.ScriptTarget.ES3, this.compilerModule.ScriptTarget.ES5].includes(target)
|
||||
? this.compilerModule.ModuleKind.CommonJS
|
||||
: this.compilerModule.ModuleKind.ESNext;
|
||||
const moduleValue = finalOptions.module ?? defaultModule;
|
||||
const warningModulesForEsmInterop = [
|
||||
this.compilerModule.ModuleKind.CommonJS,
|
||||
this.compilerModule.ModuleKind.Node16,
|
||||
this.compilerModule.ModuleKind.NodeNext,
|
||||
];
|
||||
if (!this.babelConfig &&
|
||||
!warningModulesForEsmInterop.includes(moduleValue) &&
|
||||
!(finalOptions.esModuleInterop || finalOptions.allowSyntheticDefaultImports)) {
|
||||
result.errors.push({
|
||||
code: utils_1.TsJestDiagnosticCodes.ConfigModuleOption,
|
||||
messageText: "If you have issues related to imports, you should consider setting `esModuleInterop` to `true` in your TypeScript configuration file (usually `tsconfig.json`). See https://blogs.msdn.microsoft.com/typescript/2018/01/31/announcing-typescript-2-7/#easier-ecmascript-module-interoperability for more information." /* Errors.ConfigNoModuleInterop */,
|
||||
category: this.compilerModule.DiagnosticCategory.Message,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
});
|
||||
}
|
||||
// Make sure when allowJs is enabled, outDir is required to have when using allowJs: true
|
||||
if (finalOptions.allowJs && !finalOptions.outDir) {
|
||||
finalOptions.outDir = exports.TS_JEST_OUT_DIR;
|
||||
}
|
||||
// ensure undefined are removed and other values are overridden
|
||||
for (const key of Object.keys(forcedOptions)) {
|
||||
const val = forcedOptions[key];
|
||||
if (val === undefined) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||
delete finalOptions[key];
|
||||
}
|
||||
else {
|
||||
finalOptions[key] = val;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* See https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
|
||||
* Every time this page is updated, we also need to update here. Here we only show warning message for Node LTS versions
|
||||
*/
|
||||
const nodeJsVer = process.version;
|
||||
const compilationTarget = result.options.target;
|
||||
const TARGET_TO_VERSION_MAPPING = {
|
||||
[this.compilerModule.ScriptTarget.ES2018]: 'es2018',
|
||||
[this.compilerModule.ScriptTarget.ES2019]: 'es2019',
|
||||
[this.compilerModule.ScriptTarget.ES2020]: 'es2020',
|
||||
[this.compilerModule.ScriptTarget.ESNext]: 'ESNext',
|
||||
};
|
||||
/* istanbul ignore next (cover by e2e) */
|
||||
if (compilationTarget &&
|
||||
!this.babelConfig &&
|
||||
nodeJsVer.startsWith('v12') &&
|
||||
compilationTarget > this.compilerModule.ScriptTarget.ES2019) {
|
||||
const message = (0, messages_1.interpolate)("There is a mismatch between your NodeJs version {{nodeJsVer}} and your TypeScript target {{compilationTarget}}. This might lead to some unexpected errors when running tests with `ts-jest`. To fix this, you can check https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping" /* Errors.MismatchNodeTargetMapping */, {
|
||||
nodeJsVer: process.version,
|
||||
compilationTarget: TARGET_TO_VERSION_MAPPING[compilationTarget],
|
||||
});
|
||||
this.logger.warn(message);
|
||||
}
|
||||
const resultOptions = result.options;
|
||||
const sourceMap = resultOptions.sourceMap ?? true;
|
||||
return {
|
||||
...result,
|
||||
options: {
|
||||
...resultOptions,
|
||||
sourceMap,
|
||||
inlineSources: sourceMap,
|
||||
module: resultOptions.module ?? this.compilerModule.ModuleKind.CommonJS,
|
||||
},
|
||||
};
|
||||
}
|
||||
_resolveTsConfig(compilerOptions, resolvedConfigFile) {
|
||||
let config = { compilerOptions: Object.create(null) };
|
||||
let basePath = (0, normalize_slashes_1.normalizeSlashes)(this.rootDir);
|
||||
const ts = this.compilerModule;
|
||||
// Read project configuration when available.
|
||||
this.tsconfigFilePath = resolvedConfigFile
|
||||
? (0, normalize_slashes_1.normalizeSlashes)(resolvedConfigFile)
|
||||
: ts.findConfigFile((0, normalize_slashes_1.normalizeSlashes)(this.rootDir), ts.sys.fileExists);
|
||||
if (this.tsconfigFilePath) {
|
||||
this.logger.debug({ tsConfigFileName: this.tsconfigFilePath }, 'readTsConfig(): reading', this.tsconfigFilePath);
|
||||
const result = ts.readConfigFile(this.tsconfigFilePath, ts.sys.readFile);
|
||||
// Return diagnostics.
|
||||
if (result.error) {
|
||||
return { errors: [result.error], fileNames: [], options: {} };
|
||||
}
|
||||
config = result.config;
|
||||
basePath = (0, normalize_slashes_1.normalizeSlashes)((0, path_1.dirname)(this.tsconfigFilePath));
|
||||
}
|
||||
// Override default configuration options `ts-jest` requires.
|
||||
config.compilerOptions = {
|
||||
...config.compilerOptions,
|
||||
...compilerOptions,
|
||||
};
|
||||
// parse json, merge config extending others, ...
|
||||
return ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, this.tsconfigFilePath);
|
||||
}
|
||||
isTestFile(fileName) {
|
||||
return this._matchablePatterns.some((pattern) => typeof pattern === 'string' ? this._matchTestFilePath(fileName) : pattern.test(fileName));
|
||||
}
|
||||
shouldStringifyContent(filePath) {
|
||||
return this._stringifyContentRegExp ? this._stringifyContentRegExp.test(filePath) : false;
|
||||
}
|
||||
raiseDiagnostics(diagnostics, filePath, logger = this.logger) {
|
||||
const { ignoreCodes } = this._diagnostics;
|
||||
const { DiagnosticCategory } = this.compilerModule;
|
||||
const filteredDiagnostics = filePath && !this.shouldReportDiagnostics(filePath)
|
||||
? []
|
||||
: diagnostics.filter((diagnostic) => {
|
||||
if (diagnostic.file?.fileName && !this.shouldReportDiagnostics(diagnostic.file.fileName)) {
|
||||
return false;
|
||||
}
|
||||
return !ignoreCodes.includes(diagnostic.code);
|
||||
});
|
||||
if (!filteredDiagnostics.length)
|
||||
return;
|
||||
const error = this.createTsError(filteredDiagnostics);
|
||||
// only throw if `warnOnly` and it is a warning or error
|
||||
const importantCategories = [DiagnosticCategory.Warning, DiagnosticCategory.Error];
|
||||
if (this._diagnostics.throws && filteredDiagnostics.some((d) => importantCategories.includes(d.category))) {
|
||||
throw error;
|
||||
}
|
||||
logger.warn({ error }, error.message);
|
||||
}
|
||||
shouldReportDiagnostics(filePath) {
|
||||
const fileExtension = (0, path_1.extname)(filePath);
|
||||
return constants_1.JS_JSX_EXTENSIONS.includes(fileExtension)
|
||||
? this.parsedTsConfig.options.checkJs && !this._shouldIgnoreDiagnosticsForFile(filePath)
|
||||
: !this._shouldIgnoreDiagnosticsForFile(filePath);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
createTsError(diagnostics) {
|
||||
const formatDiagnostics = this._diagnostics.pretty
|
||||
? this.compilerModule.formatDiagnosticsWithColorAndContext
|
||||
: this.compilerModule.formatDiagnostics;
|
||||
/* istanbul ignore next (not possible to cover) */
|
||||
const diagnosticHost = {
|
||||
getNewLine: () => '\n',
|
||||
getCurrentDirectory: () => this.cwd,
|
||||
getCanonicalFileName: (path) => path,
|
||||
};
|
||||
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
|
||||
const diagnosticCodes = diagnostics.map((x) => x.code);
|
||||
return new ts_error_1.TSError(diagnosticText, diagnosticCodes);
|
||||
}
|
||||
resolvePath(inputPath, { throwIfMissing = true, nodeResolve = false } = {}) {
|
||||
let path = inputPath;
|
||||
let nodeResolved = false;
|
||||
if (path.startsWith('<rootDir>')) {
|
||||
path = (0, path_1.resolve)((0, path_1.join)(this.rootDir, path.substr(9)));
|
||||
}
|
||||
else if (!(0, path_1.isAbsolute)(path)) {
|
||||
if (!path.startsWith('.') && nodeResolve) {
|
||||
try {
|
||||
path = require.resolve(path);
|
||||
nodeResolved = true;
|
||||
}
|
||||
catch {
|
||||
this.logger.debug({ path }, 'failed to resolve path', path);
|
||||
}
|
||||
}
|
||||
if (!nodeResolved) {
|
||||
path = (0, path_1.resolve)(this.cwd, path);
|
||||
}
|
||||
}
|
||||
if (!nodeResolved && nodeResolve) {
|
||||
try {
|
||||
path = require.resolve(path);
|
||||
nodeResolved = true;
|
||||
}
|
||||
catch {
|
||||
this.logger.debug({ path }, 'failed to resolve path', path);
|
||||
}
|
||||
}
|
||||
if (throwIfMissing && !(0, fs_1.existsSync)(path)) {
|
||||
throw new Error((0, messages_1.interpolate)("File not found: {{inputPath}} (resolved as: {{resolvedPath}})" /* Errors.FileNotFound */, { inputPath, resolvedPath: path }));
|
||||
}
|
||||
this.logger.debug({ fromPath: inputPath, toPath: path }, 'resolved path from', inputPath, 'to', path);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
exports.ConfigSet = ConfigSet;
|
||||
6
node_modules/ts-jest/dist/legacy/index.d.ts
generated
vendored
Normal file
6
node_modules/ts-jest/dist/legacy/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { TsJestTransformerOptions } from '../types';
|
||||
import { TsJestTransformer } from './ts-jest-transformer';
|
||||
declare const _default: {
|
||||
createTransformer: (tsJestConfig?: TsJestTransformerOptions) => TsJestTransformer;
|
||||
};
|
||||
export default _default;
|
||||
6
node_modules/ts-jest/dist/legacy/index.js
generated
vendored
Normal file
6
node_modules/ts-jest/dist/legacy/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ts_jest_transformer_1 = require("./ts-jest-transformer");
|
||||
exports.default = {
|
||||
createTransformer: (tsJestConfig) => new ts_jest_transformer_1.TsJestTransformer(tsJestConfig),
|
||||
};
|
||||
28
node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts
generated
vendored
Normal file
28
node_modules/ts-jest/dist/legacy/ts-jest-transformer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { SyncTransformer, TransformedSource } from '@jest/transform';
|
||||
import type { CompilerInstance, TsJestTransformerOptions, TsJestTransformOptions } from '../types';
|
||||
import { ConfigSet } from './config/config-set';
|
||||
export declare class TsJestTransformer implements SyncTransformer<TsJestTransformerOptions> {
|
||||
private readonly transformerOptions?;
|
||||
private readonly _logger;
|
||||
protected _compiler: CompilerInstance;
|
||||
private _transformCfgStr;
|
||||
private _depGraphs;
|
||||
private _watchMode;
|
||||
constructor(transformerOptions?: TsJestTransformerOptions | undefined);
|
||||
private _configsFor;
|
||||
protected _createConfigSet(config: TsJestTransformOptions['config'] | undefined): ConfigSet;
|
||||
protected _createCompiler(configSet: ConfigSet, cacheFS: Map<string, string>): void;
|
||||
process(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): TransformedSource;
|
||||
processAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<TransformedSource>;
|
||||
private processWithTs;
|
||||
private runTsJestHook;
|
||||
/**
|
||||
* Jest uses this to cache the compiled version of a file
|
||||
*
|
||||
* @see https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getCacheKey(fileContent: string, filePath: string, transformOptions: TsJestTransformOptions): string;
|
||||
getCacheKeyAsync(sourceText: string, sourcePath: string, transformOptions: TsJestTransformOptions): Promise<string>;
|
||||
}
|
||||
293
node_modules/ts-jest/dist/legacy/ts-jest-transformer.js
generated
vendored
Normal file
293
node_modules/ts-jest/dist/legacy/ts-jest-transformer.js
generated
vendored
Normal file
@@ -0,0 +1,293 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestTransformer = exports.CACHE_KEY_EL_SEPARATOR = void 0;
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const constants_1 = require("../constants");
|
||||
const utils_1 = require("../utils");
|
||||
const importer_1 = require("../utils/importer");
|
||||
const messages_1 = require("../utils/messages");
|
||||
const sha1_1 = require("../utils/sha1");
|
||||
const compiler_1 = require("./compiler");
|
||||
const compiler_utils_1 = require("./compiler/compiler-utils");
|
||||
const config_set_1 = require("./config/config-set");
|
||||
const isNodeModule = (filePath) => {
|
||||
return path_1.default.normalize(filePath).split(path_1.default.sep).includes('node_modules');
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.CACHE_KEY_EL_SEPARATOR = '\x00';
|
||||
class TsJestTransformer {
|
||||
transformerOptions;
|
||||
/**
|
||||
* cache ConfigSet between test runs
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
static _cachedConfigSets = [];
|
||||
_logger;
|
||||
_compiler;
|
||||
_transformCfgStr;
|
||||
_depGraphs = new Map();
|
||||
_watchMode = false;
|
||||
constructor(transformerOptions) {
|
||||
this.transformerOptions = transformerOptions;
|
||||
this._logger = utils_1.rootLogger.child({ namespace: 'ts-jest-transformer' });
|
||||
/**
|
||||
* For some unknown reasons, `this` is undefined in `getCacheKey` and `process`
|
||||
* when running Jest in ESM mode
|
||||
*/
|
||||
this.getCacheKey = this.getCacheKey.bind(this);
|
||||
this.getCacheKeyAsync = this.getCacheKeyAsync.bind(this);
|
||||
this.process = this.process.bind(this);
|
||||
this.processAsync = this.processAsync.bind(this);
|
||||
this._logger.debug('created new transformer');
|
||||
process.env.TS_JEST = '1';
|
||||
}
|
||||
_configsFor(transformOptions) {
|
||||
const { config, cacheFS } = transformOptions;
|
||||
const ccs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.value === config);
|
||||
let configSet;
|
||||
if (ccs) {
|
||||
this._transformCfgStr = ccs.transformerCfgStr;
|
||||
this._compiler = ccs.compiler;
|
||||
this._depGraphs = ccs.depGraphs;
|
||||
this._watchMode = ccs.watchMode;
|
||||
configSet = ccs.configSet;
|
||||
}
|
||||
else {
|
||||
// try to look-it up by stringified version
|
||||
const serializedJestCfg = (0, utils_1.stringify)(config);
|
||||
const serializedCcs = TsJestTransformer._cachedConfigSets.find((cs) => cs.jestConfig.serialized === serializedJestCfg);
|
||||
if (serializedCcs) {
|
||||
// update the object so that we can find it later
|
||||
// this happens because jest first calls getCacheKey with stringified version of
|
||||
// the config, and then it calls the transformer with the proper object
|
||||
serializedCcs.jestConfig.value = config;
|
||||
this._transformCfgStr = serializedCcs.transformerCfgStr;
|
||||
this._compiler = serializedCcs.compiler;
|
||||
this._depGraphs = serializedCcs.depGraphs;
|
||||
this._watchMode = serializedCcs.watchMode;
|
||||
configSet = serializedCcs.configSet;
|
||||
}
|
||||
else {
|
||||
// create the new record in the index
|
||||
this._logger.info('no matching config-set found, creating a new one');
|
||||
if (config.globals?.['ts-jest']) {
|
||||
this._logger.warn("Define `ts-jest` config under `globals` is deprecated. Please do\ntransform: {\n <transform_regex>: ['ts-jest', { /* ts-jest config goes here in Jest */ }],\n},\nSee more at https://kulshekhar.github.io/ts-jest/docs/getting-started/presets#advanced" /* Deprecations.GlobalsTsJestConfigOption */);
|
||||
}
|
||||
const jestGlobalsConfig = config.globals ?? {};
|
||||
const tsJestGlobalsConfig = jestGlobalsConfig['ts-jest'] ?? {};
|
||||
const migratedConfig = this.transformerOptions
|
||||
? {
|
||||
...config,
|
||||
globals: {
|
||||
...jestGlobalsConfig,
|
||||
'ts-jest': {
|
||||
...tsJestGlobalsConfig,
|
||||
...this.transformerOptions,
|
||||
},
|
||||
},
|
||||
}
|
||||
: config;
|
||||
configSet = this._createConfigSet(migratedConfig);
|
||||
const jest = { ...migratedConfig };
|
||||
// we need to remove some stuff from jest config
|
||||
// this which does not depend on config
|
||||
jest.cacheDirectory = undefined; // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
this._transformCfgStr = `${new utils_1.JsonableValue(jest).serialized}${configSet.cacheSuffix}`;
|
||||
this._createCompiler(configSet, cacheFS);
|
||||
this._watchMode = process.argv.includes('--watch');
|
||||
TsJestTransformer._cachedConfigSets.push({
|
||||
jestConfig: new utils_1.JsonableValue(config),
|
||||
configSet,
|
||||
transformerCfgStr: this._transformCfgStr,
|
||||
compiler: this._compiler,
|
||||
depGraphs: this._depGraphs,
|
||||
watchMode: this._watchMode,
|
||||
});
|
||||
}
|
||||
}
|
||||
return configSet;
|
||||
}
|
||||
_createConfigSet(config) {
|
||||
return new config_set_1.ConfigSet(config);
|
||||
}
|
||||
_createCompiler(configSet, cacheFS) {
|
||||
this._compiler = new compiler_1.TsJestCompiler(configSet, cacheFS);
|
||||
}
|
||||
process(sourceText, sourcePath, transformOptions) {
|
||||
this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
let result = {
|
||||
code: this.processWithTs(sourceText, sourcePath, transformOptions).code,
|
||||
};
|
||||
if (babelJest) {
|
||||
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
||||
// do not instrument here, jest will do it anyway afterwards
|
||||
result = babelJest.process(result.code, sourcePath, {
|
||||
...transformOptions,
|
||||
instrument: false,
|
||||
});
|
||||
}
|
||||
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
||||
return result;
|
||||
}
|
||||
async processAsync(sourceText, sourcePath, transformOptions) {
|
||||
this._logger.debug({ fileName: sourcePath, transformOptions }, 'processing', sourcePath);
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
let result;
|
||||
const processWithTsResult = this.processWithTs(sourceText, sourcePath, transformOptions);
|
||||
result = {
|
||||
code: processWithTsResult.code,
|
||||
};
|
||||
if (processWithTsResult.diagnostics?.length) {
|
||||
throw configs.createTsError(processWithTsResult.diagnostics);
|
||||
}
|
||||
if (babelJest) {
|
||||
this._logger.debug({ fileName: sourcePath }, 'calling babel-jest processor');
|
||||
// do not instrument here, jest will do it anyway afterwards
|
||||
result = await babelJest.processAsync(result.code, sourcePath, {
|
||||
...transformOptions,
|
||||
instrument: false,
|
||||
});
|
||||
}
|
||||
result = this.runTsJestHook(sourcePath, sourceText, transformOptions, result);
|
||||
return result;
|
||||
}
|
||||
processWithTs(sourceText, sourcePath, transformOptions) {
|
||||
let result;
|
||||
const configs = this._configsFor(transformOptions);
|
||||
const shouldStringifyContent = configs.shouldStringifyContent(sourcePath);
|
||||
const babelJest = shouldStringifyContent ? undefined : configs.babelJestTransformer;
|
||||
const isDefinitionFile = sourcePath.endsWith(constants_1.DECLARATION_TYPE_EXT);
|
||||
const isJsFile = constants_1.JS_JSX_REGEX.test(sourcePath);
|
||||
const isTsFile = !isDefinitionFile && constants_1.TS_TSX_REGEX.test(sourcePath);
|
||||
if (shouldStringifyContent) {
|
||||
// handles here what we should simply stringify
|
||||
result = {
|
||||
code: `module.exports=${(0, utils_1.stringify)(sourceText)}`,
|
||||
};
|
||||
}
|
||||
else if (isDefinitionFile) {
|
||||
// do not try to compile declaration files
|
||||
result = {
|
||||
code: '',
|
||||
};
|
||||
}
|
||||
else if (isJsFile || isTsFile) {
|
||||
if (isJsFile && isNodeModule(sourcePath)) {
|
||||
const transpiledResult = typescript_1.default.transpileModule(sourceText, {
|
||||
compilerOptions: {
|
||||
...configs.parsedTsConfig.options,
|
||||
module: transformOptions.supportsStaticESM && transformOptions.transformerConfig.useESM
|
||||
? typescript_1.default.ModuleKind.ESNext
|
||||
: typescript_1.default.ModuleKind.CommonJS,
|
||||
},
|
||||
fileName: sourcePath,
|
||||
});
|
||||
result = {
|
||||
code: (0, compiler_utils_1.updateOutput)(transpiledResult.outputText, sourcePath, transpiledResult.sourceMapText),
|
||||
};
|
||||
}
|
||||
else {
|
||||
// transpile TS code (source maps are included)
|
||||
result = this._compiler.getCompiledOutput(sourceText, sourcePath, {
|
||||
depGraphs: this._depGraphs,
|
||||
supportsStaticESM: transformOptions.supportsStaticESM,
|
||||
watchMode: this._watchMode,
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
// we should not get called for files with other extension than js[x], ts[x] and d.ts,
|
||||
// TypeScript will bail if we try to compile, and if it was to call babel, users can
|
||||
// define the transform value with `babel-jest` for this extension instead
|
||||
const message = babelJest ? "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore. If you still want Babel to process it, add another entry to the `transform` option with value `babel-jest` which key matches this type of files." /* Errors.GotUnknownFileTypeWithBabel */ : "Got a unknown file type to compile (file: {{path}}). To fix this, in your Jest config change the `transform` key which value is `ts-jest` so that it does not match this kind of files anymore." /* Errors.GotUnknownFileTypeWithoutBabel */;
|
||||
this._logger.warn({ fileName: sourcePath }, (0, messages_1.interpolate)(message, { path: sourcePath }));
|
||||
result = {
|
||||
code: sourceText,
|
||||
};
|
||||
}
|
||||
return result;
|
||||
}
|
||||
runTsJestHook(sourcePath, sourceText, transformOptions, compiledOutput) {
|
||||
let hooksFile = process.env.TS_JEST_HOOKS;
|
||||
let hooks;
|
||||
/* istanbul ignore next (cover by e2e) */
|
||||
if (hooksFile) {
|
||||
hooksFile = path_1.default.resolve(this._configsFor(transformOptions).cwd, hooksFile);
|
||||
hooks = importer_1.importer.tryTheseOr(hooksFile, {});
|
||||
}
|
||||
// This is not supposed to be a public API but we keep it as some people use it
|
||||
if (hooks?.afterProcess) {
|
||||
this._logger.debug({ fileName: sourcePath, hookName: 'afterProcess' }, 'calling afterProcess hook');
|
||||
const newResult = hooks.afterProcess([sourceText, sourcePath, transformOptions.config, transformOptions], compiledOutput);
|
||||
if (newResult) {
|
||||
return newResult;
|
||||
}
|
||||
}
|
||||
return compiledOutput;
|
||||
}
|
||||
/**
|
||||
* Jest uses this to cache the compiled version of a file
|
||||
*
|
||||
* @see https://github.com/facebook/jest/blob/v23.5.0/packages/jest-runtime/src/script_transformer.js#L61-L90
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
getCacheKey(fileContent, filePath, transformOptions) {
|
||||
const configs = this._configsFor(transformOptions);
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'computing cache key for', filePath);
|
||||
// we do not instrument, ensure it is false all the time
|
||||
const { supportsStaticESM, instrument = false } = transformOptions;
|
||||
const constructingCacheKeyElements = [
|
||||
this._transformCfgStr,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
configs.rootDir,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
`instrument:${instrument ? 'on' : 'off'}`,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
`supportsStaticESM:${supportsStaticESM ? 'on' : 'off'}`,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
fileContent,
|
||||
exports.CACHE_KEY_EL_SEPARATOR,
|
||||
filePath,
|
||||
];
|
||||
if (!configs.isolatedModules && configs.tsCacheDir) {
|
||||
let resolvedModuleNames;
|
||||
if (this._depGraphs.get(filePath)?.fileContent === fileContent) {
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from disk caching or memory caching for', filePath);
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
resolvedModuleNames = this._depGraphs
|
||||
.get(filePath)
|
||||
.resolvedModuleNames.filter((moduleName) => (0, fs_1.existsSync)(moduleName));
|
||||
}
|
||||
else {
|
||||
this._logger.debug({ fileName: filePath, transformOptions }, 'getting resolved modules from TypeScript API for', filePath);
|
||||
resolvedModuleNames = this._compiler.getResolvedModules(fileContent, filePath, transformOptions.cacheFS);
|
||||
this._depGraphs.set(filePath, {
|
||||
fileContent,
|
||||
resolvedModuleNames,
|
||||
});
|
||||
}
|
||||
resolvedModuleNames.forEach((moduleName) => {
|
||||
constructingCacheKeyElements.push(exports.CACHE_KEY_EL_SEPARATOR, moduleName, exports.CACHE_KEY_EL_SEPARATOR, (0, fs_1.statSync)(moduleName).mtimeMs.toString());
|
||||
});
|
||||
}
|
||||
return (0, sha1_1.sha1)(...constructingCacheKeyElements);
|
||||
}
|
||||
async getCacheKeyAsync(sourceText, sourcePath, transformOptions) {
|
||||
return Promise.resolve(this.getCacheKey(sourceText, sourcePath, transformOptions));
|
||||
}
|
||||
}
|
||||
exports.TsJestTransformer = TsJestTransformer;
|
||||
15
node_modules/ts-jest/dist/presets/all-presets.d.ts
generated
vendored
Normal file
15
node_modules/ts-jest/dist/presets/all-presets.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
declare const allPresets: {
|
||||
readonly defaults: import("..").DefaultPreset;
|
||||
readonly defaultsLegacy: import("..").DefaultLegacyPreset;
|
||||
readonly defaultsESM: import("..").DefaultEsmPreset;
|
||||
readonly defaultsESMLegacy: import("..").DefaultEsmLegacyPreset;
|
||||
readonly jsWithTs: import("..").JsWithTsPreset;
|
||||
readonly jsWithTsLegacy: import("..").JsWithTsLegacyPreset;
|
||||
readonly jsWithTsESM: import("..").JsWithTsEsmPreset;
|
||||
readonly jsWithTsESMLegacy: import("..").JsWithTsEsmLegacyPreset;
|
||||
readonly jsWithBabel: import("..").JsWithBabelPreset;
|
||||
readonly jsWithBabelLegacy: import("..").JsWithBabelLegacyPreset;
|
||||
readonly jsWithBabelESM: import("..").JsWithBabelEsmPreset;
|
||||
readonly jsWithBabelESMLegacy: import("..").JsWithBabelEsmLegacyPreset;
|
||||
};
|
||||
export default allPresets;
|
||||
42
node_modules/ts-jest/dist/presets/all-presets.js
generated
vendored
Normal file
42
node_modules/ts-jest/dist/presets/all-presets.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const create_jest_preset_1 = require("./create-jest-preset");
|
||||
const allPresets = {
|
||||
get defaults() {
|
||||
return (0, create_jest_preset_1.createDefaultPreset)();
|
||||
},
|
||||
get defaultsLegacy() {
|
||||
return (0, create_jest_preset_1.createDefaultLegacyPreset)();
|
||||
},
|
||||
get defaultsESM() {
|
||||
return (0, create_jest_preset_1.createDefaultEsmPreset)();
|
||||
},
|
||||
get defaultsESMLegacy() {
|
||||
return (0, create_jest_preset_1.createDefaultEsmLegacyPreset)();
|
||||
},
|
||||
get jsWithTs() {
|
||||
return (0, create_jest_preset_1.createJsWithTsPreset)();
|
||||
},
|
||||
get jsWithTsLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithTsLegacyPreset)();
|
||||
},
|
||||
get jsWithTsESM() {
|
||||
return (0, create_jest_preset_1.createJsWithTsEsmPreset)();
|
||||
},
|
||||
get jsWithTsESMLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithTsEsmLegacyPreset)();
|
||||
},
|
||||
get jsWithBabel() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelPreset)();
|
||||
},
|
||||
get jsWithBabelLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelLegacyPreset)();
|
||||
},
|
||||
get jsWithBabelESM() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelEsmPreset)();
|
||||
},
|
||||
get jsWithBabelESMLegacy() {
|
||||
return (0, create_jest_preset_1.createJsWithBabelEsmLegacyPreset)();
|
||||
},
|
||||
};
|
||||
exports.default = allPresets;
|
||||
18
node_modules/ts-jest/dist/presets/create-jest-preset.d.ts
generated
vendored
Normal file
18
node_modules/ts-jest/dist/presets/create-jest-preset.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import type { Config } from '@jest/types';
|
||||
import { DefaultEsmLegacyPreset, DefaultEsmPreset, DefaultEsmTransformOptions, DefaultLegacyPreset, DefaultPreset, DefaultTransformOptions, JsWithBabelEsmLegacyPreset, JsWithBabelEsmPreset, JsWithBabelEsmTransformOptions, JsWithBabelLegacyPreset, JsWithBabelPreset, JsWithBabelTransformerOptions, JsWithTsEsmLegacyPreset, JsWithTsEsmPreset, JsWithTsEsmTransformOptions, JsWithTsLegacyPreset, JsWithTsPreset, JsWithTsTransformOptions, TsJestPresets } from '../types';
|
||||
/**
|
||||
* @deprecated use other functions below instead
|
||||
*/
|
||||
export declare function createJestPreset(legacy?: boolean, allowJs?: boolean, extraOptions?: Config.InitialOptions): TsJestPresets;
|
||||
export declare function createDefaultPreset(tsJestTransformOptions?: DefaultTransformOptions): DefaultPreset;
|
||||
export declare function createDefaultLegacyPreset(tsJestTransformOptions?: DefaultTransformOptions): DefaultLegacyPreset;
|
||||
export declare function createJsWithTsPreset(tsJestTransformOptions?: JsWithTsTransformOptions): JsWithTsPreset;
|
||||
export declare function createJsWithTsLegacyPreset(tsJestTransformOptions?: JsWithTsTransformOptions): JsWithTsLegacyPreset;
|
||||
export declare function createJsWithBabelPreset(tsJestTransformOptions?: JsWithBabelTransformerOptions): JsWithBabelPreset;
|
||||
export declare function createJsWithBabelLegacyPreset(tsJestTransformOptions?: JsWithBabelTransformerOptions): JsWithBabelLegacyPreset;
|
||||
export declare function createDefaultEsmPreset(tsJestTransformOptions?: DefaultEsmTransformOptions): DefaultEsmPreset;
|
||||
export declare function createDefaultEsmLegacyPreset(tsJestTransformOptions?: DefaultEsmTransformOptions): DefaultEsmLegacyPreset;
|
||||
export declare function createJsWithTsEsmPreset(tsJestTransformOptions?: JsWithTsEsmTransformOptions): JsWithTsEsmPreset;
|
||||
export declare function createJsWithTsEsmLegacyPreset(tsJestTransformOptions?: JsWithTsEsmTransformOptions): JsWithTsEsmLegacyPreset;
|
||||
export declare function createJsWithBabelEsmPreset(tsJestTransformOptions?: JsWithBabelEsmTransformOptions): JsWithBabelEsmPreset;
|
||||
export declare function createJsWithBabelEsmLegacyPreset(tsJestTransformOptions?: JsWithBabelEsmTransformOptions): JsWithBabelEsmLegacyPreset;
|
||||
180
node_modules/ts-jest/dist/presets/create-jest-preset.js
generated
vendored
Normal file
180
node_modules/ts-jest/dist/presets/create-jest-preset.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createJestPreset = createJestPreset;
|
||||
exports.createDefaultPreset = createDefaultPreset;
|
||||
exports.createDefaultLegacyPreset = createDefaultLegacyPreset;
|
||||
exports.createJsWithTsPreset = createJsWithTsPreset;
|
||||
exports.createJsWithTsLegacyPreset = createJsWithTsLegacyPreset;
|
||||
exports.createJsWithBabelPreset = createJsWithBabelPreset;
|
||||
exports.createJsWithBabelLegacyPreset = createJsWithBabelLegacyPreset;
|
||||
exports.createDefaultEsmPreset = createDefaultEsmPreset;
|
||||
exports.createDefaultEsmLegacyPreset = createDefaultEsmLegacyPreset;
|
||||
exports.createJsWithTsEsmPreset = createJsWithTsEsmPreset;
|
||||
exports.createJsWithTsEsmLegacyPreset = createJsWithTsEsmLegacyPreset;
|
||||
exports.createJsWithBabelEsmPreset = createJsWithBabelEsmPreset;
|
||||
exports.createJsWithBabelEsmLegacyPreset = createJsWithBabelEsmLegacyPreset;
|
||||
const constants_1 = require("../constants");
|
||||
const utils_1 = require("../utils");
|
||||
const logger = utils_1.rootLogger.child({ namespace: 'jest-preset' });
|
||||
/**
|
||||
* @deprecated use other functions below instead
|
||||
*/
|
||||
function createJestPreset(legacy = false, allowJs = false, extraOptions = {}) {
|
||||
logger.debug({ allowJs }, 'creating jest presets', allowJs ? 'handling' : 'not handling', 'JavaScript files');
|
||||
const { extensionsToTreatAsEsm, moduleFileExtensions, testMatch } = extraOptions;
|
||||
const supportESM = extensionsToTreatAsEsm?.length;
|
||||
const tsJestTransformOptions = supportESM ? { useESM: true } : {};
|
||||
return {
|
||||
...(extensionsToTreatAsEsm ? { extensionsToTreatAsEsm } : undefined),
|
||||
...(moduleFileExtensions ? { moduleFileExtensions } : undefined),
|
||||
...(testMatch ? { testMatch } : undefined),
|
||||
transform: {
|
||||
...extraOptions.transform,
|
||||
[allowJs ? (supportESM ? '^.+\\.m?[tj]sx?$' : '^.+\\.[tj]sx?$') : '^.+\\.tsx?$']: legacy
|
||||
? ['ts-jest/legacy', tsJestTransformOptions]
|
||||
: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_JS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel CJS Jest preset');
|
||||
return {
|
||||
transform: {
|
||||
[constants_1.JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', tsJestTransformOptions],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createDefaultEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating default ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_JS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithTsEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating Js with Ts ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_TS_JS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelEsmPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
function createJsWithBabelEsmLegacyPreset(tsJestTransformOptions = {}) {
|
||||
logger.debug('creating JS with Babel ESM Jest preset');
|
||||
return {
|
||||
extensionsToTreatAsEsm: [...constants_1.JS_EXT_TO_TREAT_AS_ESM, ...constants_1.TS_EXT_TO_TREAT_AS_ESM],
|
||||
transform: {
|
||||
[constants_1.ESM_JS_TRANSFORM_PATTERN]: 'babel-jest',
|
||||
[constants_1.ESM_TS_TRANSFORM_PATTERN]: [
|
||||
'ts-jest/legacy',
|
||||
{
|
||||
...tsJestTransformOptions,
|
||||
useESM: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
556
node_modules/ts-jest/dist/raw-compiler-options.d.ts
generated
vendored
Normal file
556
node_modules/ts-jest/dist/raw-compiler-options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,556 @@
|
||||
/**
|
||||
* @deprecated This interface will be replaced with {@link TsConfigJson.CompilerOptions} in the next major release.
|
||||
*/
|
||||
export interface RawCompilerOptions {
|
||||
/**
|
||||
* Enable importing files with any extension, provided a declaration file is present.
|
||||
*/
|
||||
allowArbitraryExtensions?: boolean | null;
|
||||
/**
|
||||
* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.
|
||||
*/
|
||||
allowImportingTsExtensions?: boolean | null;
|
||||
/**
|
||||
* No longer supported. In early versions, manually set the text encoding for reading files.
|
||||
*/
|
||||
charset?: string | null;
|
||||
/**
|
||||
* Enable constraints that allow a TypeScript project to be used with project references.
|
||||
*/
|
||||
composite?: boolean | null;
|
||||
/**
|
||||
* Conditions to set in addition to the resolver-specific defaults when resolving imports.
|
||||
*/
|
||||
customConditions?: Array<string | null> | null;
|
||||
/**
|
||||
* Generate .d.ts files from TypeScript and JavaScript files in your project.
|
||||
*/
|
||||
declaration?: boolean | null;
|
||||
/**
|
||||
* Specify the output directory for generated declaration files.
|
||||
*/
|
||||
declarationDir?: string | null;
|
||||
/**
|
||||
* Output compiler performance information after building.
|
||||
*/
|
||||
diagnostics?: boolean | null;
|
||||
/**
|
||||
* Reduce the number of projects loaded automatically by TypeScript.
|
||||
*/
|
||||
disableReferencedProjectLoad?: boolean | null;
|
||||
/**
|
||||
* Enforces using indexed accessors for keys declared using an indexed type
|
||||
*/
|
||||
noPropertyAccessFromIndexSignature?: boolean | null;
|
||||
/**
|
||||
* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.
|
||||
*/
|
||||
emitBOM?: boolean | null;
|
||||
/**
|
||||
* Only output d.ts files and not JavaScript files.
|
||||
*/
|
||||
emitDeclarationOnly?: boolean | null;
|
||||
/**
|
||||
* Differentiate between undefined and not present when type checking
|
||||
*/
|
||||
exactOptionalPropertyTypes?: boolean | null;
|
||||
/**
|
||||
* Enable incremental compilation. Requires TypeScript version 3.4 or later.
|
||||
*/
|
||||
incremental?: boolean | null;
|
||||
/**
|
||||
* Specify the folder for .tsbuildinfo incremental compilation files.
|
||||
*/
|
||||
tsBuildInfoFile?: string | null;
|
||||
/**
|
||||
* Include sourcemap files inside the emitted JavaScript.
|
||||
*/
|
||||
inlineSourceMap?: boolean | null;
|
||||
/**
|
||||
* Include source code in the sourcemaps inside the emitted JavaScript.
|
||||
*/
|
||||
inlineSources?: boolean | null;
|
||||
/**
|
||||
* Specify what JSX code is generated.
|
||||
*/
|
||||
jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native';
|
||||
/**
|
||||
* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit.
|
||||
*/
|
||||
reactNamespace?: string | null;
|
||||
/**
|
||||
* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'
|
||||
*/
|
||||
jsxFactory?: string | null;
|
||||
/**
|
||||
* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'.
|
||||
*/
|
||||
jsxFragmentFactory?: string | null;
|
||||
/**
|
||||
* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx`.
|
||||
*/
|
||||
jsxImportSource?: string | null;
|
||||
/**
|
||||
* Print all of the files read during the compilation.
|
||||
*/
|
||||
listFiles?: boolean | null;
|
||||
/**
|
||||
* Specify the location where debugger should locate map files instead of generated locations.
|
||||
*/
|
||||
mapRoot?: string | null;
|
||||
/**
|
||||
* Specify what module code is generated.
|
||||
*/
|
||||
module?: ('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') & (((('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('CommonJS' | 'AMD' | 'System' | 'UMD' | 'ES6' | 'ES2015' | 'ES2020' | 'ESNext' | 'None' | 'ES2022' | 'Node16' | 'NodeNext' | 'Preserve') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Specify how TypeScript looks up a file from a given module specifier.
|
||||
*/
|
||||
moduleResolution?: ('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') & (((('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('Classic' | 'Node' | 'Node10' | 'Node16' | 'NodeNext' | 'Bundler') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Set the newline character for emitting files.
|
||||
*/
|
||||
newLine?: ('crlf' | 'lf') & (((('crlf' | 'lf') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('crlf' | 'lf') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Disable emitting file from a compilation.
|
||||
*/
|
||||
noEmit?: boolean | null;
|
||||
/**
|
||||
* Disable generating custom helper functions like `__extends` in compiled output.
|
||||
*/
|
||||
noEmitHelpers?: boolean | null;
|
||||
/**
|
||||
* Disable emitting files if any type checking errors are reported.
|
||||
*/
|
||||
noEmitOnError?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for expressions and declarations with an implied `any` type..
|
||||
*/
|
||||
noImplicitAny?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting when `this` is given the type `any`.
|
||||
*/
|
||||
noImplicitThis?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting when a local variables aren't read.
|
||||
*/
|
||||
noUnusedLocals?: boolean | null;
|
||||
/**
|
||||
* Raise an error when a function parameter isn't read
|
||||
*/
|
||||
noUnusedParameters?: boolean | null;
|
||||
/**
|
||||
* Disable including any library files, including the default lib.d.ts.
|
||||
*/
|
||||
noLib?: boolean | null;
|
||||
/**
|
||||
* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project.
|
||||
*/
|
||||
noResolve?: boolean | null;
|
||||
/**
|
||||
* Disable strict checking of generic signatures in function types.
|
||||
*/
|
||||
noStrictGenericChecks?: boolean | null;
|
||||
/**
|
||||
* Skip type checking .d.ts files that are included with TypeScript.
|
||||
*/
|
||||
skipDefaultLibCheck?: boolean | null;
|
||||
/**
|
||||
* Skip type checking all .d.ts files.
|
||||
*/
|
||||
skipLibCheck?: boolean | null;
|
||||
/**
|
||||
* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.
|
||||
*/
|
||||
outFile?: string | null;
|
||||
/**
|
||||
* Specify an output folder for all emitted files.
|
||||
*/
|
||||
outDir?: string | null;
|
||||
/**
|
||||
* Disable erasing `const enum` declarations in generated code.
|
||||
*/
|
||||
preserveConstEnums?: boolean | null;
|
||||
/**
|
||||
* Disable resolving symlinks to their realpath. This correlates to the same flag in node.
|
||||
*/
|
||||
preserveSymlinks?: boolean | null;
|
||||
/**
|
||||
* Preserve unused imported values in the JavaScript output that would otherwise be removed
|
||||
*/
|
||||
preserveValueImports?: boolean | null;
|
||||
/**
|
||||
* Disable wiping the console in watch mode
|
||||
*/
|
||||
preserveWatchOutput?: boolean | null;
|
||||
/**
|
||||
* Enable color and formatting in output to make compiler errors easier to read
|
||||
*/
|
||||
pretty?: boolean | null;
|
||||
/**
|
||||
* Disable emitting comments.
|
||||
*/
|
||||
removeComments?: boolean | null;
|
||||
/**
|
||||
* Specify the root folder within your source files.
|
||||
*/
|
||||
rootDir?: string | null;
|
||||
/**
|
||||
* Ensure that each file can be safely transpiled without relying on other imports.
|
||||
*/
|
||||
isolatedModules?: boolean | null;
|
||||
/**
|
||||
* Create source map files for emitted JavaScript files.
|
||||
*/
|
||||
sourceMap?: boolean | null;
|
||||
/**
|
||||
* Specify the root path for debuggers to find the reference source code.
|
||||
*/
|
||||
sourceRoot?: string | null;
|
||||
/**
|
||||
* Disable reporting of excess property errors during the creation of object literals.
|
||||
*/
|
||||
suppressExcessPropertyErrors?: boolean | null;
|
||||
/**
|
||||
* Suppress `noImplicitAny` errors when indexing objects that lack index signatures.
|
||||
*/
|
||||
suppressImplicitAnyIndexErrors?: boolean | null;
|
||||
/**
|
||||
* Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
|
||||
*/
|
||||
target?: ('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') & (((('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('ES3' | 'ES5' | 'ES6' | 'ES2015' | 'ES2016' | 'ES2017' | 'ES2018' | 'ES2019' | 'ES2020' | 'ES2021' | 'ES2022' | 'ES2023' | 'ESNext') | {
|
||||
[k: string]: unknown;
|
||||
}) & null));
|
||||
/**
|
||||
* Default catch clause variables as `unknown` instead of `any`.
|
||||
*/
|
||||
useUnknownInCatchVariables?: boolean | null;
|
||||
/**
|
||||
* Watch input files.
|
||||
*/
|
||||
watch?: boolean | null;
|
||||
/**
|
||||
* Specify the polling strategy to use when the system runs out of or doesn't support native file watchers. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
fallbackPolling?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'fixedInterval' | 'priorityInterval' | 'dynamicPriority' | 'fixedChunkSize';
|
||||
/**
|
||||
* Specify the strategy for watching directories under systems that lack recursive file-watching functionality. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
watchDirectory?: 'useFsEvents' | 'fixedPollingInterval' | 'dynamicPriorityPolling' | 'fixedChunkSizePolling';
|
||||
/**
|
||||
* Specify the strategy for watching individual files. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
watchFile?: 'fixedPollingInterval' | 'priorityPollingInterval' | 'dynamicPriorityPolling' | 'useFsEvents' | 'useFsEventsOnParentDirectory' | 'fixedChunkSizePolling';
|
||||
/**
|
||||
* Enable experimental support for TC39 stage 2 draft decorators.
|
||||
*/
|
||||
experimentalDecorators?: boolean | null;
|
||||
/**
|
||||
* Emit design-type metadata for decorated declarations in source files.
|
||||
*/
|
||||
emitDecoratorMetadata?: boolean | null;
|
||||
/**
|
||||
* Disable error reporting for unused labels.
|
||||
*/
|
||||
allowUnusedLabels?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for codepaths that do not explicitly return in a function.
|
||||
*/
|
||||
noImplicitReturns?: boolean | null;
|
||||
/**
|
||||
* Add `undefined` to a type when accessed using an index.
|
||||
*/
|
||||
noUncheckedIndexedAccess?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting for fallthrough cases in switch statements.
|
||||
*/
|
||||
noFallthroughCasesInSwitch?: boolean | null;
|
||||
/**
|
||||
* Ensure overriding members in derived classes are marked with an override modifier.
|
||||
*/
|
||||
noImplicitOverride?: boolean | null;
|
||||
/**
|
||||
* Disable error reporting for unreachable code.
|
||||
*/
|
||||
allowUnreachableCode?: boolean | null;
|
||||
/**
|
||||
* Ensure that casing is correct in imports.
|
||||
*/
|
||||
forceConsistentCasingInFileNames?: boolean | null;
|
||||
/**
|
||||
* Emit a v8 CPU profile of the compiler run for debugging.
|
||||
*/
|
||||
generateCpuProfile?: string | null;
|
||||
/**
|
||||
* Specify the base directory to resolve non-relative module names.
|
||||
*/
|
||||
baseUrl?: string | null;
|
||||
/**
|
||||
* Specify a set of entries that re-map imports to additional lookup locations.
|
||||
*/
|
||||
paths?: {
|
||||
[k: string]: Array<string | null> | null;
|
||||
} | null;
|
||||
/**
|
||||
* Specify a list of language service plugins to include.
|
||||
*/
|
||||
plugins?: Array<{
|
||||
/**
|
||||
* Plugin name.
|
||||
*/
|
||||
name?: string | null;
|
||||
[k: string]: unknown;
|
||||
} | null> | null;
|
||||
/**
|
||||
* Allow multiple folders to be treated as one when resolving modules.
|
||||
*/
|
||||
rootDirs?: Array<string | null> | null;
|
||||
/**
|
||||
* Specify multiple folders that act like `./node_modules/@types`.
|
||||
*/
|
||||
typeRoots?: Array<string | null> | null;
|
||||
/**
|
||||
* Specify type package names to be included without being referenced in a source file.
|
||||
*/
|
||||
types?: Array<string | null> | null;
|
||||
/**
|
||||
* Enable tracing of the name resolution process. Requires TypeScript version 2.0 or later.
|
||||
*/
|
||||
traceResolution?: boolean | null;
|
||||
/**
|
||||
* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
|
||||
*/
|
||||
allowJs?: boolean | null;
|
||||
/**
|
||||
* Disable truncating types in error messages.
|
||||
*/
|
||||
noErrorTruncation?: boolean | null;
|
||||
/**
|
||||
* Allow 'import x from y' when a module doesn't have a default export.
|
||||
*/
|
||||
allowSyntheticDefaultImports?: boolean | null;
|
||||
/**
|
||||
* Disable adding 'use strict' directives in emitted JavaScript files.
|
||||
*/
|
||||
noImplicitUseStrict?: boolean | null;
|
||||
/**
|
||||
* Print the names of emitted files after a compilation.
|
||||
*/
|
||||
listEmittedFiles?: boolean | null;
|
||||
/**
|
||||
* Remove the 20mb cap on total source code size for JavaScript files in the TypeScript language server.
|
||||
*/
|
||||
disableSizeLimit?: boolean | null;
|
||||
/**
|
||||
* Specify a set of bundled library declaration files that describe the target runtime environment.
|
||||
*/
|
||||
lib?: Array<(('ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & (((('ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & string) | ((('ES5' | 'ES6' | 'ES2015' | 'ES2015.Collection' | 'ES2015.Core' | 'ES2015.Generator' | 'ES2015.Iterable' | 'ES2015.Promise' | 'ES2015.Proxy' | 'ES2015.Reflect' | 'ES2015.Symbol.WellKnown' | 'ES2015.Symbol' | 'ES2016' | 'ES2016.Array.Include' | 'ES2017' | 'ES2017.Intl' | 'ES2017.Object' | 'ES2017.SharedMemory' | 'ES2017.String' | 'ES2017.TypedArrays' | 'ES2018' | 'ES2018.AsyncGenerator' | 'ES2018.AsyncIterable' | 'ES2018.Intl' | 'ES2018.Promise' | 'ES2018.Regexp' | 'ES2019' | 'ES2019.Array' | 'ES2019.Intl' | 'ES2019.Object' | 'ES2019.String' | 'ES2019.Symbol' | 'ES2020' | 'ES2020.BigInt' | 'ES2020.Promise' | 'ES2020.String' | 'ES2020.Symbol.WellKnown' | 'ESNext' | 'ESNext.Array' | 'ESNext.AsyncIterable' | 'ESNext.BigInt' | 'ESNext.Intl' | 'ESNext.Promise' | 'ESNext.String' | 'ESNext.Symbol' | 'DOM' | 'DOM.AsyncIterable' | 'DOM.Iterable' | 'ScriptHost' | 'WebWorker' | 'WebWorker.AsyncIterable' | 'WebWorker.ImportScripts' | 'Webworker.Iterable' | 'ES7' | 'ES2021' | 'ES2020.SharedMemory' | 'ES2020.Intl' | 'ES2020.Date' | 'ES2020.Number' | 'ES2021.Promise' | 'ES2021.String' | 'ES2021.WeakRef' | 'ESNext.WeakRef' | 'ES2021.Intl' | 'ES2022' | 'ES2022.Array' | 'ES2022.Error' | 'ES2022.Intl' | 'ES2022.Object' | 'ES2022.String' | 'ES2022.SharedMemory' | 'ES2022.RegExp' | 'ES2023' | 'ES2023.Array' | 'Decorators' | 'Decorators.Legacy' | 'ES2017.Date' | 'ES2023.Collection' | 'ESNext.Decorators' | 'ESNext.Disposable') | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
} | {
|
||||
[k: string]: unknown;
|
||||
}) & null))> | null;
|
||||
/**
|
||||
* Specify how TypeScript determine a file as module.
|
||||
*/
|
||||
moduleDetection?: 'auto' | 'legacy' | 'force';
|
||||
/**
|
||||
* When type checking, take into account `null` and `undefined`.
|
||||
*/
|
||||
strictNullChecks?: boolean | null;
|
||||
/**
|
||||
* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`.
|
||||
*/
|
||||
maxNodeModuleJsDepth?: number | null;
|
||||
/**
|
||||
* Allow importing helper functions from tslib once per project, instead of including them per-file.
|
||||
*/
|
||||
importHelpers?: boolean | null;
|
||||
/**
|
||||
* Specify emit/checking behavior for imports that are only used for types.
|
||||
*/
|
||||
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error';
|
||||
/**
|
||||
* Ensure 'use strict' is always emitted.
|
||||
*/
|
||||
alwaysStrict?: boolean | null;
|
||||
/**
|
||||
* Enable all strict type checking options.
|
||||
*/
|
||||
strict?: boolean | null;
|
||||
/**
|
||||
* Check that the arguments for `bind`, `call`, and `apply` methods match the original function.
|
||||
*/
|
||||
strictBindCallApply?: boolean | null;
|
||||
/**
|
||||
* Emit more compliant, but verbose and less performant JavaScript for iteration.
|
||||
*/
|
||||
downlevelIteration?: boolean | null;
|
||||
/**
|
||||
* Enable error reporting in type-checked JavaScript files.
|
||||
*/
|
||||
checkJs?: boolean | null;
|
||||
/**
|
||||
* When assigning functions, check to ensure parameters and the return values are subtype-compatible.
|
||||
*/
|
||||
strictFunctionTypes?: boolean | null;
|
||||
/**
|
||||
* Check for class properties that are declared but not set in the constructor.
|
||||
*/
|
||||
strictPropertyInitialization?: boolean | null;
|
||||
/**
|
||||
* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
|
||||
*/
|
||||
esModuleInterop?: boolean | null;
|
||||
/**
|
||||
* Allow accessing UMD globals from modules.
|
||||
*/
|
||||
allowUmdGlobalAccess?: boolean | null;
|
||||
/**
|
||||
* Make keyof only return strings instead of string, numbers or symbols. Legacy option.
|
||||
*/
|
||||
keyofStringsOnly?: boolean | null;
|
||||
/**
|
||||
* Emit ECMAScript-standard-compliant class fields.
|
||||
*/
|
||||
useDefineForClassFields?: boolean | null;
|
||||
/**
|
||||
* Create sourcemaps for d.ts files.
|
||||
*/
|
||||
declarationMap?: boolean | null;
|
||||
/**
|
||||
* Enable importing .json files
|
||||
*/
|
||||
resolveJsonModule?: boolean | null;
|
||||
/**
|
||||
* Use the package.json 'exports' field when resolving package imports.
|
||||
*/
|
||||
resolvePackageJsonExports?: boolean | null;
|
||||
/**
|
||||
* Use the package.json 'imports' field when resolving imports.
|
||||
*/
|
||||
resolvePackageJsonImports?: boolean | null;
|
||||
/**
|
||||
* Have recompiles in '--incremental' and '--watch' assume that changes within a file will only affect files directly depending on it. Requires TypeScript version 3.8 or later.
|
||||
*/
|
||||
assumeChangesOnlyAffectDirectDependencies?: boolean | null;
|
||||
/**
|
||||
* Output more detailed compiler performance information after building.
|
||||
*/
|
||||
extendedDiagnostics?: boolean | null;
|
||||
/**
|
||||
* Print names of files that are part of the compilation and then stop processing.
|
||||
*/
|
||||
listFilesOnly?: boolean | null;
|
||||
/**
|
||||
* Disable preferring source files instead of declaration files when referencing composite projects
|
||||
*/
|
||||
disableSourceOfProjectReferenceRedirect?: boolean | null;
|
||||
/**
|
||||
* Opt a project out of multi-project reference checking when editing.
|
||||
*/
|
||||
disableSolutionSearching?: boolean | null;
|
||||
/**
|
||||
* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting.
|
||||
*/
|
||||
verbatimModuleSyntax?: boolean | null;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
2
node_modules/ts-jest/dist/raw-compiler-options.js
generated
vendored
Normal file
2
node_modules/ts-jest/dist/raw-compiler-options.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
9
node_modules/ts-jest/dist/transformers/hoist-jest.d.ts
generated
vendored
Normal file
9
node_modules/ts-jest/dist/transformers/hoist-jest.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type _ts from 'typescript';
|
||||
import type { TsCompilerInstance } from '../types';
|
||||
/**
|
||||
* Remember to increase the version whenever transformer's content is changed. This is to inform Jest to not reuse
|
||||
* the previous cache which contains old transformer's content
|
||||
*/
|
||||
export declare const version = 4;
|
||||
export declare const name = "hoist-jest";
|
||||
export declare function factory({ configSet }: TsCompilerInstance): (ctx: _ts.TransformationContext) => _ts.Transformer<_ts.SourceFile>;
|
||||
111
node_modules/ts-jest/dist/transformers/hoist-jest.js
generated
vendored
Normal file
111
node_modules/ts-jest/dist/transformers/hoist-jest.js
generated
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.name = exports.version = void 0;
|
||||
exports.factory = factory;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
/**
|
||||
* Remember to increase the version whenever transformer's content is changed. This is to inform Jest to not reuse
|
||||
* the previous cache which contains old transformer's content
|
||||
*/
|
||||
exports.version = 4;
|
||||
// Used for constructing cache key
|
||||
exports.name = 'hoist-jest';
|
||||
const HOIST_METHODS = ['mock', 'unmock', 'enableAutomock', 'disableAutomock', 'deepUnmock'];
|
||||
const JEST_GLOBALS_MODULE_NAME = '@jest/globals';
|
||||
const JEST_GLOBAL_NAME = 'jest';
|
||||
function factory({ configSet }) {
|
||||
const logger = configSet.logger.child({ namespace: exports.name });
|
||||
const ts = configSet.compilerModule;
|
||||
const importNamesOfJestObj = [];
|
||||
const isJestGlobalImport = (node) => {
|
||||
return (ts.isImportDeclaration(node) &&
|
||||
ts.isStringLiteral(node.moduleSpecifier) &&
|
||||
node.moduleSpecifier.text === JEST_GLOBALS_MODULE_NAME);
|
||||
};
|
||||
const shouldHoistExpression = (node) => {
|
||||
if (ts.isCallExpression(node) &&
|
||||
ts.isPropertyAccessExpression(node.expression) &&
|
||||
HOIST_METHODS.includes(node.expression.name.text)) {
|
||||
if (importNamesOfJestObj.length) {
|
||||
// @jest/globals is in used
|
||||
return ((ts.isIdentifier(node.expression.expression) &&
|
||||
importNamesOfJestObj.includes(node.expression.expression.text)) ||
|
||||
(ts.isPropertyAccessExpression(node.expression.expression) &&
|
||||
ts.isIdentifier(node.expression.expression.expression) &&
|
||||
importNamesOfJestObj.includes(node.expression.expression.expression.text)) ||
|
||||
shouldHoistExpression(node.expression.expression));
|
||||
}
|
||||
else {
|
||||
// @jest/globals is not in used
|
||||
return ((ts.isIdentifier(node.expression.expression) && node.expression.expression.text === JEST_GLOBAL_NAME) ||
|
||||
shouldHoistExpression(node.expression.expression));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* Checks whether given node is a statement that we need to hoist
|
||||
*/
|
||||
const isHoistableStatement = (node) => {
|
||||
return ts.isExpressionStatement(node) && shouldHoistExpression(node.expression);
|
||||
};
|
||||
const canHoistInBlockScope = (node) => !!node.statements.find((stmt) => ts.isVariableStatement(stmt) &&
|
||||
stmt.declarationList.declarations.find((decl) => ts.isIdentifier(decl.name) && decl.name.text !== JEST_GLOBAL_NAME) &&
|
||||
node.statements.find((stmt) => isHoistableStatement(stmt)));
|
||||
/**
|
||||
* Sort statements according to priority
|
||||
* - Import Jest object from `@jest/globals`
|
||||
* - Hoistable methods
|
||||
* - Non-hoistable methods
|
||||
*/
|
||||
const sortStatements = (statements) => {
|
||||
if (statements.length <= 1) {
|
||||
return statements;
|
||||
}
|
||||
return statements.sort((stmtA, stmtB) => isJestGlobalImport(stmtA) ||
|
||||
(isHoistableStatement(stmtA) && !isHoistableStatement(stmtB) && !isJestGlobalImport(stmtB))
|
||||
? -1
|
||||
: 1);
|
||||
};
|
||||
const createVisitor = (ctx, _) => {
|
||||
const visitor = (node) => {
|
||||
const resultNode = ts.visitEachChild(node, visitor, ctx);
|
||||
// Since we use `visitEachChild`, we go upwards tree so all children node elements are checked first
|
||||
if (ts.isBlock(resultNode) && canHoistInBlockScope(resultNode)) {
|
||||
const newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
||||
return ts.factory.updateBlock(resultNode, newNodeArrayStatements);
|
||||
}
|
||||
else {
|
||||
if (ts.isSourceFile(resultNode)) {
|
||||
resultNode.statements.forEach((stmt) => {
|
||||
/**
|
||||
* Gather all possible import names, from different types of import syntax including:
|
||||
* - named import, e.g. `import { jest } from '@jest/globals'`
|
||||
* - aliased named import, e.g. `import {jest as aliasedJest} from '@jest/globals'`
|
||||
* - namespace import, e.g `import * as JestGlobals from '@jest/globals'`
|
||||
*/
|
||||
if (isJestGlobalImport(stmt) &&
|
||||
stmt.importClause?.namedBindings &&
|
||||
(ts.isNamespaceImport(stmt.importClause.namedBindings) ||
|
||||
ts.isNamedImports(stmt.importClause.namedBindings))) {
|
||||
const { namedBindings } = stmt.importClause;
|
||||
const jestImportName = ts.isNamespaceImport(namedBindings)
|
||||
? namedBindings.name.text
|
||||
: namedBindings.elements.find((element) => element.name.text === JEST_GLOBAL_NAME || element.propertyName?.text === JEST_GLOBAL_NAME)?.name.text;
|
||||
if (jestImportName) {
|
||||
importNamesOfJestObj.push(jestImportName);
|
||||
}
|
||||
}
|
||||
});
|
||||
const newNodeArrayStatements = ts.factory.createNodeArray(sortStatements(resultNode.statements));
|
||||
importNamesOfJestObj.length = 0;
|
||||
return ts.factory.updateSourceFile(resultNode, newNodeArrayStatements, resultNode.isDeclarationFile, resultNode.referencedFiles, resultNode.typeReferenceDirectives, resultNode.hasNoDefaultLib, resultNode.libReferenceDirectives);
|
||||
}
|
||||
return resultNode;
|
||||
}
|
||||
};
|
||||
return visitor;
|
||||
};
|
||||
// returns the transformer factory
|
||||
return (ctx) => logger.wrap({ [bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.debug, call: null }, 'visitSourceFileNode(): hoist jest', (sf) => ts.visitNode(sf, createVisitor(ctx, sf)));
|
||||
}
|
||||
8
node_modules/ts-jest/dist/transpilers/typescript/transpile-module.d.ts
generated
vendored
Normal file
8
node_modules/ts-jest/dist/transpilers/typescript/transpile-module.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import ts from 'typescript';
|
||||
type ExtendedTranspileOptions = Omit<ts.TranspileOptions, 'transformers'> & {
|
||||
transformers?: (program: ts.Program) => ts.CustomTransformers;
|
||||
};
|
||||
type ExtendedTsTranspileModuleFn = (fileContent: string, transpileOptions: ExtendedTranspileOptions) => ts.TranspileOutput;
|
||||
export declare const isModernNodeModuleKind: (module: ts.ModuleKind | undefined) => boolean;
|
||||
export declare const tsTranspileModule: ExtendedTsTranspileModuleFn;
|
||||
export {};
|
||||
174
node_modules/ts-jest/dist/transpilers/typescript/transpile-module.js
generated
vendored
Normal file
174
node_modules/ts-jest/dist/transpilers/typescript/transpile-module.js
generated
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.tsTranspileModule = exports.isModernNodeModuleKind = void 0;
|
||||
const node_path_1 = __importDefault(require("node:path"));
|
||||
const typescript_1 = __importDefault(require("typescript"));
|
||||
const utils_1 = require("../../utils");
|
||||
const barebonesLibContent = `/// <reference no-default-lib="true"/>
|
||||
interface Boolean {}
|
||||
interface Function {}
|
||||
interface CallableFunction {}
|
||||
interface NewableFunction {}
|
||||
interface IArguments {}
|
||||
interface Number {}
|
||||
interface Object {}
|
||||
interface RegExp {}
|
||||
interface String {}
|
||||
interface Array<T> { length: number; [n: number]: T; }
|
||||
interface SymbolConstructor {
|
||||
(desc?: string | number): symbol;
|
||||
for(name: string): symbol;
|
||||
readonly toStringTag: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
interface Symbol {
|
||||
readonly [Symbol.toStringTag]: string;
|
||||
}`;
|
||||
const barebonesLibName = 'lib.d.ts';
|
||||
let barebonesLibSourceFile;
|
||||
const carriageReturnLineFeed = '\r\n';
|
||||
const lineFeed = '\n';
|
||||
function getNewLineCharacter(options) {
|
||||
switch (options.newLine) {
|
||||
case typescript_1.default.NewLineKind.CarriageReturnLineFeed:
|
||||
return carriageReturnLineFeed;
|
||||
case typescript_1.default.NewLineKind.LineFeed:
|
||||
default:
|
||||
return lineFeed;
|
||||
}
|
||||
}
|
||||
const isModernNodeModuleKind = (module) => {
|
||||
return module
|
||||
? [typescript_1.default.ModuleKind.Node16, /* ModuleKind.Node18 */ 101, /* ModuleKind.Node20 */ 102, typescript_1.default.ModuleKind.NodeNext].includes(module)
|
||||
: false;
|
||||
};
|
||||
exports.isModernNodeModuleKind = isModernNodeModuleKind;
|
||||
const shouldCheckProjectPkgJsonContent = (fileName, moduleKind) => {
|
||||
return fileName.endsWith('package.json') && (0, exports.isModernNodeModuleKind)(moduleKind);
|
||||
};
|
||||
/**
|
||||
* Copy source code of {@link ts.transpileModule} from {@link https://github.com/microsoft/TypeScript/blob/main/src/services/transpile.ts}
|
||||
* with extra modifications:
|
||||
* - Remove generation of declaration files
|
||||
* - Allow using custom AST transformers with the internal created {@link Program}
|
||||
*/
|
||||
const transpileWorker = (input, transpileOptions) => {
|
||||
if (!barebonesLibSourceFile) {
|
||||
barebonesLibSourceFile = typescript_1.default.createSourceFile(barebonesLibName, barebonesLibContent, {
|
||||
languageVersion: typescript_1.default.ScriptTarget.Latest,
|
||||
});
|
||||
}
|
||||
const diagnostics = [];
|
||||
const options = transpileOptions.compilerOptions
|
||||
? // @ts-expect-error internal TypeScript API
|
||||
typescript_1.default.fixupCompilerOptions(transpileOptions.compilerOptions, diagnostics)
|
||||
: {};
|
||||
// mix in default options
|
||||
const defaultOptions = typescript_1.default.getDefaultCompilerOptions();
|
||||
for (const key in defaultOptions) {
|
||||
if (Object.hasOwn(defaultOptions, key) && options[key] === undefined) {
|
||||
options[key] = defaultOptions[key];
|
||||
}
|
||||
}
|
||||
// @ts-expect-error internal TypeScript API
|
||||
for (const option of typescript_1.default.transpileOptionValueCompilerOptions) {
|
||||
// Do not set redundant config options if `verbatimModuleSyntax` was supplied.
|
||||
if (options.verbatimModuleSyntax && new Set(['isolatedModules']).has(option.name)) {
|
||||
continue;
|
||||
}
|
||||
options[option.name] = option.transpileOptionValue;
|
||||
}
|
||||
// transpileModule does not write anything to disk so there is no need to verify that there are no conflicts between input and output paths.
|
||||
options.suppressOutputPathCheck = true;
|
||||
// Filename can be non-ts file.
|
||||
options.allowNonTsExtensions = true;
|
||||
options.declaration = false;
|
||||
options.declarationMap = false;
|
||||
const newLine = getNewLineCharacter(options);
|
||||
// if jsx is specified then treat file as .tsx
|
||||
const inputFileName = transpileOptions.fileName ?? (transpileOptions.compilerOptions?.jsx ? 'module.tsx' : 'module.ts');
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
const compilerHost = {
|
||||
getSourceFile: (fileName) => {
|
||||
// @ts-expect-error internal TypeScript API
|
||||
if (fileName === typescript_1.default.normalizePath(inputFileName)) {
|
||||
return sourceFile;
|
||||
}
|
||||
// @ts-expect-error internal TypeScript API
|
||||
return fileName === typescript_1.default.normalizePath(barebonesLibName) ? barebonesLibSourceFile : undefined;
|
||||
},
|
||||
writeFile: (name, text) => {
|
||||
if (node_path_1.default.extname(name) === '.map') {
|
||||
sourceMapText = text;
|
||||
}
|
||||
else {
|
||||
outputText = text;
|
||||
}
|
||||
},
|
||||
getDefaultLibFileName: () => barebonesLibName,
|
||||
useCaseSensitiveFileNames: () => false,
|
||||
getCanonicalFileName: (fileName) => fileName,
|
||||
getCurrentDirectory: () => '',
|
||||
getNewLine: () => newLine,
|
||||
fileExists: (fileName) => {
|
||||
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
||||
return typescript_1.default.sys.fileExists(fileName);
|
||||
}
|
||||
return fileName === inputFileName;
|
||||
},
|
||||
readFile: (fileName) => {
|
||||
if (shouldCheckProjectPkgJsonContent(fileName, options.module)) {
|
||||
return typescript_1.default.sys.readFile(fileName);
|
||||
}
|
||||
return '';
|
||||
},
|
||||
directoryExists: () => true,
|
||||
getDirectories: () => [],
|
||||
};
|
||||
const sourceFile = typescript_1.default.createSourceFile(inputFileName, input, {
|
||||
languageVersion: options.target ?? typescript_1.default.ScriptTarget.ESNext,
|
||||
impliedNodeFormat: typescript_1.default.getImpliedNodeFormatForFile(inputFileName,
|
||||
/*packageJsonInfoCache*/ undefined, compilerHost, options),
|
||||
// @ts-expect-error internal TypeScript API
|
||||
setExternalModuleIndicator: typescript_1.default.getSetExternalModuleIndicator(options),
|
||||
jsDocParsingMode: transpileOptions.jsDocParsingMode ?? typescript_1.default.JSDocParsingMode.ParseAll,
|
||||
});
|
||||
if (transpileOptions.moduleName) {
|
||||
sourceFile.moduleName = transpileOptions.moduleName;
|
||||
}
|
||||
if (transpileOptions.renamedDependencies) {
|
||||
// @ts-expect-error internal TypeScript API
|
||||
sourceFile.renamedDependencies = new Map(Object.entries(transpileOptions.renamedDependencies));
|
||||
}
|
||||
// Output
|
||||
let outputText;
|
||||
let sourceMapText;
|
||||
const inputs = [inputFileName];
|
||||
const program = typescript_1.default.createProgram(inputs, options, compilerHost);
|
||||
if (transpileOptions.reportDiagnostics) {
|
||||
diagnostics.push(...program.getSyntacticDiagnostics(sourceFile));
|
||||
}
|
||||
diagnostics.push(...program.getOptionsDiagnostics());
|
||||
// Emit
|
||||
const result = program.emit(
|
||||
/*targetSourceFile*/ undefined,
|
||||
/*writeFile*/ undefined,
|
||||
/*cancellationToken*/ undefined,
|
||||
/*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers?.(program));
|
||||
diagnostics.push(...result.diagnostics);
|
||||
if (outputText === undefined) {
|
||||
diagnostics.push({
|
||||
category: typescript_1.default.DiagnosticCategory.Error,
|
||||
code: utils_1.TsJestDiagnosticCodes.Generic,
|
||||
messageText: 'No output generated',
|
||||
file: sourceFile,
|
||||
start: 0,
|
||||
length: 0,
|
||||
});
|
||||
}
|
||||
return { outputText: outputText ?? '', diagnostics, sourceMapText };
|
||||
};
|
||||
exports.tsTranspileModule = transpileWorker;
|
||||
282
node_modules/ts-jest/dist/types.d.ts
generated
vendored
Normal file
282
node_modules/ts-jest/dist/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,282 @@
|
||||
import type { TransformedSource, TransformOptions } from '@jest/transform';
|
||||
import type { Config } from '@jest/types';
|
||||
import type * as _babel from 'babel__core';
|
||||
import type * as _ts from 'typescript';
|
||||
import type { TsConfigCompilerOptionsJson } from './config/types';
|
||||
import { ESM_JS_TRANSFORM_PATTERN, ESM_TS_JS_TRANSFORM_PATTERN, ESM_TS_TRANSFORM_PATTERN, JS_TRANSFORM_PATTERN, TS_JS_TRANSFORM_PATTERN, TS_TRANSFORM_PATTERN } from './constants';
|
||||
import type { ConfigSet } from './legacy/config/config-set';
|
||||
import type { RawCompilerOptions } from './raw-compiler-options';
|
||||
export type TTypeScript = typeof _ts;
|
||||
/**
|
||||
* Don't mark as internal because it is used in TsJestGlobalOptions which is an exposed type
|
||||
*/
|
||||
export type BabelConfig = _babel.TransformOptions;
|
||||
export interface AstTransformer<T = Record<string, unknown>> {
|
||||
path: string;
|
||||
options?: T;
|
||||
}
|
||||
export interface ConfigCustomTransformer {
|
||||
before?: Array<string | AstTransformer>;
|
||||
after?: Array<string | AstTransformer>;
|
||||
afterDeclarations?: Array<string | AstTransformer>;
|
||||
}
|
||||
/**
|
||||
* @deprecated use {@link TsJestTransformerOptions} instead
|
||||
*/
|
||||
export type TsJestGlobalOptions = Config.TransformerConfig[1] & {
|
||||
/**
|
||||
* Compiler options. It can be:
|
||||
* - `true` (or `undefined`, it's the default): use default tsconfig file
|
||||
* - `false`: do NOT use default config file
|
||||
* - `path/to/tsconfig.json`: path to a specific tsconfig file (<rootDir> can be used)
|
||||
* - `{...}`: an object with inline compiler options
|
||||
*
|
||||
* @default `undefined` (the default config file will be used if it exists)
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
* {@link RawCompilerOptions} will be replaced with {@link TsConfigCompilerOptionsJson} in the next major release
|
||||
*/
|
||||
tsconfig?: boolean | string | RawCompilerOptions | TsConfigCompilerOptionsJson;
|
||||
/**
|
||||
* @deprecated use {@link TsConfigCompilerOptionsJson.isolatedModules} instead
|
||||
*
|
||||
* Compiles files as isolated modules (disables some features)
|
||||
*
|
||||
* @default `undefined` (disables transpiling files with {@link _ts.transpileModule})
|
||||
*/
|
||||
isolatedModules?: boolean;
|
||||
/**
|
||||
* Compiler to use
|
||||
*
|
||||
* @default `typescript`
|
||||
*/
|
||||
compiler?: 'typescript' | 'ttypescript' | string;
|
||||
/**
|
||||
* Custom transformers (mostly used by jest presets)
|
||||
*/
|
||||
astTransformers?: ConfigCustomTransformer;
|
||||
/**
|
||||
* TS diagnostics - less to be reported if `isolatedModules` is `true`. It can be:
|
||||
* - `true` (or `undefined`, it's the default): show all diagnostics
|
||||
* - `false`: hide diagnostics of all files (kind of useless)
|
||||
* - `{...}`: an inline object with fine grained settings
|
||||
*
|
||||
* @default `undefined`
|
||||
*/
|
||||
diagnostics?: boolean | {
|
||||
/**
|
||||
* Enables colorful and pretty output of errors
|
||||
*
|
||||
* @default `undefined` (enables formatting errors)
|
||||
*/
|
||||
pretty?: boolean;
|
||||
/**
|
||||
* List of TypeScript diagnostic error codes to ignore
|
||||
* [here](https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json).
|
||||
*
|
||||
* @see https://github.com/Microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json
|
||||
* @default `[6059,18002,18003]`
|
||||
*/
|
||||
ignoreCodes?: number | string | Array<number | string>;
|
||||
/**
|
||||
* If specified, diagnostics of source files which path **matches** will be ignored
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* Logs TypeScript errors to stderr instead of throwing exceptions
|
||||
*
|
||||
* @default `undefined` (TypeScript errors will be thrown as exceptions)
|
||||
*/
|
||||
warnOnly?: boolean;
|
||||
};
|
||||
/**
|
||||
* Babel config. It can be:
|
||||
* - `false` (or `undefined`, it's the default): do NOT use babel
|
||||
* - `true`: use babel using default babelrc file
|
||||
* - `path/to/.babelrc`: path to a babelrc file (<rootDir> can be used)
|
||||
* - `{...}`: an object with inline babel options
|
||||
*
|
||||
* @default `undefined` (not using `Babel`)
|
||||
*/
|
||||
babelConfig?: boolean | string | BabelConfig;
|
||||
/**
|
||||
* Kept for backward compatibility to handle __TRANSFORM_HTML__
|
||||
* Any file which will match this regex will be transpiled as a module
|
||||
* exporting the content of the file as a string
|
||||
*/
|
||||
stringifyContentPathRegex?: string | RegExp;
|
||||
/**
|
||||
* Tell `ts-jest` to transform codes to ESM format. This only works in combination with `jest-runtime` ESM option
|
||||
* `supportsStaticESM` true which is passed into Jest transformer
|
||||
*/
|
||||
useESM?: boolean;
|
||||
};
|
||||
/**
|
||||
* For transformers which extends `ts-jest`
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface ProjectConfigTsJest extends Config.ProjectConfig {
|
||||
globals: GlobalConfigTsJest;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface TransformOptionsTsJest<TransformerConfig = unknown> extends TransformOptions<TransformerConfig> {
|
||||
config: Config.ProjectConfig;
|
||||
}
|
||||
/**
|
||||
* For typings in `jest.config.ts`
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface GlobalConfigTsJest extends Config.ConfigGlobals {
|
||||
'ts-jest'?: TsJestGlobalOptions;
|
||||
}
|
||||
/**
|
||||
* @deprecated use `JestConfigWithTsJest` instead
|
||||
*/
|
||||
export interface InitialOptionsTsJest extends Config.InitialOptions {
|
||||
globals?: GlobalConfigTsJest;
|
||||
}
|
||||
export type TsJestTransformerOptions = TsJestGlobalOptions;
|
||||
export type TsJestTransformOptions = TransformOptions<TsJestTransformerOptions>;
|
||||
export interface JestConfigWithTsJest extends Omit<Config.InitialOptions, 'transform'> {
|
||||
transform?: {
|
||||
[regex: string]: 'ts-jest' | 'ts-jest/legacy' | ['ts-jest', TsJestTransformerOptions] | ['ts-jest/legacy', TsJestTransformerOptions];
|
||||
} | Config.InitialOptions['transform'];
|
||||
}
|
||||
export type StringMap = Map<string, string>;
|
||||
export interface DepGraphInfo {
|
||||
fileContent: string;
|
||||
resolvedModuleNames: string[];
|
||||
}
|
||||
export interface TsJestCompileOptions {
|
||||
depGraphs: Map<string, DepGraphInfo>;
|
||||
watchMode: boolean;
|
||||
supportsStaticESM: boolean;
|
||||
}
|
||||
export interface CompiledOutput extends TransformedSource {
|
||||
diagnostics?: _ts.Diagnostic[];
|
||||
}
|
||||
export interface CompilerInstance {
|
||||
getResolvedModules(fileContent: string, fileName: string, runtimeCacheFS: StringMap): string[];
|
||||
getCompiledOutput(fileContent: string, fileName: string, options: TsJestCompileOptions): CompiledOutput;
|
||||
}
|
||||
export interface TsCompilerInstance extends CompilerInstance {
|
||||
configSet: ConfigSet;
|
||||
program: _ts.Program | undefined;
|
||||
}
|
||||
export interface AstTransformerDesc<T = Record<string, unknown>> {
|
||||
name: string;
|
||||
version: number;
|
||||
factory(tsCompiler: TsCompilerInstance, opts?: T): _ts.TransformerFactory<_ts.SourceFile> | _ts.TransformerFactory<_ts.Bundle | _ts.SourceFile>;
|
||||
options?: T;
|
||||
}
|
||||
export interface TsJestAstTransformer {
|
||||
before: AstTransformerDesc[];
|
||||
after: AstTransformerDesc[];
|
||||
afterDeclarations: AstTransformerDesc[];
|
||||
}
|
||||
/**
|
||||
* @deprecated use other preset types below instead
|
||||
*/
|
||||
export type TsJestPresets = Pick<JestConfigWithTsJest, 'extensionsToTreatAsEsm' | 'moduleFileExtensions' | 'transform' | 'testMatch'>;
|
||||
export type DefaultTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type DefaultPreset = {
|
||||
transform: {
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest', DefaultTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultLegacyPreset = {
|
||||
transform: {
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', DefaultTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type DefaultEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & DefaultEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type DefaultEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & DefaultEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithTsPreset = {
|
||||
transform: {
|
||||
[TS_JS_TRANSFORM_PATTERN]: ['ts-jest', JsWithTsTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsLegacyPreset = {
|
||||
transform: {
|
||||
[TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithTsTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithTsEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_JS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & JsWithTsEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithTsEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_TS_JS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & JsWithTsEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelTransformerOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithBabelPreset = {
|
||||
transform: {
|
||||
[JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest', JsWithBabelTransformerOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelLegacyPreset = {
|
||||
transform: {
|
||||
[JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', JsWithBabelTransformerOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelEsmTransformOptions = Omit<TsJestTransformerOptions, 'useESM'>;
|
||||
export type JsWithBabelEsmPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest', {
|
||||
useESM: true;
|
||||
} & JsWithBabelEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
export type JsWithBabelEsmLegacyPreset = {
|
||||
extensionsToTreatAsEsm: string[];
|
||||
transform: {
|
||||
[ESM_JS_TRANSFORM_PATTERN]: 'babel-jest';
|
||||
[ESM_TS_TRANSFORM_PATTERN]: ['ts-jest/legacy', {
|
||||
useESM: true;
|
||||
} & JsWithBabelEsmTransformOptions];
|
||||
};
|
||||
};
|
||||
declare module '@jest/types' {
|
||||
namespace Config {
|
||||
interface ConfigGlobals {
|
||||
/**
|
||||
* strangely `@ts-expect-error` doesn't work in this case when running
|
||||
* `npm run build` vs `npm run pretest`
|
||||
*/
|
||||
'ts-jest'?: TsJestTransformerOptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
node_modules/ts-jest/dist/types.js
generated
vendored
Normal file
3
node_modules/ts-jest/dist/types.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const constants_1 = require("./constants");
|
||||
1
node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/backports.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
118
node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
118
node_modules/ts-jest/dist/utils/backports.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.backportTsJestDebugEnvVar = exports.backportJestConfig = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const messages_1 = require("./messages");
|
||||
const context = { [bs_logger_1.LogContexts.namespace]: 'backports' };
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportJestConfig = (logger, config) => {
|
||||
logger.debug({ ...context, config }, 'backporting config');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const { globals = {} } = (config || {});
|
||||
const { 'ts-jest': tsJest = {} } = globals;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const mergeTsJest = {};
|
||||
let hadWarnings = false;
|
||||
const warnConfig = (oldPath, newPath, note) => {
|
||||
hadWarnings = true;
|
||||
logger.warn(context, (0, messages_1.interpolate)(note ? "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead.\n \u21B3 {{note}}" /* Deprecations.ConfigOptionWithNote */ : "\"[jest-config].{{oldPath}}\" is deprecated, use \"[jest-config].{{newPath}}\" instead." /* Deprecations.ConfigOption */, {
|
||||
oldPath,
|
||||
newPath,
|
||||
note,
|
||||
}));
|
||||
};
|
||||
if ('__TS_CONFIG__' in globals) {
|
||||
warnConfig('globals.__TS_CONFIG__', 'globals.ts-jest.tsconfig');
|
||||
if (typeof globals.__TS_CONFIG__ === 'object') {
|
||||
mergeTsJest.tsconfig = globals.__TS_CONFIG__;
|
||||
}
|
||||
delete globals.__TS_CONFIG__;
|
||||
}
|
||||
if ('__TRANSFORM_HTML__' in globals) {
|
||||
warnConfig('globals.__TRANSFORM_HTML__', 'globals.ts-jest.stringifyContentPathRegex');
|
||||
if (globals.__TRANSFORM_HTML__) {
|
||||
mergeTsJest.stringifyContentPathRegex = '\\.html?$';
|
||||
}
|
||||
delete globals.__TRANSFORM_HTML__;
|
||||
}
|
||||
if ('typeCheck' in tsJest) {
|
||||
warnConfig('globals.ts-jest.typeCheck', 'globals.ts-jest.isolatedModules');
|
||||
mergeTsJest.isolatedModules = !tsJest.typeCheck;
|
||||
delete tsJest.typeCheck;
|
||||
}
|
||||
if ('tsConfigFile' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfigFile', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfigFile) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfigFile;
|
||||
}
|
||||
delete tsJest.tsConfigFile;
|
||||
}
|
||||
if ('tsConfig' in tsJest) {
|
||||
warnConfig('globals.ts-jest.tsConfig', 'globals.ts-jest.tsconfig');
|
||||
if (tsJest.tsConfig) {
|
||||
mergeTsJest.tsconfig = tsJest.tsConfig;
|
||||
}
|
||||
delete tsJest.tsConfig;
|
||||
}
|
||||
if ('enableTsDiagnostics' in tsJest) {
|
||||
warnConfig('globals.ts-jest.enableTsDiagnostics', 'globals.ts-jest.diagnostics');
|
||||
if (tsJest.enableTsDiagnostics) {
|
||||
mergeTsJest.diagnostics = { warnOnly: true };
|
||||
if (typeof tsJest.enableTsDiagnostics === 'string')
|
||||
mergeTsJest.diagnostics.exclude = [tsJest.enableTsDiagnostics];
|
||||
}
|
||||
else {
|
||||
mergeTsJest.diagnostics = false;
|
||||
}
|
||||
delete tsJest.enableTsDiagnostics;
|
||||
}
|
||||
if ('useBabelrc' in tsJest) {
|
||||
warnConfig('globals.ts-jest.useBabelrc', 'globals.ts-jest.babelConfig', "See `babel-jest` related issue: https://github.com/facebook/jest/issues/3845" /* Deprecations.ConfigOptionUseBabelRcNote */);
|
||||
if (tsJest.useBabelrc != null) {
|
||||
mergeTsJest.babelConfig = tsJest.useBabelrc ? true : {};
|
||||
}
|
||||
delete tsJest.useBabelrc;
|
||||
}
|
||||
if ('skipBabel' in tsJest) {
|
||||
warnConfig('globals.ts-jest.skipBabel', 'globals.ts-jest.babelConfig');
|
||||
if (tsJest.skipBabel === false && !mergeTsJest.babelConfig) {
|
||||
mergeTsJest.babelConfig = true;
|
||||
}
|
||||
delete tsJest.skipBabel;
|
||||
}
|
||||
// if we had some warnings we can inform the user about the CLI tool
|
||||
if (hadWarnings) {
|
||||
logger.warn(context, messages_1.Helps.MigrateConfigUsingCLI);
|
||||
}
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
...config,
|
||||
globals: {
|
||||
...globals,
|
||||
'ts-jest': {
|
||||
...mergeTsJest,
|
||||
...tsJest,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
exports.backportJestConfig = backportJestConfig;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
const backportTsJestDebugEnvVar = (logger) => {
|
||||
if ('TS_JEST_DEBUG' in process.env) {
|
||||
const shouldLog = !/^\s*(?:0|f(?:alse)?|no?|disabled?|off|)\s*$/i.test(process.env.TS_JEST_DEBUG || '');
|
||||
delete process.env.TS_JEST_DEBUG;
|
||||
if (shouldLog) {
|
||||
process.env.TS_JEST_LOG = 'ts-jest.log,stderr:warn';
|
||||
}
|
||||
logger.warn(context, (0, messages_1.interpolate)("Using env. var \"{{old}}\" is deprecated, use \"{{new}}\" instead." /* Deprecations.EnvVar */, {
|
||||
old: 'TS_JEST_DEBUG',
|
||||
new: 'TS_JEST_LOG',
|
||||
}));
|
||||
}
|
||||
};
|
||||
exports.backportTsJestDebugEnvVar = backportTsJestDebugEnvVar;
|
||||
5
node_modules/ts-jest/dist/utils/diagnostics.d.ts
generated
vendored
Normal file
5
node_modules/ts-jest/dist/utils/diagnostics.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare const TsJestDiagnosticCodes: {
|
||||
readonly Generic: 151000;
|
||||
readonly ConfigModuleOption: 151001;
|
||||
readonly ModernNodeModule: 151002;
|
||||
};
|
||||
8
node_modules/ts-jest/dist/utils/diagnostics.js
generated
vendored
Normal file
8
node_modules/ts-jest/dist/utils/diagnostics.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TsJestDiagnosticCodes = void 0;
|
||||
exports.TsJestDiagnosticCodes = {
|
||||
Generic: 151000,
|
||||
ConfigModuleOption: 151001,
|
||||
ModernNodeModule: 151002,
|
||||
};
|
||||
1
node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/get-package-version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
14
node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
14
node_modules/ts-jest/dist/utils/get-package-version.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPackageVersion = getPackageVersion;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getPackageVersion(moduleName) {
|
||||
try {
|
||||
return require(`${moduleName}/package.json`).version;
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/importer.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
146
node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
146
node_modules/ts-jest/dist/utils/importer.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.importer = exports.Importer = void 0;
|
||||
exports.__requireModule = __requireModule;
|
||||
const logger_1 = require("./logger");
|
||||
const memoize_1 = require("./memoize");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'Importer' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
class Importer {
|
||||
static get instance() {
|
||||
logger.debug('creating Importer singleton');
|
||||
return new Importer();
|
||||
}
|
||||
babelJest(why) {
|
||||
return this._import(why, 'babel-jest');
|
||||
}
|
||||
babelCore(why) {
|
||||
return this._import(why, '@babel/core');
|
||||
}
|
||||
typescript(why, which) {
|
||||
return this._import(why, which);
|
||||
}
|
||||
esBuild(why) {
|
||||
return this._import(why, 'esbuild');
|
||||
}
|
||||
tryThese(moduleName, ...fallbacks) {
|
||||
let name;
|
||||
let loaded;
|
||||
const tries = [moduleName, ...fallbacks];
|
||||
while ((name = tries.shift()) !== undefined) {
|
||||
const req = requireWrapper(name);
|
||||
// remove exports from what we're going to log
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const contextReq = { ...req };
|
||||
delete contextReq.exports;
|
||||
if (req.exists) {
|
||||
// module exists
|
||||
loaded = req;
|
||||
if (req.error) {
|
||||
logger.error({ requireResult: contextReq }, `failed loading module '${name}'`, req.error.message);
|
||||
}
|
||||
else {
|
||||
logger.debug({ requireResult: contextReq }, 'loaded module', name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// module does not exists in the path
|
||||
logger.debug({ requireResult: contextReq }, `module '${name}' not found`);
|
||||
}
|
||||
}
|
||||
// return the loaded one, could be one that has been loaded, or one which has failed during load
|
||||
// but not one which does not exists
|
||||
return loaded;
|
||||
}
|
||||
tryTheseOr(moduleNames, missingResult, allowLoadError = false) {
|
||||
const args = Array.isArray(moduleNames) ? moduleNames : [moduleNames];
|
||||
const result = this.tryThese(...args);
|
||||
if (!result)
|
||||
return missingResult;
|
||||
if (!result.error)
|
||||
return result.exports;
|
||||
if (allowLoadError)
|
||||
return missingResult;
|
||||
throw result.error;
|
||||
}
|
||||
_import(why, moduleName, { alternatives = [], installTip = moduleName } = {}) {
|
||||
// try to load any of the alternative after trying main one
|
||||
const res = this.tryThese(moduleName, ...alternatives);
|
||||
// if we could load one, return it
|
||||
if (res?.exists) {
|
||||
if (!res.error)
|
||||
return res.exports;
|
||||
// it could not load because of a failure while importing, but it exists
|
||||
throw new Error((0, messages_1.interpolate)("Loading module {{module}} failed with error: {{error}}" /* Errors.LoadingModuleFailed */, { module: res.given, error: res.error.message }));
|
||||
}
|
||||
// if it couldn't load, build a nice error message so the user can fix it by himself
|
||||
const msg = alternatives.length ? "Unable to load any of these modules: {{module}}. {{reason}}. To fix it:\n{{fix}}" /* Errors.UnableToLoadAnyModule */ : "Unable to load the module {{module}}. {{reason}} To fix it:\n{{fix}}" /* Errors.UnableToLoadOneModule */;
|
||||
const loadModule = [moduleName, ...alternatives].map((m) => `"${m}"`).join(', ');
|
||||
if (typeof installTip === 'string') {
|
||||
installTip = [{ module: installTip, label: `install "${installTip}"` }];
|
||||
}
|
||||
const fix = installTip
|
||||
.map((tip) => ` ${installTip.length === 1 ? '↳' : '•'} ${(0, messages_1.interpolate)(messages_1.Helps.FixMissingModule, tip)}`)
|
||||
.join('\n');
|
||||
throw new Error((0, messages_1.interpolate)(msg, {
|
||||
module: loadModule,
|
||||
reason: why,
|
||||
fix,
|
||||
}));
|
||||
}
|
||||
}
|
||||
exports.Importer = Importer;
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)((...args) => args.join(':'))
|
||||
], Importer.prototype, "tryThese", null);
|
||||
__decorate([
|
||||
(0, memoize_1.Memoize)()
|
||||
], Importer, "instance", null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.importer = Importer.instance;
|
||||
function requireWrapper(moduleName) {
|
||||
let path;
|
||||
let exists = false;
|
||||
try {
|
||||
path = resolveModule(moduleName);
|
||||
exists = true;
|
||||
}
|
||||
catch (error) {
|
||||
return { error: error, exists, given: moduleName };
|
||||
}
|
||||
const result = { exists, path, given: moduleName };
|
||||
try {
|
||||
result.exports = requireModule(path);
|
||||
}
|
||||
catch {
|
||||
try {
|
||||
result.exports = requireModule(moduleName);
|
||||
}
|
||||
catch (error) {
|
||||
result.error = error;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
let requireModule = (mod) => require(mod);
|
||||
let resolveModule = (mod) => require.resolve(mod, { paths: [process.cwd(), __dirname] });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// so that we can test easier
|
||||
function __requireModule(localRequire, localResolve) {
|
||||
requireModule = localRequire;
|
||||
resolveModule = localResolve;
|
||||
}
|
||||
4
node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
4
node_modules/ts-jest/dist/utils/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './json';
|
||||
export * from './jsonable-value';
|
||||
export * from './logger';
|
||||
export * from './diagnostics';
|
||||
20
node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
20
node_modules/ts-jest/dist/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./json"), exports);
|
||||
__exportStar(require("./jsonable-value"), exports);
|
||||
__exportStar(require("./logger"), exports);
|
||||
__exportStar(require("./diagnostics"), exports);
|
||||
2
node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
2
node_modules/ts-jest/dist/utils/json.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare function stringify(input: unknown): string;
|
||||
export declare function parse(input: string): any;
|
||||
16
node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
16
node_modules/ts-jest/dist/utils/json.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stringify = stringify;
|
||||
exports.parse = parse;
|
||||
const fast_json_stable_stringify_1 = __importDefault(require("fast-json-stable-stringify"));
|
||||
const UNDEFINED = 'undefined';
|
||||
function stringify(input) {
|
||||
return input === undefined ? UNDEFINED : (0, fast_json_stable_stringify_1.default)(input);
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function parse(input) {
|
||||
return input === UNDEFINED ? undefined : JSON.parse(input);
|
||||
}
|
||||
10
node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
10
node_modules/ts-jest/dist/utils/jsonable-value.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare class JsonableValue<V = Record<string, any>> {
|
||||
private _serialized;
|
||||
private _value;
|
||||
constructor(value: V);
|
||||
set value(value: V);
|
||||
get value(): V;
|
||||
get serialized(): string;
|
||||
valueOf(): V;
|
||||
toString(): string;
|
||||
}
|
||||
29
node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
29
node_modules/ts-jest/dist/utils/jsonable-value.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.JsonableValue = void 0;
|
||||
const json_1 = require("./json");
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
class JsonableValue {
|
||||
_serialized;
|
||||
_value;
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
set value(value) {
|
||||
this._value = value;
|
||||
this._serialized = (0, json_1.stringify)(value);
|
||||
}
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
get serialized() {
|
||||
return this._serialized;
|
||||
}
|
||||
valueOf() {
|
||||
return this._value;
|
||||
}
|
||||
toString() {
|
||||
return this._serialized;
|
||||
}
|
||||
}
|
||||
exports.JsonableValue = JsonableValue;
|
||||
1
node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/logger.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare let rootLogger: import("bs-logger").Logger;
|
||||
20
node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
20
node_modules/ts-jest/dist/utils/logger.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.rootLogger = void 0;
|
||||
const bs_logger_1 = require("bs-logger");
|
||||
const backports_1 = require("./backports");
|
||||
const original = process.env.TS_JEST_LOG;
|
||||
const buildOptions = () => ({
|
||||
context: {
|
||||
[bs_logger_1.LogContexts.package]: 'ts-jest',
|
||||
[bs_logger_1.LogContexts.logLevel]: bs_logger_1.LogLevels.trace,
|
||||
version: require('../../package.json').version,
|
||||
},
|
||||
targets: process.env.TS_JEST_LOG ?? undefined,
|
||||
});
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
(0, backports_1.backportTsJestDebugEnvVar)(exports.rootLogger);
|
||||
// re-create the logger if the env var has been backported
|
||||
if (original !== process.env.TS_JEST_LOG) {
|
||||
exports.rootLogger = (0, bs_logger_1.createLogger)(buildOptions());
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/memoize.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
60
node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
60
node_modules/ts-jest/dist/utils/memoize.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Memoize = Memoize;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const cacheProp = Symbol.for('[memoize]');
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function Memoize(keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (_, propertyKey, descriptor) => {
|
||||
if (descriptor.value != null) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
descriptor.value = memoize(propertyKey, descriptor.value, keyBuilder || ((v) => v));
|
||||
}
|
||||
else if (descriptor.get != null) {
|
||||
descriptor.get = memoize(propertyKey, descriptor.get, keyBuilder || (() => propertyKey));
|
||||
}
|
||||
};
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureCache(target, reset = false) {
|
||||
if (reset || !target[cacheProp]) {
|
||||
Object.defineProperty(target, cacheProp, {
|
||||
value: Object.create(null),
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
return target[cacheProp];
|
||||
}
|
||||
// See https://github.com/microsoft/TypeScript/issues/1863#issuecomment-579541944
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function ensureChildCache(target, key, reset = false) {
|
||||
const dict = ensureCache(target);
|
||||
if (reset || !dict[key]) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
dict[key] = new Map();
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return dict[key];
|
||||
}
|
||||
function memoize(namespace,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
func,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
keyBuilder) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return function (...args) {
|
||||
const cache = ensureChildCache(this, namespace);
|
||||
const key = keyBuilder.apply(this, args);
|
||||
if (cache.has(key))
|
||||
return cache.get(key);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const res = func.apply(this, args);
|
||||
cache.set(key, res);
|
||||
return res;
|
||||
};
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/messages.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
21
node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
21
node_modules/ts-jest/dist/utils/messages.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Helps = void 0;
|
||||
exports.interpolate = interpolate;
|
||||
const diagnostics_1 = require("./diagnostics");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.Helps = {
|
||||
FixMissingModule: '{{label}}: `npm i -D {{module}}` (or `yarn add --dev {{module}}`)',
|
||||
MigrateConfigUsingCLI: 'Your Jest configuration is outdated. Use the CLI to help migrating it: ts-jest config:migrate <config-file>.',
|
||||
UsingModernNodeResolution: `Using hybrid module kind (Node16/18/Next) is only supported in "isolatedModules: true". Please set "isolatedModules: true" in your tsconfig.json. To disable this message, you can set "diagnostics.ignoreCodes" to include ${diagnostics_1.TsJestDiagnosticCodes.ModernNodeModule} in your ts-jest config. See more at https://kulshekhar.github.io/ts-jest/docs/getting-started/options/diagnostics`,
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
function interpolate(msg, vars = {}) {
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
return msg.replace(/\{\{([^\}]+)\}\}/g, (_, key) => (key in vars ? vars[key] : _));
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/normalize-slashes.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
9
node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
9
node_modules/ts-jest/dist/utils/normalize-slashes.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeSlashes = normalizeSlashes;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function normalizeSlashes(value) {
|
||||
return value.replace(/\\/g, '/');
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/sha1.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
38
node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
38
node_modules/ts-jest/dist/utils/sha1.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cache = void 0;
|
||||
exports.sha1 = sha1;
|
||||
const crypto_1 = require("crypto");
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
// stores hashes made out of only one argument being a string
|
||||
exports.cache = Object.create(null);
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function sha1(...data) {
|
||||
const canCache = data.length === 1 && typeof data[0] === 'string';
|
||||
// caching
|
||||
let cacheKey;
|
||||
if (canCache) {
|
||||
cacheKey = data[0];
|
||||
if (cacheKey in exports.cache) {
|
||||
return exports.cache[cacheKey];
|
||||
}
|
||||
}
|
||||
// we use SHA1 because it's the fastest provided by node
|
||||
// and we are not concerned about security here
|
||||
const hash = (0, crypto_1.createHash)('sha1');
|
||||
data.forEach((item) => {
|
||||
if (typeof item === 'string')
|
||||
hash.update(item, 'utf8');
|
||||
else
|
||||
hash.update(item);
|
||||
});
|
||||
const res = hash.digest('hex').toString();
|
||||
if (canCache) {
|
||||
exports.cache[cacheKey] = res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
1
node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
1
node_modules/ts-jest/dist/utils/ts-error.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
37
node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
37
node_modules/ts-jest/dist/utils/ts-error.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TSError = exports.INSPECT_CUSTOM = void 0;
|
||||
const util_1 = require("util");
|
||||
const make_error_1 = require("make-error");
|
||||
const logger_1 = require("./logger");
|
||||
const messages_1 = require("./messages");
|
||||
const logger = logger_1.rootLogger.child({ namespace: 'TSError' });
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
exports.INSPECT_CUSTOM = util_1.inspect.custom || 'inspect';
|
||||
/**
|
||||
* TypeScript diagnostics error.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TSError extends make_error_1.BaseError {
|
||||
diagnosticText;
|
||||
diagnosticCodes;
|
||||
name = 'TSError';
|
||||
constructor(diagnosticText, diagnosticCodes) {
|
||||
super((0, messages_1.interpolate)("{{diagnostics}}" /* Errors.UnableToCompileTypeScript */, {
|
||||
diagnostics: diagnosticText.trim(),
|
||||
}));
|
||||
this.diagnosticText = diagnosticText;
|
||||
this.diagnosticCodes = diagnosticCodes;
|
||||
logger.debug({ diagnosticCodes, diagnosticText }, 'created new TSError');
|
||||
// ensure we blacklist any of our code
|
||||
Object.defineProperty(this, 'stack', { value: '' });
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
[exports.INSPECT_CUSTOM]() {
|
||||
return this.diagnosticText;
|
||||
}
|
||||
}
|
||||
exports.TSError = TSError;
|
||||
1
node_modules/ts-jest/jest-preset.js
generated
vendored
Normal file
1
node_modules/ts-jest/jest-preset.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./presets').defaults
|
||||
1
node_modules/ts-jest/legacy.js
generated
vendored
Normal file
1
node_modules/ts-jest/legacy.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./dist/legacy')
|
||||
1
node_modules/ts-jest/node_modules/.bin/semver
generated
vendored
Symbolic link
1
node_modules/ts-jest/node_modules/.bin/semver
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../semver/bin/semver.js
|
||||
15
node_modules/ts-jest/node_modules/semver/LICENSE
generated
vendored
Normal file
15
node_modules/ts-jest/node_modules/semver/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
680
node_modules/ts-jest/node_modules/semver/README.md
generated
vendored
Normal file
680
node_modules/ts-jest/node_modules/semver/README.md
generated
vendored
Normal file
@@ -0,0 +1,680 @@
|
||||
semver(1) -- The semantic versioner for npm
|
||||
===========================================
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install semver
|
||||
````
|
||||
|
||||
## Usage
|
||||
|
||||
As a node module:
|
||||
|
||||
```js
|
||||
const semver = require('semver')
|
||||
|
||||
semver.valid('1.2.3') // '1.2.3'
|
||||
semver.valid('a.b.c') // null
|
||||
semver.clean(' =v1.2.3 ') // '1.2.3'
|
||||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
||||
semver.gt('1.2.3', '9.8.7') // false
|
||||
semver.lt('1.2.3', '9.8.7') // true
|
||||
semver.minVersion('>=1.0.0') // '1.0.0'
|
||||
semver.valid(semver.coerce('v2')) // '2.0.0'
|
||||
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
||||
```
|
||||
|
||||
You can also just load the module for the function that you care about if
|
||||
you'd like to minimize your footprint.
|
||||
|
||||
```js
|
||||
// load the whole API at once in a single object
|
||||
const semver = require('semver')
|
||||
|
||||
// or just load the bits you need
|
||||
// all of them listed here, just pick and choose what you want
|
||||
|
||||
// classes
|
||||
const SemVer = require('semver/classes/semver')
|
||||
const Comparator = require('semver/classes/comparator')
|
||||
const Range = require('semver/classes/range')
|
||||
|
||||
// functions for working with versions
|
||||
const semverParse = require('semver/functions/parse')
|
||||
const semverValid = require('semver/functions/valid')
|
||||
const semverClean = require('semver/functions/clean')
|
||||
const semverInc = require('semver/functions/inc')
|
||||
const semverDiff = require('semver/functions/diff')
|
||||
const semverMajor = require('semver/functions/major')
|
||||
const semverMinor = require('semver/functions/minor')
|
||||
const semverPatch = require('semver/functions/patch')
|
||||
const semverPrerelease = require('semver/functions/prerelease')
|
||||
const semverCompare = require('semver/functions/compare')
|
||||
const semverRcompare = require('semver/functions/rcompare')
|
||||
const semverCompareLoose = require('semver/functions/compare-loose')
|
||||
const semverCompareBuild = require('semver/functions/compare-build')
|
||||
const semverSort = require('semver/functions/sort')
|
||||
const semverRsort = require('semver/functions/rsort')
|
||||
const semverTruncate = require('semver/functions/truncate')
|
||||
|
||||
// low-level comparators between versions
|
||||
const semverGt = require('semver/functions/gt')
|
||||
const semverLt = require('semver/functions/lt')
|
||||
const semverEq = require('semver/functions/eq')
|
||||
const semverNeq = require('semver/functions/neq')
|
||||
const semverGte = require('semver/functions/gte')
|
||||
const semverLte = require('semver/functions/lte')
|
||||
const semverCmp = require('semver/functions/cmp')
|
||||
const semverCoerce = require('semver/functions/coerce')
|
||||
|
||||
// working with ranges
|
||||
const semverSatisfies = require('semver/functions/satisfies')
|
||||
const semverMaxSatisfying = require('semver/ranges/max-satisfying')
|
||||
const semverMinSatisfying = require('semver/ranges/min-satisfying')
|
||||
const semverToComparators = require('semver/ranges/to-comparators')
|
||||
const semverMinVersion = require('semver/ranges/min-version')
|
||||
const semverValidRange = require('semver/ranges/valid')
|
||||
const semverOutside = require('semver/ranges/outside')
|
||||
const semverGtr = require('semver/ranges/gtr')
|
||||
const semverLtr = require('semver/ranges/ltr')
|
||||
const semverIntersects = require('semver/ranges/intersects')
|
||||
const semverSimplifyRange = require('semver/ranges/simplify')
|
||||
const semverRangeSubset = require('semver/ranges/subset')
|
||||
```
|
||||
|
||||
As a command-line utility:
|
||||
|
||||
```
|
||||
$ semver -h
|
||||
|
||||
A JavaScript implementation of the https://semver.org/ specification
|
||||
Copyright Isaac Z. Schlueter
|
||||
|
||||
Usage: semver [options] <version> [<version> [...]]
|
||||
Prints valid versions sorted by SemVer precedence
|
||||
|
||||
Options:
|
||||
-r --range <range>
|
||||
Print versions that match the specified range.
|
||||
|
||||
-i --increment [<level>]
|
||||
Increment a version by the specified level. Level can
|
||||
be one of: major, minor, patch, premajor, preminor,
|
||||
prepatch, prerelease, or release. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
Identifier to be used to prefix premajor, preminor,
|
||||
prepatch or prerelease version increments.
|
||||
|
||||
-l --loose
|
||||
Interpret versions and ranges loosely
|
||||
|
||||
-n <0|1|false>
|
||||
Base number for prerelease identifier (default: 0).
|
||||
Use false to omit the number altogether.
|
||||
|
||||
-p --include-prerelease
|
||||
Always include prerelease versions in range matching
|
||||
|
||||
-c --coerce
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
--rtl
|
||||
Coerce version strings right to left
|
||||
|
||||
--ltr
|
||||
Coerce version strings left to right (default)
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no satisfying versions are found, then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.
|
||||
```
|
||||
|
||||
## Versions
|
||||
|
||||
A "version" is described by the `v2.0.0` specification found at
|
||||
<https://semver.org/>.
|
||||
|
||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
||||
Support for stripping a leading "v" is kept for compatibility with `v1.0.0` of the SemVer
|
||||
specification but should not be used anymore.
|
||||
|
||||
## Ranges
|
||||
|
||||
A `version range` is a set of `comparators` that specify versions
|
||||
that satisfy the range.
|
||||
|
||||
A `comparator` is composed of an `operator` and a `version`. The set
|
||||
of primitive `operators` is:
|
||||
|
||||
* `<` Less than
|
||||
* `<=` Less than or equal to
|
||||
* `>` Greater than
|
||||
* `>=` Greater than or equal to
|
||||
* `=` Equal. If no operator is specified, then equality is assumed,
|
||||
so this operator is optional but MAY be included.
|
||||
|
||||
For example, the comparator `>=1.2.7` would match the versions
|
||||
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
||||
or `1.1.0`. The comparator `>1` is equivalent to `>=2.0.0` and
|
||||
would match the versions `2.0.0` and `3.1.0`, but not the versions
|
||||
`1.0.1` or `1.1.0`.
|
||||
|
||||
Comparators can be joined by whitespace to form a `comparator set`,
|
||||
which is satisfied by the **intersection** of all of the comparators
|
||||
it includes.
|
||||
|
||||
A range is composed of one or more comparator sets, joined by `||`. A
|
||||
version matches a range if and only if every comparator in at least
|
||||
one of the `||`-separated comparator sets is satisfied by the version.
|
||||
|
||||
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
||||
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
||||
or `1.1.0`.
|
||||
|
||||
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
||||
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
||||
|
||||
### Prerelease Tags
|
||||
|
||||
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
||||
it will only be allowed to satisfy comparator sets if at least one
|
||||
comparator with the same `[major, minor, patch]` tuple also has a
|
||||
prerelease tag.
|
||||
|
||||
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
||||
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
||||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
||||
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
||||
range only accepts prerelease tags on the `1.2.3` version.
|
||||
Version `3.4.5` *would* satisfy the range because it does not have a
|
||||
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
||||
|
||||
The purpose of this behavior is twofold. First, prerelease versions
|
||||
frequently are updated very quickly, and contain many breaking changes
|
||||
that are (by the author's design) not yet fit for public consumption.
|
||||
Therefore, by default, they are excluded from range-matching
|
||||
semantics.
|
||||
|
||||
Second, a user who has opted into using a prerelease version has
|
||||
indicated the intent to use *that specific* set of
|
||||
alpha/beta/rc versions. By including a prerelease tag in the range,
|
||||
the user is indicating that they are aware of the risk. However, it
|
||||
is still not appropriate to assume that they have opted into taking a
|
||||
similar risk on the *next* set of prerelease versions.
|
||||
|
||||
Note that this behavior can be suppressed (treating all prerelease
|
||||
versions as if they were normal versions, for range-matching)
|
||||
by setting the `includePrerelease` flag on the options
|
||||
object to any
|
||||
[functions](https://github.com/npm/node-semver#functions) that do
|
||||
range matching.
|
||||
|
||||
#### Prerelease Identifiers
|
||||
|
||||
The method `.inc` takes an additional `identifier` string argument that
|
||||
will append the value of the string as a prerelease identifier:
|
||||
|
||||
```javascript
|
||||
semver.inc('1.2.3', 'prerelease', 'beta')
|
||||
// '1.2.4-beta.0'
|
||||
```
|
||||
|
||||
command-line example:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.3 -i prerelease --preid beta
|
||||
1.2.4-beta.0
|
||||
```
|
||||
|
||||
Which then can be used to increment further:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.4-beta.0 -i prerelease
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
To get out of the prerelease phase, use the `release` option:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.4-beta.1 -i release
|
||||
1.2.4
|
||||
```
|
||||
|
||||
#### Prerelease Identifier Base
|
||||
|
||||
The method `.inc` takes an optional parameter 'identifierBase' string
|
||||
that will let you let your prerelease number as zero-based or one-based.
|
||||
Set to `false` to omit the prerelease number altogether.
|
||||
If you do not specify this parameter, it will default to zero-based.
|
||||
|
||||
```javascript
|
||||
semver.inc('1.2.3', 'prerelease', 'beta', '1')
|
||||
// '1.2.4-beta.1'
|
||||
```
|
||||
|
||||
```javascript
|
||||
semver.inc('1.2.3', 'prerelease', 'beta', false)
|
||||
// '1.2.4-beta'
|
||||
```
|
||||
|
||||
command-line example:
|
||||
|
||||
```bash
|
||||
$ semver 1.2.3 -i prerelease --preid beta -n 1
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
```bash
|
||||
$ semver 1.2.3 -i prerelease --preid beta -n false
|
||||
1.2.4-beta
|
||||
```
|
||||
|
||||
### Advanced Range Syntax
|
||||
|
||||
Advanced range syntax desugars to primitive comparators in
|
||||
deterministic ways.
|
||||
|
||||
Advanced ranges may be combined in the same way as primitive
|
||||
comparators using white space or `||`.
|
||||
|
||||
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
||||
|
||||
Specifies an inclusive set.
|
||||
|
||||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the first version in the inclusive
|
||||
range, then the missing pieces are replaced with zeroes.
|
||||
|
||||
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the second version in the
|
||||
inclusive range, then all versions that start with the supplied parts
|
||||
of the tuple are accepted, but nothing that would be greater than the
|
||||
provided tuple parts.
|
||||
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
|
||||
|
||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
||||
|
||||
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
||||
numeric values in the `[major, minor, patch]` tuple.
|
||||
|
||||
* `*` := `>=0.0.0` (Any non-prerelease version satisfies, unless
|
||||
`includePrerelease` is specified, in which case any version at all
|
||||
satisfies)
|
||||
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
|
||||
|
||||
A partial version range is treated as an X-Range, so the special
|
||||
character is in fact optional.
|
||||
|
||||
* `""` (empty string) := `*` := `>=0.0.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
|
||||
|
||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||
|
||||
Allows patch-level changes if a minor version is specified on the
|
||||
comparator. Allows minor-level changes if not.
|
||||
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
|
||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
||||
|
||||
Allows changes that do not modify the left-most non-zero element in the
|
||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
||||
minor updates for versions `1.0.0` and above, patch updates for
|
||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
||||
|
||||
Many authors treat a `0.x` version as if the `x` were the major
|
||||
"breaking-change" indicator.
|
||||
|
||||
Caret ranges are ideal when an author may make breaking changes
|
||||
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
||||
However, it presumes that there will *not* be breaking changes between
|
||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
||||
additive (but non-breaking), according to commonly observed practices.
|
||||
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the
|
||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
||||
|
||||
When parsing caret ranges, a missing `patch` value desugars to the
|
||||
number `0`, but will allow flexibility within that value, even if the
|
||||
major and minor versions are both `0`.
|
||||
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0-0`
|
||||
|
||||
A missing `minor` and `patch` values will desugar to zero, but also
|
||||
allow flexibility within those values, even if the major version is
|
||||
zero.
|
||||
|
||||
* `^1.x` := `>=1.0.0 <2.0.0-0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0-0`
|
||||
|
||||
### Range Grammar
|
||||
|
||||
Putting all this together, here is a Backus-Naur grammar for ranges,
|
||||
for the benefit of parser authors:
|
||||
|
||||
```bnf
|
||||
range-set ::= range ( logical-or range ) *
|
||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
||||
hyphen ::= partial ' - ' partial
|
||||
simple ::= primitive | partial | tilde | caret
|
||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
||||
xr ::= 'x' | 'X' | '*' | nr
|
||||
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
||||
tilde ::= '~' partial
|
||||
caret ::= '^' partial
|
||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
||||
pre ::= prepart ( '.' prepart ) *
|
||||
prepart ::= nr | alphanumid
|
||||
build ::= buildid ( '.' buildid ) *
|
||||
alphanumid ::= ( ['0'-'9'] ) * [-A-Za-z] [-0-9A-Za-z] *
|
||||
buildid ::= [-0-9A-Za-z]+
|
||||
```
|
||||
|
||||
Note: Prerelease identifiers (`pre`) use `nr` for numeric parts, which
|
||||
disallows leading zeros (e.g., `1.2.3-00` is invalid). Build metadata
|
||||
identifiers (`build`) allow any alphanumeric string including leading
|
||||
zeros (e.g., `1.2.3+00` is valid). This matches the
|
||||
[SemVer 2.0.0 specification](https://semver.org/#spec-item-9).
|
||||
|
||||
## Functions
|
||||
|
||||
All methods and classes take a final `options` object argument. All
|
||||
options in this object are `false` by default. The options supported
|
||||
are:
|
||||
|
||||
- `loose`: Be more forgiving about not-quite-valid semver strings.
|
||||
(Any resulting output will always be 100% strict compliant, of
|
||||
course.) For backwards compatibility reasons, if the `options`
|
||||
argument is a boolean value instead of an object, it is interpreted
|
||||
to be the `loose` param.
|
||||
- `includePrerelease`: Set to suppress the [default
|
||||
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
||||
excluding prerelease tagged versions from ranges unless they are
|
||||
explicitly opted into.
|
||||
|
||||
Strict-mode Comparators and Ranges will be strict about the SemVer
|
||||
strings that they parse.
|
||||
|
||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
||||
* `inc(v, releaseType, options, identifier, identifierBase)`:
|
||||
Return the version incremented by the release
|
||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
||||
`prepatch`, `prerelease`, or `release`), or null if it's not valid
|
||||
* `premajor` in one call will bump the version up to the next major
|
||||
version and down to a prerelease of that major version.
|
||||
`preminor`, and `prepatch` work the same way.
|
||||
* If called from a non-prerelease version, `prerelease` will work the
|
||||
same as `prepatch`. It increments the patch version and then makes a
|
||||
prerelease. If the input version is already a prerelease it simply
|
||||
increments it.
|
||||
* `release` will remove any prerelease part of the version.
|
||||
* `identifier` can be used to prefix `premajor`, `preminor`,
|
||||
`prepatch`, or `prerelease` version increments. `identifierBase`
|
||||
is the base to be used for the `prerelease` identifier.
|
||||
* `prerelease(v)`: Returns an array of prerelease components, or null
|
||||
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
||||
* `major(v)`: Return the major version number.
|
||||
* `minor(v)`: Return the minor version number.
|
||||
* `patch(v)`: Return the patch version number.
|
||||
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
||||
or comparators intersect.
|
||||
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
||||
a `SemVer` object or `null`.
|
||||
* `truncate(v, releaseType)`: Return the version with components _lower_
|
||||
than `releaseType` dropped off, e.g.:
|
||||
* `major` removes build & prerelease info and sets minor & patch to 0.
|
||||
* `minor` removes build & prerelease info, and sets patch to 0
|
||||
* `patch` removes build & prerelease info
|
||||
* All prerelease types remove build info only
|
||||
|
||||
### Comparison
|
||||
|
||||
* `gt(v1, v2)`: `v1 > v2`
|
||||
* `gte(v1, v2)`: `v1 >= v2`
|
||||
* `lt(v1, v2)`: `v1 < v2`
|
||||
* `lte(v1, v2)`: `v1 <= v2`
|
||||
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
||||
even if they're not the same string. You already know how to
|
||||
compare strings.
|
||||
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
||||
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
||||
the corresponding function above. `"==="` and `"!=="` do simple
|
||||
string comparison, but are included for completeness. Throws if an
|
||||
invalid comparison string is provided.
|
||||
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `rcompare(v1, v2)`: The reverse of `compare`. Sorts an array of versions
|
||||
in descending order when passed to `Array.sort()`.
|
||||
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
||||
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `compareLoose(v1, v2)`: Short for `compare(v1, v2, { loose: true })`.
|
||||
* `diff(v1, v2)`: Returns the difference between two versions by the release type
|
||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
||||
or null if the versions are the same.
|
||||
|
||||
### Sorting
|
||||
|
||||
* `sort(versions)`: Returns a sorted array of versions based on the `compareBuild`
|
||||
function.
|
||||
* `rsort(versions)`: The reverse of `sort`. Returns an array of versions based on
|
||||
the `compareBuild` function in descending order.
|
||||
|
||||
### Comparators
|
||||
|
||||
* `intersects(comparator)`: Return true if the comparators intersect
|
||||
|
||||
### Ranges
|
||||
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid.
|
||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
||||
range.
|
||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `minVersion(range)`: Return the lowest version that can match
|
||||
the given range.
|
||||
* `gtr(version, range)`: Return `true` if the version is greater than all the
|
||||
versions possible in the range.
|
||||
* `ltr(version, range)`: Return `true` if the version is less than all the
|
||||
versions possible in the range.
|
||||
* `outside(version, range, hilo)`: Return true if the version is outside
|
||||
the bounds of the range in either the high or low direction. The
|
||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||
the function called by `gtr` and `ltr`.)
|
||||
* `intersects(range)`: Return true if any of the range comparators intersect.
|
||||
* `simplifyRange(versions, range)`: Return a "simplified" range that
|
||||
matches the same items in the `versions` list as the range specified. Note
|
||||
that it does *not* guarantee that it would match the same versions in all
|
||||
cases, only for the set of versions provided. This is useful when
|
||||
generating ranges by joining together multiple versions with `||`
|
||||
programmatically, to provide the user with something a bit more
|
||||
ergonomic. If the provided range is shorter in string-length than the
|
||||
generated range, then that is returned.
|
||||
* `subset(subRange, superRange)`: Return `true` if the `subRange` range is
|
||||
entirely contained by the `superRange` range.
|
||||
|
||||
Note that, since ranges may be non-contiguous, a version might not be
|
||||
greater than a range, less than a range, *or* satisfy a range! For
|
||||
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
||||
until `2.0.0`, so version `1.2.10` would not be greater than the
|
||||
range (because `2.0.1` satisfies, which is higher), nor less than the
|
||||
range (since `1.2.8` satisfies, which is lower), and it also does not
|
||||
satisfy the range.
|
||||
|
||||
If you want to know if a version satisfies or does not satisfy a
|
||||
range, use the `satisfies(version, range)` function.
|
||||
|
||||
### Coercion
|
||||
|
||||
* `coerce(version, options)`: Coerces a string to semver if possible
|
||||
|
||||
This aims to provide a very forgiving translation of a non-semver string to
|
||||
semver. It looks for the first digit in a string and consumes all
|
||||
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
||||
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
||||
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
||||
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
||||
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
||||
is not valid). The maximum length for any semver component considered for
|
||||
coercion is 16 characters; longer components will be ignored
|
||||
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
||||
semver component is `Number.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
||||
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
||||
|
||||
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
||||
coercible tuple that does not share an ending index with a longer coercible
|
||||
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
||||
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
||||
any other overlapping SemVer tuple.
|
||||
|
||||
If the `options.includePrerelease` flag is set, then the `coerce` result will contain
|
||||
prerelease and build parts of a version. For example, `1.2.3.4-rc.1+rev.2`
|
||||
will preserve prerelease `rc.1` and build `rev.2` in the result.
|
||||
|
||||
### Clean
|
||||
|
||||
* `clean(version)`: Clean a string to be a valid semver if possible
|
||||
|
||||
This will return a cleaned and trimmed semver version. If the provided
|
||||
version is not valid a null will be returned. This does not work for
|
||||
ranges.
|
||||
|
||||
ex.
|
||||
* `s.clean(' = v 2.1.5foo')`: `null`
|
||||
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
||||
* `s.clean(' = v 2.1.5-foo')`: `null`
|
||||
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
||||
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
||||
* `s.clean(' =v2.1.5')`: `'2.1.5'`
|
||||
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
||||
* `s.clean('~1.0.0')`: `null`
|
||||
|
||||
## Constants
|
||||
|
||||
As a convenience, helper constants are exported to provide information about what `node-semver` supports:
|
||||
|
||||
### `RELEASE_TYPES`
|
||||
|
||||
- major
|
||||
- premajor
|
||||
- minor
|
||||
- preminor
|
||||
- patch
|
||||
- prepatch
|
||||
- prerelease
|
||||
|
||||
```
|
||||
const semver = require('semver');
|
||||
|
||||
if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) {
|
||||
console.log('This is a valid release type!');
|
||||
} else {
|
||||
console.warn('This is NOT a valid release type!');
|
||||
}
|
||||
```
|
||||
|
||||
### `SEMVER_SPEC_VERSION`
|
||||
|
||||
2.0.0
|
||||
|
||||
```
|
||||
const semver = require('semver');
|
||||
|
||||
console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION);
|
||||
```
|
||||
|
||||
## Exported Modules
|
||||
|
||||
<!--
|
||||
TODO: Make sure that all of these items are documented (classes aren't,
|
||||
eg), and then pull the module name into the documentation for that specific
|
||||
thing.
|
||||
-->
|
||||
|
||||
You may pull in just the part of this semver utility that you need if you
|
||||
are sensitive to packing and tree-shaking concerns. The main
|
||||
`require('semver')` export uses getter functions to lazily load the parts
|
||||
of the API that are used.
|
||||
|
||||
The following modules are available:
|
||||
|
||||
* `require('semver')`
|
||||
* `require('semver/classes')`
|
||||
* `require('semver/classes/comparator')`
|
||||
* `require('semver/classes/range')`
|
||||
* `require('semver/classes/semver')`
|
||||
* `require('semver/functions/clean')`
|
||||
* `require('semver/functions/cmp')`
|
||||
* `require('semver/functions/coerce')`
|
||||
* `require('semver/functions/compare')`
|
||||
* `require('semver/functions/compare-build')`
|
||||
* `require('semver/functions/compare-loose')`
|
||||
* `require('semver/functions/diff')`
|
||||
* `require('semver/functions/eq')`
|
||||
* `require('semver/functions/gt')`
|
||||
* `require('semver/functions/gte')`
|
||||
* `require('semver/functions/inc')`
|
||||
* `require('semver/functions/lt')`
|
||||
* `require('semver/functions/lte')`
|
||||
* `require('semver/functions/major')`
|
||||
* `require('semver/functions/minor')`
|
||||
* `require('semver/functions/neq')`
|
||||
* `require('semver/functions/parse')`
|
||||
* `require('semver/functions/patch')`
|
||||
* `require('semver/functions/prerelease')`
|
||||
* `require('semver/functions/rcompare')`
|
||||
* `require('semver/functions/rsort')`
|
||||
* `require('semver/functions/satisfies')`
|
||||
* `require('semver/functions/sort')`
|
||||
* `require('semver/functions/truncate')`
|
||||
* `require('semver/functions/valid')`
|
||||
* `require('semver/ranges/gtr')`
|
||||
* `require('semver/ranges/intersects')`
|
||||
* `require('semver/ranges/ltr')`
|
||||
* `require('semver/ranges/max-satisfying')`
|
||||
* `require('semver/ranges/min-satisfying')`
|
||||
* `require('semver/ranges/min-version')`
|
||||
* `require('semver/ranges/outside')`
|
||||
* `require('semver/ranges/simplify')`
|
||||
* `require('semver/ranges/subset')`
|
||||
* `require('semver/ranges/to-comparators')`
|
||||
* `require('semver/ranges/valid')`
|
||||
|
||||
195
node_modules/ts-jest/node_modules/semver/bin/semver.js
generated
vendored
Executable file
195
node_modules/ts-jest/node_modules/semver/bin/semver.js
generated
vendored
Executable file
@@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env node
|
||||
// Standalone semver comparison program.
|
||||
// Exits successfully and prints matching version(s) if
|
||||
// any supplied version is valid and passes all tests.
|
||||
|
||||
'use strict'
|
||||
|
||||
const argv = process.argv.slice(2)
|
||||
|
||||
let versions = []
|
||||
|
||||
const range = []
|
||||
|
||||
let inc = null
|
||||
|
||||
const version = require('../package.json').version
|
||||
|
||||
let loose = false
|
||||
|
||||
let includePrerelease = false
|
||||
|
||||
let coerce = false
|
||||
|
||||
let rtl = false
|
||||
|
||||
let identifier
|
||||
|
||||
let identifierBase
|
||||
|
||||
const semver = require('../')
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
|
||||
let reverse = false
|
||||
|
||||
let options = {}
|
||||
|
||||
const main = () => {
|
||||
if (!argv.length) {
|
||||
return help()
|
||||
}
|
||||
while (argv.length) {
|
||||
let a = argv.shift()
|
||||
const indexOfEqualSign = a.indexOf('=')
|
||||
if (indexOfEqualSign !== -1) {
|
||||
const value = a.slice(indexOfEqualSign + 1)
|
||||
a = a.slice(0, indexOfEqualSign)
|
||||
argv.unshift(value)
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case '-rv': case '-rev': case '--rev': case '--reverse':
|
||||
reverse = true
|
||||
break
|
||||
case '-l': case '--loose':
|
||||
loose = true
|
||||
break
|
||||
case '-p': case '--include-prerelease':
|
||||
includePrerelease = true
|
||||
break
|
||||
case '-v': case '--version':
|
||||
versions.push(argv.shift())
|
||||
break
|
||||
case '-i': case '--inc': case '--increment':
|
||||
if (semver.RELEASE_TYPES.includes(argv[0]) || (argv[0] === 'release')) {
|
||||
inc = { value: argv.shift(), maybeErrantValue: null, option: a }
|
||||
} else {
|
||||
inc = { value: 'patch', maybeErrantValue: argv[0], option: a }
|
||||
}
|
||||
break
|
||||
case '--preid':
|
||||
identifier = argv.shift()
|
||||
break
|
||||
case '-r': case '--range':
|
||||
range.push(argv.shift())
|
||||
break
|
||||
case '-n':
|
||||
identifierBase = argv.shift()
|
||||
if (identifierBase === 'false') {
|
||||
identifierBase = false
|
||||
}
|
||||
break
|
||||
case '-c': case '--coerce':
|
||||
coerce = true
|
||||
break
|
||||
case '--rtl':
|
||||
rtl = true
|
||||
break
|
||||
case '--ltr':
|
||||
rtl = false
|
||||
break
|
||||
case '-h': case '--help': case '-?':
|
||||
return help()
|
||||
default:
|
||||
versions.push(a)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
options = parseOptions({ loose, includePrerelease, rtl })
|
||||
|
||||
if (
|
||||
inc &&
|
||||
versions.includes(inc.maybeErrantValue) &&
|
||||
!semver.valid(inc.maybeErrantValue, options)
|
||||
) {
|
||||
console.warn(`Invalid value for ${inc.option}; defaulting to 'patch'. This may become a failure in future major versions.`)
|
||||
}
|
||||
|
||||
versions = versions.map((v) => {
|
||||
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
||||
}).filter((v) => {
|
||||
return semver.valid(v, options)
|
||||
})
|
||||
if (!versions.length) {
|
||||
return fail()
|
||||
}
|
||||
if (inc && (versions.length !== 1 || range.length)) {
|
||||
return failInc()
|
||||
}
|
||||
|
||||
for (let i = 0, l = range.length; i < l; i++) {
|
||||
versions = versions.filter((v) => {
|
||||
return semver.satisfies(v, range[i], options)
|
||||
})
|
||||
if (!versions.length) {
|
||||
return fail()
|
||||
}
|
||||
}
|
||||
versions
|
||||
.sort((a, b) => semver[reverse ? 'rcompare' : 'compare'](a, b, options))
|
||||
.map(v => semver.clean(v, options))
|
||||
.map(v => inc ? semver.inc(v, inc.value, options, identifier, identifierBase) : v)
|
||||
.forEach(v => console.log(v))
|
||||
}
|
||||
|
||||
const failInc = () => {
|
||||
console.error('--inc can only be used on a single version with no range')
|
||||
fail()
|
||||
}
|
||||
|
||||
const fail = () => process.exit(1)
|
||||
|
||||
const help = () => console.log(
|
||||
`SemVer ${version}
|
||||
|
||||
A JavaScript implementation of the https://semver.org/ specification
|
||||
Copyright Isaac Z. Schlueter
|
||||
|
||||
Usage: semver [options] <version> [<version> [...]]
|
||||
Prints valid versions sorted by SemVer precedence
|
||||
|
||||
Options:
|
||||
-r --range <range>
|
||||
Print versions that match the specified range.
|
||||
|
||||
-i --increment [<level>]
|
||||
Increment a version by the specified level. Level can
|
||||
be one of: major, minor, patch, premajor, preminor,
|
||||
prepatch, prerelease, or release. Default level is 'patch'.
|
||||
Only one version may be specified.
|
||||
|
||||
--preid <identifier>
|
||||
Identifier to be used to prefix premajor, preminor,
|
||||
prepatch or prerelease version increments.
|
||||
|
||||
-l --loose
|
||||
Interpret versions and ranges loosely
|
||||
|
||||
-p --include-prerelease
|
||||
Always include prerelease versions in range matching
|
||||
|
||||
-c --coerce
|
||||
Coerce a string into SemVer if possible
|
||||
(does not imply --loose)
|
||||
|
||||
--rtl
|
||||
Coerce version strings right to left
|
||||
|
||||
--ltr
|
||||
Coerce version strings left to right (default)
|
||||
|
||||
-n <base>
|
||||
Base number to be used for the prerelease identifier.
|
||||
Can be either 0 or 1, or false to omit the number altogether.
|
||||
Defaults to 0.
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no satisfying versions are found, then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.`)
|
||||
|
||||
main()
|
||||
143
node_modules/ts-jest/node_modules/semver/classes/comparator.js
generated
vendored
Normal file
143
node_modules/ts-jest/node_modules/semver/classes/comparator.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
'use strict'
|
||||
|
||||
const ANY = Symbol('SemVer ANY')
|
||||
// hoisted class for cyclic dependency
|
||||
class Comparator {
|
||||
static get ANY () {
|
||||
return ANY
|
||||
}
|
||||
|
||||
constructor (comp, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (comp instanceof Comparator) {
|
||||
if (comp.loose === !!options.loose) {
|
||||
return comp
|
||||
} else {
|
||||
comp = comp.value
|
||||
}
|
||||
}
|
||||
|
||||
comp = comp.trim().split(/\s+/).join(' ')
|
||||
debug('comparator', comp, options)
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
this.parse(comp)
|
||||
|
||||
if (this.semver === ANY) {
|
||||
this.value = ''
|
||||
} else {
|
||||
this.value = this.operator + this.semver.version
|
||||
}
|
||||
|
||||
debug('comp', this)
|
||||
}
|
||||
|
||||
parse (comp) {
|
||||
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||
const m = comp.match(r)
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError(`Invalid comparator: ${comp}`)
|
||||
}
|
||||
|
||||
this.operator = m[1] !== undefined ? m[1] : ''
|
||||
if (this.operator === '=') {
|
||||
this.operator = ''
|
||||
}
|
||||
|
||||
// if it literally is just '>' or '' then allow anything.
|
||||
if (!m[2]) {
|
||||
this.semver = ANY
|
||||
} else {
|
||||
this.semver = new SemVer(m[2], this.options.loose)
|
||||
}
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.value
|
||||
}
|
||||
|
||||
test (version) {
|
||||
debug('Comparator.test', version, this.options.loose)
|
||||
|
||||
if (this.semver === ANY || version === ANY) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return cmp(version, this.operator, this.semver, this.options)
|
||||
}
|
||||
|
||||
intersects (comp, options) {
|
||||
if (!(comp instanceof Comparator)) {
|
||||
throw new TypeError('a Comparator is required')
|
||||
}
|
||||
|
||||
if (this.operator === '') {
|
||||
if (this.value === '') {
|
||||
return true
|
||||
}
|
||||
return new Range(comp.value, options).test(this.value)
|
||||
} else if (comp.operator === '') {
|
||||
if (comp.value === '') {
|
||||
return true
|
||||
}
|
||||
return new Range(this.value, options).test(comp.semver)
|
||||
}
|
||||
|
||||
options = parseOptions(options)
|
||||
|
||||
// Special cases where nothing can possibly be lower
|
||||
if (options.includePrerelease &&
|
||||
(this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {
|
||||
return false
|
||||
}
|
||||
if (!options.includePrerelease &&
|
||||
(this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Same direction increasing (> or >=)
|
||||
if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {
|
||||
return true
|
||||
}
|
||||
// Same direction decreasing (< or <=)
|
||||
if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {
|
||||
return true
|
||||
}
|
||||
// same SemVer and both sides are inclusive (<= or >=)
|
||||
if (
|
||||
(this.semver.version === comp.semver.version) &&
|
||||
this.operator.includes('=') && comp.operator.includes('=')) {
|
||||
return true
|
||||
}
|
||||
// opposite directions less than
|
||||
if (cmp(this.semver, '<', comp.semver, options) &&
|
||||
this.operator.startsWith('>') && comp.operator.startsWith('<')) {
|
||||
return true
|
||||
}
|
||||
// opposite directions greater than
|
||||
if (cmp(this.semver, '>', comp.semver, options) &&
|
||||
this.operator.startsWith('<') && comp.operator.startsWith('>')) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Comparator
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
const cmp = require('../functions/cmp')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
const Range = require('./range')
|
||||
7
node_modules/ts-jest/node_modules/semver/classes/index.js
generated
vendored
Normal file
7
node_modules/ts-jest/node_modules/semver/classes/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
SemVer: require('./semver.js'),
|
||||
Range: require('./range.js'),
|
||||
Comparator: require('./comparator.js'),
|
||||
}
|
||||
557
node_modules/ts-jest/node_modules/semver/classes/range.js
generated
vendored
Normal file
557
node_modules/ts-jest/node_modules/semver/classes/range.js
generated
vendored
Normal file
@@ -0,0 +1,557 @@
|
||||
'use strict'
|
||||
|
||||
const SPACE_CHARACTERS = /\s+/g
|
||||
|
||||
// hoisted class for cyclic dependency
|
||||
class Range {
|
||||
constructor (range, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (range instanceof Range) {
|
||||
if (
|
||||
range.loose === !!options.loose &&
|
||||
range.includePrerelease === !!options.includePrerelease
|
||||
) {
|
||||
return range
|
||||
} else {
|
||||
return new Range(range.raw, options)
|
||||
}
|
||||
}
|
||||
|
||||
if (range instanceof Comparator) {
|
||||
// just put it in the set and return
|
||||
this.raw = range.value
|
||||
this.set = [[range]]
|
||||
this.formatted = undefined
|
||||
return this
|
||||
}
|
||||
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
this.includePrerelease = !!options.includePrerelease
|
||||
|
||||
// First reduce all whitespace as much as possible so we do not have to rely
|
||||
// on potentially slow regexes like \s*. This is then stored and used for
|
||||
// future error messages as well.
|
||||
this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')
|
||||
|
||||
// First, split on ||
|
||||
this.set = this.raw
|
||||
.split('||')
|
||||
// map the range to a 2d array of comparators
|
||||
.map(r => this.parseRange(r.trim()))
|
||||
// throw out any comparator lists that are empty
|
||||
// this generally means that it was not a valid range, which is allowed
|
||||
// in loose mode, but will still throw if the WHOLE range is invalid.
|
||||
.filter(c => c.length)
|
||||
|
||||
if (!this.set.length) {
|
||||
throw new TypeError(`Invalid SemVer Range: ${this.raw}`)
|
||||
}
|
||||
|
||||
// if we have any that are not the null set, throw out null sets.
|
||||
if (this.set.length > 1) {
|
||||
// keep the first one, in case they're all null sets
|
||||
const first = this.set[0]
|
||||
this.set = this.set.filter(c => !isNullSet(c[0]))
|
||||
if (this.set.length === 0) {
|
||||
this.set = [first]
|
||||
} else if (this.set.length > 1) {
|
||||
// if we have any that are *, then the range is just *
|
||||
for (const c of this.set) {
|
||||
if (c.length === 1 && isAny(c[0])) {
|
||||
this.set = [c]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.formatted = undefined
|
||||
}
|
||||
|
||||
get range () {
|
||||
if (this.formatted === undefined) {
|
||||
this.formatted = ''
|
||||
for (let i = 0; i < this.set.length; i++) {
|
||||
if (i > 0) {
|
||||
this.formatted += '||'
|
||||
}
|
||||
const comps = this.set[i]
|
||||
for (let k = 0; k < comps.length; k++) {
|
||||
if (k > 0) {
|
||||
this.formatted += ' '
|
||||
}
|
||||
this.formatted += comps[k].toString().trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.formatted
|
||||
}
|
||||
|
||||
format () {
|
||||
return this.range
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.range
|
||||
}
|
||||
|
||||
parseRange (range) {
|
||||
// memoize range parsing for performance.
|
||||
// this is a very hot path, and fully deterministic.
|
||||
const memoOpts =
|
||||
(this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |
|
||||
(this.options.loose && FLAG_LOOSE)
|
||||
const memoKey = memoOpts + ':' + range
|
||||
const cached = cache.get(memoKey)
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const loose = this.options.loose
|
||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
||||
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
||||
debug('hyphen replace', range)
|
||||
|
||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||
debug('comparator trim', range)
|
||||
|
||||
// `~ 1.2.3` => `~1.2.3`
|
||||
range = range.replace(re[t.TILDETRIM], tildeTrimReplace)
|
||||
debug('tilde trim', range)
|
||||
|
||||
// `^ 1.2.3` => `^1.2.3`
|
||||
range = range.replace(re[t.CARETTRIM], caretTrimReplace)
|
||||
debug('caret trim', range)
|
||||
|
||||
// At this point, the range is completely trimmed and
|
||||
// ready to be split into comparators.
|
||||
|
||||
let rangeList = range
|
||||
.split(' ')
|
||||
.map(comp => parseComparator(comp, this.options))
|
||||
.join(' ')
|
||||
.split(/\s+/)
|
||||
// >=0.0.0 is equivalent to *
|
||||
.map(comp => replaceGTE0(comp, this.options))
|
||||
|
||||
if (loose) {
|
||||
// in loose mode, throw out any that are not valid comparators
|
||||
rangeList = rangeList.filter(comp => {
|
||||
debug('loose invalid filter', comp, this.options)
|
||||
return !!comp.match(re[t.COMPARATORLOOSE])
|
||||
})
|
||||
}
|
||||
debug('range list', rangeList)
|
||||
|
||||
// if any comparators are the null set, then replace with JUST null set
|
||||
// if more than one comparator, remove any * comparators
|
||||
// also, don't include the same comparator more than once
|
||||
const rangeMap = new Map()
|
||||
const comparators = rangeList.map(comp => new Comparator(comp, this.options))
|
||||
for (const comp of comparators) {
|
||||
if (isNullSet(comp)) {
|
||||
return [comp]
|
||||
}
|
||||
rangeMap.set(comp.value, comp)
|
||||
}
|
||||
if (rangeMap.size > 1 && rangeMap.has('')) {
|
||||
rangeMap.delete('')
|
||||
}
|
||||
|
||||
const result = [...rangeMap.values()]
|
||||
cache.set(memoKey, result)
|
||||
return result
|
||||
}
|
||||
|
||||
intersects (range, options) {
|
||||
if (!(range instanceof Range)) {
|
||||
throw new TypeError('a Range is required')
|
||||
}
|
||||
|
||||
return this.set.some((thisComparators) => {
|
||||
return (
|
||||
isSatisfiable(thisComparators, options) &&
|
||||
range.set.some((rangeComparators) => {
|
||||
return (
|
||||
isSatisfiable(rangeComparators, options) &&
|
||||
thisComparators.every((thisComparator) => {
|
||||
return rangeComparators.every((rangeComparator) => {
|
||||
return thisComparator.intersects(rangeComparator, options)
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// if ANY of the sets match ALL of its comparators, then pass
|
||||
test (version) {
|
||||
if (!version) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (typeof version === 'string') {
|
||||
try {
|
||||
version = new SemVer(version, this.options)
|
||||
} catch (er) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.set.length; i++) {
|
||||
if (testSet(this.set[i], version, this.options)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Range
|
||||
|
||||
const LRU = require('../internal/lrucache')
|
||||
const cache = new LRU()
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const Comparator = require('./comparator')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
const {
|
||||
safeRe: re,
|
||||
t,
|
||||
comparatorTrimReplace,
|
||||
tildeTrimReplace,
|
||||
caretTrimReplace,
|
||||
} = require('../internal/re')
|
||||
const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')
|
||||
|
||||
const isNullSet = c => c.value === '<0.0.0-0'
|
||||
const isAny = c => c.value === ''
|
||||
|
||||
// take a set of comparators and determine whether there
|
||||
// exists a version which can satisfy it
|
||||
const isSatisfiable = (comparators, options) => {
|
||||
let result = true
|
||||
const remainingComparators = comparators.slice()
|
||||
let testComparator = remainingComparators.pop()
|
||||
|
||||
while (result && remainingComparators.length) {
|
||||
result = remainingComparators.every((otherComparator) => {
|
||||
return testComparator.intersects(otherComparator, options)
|
||||
})
|
||||
|
||||
testComparator = remainingComparators.pop()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
||||
// already replaced the hyphen ranges
|
||||
// turn into a set of JUST comparators.
|
||||
const parseComparator = (comp, options) => {
|
||||
comp = comp.replace(re[t.BUILD], '')
|
||||
debug('comp', comp, options)
|
||||
comp = replaceCarets(comp, options)
|
||||
debug('caret', comp)
|
||||
comp = replaceTildes(comp, options)
|
||||
debug('tildes', comp)
|
||||
comp = replaceXRanges(comp, options)
|
||||
debug('xrange', comp)
|
||||
comp = replaceStars(comp, options)
|
||||
debug('stars', comp)
|
||||
return comp
|
||||
}
|
||||
|
||||
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
||||
|
||||
// ~, ~> --> * (any, kinda silly)
|
||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
||||
// ~0.0.1 --> >=0.0.1 <0.1.0-0
|
||||
const replaceTildes = (comp, options) => {
|
||||
return comp
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceTilde(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceTilde = (comp, options) => {
|
||||
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('tilde', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
// ~1.2 == >=1.2.0 <1.3.0-0
|
||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
|
||||
} else if (pr) {
|
||||
debug('replaceTilde pr', pr)
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('tilde return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// ^ --> * (any, kinda silly)
|
||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
||||
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
||||
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
||||
// ^0.0.1 --> >=0.0.1 <0.0.2-0
|
||||
// ^0.1.0 --> >=0.1.0 <0.2.0-0
|
||||
const replaceCarets = (comp, options) => {
|
||||
return comp
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceCaret(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceCaret = (comp, options) => {
|
||||
debug('caret', comp, options)
|
||||
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||
const z = options.includePrerelease ? '-0' : ''
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('caret', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
if (M === '0') {
|
||||
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else if (pr) {
|
||||
debug('replaceCaret pr', pr)
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else {
|
||||
debug('no pr')
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p
|
||||
}${z} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
}${z} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
}
|
||||
|
||||
debug('caret return', ret)
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
const replaceXRanges = (comp, options) => {
|
||||
debug('replaceXRanges', comp, options)
|
||||
return comp
|
||||
.split(/\s+/)
|
||||
.map((c) => replaceXRange(c, options))
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
const replaceXRange = (comp, options) => {
|
||||
comp = comp.trim()
|
||||
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]
|
||||
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
||||
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
||||
const xM = isX(M)
|
||||
const xm = xM || isX(m)
|
||||
const xp = xm || isX(p)
|
||||
const anyX = xp
|
||||
|
||||
if (gtlt === '=' && anyX) {
|
||||
gtlt = ''
|
||||
}
|
||||
|
||||
// if we're including prereleases in the match, then we need
|
||||
// to fix this to -0, the lowest possible prerelease value
|
||||
pr = options.includePrerelease ? '-0' : ''
|
||||
|
||||
if (xM) {
|
||||
if (gtlt === '>' || gtlt === '<') {
|
||||
// nothing is allowed
|
||||
ret = '<0.0.0-0'
|
||||
} else {
|
||||
// nothing is forbidden
|
||||
ret = '*'
|
||||
}
|
||||
} else if (gtlt && anyX) {
|
||||
// we know patch is an x, because we have any x at all.
|
||||
// replace X with 0
|
||||
if (xm) {
|
||||
m = 0
|
||||
}
|
||||
p = 0
|
||||
|
||||
if (gtlt === '>') {
|
||||
// >1 => >=2.0.0
|
||||
// >1.2 => >=1.3.0
|
||||
gtlt = '>='
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
m = 0
|
||||
p = 0
|
||||
} else {
|
||||
m = +m + 1
|
||||
p = 0
|
||||
}
|
||||
} else if (gtlt === '<=') {
|
||||
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
||||
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
||||
gtlt = '<'
|
||||
if (xm) {
|
||||
M = +M + 1
|
||||
} else {
|
||||
m = +m + 1
|
||||
}
|
||||
}
|
||||
|
||||
if (gtlt === '<') {
|
||||
pr = '-0'
|
||||
}
|
||||
|
||||
ret = `${gtlt + M}.${m}.${p}${pr}`
|
||||
} else if (xm) {
|
||||
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
|
||||
} else if (xp) {
|
||||
ret = `>=${M}.${m}.0${pr
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('xRange return', ret)
|
||||
|
||||
return ret
|
||||
})
|
||||
}
|
||||
|
||||
// Because * is AND-ed with everything else in the comparator,
|
||||
// and '' means "any version", just remove the *s entirely.
|
||||
const replaceStars = (comp, options) => {
|
||||
debug('replaceStars', comp, options)
|
||||
// Looseness is ignored here. star is always as loose as it gets!
|
||||
return comp
|
||||
.trim()
|
||||
.replace(re[t.STAR], '')
|
||||
}
|
||||
|
||||
const replaceGTE0 = (comp, options) => {
|
||||
debug('replaceGTE0', comp, options)
|
||||
return comp
|
||||
.trim()
|
||||
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
||||
}
|
||||
|
||||
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||
// M, m, patch, prerelease, build
|
||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
||||
// TODO build?
|
||||
const hyphenReplace = incPr => ($0,
|
||||
from, fM, fm, fp, fpr, fb,
|
||||
to, tM, tm, tp, tpr) => {
|
||||
if (isX(fM)) {
|
||||
from = ''
|
||||
} else if (isX(fm)) {
|
||||
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
|
||||
} else if (isX(fp)) {
|
||||
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
|
||||
} else if (fpr) {
|
||||
from = `>=${from}`
|
||||
} else {
|
||||
from = `>=${from}${incPr ? '-0' : ''}`
|
||||
}
|
||||
|
||||
if (isX(tM)) {
|
||||
to = ''
|
||||
} else if (isX(tm)) {
|
||||
to = `<${+tM + 1}.0.0-0`
|
||||
} else if (isX(tp)) {
|
||||
to = `<${tM}.${+tm + 1}.0-0`
|
||||
} else if (tpr) {
|
||||
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
||||
} else if (incPr) {
|
||||
to = `<${tM}.${tm}.${+tp + 1}-0`
|
||||
} else {
|
||||
to = `<=${to}`
|
||||
}
|
||||
|
||||
return `${from} ${to}`.trim()
|
||||
}
|
||||
|
||||
const testSet = (set, version, options) => {
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
if (!set[i].test(version)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (version.prerelease.length && !options.includePrerelease) {
|
||||
// Find the set of versions that are allowed to have prereleases
|
||||
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
||||
// That should allow `1.2.3-pr.2` to pass.
|
||||
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
||||
// even though it's within the range set by the comparators.
|
||||
for (let i = 0; i < set.length; i++) {
|
||||
debug(set[i].semver)
|
||||
if (set[i].semver === Comparator.ANY) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (set[i].semver.prerelease.length > 0) {
|
||||
const allowed = set[i].semver
|
||||
if (allowed.major === version.major &&
|
||||
allowed.minor === version.minor &&
|
||||
allowed.patch === version.patch) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Version has a -pre, but it's not one of the ones we like.
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
333
node_modules/ts-jest/node_modules/semver/classes/semver.js
generated
vendored
Normal file
333
node_modules/ts-jest/node_modules/semver/classes/semver.js
generated
vendored
Normal file
@@ -0,0 +1,333 @@
|
||||
'use strict'
|
||||
|
||||
const debug = require('../internal/debug')
|
||||
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const { compareIdentifiers } = require('../internal/identifiers')
|
||||
class SemVer {
|
||||
constructor (version, options) {
|
||||
options = parseOptions(options)
|
||||
|
||||
if (version instanceof SemVer) {
|
||||
if (version.loose === !!options.loose &&
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
return version
|
||||
} else {
|
||||
version = version.version
|
||||
}
|
||||
} else if (typeof version !== 'string') {
|
||||
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
||||
}
|
||||
|
||||
if (version.length > MAX_LENGTH) {
|
||||
throw new TypeError(
|
||||
`version is longer than ${MAX_LENGTH} characters`
|
||||
)
|
||||
}
|
||||
|
||||
debug('SemVer', version, options)
|
||||
this.options = options
|
||||
this.loose = !!options.loose
|
||||
// this isn't actually relevant for versions, but keep it so that we
|
||||
// don't run into trouble passing this.options around.
|
||||
this.includePrerelease = !!options.includePrerelease
|
||||
|
||||
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError(`Invalid Version: ${version}`)
|
||||
}
|
||||
|
||||
this.raw = version
|
||||
|
||||
// these are actually numbers
|
||||
this.major = +m[1]
|
||||
this.minor = +m[2]
|
||||
this.patch = +m[3]
|
||||
|
||||
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
||||
throw new TypeError('Invalid major version')
|
||||
}
|
||||
|
||||
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
||||
throw new TypeError('Invalid minor version')
|
||||
}
|
||||
|
||||
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
||||
throw new TypeError('Invalid patch version')
|
||||
}
|
||||
|
||||
// numberify any prerelease numeric ids
|
||||
if (!m[4]) {
|
||||
this.prerelease = []
|
||||
} else {
|
||||
this.prerelease = m[4].split('.').map((id) => {
|
||||
if (/^[0-9]+$/.test(id)) {
|
||||
const num = +id
|
||||
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
||||
return num
|
||||
}
|
||||
}
|
||||
return id
|
||||
})
|
||||
}
|
||||
|
||||
this.build = m[5] ? m[5].split('.') : []
|
||||
this.format()
|
||||
}
|
||||
|
||||
format () {
|
||||
this.version = `${this.major}.${this.minor}.${this.patch}`
|
||||
if (this.prerelease.length) {
|
||||
this.version += `-${this.prerelease.join('.')}`
|
||||
}
|
||||
return this.version
|
||||
}
|
||||
|
||||
toString () {
|
||||
return this.version
|
||||
}
|
||||
|
||||
compare (other) {
|
||||
debug('SemVer.compare', this.version, this.options, other)
|
||||
if (!(other instanceof SemVer)) {
|
||||
if (typeof other === 'string' && other === this.version) {
|
||||
return 0
|
||||
}
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
if (other.version === this.version) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return this.compareMain(other) || this.comparePre(other)
|
||||
}
|
||||
|
||||
compareMain (other) {
|
||||
if (!(other instanceof SemVer)) {
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
if (this.major < other.major) {
|
||||
return -1
|
||||
}
|
||||
if (this.major > other.major) {
|
||||
return 1
|
||||
}
|
||||
if (this.minor < other.minor) {
|
||||
return -1
|
||||
}
|
||||
if (this.minor > other.minor) {
|
||||
return 1
|
||||
}
|
||||
if (this.patch < other.patch) {
|
||||
return -1
|
||||
}
|
||||
if (this.patch > other.patch) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
comparePre (other) {
|
||||
if (!(other instanceof SemVer)) {
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
// NOT having a prerelease is > having one
|
||||
if (this.prerelease.length && !other.prerelease.length) {
|
||||
return -1
|
||||
} else if (!this.prerelease.length && other.prerelease.length) {
|
||||
return 1
|
||||
} else if (!this.prerelease.length && !other.prerelease.length) {
|
||||
return 0
|
||||
}
|
||||
|
||||
let i = 0
|
||||
do {
|
||||
const a = this.prerelease[i]
|
||||
const b = other.prerelease[i]
|
||||
debug('prerelease compare', i, a, b)
|
||||
if (a === undefined && b === undefined) {
|
||||
return 0
|
||||
} else if (b === undefined) {
|
||||
return 1
|
||||
} else if (a === undefined) {
|
||||
return -1
|
||||
} else if (a === b) {
|
||||
continue
|
||||
} else {
|
||||
return compareIdentifiers(a, b)
|
||||
}
|
||||
} while (++i)
|
||||
}
|
||||
|
||||
compareBuild (other) {
|
||||
if (!(other instanceof SemVer)) {
|
||||
other = new SemVer(other, this.options)
|
||||
}
|
||||
|
||||
let i = 0
|
||||
do {
|
||||
const a = this.build[i]
|
||||
const b = other.build[i]
|
||||
debug('build compare', i, a, b)
|
||||
if (a === undefined && b === undefined) {
|
||||
return 0
|
||||
} else if (b === undefined) {
|
||||
return 1
|
||||
} else if (a === undefined) {
|
||||
return -1
|
||||
} else if (a === b) {
|
||||
continue
|
||||
} else {
|
||||
return compareIdentifiers(a, b)
|
||||
}
|
||||
} while (++i)
|
||||
}
|
||||
|
||||
// preminor will bump the version up to the next minor release, and immediately
|
||||
// down to pre-release. premajor and prepatch work the same way.
|
||||
inc (release, identifier, identifierBase) {
|
||||
if (release.startsWith('pre')) {
|
||||
if (!identifier && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier is empty')
|
||||
}
|
||||
// Avoid an invalid semver results
|
||||
if (identifier) {
|
||||
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])
|
||||
if (!match || match[1] !== identifier) {
|
||||
throw new Error(`invalid identifier: ${identifier}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (release) {
|
||||
case 'premajor':
|
||||
this.prerelease.length = 0
|
||||
this.patch = 0
|
||||
this.minor = 0
|
||||
this.major++
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
case 'preminor':
|
||||
this.prerelease.length = 0
|
||||
this.patch = 0
|
||||
this.minor++
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
case 'prepatch':
|
||||
// If this is already a prerelease, it will bump to the next version
|
||||
// drop any prereleases that might already exist, since they are not
|
||||
// relevant at this point.
|
||||
this.prerelease.length = 0
|
||||
this.inc('patch', identifier, identifierBase)
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
// If the input is a non-prerelease version, this acts the same as
|
||||
// prepatch.
|
||||
case 'prerelease':
|
||||
if (this.prerelease.length === 0) {
|
||||
this.inc('patch', identifier, identifierBase)
|
||||
}
|
||||
this.inc('pre', identifier, identifierBase)
|
||||
break
|
||||
case 'release':
|
||||
if (this.prerelease.length === 0) {
|
||||
throw new Error(`version ${this.raw} is not a prerelease`)
|
||||
}
|
||||
this.prerelease.length = 0
|
||||
break
|
||||
|
||||
case 'major':
|
||||
// If this is a pre-major version, bump up to the same major version.
|
||||
// Otherwise increment major.
|
||||
// 1.0.0-5 bumps to 1.0.0
|
||||
// 1.1.0 bumps to 2.0.0
|
||||
if (
|
||||
this.minor !== 0 ||
|
||||
this.patch !== 0 ||
|
||||
this.prerelease.length === 0
|
||||
) {
|
||||
this.major++
|
||||
}
|
||||
this.minor = 0
|
||||
this.patch = 0
|
||||
this.prerelease = []
|
||||
break
|
||||
case 'minor':
|
||||
// If this is a pre-minor version, bump up to the same minor version.
|
||||
// Otherwise increment minor.
|
||||
// 1.2.0-5 bumps to 1.2.0
|
||||
// 1.2.1 bumps to 1.3.0
|
||||
if (this.patch !== 0 || this.prerelease.length === 0) {
|
||||
this.minor++
|
||||
}
|
||||
this.patch = 0
|
||||
this.prerelease = []
|
||||
break
|
||||
case 'patch':
|
||||
// If this is not a pre-release version, it will increment the patch.
|
||||
// If it is a pre-release it will bump up to the same patch version.
|
||||
// 1.2.0-5 patches to 1.2.0
|
||||
// 1.2.0 patches to 1.2.1
|
||||
if (this.prerelease.length === 0) {
|
||||
this.patch++
|
||||
}
|
||||
this.prerelease = []
|
||||
break
|
||||
// This probably shouldn't be used publicly.
|
||||
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
||||
case 'pre': {
|
||||
const base = Number(identifierBase) ? 1 : 0
|
||||
|
||||
if (this.prerelease.length === 0) {
|
||||
this.prerelease = [base]
|
||||
} else {
|
||||
let i = this.prerelease.length
|
||||
while (--i >= 0) {
|
||||
if (typeof this.prerelease[i] === 'number') {
|
||||
this.prerelease[i]++
|
||||
i = -2
|
||||
}
|
||||
}
|
||||
if (i === -1) {
|
||||
// didn't increment anything
|
||||
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
||||
throw new Error('invalid increment argument: identifier already exists')
|
||||
}
|
||||
this.prerelease.push(base)
|
||||
}
|
||||
}
|
||||
if (identifier) {
|
||||
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
||||
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
||||
let prerelease = [identifier, base]
|
||||
if (identifierBase === false) {
|
||||
prerelease = [identifier]
|
||||
}
|
||||
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
||||
if (isNaN(this.prerelease[1])) {
|
||||
this.prerelease = prerelease
|
||||
}
|
||||
} else {
|
||||
this.prerelease = prerelease
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
default:
|
||||
throw new Error(`invalid increment argument: ${release}`)
|
||||
}
|
||||
this.raw = this.format()
|
||||
if (this.build.length) {
|
||||
this.raw += `+${this.build.join('.')}`
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SemVer
|
||||
8
node_modules/ts-jest/node_modules/semver/functions/clean.js
generated
vendored
Normal file
8
node_modules/ts-jest/node_modules/semver/functions/clean.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse')
|
||||
const clean = (version, options) => {
|
||||
const s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
||||
return s ? s.version : null
|
||||
}
|
||||
module.exports = clean
|
||||
54
node_modules/ts-jest/node_modules/semver/functions/cmp.js
generated
vendored
Normal file
54
node_modules/ts-jest/node_modules/semver/functions/cmp.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict'
|
||||
|
||||
const eq = require('./eq')
|
||||
const neq = require('./neq')
|
||||
const gt = require('./gt')
|
||||
const gte = require('./gte')
|
||||
const lt = require('./lt')
|
||||
const lte = require('./lte')
|
||||
|
||||
const cmp = (a, op, b, loose) => {
|
||||
switch (op) {
|
||||
case '===':
|
||||
if (typeof a === 'object') {
|
||||
a = a.version
|
||||
}
|
||||
if (typeof b === 'object') {
|
||||
b = b.version
|
||||
}
|
||||
return a === b
|
||||
|
||||
case '!==':
|
||||
if (typeof a === 'object') {
|
||||
a = a.version
|
||||
}
|
||||
if (typeof b === 'object') {
|
||||
b = b.version
|
||||
}
|
||||
return a !== b
|
||||
|
||||
case '':
|
||||
case '=':
|
||||
case '==':
|
||||
return eq(a, b, loose)
|
||||
|
||||
case '!=':
|
||||
return neq(a, b, loose)
|
||||
|
||||
case '>':
|
||||
return gt(a, b, loose)
|
||||
|
||||
case '>=':
|
||||
return gte(a, b, loose)
|
||||
|
||||
case '<':
|
||||
return lt(a, b, loose)
|
||||
|
||||
case '<=':
|
||||
return lte(a, b, loose)
|
||||
|
||||
default:
|
||||
throw new TypeError(`Invalid operator: ${op}`)
|
||||
}
|
||||
}
|
||||
module.exports = cmp
|
||||
62
node_modules/ts-jest/node_modules/semver/functions/coerce.js
generated
vendored
Normal file
62
node_modules/ts-jest/node_modules/semver/functions/coerce.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const parse = require('./parse')
|
||||
const { safeRe: re, t } = require('../internal/re')
|
||||
|
||||
const coerce = (version, options) => {
|
||||
if (version instanceof SemVer) {
|
||||
return version
|
||||
}
|
||||
|
||||
if (typeof version === 'number') {
|
||||
version = String(version)
|
||||
}
|
||||
|
||||
if (typeof version !== 'string') {
|
||||
return null
|
||||
}
|
||||
|
||||
options = options || {}
|
||||
|
||||
let match = null
|
||||
if (!options.rtl) {
|
||||
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])
|
||||
} else {
|
||||
// Find the right-most coercible string that does not share
|
||||
// a terminus with a more left-ward coercible string.
|
||||
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
||||
// With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'
|
||||
//
|
||||
// Walk through the string checking with a /g regexp
|
||||
// Manually set the index so as to pick up overlapping matches.
|
||||
// Stop when we get a match that ends at the string end, since no
|
||||
// coercible string can be more right-ward without the same terminus.
|
||||
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]
|
||||
let next
|
||||
while ((next = coerceRtlRegex.exec(version)) &&
|
||||
(!match || match.index + match[0].length !== version.length)
|
||||
) {
|
||||
if (!match ||
|
||||
next.index + next[0].length !== match.index + match[0].length) {
|
||||
match = next
|
||||
}
|
||||
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length
|
||||
}
|
||||
// leave it in a clean state
|
||||
coerceRtlRegex.lastIndex = -1
|
||||
}
|
||||
|
||||
if (match === null) {
|
||||
return null
|
||||
}
|
||||
|
||||
const major = match[2]
|
||||
const minor = match[3] || '0'
|
||||
const patch = match[4] || '0'
|
||||
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''
|
||||
const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''
|
||||
|
||||
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)
|
||||
}
|
||||
module.exports = coerce
|
||||
9
node_modules/ts-jest/node_modules/semver/functions/compare-build.js
generated
vendored
Normal file
9
node_modules/ts-jest/node_modules/semver/functions/compare-build.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const compareBuild = (a, b, loose) => {
|
||||
const versionA = new SemVer(a, loose)
|
||||
const versionB = new SemVer(b, loose)
|
||||
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
||||
}
|
||||
module.exports = compareBuild
|
||||
5
node_modules/ts-jest/node_modules/semver/functions/compare-loose.js
generated
vendored
Normal file
5
node_modules/ts-jest/node_modules/semver/functions/compare-loose.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const compareLoose = (a, b) => compare(a, b, true)
|
||||
module.exports = compareLoose
|
||||
7
node_modules/ts-jest/node_modules/semver/functions/compare.js
generated
vendored
Normal file
7
node_modules/ts-jest/node_modules/semver/functions/compare.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const SemVer = require('../classes/semver')
|
||||
const compare = (a, b, loose) =>
|
||||
new SemVer(a, loose).compare(new SemVer(b, loose))
|
||||
|
||||
module.exports = compare
|
||||
60
node_modules/ts-jest/node_modules/semver/functions/diff.js
generated
vendored
Normal file
60
node_modules/ts-jest/node_modules/semver/functions/diff.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict'
|
||||
|
||||
const parse = require('./parse.js')
|
||||
|
||||
const diff = (version1, version2) => {
|
||||
const v1 = parse(version1, null, true)
|
||||
const v2 = parse(version2, null, true)
|
||||
const comparison = v1.compare(v2)
|
||||
|
||||
if (comparison === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
const v1Higher = comparison > 0
|
||||
const highVersion = v1Higher ? v1 : v2
|
||||
const lowVersion = v1Higher ? v2 : v1
|
||||
const highHasPre = !!highVersion.prerelease.length
|
||||
const lowHasPre = !!lowVersion.prerelease.length
|
||||
|
||||
if (lowHasPre && !highHasPre) {
|
||||
// Going from prerelease -> no prerelease requires some special casing
|
||||
|
||||
// If the low version has only a major, then it will always be a major
|
||||
// Some examples:
|
||||
// 1.0.0-1 -> 1.0.0
|
||||
// 1.0.0-1 -> 1.1.1
|
||||
// 1.0.0-1 -> 2.0.0
|
||||
if (!lowVersion.patch && !lowVersion.minor) {
|
||||
return 'major'
|
||||
}
|
||||
|
||||
// If the main part has no difference
|
||||
if (lowVersion.compareMain(highVersion) === 0) {
|
||||
if (lowVersion.minor && !lowVersion.patch) {
|
||||
return 'minor'
|
||||
}
|
||||
return 'patch'
|
||||
}
|
||||
}
|
||||
|
||||
// add the `pre` prefix if we are going to a prerelease version
|
||||
const prefix = highHasPre ? 'pre' : ''
|
||||
|
||||
if (v1.major !== v2.major) {
|
||||
return prefix + 'major'
|
||||
}
|
||||
|
||||
if (v1.minor !== v2.minor) {
|
||||
return prefix + 'minor'
|
||||
}
|
||||
|
||||
if (v1.patch !== v2.patch) {
|
||||
return prefix + 'patch'
|
||||
}
|
||||
|
||||
// high and low are prereleases
|
||||
return 'prerelease'
|
||||
}
|
||||
|
||||
module.exports = diff
|
||||
5
node_modules/ts-jest/node_modules/semver/functions/eq.js
generated
vendored
Normal file
5
node_modules/ts-jest/node_modules/semver/functions/eq.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const eq = (a, b, loose) => compare(a, b, loose) === 0
|
||||
module.exports = eq
|
||||
5
node_modules/ts-jest/node_modules/semver/functions/gt.js
generated
vendored
Normal file
5
node_modules/ts-jest/node_modules/semver/functions/gt.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const gt = (a, b, loose) => compare(a, b, loose) > 0
|
||||
module.exports = gt
|
||||
5
node_modules/ts-jest/node_modules/semver/functions/gte.js
generated
vendored
Normal file
5
node_modules/ts-jest/node_modules/semver/functions/gte.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const compare = require('./compare')
|
||||
const gte = (a, b, loose) => compare(a, b, loose) >= 0
|
||||
module.exports = gte
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user