Updating NPM dependencies

This commit is contained in:
Drew Heavner
2020-11-11 13:30:52 +00:00
committed by GitHub
parent 7a6fb66c63
commit bd487ef324
9068 changed files with 1400893 additions and 587661 deletions

View File

@@ -6,49 +6,19 @@ Object.defineProperty(exports, '__esModule', {
exports.default = normalize;
function _crypto() {
const data = _interopRequireDefault(require('crypto'));
const data = require('crypto');
_crypto = function _crypto() {
_crypto = function () {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require('path'));
function path() {
const data = _interopRequireWildcard(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _glob() {
const data = _interopRequireDefault(require('glob'));
_glob = function _glob() {
return data;
};
return data;
}
function _jestValidate() {
const data = require('jest-validate');
_jestValidate = function _jestValidate() {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function _jestUtil() {
path = function () {
return data;
};
@@ -58,7 +28,37 @@ function _jestUtil() {
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function _chalk() {
_chalk = function () {
return data;
};
return data;
}
function _deepmerge() {
const data = _interopRequireDefault(require('deepmerge'));
_deepmerge = function () {
return data;
};
return data;
}
function _glob() {
const data = require('glob');
_glob = function () {
return data;
};
return data;
}
function _gracefulFs() {
const data = require('graceful-fs');
_gracefulFs = function () {
return data;
};
@@ -68,27 +68,7 @@ function _chalk() {
function _micromatch() {
const data = _interopRequireDefault(require('micromatch'));
_micromatch = function _micromatch() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function _realpathNative() {
return data;
};
return data;
}
function _jestResolve() {
const data = _interopRequireDefault(require('jest-resolve'));
_jestResolve = function _jestResolve() {
_micromatch = function () {
return data;
};
@@ -98,106 +78,185 @@ function _jestResolve() {
function _jestRegexUtil() {
const data = require('jest-regex-util');
_jestRegexUtil = function _jestRegexUtil() {
_jestRegexUtil = function () {
return data;
};
return data;
}
function _jestGetType() {
const data = _interopRequireDefault(require('jest-get-type'));
function _jestResolve() {
const data = _interopRequireDefault(require('jest-resolve'));
_jestGetType = function _jestGetType() {
_jestResolve = function () {
return data;
};
return data;
}
var _validatePattern = _interopRequireDefault(require('./validatePattern'));
function _jestUtil() {
const data = require('jest-util');
var _getMaxWorkers = _interopRequireDefault(require('./getMaxWorkers'));
_jestUtil = function () {
return data;
};
var _utils = require('./utils');
return data;
}
var _constants = require('./constants');
function _jestValidate() {
const data = require('jest-validate');
var _ReporterValidationErrors = require('./ReporterValidationErrors');
_jestValidate = function () {
return data;
};
return data;
}
var _Defaults = _interopRequireDefault(require('./Defaults'));
var _Deprecated = _interopRequireDefault(require('./Deprecated'));
var _setFromArgv = _interopRequireDefault(require('./setFromArgv'));
var _ReporterValidationErrors = require('./ReporterValidationErrors');
var _ValidConfig = _interopRequireDefault(require('./ValidConfig'));
var _color = require('./color');
var _constants = require('./constants');
var _getMaxWorkers = _interopRequireDefault(require('./getMaxWorkers'));
var _setFromArgv = _interopRequireDefault(require('./setFromArgv'));
var _utils = require('./utils');
var _validatePattern = _interopRequireDefault(require('./validatePattern'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(
Object.getOwnPropertySymbols(source).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
})
);
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];
}
}
ownKeys.forEach(function(key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
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 ERROR = `${_utils.BULLET}Validation Error`;
const PRESET_EXTENSIONS = ['.json', '.js'];
const PRESET_NAME = 'jest-preset';
const createConfigError = message =>
new (_jestValidate()).ValidationError(
new (_jestValidate().ValidationError)(
ERROR,
message,
_utils.DOCUMENTATION_NOTE
); // TS 3.5 forces us to split these into 2
);
function verifyDirectoryExists(path, key) {
try {
const rootStat = (0, _gracefulFs().statSync)(path);
if (!rootStat.isDirectory()) {
throw createConfigError(
` ${_chalk().default.bold(path)} in the ${_chalk().default.bold(
key
)} option is not a directory.`
);
}
} catch (err) {
if (err instanceof _jestValidate().ValidationError) {
throw err;
}
if (err.code === 'ENOENT') {
throw createConfigError(
` Directory ${_chalk().default.bold(
path
)} in the ${_chalk().default.bold(key)} option was not found.`
);
} // Not sure in which cases `statSync` can throw, so let's just show the underlying error to the user
throw createConfigError(
` Got an error trying to find ${_chalk().default.bold(
path
)} in the ${_chalk().default.bold(key)} option.\n\n Error was: ${
err.message
}`
);
}
} // TS 3.5 forces us to split these into 2
const mergeModuleNameMapperWithPreset = (options, preset) => {
if (options['moduleNameMapper'] && preset['moduleNameMapper']) {
options['moduleNameMapper'] = _objectSpread(
{},
options['moduleNameMapper'],
preset['moduleNameMapper'],
options['moduleNameMapper']
);
options['moduleNameMapper'] = {
...options['moduleNameMapper'],
...preset['moduleNameMapper'],
...options['moduleNameMapper']
};
}
};
const mergeTransformWithPreset = (options, preset) => {
if (options['transform'] && preset['transform']) {
options['transform'] = _objectSpread(
{},
options['transform'],
preset['transform'],
options['transform']
options['transform'] = {
...options['transform'],
...preset['transform'],
...options['transform']
};
}
};
const mergeGlobalsWithPreset = (options, preset) => {
if (options['globals'] && preset['globals']) {
options['globals'] = (0, _deepmerge().default)(
preset['globals'],
options['globals']
);
}
};
@@ -212,7 +271,7 @@ const setupPreset = (options, optionsPreset) => {
const presetModule = _jestResolve().default.findNodeModule(
presetPath.startsWith('.')
? presetPath
: _path().default.join(presetPath, PRESET_NAME),
: path().join(presetPath, PRESET_NAME),
{
basedir: options.rootDir,
extensions: PRESET_EXTENSIONS
@@ -220,12 +279,13 @@ const setupPreset = (options, optionsPreset) => {
);
try {
// Force re-evaluation to support multiple projects
if (!presetModule) {
throw new Error(`Cannot find module '${presetPath}'`);
} // Force re-evaluation to support multiple projects
try {
if (presetModule) {
delete require.cache[require.resolve(presetModule)];
}
} catch (e) {} // @ts-ignore: `presetModule` can be null?
delete require.cache[require.resolve(presetModule)];
} catch {}
preset = require(presetModule);
} catch (error) {
@@ -237,20 +297,36 @@ const setupPreset = (options, optionsPreset) => {
);
}
const preset = _jestResolve().default.findNodeModule(presetPath, {
basedir: options.rootDir
});
if (error.message.includes('Cannot find module')) {
if (error.message.includes(presetPath)) {
const preset = _jestResolve().default.findNodeModule(presetPath, {
basedir: options.rootDir
});
if (preset) {
throw createConfigError(
` Module ${_chalk().default.bold(
presetPath
)} should have "jest-preset.js" or "jest-preset.json" file at the root.`
);
}
throw createConfigError(
` Preset ${_chalk().default.bold(presetPath)} not found.`
);
}
if (preset) {
throw createConfigError(
` Module ${_chalk().default.bold(
presetPath
)} should have "jest-preset.js" or "jest-preset.json" file at the root.`
` Missing dependency in ${_chalk().default.bold(presetPath)}:\n\n ${
error.message
}\n ${error.stack}`
);
}
throw createConfigError(
` Preset ${_chalk().default.bold(presetPath)} not found.`
` An unknown error occurred in ${_chalk().default.bold(
presetPath
)}:\n\n ${error.message}\n ${error.stack}`
);
}
@@ -258,6 +334,12 @@ const setupPreset = (options, optionsPreset) => {
options.setupFiles = (preset.setupFiles || []).concat(options.setupFiles);
}
if (options.setupFilesAfterEnv) {
options.setupFilesAfterEnv = (preset.setupFilesAfterEnv || []).concat(
options.setupFilesAfterEnv
);
}
if (options.modulePathIgnorePatterns && preset.modulePathIgnorePatterns) {
options.modulePathIgnorePatterns = preset.modulePathIgnorePatterns.concat(
options.modulePathIgnorePatterns
@@ -266,7 +348,8 @@ const setupPreset = (options, optionsPreset) => {
mergeModuleNameMapperWithPreset(options, preset);
mergeTransformWithPreset(options, preset);
return _objectSpread({}, preset, options);
mergeGlobalsWithPreset(options, preset);
return {...preset, ...options};
};
const setupBabelJest = options => {
@@ -318,7 +401,7 @@ const normalizeCollectCoverageOnlyFrom = (options, key) => {
: Object.keys(initialCollectCoverageFrom); // passed from options
return collectCoverageOnlyFrom.reduce((map, filePath) => {
filePath = _path().default.resolve(
filePath = path().resolve(
options.rootDir,
(0, _utils.replaceRootDirInPath)(options.rootDir, filePath)
);
@@ -338,7 +421,7 @@ const normalizeCollectCoverageFrom = (options, key) => {
if (!Array.isArray(initialCollectCoverageFrom)) {
try {
value = JSON.parse(initialCollectCoverageFrom);
} catch (e) {}
} catch {}
if (options[key] && !Array.isArray(value)) {
value = [initialCollectCoverageFrom];
@@ -359,12 +442,12 @@ const normalizeCollectCoverageFrom = (options, key) => {
const normalizeUnmockedModulePathPatterns = (
options,
key // _replaceRootDirTags is specifically well-suited for substituting
) =>
// <rootDir> in paths (it deals with properly interpreting relative path
// separators, etc).
//
// For patterns, direct global substitution is far more ideal, so we
// special case substitutions for patterns here.
) =>
options[key].map(pattern =>
(0, _jestRegexUtil().replacePathSepForRegex)(
pattern.replace(/<rootDir>/g, options.rootDir)
@@ -409,8 +492,7 @@ const normalizePreprocessor = options => {
const normalizeMissingOptions = (options, configPath, projectIndex) => {
if (!options.name) {
options.name = _crypto()
.default.createHash('md5')
options.name = (0, _crypto().createHash)('md5')
.update(options.rootDir) // In case we load config from some path that has the same root dir
.update(configPath || '')
.update(String(projectIndex))
@@ -426,7 +508,7 @@ const normalizeMissingOptions = (options, configPath, projectIndex) => {
const normalizeRootDir = options => {
// Assert that there *is* a rootDir
if (!options.hasOwnProperty('rootDir')) {
if (!options.rootDir) {
throw createConfigError(
` Configuration option ${_chalk().default.bold(
'rootDir'
@@ -434,16 +516,17 @@ const normalizeRootDir = options => {
);
}
options.rootDir = _path().default.normalize(options.rootDir);
options.rootDir = path().normalize(options.rootDir);
try {
// try to resolve windows short paths, ignoring errors (permission errors, mostly)
options.rootDir = (0, _realpathNative().sync)(options.rootDir);
} catch (e) {
options.rootDir = (0, _jestUtil().tryRealpath)(options.rootDir);
} catch {
// ignored
}
return options;
verifyDirectoryExists(options.rootDir, 'rootDir');
return {...options, rootDir: options.rootDir};
};
const normalizeReporters = options => {
@@ -458,6 +541,7 @@ const normalizeReporters = options => {
const normalizedReporterConfig =
typeof reporterConfig === 'string' // if reporter config is a string, we wrap it in an array
? // and pass an empty object for options argument, to normalize
// the shape.
[reporterConfig, {}]
: reporterConfig;
const reporterPath = (0, _utils.replaceRootDirInPath)(
@@ -471,7 +555,7 @@ const normalizeReporters = options => {
});
if (!reporter) {
throw new Error(
throw new (_jestResolve().default.ModuleNotFoundError)(
`Could not resolve a module for a custom reporter.\n` +
` Module name: ${reporterPath}`
);
@@ -497,11 +581,14 @@ const buildTestPathPattern = argv => {
}
const replacePosixSep = pattern => {
if (_path().default.sep === '/') {
return pattern;
// yargs coerces positional args into numbers
const patternAsString = pattern.toString();
if (path().sep === '/') {
return patternAsString;
}
return pattern.replace(/\//g, '\\\\');
return patternAsString.replace(/\//g, '\\\\');
};
const testPathPattern = patterns.map(replacePosixSep).join('|');
@@ -524,26 +611,28 @@ const showTestPathPatternError = testPathPattern => {
);
};
function normalize(options, argv, configPath, projectIndex = Infinity) {
const _validate = (0, _jestValidate().validate)(options, {
function normalize(initialOptions, argv, configPath, projectIndex = Infinity) {
const {hasDeprecationWarnings} = (0, _jestValidate().validate)(
initialOptions,
{
comment: _utils.DOCUMENTATION_NOTE,
deprecatedConfig: _Deprecated.default,
exampleConfig: _ValidConfig.default,
recursiveBlacklist: [
'collectCoverageOnlyFrom', // 'coverageThreshold' allows to use 'global' and glob strings on the same
// level, there's currently no way we can deal with such config
'coverageThreshold',
'globals',
'moduleNameMapper',
'testEnvironmentOptions',
'transform'
]
}),
hasDeprecationWarnings = _validate.hasDeprecationWarnings;
options = normalizePreprocessor(
}
);
let options = normalizePreprocessor(
normalizeReporters(
normalizeMissingOptions(
normalizeRootDir((0, _setFromArgv.default)(options, argv)),
normalizeRootDir((0, _setFromArgv.default)(initialOptions, argv)),
configPath,
projectIndex
)
@@ -596,15 +685,12 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
}
if (!options.coverageDirectory) {
options.coverageDirectory = _path().default.resolve(
options.rootDir,
'coverage'
);
options.coverageDirectory = path().resolve(options.rootDir, 'coverage');
}
setupBabelJest(options); // TODO: Type this properly
const newOptions = _objectSpread({}, _Defaults.default);
const newOptions = {..._Defaults.default};
if (options.resolver) {
newOptions.resolver = (0, _utils.resolve)(null, {
@@ -655,7 +741,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
value =
option &&
option.map(filePath =>
_path().default.resolve(
path().resolve(
options.rootDir,
(0, _utils.replaceRootDirInPath)(options.rootDir, filePath)
)
@@ -673,7 +759,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
const option = oldOptions[key];
value =
option &&
_path().default.resolve(
path().resolve(
options.rootDir,
(0, _utils.replaceRootDirInPath)(options.rootDir, option)
);
@@ -759,7 +845,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
key,
rootDir: options.rootDir
}),
...(Array.isArray(transformElement) ? [transformElement[1]] : [])
Array.isArray(transformElement) ? transformElement[1] : {}
];
});
break;
@@ -774,7 +860,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
break;
case 'haste':
value = _objectSpread({}, oldOptions[key]);
value = {...oldOptions[key]};
if (value.hasteImplModulePath != null) {
const resolvedHasteImpl = (0, _utils.resolve)(newOptions.resolver, {
@@ -802,7 +888,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
// We expand it to these paths. If not, we keep the original path
// for the future resolution.
const globMatches =
typeof project === 'string' ? _glob().default.sync(project) : [];
typeof project === 'string' ? (0, _glob().sync)(project) : [];
return projects.concat(globMatches.length ? globMatches : project);
}, []);
break;
@@ -886,41 +972,13 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
case 'displayName': {
const displayName = oldOptions[key];
if (typeof displayName === 'string') {
value = displayName;
break;
}
/**
* Ensuring that displayName shape is correct here so that the
* reporters can trust the shape of the data
* TODO: Normalize "displayName" such that given a config option
* {
* "displayName": "Test"
* }
* becomes
* {
* displayName: {
* name: "Test",
* color: "white"
* }
* }
*
* This can't be done now since this will be a breaking change
* for custom reporters
*/
if ((0, _jestGetType().default)(displayName) === 'object') {
const errorMessage =
` Option "${_chalk().default.bold(
'displayName'
)}" must be of type:\n\n` +
' {\n' +
' name: string;\n' +
' color: string;\n' +
' }\n';
const name = displayName.name,
color = displayName.color;
if (typeof displayName === 'object') {
const {name, color} = displayName;
if (
!name ||
@@ -928,11 +986,25 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
typeof name !== 'string' ||
typeof color !== 'string'
) {
const errorMessage =
` Option "${_chalk().default.bold(
'displayName'
)}" must be of type:\n\n` +
' {\n' +
' name: string;\n' +
' color: string;\n' +
' }\n';
throw createConfigError(errorMessage);
}
value = oldOptions[key];
} else {
value = {
color: (0, _color.getDisplayNameColor)(options.runner),
name: displayName
};
}
value = oldOptions[key];
break;
}
@@ -950,12 +1022,12 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
}
case 'automock':
case 'browser':
case 'cache':
case 'changedSince':
case 'changedFilesWithAncestor':
case 'clearMocks':
case 'collectCoverage':
case 'coverageProvider':
case 'coverageReporters':
case 'coverageThreshold':
case 'detectLeaks':
@@ -967,6 +1039,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
case 'findRelatedTests':
case 'forceCoverageMatch':
case 'forceExit':
case 'injectGlobals':
case 'lastCommit':
case 'listTests':
case 'logHeapUsage':
@@ -977,6 +1050,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
case 'notify':
case 'notifyMode':
case 'onlyChanged':
case 'onlyFailures':
case 'outputFile':
case 'passWithNoTests':
case 'replname':
@@ -989,6 +1063,7 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
case 'silent':
case 'skipFilter':
case 'skipNodeResolution':
case 'slowTestThreshold':
case 'testEnvironment':
case 'testEnvironmentOptions':
case 'testFailureExitCode':
@@ -1025,16 +1100,19 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
}
});
break;
} // @ts-ignore: automock is missing in GlobalConfig, so what
} // @ts-expect-error: automock is missing in GlobalConfig, so what
newOptions[key] = value;
return newOptions;
}, newOptions);
newOptions.roots.forEach((root, i) => {
verifyDirectoryExists(root, `roots[${i}]`);
});
try {
// try to resolve windows short paths, ignoring errors (permission errors, mostly)
newOptions.cwd = (0, _realpathNative().sync)(process.cwd());
} catch (e) {
newOptions.cwd = (0, _jestUtil().tryRealpath)(process.cwd());
} catch {
// ignored
}
@@ -1057,12 +1135,33 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
if (argv.all) {
newOptions.onlyChanged = false;
newOptions.onlyFailures = false;
} else if (newOptions.testPathPattern) {
// When passing a test path pattern we don't want to only monitor changed
// files unless `--watch` is also passed.
newOptions.onlyChanged = newOptions.watch;
}
if (!newOptions.onlyChanged) {
newOptions.onlyChanged = false;
}
if (!newOptions.lastCommit) {
newOptions.lastCommit = false;
}
if (!newOptions.onlyFailures) {
newOptions.onlyFailures = false;
}
if (!newOptions.watchAll) {
newOptions.watchAll = false;
} // as unknown since it can happen. We really need to fix the types here
if (newOptions.moduleNameMapper === _Defaults.default.moduleNameMapper) {
newOptions.moduleNameMapper = [];
}
newOptions.updateSnapshot =
argv.ci && !argv.updateSnapshot
? 'none'
@@ -1099,20 +1198,22 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
if (newOptions.collectCoverage && argv.findRelatedTests) {
let collectCoverageFrom = argv._.map(filename => {
filename = (0, _utils.replaceRootDirInPath)(options.rootDir, filename);
return _path().default.isAbsolute(filename)
? _path().default.relative(options.rootDir, filename)
return path().isAbsolute(filename)
? path().relative(options.rootDir, filename)
: filename;
}); // Don't override existing collectCoverageFrom options
if (newOptions.collectCoverageFrom) {
collectCoverageFrom = collectCoverageFrom.reduce((patterns, filename) => {
if (
!_micromatch().default.some(
(0, _jestUtil().replacePathSepForGlob)(
_path().default.relative(options.rootDir, filename)
),
(0, _micromatch().default)(
[
(0, _jestUtil().replacePathSepForGlob)(
path().relative(options.rootDir, filename)
)
],
newOptions.collectCoverageFrom
)
).length === 0
) {
return patterns;
}
@@ -1122,6 +1223,28 @@ function normalize(options, argv, configPath, projectIndex = Infinity) {
}
newOptions.collectCoverageFrom = collectCoverageFrom;
} else if (!newOptions.collectCoverageFrom) {
newOptions.collectCoverageFrom = [];
}
if (!newOptions.findRelatedTests) {
newOptions.findRelatedTests = false;
}
if (!newOptions.projects) {
newOptions.projects = [];
}
if (!newOptions.extraGlobals) {
newOptions.extraGlobals = [];
}
if (!newOptions.forceExit) {
newOptions.forceExit = false;
}
if (!newOptions.logHeapUsage) {
newOptions.logHeapUsage = false;
}
return {