@nx/jest 21.0.0-beta.8 → 21.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +1 -3
- package/migrations.json +7 -15
- package/package.json +3 -3
- package/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.js +86 -0
- package/src/utils/config/get-jest-projects.d.ts +0 -22
- package/src/utils/config/get-jest-projects.js +0 -58
- package/src/generators/configuration/lib/update-jestconfig.d.ts +0 -3
- package/src/generators/configuration/lib/update-jestconfig.js +0 -25
- package/src/migrations/update-17-1-0/move-options-to-target-defaults.js +0 -117
- /package/src/migrations/{update-17-1-0/move-options-to-target-defaults.d.ts → update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.d.ts} +0 -0
package/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare const jestProjectGenerator: typeof configurationGenerator;
|
|
|
5
5
|
export { addPropertyToJestConfig, removePropertyFromJestConfig, } from './src/utils/config/update-config';
|
|
6
6
|
export { jestConfigObjectAst } from './src/utils/config/functions';
|
|
7
7
|
export { jestInitGenerator } from './src/generators/init/init';
|
|
8
|
-
export {
|
|
8
|
+
export { getJestProjectsAsync } from './src/utils/config/get-jest-projects';
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getJestProjectsAsync = exports.jestInitGenerator = exports.jestConfigObjectAst = exports.removePropertyFromJestConfig = exports.addPropertyToJestConfig = exports.jestProjectGenerator = exports.configurationGenerator = void 0;
|
|
4
4
|
const configuration_1 = require("./src/generators/configuration/configuration");
|
|
5
5
|
Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
|
|
6
6
|
// Exported for backwards compatibility in case a plugin is using the old name.
|
|
@@ -14,6 +14,4 @@ Object.defineProperty(exports, "jestConfigObjectAst", { enumerable: true, get: f
|
|
|
14
14
|
var init_1 = require("./src/generators/init/init");
|
|
15
15
|
Object.defineProperty(exports, "jestInitGenerator", { enumerable: true, get: function () { return init_1.jestInitGenerator; } });
|
|
16
16
|
var get_jest_projects_1 = require("./src/utils/config/get-jest-projects");
|
|
17
|
-
Object.defineProperty(exports, "getJestProjects", { enumerable: true, get: function () { return get_jest_projects_1.getJestProjects; } });
|
|
18
17
|
Object.defineProperty(exports, "getJestProjectsAsync", { enumerable: true, get: function () { return get_jest_projects_1.getJestProjectsAsync; } });
|
|
19
|
-
Object.defineProperty(exports, "getNestedJestProjects", { enumerable: true, get: function () { return get_jest_projects_1.getNestedJestProjects; } });
|
package/migrations.json
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"move-options-to-target-defaults": {
|
|
4
|
-
"version": "17.1.0-beta.2",
|
|
5
|
-
"description": "Move jest executor options to nx.json targetDefaults",
|
|
6
|
-
"implementation": "./src/migrations/update-17-1-0/move-options-to-target-defaults"
|
|
7
|
-
},
|
|
8
3
|
"replace-getJestProjects-with-getJestProjectsAsync": {
|
|
9
4
|
"cli": "nx",
|
|
10
5
|
"version": "20.0.0-beta.5",
|
|
11
|
-
"description": "
|
|
6
|
+
"description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.",
|
|
12
7
|
"implementation": "./src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync"
|
|
8
|
+
},
|
|
9
|
+
"replace-getJestProjects-with-getJestProjectsAsync-v21": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "21.0.0-beta.9",
|
|
12
|
+
"description": "Replace usage of `getJestProjects` with `getJestProjectsAsync`.",
|
|
13
|
+
"implementation": "./src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"packageJsonUpdates": {
|
|
16
|
-
"17.2.0": {
|
|
17
|
-
"version": "17.2.0-beta.2",
|
|
18
|
-
"packages": {
|
|
19
|
-
"@types/node": {
|
|
20
|
-
"version": "18.16.9",
|
|
21
|
-
"alwaysAddToPackageJson": false
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
17
|
"19.2.0": {
|
|
26
18
|
"version": "19.2.0-beta.0",
|
|
27
19
|
"packages": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "21.0.0-beta.
|
|
3
|
+
"version": "21.0.0-beta.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Jest contains executors and generators allowing your workspace to use the powerful Jest testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jest/reporters": "^29.4.1",
|
|
39
39
|
"@jest/test-result": "^29.4.1",
|
|
40
|
-
"@nx/devkit": "21.0.0-beta.
|
|
41
|
-
"@nx/js": "21.0.0-beta.
|
|
40
|
+
"@nx/devkit": "21.0.0-beta.9",
|
|
41
|
+
"@nx/js": "21.0.0-beta.9",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"identity-obj-proxy": "3.0.0",
|
|
44
44
|
"jest-config": "^29.4.1",
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// go through the jest.config files
|
|
3
|
+
// see if it imports from @nx/jest and if it uses getJestProjects
|
|
4
|
+
// replace getJestProjects with getJestProjectsAsync
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = update;
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
9
|
+
let tsModule;
|
|
10
|
+
async function update(tree) {
|
|
11
|
+
if (!tsModule) {
|
|
12
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
13
|
+
}
|
|
14
|
+
const jestConfigPaths = await (0, devkit_1.globAsync)(tree, [
|
|
15
|
+
'**/jest.config.{cjs,mjs,js,cts,mts,ts}',
|
|
16
|
+
]);
|
|
17
|
+
jestConfigPaths.forEach((jestConfigPath) => {
|
|
18
|
+
const oldContent = tree.read(jestConfigPath).toString();
|
|
19
|
+
if (oldContent?.includes('projects: getJestProjects()')) {
|
|
20
|
+
let sourceFile = tsModule.createSourceFile(jestConfigPath, oldContent, tsModule.ScriptTarget.Latest, true);
|
|
21
|
+
// find `require('@nx/jest')` or `import { getJestProjects } from '@nx/jest`
|
|
22
|
+
const requireStatement = sourceFile.statements.find((statement) => tsModule.isVariableStatement(statement) &&
|
|
23
|
+
statement.declarationList.declarations.some((declaration) => tsModule.isCallExpression(declaration.initializer) &&
|
|
24
|
+
tsModule.isIdentifier(declaration.initializer.expression) &&
|
|
25
|
+
declaration.initializer.expression.escapedText === 'require' &&
|
|
26
|
+
tsModule.isStringLiteral(declaration.initializer.arguments[0]) &&
|
|
27
|
+
declaration.initializer.arguments[0].text === '@nx/jest'));
|
|
28
|
+
const importStatement = sourceFile.statements.find((statement) => tsModule.isImportDeclaration(statement) &&
|
|
29
|
+
statement.moduleSpecifier.getText() === `'@nx/jest'`);
|
|
30
|
+
if (requireStatement || importStatement) {
|
|
31
|
+
// find `module.exports` statement with `projects: getJestProjects()`
|
|
32
|
+
const moduleExports = sourceFile.statements.find((statement) => tsModule.isExpressionStatement(statement) &&
|
|
33
|
+
tsModule.isBinaryExpression(statement.expression) &&
|
|
34
|
+
tsModule.isPropertyAccessExpression(statement.expression.left) &&
|
|
35
|
+
tsModule.isObjectLiteralExpression(statement.expression.right) &&
|
|
36
|
+
statement.expression.operatorToken.kind ===
|
|
37
|
+
tsModule.SyntaxKind.EqualsToken &&
|
|
38
|
+
tsModule.isIdentifier(statement.expression.left.expression) &&
|
|
39
|
+
statement.expression.left.expression.escapedText === 'module' &&
|
|
40
|
+
tsModule.isIdentifier(statement.expression.left.name) &&
|
|
41
|
+
statement.expression.left.name.escapedText === 'exports' &&
|
|
42
|
+
statement.expression.right.properties.some((property) => tsModule.isPropertyAssignment(property) &&
|
|
43
|
+
tsModule.isIdentifier(property.name) &&
|
|
44
|
+
property.name.escapedText === 'projects' &&
|
|
45
|
+
tsModule.isCallExpression(property.initializer) &&
|
|
46
|
+
tsModule.isIdentifier(property.initializer.expression) &&
|
|
47
|
+
property.initializer.expression.escapedText ===
|
|
48
|
+
'getJestProjects'));
|
|
49
|
+
if (moduleExports) {
|
|
50
|
+
// replace getJestProjects with getJestProjectsAsync in export statement
|
|
51
|
+
const rightExpression = moduleExports.expression.right.getText();
|
|
52
|
+
const newExpression = rightExpression.replace('getJestProjects()', 'await getJestProjectsAsync()');
|
|
53
|
+
const newStatement = `module.exports = async () => (${newExpression});`;
|
|
54
|
+
let newContent = oldContent.replace(moduleExports.getText(), newStatement);
|
|
55
|
+
// replace getJestProjects with getJestProjectsAsync in import statement
|
|
56
|
+
newContent = newContent.replace('getJestProjects', 'getJestProjectsAsync');
|
|
57
|
+
tree.write(jestConfigPath, newContent);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// find `export default` statement with `projects: getJestProjects()`
|
|
61
|
+
const exportAssignment = sourceFile.statements.find((statement) => tsModule.isExportAssignment(statement));
|
|
62
|
+
const defaultExport = exportAssignment?.expression &&
|
|
63
|
+
tsModule.isObjectLiteralExpression(exportAssignment?.expression)
|
|
64
|
+
? exportAssignment?.expression
|
|
65
|
+
: null;
|
|
66
|
+
const projectProperty = defaultExport?.properties.find((property) => tsModule.isPropertyAssignment(property) &&
|
|
67
|
+
property.name.getText() === 'projects' &&
|
|
68
|
+
tsModule.isCallExpression(property.initializer) &&
|
|
69
|
+
tsModule.isIdentifier(property.initializer.expression) &&
|
|
70
|
+
property.initializer.expression.escapedText === 'getJestProjects');
|
|
71
|
+
if (projectProperty) {
|
|
72
|
+
// replace getJestProjects with getJestProjectsAsync in export statement
|
|
73
|
+
const newExpression = defaultExport
|
|
74
|
+
.getText()
|
|
75
|
+
.replace('getJestProjects()', 'await getJestProjectsAsync()');
|
|
76
|
+
const newStatement = `export default async () => (${newExpression});`;
|
|
77
|
+
let newContent = oldContent.replace(exportAssignment.getText(), newStatement);
|
|
78
|
+
// replace getJestProjects with getJestProjectsAsync in import statement
|
|
79
|
+
newContent = newContent.replace('getJestProjects', 'getJestProjectsAsync');
|
|
80
|
+
tree.write(jestConfigPath, newContent);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO(v21): Remove this function
|
|
3
|
-
* @deprecated To get projects use {@link getJestProjectsAsync} instead. This will be removed in v21.
|
|
4
|
-
* Get a list of paths to all the jest config files
|
|
5
|
-
* using the Nx Jest executor.
|
|
6
|
-
*
|
|
7
|
-
* This is used to configure Jest multi-project support. To support projects
|
|
8
|
-
* using inferred targets @see getJestProjectsAsync
|
|
9
|
-
*
|
|
10
|
-
* To add a project not using the Nx Jest executor:
|
|
11
|
-
* export default {
|
|
12
|
-
* projects: [...getJestProjects(), '<rootDir>/path/to/jest.config.ts'];
|
|
13
|
-
* }
|
|
14
|
-
*
|
|
15
|
-
**/
|
|
16
|
-
export declare function getJestProjects(): string[];
|
|
17
|
-
/**
|
|
18
|
-
* a list of nested projects that have jest configured
|
|
19
|
-
* to be used in the testPathIgnorePatterns property of a given jest config
|
|
20
|
-
* https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring
|
|
21
|
-
* */
|
|
22
|
-
export declare function getNestedJestProjects(): string[];
|
|
23
1
|
/**
|
|
24
2
|
* Get a list of paths to all the jest config files
|
|
25
3
|
* using the Nx Jest executor and `@nx/run:commands`
|
|
@@ -1,70 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJestProjects = getJestProjects;
|
|
4
|
-
exports.getNestedJestProjects = getNestedJestProjects;
|
|
5
3
|
exports.getJestProjectsAsync = getJestProjectsAsync;
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const file_utils_1 = require("nx/src/project-graph/file-utils");
|
|
8
5
|
const path_1 = require("path");
|
|
9
6
|
const yargs = require("yargs-parser");
|
|
10
7
|
function getJestConfigProjectPath(projectJestConfigPath) {
|
|
11
8
|
return (0, path_1.join)('<rootDir>', projectJestConfigPath);
|
|
12
9
|
}
|
|
13
|
-
/**
|
|
14
|
-
* TODO(v21): Remove this function
|
|
15
|
-
* @deprecated To get projects use {@link getJestProjectsAsync} instead. This will be removed in v21.
|
|
16
|
-
* Get a list of paths to all the jest config files
|
|
17
|
-
* using the Nx Jest executor.
|
|
18
|
-
*
|
|
19
|
-
* This is used to configure Jest multi-project support. To support projects
|
|
20
|
-
* using inferred targets @see getJestProjectsAsync
|
|
21
|
-
*
|
|
22
|
-
* To add a project not using the Nx Jest executor:
|
|
23
|
-
* export default {
|
|
24
|
-
* projects: [...getJestProjects(), '<rootDir>/path/to/jest.config.ts'];
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
**/
|
|
28
|
-
function getJestProjects() {
|
|
29
|
-
const ws = (0, file_utils_1.readWorkspaceConfig)({
|
|
30
|
-
format: 'nx',
|
|
31
|
-
});
|
|
32
|
-
const jestConfigurationSet = new Set();
|
|
33
|
-
for (const projectConfig of Object.values(ws.projects)) {
|
|
34
|
-
if (!projectConfig.targets) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
for (const targetConfiguration of Object.values(projectConfig.targets)) {
|
|
38
|
-
if (targetConfiguration.executor !== '@nx/jest:jest' &&
|
|
39
|
-
targetConfiguration.executor !== '@nrwl/jest:jest') {
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (targetConfiguration.options?.jestConfig) {
|
|
43
|
-
jestConfigurationSet.add(getJestConfigProjectPath(targetConfiguration.options.jestConfig));
|
|
44
|
-
}
|
|
45
|
-
if (targetConfiguration.configurations) {
|
|
46
|
-
for (const configurationObject of Object.values(targetConfiguration.configurations)) {
|
|
47
|
-
if (configurationObject.jestConfig) {
|
|
48
|
-
jestConfigurationSet.add(getJestConfigProjectPath(configurationObject.jestConfig));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return Array.from(jestConfigurationSet);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* a list of nested projects that have jest configured
|
|
58
|
-
* to be used in the testPathIgnorePatterns property of a given jest config
|
|
59
|
-
* https://jestjs.io/docs/configuration#testpathignorepatterns-arraystring
|
|
60
|
-
* */
|
|
61
|
-
function getNestedJestProjects() {
|
|
62
|
-
// TODO(caleb): get current project path and list of all projects and their rootDir
|
|
63
|
-
// return a list of all projects that are nested in the current projects path
|
|
64
|
-
// always include node_modules as that's the default
|
|
65
|
-
const allProjects = getJestProjects();
|
|
66
|
-
return ['/node_modules/'];
|
|
67
|
-
}
|
|
68
10
|
/**
|
|
69
11
|
* Get a list of paths to all the jest config files
|
|
70
12
|
* using the Nx Jest executor and `@nx/run:commands`
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateJestConfig = updateJestConfig;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const config_file_1 = require("../../../utils/config/config-file");
|
|
6
|
-
const update_config_1 = require("../../../utils/config/update-config");
|
|
7
|
-
function isUsingUtilityFunction(host) {
|
|
8
|
-
const rootConfig = (0, config_file_1.findRootJestConfig)(host);
|
|
9
|
-
if (!rootConfig) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
const rootConfigContent = host.read(rootConfig, 'utf-8');
|
|
13
|
-
return (rootConfigContent.includes('getJestProjects()') ||
|
|
14
|
-
rootConfigContent.includes('getJestProjectsAsync()'));
|
|
15
|
-
}
|
|
16
|
-
function updateJestConfig(host, options) {
|
|
17
|
-
if (isUsingUtilityFunction(host)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const project = (0, devkit_1.readProjectConfiguration)(host, options.project);
|
|
21
|
-
const rootConfig = (0, config_file_1.findRootJestConfig)(host);
|
|
22
|
-
if (rootConfig) {
|
|
23
|
-
(0, update_config_1.addPropertyToJestConfig)(host, (0, config_file_1.findRootJestConfig)(host), 'projects', `<rootDir>/${project.root}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = update;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
const project_configuration_utils_1 = require("nx/src/project-graph/utils/project-configuration-utils");
|
|
7
|
-
async function update(tree) {
|
|
8
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
9
|
-
// Don't override anything if there are already target defaults for jest
|
|
10
|
-
if (nxJson.targetDefaults?.['@nx/jest:jest']) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
nxJson.targetDefaults ??= {};
|
|
14
|
-
/**
|
|
15
|
-
* A set of targets which does not use any other executors
|
|
16
|
-
*/
|
|
17
|
-
const jestTargets = new Set();
|
|
18
|
-
const graph = await (0, devkit_1.createProjectGraphAsync)();
|
|
19
|
-
(0, executor_options_utils_1.forEachExecutorOptionsInGraph)(graph, '@nx/jest:jest', (value, proj, targetName) => {
|
|
20
|
-
jestTargets.add(targetName);
|
|
21
|
-
});
|
|
22
|
-
// Workspace does not use jest?
|
|
23
|
-
if (jestTargets.size === 0) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// Use the project graph so targets which are inferred are considered
|
|
27
|
-
const projects = graph.nodes;
|
|
28
|
-
const projectMap = (0, devkit_1.getProjects)(tree);
|
|
29
|
-
const jestDefaults = (nxJson.targetDefaults['@nx/jest:jest'] = {});
|
|
30
|
-
// All jest targets have the same name
|
|
31
|
-
if (jestTargets.size === 1) {
|
|
32
|
-
const targetName = Array.from(jestTargets)[0];
|
|
33
|
-
if (nxJson.targetDefaults[targetName]) {
|
|
34
|
-
Object.assign(jestDefaults, nxJson.targetDefaults[targetName]);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
jestDefaults.cache ??= true;
|
|
38
|
-
const inputs = ['default'];
|
|
39
|
-
inputs.push(nxJson.namedInputs?.production ? '^production' : '^default');
|
|
40
|
-
if (tree.exists('jest.preset.js')) {
|
|
41
|
-
inputs.push('{workspaceRoot}/jest.preset.js');
|
|
42
|
-
}
|
|
43
|
-
jestDefaults.inputs ??= inputs;
|
|
44
|
-
// Remember if there were already defaults so we don't assume the executor default
|
|
45
|
-
const passWithNoTestsPreviouslyInDefaults = jestDefaults.options?.passWithNoTests !== undefined;
|
|
46
|
-
const ciCiPreviouslyInDefaults = jestDefaults.configurations?.ci?.ci !== undefined;
|
|
47
|
-
const ciCodeCoveragePreviouslyInDefaults = jestDefaults.configurations?.ci?.codeCoverage !== undefined;
|
|
48
|
-
jestDefaults.options ??= {};
|
|
49
|
-
jestDefaults.options.passWithNoTests ??= true;
|
|
50
|
-
jestDefaults.configurations ??= {};
|
|
51
|
-
jestDefaults.configurations.ci ??= {};
|
|
52
|
-
jestDefaults.configurations.ci.ci ??= true;
|
|
53
|
-
jestDefaults.configurations.ci.codeCoverage ??= true;
|
|
54
|
-
// Cleanup old target defaults
|
|
55
|
-
for (const [targetDefaultKey, targetDefault] of Object.entries(nxJson.targetDefaults)) {
|
|
56
|
-
if (!isTargetDefaultUsed(targetDefault, nxJson.targetDefaults, projects, projectMap)) {
|
|
57
|
-
delete nxJson.targetDefaults[targetDefaultKey];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
61
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/jest:jest', (value, proj, targetName, configuration) => {
|
|
62
|
-
const projConfig = projectMap.get(proj);
|
|
63
|
-
if (!configuration) {
|
|
64
|
-
// Options
|
|
65
|
-
if (value.passWithNoTests === jestDefaults.options.passWithNoTests) {
|
|
66
|
-
delete projConfig.targets[targetName].options.passWithNoTests;
|
|
67
|
-
}
|
|
68
|
-
else if (!passWithNoTestsPreviouslyInDefaults) {
|
|
69
|
-
projConfig.targets[targetName].options.passWithNoTests ??= false;
|
|
70
|
-
}
|
|
71
|
-
if (Object.keys(projConfig.targets[targetName].options).length === 0) {
|
|
72
|
-
delete projConfig.targets[targetName].options;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
else if (configuration === 'ci') {
|
|
76
|
-
// CI Config
|
|
77
|
-
if (value.ci === jestDefaults.configurations.ci.ci) {
|
|
78
|
-
delete projConfig.targets[targetName].configurations.ci.ci;
|
|
79
|
-
}
|
|
80
|
-
else if (ciCiPreviouslyInDefaults) {
|
|
81
|
-
projConfig.targets[targetName].configurations.ci.ci ??= false;
|
|
82
|
-
}
|
|
83
|
-
if (value.codeCoverage === jestDefaults.configurations.ci.codeCoverage) {
|
|
84
|
-
delete projConfig.targets[targetName].configurations.ci.codeCoverage;
|
|
85
|
-
}
|
|
86
|
-
else if (ciCodeCoveragePreviouslyInDefaults) {
|
|
87
|
-
projConfig.targets[targetName].configurations.ci.codeCoverage ??=
|
|
88
|
-
false;
|
|
89
|
-
}
|
|
90
|
-
if (Object.keys(projConfig.targets[targetName].configurations.ci)
|
|
91
|
-
.length === 0) {
|
|
92
|
-
delete projConfig.targets[targetName].configurations.ci;
|
|
93
|
-
}
|
|
94
|
-
if (Object.keys(projConfig.targets[targetName].configurations).length ===
|
|
95
|
-
0) {
|
|
96
|
-
delete projConfig.targets[targetName].configurations;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
(0, devkit_1.updateProjectConfiguration)(tree, proj, projConfig);
|
|
100
|
-
});
|
|
101
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Checks every target on every project to see if one of them uses the target default
|
|
105
|
-
*/
|
|
106
|
-
function isTargetDefaultUsed(targetDefault, targetDefaults, projects, projectMap) {
|
|
107
|
-
for (const p of Object.values(projects)) {
|
|
108
|
-
for (const targetName in p.data?.targets ?? {}) {
|
|
109
|
-
if ((0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, targetDefaults,
|
|
110
|
-
// It might seem like we should use the graph here too but we don't want to pass an executor which was processed in the graph
|
|
111
|
-
projectMap.get(p.name)?.targets?.[targetName]?.executor) === targetDefault) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return false;
|
|
117
|
-
}
|