Add node modules and compiled JavaScript from main
This commit is contained in:
parent
8bccaeaf7c
commit
4181bfdf50
7465 changed files with 1775003 additions and 2 deletions
12
node_modules/jest-cli/build/init/errors.d.ts
generated
vendored
Normal file
12
node_modules/jest-cli/build/init/errors.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
export declare class NotFoundPackageJsonError extends Error {
|
||||
constructor(rootDir: string);
|
||||
}
|
||||
export declare class MalformedPackageJsonError extends Error {
|
||||
constructor(packageJsonPath: string);
|
||||
}
|
35
node_modules/jest-cli/build/init/errors.js
generated
vendored
Normal file
35
node_modules/jest-cli/build/init/errors.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.MalformedPackageJsonError = exports.NotFoundPackageJsonError = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
class NotFoundPackageJsonError extends Error {
|
||||
constructor(rootDir) {
|
||||
super(`Could not find a "package.json" file in ${rootDir}`);
|
||||
this.name = '';
|
||||
Error.captureStackTrace(this, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
exports.NotFoundPackageJsonError = NotFoundPackageJsonError;
|
||||
|
||||
class MalformedPackageJsonError extends Error {
|
||||
constructor(packageJsonPath) {
|
||||
super(
|
||||
`There is malformed json in ${packageJsonPath}\n` +
|
||||
'Fix it, and then run "jest --init"'
|
||||
);
|
||||
this.name = '';
|
||||
Error.captureStackTrace(this, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
exports.MalformedPackageJsonError = MalformedPackageJsonError;
|
8
node_modules/jest-cli/build/init/generateConfigFile.d.ts
generated
vendored
Normal file
8
node_modules/jest-cli/build/init/generateConfigFile.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
declare const generateConfigFile: (results: Record<string, unknown>, generateEsm?: boolean) => string;
|
||||
export default generateConfigFile;
|
108
node_modules/jest-cli/build/init/generateConfigFile.js
generated
vendored
Normal file
108
node_modules/jest-cli/build/init/generateConfigFile.js
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function _jestConfig() {
|
||||
const data = require('jest-config');
|
||||
|
||||
_jestConfig = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const stringifyOption = (option, map, linePrefix = '') => {
|
||||
const optionDescription = ` // ${_jestConfig().descriptions[option]}`;
|
||||
const stringifiedObject = `${option}: ${JSON.stringify(
|
||||
map[option],
|
||||
null,
|
||||
2
|
||||
)}`;
|
||||
return (
|
||||
optionDescription +
|
||||
'\n' +
|
||||
stringifiedObject
|
||||
.split('\n')
|
||||
.map(line => ' ' + linePrefix + line)
|
||||
.join('\n') +
|
||||
',\n'
|
||||
);
|
||||
};
|
||||
|
||||
const generateConfigFile = (results, generateEsm = false) => {
|
||||
const {
|
||||
useTypescript,
|
||||
coverage,
|
||||
coverageProvider,
|
||||
clearMocks,
|
||||
environment
|
||||
} = results;
|
||||
const overrides = {};
|
||||
|
||||
if (coverage) {
|
||||
Object.assign(overrides, {
|
||||
coverageDirectory: 'coverage'
|
||||
});
|
||||
}
|
||||
|
||||
if (coverageProvider === 'v8') {
|
||||
Object.assign(overrides, {
|
||||
coverageProvider: 'v8'
|
||||
});
|
||||
}
|
||||
|
||||
if (environment === 'node') {
|
||||
Object.assign(overrides, {
|
||||
testEnvironment: 'node'
|
||||
});
|
||||
}
|
||||
|
||||
if (clearMocks) {
|
||||
Object.assign(overrides, {
|
||||
clearMocks: true
|
||||
});
|
||||
}
|
||||
|
||||
const overrideKeys = Object.keys(overrides);
|
||||
const properties = [];
|
||||
|
||||
for (const option in _jestConfig().descriptions) {
|
||||
const opt = option;
|
||||
|
||||
if (overrideKeys.includes(opt)) {
|
||||
properties.push(stringifyOption(opt, overrides));
|
||||
} else {
|
||||
properties.push(stringifyOption(opt, _jestConfig().defaults, '// '));
|
||||
}
|
||||
}
|
||||
|
||||
const configHeaderMessage = `/*
|
||||
* For a detailed explanation regarding each configuration property${
|
||||
useTypescript ? ' and type check' : ''
|
||||
}, visit:
|
||||
* https://jestjs.io/docs/en/configuration.html
|
||||
*/
|
||||
|
||||
`;
|
||||
return (
|
||||
configHeaderMessage +
|
||||
(useTypescript || generateEsm
|
||||
? 'export default {\n'
|
||||
: 'module.exports = {\n') +
|
||||
properties.join('\n') +
|
||||
'};\n'
|
||||
);
|
||||
};
|
||||
|
||||
var _default = generateConfigFile;
|
||||
exports.default = _default;
|
8
node_modules/jest-cli/build/init/index.d.ts
generated
vendored
Normal file
8
node_modules/jest-cli/build/init/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
declare const _default: (rootDir?: string) => Promise<void>;
|
||||
export default _default;
|
250
node_modules/jest-cli/build/init/index.js
generated
vendored
Normal file
250
node_modules/jest-cli/build/init/index.js
generated
vendored
Normal file
|
@ -0,0 +1,250 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _chalk() {
|
||||
const data = _interopRequireDefault(require('chalk'));
|
||||
|
||||
_chalk = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _prompts() {
|
||||
const data = _interopRequireDefault(require('prompts'));
|
||||
|
||||
_prompts = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestConfig() {
|
||||
const data = require('jest-config');
|
||||
|
||||
_jestConfig = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _jestUtil() {
|
||||
const data = require('jest-util');
|
||||
|
||||
_jestUtil = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _errors = require('./errors');
|
||||
|
||||
var _generateConfigFile = _interopRequireDefault(
|
||||
require('./generateConfigFile')
|
||||
);
|
||||
|
||||
var _modifyPackageJson = _interopRequireDefault(require('./modifyPackageJson'));
|
||||
|
||||
var _questions = _interopRequireWildcard(require('./questions'));
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const {
|
||||
JEST_CONFIG_BASE_NAME,
|
||||
JEST_CONFIG_EXT_MJS,
|
||||
JEST_CONFIG_EXT_JS,
|
||||
JEST_CONFIG_EXT_TS,
|
||||
JEST_CONFIG_EXT_ORDER,
|
||||
PACKAGE_JSON
|
||||
} = _jestConfig().constants;
|
||||
|
||||
const getConfigFilename = ext => JEST_CONFIG_BASE_NAME + ext;
|
||||
|
||||
var _default = async (
|
||||
rootDir = (0, _jestUtil().tryRealpath)(process.cwd())
|
||||
) => {
|
||||
// prerequisite checks
|
||||
const projectPackageJsonPath = path().join(rootDir, PACKAGE_JSON);
|
||||
|
||||
if (!fs().existsSync(projectPackageJsonPath)) {
|
||||
throw new _errors.NotFoundPackageJsonError(rootDir);
|
||||
}
|
||||
|
||||
const questions = _questions.default.slice(0);
|
||||
|
||||
let hasJestProperty = false;
|
||||
let projectPackageJson;
|
||||
|
||||
try {
|
||||
projectPackageJson = JSON.parse(
|
||||
fs().readFileSync(projectPackageJsonPath, 'utf-8')
|
||||
);
|
||||
} catch {
|
||||
throw new _errors.MalformedPackageJsonError(projectPackageJsonPath);
|
||||
}
|
||||
|
||||
if (projectPackageJson.jest) {
|
||||
hasJestProperty = true;
|
||||
}
|
||||
|
||||
const existingJestConfigExt = JEST_CONFIG_EXT_ORDER.find(ext =>
|
||||
fs().existsSync(path().join(rootDir, getConfigFilename(ext)))
|
||||
);
|
||||
|
||||
if (hasJestProperty || existingJestConfigExt) {
|
||||
const result = await (0, _prompts().default)({
|
||||
initial: true,
|
||||
message:
|
||||
'It seems that you already have a jest configuration, do you want to override it?',
|
||||
name: 'continue',
|
||||
type: 'confirm'
|
||||
});
|
||||
|
||||
if (!result.continue) {
|
||||
console.log();
|
||||
console.log('Aborting...');
|
||||
return;
|
||||
}
|
||||
} // Add test script installation only if needed
|
||||
|
||||
if (
|
||||
!projectPackageJson.scripts ||
|
||||
projectPackageJson.scripts.test !== 'jest'
|
||||
) {
|
||||
questions.unshift(_questions.testScriptQuestion);
|
||||
} // Start the init process
|
||||
|
||||
console.log();
|
||||
console.log(
|
||||
_chalk().default.underline(
|
||||
`The following questions will help Jest to create a suitable configuration for your project\n`
|
||||
)
|
||||
);
|
||||
let promptAborted = false; // @ts-expect-error: Return type cannot be object - faulty typings
|
||||
|
||||
const results = await (0, _prompts().default)(questions, {
|
||||
onCancel: () => {
|
||||
promptAborted = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (promptAborted) {
|
||||
console.log();
|
||||
console.log('Aborting...');
|
||||
return;
|
||||
} // Determine if Jest should use JS or TS for the config file
|
||||
|
||||
const jestConfigFileExt = results.useTypescript
|
||||
? JEST_CONFIG_EXT_TS
|
||||
: projectPackageJson.type === 'module'
|
||||
? JEST_CONFIG_EXT_MJS
|
||||
: JEST_CONFIG_EXT_JS; // Determine Jest config path
|
||||
|
||||
const jestConfigPath = existingJestConfigExt
|
||||
? getConfigFilename(existingJestConfigExt)
|
||||
: path().join(rootDir, getConfigFilename(jestConfigFileExt));
|
||||
const shouldModifyScripts = results.scripts;
|
||||
|
||||
if (shouldModifyScripts || hasJestProperty) {
|
||||
const modifiedPackageJson = (0, _modifyPackageJson.default)({
|
||||
projectPackageJson,
|
||||
shouldModifyScripts
|
||||
});
|
||||
fs().writeFileSync(projectPackageJsonPath, modifiedPackageJson);
|
||||
console.log('');
|
||||
console.log(
|
||||
`✏️ Modified ${_chalk().default.cyan(projectPackageJsonPath)}`
|
||||
);
|
||||
}
|
||||
|
||||
const generatedConfig = (0, _generateConfigFile.default)(
|
||||
results,
|
||||
projectPackageJson.type === 'module' ||
|
||||
jestConfigPath.endsWith(JEST_CONFIG_EXT_MJS)
|
||||
);
|
||||
fs().writeFileSync(jestConfigPath, generatedConfig);
|
||||
console.log('');
|
||||
console.log(
|
||||
`📝 Configuration file created at ${_chalk().default.cyan(jestConfigPath)}`
|
||||
);
|
||||
};
|
||||
|
||||
exports.default = _default;
|
12
node_modules/jest-cli/build/init/modifyPackageJson.d.ts
generated
vendored
Normal file
12
node_modules/jest-cli/build/init/modifyPackageJson.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { ProjectPackageJson } from './types';
|
||||
declare const modifyPackageJson: ({ projectPackageJson, shouldModifyScripts, }: {
|
||||
projectPackageJson: ProjectPackageJson;
|
||||
shouldModifyScripts: boolean;
|
||||
}) => string;
|
||||
export default modifyPackageJson;
|
28
node_modules/jest-cli/build/init/modifyPackageJson.js
generated
vendored
Normal file
28
node_modules/jest-cli/build/init/modifyPackageJson.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const modifyPackageJson = ({projectPackageJson, shouldModifyScripts}) => {
|
||||
if (shouldModifyScripts) {
|
||||
projectPackageJson.scripts
|
||||
? (projectPackageJson.scripts.test = 'jest')
|
||||
: (projectPackageJson.scripts = {
|
||||
test: 'jest'
|
||||
});
|
||||
}
|
||||
|
||||
delete projectPackageJson.jest;
|
||||
return JSON.stringify(projectPackageJson, null, 2) + '\n';
|
||||
};
|
||||
|
||||
var _default = modifyPackageJson;
|
||||
exports.default = _default;
|
10
node_modules/jest-cli/build/init/questions.d.ts
generated
vendored
Normal file
10
node_modules/jest-cli/build/init/questions.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { PromptObject } from 'prompts';
|
||||
declare const defaultQuestions: Array<PromptObject>;
|
||||
export default defaultQuestions;
|
||||
export declare const testScriptQuestion: PromptObject;
|
75
node_modules/jest-cli/build/init/questions.js
generated
vendored
Normal file
75
node_modules/jest-cli/build/init/questions.js
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
value: true
|
||||
});
|
||||
exports.testScriptQuestion = exports.default = void 0;
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const defaultQuestions = [
|
||||
{
|
||||
initial: false,
|
||||
message: 'Would you like to use Typescript for the configuration file?',
|
||||
name: 'useTypescript',
|
||||
type: 'confirm'
|
||||
},
|
||||
{
|
||||
choices: [
|
||||
{
|
||||
title: 'node',
|
||||
value: 'node'
|
||||
},
|
||||
{
|
||||
title: 'jsdom (browser-like)',
|
||||
value: 'jsdom'
|
||||
}
|
||||
],
|
||||
initial: 0,
|
||||
message: 'Choose the test environment that will be used for testing',
|
||||
name: 'environment',
|
||||
type: 'select'
|
||||
},
|
||||
{
|
||||
initial: false,
|
||||
message: 'Do you want Jest to add coverage reports?',
|
||||
name: 'coverage',
|
||||
type: 'confirm'
|
||||
},
|
||||
{
|
||||
choices: [
|
||||
{
|
||||
title: 'v8',
|
||||
value: 'v8'
|
||||
},
|
||||
{
|
||||
title: 'babel',
|
||||
value: 'babel'
|
||||
}
|
||||
],
|
||||
initial: 0,
|
||||
message: 'Which provider should be used to instrument code for coverage?',
|
||||
name: 'coverageProvider',
|
||||
type: 'select'
|
||||
},
|
||||
{
|
||||
initial: false,
|
||||
message: 'Automatically clear mock calls and instances between every test?',
|
||||
name: 'clearMocks',
|
||||
type: 'confirm'
|
||||
}
|
||||
];
|
||||
var _default = defaultQuestions;
|
||||
exports.default = _default;
|
||||
const testScriptQuestion = {
|
||||
initial: true,
|
||||
message:
|
||||
'Would you like to use Jest when running "test" script in "package.json"?',
|
||||
name: 'scripts',
|
||||
type: 'confirm'
|
||||
};
|
||||
exports.testScriptQuestion = testScriptQuestion;
|
12
node_modules/jest-cli/build/init/types.d.ts
generated
vendored
Normal file
12
node_modules/jest-cli/build/init/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import type { Config } from '@jest/types';
|
||||
export declare type ProjectPackageJson = {
|
||||
jest?: Partial<Config.InitialOptions>;
|
||||
scripts?: Record<string, string>;
|
||||
type?: 'commonjs' | 'module';
|
||||
};
|
1
node_modules/jest-cli/build/init/types.js
generated
vendored
Normal file
1
node_modules/jest-cli/build/init/types.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
'use strict';
|
Loading…
Add table
Add a link
Reference in a new issue