This commit is contained in:
Domen Kožar 2019-11-13 17:14:48 +01:00
parent d1407282e6
commit 08403cd828
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
6774 changed files with 1602535 additions and 1 deletions

9
node_modules/jest-cli/build/init/constants.d.ts generated vendored Normal file
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.
*/
export declare const PACKAGE_JSON = "package.json";
export declare const JEST_CONFIG = "jest.config.js";
//# sourceMappingURL=constants.d.ts.map

1
node_modules/jest-cli/build/init/constants.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/init/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,WAAW,mBAAmB,CAAC"}

17
node_modules/jest-cli/build/init/constants.js generated vendored Normal file
View file

@ -0,0 +1,17 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.JEST_CONFIG = exports.PACKAGE_JSON = 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 PACKAGE_JSON = 'package.json';
exports.PACKAGE_JSON = PACKAGE_JSON;
const JEST_CONFIG = 'jest.config.js';
exports.JEST_CONFIG = JEST_CONFIG;

13
node_modules/jest-cli/build/init/errors.d.ts generated vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* 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);
}
//# sourceMappingURL=errors.d.ts.map

1
node_modules/jest-cli/build/init/errors.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/init/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAED,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,eAAe,EAAE,MAAM;CAQpC"}

35
node_modules/jest-cli/build/init/errors.js generated vendored Normal file
View 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;

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.
*/
declare const generateConfigFile: (results: Record<string, unknown>) => string;
export default generateConfigFile;
//# sourceMappingURL=generate_config_file.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"generate_config_file.d.ts","sourceRoot":"","sources":["../../src/init/generate_config_file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA4BH,QAAA,MAAM,kBAAkB,8CAgDvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}

View file

@ -0,0 +1,89 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _jestConfig() {
const data = require('jest-config');
_jestConfig = function _jestConfig() {
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 => {
const coverage = results.coverage,
clearMocks = results.clearMocks,
environment = results.environment;
const overrides = {};
if (coverage) {
Object.assign(overrides, {
coverageDirectory: 'coverage'
});
}
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, '// '));
}
}
return (
'// For a detailed explanation regarding each configuration property, visit:\n' +
'// https://jestjs.io/docs/en/configuration.html\n\n' +
'module.exports = {\n' +
properties.join('\n') +
'};\n'
);
};
var _default = generateConfigFile;
exports.default = _default;

9
node_modules/jest-cli/build/init/index.d.ts generated vendored Normal file
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.
*/
declare const _default: (rootDir?: string) => Promise<void>;
export default _default;
//# sourceMappingURL=index.d.ts.map

1
node_modules/jest-cli/build/init/index.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/init/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAqBH,wBAmGE"}

255
node_modules/jest-cli/build/init/index.js generated vendored Normal file
View file

@ -0,0 +1,255 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = void 0;
function _fs() {
const data = _interopRequireDefault(require('fs'));
_fs = function _fs() {
return data;
};
return data;
}
function _path() {
const data = _interopRequireDefault(require('path'));
_path = function _path() {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function _chalk() {
return data;
};
return data;
}
function _prompts() {
const data = _interopRequireDefault(require('prompts'));
_prompts = function _prompts() {
return data;
};
return data;
}
function _realpathNative() {
const data = require('realpath-native');
_realpathNative = function _realpathNative() {
return data;
};
return data;
}
var _questions = _interopRequireWildcard(require('./questions'));
var _errors = require('./errors');
var _constants = require('./constants');
var _generate_config_file = _interopRequireDefault(
require('./generate_config_file')
);
var _modify_package_json = _interopRequireDefault(
require('./modify_package_json')
);
function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc =
Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
}
newObj.default = obj;
return newObj;
}
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function() {
var self = this,
args = arguments;
return new Promise(function(resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
}
_next(undefined);
});
};
}
var _default =
/*#__PURE__*/
(function() {
var _ref = _asyncToGenerator(function*(
rootDir = (0, _realpathNative().sync)(process.cwd())
) {
// prerequisite checks
const projectPackageJsonPath = _path().default.join(
rootDir,
_constants.PACKAGE_JSON
);
const jestConfigPath = _path().default.join(
rootDir,
_constants.JEST_CONFIG
);
if (!_fs().default.existsSync(projectPackageJsonPath)) {
throw new _errors.NotFoundPackageJsonError(rootDir);
}
const questions = _questions.default.slice(0);
let hasJestProperty = false;
let hasJestConfig = false;
let projectPackageJson;
try {
projectPackageJson = JSON.parse(
_fs().default.readFileSync(projectPackageJsonPath, 'utf-8')
);
} catch (error) {
throw new _errors.MalformedPackageJsonError(projectPackageJsonPath);
}
if (projectPackageJson.jest) {
hasJestProperty = true;
}
if (_fs().default.existsSync(jestConfigPath)) {
hasJestConfig = true;
}
if (hasJestProperty || hasJestConfig) {
const result = yield (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-ignore: Return type cannot be object - faulty typings
const results = yield (0, _prompts().default)(questions, {
onCancel: () => {
promptAborted = true;
}
});
if (promptAborted) {
console.log();
console.log('Aborting...');
return;
}
const shouldModifyScripts = results.scripts;
if (shouldModifyScripts || hasJestProperty) {
const modifiedPackageJson = (0, _modify_package_json.default)({
projectPackageJson,
shouldModifyScripts
});
_fs().default.writeFileSync(
projectPackageJsonPath,
modifiedPackageJson
);
console.log('');
console.log(
`✏️ Modified ${_chalk().default.cyan(projectPackageJsonPath)}`
);
}
const generatedConfig = (0, _generate_config_file.default)(results);
_fs().default.writeFileSync(jestConfigPath, generatedConfig);
console.log('');
console.log(
`📝 Configuration file created at ${_chalk().default.cyan(
jestConfigPath
)}`
);
});
return function() {
return _ref.apply(this, arguments);
};
})();
exports.default = _default;

View file

@ -0,0 +1,13 @@
/**
* 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 { ProjectPackageJson } from './types';
declare const modifyPackageJson: ({ projectPackageJson, shouldModifyScripts, }: {
projectPackageJson: ProjectPackageJson;
shouldModifyScripts: boolean;
}) => string;
export default modifyPackageJson;
//# sourceMappingURL=modify_package_json.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"modify_package_json.d.ts","sourceRoot":"","sources":["../../src/init/modify_package_json.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAE3C,QAAA,MAAM,iBAAiB;;;YAgBtB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}

View 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;

11
node_modules/jest-cli/build/init/questions.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
/**
* 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 { PromptObject } from 'prompts';
declare const defaultQuestions: Array<PromptObject>;
export default defaultQuestions;
export declare const testScriptQuestion: PromptObject;
//# sourceMappingURL=questions.d.ts.map

1
node_modules/jest-cli/build/init/questions.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../../src/init/questions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,YAAY,CAuBzC,CAAC;AAEF,eAAe,gBAAgB,CAAC;AAEhC,eAAO,MAAM,kBAAkB,EAAE,YAMhC,CAAC"}

53
node_modules/jest-cli/build/init/questions.js generated vendored Normal file
View file

@ -0,0 +1,53 @@
'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 = [
{
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'
},
{
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
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.
*/
import { Config } from '@jest/types';
export declare type ProjectPackageJson = {
jest?: Partial<Config.InitialOptions>;
scripts?: Record<string, string>;
};
//# sourceMappingURL=types.d.ts.map

1
node_modules/jest-cli/build/init/types.d.ts.map generated vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/init/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC"}

1
node_modules/jest-cli/build/init/types.js generated vendored Normal file
View file

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