nx 22.6.0 → 22.6.2
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/bin/nx.js +19 -11
- package/package.json +11 -12
- package/release/changelog-renderer/index.d.ts +2 -1
- package/release/changelog-renderer/index.d.ts.map +1 -1
- package/schemas/nx-schema.json +102 -0
- package/src/adapter/ngcli-adapter.d.ts +8 -5
- package/src/adapter/ngcli-adapter.d.ts.map +1 -1
- package/src/adapter/ngcli-adapter.js +33 -19
- package/src/ai/clone-ai-config-repo.d.ts.map +1 -1
- package/src/ai/clone-ai-config-repo.js +2 -0
- package/src/command-line/add/add.js +1 -1
- package/src/command-line/examples.d.ts +7 -0
- package/src/command-line/examples.d.ts.map +1 -1
- package/src/command-line/examples.js +29 -1
- package/src/command-line/exec/exec.js +3 -3
- package/src/command-line/format/format.js +3 -3
- package/src/command-line/generate/generate.d.ts.map +1 -1
- package/src/command-line/generate/generate.js +1 -1
- package/src/command-line/graph/graph.js +1 -1
- package/src/command-line/init/command-object.js +1 -21
- package/src/command-line/init/configure-plugins.js +1 -1
- package/src/command-line/init/implementation/angular/integrated-workspace.js +1 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +2 -2
- package/src/command-line/init/implementation/deduce-default-base.js +5 -5
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +2 -2
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -1
- package/src/command-line/init/implementation/utils.d.ts +1 -2
- package/src/command-line/init/implementation/utils.d.ts.map +1 -1
- package/src/command-line/init/implementation/utils.js +1 -15
- package/src/command-line/init/init-v1.d.ts +0 -3
- package/src/command-line/init/init-v1.d.ts.map +1 -1
- package/src/command-line/init/init-v1.js +1 -27
- package/src/command-line/init/init-v2.d.ts +0 -1
- package/src/command-line/init/init-v2.d.ts.map +1 -1
- package/src/command-line/init/init-v2.js +7 -35
- package/src/command-line/mcp/mcp.d.ts.map +1 -1
- package/src/command-line/mcp/mcp.js +2 -0
- package/src/command-line/migrate/migrate-ui-api.d.ts.map +1 -1
- package/src/command-line/migrate/migrate-ui-api.js +13 -0
- package/src/command-line/migrate/migrate.d.ts.map +1 -1
- package/src/command-line/migrate/migrate.js +41 -23
- package/src/command-line/migrate/run-migration-process.js +2 -0
- package/src/command-line/nx-cloud/connect/view-logs.js +1 -1
- package/src/command-line/nx-commands.js +65 -65
- package/src/command-line/release/config/version-plans.js +1 -1
- package/src/command-line/release/utils/exec-command.js +1 -1
- package/src/command-line/release/utils/launch-editor.js +2 -2
- package/src/command-line/release/utils/remote-release-clients/github.d.ts +1 -0
- package/src/command-line/release/utils/remote-release-clients/github.d.ts.map +1 -1
- package/src/command-line/release/utils/remote-release-clients/github.js +39 -2
- package/src/command-line/release/utils/remote-release-clients/gitlab.d.ts.map +1 -1
- package/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -0
- package/src/command-line/release/version/release-group-processor.d.ts.map +1 -1
- package/src/command-line/release/version/release-group-processor.js +2 -4
- package/src/command-line/release/version.js +1 -1
- package/src/command-line/run/run-one.d.ts.map +1 -1
- package/src/command-line/run/run-one.js +1 -1
- package/src/command-line/run/run.d.ts.map +1 -1
- package/src/command-line/run/run.js +2 -2
- package/src/command-line/show/target.js +5 -2
- package/src/command-line/watch/watch.js +1 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +2 -2
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +3 -2
- package/src/daemon/client/generate-help-output.js +1 -1
- package/src/daemon/server/handle-configure-ai-agents.js +11 -4
- package/src/daemon/server/handle-hash-tasks.d.ts +1 -0
- package/src/daemon/server/handle-hash-tasks.d.ts.map +1 -1
- package/src/daemon/server/handle-hash-tasks.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts.map +1 -1
- package/src/daemon/server/project-graph-listener-sockets.d.ts +1 -1
- package/src/daemon/server/project-graph-listener-sockets.d.ts.map +1 -1
- package/src/daemon/server/shutdown-utils.js +1 -1
- package/src/devkit-internals.d.ts +3 -2
- package/src/devkit-internals.d.ts.map +1 -1
- package/src/devkit-internals.js +5 -4
- package/src/executors/run-commands/run-commands.impl.d.ts.map +1 -1
- package/src/executors/run-commands/run-commands.impl.js +60 -7
- package/src/executors/run-commands/running-tasks.d.ts.map +1 -1
- package/src/executors/run-commands/running-tasks.js +1 -5
- package/src/executors/run-script/run-script.impl.js +1 -1
- package/src/executors/utils/convert-nx-executor.js +2 -2
- package/src/generators/utils/project-configuration.js +4 -4
- package/src/hasher/hash-plan-inspector.d.ts.map +1 -1
- package/src/hasher/hash-plan-inspector.js +1 -1
- package/src/hasher/native-task-hasher-impl.d.ts +2 -2
- package/src/hasher/native-task-hasher-impl.d.ts.map +1 -1
- package/src/hasher/native-task-hasher-impl.js +6 -6
- package/src/hasher/task-hasher.d.ts +4 -4
- package/src/hasher/task-hasher.d.ts.map +1 -1
- package/src/hasher/task-hasher.js +9 -6
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/plugins/js/lock-file/bun-parser.js +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts.map +1 -1
- package/src/plugins/js/lock-file/lock-file.js +3 -1
- package/src/project-graph/build-project-graph.d.ts +1 -1
- package/src/project-graph/build-project-graph.d.ts.map +1 -1
- package/src/project-graph/build-project-graph.js +2 -2
- package/src/project-graph/error-types.d.ts +2 -1
- package/src/project-graph/error-types.d.ts.map +1 -1
- package/src/project-graph/file-utils.d.ts.map +1 -1
- package/src/project-graph/file-utils.js +4 -2
- package/src/project-graph/nx-deps-cache.d.ts +1 -1
- package/src/project-graph/nx-deps-cache.d.ts.map +1 -1
- package/src/project-graph/plugins/isolation/isolated-plugin.js +5 -5
- package/src/project-graph/project-graph.d.ts +2 -2
- package/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +23 -18
- package/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts.map +1 -1
- package/src/project-graph/utils/project-configuration/name-substitution-manager.js +129 -87
- package/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +40 -0
- package/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts.map +1 -0
- package/src/project-graph/utils/project-configuration/project-nodes-manager.js +264 -0
- package/src/project-graph/utils/project-configuration/target-merging.d.ts +32 -0
- package/src/project-graph/utils/project-configuration/target-merging.d.ts.map +1 -0
- package/src/project-graph/utils/project-configuration/target-merging.js +332 -0
- package/src/project-graph/utils/project-configuration/target-normalization.d.ts +13 -0
- package/src/project-graph/utils/project-configuration/target-normalization.d.ts.map +1 -0
- package/src/project-graph/utils/project-configuration/target-normalization.js +177 -0
- package/src/project-graph/utils/project-configuration-utils.d.ts +16 -41
- package/src/project-graph/utils/project-configuration-utils.d.ts.map +1 -1
- package/src/project-graph/utils/project-configuration-utils.js +56 -734
- package/src/tasks-runner/cache.js +1 -1
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycle.d.ts +4 -0
- package/src/tasks-runner/life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts.map +1 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +4 -0
- package/src/tasks-runner/task-orchestrator.d.ts +12 -4
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +123 -68
- package/src/tasks-runner/tasks-schedule.d.ts +1 -1
- package/src/tasks-runner/tasks-schedule.d.ts.map +1 -1
- package/src/tasks-runner/tasks-schedule.js +14 -3
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.d.ts.map +1 -1
- package/src/tasks-runner/utils.js +5 -7
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/analytics-prompt.d.ts.map +1 -1
- package/src/utils/analytics-prompt.js +2 -0
- package/src/utils/child-process.d.ts.map +1 -1
- package/src/utils/child-process.js +1 -2
- package/src/utils/command-line-utils.js +3 -3
- package/src/utils/default-base.js +1 -1
- package/src/utils/git-utils.d.ts.map +1 -1
- package/src/utils/git-utils.index-filter.js +2 -2
- package/src/utils/git-utils.js +6 -5
- package/src/utils/git-utils.tree-filter.js +1 -1
- package/src/utils/machine-id-cache.d.ts.map +1 -1
- package/src/utils/machine-id-cache.js +72 -2
- package/src/utils/package-json.js +2 -2
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +8 -13
- package/src/utils/provenance.d.ts.map +1 -1
- package/src/utils/provenance.js +2 -2
- package/src/utils/require-nx-key.js +1 -1
- package/src/utils/serialize-overrides-into-command-line.d.ts.map +1 -1
- package/src/utils/serialize-overrides-into-command-line.js +3 -4
- package/src/utils/shell-quoting.d.ts +11 -0
- package/src/utils/shell-quoting.d.ts.map +1 -0
- package/src/utils/shell-quoting.js +41 -0
- package/src/utils/split-target.d.ts +13 -2
- package/src/utils/split-target.d.ts.map +1 -1
- package/src/utils/split-target.js +180 -31
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts +0 -2
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/add-craco-commands-to-package-scripts.js +0 -21
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts +0 -2
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +0 -20
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts +0 -2
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/check-for-custom-webpack-setup.js +0 -17
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts +0 -2
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +0 -20
- package/src/command-line/init/implementation/react/clean-up-files.d.ts +0 -2
- package/src/command-line/init/implementation/react/clean-up-files.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/clean-up-files.js +0 -30
- package/src/command-line/init/implementation/react/index.d.ts +0 -5
- package/src/command-line/init/implementation/react/index.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/index.js +0 -77
- package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts +0 -2
- package/src/command-line/init/implementation/react/read-name-from-package-json.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/read-name-from-package-json.js +0 -16
- package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts +0 -2
- package/src/command-line/init/implementation/react/rename-js-to-jsx.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +0 -22
- package/src/command-line/init/implementation/react/tsconfig-setup.d.ts +0 -2
- package/src/command-line/init/implementation/react/tsconfig-setup.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/tsconfig-setup.js +0 -108
- package/src/command-line/init/implementation/react/write-vite-config.d.ts +0 -2
- package/src/command-line/init/implementation/react/write-vite-config.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/write-vite-config.js +0 -53
- package/src/command-line/init/implementation/react/write-vite-index-html.d.ts +0 -2
- package/src/command-line/init/implementation/react/write-vite-index-html.d.ts.map +0 -1
- package/src/command-line/init/implementation/react/write-vite-index-html.js +0 -24
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
|
|
2
|
+
import type { ConfigurationSourceMaps, SourceInformation } from './source-maps';
|
|
3
|
+
export { validateProject } from './target-normalization';
|
|
4
|
+
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): {
|
|
5
|
+
nameChanged: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
|
8
|
+
export declare function createRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* Owns the rootMap (root → ProjectConfiguration) and nameMap
|
|
11
|
+
* (name → ProjectConfiguration), coordinating merges with the
|
|
12
|
+
* {@link ProjectNameInNodePropsManager} for deferred name substitutions.
|
|
13
|
+
*
|
|
14
|
+
* The nameMap entries are the *same object references* as the rootMap
|
|
15
|
+
* entries, so when a merge adds targets to a rootMap entry the nameMap
|
|
16
|
+
* entry automatically has them too — no copying, no staleness.
|
|
17
|
+
*/
|
|
18
|
+
export declare class ProjectNodesManager {
|
|
19
|
+
private rootMap;
|
|
20
|
+
private nameMap;
|
|
21
|
+
private nameSubstitutionManager;
|
|
22
|
+
constructor();
|
|
23
|
+
getRootMap(): Record<string, ProjectConfiguration>;
|
|
24
|
+
/**
|
|
25
|
+
* Merges a project into the rootMap, updates the nameMap, and notifies
|
|
26
|
+
* the substitution manager if the name changed at this root.
|
|
27
|
+
*/
|
|
28
|
+
mergeProjectNode(project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation): void;
|
|
29
|
+
/**
|
|
30
|
+
* Registers substitutors for a plugin result's project references
|
|
31
|
+
* in `inputs` and `dependsOn`.
|
|
32
|
+
*/
|
|
33
|
+
registerSubstitutors(pluginResultProjects?: Record<string, Omit<ProjectConfiguration, 'root'> & Partial<ProjectConfiguration>>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Applies all pending name substitutions. Call once after all plugin
|
|
36
|
+
* results have been merged.
|
|
37
|
+
*/
|
|
38
|
+
applySubstitutions(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=project-nodes-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-nodes-manager.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/project-graph/utils/project-configuration/project-nodes-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6CAA6C,CAAC;AAcnF,OAAO,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAMhF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACpD,OAAO,EAAE,oBAAoB,EAC7B,uBAAuB,CAAC,EAAE,uBAAuB,EACjD,iBAAiB,CAAC,EAAE,iBAAiB,EAGrC,uBAAuB,CAAC,EAAE,OAAO,GAChC;IACD,WAAW,EAAE,OAAO,CAAC;CACtB,CAqLA;AAED,wBAAgB,oCAAoC,CAClD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,wCAwCrD;AAED,wBAAgB,aAAa,CAC3B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,0BAQrD;AAED;;;;;;;;GAQG;AACH,qBAAa,mBAAmB;IAE9B,OAAO,CAAC,OAAO,CAA4C;IAE3D,OAAO,CAAC,OAAO,CAA4C;IAC3D,OAAO,CAAC,uBAAuB,CAAgC;;IAU/D,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC;IAIlD;;;OAGG;IACH,gBAAgB,CACd,OAAO,EAAE,oBAAoB,EAC7B,uBAAuB,CAAC,EAAE,uBAAuB,EACjD,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,IAAI;IA+BP;;;OAGG;IACH,oBAAoB,CAClB,oBAAoB,CAAC,EAAE,MAAM,CAC3B,MAAM,EACN,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CACnE,GACA,IAAI;IAMP;;;OAGG;IACH,kBAAkB,IAAI,IAAI;CAG3B"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProjectNodesManager = exports.validateProject = void 0;
|
|
4
|
+
exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
|
|
5
|
+
exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
|
|
6
|
+
exports.createRootMap = createRootMap;
|
|
7
|
+
const error_types_1 = require("../../error-types");
|
|
8
|
+
const target_merging_1 = require("./target-merging");
|
|
9
|
+
const target_normalization_1 = require("./target-normalization");
|
|
10
|
+
const name_substitution_manager_1 = require("./name-substitution-manager");
|
|
11
|
+
const source_maps_1 = require("./source-maps");
|
|
12
|
+
const minimatch_1 = require("minimatch");
|
|
13
|
+
const globs_1 = require("../../../utils/globs");
|
|
14
|
+
var target_normalization_2 = require("./target-normalization");
|
|
15
|
+
Object.defineProperty(exports, "validateProject", { enumerable: true, get: function () { return target_normalization_2.validateProject; } });
|
|
16
|
+
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
|
17
|
+
// This function is used when reading project configuration
|
|
18
|
+
// in generators, where we don't want to do this.
|
|
19
|
+
skipTargetNormalization) {
|
|
20
|
+
project.root = project.root === '' ? '.' : project.root;
|
|
21
|
+
if (configurationSourceMaps && !configurationSourceMaps[project.root]) {
|
|
22
|
+
configurationSourceMaps[project.root] = {};
|
|
23
|
+
}
|
|
24
|
+
const sourceMap = configurationSourceMaps?.[project.root];
|
|
25
|
+
let matchingProject = projectRootMap[project.root];
|
|
26
|
+
if (!matchingProject) {
|
|
27
|
+
projectRootMap[project.root] = {
|
|
28
|
+
root: project.root,
|
|
29
|
+
};
|
|
30
|
+
matchingProject = projectRootMap[project.root];
|
|
31
|
+
if (sourceMap) {
|
|
32
|
+
sourceMap[`root`] = sourceInformation;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// This handles top level properties that are overwritten.
|
|
36
|
+
// e.g. `srcRoot`, `projectType`, or other fields that shouldn't be extended
|
|
37
|
+
// Note: `name` is set specifically here to keep it from changing. The name is
|
|
38
|
+
// always determined by the first inference plugin to ID a project, unless it has
|
|
39
|
+
// a project.json in which case it was already updated above.
|
|
40
|
+
const updatedProjectConfiguration = {
|
|
41
|
+
...matchingProject,
|
|
42
|
+
};
|
|
43
|
+
for (const k in project) {
|
|
44
|
+
if (![
|
|
45
|
+
'tags',
|
|
46
|
+
'implicitDependencies',
|
|
47
|
+
'generators',
|
|
48
|
+
'targets',
|
|
49
|
+
'metadata',
|
|
50
|
+
'namedInputs',
|
|
51
|
+
].includes(k)) {
|
|
52
|
+
updatedProjectConfiguration[k] = project[k];
|
|
53
|
+
if (sourceMap) {
|
|
54
|
+
sourceMap[`${k}`] = sourceInformation;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// The next blocks handle properties that should be themselves merged (e.g. targets, tags, and implicit dependencies)
|
|
59
|
+
if (project.tags) {
|
|
60
|
+
updatedProjectConfiguration.tags = Array.from(new Set((matchingProject.tags ?? []).concat(project.tags)));
|
|
61
|
+
if (sourceMap) {
|
|
62
|
+
sourceMap['tags'] ??= sourceInformation;
|
|
63
|
+
project.tags.forEach((tag) => {
|
|
64
|
+
sourceMap[`tags.${tag}`] = sourceInformation;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (project.implicitDependencies) {
|
|
69
|
+
updatedProjectConfiguration.implicitDependencies = (matchingProject.implicitDependencies ?? []).concat(project.implicitDependencies);
|
|
70
|
+
if (sourceMap) {
|
|
71
|
+
sourceMap['implicitDependencies'] ??= sourceInformation;
|
|
72
|
+
project.implicitDependencies.forEach((implicitDependency) => {
|
|
73
|
+
sourceMap[`implicitDependencies.${implicitDependency}`] =
|
|
74
|
+
sourceInformation;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (project.generators) {
|
|
79
|
+
// Start with generators config in new project.
|
|
80
|
+
updatedProjectConfiguration.generators = { ...project.generators };
|
|
81
|
+
if (sourceMap) {
|
|
82
|
+
sourceMap['generators'] ??= sourceInformation;
|
|
83
|
+
for (const generator in project.generators) {
|
|
84
|
+
sourceMap[`generators.${generator}`] = sourceInformation;
|
|
85
|
+
for (const property in project.generators[generator]) {
|
|
86
|
+
sourceMap[`generators.${generator}.${property}`] = sourceInformation;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (matchingProject.generators) {
|
|
91
|
+
// For each generator that was already defined, shallow merge the options.
|
|
92
|
+
// Project contains the new info, so it has higher priority.
|
|
93
|
+
for (const generator in matchingProject.generators) {
|
|
94
|
+
updatedProjectConfiguration.generators[generator] = {
|
|
95
|
+
...matchingProject.generators[generator],
|
|
96
|
+
...project.generators[generator],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (project.namedInputs) {
|
|
102
|
+
updatedProjectConfiguration.namedInputs = {
|
|
103
|
+
...matchingProject.namedInputs,
|
|
104
|
+
...project.namedInputs,
|
|
105
|
+
};
|
|
106
|
+
if (sourceMap) {
|
|
107
|
+
sourceMap['namedInputs'] ??= sourceInformation;
|
|
108
|
+
for (const namedInput in project.namedInputs) {
|
|
109
|
+
sourceMap[`namedInputs.${namedInput}`] = sourceInformation;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
if (project.metadata) {
|
|
114
|
+
updatedProjectConfiguration.metadata = (0, target_merging_1.mergeMetadata)(sourceMap, sourceInformation, 'metadata', project.metadata, matchingProject.metadata);
|
|
115
|
+
}
|
|
116
|
+
if (project.targets) {
|
|
117
|
+
// We merge the targets with special handling, so clear this back to the
|
|
118
|
+
// targets as defined originally before merging.
|
|
119
|
+
updatedProjectConfiguration.targets = matchingProject?.targets ?? {};
|
|
120
|
+
if (sourceMap) {
|
|
121
|
+
sourceMap['targets'] ??= sourceInformation;
|
|
122
|
+
}
|
|
123
|
+
// For each target defined in the new config
|
|
124
|
+
for (const targetName in project.targets) {
|
|
125
|
+
// Always set source map info for the target, but don't overwrite info already there
|
|
126
|
+
// if augmenting an existing target.
|
|
127
|
+
const target = project.targets?.[targetName];
|
|
128
|
+
if (sourceMap) {
|
|
129
|
+
sourceMap[(0, source_maps_1.targetSourceMapKey)(targetName)] = sourceInformation;
|
|
130
|
+
}
|
|
131
|
+
const normalizedTarget = skipTargetNormalization
|
|
132
|
+
? target
|
|
133
|
+
: (0, target_merging_1.resolveCommandSyntacticSugar)(target, project.root);
|
|
134
|
+
let matchingTargets = [];
|
|
135
|
+
if ((0, globs_1.isGlobPattern)(targetName)) {
|
|
136
|
+
// find all targets matching the glob pattern
|
|
137
|
+
// this will map atomized targets to the glob pattern same as it does for targetDefaults
|
|
138
|
+
matchingTargets = Object.keys(updatedProjectConfiguration.targets).filter((key) => (0, minimatch_1.minimatch)(key, targetName));
|
|
139
|
+
}
|
|
140
|
+
// If no matching targets were found, we can assume that the target name is not (meant to be) a glob pattern
|
|
141
|
+
if (!matchingTargets.length) {
|
|
142
|
+
matchingTargets = [targetName];
|
|
143
|
+
}
|
|
144
|
+
for (const matchingTargetName of matchingTargets) {
|
|
145
|
+
updatedProjectConfiguration.targets[matchingTargetName] =
|
|
146
|
+
(0, target_merging_1.mergeTargetConfigurations)(normalizedTarget, matchingProject.targets?.[matchingTargetName], sourceMap, sourceInformation, `targets.${matchingTargetName}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
projectRootMap[updatedProjectConfiguration.root] =
|
|
151
|
+
updatedProjectConfiguration;
|
|
152
|
+
const nameChanged = !!updatedProjectConfiguration.name &&
|
|
153
|
+
updatedProjectConfiguration.name !== matchingProject?.name;
|
|
154
|
+
return { nameChanged };
|
|
155
|
+
}
|
|
156
|
+
function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
157
|
+
const projects = {};
|
|
158
|
+
// If there are projects that have the same name, that is an error.
|
|
159
|
+
// This object tracks name -> (all roots of projects with that name)
|
|
160
|
+
// to provide better error messaging.
|
|
161
|
+
const conflicts = new Map();
|
|
162
|
+
const projectRootsWithNoName = [];
|
|
163
|
+
for (const root in projectRootMap) {
|
|
164
|
+
const project = projectRootMap[root];
|
|
165
|
+
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
|
166
|
+
// Strip it before returning configuration for usage.
|
|
167
|
+
if (project['// targets'])
|
|
168
|
+
delete project['// targets'];
|
|
169
|
+
try {
|
|
170
|
+
(0, target_normalization_1.validateProject)(project, projects);
|
|
171
|
+
projects[project.name] = project;
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
if ((0, error_types_1.isProjectWithNoNameError)(e)) {
|
|
175
|
+
projectRootsWithNoName.push(e.projectRoot);
|
|
176
|
+
}
|
|
177
|
+
else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
|
|
178
|
+
const rootErrors = conflicts.get(e.projectName) ?? [
|
|
179
|
+
projects[e.projectName].root,
|
|
180
|
+
];
|
|
181
|
+
rootErrors.push(e.projectRoot);
|
|
182
|
+
conflicts.set(e.projectName, rootErrors);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
throw e;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (conflicts.size > 0) {
|
|
190
|
+
throw new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects);
|
|
191
|
+
}
|
|
192
|
+
if (projectRootsWithNoName.length > 0) {
|
|
193
|
+
throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
|
|
194
|
+
}
|
|
195
|
+
return projects;
|
|
196
|
+
}
|
|
197
|
+
function createRootMap(projectRootMap) {
|
|
198
|
+
const map = {};
|
|
199
|
+
for (const projectRoot in projectRootMap) {
|
|
200
|
+
const projectName = projectRootMap[projectRoot].name;
|
|
201
|
+
map[projectRoot] = projectName;
|
|
202
|
+
}
|
|
203
|
+
return map;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Owns the rootMap (root → ProjectConfiguration) and nameMap
|
|
207
|
+
* (name → ProjectConfiguration), coordinating merges with the
|
|
208
|
+
* {@link ProjectNameInNodePropsManager} for deferred name substitutions.
|
|
209
|
+
*
|
|
210
|
+
* The nameMap entries are the *same object references* as the rootMap
|
|
211
|
+
* entries, so when a merge adds targets to a rootMap entry the nameMap
|
|
212
|
+
* entry automatically has them too — no copying, no staleness.
|
|
213
|
+
*/
|
|
214
|
+
class ProjectNodesManager {
|
|
215
|
+
constructor() {
|
|
216
|
+
// root → ProjectConfiguration (the merge target)
|
|
217
|
+
this.rootMap = {};
|
|
218
|
+
// name → ProjectConfiguration (same object references as rootMap)
|
|
219
|
+
this.nameMap = {};
|
|
220
|
+
// Pass a lazy accessor so the substitution manager always sees
|
|
221
|
+
// the current nameMap without manual synchronization.
|
|
222
|
+
this.nameSubstitutionManager = new name_substitution_manager_1.ProjectNameInNodePropsManager(() => this.nameMap);
|
|
223
|
+
}
|
|
224
|
+
getRootMap() {
|
|
225
|
+
return this.rootMap;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Merges a project into the rootMap, updates the nameMap, and notifies
|
|
229
|
+
* the substitution manager if the name changed at this root.
|
|
230
|
+
*/
|
|
231
|
+
mergeProjectNode(project, configurationSourceMaps, sourceInformation) {
|
|
232
|
+
const previousName = this.rootMap[project.root]?.name;
|
|
233
|
+
mergeProjectConfigurationIntoRootMap(this.rootMap, project, configurationSourceMaps, sourceInformation);
|
|
234
|
+
const merged = this.rootMap[project.root];
|
|
235
|
+
const currentName = merged?.name;
|
|
236
|
+
if (currentName) {
|
|
237
|
+
// Remove old nameMap entry on rename
|
|
238
|
+
if (previousName && previousName !== currentName) {
|
|
239
|
+
delete this.nameMap[previousName];
|
|
240
|
+
}
|
|
241
|
+
// Point nameMap at the same object as rootMap
|
|
242
|
+
this.nameMap[currentName] = merged;
|
|
243
|
+
// Notify substitution manager of name change
|
|
244
|
+
if (currentName !== previousName) {
|
|
245
|
+
this.nameSubstitutionManager.identifyProjectWithRoot(project.root, currentName);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Registers substitutors for a plugin result's project references
|
|
251
|
+
* in `inputs` and `dependsOn`.
|
|
252
|
+
*/
|
|
253
|
+
registerSubstitutors(pluginResultProjects) {
|
|
254
|
+
this.nameSubstitutionManager.registerSubstitutorsForNodeResults(pluginResultProjects);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Applies all pending name substitutions. Call once after all plugin
|
|
258
|
+
* results have been merged.
|
|
259
|
+
*/
|
|
260
|
+
applySubstitutions() {
|
|
261
|
+
this.nameSubstitutionManager.applySubstitutions(this.rootMap);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.ProjectNodesManager = ProjectNodesManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../../config/workspace-json-project-json';
|
|
2
|
+
import { TargetDefaults } from '../../../config/nx-json';
|
|
3
|
+
import type { SourceInformation } from './source-maps';
|
|
4
|
+
export declare function deepClone<T>(obj: T): T;
|
|
5
|
+
export declare function resolveCommandSyntacticSugar(target: TargetConfiguration, key: string): TargetConfiguration;
|
|
6
|
+
export declare function mergeMetadata<T = ProjectMetadata | TargetMetadata>(sourceMap: Record<string, [file: string, plugin: string]>, sourceInformation: [file: string, plugin: string], baseSourceMapPath: string, metadata: T, matchingMetadata?: T): T;
|
|
7
|
+
/**
|
|
8
|
+
* Merges two targets.
|
|
9
|
+
*
|
|
10
|
+
* Most properties from `target` will overwrite any properties from `baseTarget`.
|
|
11
|
+
* Options and configurations are treated differently - they are merged together if the executor definition is compatible.
|
|
12
|
+
*
|
|
13
|
+
* @param target The target definition with higher priority
|
|
14
|
+
* @param baseTarget The target definition that should be overwritten. Can be undefined, in which case the target is returned as-is.
|
|
15
|
+
* @param projectConfigSourceMap The source map to be filled with metadata about where each property came from
|
|
16
|
+
* @param sourceInformation The metadata about where the new target was defined
|
|
17
|
+
* @param targetIdentifier The identifier for the target to merge, used for source map
|
|
18
|
+
* @returns A merged target configuration
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeTargetConfigurations(target: TargetConfiguration, baseTarget?: TargetConfiguration, projectConfigSourceMap?: Record<string, SourceInformation>, sourceInformation?: SourceInformation, targetIdentifier?: string): TargetConfiguration;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if targets options are compatible - used when merging configurations
|
|
23
|
+
* to avoid merging options for @nx/js:tsc into something like @nx/webpack:webpack.
|
|
24
|
+
*
|
|
25
|
+
* If the executors are both specified and don't match, the options aren't considered
|
|
26
|
+
* "compatible" and shouldn't be merged.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
|
|
29
|
+
export declare function mergeTargetDefaultWithTargetDefinition(targetName: string, project: ProjectConfiguration, targetDefault: Partial<TargetConfiguration>, sourceMap: Record<string, SourceInformation>): TargetConfiguration;
|
|
30
|
+
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
|
31
|
+
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
|
32
|
+
//# sourceMappingURL=target-merging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target-merging.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/project-graph/utils/project-configuration/target-merging.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAEtC;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,MAAM,GACV,mBAAmB,CAqBrB;AAED,wBAAgB,aAAa,CAAC,CAAC,GAAG,eAAe,GAAG,cAAc,EAChE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EACzD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACjD,iBAAiB,EAAE,MAAM,EACzB,QAAQ,EAAE,CAAC,EACX,gBAAgB,CAAC,EAAE,CAAC,GACnB,CAAC,CA6EH;AA8DD;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,mBAAmB,EAC3B,UAAU,CAAC,EAAE,mBAAmB,EAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC1D,iBAAiB,CAAC,EAAE,iBAAiB,EACrC,gBAAgB,CAAC,EAAE,MAAM,GACxB,mBAAmB,CAyErB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,mBAAmB,EACtB,CAAC,EAAE,mBAAmB,WA+BvB;AAiBD,wBAAgB,sCAAsC,CACpD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,OAAO,CAAC,mBAAmB,CAAC,EAC3C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GAC3C,mBAAmB,CA8ErB;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,EACxE,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,MAAM,GACV,CAAC,CAwBH;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,cAAc,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,cAAc,CAAC,MAAM,CAAC,CA6BxB"}
|