Add node modules and compiled JavaScript from main (#57)

Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
github-actions[bot] 2022-06-21 12:18:30 -04:00 committed by GitHub
parent d893f27da9
commit 7f7e5ba5ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6750 changed files with 1745644 additions and 10860 deletions

21
node_modules/@jest/transform/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
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.

View file

@ -0,0 +1,33 @@
/**
* 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';
import type { Options, TransformResult } from './types';
export default class ScriptTransformer {
private _cache;
private _config;
private _transformCache;
private _transformConfigCache;
constructor(config: Config.ProjectConfig);
private _getCacheKey;
private _getFileCachePath;
private _getTransformPath;
private _getTransformer;
private _instrumentFile;
preloadTransformer(filepath: Config.Path): void;
transformSource(filepath: Config.Path, content: string, instrument: boolean, supportsDynamicImport?: boolean, supportsStaticESM?: boolean): TransformResult;
private _transformAndBuildScript;
transform(filename: Config.Path, options: Options, fileSource?: string): TransformResult;
transformJson(filename: Config.Path, options: Options, fileSource: string): string;
requireAndTranspileModule<ModuleType = unknown>(moduleName: string, callback?: (module: ModuleType) => void): ModuleType;
requireAndTranspileModule<ModuleType = unknown>(moduleName: string, callback?: (module: ModuleType) => Promise<void>): Promise<ModuleType>;
/**
* @deprecated use `this.shouldTransform` instead
*/
private _shouldTransform;
shouldTransform(filename: Config.Path): boolean;
}
export declare function createTranspilingRequire(config: Config.ProjectConfig): <TModuleType = unknown>(resolverPath: string, applyInteropRequireDefault?: boolean) => TModuleType;

881
node_modules/@jest/transform/build/ScriptTransformer.js generated vendored Normal file
View file

