@nx/jest 21.3.0-beta.2 → 21.3.0-beta.3
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/package.json +3 -3
- package/src/plugins/plugin.js +13 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/jest",
|
|
3
|
-
"version": "21.3.0-beta.
|
|
3
|
+
"version": "21.3.0-beta.3",
|
|
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.3.0-beta.
|
|
41
|
-
"@nx/js": "21.3.0-beta.
|
|
40
|
+
"@nx/devkit": "21.3.0-beta.3",
|
|
41
|
+
"@nx/js": "21.3.0-beta.3",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"identity-obj-proxy": "3.0.0",
|
|
44
44
|
"jest-config": "^29.4.1",
|
package/src/plugins/plugin.js
CHANGED
|
@@ -32,11 +32,11 @@ exports.createNodesV2 = [
|
|
|
32
32
|
const targetsCache = readTargetsCache(cachePath);
|
|
33
33
|
// Cache jest preset(s) to avoid penalties of module load times. Most of jest configs will use the same preset.
|
|
34
34
|
const presetCache = {};
|
|
35
|
-
const
|
|
35
|
+
const isInPackageManagerWorkspaces = buildPackageJsonWorkspacesMatcher(context.workspaceRoot);
|
|
36
36
|
options = normalizeOptions(options);
|
|
37
37
|
const { roots: projectRoots, configFiles: validConfigFiles } = configFiles.reduce((acc, configFile) => {
|
|
38
38
|
const potentialRoot = (0, path_1.dirname)(configFile);
|
|
39
|
-
if (checkIfConfigFileShouldBeProject(configFile, potentialRoot,
|
|
39
|
+
if (checkIfConfigFileShouldBeProject(configFile, potentialRoot, isInPackageManagerWorkspaces, context)) {
|
|
40
40
|
acc.roots.push(potentialRoot);
|
|
41
41
|
acc.configFiles.push(configFile);
|
|
42
42
|
}
|
|
@@ -77,8 +77,8 @@ exports.createNodes = [
|
|
|
77
77
|
async (configFilePath, options, context) => {
|
|
78
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.');
|
|
79
79
|
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
80
|
-
const
|
|
81
|
-
if (!checkIfConfigFileShouldBeProject(configFilePath, projectRoot,
|
|
80
|
+
const isInPackageManagerWorkspaces = buildPackageJsonWorkspacesMatcher(context.workspaceRoot);
|
|
81
|
+
if (!checkIfConfigFileShouldBeProject(configFilePath, projectRoot, isInPackageManagerWorkspaces, context)) {
|
|
82
82
|
return {};
|
|
83
83
|
}
|
|
84
84
|
options = normalizeOptions(options);
|
|
@@ -94,7 +94,14 @@ exports.createNodes = [
|
|
|
94
94
|
};
|
|
95
95
|
},
|
|
96
96
|
];
|
|
97
|
-
function
|
|
97
|
+
function buildPackageJsonWorkspacesMatcher(workspaceRoot) {
|
|
98
|
+
if (process.env.NX_INFER_ALL_PACKAGE_JSONS === 'true') {
|
|
99
|
+
return () => true;
|
|
100
|
+
}
|
|
101
|
+
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(workspaceRoot));
|
|
102
|
+
return (path) => (0, minimatch_1.minimatch)(path, packageManagerWorkspacesGlob);
|
|
103
|
+
}
|
|
104
|
+
function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, isInPackageManagerWorkspaces, context) {
|
|
98
105
|
// Do not create a project if package.json and project.json isn't there.
|
|
99
106
|
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
100
107
|
if (!siblingFiles.includes('package.json') &&
|
|
@@ -104,7 +111,7 @@ function checkIfConfigFileShouldBeProject(configFilePath, projectRoot, packageMa
|
|
|
104
111
|
else if (!siblingFiles.includes('project.json') &&
|
|
105
112
|
siblingFiles.includes('package.json')) {
|
|
106
113
|
const path = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
|
107
|
-
const isPackageJsonProject = (
|
|
114
|
+
const isPackageJsonProject = isInPackageManagerWorkspaces(path);
|
|
108
115
|
if (!isPackageJsonProject) {
|
|
109
116
|
return false;
|
|
110
117
|
}
|