@nx/jest 21.0.0-beta.0 → 21.0.0-beta.10
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/executors/jest/jest.impl.js +7 -1
- package/src/generators/configuration/files/common/src/test-setup.ts__tmpl__ +7 -1
- package/src/generators/configuration/lib/create-jest-config.js +3 -2
- package/src/generators/configuration/schema.d.ts +6 -1
- package/src/migrations/update-21-0-0/replace-getJestProjects-with-getJestProjectsAsync.js +86 -0
- package/src/plugins/plugin.d.ts +1 -1
- package/src/plugins/plugin.js +89 -61
- 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.10",
|
|
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.10",
|
|
41
|
+
"@nx/js": "21.0.0-beta.10",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"identity-obj-proxy": "3.0.0",
|
|
44
44
|
"jest-config": "^29.4.1",
|
|
@@ -16,7 +16,13 @@ process.env.NODE_ENV ??= 'test';
|
|
|
16
16
|
async function jestExecutor(options, context) {
|
|
17
17
|
// Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119
|
|
18
18
|
// We want to support of ESM via 'module':'nodenext', we need to override the resolution until Jest supports it.
|
|
19
|
-
process.env
|
|
19
|
+
const existingValue = process.env['TS_NODE_COMPILER_OPTIONS'];
|
|
20
|
+
process.env['TS_NODE_COMPILER_OPTIONS'] = JSON.stringify({
|
|
21
|
+
...(existingValue ? JSON.parse(existingValue) : {}),
|
|
22
|
+
moduleResolution: 'Node10',
|
|
23
|
+
module: 'commonjs',
|
|
24
|
+
customConditions: null,
|
|
25
|
+
});
|
|
20
26
|
const config = await parseJestConfig(options, context);
|
|
21
27
|
const { results } = await (0, jest_1.runCLI)(config, [options.jestConfig]);
|
|
22
28
|
return { success: results.success };
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
<% if(setupFile === 'react-native') { %>import '@testing-library/jest-native/extend-expect';<% } %>
|
|
1
|
+
<% if(setupFile === 'react-native') { %>import '@testing-library/jest-native/extend-expect';<% } %>
|
|
2
|
+
<%_ if(setupFile === 'react-router') { _%>
|
|
3
|
+
import { TextEncoder, TextDecoder as NodeTextDecoder } from "util";
|
|
4
|
+
|
|
5
|
+
global.TextEncoder = TextEncoder;
|
|
6
|
+
global.TextDecoder = NodeTextDecoder as typeof TextDecoder; // necessary because there is a mismatch between ts type and node type
|
|
7
|
+
<%_ } _%>
|
|
@@ -99,9 +99,10 @@ function generateGlobalConfig(tree, isJS) {
|
|
|
99
99
|
module.exports = async () => ({
|
|
100
100
|
projects: await getJestProjectsAsync()
|
|
101
101
|
});`
|
|
102
|
-
: `import {
|
|
102
|
+
: `import type { Config } from 'jest';
|
|
103
|
+
import { getJestProjectsAsync } from '@nx/jest';
|
|
103
104
|
|
|
104
|
-
export default async () => ({
|
|
105
|
+
export default async (): Promise<Config> => ({
|
|
105
106
|
projects: await getJestProjectsAsync()
|
|
106
107
|
});`;
|
|
107
108
|
tree.write(`jest.config.${isJS ? 'js' : 'ts'}`, contents);
|
|
@@ -6,7 +6,12 @@ export interface JestProjectSchema {
|
|
|
6
6
|
* @deprecated use setupFile instead
|
|
7
7
|
*/
|
|
8
8
|
skipSetupFile?: boolean;
|
|
9
|
-
setupFile?:
|
|
9
|
+
setupFile?:
|
|
10
|
+
| 'angular'
|
|
11
|
+
| 'web-components'
|
|
12
|
+
| 'react-native'
|
|
13
|
+
| 'react-router'
|
|
14
|
+
| 'none';
|
|
10
15
|
skipSerializers?: boolean;
|
|
11
16
|
testEnvironment?: 'node' | 'jsdom' | 'none';
|
|
12
17
|
/**
|
|
@@ -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
|
+
}
|
package/src/plugins/plugin.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface JestPluginOptions {
|
|
|
7
7
|
*/
|
|
8
8
|
ciGroupName?: string;
|
|
9
9
|
/**
|
|
10
|
-
* Whether to use jest-config and jest-runtime to load Jest configuration and context.
|
|
10
|
+
* Whether to use jest-config and jest-runtime are used to load Jest configuration and context.
|
|
11
11
|
* Disabling this is much faster but could be less correct since we are using our own config loader
|
|
12
12
|
* and test matcher instead of Jest's.
|
|
13
13
|
*/
|
package/src/plugins/plugin.js
CHANGED
|
@@ -15,6 +15,7 @@ const path_1 = require("path");
|
|
|
15
15
|
const version_utils_1 = require("../utils/version-utils");
|
|
16
16
|
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
17
17
|
const node_path_1 = require("node:path");
|
|
18
|
+
const installation_directory_1 = require("nx/src/utils/installation-directory");
|
|
18
19
|
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
19
20
|
function readTargetsCache(cachePath) {
|
|
20
21
|
return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
|
|
@@ -31,8 +32,36 @@ exports.createNodesV2 = [
|
|
|
31
32
|
const targetsCache = readTargetsCache(cachePath);
|
|
32
33
|
// Cache jest preset(s) to avoid penalties of module load times. Most of jest configs will use the same preset.
|
|
33
34
|
const presetCache = {};
|
|
35
|
+
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(context.workspaceRoot));
|
|
36
|
+
options = normalizeOptions(options);
|
|
37
|
+
const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
|
|
38
|
+
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
39
|
+
if (checkIfConfigFileShouldBeProject(configFile, potentialRoot, packageManagerWorkspacesGlob, context)) {
|
|
40
|
+
acc.roots.push(potentialRoot);
|
|
41
|
+
acc.configFiles.push(configFile);
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, {
|
|
45
|
+
roots: [],
|
|
46
|
+
configFiles: [],
|
|
47
|
+
});
|
|
48
|
+
const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, options, context);
|
|
34
49
|
try {
|
|
35
|
-
return await (0, devkit_1.createNodesFromFiles)(
|
|
50
|
+
return await (0, devkit_1.createNodesFromFiles)(async (configFilePath, options, context, idx) => {
|
|
51
|
+
const projectRoot = projectRoots[idx];
|
|
52
|
+
const hash = hashes[idx];
|
|
53
|
+
targetsCache[hash] ??= await buildJestTargets(configFilePath, projectRoot, options, context, presetCache);
|
|
54
|
+
const { targets, metadata } = targetsCache[hash];
|
|
55
|
+
return {
|
|
56
|
+
projects: {
|
|
57
|
+
[projectRoot]: {
|
|
58
|
+
root: projectRoot,
|
|
59
|
+
targets,
|
|
60
|
+
metadata,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}, validConfigFiles, options, context);
|
|
36
65
|
}
|
|
37
66
|
finally {
|
|
38
67
|
writeTargetsToCache(cachePath, targetsCache);
|
|
@@ -45,26 +74,39 @@ exports.createNodesV2 = [
|
|
|
45
74
|
*/
|
|
46
75
|
exports.createNodes = [
|
|
47
76
|
jestConfigGlob,
|
|
48
|
-
(
|
|
77
|
+
async (configFilePath, options, context) => {
|
|
49
78
|
devkit_1.logger.warn('`createNodes` is deprecated. Update your plugin to utilize createNodesV2 instead. In Nx 20, this will change to the createNodesV2 API.');
|
|
50
|
-
|
|
79
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
80
|
+
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(context.workspaceRoot));
|
|
81
|
+
if (!checkIfConfigFileShouldBeProject(configFilePath, projectRoot, packageManagerWorkspacesGlob, context)) {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
options = normalizeOptions(options);
|
|
85
|
+
const { targets, metadata } = await buildJestTargets(configFilePath, projectRoot, options, context, {});
|
|
86
|
+
return {
|
|
87
|
+
projects: {
|
|
88
|
+
[projectRoot]: {
|
|
89
|
+
root: projectRoot,
|
|
90
|
+
targets,
|
|
91
|
+
metadata,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
51
95
|
},
|
|
52
96
|
];
|
|
53
|
-
|
|
54
|
-
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
55
|
-
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(context.workspaceRoot));
|
|
97
|
+
function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, packageManagerWorkspacesGlob, context) {
|
|
56
98
|
// Do not create a project if package.json and project.json isn't there.
|
|
57
99
|
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
58
100
|
if (!siblingFiles.includes('package.json') &&
|
|
59
101
|
!siblingFiles.includes('project.json')) {
|
|
60
|
-
return
|
|
102
|
+
return false;
|
|
61
103
|
}
|
|
62
104
|
else if (!siblingFiles.includes('project.json') &&
|
|
63
105
|
siblingFiles.includes('package.json')) {
|
|
64
106
|
const path = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
|
65
107
|
const isPackageJsonProject = (0, minimatch_1.minimatch)(path, packageManagerWorkspacesGlob);
|
|
66
108
|
if (!isPackageJsonProject) {
|
|
67
|
-
return
|
|
109
|
+
return false;
|
|
68
110
|
}
|
|
69
111
|
}
|
|
70
112
|
const jestConfigContent = (0, fs_1.readFileSync)((0, path_1.resolve)(context.workspaceRoot, configFilePath), 'utf-8');
|
|
@@ -72,21 +114,9 @@ async function createNodesInternal(configFilePath, options, context, targetsCach
|
|
|
72
114
|
// The `getJestProjectsAsync` function uses the project graph, which leads to a
|
|
73
115
|
// circular dependency. We can skip this since it's no intended to be used for
|
|
74
116
|
// an Nx project.
|
|
75
|
-
return
|
|
117
|
+
return false;
|
|
76
118
|
}
|
|
77
|
-
|
|
78
|
-
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context);
|
|
79
|
-
targetsCache[hash] ??= await buildJestTargets(configFilePath, projectRoot, options, context, presetCache);
|
|
80
|
-
const { targets, metadata } = targetsCache[hash];
|
|
81
|
-
return {
|
|
82
|
-
projects: {
|
|
83
|
-
[projectRoot]: {
|
|
84
|
-
root: projectRoot,
|
|
85
|
-
targets,
|
|
86
|
-
metadata,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
};
|
|
119
|
+
return true;
|
|
90
120
|
}
|
|
91
121
|
async function buildJestTargets(configFilePath, projectRoot, options, context, presetCache) {
|
|
92
122
|
const absConfigFilePath = (0, path_1.resolve)(context.workspaceRoot, configFilePath);
|
|
@@ -95,13 +125,18 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
95
125
|
const rawConfig = await (0, config_utils_1.loadConfigFile)(absConfigFilePath);
|
|
96
126
|
const targets = {};
|
|
97
127
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
128
|
+
const tsNodeCompilerOptions = JSON.stringify({
|
|
129
|
+
moduleResolution: 'node10',
|
|
130
|
+
module: 'commonjs',
|
|
131
|
+
customConditions: null,
|
|
132
|
+
});
|
|
98
133
|
const target = (targets[options.targetName] = {
|
|
99
134
|
command: 'jest',
|
|
100
135
|
options: {
|
|
101
136
|
cwd: projectRoot,
|
|
102
137
|
// Jest registers ts-node with module CJS https://github.com/SimenB/jest/blob/v29.6.4/packages/jest-config/src/readConfigFileAndSetRootDir.ts#L117-L119
|
|
103
138
|
// We want to support of ESM via 'module':'nodenext', we need to override the resolution until Jest supports it.
|
|
104
|
-
env: { TS_NODE_COMPILER_OPTIONS:
|
|
139
|
+
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
105
140
|
},
|
|
106
141
|
metadata: {
|
|
107
142
|
technologies: ['jest'],
|
|
@@ -116,11 +151,13 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
116
151
|
},
|
|
117
152
|
},
|
|
118
153
|
});
|
|
154
|
+
// Not normalizing it here since also affects options for convert-to-inferred.
|
|
155
|
+
const disableJestRuntime = options.disableJestRuntime !== false;
|
|
119
156
|
const cache = (target.cache = true);
|
|
120
|
-
const inputs = (target.inputs = getInputs(namedInputs, rawConfig.preset, projectRoot, context.workspaceRoot,
|
|
157
|
+
const inputs = (target.inputs = getInputs(namedInputs, rawConfig.preset, projectRoot, context.workspaceRoot, disableJestRuntime));
|
|
121
158
|
let metadata;
|
|
122
159
|
const groupName = options?.ciGroupName ?? deductGroupNameFromTarget(options?.ciTargetName);
|
|
123
|
-
if (
|
|
160
|
+
if (disableJestRuntime) {
|
|
124
161
|
const outputs = (target.outputs = getOutputs(projectRoot, rawConfig.coverageDirectory
|
|
125
162
|
? (0, path_1.join)(context.workspaceRoot, projectRoot, rawConfig.coverageDirectory)
|
|
126
163
|
: undefined, undefined, context));
|
|
@@ -148,7 +185,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
148
185
|
outputs,
|
|
149
186
|
options: {
|
|
150
187
|
cwd: projectRoot,
|
|
151
|
-
env: { TS_NODE_COMPILER_OPTIONS:
|
|
188
|
+
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
152
189
|
},
|
|
153
190
|
metadata: {
|
|
154
191
|
technologies: ['jest'],
|
|
@@ -192,10 +229,17 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
192
229
|
}
|
|
193
230
|
else {
|
|
194
231
|
const { readConfig } = requireJestUtil('jest-config', projectRoot, context.workspaceRoot);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
232
|
+
let config;
|
|
233
|
+
try {
|
|
234
|
+
config = await readConfig({
|
|
235
|
+
_: [],
|
|
236
|
+
$0: undefined,
|
|
237
|
+
}, rawConfig, undefined, (0, path_1.dirname)(absConfigFilePath));
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
console.error(e);
|
|
241
|
+
throw e;
|
|
242
|
+
}
|
|
199
243
|
const outputs = (target.outputs = getOutputs(projectRoot, config.globalConfig?.coverageDirectory, config.globalConfig?.outputFile, context));
|
|
200
244
|
if (options?.ciTargetName) {
|
|
201
245
|
// nx-ignore-next-line
|
|
@@ -208,8 +252,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
208
252
|
const source = new jest.SearchSource(jestContext);
|
|
209
253
|
const jestVersion = (0, version_utils_1.getInstalledJestMajorVersion)();
|
|
210
254
|
const specs = jestVersion >= 30
|
|
211
|
-
?
|
|
212
|
-
await source.getTestPaths(config.globalConfig, config.projectConfig)
|
|
255
|
+
? await source.getTestPaths(config.globalConfig, config.projectConfig)
|
|
213
256
|
: await source.getTestPaths(config.globalConfig);
|
|
214
257
|
const testPaths = new Set(specs.tests.map(({ path }) => path));
|
|
215
258
|
if (testPaths.size > 0) {
|
|
@@ -252,9 +295,7 @@ async function buildJestTargets(configFilePath, projectRoot, options, context, p
|
|
|
252
295
|
outputs,
|
|
253
296
|
options: {
|
|
254
297
|
cwd: projectRoot,
|
|
255
|
-
env: {
|
|
256
|
-
TS_NODE_COMPILER_OPTIONS: '{"moduleResolution":"node10"}',
|
|
257
|
-
},
|
|
298
|
+
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
258
299
|
},
|
|
259
300
|
metadata: {
|
|
260
301
|
technologies: ['jest'],
|
|
@@ -378,7 +419,7 @@ function resolveJestPath(projectRoot, workspaceRoot) {
|
|
|
378
419
|
return resolvedJestPaths[projectRoot];
|
|
379
420
|
}
|
|
380
421
|
resolvedJestPaths[projectRoot] = require.resolve('jest', {
|
|
381
|
-
paths: [projectRoot, workspaceRoot, __dirname],
|
|
422
|
+
paths: [projectRoot, ...(0, installation_directory_1.getNxRequirePaths)(workspaceRoot), __dirname],
|
|
382
423
|
});
|
|
383
424
|
return resolvedJestPaths[projectRoot];
|
|
384
425
|
}
|
|
@@ -401,32 +442,19 @@ function requireJestUtil(packageName, projectRoot, workspaceRoot) {
|
|
|
401
442
|
}
|
|
402
443
|
async function getTestPaths(projectRoot, rawConfig, absConfigFilePath, context, presetCache) {
|
|
403
444
|
const testMatch = await getJestOption(rawConfig, absConfigFilePath, 'testMatch', presetCache);
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
for (const file of projectFiles) {
|
|
416
|
-
if (testRegexes.some((r) => r.test(file)))
|
|
417
|
-
files.push(file);
|
|
418
|
-
}
|
|
419
|
-
return files;
|
|
420
|
-
}
|
|
421
|
-
else {
|
|
422
|
-
// Default copied from https://github.com/jestjs/jest/blob/d1a2ed7/packages/jest-config/src/Defaults.ts#L84
|
|
423
|
-
const defaultTestMatch = [
|
|
424
|
-
'**/__tests__/**/*.?([mc])[jt]s?(x)',
|
|
425
|
-
'**/?(*.)+(spec|test).?([mc])[jt]s?(x)',
|
|
426
|
-
];
|
|
427
|
-
return await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, defaultTestMatch.map((pattern) => (0, path_1.join)(projectRoot, pattern)), []);
|
|
428
|
-
}
|
|
445
|
+
let paths = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, (testMatch || [
|
|
446
|
+
// Default copied from https://github.com/jestjs/jest/blob/d1a2ed7/packages/jest-config/src/Defaults.ts#L84
|
|
447
|
+
'**/__tests__/**/*.?([mc])[jt]s?(x)',
|
|
448
|
+
'**/?(*.)+(spec|test).?([mc])[jt]s?(x)',
|
|
449
|
+
]).map((pattern) => (0, path_1.join)(projectRoot, pattern)), []);
|
|
450
|
+
const testRegex = await getJestOption(rawConfig, absConfigFilePath, 'testRegex', presetCache);
|
|
451
|
+
if (testRegex) {
|
|
452
|
+
const testRegexes = Array.isArray(rawConfig.testRegex)
|
|
453
|
+
? rawConfig.testRegex.map((r) => new RegExp(r))
|
|
454
|
+
: [new RegExp(rawConfig.testRegex)];
|
|
455
|
+
paths = paths.filter((path) => testRegexes.some((r) => r.test(path)));
|
|
429
456
|
}
|
|
457
|
+
return paths;
|
|
430
458
|
}
|
|
431
459
|
async function getJestOption(rawConfig, absConfigFilePath, optionName, presetCache) {
|
|
432
460
|
if (rawConfig[optionName])
|
|
@@ -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
|
-
}
|