@ -0,0 +1,881 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.createTranspilingRequire = createTranspilingRequire;
exports.default = void 0;
function _crypto() {
const data = require('crypto');
_crypto = function () {
return data;
};
return data;
}
function path() {
const data = _interopRequireWildcard(require('path'));
path = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
function fs() {
const data = _interopRequireWildcard(require('graceful-fs'));
fs = function () {
return data;
};
return data;
}
function _core() {
const data = require('@babel/core');
_core = function () {
return data;
};
return data;
}
function _babelPluginIstanbul() {
const data = _interopRequireDefault(require('babel-plugin-istanbul'));
_babelPluginIstanbul = function () {
return data;
};
return data;
}
function _convertSourceMap() {
const data = require('convert-source-map');
_convertSourceMap = function () {
return data;
};
return data;
}
function _jestHasteMap() {
const data = _interopRequireDefault(require('jest-haste-map'));
_jestHasteMap = function () {
return data;
};
return data;
}
function _fastJsonStableStringify() {
const data = _interopRequireDefault(require('fast-json-stable-stringify'));
_fastJsonStableStringify = function () {
return data;
};
return data;
}
function _slash() {
const data = _interopRequireDefault(require('slash'));
_slash = function () {
return data;
};
return data;
}
function _writeFileAtomic() {
const data = require('write-file-atomic');
_writeFileAtomic = function () {
return data;
};
return data;
}
function _pirates() {
const data = require('pirates');
_pirates = function () {
return data;
};
return data;
}
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
var _enhanceUnexpectedTokenMessage = _interopRequireDefault(
require('./enhanceUnexpectedTokenMessage')
);
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;
}
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;
}
// Use `require` to avoid TS rootDir
const {version: VERSION} = require('../package.json'); // This data structure is used to avoid recalculating some data every time that
// we need to transform a file. Since ScriptTransformer is instantiated for each
// file we need to keep this object in the local scope of this module.
const projectCaches = new Map(); // To reset the cache for specific changesets (rather than package version).
const CACHE_VERSION = '1';
async function waitForPromiseWithCleanup(promise, cleanup) {
try {
await promise;
} finally {
cleanup();
}
}
class ScriptTransformer {
constructor(config) {
_defineProperty(this, '_cache', void 0);
_defineProperty(this, '_config', void 0);
_defineProperty(this, '_transformCache', void 0);
_defineProperty(this, '_transformConfigCache', void 0);
this._config = config;
this._transformCache = new Map();
this._transformConfigCache = new Map();
const configString = (0, _fastJsonStableStringify().default)(this._config);
let projectCache = projectCaches.get(configString);
if (!projectCache) {
projectCache = {
configString,
ignorePatternsRegExp: calcIgnorePatternRegExp(this._config),
transformRegExp: calcTransformRegExp(this._config),
transformedFiles: new Map()
};
projectCaches.set(configString, projectCache);
}
this._cache = projectCache;
}
_getCacheKey(
fileData,
filename,
instrument,
supportsDynamicImport,
supportsStaticESM
) {
const configString = this._cache.configString;
const transformer = this._getTransformer(filename);
if (transformer && typeof transformer.getCacheKey === 'function') {
return (0, _crypto().createHash)('md5')
.update(
transformer.getCacheKey(fileData, filename, configString, {
config: this._config,
instrument,
rootDir: this._config.rootDir,
supportsDynamicImport,
supportsStaticESM
})
)
.update(CACHE_VERSION)
.digest('hex');
} else {
return (0, _crypto().createHash)('md5')
.update(fileData)
.update(configString)
.update(instrument ? 'instrument' : '')
.update(filename)
.update(CACHE_VERSION)
.digest('hex');
}
}
_getFileCachePath(
filename,
content,
instrument,
supportsDynamicImport,
supportsStaticESM
) {
const baseCacheDir = _jestHasteMap().default.getCacheFilePath(
this._config.cacheDirectory,
'jest-transform-cache-' + this._config.name,
VERSION
);
const cacheKey = this._getCacheKey(
content,
filename,
instrument,
supportsDynamicImport,
supportsStaticESM
); // Create sub folders based on the cacheKey to avoid creating one
// directory with many files.
const cacheDir = path().join(baseCacheDir, cacheKey[0] + cacheKey[1]);
const cacheFilenamePrefix = path()
.basename(filename, path().extname(filename))
.replace(/\W/g, '');
const cachePath = (0, _slash().default)(
path().join(cacheDir, cacheFilenamePrefix + '_' + cacheKey)
);
(0, _jestUtil().createDirectory)(cacheDir);
return cachePath;
}
_getTransformPath(filename) {
const transformRegExp = this._cache.transformRegExp;
if (!transformRegExp) {
return undefined;
}
for (let i = 0; i < transformRegExp.length; i++) {
if (transformRegExp[i][0].test(filename)) {
const transformPath = transformRegExp[i][1];
this._transformConfigCache.set(transformPath, transformRegExp[i][2]);
return transformPath;
}
}
return undefined;
}
_getTransformer(filename) {
if (!this._config.transform || !this._config.transform.length) {
return null;
}
const transformPath = this._getTransformPath(filename);
if (!transformPath) {
return null;
}
const transformer = this._transformCache.get(transformPath);
if (transformer) {
return transformer;
}
let transform = require(transformPath);
if (!transform) {
throw new TypeError('Jest: a transform must export something.');
}
const transformerConfig = this._transformConfigCache.get(transformPath);
if (typeof transform.createTransformer === 'function') {
transform = transform.createTransformer(transformerConfig);
}
if (typeof transform.process !== 'function') {
throw new TypeError(
'Jest: a transform must export a `process` function.'
);
}
this._transformCache.set(transformPath, transform);
return transform;
}
_instrumentFile(
filename,
input,
supportsDynamicImport,
supportsStaticESM,
canMapToInput
) {
const inputCode = typeof input === 'string' ? input : input.code;
const inputMap = typeof input === 'string' ? null : input.map;
const result = (0, _core().transformSync)(inputCode, {
auxiliaryCommentBefore: ' istanbul ignore next ',
babelrc: false,
caller: {
name: '@jest/transform',
supportsDynamicImport,
supportsStaticESM
},
configFile: false,
filename,
plugins: [
[
_babelPluginIstanbul().default,
{
compact: false,
// files outside `cwd` will not be instrumented
cwd: this._config.rootDir,
exclude: [],
extension: false,
inputSourceMap: inputMap,
useInlineSourceMaps: false
}
]
],
sourceMaps: canMapToInput ? 'both' : false
});
if (result && result.code) {
return result;
}
return input;
} // We don't want to expose transformers to the outside - this function is just
// to warm up `this._transformCache`
preloadTransformer(filepath) {
this._getTransformer(filepath);
} // TODO: replace third argument with TransformOptions in Jest 26
transformSource(
filepath,
content,
instrument,
supportsDynamicImport = false,
supportsStaticESM = false
) {
const filename = (0, _jestUtil().tryRealpath)(filepath);
const transform = this._getTransformer(filename);
const cacheFilePath = this._getFileCachePath(
filename,
content,
instrument,
supportsDynamicImport,
supportsStaticESM
);
let sourceMapPath = cacheFilePath + '.map'; // Ignore cache if `config.cache` is set (--no-cache)
let code = this._config.cache ? readCodeCacheFile(cacheFilePath) : null;
const shouldCallTransform = transform && this.shouldTransform(filename); // That means that the transform has a custom instrumentation
// logic and will handle it based on `config.collectCoverage` option
const transformWillInstrument =
shouldCallTransform && transform && transform.canInstrument;
if (code) {
// This is broken: we return the code, and a path for the source map
// directly from the cache. But, nothing ensures the source map actually
// matches that source code. They could have gotten out-of-sync in case
// two separate processes write concurrently to the same cache files.
return {
code,
originalCode: content,
sourceMapPath
};
}
let transformed = {
code: content,
map: null
};
if (transform && shouldCallTransform) {
const processed = transform.process(content, filename, this._config, {
instrument,
supportsDynamicImport,
supportsStaticESM
});
if (typeof processed === 'string') {
transformed.code = processed;
} else if (processed != null && typeof processed.code === 'string') {
transformed = processed;
} else {
throw new TypeError(
"Jest: a transform's `process` function must return a string, " +
'or an object with `code` key containing this string.'
);
}
}
if (!transformed.map) {
try {
//Could be a potential freeze here.
//See: https://github.com/facebook/jest/pull/5177#discussion_r158883570
const inlineSourceMap = (0, _convertSourceMap().fromSource)(
transformed.code
);
if (inlineSourceMap) {
transformed.map = inlineSourceMap.toObject();
}
} catch {
const transformPath = this._getTransformPath(filename);
console.warn(
`jest-transform: The source map produced for the file ${filename} ` +
`by ${transformPath} was invalid. Proceeding without source ` +
'mapping for that file.'
);
}
} // Apply instrumentation to the code if necessary, keeping the instrumented code and new map
let map = transformed.map;
if (!transformWillInstrument && instrument) {
/**
* We can map the original source code to the instrumented code ONLY if
* - the process of transforming the code produced a source map e.g. ts-jest
* - we did not transform the source code
*
* Otherwise we cannot make any statements about how the instrumented code corresponds to the original code,
* and we should NOT emit any source maps
*
*/
const shouldEmitSourceMaps =
(transform != null && map != null) || transform == null;
const instrumented = this._instrumentFile(
filename,
transformed,
supportsDynamicImport,
supportsStaticESM,
shouldEmitSourceMaps
);
code =
typeof instrumented === 'string' ? instrumented : instrumented.code;
map = typeof instrumented === 'string' ? null : instrumented.map;
} else {
code = transformed.code;
}
if (map) {
const sourceMapContent =
typeof map === 'string' ? map : JSON.stringify(map);
writeCacheFile(sourceMapPath, sourceMapContent);
} else {
sourceMapPath = null;
}
writeCodeCacheFile(cacheFilePath, code);
return {
code,
originalCode: content,
sourceMapPath
};
}
_transformAndBuildScript(filename, options, instrument, fileSource) {
const {
isCoreModule,
isInternalModule,
supportsDynamicImport,
supportsStaticESM
} = options;
const content = stripShebang(
fileSource || fs().readFileSync(filename, 'utf8')
);
let code = content;
let sourceMapPath = null;
const willTransform =
!isInternalModule &&
!isCoreModule &&
(this.shouldTransform(filename) || instrument);
try {
if (willTransform) {
const transformedSource = this.transformSource(
filename,
content,
instrument,
supportsDynamicImport,
supportsStaticESM
);
code = transformedSource.code;
sourceMapPath = transformedSource.sourceMapPath;
}
return {
code,
originalCode: content,
sourceMapPath
};
} catch (e) {
throw (0, _enhanceUnexpectedTokenMessage.default)(e);
}
}
transform(filename, options, fileSource) {
let scriptCacheKey = undefined;
let instrument = false;
if (!options.isCoreModule) {
instrument =
options.coverageProvider === 'babel' &&
(0, _shouldInstrument.default)(filename, options, this._config);
scriptCacheKey = getScriptCacheKey(filename, instrument);
const result = this._cache.transformedFiles.get(scriptCacheKey);
if (result) {
return result;
}
}
const result = this._transformAndBuildScript(
filename,
options,
instrument,
fileSource
);
if (scriptCacheKey) {
this._cache.transformedFiles.set(scriptCacheKey, result);
}
return result;
}
transformJson(filename, options, fileSource) {
const {
isCoreModule,
isInternalModule,
supportsDynamicImport,
supportsStaticESM
} = options;
const willTransform =
!isInternalModule && !isCoreModule && this.shouldTransform(filename);
if (willTransform) {
const {code: transformedJsonSource} = this.transformSource(
filename,
fileSource,
false,
supportsDynamicImport,
supportsStaticESM
);
return transformedJsonSource;
}
return fileSource;
}
requireAndTranspileModule(moduleName, callback) {
// Load the transformer to avoid a cycle where we need to load a
// transformer in order to transform it in the require hooks
this.preloadTransformer(moduleName);
let transforming = false;
const revertHook = (0, _pirates().addHook)(
(code, filename) => {
try {
transforming = true;
return (
// we might wanna do `supportsDynamicImport` at some point
this.transformSource(filename, code, false, false, false).code ||
code
);
} finally {
transforming = false;
}
},
{
exts: this._config.moduleFileExtensions.map(ext => `.${ext}`),
ignoreNodeModules: false,
matcher: filename => {
if (transforming) {
// Don't transform any dependency required by the transformer itself
return false;
}
return this.shouldTransform(filename);
}
}
);
const module = require(moduleName);
if (!callback) {
revertHook();
return module;
}
try {
const cbResult = callback(module);
if ((0, _jestUtil().isPromise)(cbResult)) {
return waitForPromiseWithCleanup(cbResult, revertHook).then(
() => module
);
}
} finally {
revertHook();
}
return module;
}
/**
* @deprecated use `this.shouldTransform` instead
*/
// @ts-expect-error: Unused and private - remove in Jest 25
_shouldTransform(filename) {
return this.shouldTransform(filename);
}
shouldTransform(filename) {
const ignoreRegexp = this._cache.ignorePatternsRegExp;
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false;
return (
!!this._config.transform && !!this._config.transform.length && !isIgnored
);
}
} // TODO: do we need to define the generics twice?
exports.default = ScriptTransformer;
function createTranspilingRequire(config) {
const transformer = new ScriptTransformer(config);
return function requireAndTranspileModule(
resolverPath,
applyInteropRequireDefault = false
) {
const transpiledModule = transformer.requireAndTranspileModule(
resolverPath
);
return applyInteropRequireDefault
? (0, _jestUtil().interopRequireDefault)(transpiledModule).default
: transpiledModule;
};
}
const removeFile = path => {
try {
fs().unlinkSync(path);
} catch {}
};
const stripShebang = content => {
// If the file data starts with a shebang remove it. Leaves the empty line
// to keep stack trace line numbers correct.
if (content.startsWith('#!')) {
return content.replace(/^#!.*/, '');
} else {
return content;
}
};
/**
* This is like `writeCacheFile` but with an additional sanity checksum. We
* cannot use the same technique for source maps because we expose source map
* cache file paths directly to callsites, with the expectation they can read
* it right away. This is not a great system, because source map cache file
* could get corrupted, out-of-sync, etc.
*/
function writeCodeCacheFile(cachePath, code) {
const checksum = (0, _crypto().createHash)('md5').update(code).digest('hex');
writeCacheFile(cachePath, checksum + '\n' + code);
}
/**
* Read counterpart of `writeCodeCacheFile`. We verify that the content of the
* file matches the checksum, in case some kind of corruption happened. This
* could happen if an older version of `jest-runtime` writes non-atomically to
* the same cache, for example.
*/
function readCodeCacheFile(cachePath) {
const content = readCacheFile(cachePath);
if (content == null) {
return null;
}
const code = content.substr(33);
const checksum = (0, _crypto().createHash)('md5').update(code).digest('hex');
if (checksum === content.substr(0, 32)) {
return code;
}
return null;
}
/**
* Writing to the cache atomically relies on 'rename' being atomic on most
* file systems. Doing atomic write reduces the risk of corruption by avoiding
* two processes to write to the same file at the same time. It also reduces
* the risk of reading a file that's being overwritten at the same time.
*/
const writeCacheFile = (cachePath, fileData) => {
try {
(0, _writeFileAtomic().sync)(cachePath, fileData, {
encoding: 'utf8',
fsync: false
});
} catch (e) {
if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
return;
}
e.message =
'jest: failed to cache transform results in: ' +
cachePath +
'\nFailure message: ' +
e.message;
removeFile(cachePath);
throw e;
}
};
/**
* On Windows, renames are not atomic, leading to EPERM exceptions when two
* processes attempt to rename to the same target file at the same time.
* If the target file exists we can be reasonably sure another process has
* legitimately won a cache write race and ignore the error.
*/
const cacheWriteErrorSafeToIgnore = (e, cachePath) =>
process.platform === 'win32' &&
e.code === 'EPERM' &&
fs().existsSync(cachePath);
const readCacheFile = cachePath => {
if (!fs().existsSync(cachePath)) {
return null;
}
let fileData;
try {
fileData = fs().readFileSync(cachePath, 'utf8');
} catch (e) {
e.message =
'jest: failed to read cache file: ' +
cachePath +
'\nFailure message: ' +
e.message;
removeFile(cachePath);
throw e;
}
if (fileData == null) {
// We must have somehow created the file but failed to write to it,
// let's delete it and retry.
removeFile(cachePath);
}
return fileData;
};
const getScriptCacheKey = (filename, instrument) => {
const mtime = fs().statSync(filename).mtime;
return filename + '_' + mtime.getTime() + (instrument ? '_instrumented' : '');
};
const calcIgnorePatternRegExp = config => {
if (
!config.transformIgnorePatterns ||
config.transformIgnorePatterns.length === 0
) {
return undefined;
}
return new RegExp(config.transformIgnorePatterns.join('|'));
};
const calcTransformRegExp = config => {
if (!config.transform.length) {
return undefined;
}
const transformRegexp = [];
for (let i = 0; i < config.transform.length; i++) {
transformRegexp.push([
new RegExp(config.transform[i][0]),
config.transform[i][1],
config.transform[i][2]
]);
}
return transformRegexp;
};

