This commit is contained in:
parent
7a9bf3199a
commit
c294e2e9ae
5702 changed files with 465039 additions and 34 deletions
22
node_modules/jest-validate/LICENSE
generated
vendored
Normal file
22
node_modules/jest-validate/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
Copyright Contributors to the Jest project.
|
||||
|
||||
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.
|
||||
216
node_modules/jest-validate/README.md
generated
vendored
Normal file
216
node_modules/jest-validate/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
# jest-validate
|
||||
|
||||
Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration.
|
||||
|
||||
```bash
|
||||
npm install --save jest-validate
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import {validate} from 'jest-validate';
|
||||
|
||||
validate(config, validationOptions); // => {hasDeprecationWarnings: boolean, isValid: boolean}
|
||||
```
|
||||
|
||||
Where `ValidationOptions` are:
|
||||
|
||||
```ts
|
||||
type ValidationOptions = {
|
||||
comment?: string;
|
||||
condition?: (option: unknown, validOption: unknown) => boolean;
|
||||
deprecate?: (
|
||||
config: Record<string, unknown>,
|
||||
option: string,
|
||||
deprecatedOptions: DeprecatedOptions,
|
||||
options: ValidationOptions,
|
||||
) => boolean;
|
||||
deprecatedConfig?: DeprecatedOptions;
|
||||
error?: (
|
||||
option: string,
|
||||
received: unknown,
|
||||
defaultValue: unknown,
|
||||
options: ValidationOptions,
|
||||
path?: Array<string>,
|
||||
) => void;
|
||||
exampleConfig: Record<string, unknown>;
|
||||
recursive?: boolean;
|
||||
recursiveBlacklist?: Array<string>;
|
||||
recursiveDenylist?: Array<string>;
|
||||
title?: Title;
|
||||
unknown?: (
|
||||
config: Record<string, unknown>,
|
||||
exampleConfig: Record<string, unknown>,
|
||||
option: string,
|
||||
options: ValidationOptions,
|
||||
path?: Array<string>,
|
||||
) => void;
|
||||
};
|
||||
|
||||
type Title = {
|
||||
deprecation?: string;
|
||||
error?: string;
|
||||
warning?: string;
|
||||
};
|
||||
```
|
||||
|
||||
`exampleConfig` is the only option required.
|
||||
|
||||
## API
|
||||
|
||||
By default `jest-validate` will print generic warning and error messages. You can however customize this behavior by providing `options: ValidationOptions` object as a second argument:
|
||||
|
||||
Almost anything can be overwritten to suite your needs.
|
||||
|
||||
### Options
|
||||
|
||||
- `recursiveDenylist` – optional array of string keyPaths that should be excluded from deep (recursive) validation.
|
||||
- `comment` – optional string to be rendered below error/warning message.
|
||||
- `condition` – an optional function with validation condition.
|
||||
- `deprecate`, `error`, `unknown` – optional functions responsible for displaying warning and error messages.
|
||||
- `deprecatedConfig` – optional object with deprecated config keys.
|
||||
- `exampleConfig` – the only **required** option with configuration against which you'd like to test.
|
||||
- `recursive` - optional boolean determining whether recursively compare `exampleConfig` to `config` (default: `true`).
|
||||
- `title` – optional object of titles for errors and messages.
|
||||
|
||||
You will find examples of `condition`, `deprecate`, `error`, `unknown`, and `deprecatedConfig` inside source of this repository, named respectively.
|
||||
|
||||
## exampleConfig syntax
|
||||
|
||||
`exampleConfig` should be an object with key/value pairs that contain an example of a valid value for each key. A configuration value is considered valid when:
|
||||
|
||||
- it matches the JavaScript type of the example value, e.g. `string`, `number`, `array`, `boolean`, `function`, or `object`
|
||||
- it is `null` or `undefined`
|
||||
- it matches the Javascript type of any of arguments passed to `MultipleValidOptions(...)`
|
||||
|
||||
The last condition is a special syntax that allows validating where more than one type is permissible; see example below. It's acceptable to have multiple values of the same type in the example, so you can also use this syntax to provide more than one example. When a validation failure occurs, the error message will show all other values in the array as examples.
|
||||
|
||||
## Examples
|
||||
|
||||
Minimal example:
|
||||
|
||||
```js
|
||||
validate(config, {exampleConfig});
|
||||
```
|
||||
|
||||
Example with slight modifications:
|
||||
|
||||
```js
|
||||
validate(config, {
|
||||
comment: ' Documentation: http://custom-docs.com',
|
||||
deprecatedConfig,
|
||||
exampleConfig,
|
||||
title: {
|
||||
deprecation: 'Custom Deprecation',
|
||||
// leaving 'error' and 'warning' as default
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
This will output:
|
||||
|
||||
#### Warning:
|
||||
|
||||
```bash
|
||||
● Validation Warning:
|
||||
|
||||
Unknown option transformx with value "<rootDir>/node_modules/babel-jest" was found.
|
||||
This is either a typing error or a user mistake. Fixing it will remove this message.
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
#### Error:
|
||||
|
||||
```bash
|
||||
● Validation Error:
|
||||
|
||||
Option transform must be of type:
|
||||
object
|
||||
but instead received:
|
||||
string
|
||||
|
||||
Example:
|
||||
{
|
||||
"transform": {
|
||||
"\\.js$": "<rootDir>/preprocessor.js"
|
||||
}
|
||||
}
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
## Example validating multiple types
|
||||
|
||||
```js
|
||||
import {multipleValidOptions} from 'jest-validate';
|
||||
|
||||
validate(config, {
|
||||
// `bar` will accept either a string or a number
|
||||
bar: multipleValidOptions('string is ok', 2),
|
||||
});
|
||||
```
|
||||
|
||||
#### Error:
|
||||
|
||||
```bash
|
||||
● Validation Error:
|
||||
|
||||
Option foo must be of type:
|
||||
string or number
|
||||
but instead received:
|
||||
array
|
||||
|
||||
Example:
|
||||
{
|
||||
"bar": "string is ok"
|
||||
}
|
||||
|
||||
or
|
||||
|
||||
{
|
||||
"bar": 2
|
||||
}
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
#### Deprecation
|
||||
|
||||
Based on `deprecatedConfig` object with proper deprecation messages. Note custom title:
|
||||
|
||||
```bash
|
||||
Custom Deprecation:
|
||||
|
||||
Option scriptPreprocessor was replaced by transform, which support multiple preprocessors.
|
||||
|
||||
Jest now treats your current configuration as:
|
||||
{
|
||||
"transform": {".*": "xxx"}
|
||||
}
|
||||
|
||||
Please update your configuration.
|
||||
|
||||
Documentation: http://custom-docs.com
|
||||
```
|
||||
|
||||
## Example validating CLI arguments
|
||||
|
||||
```js
|
||||
import {validate} from 'jest-validate';
|
||||
|
||||
validateCLIOptions(argv, {...allowedOptions, deprecatedOptions});
|
||||
```
|
||||
|
||||
If `argv` contains a deprecated option that is not specified in `allowedOptions`, `validateCLIOptions` will throw an error with the message specified in the `deprecatedOptions` config:
|
||||
|
||||
```bash
|
||||
● collectCoverageOnlyFrom:
|
||||
|
||||
Option "collectCoverageOnlyFrom" was replaced by "collectCoverageFrom"
|
||||
|
||||
CLI Options Documentation: https://jestjs.io/docs/en/cli.html
|
||||
```
|
||||
|
||||
If the deprecation option is still listed in the `allowedOptions` config, then `validateCLIOptions` will print the warning without throwing an error.
|
||||
90
node_modules/jest-validate/build/index.d.ts
generated
vendored
Normal file
90
node_modules/jest-validate/build/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {Options} from 'yargs';
|
||||
import {Config} from '@jest/types';
|
||||
|
||||
export declare const createDidYouMeanMessage: (
|
||||
unrecognized: string,
|
||||
allowedOptions: Array<string>,
|
||||
) => string;
|
||||
|
||||
declare type DeprecatedOptionFunc = (arg: Record<string, unknown>) => string;
|
||||
|
||||
export declare type DeprecatedOptions = Record<string, DeprecatedOptionFunc>;
|
||||
|
||||
export declare const format: (value: unknown) => string;
|
||||
|
||||
export declare const logValidationWarning: (
|
||||
name: string,
|
||||
message: string,
|
||||
comment?: string | null,
|
||||
) => void;
|
||||
|
||||
export declare function multipleValidOptions<T extends Array<unknown>>(
|
||||
...args: T
|
||||
): T[number];
|
||||
|
||||
declare type Title = {
|
||||
deprecation?: string;
|
||||
error?: string;
|
||||
warning?: string;
|
||||
};
|
||||
|
||||
export declare const validate: (
|
||||
config: Record<string, unknown>,
|
||||
options: ValidationOptions,
|
||||
) => {
|
||||
hasDeprecationWarnings: boolean;
|
||||
isValid: boolean;
|
||||
};
|
||||
|
||||
export declare function validateCLIOptions(
|
||||
argv: Config.Argv,
|
||||
options?: Record<string, Options> & {
|
||||
deprecationEntries?: DeprecatedOptions;
|
||||
},
|
||||
rawArgv?: Array<string>,
|
||||
): boolean;
|
||||
|
||||
export declare class ValidationError extends Error {
|
||||
name: string;
|
||||
message: string;
|
||||
constructor(name: string, message: string, comment?: string | null);
|
||||
}
|
||||
|
||||
declare type ValidationOptions = {
|
||||
comment?: string;
|
||||
condition?: (option: unknown, validOption: unknown) => boolean;
|
||||
deprecate?: (
|
||||
config: Record<string, unknown>,
|
||||
option: string,
|
||||
deprecatedOptions: DeprecatedOptions,
|
||||
options: ValidationOptions,
|
||||
) => boolean;
|
||||
deprecatedConfig?: DeprecatedOptions;
|
||||
error?: (
|
||||
option: string,
|
||||
received: unknown,
|
||||
defaultValue: unknown,
|
||||
options: ValidationOptions,
|
||||
path?: Array<string>,
|
||||
) => void;
|
||||
exampleConfig: Record<string, unknown>;
|
||||
recursive?: boolean;
|
||||
recursiveDenylist?: Array<string>;
|
||||
title?: Title;
|
||||
unknown?: (
|
||||
config: Record<string, unknown>,
|
||||
exampleConfig: Record<string, unknown>,
|
||||
option: string,
|
||||
options: ValidationOptions,
|
||||
path?: Array<string>,
|
||||
) => void;
|
||||
};
|
||||
|
||||
export {};
|
||||
567
node_modules/jest-validate/build/index.js
generated
vendored
Normal file
567
node_modules/jest-validate/build/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,567 @@
|
|||
/*!
|
||||
* /**
|
||||
* * Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* *
|
||||
* * This source code is licensed under the MIT license found in the
|
||||
* * LICENSE file in the root directory of this source tree.
|
||||
* * /
|
||||
*/
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ "./src/condition.ts"
|
||||
(__unused_webpack_module, exports) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.getValues = getValues;
|
||||
exports.multipleValidOptions = multipleValidOptions;
|
||||
exports.validationCondition = validationCondition;
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
const MULTIPLE_VALID_OPTIONS_SYMBOL = Symbol('JEST_MULTIPLE_VALID_OPTIONS');
|
||||
function validationConditionSingle(option, validOption) {
|
||||
return option === null || option === undefined || typeof option === 'function' && typeof validOption === 'function' || toString.call(option) === toString.call(validOption);
|
||||
}
|
||||
function getValues(validOption) {
|
||||
if (Array.isArray(validOption) &&
|
||||
// @ts-expect-error: no index signature
|
||||
validOption[MULTIPLE_VALID_OPTIONS_SYMBOL]) {
|
||||
return validOption;
|
||||
}
|
||||
return [validOption];
|
||||
}
|
||||
function validationCondition(option, validOption) {
|
||||
return getValues(validOption).some(e => validationConditionSingle(option, e));
|
||||
}
|
||||
function multipleValidOptions(...args) {
|
||||
const options = [...args];
|
||||
// @ts-expect-error: no index signature
|
||||
options[MULTIPLE_VALID_OPTIONS_SYMBOL] = true;
|
||||
return options;
|
||||
}
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/defaultConfig.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports["default"] = void 0;
|
||||
var _condition = __webpack_require__("./src/condition.ts");
|
||||
var _deprecated = __webpack_require__("./src/deprecated.ts");
|
||||
var _errors = __webpack_require__("./src/errors.ts");
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
var _warnings = __webpack_require__("./src/warnings.ts");
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const validationOptions = {
|
||||
comment: '',
|
||||
condition: _condition.validationCondition,
|
||||
deprecate: _deprecated.deprecationWarning,
|
||||
deprecatedConfig: {},
|
||||
error: _errors.errorMessage,
|
||||
exampleConfig: {},
|
||||
recursive: true,
|
||||
// Allow NPM-sanctioned comments in package.json. Use a "//" key.
|
||||
recursiveDenylist: ['//'],
|
||||
title: {
|
||||
deprecation: _utils.DEPRECATION,
|
||||
error: _utils.ERROR,
|
||||
warning: _utils.WARNING
|
||||
},
|
||||
unknown: _warnings.unknownOptionWarning
|
||||
};
|
||||
var _default = exports["default"] = validationOptions;
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/deprecated.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.deprecationWarning = void 0;
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const deprecationMessage = (message, options) => {
|
||||
const comment = options.comment;
|
||||
const name = options.title && options.title.deprecation || _utils.DEPRECATION;
|
||||
(0, _utils.logValidationWarning)(name, message, comment);
|
||||
};
|
||||
const deprecationWarning = (config, option, deprecatedOptions, options) => {
|
||||
if (option in deprecatedOptions) {
|
||||
deprecationMessage(deprecatedOptions[option](config), options);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.deprecationWarning = deprecationWarning;
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/errors.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.errorMessage = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _getType() {
|
||||
const data = require("@jest/get-type");
|
||||
_getType = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _condition = __webpack_require__("./src/condition.ts");
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const errorMessage = (option, received, defaultValue, options, path) => {
|
||||
const conditions = (0, _condition.getValues)(defaultValue);
|
||||
const validTypes = [...new Set(conditions.map(_getType().getType))];
|
||||
const message = ` Option ${_chalk().default.bold(`"${path && path.length > 0 ? `${path.join('.')}.` : ''}${option}"`)} must be of type:
|
||||
${validTypes.map(e => _chalk().default.bold.green(e)).join(' or ')}
|
||||
but instead received:
|
||||
${_chalk().default.bold.red((0, _getType().getType)(received))}
|
||||
|
||||
Example:
|
||||
${formatExamples(option, conditions)}`;
|
||||
const comment = options.comment;
|
||||
const name = options.title && options.title.error || _utils.ERROR;
|
||||
throw new _utils.ValidationError(name, message, comment);
|
||||
};
|
||||
exports.errorMessage = errorMessage;
|
||||
function formatExamples(option, examples) {
|
||||
return examples.map(e => ` {
|
||||
${_chalk().default.bold(`"${option}"`)}: ${_chalk().default.bold((0, _utils.formatPrettyObject)(e))}
|
||||
}`).join(`
|
||||
|
||||
or
|
||||
|
||||
`);
|
||||
}
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/utils.ts"
|
||||
(__unused_webpack_module, exports) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.logValidationWarning = exports.formatPrettyObject = exports.format = exports.createDidYouMeanMessage = exports.WARNING = exports.ValidationError = exports.ERROR = exports.DEPRECATION = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _leven() {
|
||||
const data = _interopRequireDefault(require("leven"));
|
||||
_leven = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _prettyFormat() {
|
||||
const data = require("pretty-format");
|
||||
_prettyFormat = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const BULLET = _chalk().default.bold('\u25CF');
|
||||
const DEPRECATION = exports.DEPRECATION = `${BULLET} Deprecation Warning`;
|
||||
const ERROR = exports.ERROR = `${BULLET} Validation Error`;
|
||||
const WARNING = exports.WARNING = `${BULLET} Validation Warning`;
|
||||
const format = value => typeof value === 'function' ? value.toString() : (0, _prettyFormat().format)(value, {
|
||||
min: true
|
||||
});
|
||||
exports.format = format;
|
||||
const formatPrettyObject = value => typeof value === 'function' ? value.toString() : value === undefined ? 'undefined' : JSON.stringify(value, null, 2).split('\n').join('\n ');
|
||||
exports.formatPrettyObject = formatPrettyObject;
|
||||
class ValidationError extends Error {
|
||||
name;
|
||||
message;
|
||||
constructor(name, message, comment) {
|
||||
super();
|
||||
comment = comment ? `\n\n${comment}` : '\n';
|
||||
this.name = '';
|
||||
this.message = _chalk().default.red(`${_chalk().default.bold(name)}:\n\n${message}${comment}`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
Error.captureStackTrace(this, () => {});
|
||||
}
|
||||
}
|
||||
exports.ValidationError = ValidationError;
|
||||
const logValidationWarning = (name, message, comment) => {
|
||||
comment = comment ? `\n\n${comment}` : '\n';
|
||||
console.warn(_chalk().default.yellow(`${_chalk().default.bold(name)}:\n\n${message}${comment}`));
|
||||
};
|
||||
exports.logValidationWarning = logValidationWarning;
|
||||
const createDidYouMeanMessage = (unrecognized, allowedOptions) => {
|
||||
const suggestion = allowedOptions.find(option => {
|
||||
const steps = (0, _leven().default)(option, unrecognized);
|
||||
return steps < 3;
|
||||
});
|
||||
return suggestion ? `Did you mean ${_chalk().default.bold(format(suggestion))}?` : '';
|
||||
};
|
||||
exports.createDidYouMeanMessage = createDidYouMeanMessage;
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/validate.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports["default"] = void 0;
|
||||
var _defaultConfig = _interopRequireDefault(__webpack_require__("./src/defaultConfig.ts"));
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
let hasDeprecationWarnings = false;
|
||||
const shouldSkipValidationForPath = (path, key, denylist) => denylist ? denylist.includes([...path, key].join('.')) : false;
|
||||
const _validate = (config, exampleConfig, options, path = []) => {
|
||||
if (typeof config !== 'object' || config == null || typeof exampleConfig !== 'object' || exampleConfig == null) {
|
||||
return {
|
||||
hasDeprecationWarnings
|
||||
};
|
||||
}
|
||||
for (const key in config) {
|
||||
if (options.deprecatedConfig && key in options.deprecatedConfig && typeof options.deprecate === 'function') {
|
||||
const isDeprecatedKey = options.deprecate(config, key, options.deprecatedConfig, options);
|
||||
hasDeprecationWarnings = hasDeprecationWarnings || isDeprecatedKey;
|
||||
} else if (allowsMultipleTypes(key)) {
|
||||
const value = config[key];
|
||||
if (typeof options.condition === 'function' && typeof options.error === 'function') {
|
||||
if (key === 'maxWorkers' && !isOfTypeStringOrNumber(value)) {
|
||||
throw new _utils.ValidationError('Validation Error', `${key} has to be of type string or number`, 'maxWorkers=50% or\nmaxWorkers=3');
|
||||
}
|
||||
}
|
||||
} else if (Object.hasOwnProperty.call(exampleConfig, key)) {
|
||||
if (typeof options.condition === 'function' && typeof options.error === 'function' && !options.condition(config[key], exampleConfig[key])) {
|
||||
options.error(key, config[key], exampleConfig[key], options, path);
|
||||
}
|
||||
} else if (shouldSkipValidationForPath(path, key, options.recursiveDenylist)) {
|
||||
// skip validating unknown options inside blacklisted paths
|
||||
} else {
|
||||
options.unknown?.(config, exampleConfig, key, options, path);
|
||||
}
|
||||
if (options.recursive && !Array.isArray(exampleConfig[key]) && options.recursiveDenylist && !shouldSkipValidationForPath(path, key, options.recursiveDenylist)) {
|
||||
_validate(config[key], exampleConfig[key], options, [...path, key]);
|
||||
}
|
||||
}
|
||||
return {
|
||||
hasDeprecationWarnings
|
||||
};
|
||||
};
|
||||
const allowsMultipleTypes = key => key === 'maxWorkers';
|
||||
const isOfTypeStringOrNumber = value => typeof value === 'number' || typeof value === 'string';
|
||||
const validate = (config, options) => {
|
||||
hasDeprecationWarnings = false;
|
||||
|
||||
// Preserve default denylist entries even with user-supplied denylist
|
||||
const combinedDenylist = [...(_defaultConfig.default.recursiveDenylist || []), ...(options.recursiveDenylist || [])];
|
||||
const defaultedOptions = Object.assign({
|
||||
..._defaultConfig.default,
|
||||
...options,
|
||||
recursiveDenylist: combinedDenylist,
|
||||
title: options.title || _defaultConfig.default.title
|
||||
});
|
||||
const {
|
||||
hasDeprecationWarnings: hdw
|
||||
} = _validate(config, options.exampleConfig, defaultedOptions);
|
||||
return {
|
||||
hasDeprecationWarnings: hdw,
|
||||
isValid: true
|
||||
};
|
||||
};
|
||||
var _default = exports["default"] = validate;
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/validateCLIOptions.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.DOCUMENTATION_NOTE = void 0;
|
||||
exports["default"] = validateCLIOptions;
|
||||
function _camelcase() {
|
||||
const data = _interopRequireDefault(require("camelcase"));
|
||||
_camelcase = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const BULLET = _chalk().default.bold('\u25CF');
|
||||
const DOCUMENTATION_NOTE = exports.DOCUMENTATION_NOTE = ` ${_chalk().default.bold('CLI Options Documentation:')}
|
||||
https://jestjs.io/docs/cli
|
||||
`;
|
||||
const createCLIValidationError = (unrecognizedOptions, allowedOptions) => {
|
||||
let title = `${BULLET} Unrecognized CLI Parameter`;
|
||||
let message;
|
||||
const comment = ` ${_chalk().default.bold('CLI Options Documentation')}:\n` + ' https://jestjs.io/docs/cli\n';
|
||||
if (unrecognizedOptions.length === 1) {
|
||||
const unrecognized = unrecognizedOptions[0];
|
||||
const didYouMeanMessage = unrecognized.length > 1 ? (0, _utils.createDidYouMeanMessage)(unrecognized, [...allowedOptions]) : '';
|
||||
message = ` Unrecognized option ${_chalk().default.bold((0, _utils.format)(unrecognized))}.${didYouMeanMessage ? ` ${didYouMeanMessage}` : ''}`;
|
||||
} else {
|
||||
title += 's';
|
||||
message = ' Following options were not recognized:\n' + ` ${_chalk().default.bold((0, _utils.format)(unrecognizedOptions))}`;
|
||||
}
|
||||
return new _utils.ValidationError(title, message, comment);
|
||||
};
|
||||
const validateDeprecatedOptions = (deprecatedOptions, deprecationEntries, argv) => {
|
||||
for (const opt of deprecatedOptions) {
|
||||
const name = opt.name;
|
||||
const message = deprecationEntries[name](argv);
|
||||
const comment = DOCUMENTATION_NOTE;
|
||||
if (opt.fatal) {
|
||||
throw new _utils.ValidationError(name, message, comment);
|
||||
} else {
|
||||
(0, _utils.logValidationWarning)(name, message, comment);
|
||||
}
|
||||
}
|
||||
};
|
||||
function validateCLIOptions(argv, options = {}, rawArgv = []) {
|
||||
const yargsSpecialOptions = ['$0', '_', 'help', 'h'];
|
||||
const allowedOptions = Object.keys(options).reduce((acc, option) => acc.add(option).add(options[option].alias || option), new Set(yargsSpecialOptions));
|
||||
const deprecationEntries = options.deprecationEntries ?? {};
|
||||
const CLIDeprecations = Object.keys(deprecationEntries).reduce((acc, entry) => {
|
||||
acc[entry] = deprecationEntries[entry];
|
||||
if (options[entry]) {
|
||||
const alias = options[entry].alias;
|
||||
if (alias) {
|
||||
acc[alias] = deprecationEntries[entry];
|
||||
}
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
const deprecations = new Set(Object.keys(CLIDeprecations));
|
||||
const deprecatedOptions = Object.keys(argv).filter(arg => deprecations.has(arg) && argv[arg] != null).map(arg => ({
|
||||
fatal: !allowedOptions.has(arg),
|
||||
name: arg
|
||||
}));
|
||||
if (deprecatedOptions.length > 0) {
|
||||
validateDeprecatedOptions(deprecatedOptions, CLIDeprecations, argv);
|
||||
}
|
||||
const unrecognizedOptions = Object.keys(argv).filter(arg => !allowedOptions.has((0, _camelcase().default)(arg, {
|
||||
locale: 'en-US'
|
||||
})) && !allowedOptions.has(arg) && (rawArgv.length === 0 || rawArgv.includes(arg)));
|
||||
if (unrecognizedOptions.length > 0) {
|
||||
throw createCLIValidationError(unrecognizedOptions, allowedOptions);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/***/ },
|
||||
|
||||
/***/ "./src/warnings.ts"
|
||||
(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
exports.unknownOptionWarning = void 0;
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require("chalk"));
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
return data;
|
||||
}
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
const unknownOptionWarning = (config, exampleConfig, option, options, path) => {
|
||||
const didYouMean = (0, _utils.createDidYouMeanMessage)(option, Object.keys(exampleConfig));
|
||||
const message = ` Unknown option ${_chalk().default.bold(`"${path && path.length > 0 ? `${path.join('.')}.` : ''}${option}"`)} with value ${_chalk().default.bold((0, _utils.format)(config[option]))} was found.${didYouMean && ` ${didYouMean}`}\n This is probably a typing mistake. Fixing it will remove this message.`;
|
||||
const comment = options.comment;
|
||||
const name = options.title && options.title.warning || _utils.WARNING;
|
||||
(0, _utils.logValidationWarning)(name, message, comment);
|
||||
};
|
||||
exports.unknownOptionWarning = unknownOptionWarning;
|
||||
|
||||
/***/ }
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
||||
(() => {
|
||||
var exports = __webpack_exports__;
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({
|
||||
value: true
|
||||
}));
|
||||
Object.defineProperty(exports, "ValidationError", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.ValidationError;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "createDidYouMeanMessage", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.createDidYouMeanMessage;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "format", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.format;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "logValidationWarning", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _utils.logValidationWarning;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "multipleValidOptions", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _condition.multipleValidOptions;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "validate", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _validate.default;
|
||||
}
|
||||
}));
|
||||
Object.defineProperty(exports, "validateCLIOptions", ({
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _validateCLIOptions.default;
|
||||
}
|
||||
}));
|
||||
var _utils = __webpack_require__("./src/utils.ts");
|
||||
var _validate = _interopRequireDefault(__webpack_require__("./src/validate.ts"));
|
||||
var _validateCLIOptions = _interopRequireDefault(__webpack_require__("./src/validateCLIOptions.ts"));
|
||||
var _condition = __webpack_require__("./src/condition.ts");
|
||||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
||||
})();
|
||||
|
||||
module.exports = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
9
node_modules/jest-validate/build/index.mjs
generated
vendored
Normal file
9
node_modules/jest-validate/build/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import cjsModule from './index.js';
|
||||
|
||||
export const ValidationError = cjsModule.ValidationError;
|
||||
export const createDidYouMeanMessage = cjsModule.createDidYouMeanMessage;
|
||||
export const format = cjsModule.format;
|
||||
export const logValidationWarning = cjsModule.logValidationWarning;
|
||||
export const multipleValidOptions = cjsModule.multipleValidOptions;
|
||||
export const validate = cjsModule.validate;
|
||||
export const validateCLIOptions = cjsModule.validateCLIOptions;
|
||||
39
node_modules/jest-validate/package.json
generated
vendored
Normal file
39
node_modules/jest-validate/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "jest-validate",
|
||||
"version": "30.3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jestjs/jest.git",
|
||||
"directory": "packages/jest-validate"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./build/index.js",
|
||||
"types": "./build/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./build/index.d.ts",
|
||||
"require": "./build/index.js",
|
||||
"import": "./build/index.mjs",
|
||||
"default": "./build/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jest/get-type": "30.1.0",
|
||||
"@jest/types": "30.3.0",
|
||||
"camelcase": "^6.3.0",
|
||||
"chalk": "^4.1.2",
|
||||
"leven": "^3.1.0",
|
||||
"pretty-format": "30.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/yargs": "^17.0.33"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"gitHead": "efb59c2e81083f8dc941f20d6d20a3af2dc8d068"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue