nx 18.0.6 → 18.0.7
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 +12 -12
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-exports.js +2 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +13 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +17 -5
- package/src/project-graph/utils/project-configuration-utils.js +5 -1
- package/src/utils/package-manager.d.ts +6 -0
- package/src/utils/package-manager.js +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yargs-parser": "21.1.1",
|
|
67
67
|
"node-machine-id": "1.1.12",
|
|
68
68
|
"ora": "5.3.0",
|
|
69
|
-
"@nrwl/tao": "18.0.
|
|
69
|
+
"@nrwl/tao": "18.0.7"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@swc-node/register": "^1.8.0",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-x64": "18.0.
|
|
85
|
-
"@nx/nx-darwin-arm64": "18.0.
|
|
86
|
-
"@nx/nx-linux-x64-gnu": "18.0.
|
|
87
|
-
"@nx/nx-linux-x64-musl": "18.0.
|
|
88
|
-
"@nx/nx-win32-x64-msvc": "18.0.
|
|
89
|
-
"@nx/nx-linux-arm64-gnu": "18.0.
|
|
90
|
-
"@nx/nx-linux-arm64-musl": "18.0.
|
|
91
|
-
"@nx/nx-linux-arm-gnueabihf": "18.0.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "18.0.
|
|
93
|
-
"@nx/nx-freebsd-x64": "18.0.
|
|
84
|
+
"@nx/nx-darwin-x64": "18.0.7",
|
|
85
|
+
"@nx/nx-darwin-arm64": "18.0.7",
|
|
86
|
+
"@nx/nx-linux-x64-gnu": "18.0.7",
|
|
87
|
+
"@nx/nx-linux-x64-musl": "18.0.7",
|
|
88
|
+
"@nx/nx-win32-x64-msvc": "18.0.7",
|
|
89
|
+
"@nx/nx-linux-arm64-gnu": "18.0.7",
|
|
90
|
+
"@nx/nx-linux-arm64-musl": "18.0.7",
|
|
91
|
+
"@nx/nx-linux-arm-gnueabihf": "18.0.7",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "18.0.7",
|
|
93
|
+
"@nx/nx-freebsd-x64": "18.0.7"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
package/src/devkit-exports.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export type { PackageManager } from './utils/package-manager';
|
|
|
43
43
|
/**
|
|
44
44
|
* @category Package Manager
|
|
45
45
|
*/
|
|
46
|
-
export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, } from './utils/package-manager';
|
|
46
|
+
export { getPackageManagerCommand, detectPackageManager, getPackageManagerVersion, isWorkspacesEnabled, } from './utils/package-manager';
|
|
47
47
|
/**
|
|
48
48
|
* @category Commands
|
|
49
49
|
*/
|
package/src/devkit-exports.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Try hard to not add to this API to reduce the surface area we need to maintain.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
|
|
7
|
+
exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.glob = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.isWorkspacesEnabled = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
|
|
8
8
|
// TODO(v19): Remove this export
|
|
9
9
|
/**
|
|
10
10
|
* @category Workspace
|
|
@@ -30,6 +30,7 @@ var package_manager_1 = require("./utils/package-manager");
|
|
|
30
30
|
Object.defineProperty(exports, "getPackageManagerCommand", { enumerable: true, get: function () { return package_manager_1.getPackageManagerCommand; } });
|
|
31
31
|
Object.defineProperty(exports, "detectPackageManager", { enumerable: true, get: function () { return package_manager_1.detectPackageManager; } });
|
|
32
32
|
Object.defineProperty(exports, "getPackageManagerVersion", { enumerable: true, get: function () { return package_manager_1.getPackageManagerVersion; } });
|
|
33
|
+
Object.defineProperty(exports, "isWorkspacesEnabled", { enumerable: true, get: function () { return package_manager_1.isWorkspacesEnabled; } });
|
|
33
34
|
/**
|
|
34
35
|
* @category Commands
|
|
35
36
|
*/
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { TargetConfiguration } from '../../config/workspace-json-project-json';
|
|
2
2
|
import { NxPluginV2 } from '../../utils/nx-plugin';
|
|
3
3
|
/**
|
|
4
|
-
* This
|
|
4
|
+
* This marks that a target provides information which should modify a target already registered
|
|
5
5
|
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
|
6
6
|
* the information provided by it will be discarded.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
9
|
+
* between the plugin-worker and the main process.
|
|
7
10
|
*/
|
|
8
|
-
export declare const ONLY_MODIFIES_EXISTING_TARGET
|
|
11
|
+
export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_TARGET";
|
|
12
|
+
/**
|
|
13
|
+
* This is used to override the source file for the target defaults plugin.
|
|
14
|
+
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
17
|
+
* between the plugin-worker and the main process.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
|
|
9
20
|
export declare const TargetDefaultsPlugin: NxPluginV2;
|
|
10
21
|
/**
|
|
11
22
|
* This fn gets target info that would make a target uniquely compatible
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTargetInfo = exports.TargetDefaultsPlugin = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
|
|
3
|
+
exports.getTargetInfo = exports.TargetDefaultsPlugin = exports.OVERRIDE_SOURCE_FILE = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
|
|
4
4
|
const minimatch_1 = require("minimatch");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
@@ -9,11 +9,22 @@ const globs_1 = require("../../utils/globs");
|
|
|
9
9
|
const package_json_1 = require("../../utils/package-json");
|
|
10
10
|
const package_json_workspaces_1 = require("../package-json-workspaces");
|
|
11
11
|
/**
|
|
12
|
-
* This
|
|
12
|
+
* This marks that a target provides information which should modify a target already registered
|
|
13
13
|
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
|
14
14
|
* the information provided by it will be discarded.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
17
|
+
* between the plugin-worker and the main process.
|
|
15
18
|
*/
|
|
16
|
-
exports.ONLY_MODIFIES_EXISTING_TARGET =
|
|
19
|
+
exports.ONLY_MODIFIES_EXISTING_TARGET = 'NX_ONLY_MODIFIES_EXISTING_TARGET';
|
|
20
|
+
/**
|
|
21
|
+
* This is used to override the source file for the target defaults plugin.
|
|
22
|
+
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
|
23
|
+
*
|
|
24
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
25
|
+
* between the plugin-worker and the main process.
|
|
26
|
+
*/
|
|
27
|
+
exports.OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
|
|
17
28
|
exports.TargetDefaultsPlugin = {
|
|
18
29
|
name: 'nx/core/target-defaults',
|
|
19
30
|
createNodes: [
|
|
@@ -71,6 +82,7 @@ exports.TargetDefaultsPlugin = {
|
|
|
71
82
|
targets: modifiedTargets,
|
|
72
83
|
},
|
|
73
84
|
},
|
|
85
|
+
[exports.OVERRIDE_SOURCE_FILE]: 'nx.json',
|
|
74
86
|
};
|
|
75
87
|
},
|
|
76
88
|
],
|
|
@@ -124,7 +136,7 @@ function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
|
|
|
124
136
|
return {
|
|
125
137
|
executor: 'nx:run-commands',
|
|
126
138
|
options: {
|
|
127
|
-
command:
|
|
139
|
+
command: targetOptions?.command,
|
|
128
140
|
},
|
|
129
141
|
};
|
|
130
142
|
}
|
|
@@ -158,7 +170,7 @@ function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
|
|
|
158
170
|
const projectJsonTargetConfiguration = projectJsonTargets?.[target];
|
|
159
171
|
const packageJsonTargetConfiguration = packageJsonTargets?.[target];
|
|
160
172
|
if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
|
|
161
|
-
return packageJsonTargetConfiguration?.executor
|
|
173
|
+
return packageJsonTargetConfiguration?.executor;
|
|
162
174
|
}
|
|
163
175
|
if (projectJsonTargetConfiguration?.executor) {
|
|
164
176
|
return projectJsonTargetConfiguration.executor;
|
|
@@ -191,13 +191,17 @@ plugins, root = workspace_root_1.workspaceRoot) {
|
|
|
191
191
|
const configurationSourceMaps = {};
|
|
192
192
|
for (const result of results.flat()) {
|
|
193
193
|
const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
|
|
194
|
+
const sourceInfo = [file, pluginName];
|
|
195
|
+
if (result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE]) {
|
|
196
|
+
sourceInfo[0] = result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE];
|
|
197
|
+
}
|
|
194
198
|
for (const node in projectNodes) {
|
|
195
199
|
const project = {
|
|
196
200
|
root: node,
|
|
197
201
|
...projectNodes[node],
|
|
198
202
|
};
|
|
199
203
|
try {
|
|
200
|
-
mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps,
|
|
204
|
+
mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
|
|
201
205
|
}
|
|
202
206
|
catch (e) {
|
|
203
207
|
throw new CreateNodesError(`Unable to merge project information for "${project.root}" from ${result.file} using plugin ${result.pluginName}.`, e);
|
|
@@ -16,6 +16,12 @@ export interface PackageManagerCommands {
|
|
|
16
16
|
* Detects which package manager is used in the workspace based on the lock file.
|
|
17
17
|
*/
|
|
18
18
|
export declare function detectPackageManager(dir?: string): PackageManager;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
|
|
21
|
+
* @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
|
|
22
|
+
* @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isWorkspacesEnabled(packageManager?: PackageManager, root?: string): boolean;
|
|
19
25
|
/**
|
|
20
26
|
* Returns commands for the package manager used in the workspace.
|
|
21
27
|
* By default, the package manager is derived based on the lock file,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.detectPackageManager = void 0;
|
|
3
|
+
exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.isWorkspacesEnabled = exports.detectPackageManager = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
@@ -9,6 +9,7 @@ const semver_1 = require("semver");
|
|
|
9
9
|
const tmp_1 = require("tmp");
|
|
10
10
|
const util_1 = require("util");
|
|
11
11
|
const configuration_1 = require("../config/configuration");
|
|
12
|
+
const file_utils_1 = require("../project-graph/file-utils");
|
|
12
13
|
const fileutils_1 = require("./fileutils");
|
|
13
14
|
const package_json_1 = require("./package-json");
|
|
14
15
|
const workspace_root_1 = require("./workspace-root");
|
|
@@ -26,6 +27,20 @@ function detectPackageManager(dir = '') {
|
|
|
26
27
|
: 'npm'));
|
|
27
28
|
}
|
|
28
29
|
exports.detectPackageManager = detectPackageManager;
|
|
30
|
+
/**
|
|
31
|
+
* Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
|
|
32
|
+
* @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
|
|
33
|
+
* @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
|
|
34
|
+
*/
|
|
35
|
+
function isWorkspacesEnabled(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
|
|
36
|
+
if (packageManager === 'pnpm') {
|
|
37
|
+
return (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
|
|
38
|
+
}
|
|
39
|
+
// yarn and pnpm both use the same 'workspaces' property in package.json
|
|
40
|
+
const packageJson = (0, file_utils_1.readPackageJson)();
|
|
41
|
+
return !!packageJson?.workspaces;
|
|
42
|
+
}
|
|
43
|
+
exports.isWorkspacesEnabled = isWorkspacesEnabled;
|
|
29
44
|
/**
|
|
30
45
|
* Returns commands for the package manager used in the workspace.
|
|
31
46
|
* By default, the package manager is derived based on the lock file,
|