View 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.
*/
interface ErrorWithCodeFrame extends Error {
codeFrame?: string;
}
export default function handlePotentialSyntaxError(e: ErrorWithCodeFrame): ErrorWithCodeFrame;
export declare function enhanceUnexpectedTokenMessage(e: Error): Error;
export {};

View file

@ -0,0 +1,75 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = handlePotentialSyntaxError;
exports.enhanceUnexpectedTokenMessage = enhanceUnexpectedTokenMessage;
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* 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 DOT = ' \u2022 ';
function handlePotentialSyntaxError(e) {
if (e.codeFrame) {
e.stack = e.message + '\n' + e.codeFrame;
}
if (
// `instanceof` might come from the wrong context
e.name === 'SyntaxError' &&
(e.message.includes('Unexpected token') ||
e.message.includes('Cannot use import')) &&
!e.message.includes(' expected')
) {
throw enhanceUnexpectedTokenMessage(e);
}
return e;
}
function enhanceUnexpectedTokenMessage(e) {
e.stack =
`${_chalk().default.bold.red('Jest encountered an unexpected token')}
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${_chalk().default.bold(
'"transformIgnorePatterns"'
)} in your config.
${DOT}If you need a custom transformation specify a ${_chalk().default.bold(
'"transform"'
)} option in your config.
${DOT}If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the ${_chalk().default.bold(
'"moduleNameMapper"'
)} config option.
You'll find more details and examples of these config options in the docs:
${_chalk().default.cyan('https://jestjs.io/docs/en/configuration.html')}
${_chalk().default.bold.red('Details:')}
` + e.stack;
return e;
}

10
node_modules/@jest/transform/build/index.d.ts generated vendored Normal file
View 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.
*/
export { default as ScriptTransformer, createTranspilingRequire, } from './ScriptTransformer';
export { default as shouldInstrument } from './shouldInstrument';
export type { CacheKeyOptions, Transformer, ShouldInstrumentOptions, Options as TransformationOptions, TransformOptions, TransformResult, TransformedSource, } from './types';
export { default as handlePotentialSyntaxError } from './enhanceUnexpectedTokenMessage';

85
node_modules/@jest/transform/build/index.js generated vendored Normal file
View file

@ -0,0 +1,85 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
Object.defineProperty(exports, 'ScriptTransformer', {
enumerable: true,
get: function () {
return _ScriptTransformer.default;
}
});
Object.defineProperty(exports, 'createTranspilingRequire', {
enumerable: true,
get: function () {
return _ScriptTransformer.createTranspilingRequire;
}
});
Object.defineProperty(exports, 'shouldInstrument', {
enumerable: true,
get: function () {
return _shouldInstrument.default;
}
});
Object.defineProperty(exports, 'handlePotentialSyntaxError', {
enumerable: true,
get: function () {
return _enhanceUnexpectedTokenMessage.default;
}
});
var _ScriptTransformer = _interopRequireWildcard(
require('./ScriptTransformer')
);
var _shouldInstrument = _interopRequireDefault(require('./shouldInstrument'));
var _enhanceUnexpectedTokenMessage = _interopRequireDefault(
require('./enhanceUnexpectedTokenMessage')
);
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;
}

View file

@ -0,0 +1,9 @@
/**
* 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';
import type { ShouldInstrumentOptions } from './types';
export default function shouldInstrument(filename: Config.Path, options: ShouldInstrumentOptions, config: Config.ProjectConfig): boolean;

207
node_modules/@jest/transform/build/shouldInstrument.js generated vendored Normal file
View file

@ -0,0 +1,207 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = shouldInstrument;
function path() {
const data = _interopRequireWildcard(require('path'));
path = function () {
return data;
};
return data;
}
function _jestRegexUtil() {
const data = require('jest-regex-util');
_jestRegexUtil = function () {
return data;
};
return data;
}
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
function _micromatch() {
const data = _interopRequireDefault(require('micromatch'));
_micromatch = function () {
return data;
};
return data;
}
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 MOCKS_PATTERN = new RegExp(
(0, _jestRegexUtil().escapePathForRegex)(
path().sep + '__mocks__' + path().sep
)
);
const cachedRegexes = new Map();
const getRegex = regexStr => {
if (!cachedRegexes.has(regexStr)) {
cachedRegexes.set(regexStr, new RegExp(regexStr));
}
const regex = cachedRegexes.get(regexStr); // prevent stateful regexes from breaking, just in case
regex.lastIndex = 0;
return regex;
};
function shouldInstrument(filename, options, config) {
if (!options.collectCoverage) {
return false;
}
if (
config.forceCoverageMatch.length &&
_micromatch().default.any(filename, config.forceCoverageMatch)
) {
return true;
}
if (
!config.testPathIgnorePatterns.some(pattern =>
getRegex(pattern).test(filename)
)
) {
if (config.testRegex.some(regex => new RegExp(regex).test(filename))) {
return false;
}
if (
(0, _jestUtil().globsToMatcher)(config.testMatch)(
(0, _jestUtil().replacePathSepForGlob)(filename)
)
) {
return false;
}
}
if (
// This configuration field contains an object in the form of:
// {'path/to/file.js': true}
options.collectCoverageOnlyFrom &&
!options.collectCoverageOnlyFrom[filename]
) {
return false;
}
if (
// still cover if `only` is specified
!options.collectCoverageOnlyFrom &&
options.collectCoverageFrom.length &&
!(0, _jestUtil().globsToMatcher)(options.collectCoverageFrom)(
(0, _jestUtil().replacePathSepForGlob)(
path().relative(config.rootDir, filename)
)
)
) {
return false;
}
if (
config.coveragePathIgnorePatterns.some(pattern => !!filename.match(pattern))
) {
return false;
}
if (config.globalSetup === filename) {
return false;
}
if (config.globalTeardown === filename) {
return false;
}
if (config.setupFiles.includes(filename)) {
return false;
}
if (config.setupFilesAfterEnv.includes(filename)) {
return false;
}
if (MOCKS_PATTERN.test(filename)) {
return false;
}
if (options.changedFiles && !options.changedFiles.has(filename)) {
if (!options.sourcesRelatedToTestsInChangedFiles) {
return false;
}
if (!options.sourcesRelatedToTestsInChangedFiles.has(filename)) {
return false;
}
}
return true;
}

42
node_modules/@jest/transform/build/types.d.ts generated vendored Normal file
View file

@ -0,0 +1,42 @@
/**
* 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 { RawSourceMap } from 'source-map';
import type { Config, TransformTypes } from '@jest/types';
export declare type ShouldInstrumentOptions = Pick<Config.GlobalConfig, 'collectCoverage' | 'collectCoverageFrom' | 'collectCoverageOnlyFrom' | 'coverageProvider'> & {
changedFiles?: Set<Config.Path>;
sourcesRelatedToTestsInChangedFiles?: Set<Config.Path>;
};
export declare type Options = ShouldInstrumentOptions & Partial<{
isCoreModule: boolean;
isInternalModule: boolean;
supportsDynamicImport: boolean;
supportsStaticESM: boolean;
}>;
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> {
version: number;
}
export declare type TransformedSource = {
code: string;
map?: FixedRawSourceMap | string | null;
} | string;
export declare type TransformResult = TransformTypes.TransformResult;
export interface TransformOptions {
instrument: boolean;
supportsDynamicImport?: boolean;
supportsStaticESM?: boolean;
}
export interface CacheKeyOptions extends TransformOptions {
config: Config.ProjectConfig;
rootDir: string;
}
export interface Transformer {
canInstrument?: boolean;
createTransformer?: (options?: any) => Transformer;
getCacheKey?: (fileData: string, filePath: Config.Path, configStr: string, options: CacheKeyOptions) => string;
process: (sourceText: string, sourcePath: Config.Path, config: Config.ProjectConfig, options?: TransformOptions) => TransformedSource;
}
export {};

1
node_modules/@jest/transform/build/types.js generated vendored Normal file
View file

@ -0,0 +1 @@
'use strict';

46
node_modules/@jest/transform/package.json generated vendored Normal file
View file

@ -0,0 +1,46 @@
{
"name": "@jest/transform",
"version": "26.3.0",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-transform"
},
"license": "MIT",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"@babel/core": "^7.1.0",
"@jest/types": "^26.3.0",
"babel-plugin-istanbul": "^6.0.0",
"chalk": "^4.0.0",
"convert-source-map": "^1.4.0",
"fast-json-stable-stringify": "^2.0.0",
"graceful-fs": "^4.2.4",
"jest-haste-map": "^26.3.0",
"jest-regex-util": "^26.0.0",
"jest-util": "^26.3.0",
"micromatch": "^4.0.2",
"pirates": "^4.0.1",
"slash": "^3.0.0",
"source-map": "^0.6.1",
"write-file-atomic": "^3.0.0"
},
"devDependencies": {
"@types/babel__core": "^7.1.0",
"@types/convert-source-map": "^1.5.1",
"@types/fast-json-stable-stringify": "^2.0.0",
"@types/graceful-fs": "^4.1.2",
"@types/micromatch": "^4.0.0",
"@types/write-file-atomic": "^3.0.0",
"dedent": "^0.7.0",
"jest-snapshot-serializer-raw": "^1.1.0"
},
"engines": {
"node": ">= 10.14.2"
},
"publishConfig": {
"access": "public"
},
"gitHead": "3a7e06fe855515a848241bb06a6f6e117847443d"
}