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,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepClone = deepClone;
|
|
4
|
+
exports.resolveCommandSyntacticSugar = resolveCommandSyntacticSugar;
|
|
5
|
+
exports.mergeMetadata = mergeMetadata;
|
|
6
|
+
exports.mergeTargetConfigurations = mergeTargetConfigurations;
|
|
7
|
+
exports.isCompatibleTarget = isCompatibleTarget;
|
|
8
|
+
exports.mergeTargetDefaultWithTargetDefinition = mergeTargetDefaultWithTargetDefinition;
|
|
9
|
+
exports.resolveNxTokensInOptions = resolveNxTokensInOptions;
|
|
10
|
+
exports.readTargetDefaultsForTarget = readTargetDefaultsForTarget;
|
|
11
|
+
const logger_1 = require("../../../utils/logger");
|
|
12
|
+
const globs_1 = require("../../../utils/globs");
|
|
13
|
+
const source_maps_1 = require("./source-maps");
|
|
14
|
+
const minimatch_1 = require("minimatch");
|
|
15
|
+
function deepClone(obj) {
|
|
16
|
+
return structuredClone(obj);
|
|
17
|
+
}
|
|
18
|
+
function resolveCommandSyntacticSugar(target, key) {
|
|
19
|
+
const { command, ...config } = target ?? {};
|
|
20
|
+
if (!command) {
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
if (config.executor) {
|
|
24
|
+
throw new Error(`${logger_1.NX_PREFIX} Project at ${key} should not have executor and command both configured.`);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
executor: 'nx:run-commands',
|
|
30
|
+
options: {
|
|
31
|
+
...config.options,
|
|
32
|
+
command: command,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
|
|
38
|
+
const result = {
|
|
39
|
+
...(matchingMetadata ?? {}),
|
|
40
|
+
};
|
|
41
|
+
for (const [metadataKey, value] of Object.entries(metadata)) {
|
|
42
|
+
const existingValue = matchingMetadata?.[metadataKey];
|
|
43
|
+
if (Array.isArray(value) && Array.isArray(existingValue)) {
|
|
44
|
+
const startIndex = result[metadataKey].length;
|
|
45
|
+
result[metadataKey].push(...value);
|
|
46
|
+
if (sourceMap) {
|
|
47
|
+
(0, source_maps_1.recordSourceMapKeysByIndex)(sourceMap, `${baseSourceMapPath}.${metadataKey}`, result[metadataKey], sourceInformation, startIndex);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (Array.isArray(value) && existingValue === undefined) {
|
|
51
|
+
result[metadataKey] ??= value;
|
|
52
|
+
if (sourceMap) {
|
|
53
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
|
|
54
|
+
(0, source_maps_1.recordSourceMapKeysByIndex)(sourceMap, `${baseSourceMapPath}.${metadataKey}`, value, sourceInformation);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (typeof value === 'object' && typeof existingValue === 'object') {
|
|
58
|
+
for (const key in value) {
|
|
59
|
+
const existingValue = matchingMetadata?.[metadataKey]?.[key];
|
|
60
|
+
if (Array.isArray(value[key]) && Array.isArray(existingValue)) {
|
|
61
|
+
const startIndex = result[metadataKey][key].length;
|
|
62
|
+
result[metadataKey][key].push(...value[key]);
|
|
63
|
+
if (sourceMap) {
|
|
64
|
+
(0, source_maps_1.recordSourceMapKeysByIndex)(sourceMap, `${baseSourceMapPath}.${metadataKey}.${key}`, result[metadataKey][key], sourceInformation, startIndex);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
result[metadataKey][key] = value[key];
|
|
69
|
+
if (sourceMap) {
|
|
70
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
|
|
71
|
+
sourceInformation;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
result[metadataKey] = value;
|
|
78
|
+
if (sourceMap) {
|
|
79
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
|
|
80
|
+
if (typeof value === 'object') {
|
|
81
|
+
for (const k in value) {
|
|
82
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}`] =
|
|
83
|
+
sourceInformation;
|
|
84
|
+
if (Array.isArray(value[k])) {
|
|
85
|
+
(0, source_maps_1.recordSourceMapKeysByIndex)(sourceMap, `${baseSourceMapPath}.${metadataKey}.${k}`, value[k], sourceInformation);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
function mergeOptions(newOptions, baseOptions, projectConfigSourceMap, sourceInformation, targetIdentifier) {
|
|
95
|
+
const mergedOptions = {
|
|
96
|
+
...(baseOptions ?? {}),
|
|
97
|
+
...(newOptions ?? {}),
|
|
98
|
+
};
|
|
99
|
+
// record new options & option properties in source map
|
|
100
|
+
if (projectConfigSourceMap) {
|
|
101
|
+
for (const newOption in newOptions) {
|
|
102
|
+
projectConfigSourceMap[`${targetIdentifier}.options.${newOption}`] =
|
|
103
|
+
sourceInformation;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return mergedOptions;
|
|
107
|
+
}
|
|
108
|
+
function mergeConfigurations(newConfigurations, baseConfigurations, projectConfigSourceMap, sourceInformation, targetIdentifier) {
|
|
109
|
+
const mergedConfigurations = {};
|
|
110
|
+
const configurations = new Set([
|
|
111
|
+
...Object.keys(baseConfigurations ?? {}),
|
|
112
|
+
...Object.keys(newConfigurations ?? {}),
|
|
113
|
+
]);
|
|
114
|
+
for (const configuration of configurations) {
|
|
115
|
+
mergedConfigurations[configuration] = {
|
|
116
|
+
...(baseConfigurations?.[configuration] ?? {}),
|
|
117
|
+
...(newConfigurations?.[configuration] ?? {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// record new configurations & configuration properties in source map
|
|
121
|
+
if (projectConfigSourceMap) {
|
|
122
|
+
for (const newConfiguration in newConfigurations) {
|
|
123
|
+
projectConfigSourceMap[`${targetIdentifier}.configurations.${newConfiguration}`] = sourceInformation;
|
|
124
|
+
for (const configurationProperty in newConfigurations[newConfiguration]) {
|
|
125
|
+
projectConfigSourceMap[`${targetIdentifier}.configurations.${newConfiguration}.${configurationProperty}`] = sourceInformation;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return mergedConfigurations;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Merges two targets.
|
|
133
|
+
*
|
|
134
|
+
* Most properties from `target` will overwrite any properties from `baseTarget`.
|
|
135
|
+
* Options and configurations are treated differently - they are merged together if the executor definition is compatible.
|
|
136
|
+
*
|
|
137
|
+
* @param target The target definition with higher priority
|
|
138
|
+
* @param baseTarget The target definition that should be overwritten. Can be undefined, in which case the target is returned as-is.
|
|
139
|
+
* @param projectConfigSourceMap The source map to be filled with metadata about where each property came from
|
|
140
|
+
* @param sourceInformation The metadata about where the new target was defined
|
|
141
|
+
* @param targetIdentifier The identifier for the target to merge, used for source map
|
|
142
|
+
* @returns A merged target configuration
|
|
143
|
+
*/
|
|
144
|
+
function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, sourceInformation, targetIdentifier) {
|
|
145
|
+
const { configurations: defaultConfigurations, options: defaultOptions, ...baseTargetProperties } = baseTarget ?? {};
|
|
146
|
+
// Target is "compatible", e.g. executor is defined only once or is the same
|
|
147
|
+
// in both places. This means that it is likely safe to merge
|
|
148
|
+
const isCompatible = isCompatibleTarget(baseTarget ?? {}, target);
|
|
149
|
+
if (!isCompatible && projectConfigSourceMap) {
|
|
150
|
+
// if the target is not compatible, we will simply override the options
|
|
151
|
+
// we have to delete old entries from the source map
|
|
152
|
+
for (const key in projectConfigSourceMap) {
|
|
153
|
+
if (key.startsWith(`${targetIdentifier}`)) {
|
|
154
|
+
delete projectConfigSourceMap[key];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// merge top level properties if they're compatible
|
|
159
|
+
const result = {
|
|
160
|
+
...(isCompatible ? baseTargetProperties : {}),
|
|
161
|
+
...target,
|
|
162
|
+
};
|
|
163
|
+
// record top level properties in source map
|
|
164
|
+
if (projectConfigSourceMap) {
|
|
165
|
+
projectConfigSourceMap[targetIdentifier] = sourceInformation;
|
|
166
|
+
// record root level target properties to source map
|
|
167
|
+
for (const targetProperty in target) {
|
|
168
|
+
const targetPropertyId = `${targetIdentifier}.${targetProperty}`;
|
|
169
|
+
projectConfigSourceMap[targetPropertyId] = sourceInformation;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// merge options if there are any
|
|
173
|
+
// if the targets aren't compatible, we simply discard the old options during the merge
|
|
174
|
+
if (target.options || defaultOptions) {
|
|
175
|
+
result.options = mergeOptions(target.options, isCompatible ? defaultOptions : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
|
|
176
|
+
}
|
|
177
|
+
// merge configurations if there are any
|
|
178
|
+
// if the targets aren't compatible, we simply discard the old configurations during the merge
|
|
179
|
+
if (target.configurations || defaultConfigurations) {
|
|
180
|
+
result.configurations = mergeConfigurations(target.configurations, isCompatible ? defaultConfigurations : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
|
|
181
|
+
}
|
|
182
|
+
if (target.metadata) {
|
|
183
|
+
result.metadata = mergeMetadata(projectConfigSourceMap, sourceInformation, `${targetIdentifier}.metadata`, target.metadata, baseTarget?.metadata);
|
|
184
|
+
}
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Checks if targets options are compatible - used when merging configurations
|
|
189
|
+
* to avoid merging options for @nx/js:tsc into something like @nx/webpack:webpack.
|
|
190
|
+
*
|
|
191
|
+
* If the executors are both specified and don't match, the options aren't considered
|
|
192
|
+
* "compatible" and shouldn't be merged.
|
|
193
|
+
*/
|
|
194
|
+
function isCompatibleTarget(a, b) {
|
|
195
|
+
const oneHasNoExecutor = !a.executor || !b.executor;
|
|
196
|
+
const bothHaveSameExecutor = a.executor === b.executor;
|
|
197
|
+
if (oneHasNoExecutor)
|
|
198
|
+
return true;
|
|
199
|
+
if (!bothHaveSameExecutor)
|
|
200
|
+
return false;
|
|
201
|
+
const isRunCommands = a.executor === 'nx:run-commands';
|
|
202
|
+
if (isRunCommands) {
|
|
203
|
+
const aCommand = a.options?.command ?? a.options?.commands?.join(' && ');
|
|
204
|
+
const bCommand = b.options?.command ?? b.options?.commands?.join(' && ');
|
|
205
|
+
const oneHasNoCommand = !aCommand || !bCommand;
|
|
206
|
+
const hasSameCommand = aCommand === bCommand;
|
|
207
|
+
return oneHasNoCommand || hasSameCommand;
|
|
208
|
+
}
|
|
209
|
+
const isRunScript = a.executor === 'nx:run-script';
|
|
210
|
+
if (isRunScript) {
|
|
211
|
+
const aScript = a.options?.script;
|
|
212
|
+
const bScript = b.options?.script;
|
|
213
|
+
const oneHasNoScript = !aScript || !bScript;
|
|
214
|
+
const hasSameScript = aScript === bScript;
|
|
215
|
+
return oneHasNoScript || hasSameScript;
|
|
216
|
+
}
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
function targetDefaultShouldBeApplied(key, sourceMap) {
|
|
220
|
+
const sourceInfo = sourceMap[key];
|
|
221
|
+
if (!sourceInfo) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
// The defined value of the target is from a plugin that
|
|
225
|
+
// isn't part of Nx's core plugins, so target defaults are
|
|
226
|
+
// applied on top of it.
|
|
227
|
+
const [, plugin] = sourceInfo;
|
|
228
|
+
return !plugin?.startsWith('nx/');
|
|
229
|
+
}
|
|
230
|
+
function mergeTargetDefaultWithTargetDefinition(targetName, project, targetDefault, sourceMap) {
|
|
231
|
+
const targetDefinition = project.targets[targetName] ?? {};
|
|
232
|
+
const result = deepClone(targetDefinition);
|
|
233
|
+
for (const key in targetDefault) {
|
|
234
|
+
switch (key) {
|
|
235
|
+
case 'options': {
|
|
236
|
+
const normalizedDefaults = resolveNxTokensInOptions(targetDefault.options, project, targetName);
|
|
237
|
+
for (const optionKey in normalizedDefaults) {
|
|
238
|
+
const sourceMapKey = (0, source_maps_1.targetOptionSourceMapKey)(targetName, optionKey);
|
|
239
|
+
if (targetDefinition.options[optionKey] === undefined ||
|
|
240
|
+
targetDefaultShouldBeApplied(sourceMapKey, sourceMap)) {
|
|
241
|
+
result.options[optionKey] = targetDefault.options[optionKey];
|
|
242
|
+
sourceMap[sourceMapKey] = ['nx.json', 'nx/target-defaults'];
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
case 'configurations': {
|
|
248
|
+
if (!result.configurations) {
|
|
249
|
+
result.configurations = {};
|
|
250
|
+
sourceMap[(0, source_maps_1.targetConfigurationsSourceMapKey)(targetName)] = [
|
|
251
|
+
'nx.json',
|
|
252
|
+
'nx/target-defaults',
|
|
253
|
+
];
|
|
254
|
+
}
|
|
255
|
+
for (const configuration in targetDefault.configurations) {
|
|
256
|
+
if (!result.configurations[configuration]) {
|
|
257
|
+
result.configurations[configuration] = {};
|
|
258
|
+
sourceMap[(0, source_maps_1.targetConfigurationsSourceMapKey)(targetName, configuration)] = ['nx.json', 'nx/target-defaults'];
|
|
259
|
+
}
|
|
260
|
+
const normalizedConfigurationDefaults = resolveNxTokensInOptions(targetDefault.configurations[configuration], project, targetName);
|
|
261
|
+
for (const configurationKey in normalizedConfigurationDefaults) {
|
|
262
|
+
const sourceMapKey = (0, source_maps_1.targetConfigurationsSourceMapKey)(targetName, configuration, configurationKey);
|
|
263
|
+
if (targetDefinition.configurations?.[configuration]?.[configurationKey] === undefined ||
|
|
264
|
+
targetDefaultShouldBeApplied(sourceMapKey, sourceMap)) {
|
|
265
|
+
result.configurations[configuration][configurationKey] =
|
|
266
|
+
targetDefault.configurations[configuration][configurationKey];
|
|
267
|
+
sourceMap[sourceMapKey] = ['nx.json', 'nx/target-defaults'];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
default: {
|
|
274
|
+
const sourceMapKey = `targets.${targetName}.${key}`;
|
|
275
|
+
if (targetDefinition[key] === undefined ||
|
|
276
|
+
targetDefaultShouldBeApplied(sourceMapKey, sourceMap)) {
|
|
277
|
+
result[key] = targetDefault[key];
|
|
278
|
+
sourceMap[sourceMapKey] = ['nx.json', 'nx/target-defaults'];
|
|
279
|
+
}
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
function resolveNxTokensInOptions(object, project, key) {
|
|
287
|
+
const result = Array.isArray(object) ? [...object] : { ...object };
|
|
288
|
+
for (let [opt, value] of Object.entries(object ?? {})) {
|
|
289
|
+
if (typeof value === 'string') {
|
|
290
|
+
const workspaceRootMatch = /^(\{workspaceRoot\}\/?)/.exec(value);
|
|
291
|
+
if (workspaceRootMatch?.length) {
|
|
292
|
+
value = value.replace(workspaceRootMatch[0], '');
|
|
293
|
+
}
|
|
294
|
+
if (value.includes('{workspaceRoot}')) {
|
|
295
|
+
throw new Error(`${logger_1.NX_PREFIX} The {workspaceRoot} token is only valid at the beginning of an option. (${key})`);
|
|
296
|
+
}
|
|
297
|
+
value = value.replace(/\{projectRoot\}/g, project.root);
|
|
298
|
+
result[opt] = value.replace(/\{projectName\}/g, project.name);
|
|
299
|
+
}
|
|
300
|
+
else if (typeof value === 'object' && value) {
|
|
301
|
+
result[opt] = resolveNxTokensInOptions(value, project, [key, opt].join('.'));
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return result;
|
|
305
|
+
}
|
|
306
|
+
function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
|
|
307
|
+
if (executor && targetDefaults?.[executor]) {
|
|
308
|
+
// If an executor is defined in project.json, defaults should be read
|
|
309
|
+
// from the most specific key that matches that executor.
|
|
310
|
+
// e.g. If executor === run-commands, and the target is named build:
|
|
311
|
+
// Use, use nx:run-commands if it is present
|
|
312
|
+
// If not, use build if it is present.
|
|
313
|
+
return targetDefaults?.[executor];
|
|
314
|
+
}
|
|
315
|
+
else if (targetDefaults?.[targetName]) {
|
|
316
|
+
// If the executor is not defined, the only key we have is the target name.
|
|
317
|
+
return targetDefaults?.[targetName];
|
|
318
|
+
}
|
|
319
|
+
let matchingTargetDefaultKey = null;
|
|
320
|
+
for (const key in targetDefaults ?? {}) {
|
|
321
|
+
if ((0, globs_1.isGlobPattern)(key) && (0, minimatch_1.minimatch)(targetName, key)) {
|
|
322
|
+
if (!matchingTargetDefaultKey ||
|
|
323
|
+
matchingTargetDefaultKey.length < key.length) {
|
|
324
|
+
matchingTargetDefaultKey = key;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
if (matchingTargetDefaultKey) {
|
|
329
|
+
return targetDefaults[matchingTargetDefaultKey];
|
|
330
|
+
}
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NxJsonConfiguration } from '../../../config/nx-json';
|
|
2
|
+
import { ProjectConfiguration, TargetConfiguration } from '../../../config/workspace-json-project-json';
|
|
3
|
+
import type { ConfigurationSourceMaps } from './source-maps';
|
|
4
|
+
export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
|
|
5
|
+
/**
|
|
6
|
+
* Expand's `command` syntactic sugar, replaces tokens in options, and adds information from executor schema.
|
|
7
|
+
* @param target The target to normalize
|
|
8
|
+
* @param project The project that the target belongs to
|
|
9
|
+
* @returns The normalized target configuration
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration, workspaceRoot: string, projectsMap: Record<string, ProjectConfiguration>, errorMsgKey: string): TargetConfiguration<any>;
|
|
12
|
+
export declare function validateAndNormalizeProjectRootMap(workspaceRoot: string, projectRootMap: Record<string, ProjectConfiguration>, nxJsonConfiguration: NxJsonConfiguration, sourceMaps?: ConfigurationSourceMaps): Record<string, ProjectConfiguration>;
|
|
13
|
+
//# sourceMappingURL=target-normalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target-normalization.d.ts","sourceRoot":"","sources":["../../../../../../../packages/nx/src/project-graph/utils/project-configuration/target-normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,6CAA6C,CAAC;AAyBrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAK7D,wBAAgB,eAAe,CAC7B,OAAO,EAAE,oBAAoB,EAE7B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,QAkBpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,oBAAoB,EAC7B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACjD,WAAW,EAAE,MAAM,4BAiDpB;AAiFD,wBAAgB,kCAAkC,CAChD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EACpD,mBAAmB,EAAE,mBAAmB,EACxC,UAAU,GAAE,uBAA4B,wCA+EzC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateProject = validateProject;
|
|
4
|
+
exports.normalizeTarget = normalizeTarget;
|
|
5
|
+
exports.validateAndNormalizeProjectRootMap = validateAndNormalizeProjectRootMap;
|
|
6
|
+
const executor_utils_1 = require("../../../command-line/run/executor-utils");
|
|
7
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
8
|
+
const to_project_name_1 = require("../../../config/to-project-name");
|
|
9
|
+
const error_types_1 = require("../../error-types");
|
|
10
|
+
const target_merging_1 = require("./target-merging");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
function validateProject(project,
|
|
14
|
+
// name -> project
|
|
15
|
+
knownProjects) {
|
|
16
|
+
if (!project.name) {
|
|
17
|
+
try {
|
|
18
|
+
const { name } = (0, fileutils_1.readJsonFile)((0, path_1.join)(project.root, 'package.json'));
|
|
19
|
+
if (!name) {
|
|
20
|
+
throw new Error(`Project at ${project.root} has no name provided.`);
|
|
21
|
+
}
|
|
22
|
+
project.name = name;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new error_types_1.ProjectWithNoNameError(project.root);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (knownProjects[project.name] &&
|
|
29
|
+
knownProjects[project.name].root !== project.root) {
|
|
30
|
+
throw new error_types_1.ProjectWithExistingNameError(project.name, project.root);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Expand's `command` syntactic sugar, replaces tokens in options, and adds information from executor schema.
|
|
35
|
+
* @param target The target to normalize
|
|
36
|
+
* @param project The project that the target belongs to
|
|
37
|
+
* @returns The normalized target configuration
|
|
38
|
+
*/
|
|
39
|
+
function normalizeTarget(target, project, workspaceRoot, projectsMap, errorMsgKey) {
|
|
40
|
+
target = {
|
|
41
|
+
...target,
|
|
42
|
+
configurations: {
|
|
43
|
+
...target.configurations,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
target = (0, target_merging_1.resolveCommandSyntacticSugar)(target, project.root);
|
|
47
|
+
target.options = (0, target_merging_1.resolveNxTokensInOptions)(target.options, project, errorMsgKey);
|
|
48
|
+
for (const configuration in target.configurations) {
|
|
49
|
+
target.configurations[configuration] = (0, target_merging_1.resolveNxTokensInOptions)(target.configurations[configuration], project, `${project.root}:${target}:${configuration}`);
|
|
50
|
+
}
|
|
51
|
+
target.parallelism ??= true;
|
|
52
|
+
if (target.executor && !('continuous' in target)) {
|
|
53
|
+
try {
|
|
54
|
+
const [executorNodeModule, executorName] = (0, executor_utils_1.parseExecutor)(target.executor);
|
|
55
|
+
const { schema } = (0, executor_utils_1.getExecutorInformation)(executorNodeModule, executorName, workspaceRoot, projectsMap);
|
|
56
|
+
if (schema.continuous) {
|
|
57
|
+
target.continuous ??= schema.continuous;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// If the executor is not found, we assume that it is not a valid executor.
|
|
62
|
+
// This means that we should not set the continuous property.
|
|
63
|
+
// We could throw an error here, but it would be better to just ignore it.
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return target;
|
|
67
|
+
}
|
|
68
|
+
function normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot,
|
|
69
|
+
/**
|
|
70
|
+
* Project configurations keyed by project name
|
|
71
|
+
*/
|
|
72
|
+
projects) {
|
|
73
|
+
const targetErrorMessage = [];
|
|
74
|
+
for (const targetName in project.targets) {
|
|
75
|
+
project.targets[targetName] = normalizeTarget(project.targets[targetName], project, workspaceRoot, projects, [project.root, targetName].join(':'));
|
|
76
|
+
const projectSourceMaps = sourceMaps[project.root];
|
|
77
|
+
const targetConfig = project.targets[targetName];
|
|
78
|
+
const targetDefaults = (0, target_merging_1.deepClone)((0, target_merging_1.readTargetDefaultsForTarget)(targetName, nxJsonConfiguration.targetDefaults, targetConfig.executor));
|
|
79
|
+
// We only apply defaults if they exist
|
|
80
|
+
if (targetDefaults && (0, target_merging_1.isCompatibleTarget)(targetConfig, targetDefaults)) {
|
|
81
|
+
project.targets[targetName] = (0, target_merging_1.mergeTargetDefaultWithTargetDefinition)(targetName, project, normalizeTarget(targetDefaults, project, workspaceRoot, projects, ['nx.json[targetDefaults]', targetName].join(':')), projectSourceMaps);
|
|
82
|
+
}
|
|
83
|
+
const target = project.targets[targetName];
|
|
84
|
+
if (
|
|
85
|
+
// If the target has no executor or command, it doesn't do anything
|
|
86
|
+
!target.executor &&
|
|
87
|
+
!target.command) {
|
|
88
|
+
// But it may have dependencies that do something
|
|
89
|
+
if (target.dependsOn && target.dependsOn.length > 0) {
|
|
90
|
+
target.executor = 'nx:noop';
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// If it does nothing, and has no depenencies,
|
|
94
|
+
// we can remove it.
|
|
95
|
+
delete project.targets[targetName];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (target.cache && target.continuous) {
|
|
99
|
+
targetErrorMessage.push(`- "${targetName}" has both "cache" and "continuous" set to true. Continuous targets cannot be cached. Please remove the "cache" property.`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (targetErrorMessage.length > 0) {
|
|
103
|
+
targetErrorMessage.unshift(`Errors detected in targets of project "${project.name}":`);
|
|
104
|
+
throw new error_types_1.WorkspaceValidityError(targetErrorMessage.join('\n'));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJsonConfiguration, sourceMaps = {}) {
|
|
108
|
+
// Name -> Project, used to validate that all projects have unique names
|
|
109
|
+
const projects = {};
|
|
110
|
+
// If there are projects that have the same name, that is an error.
|
|
111
|
+
// This object tracks name -> (all roots of projects with that name)
|
|
112
|
+
// to provide better error messaging.
|
|
113
|
+
const conflicts = new Map();
|
|
114
|
+
const projectRootsWithNoName = [];
|
|
115
|
+
const validityErrors = [];
|
|
116
|
+
for (const root in projectRootMap) {
|
|
117
|
+
const project = projectRootMap[root];
|
|
118
|
+
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
|
119
|
+
// Strip it before returning configuration for usage.
|
|
120
|
+
if (project['// targets'])
|
|
121
|
+
delete project['// targets'];
|
|
122
|
+
// We initially did this in the project.json plugin, but
|
|
123
|
+
// that resulted in project.json files without names causing
|
|
124
|
+
// the resulting project to change names from earlier plugins...
|
|
125
|
+
if (!project.name &&
|
|
126
|
+
(0, node_fs_1.existsSync)((0, path_1.join)(workspaceRoot, project.root, 'project.json'))) {
|
|
127
|
+
project.name = (0, to_project_name_1.toProjectName)((0, path_1.join)(root, 'project.json'));
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
validateProject(project, projects);
|
|
131
|
+
projects[project.name] = project;
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
if ((0, error_types_1.isProjectWithNoNameError)(e)) {
|
|
135
|
+
projectRootsWithNoName.push(e.projectRoot);
|
|
136
|
+
}
|
|
137
|
+
else if ((0, error_types_1.isProjectWithExistingNameError)(e)) {
|
|
138
|
+
const rootErrors = conflicts.get(e.projectName) ?? [
|
|
139
|
+
projects[e.projectName].root,
|
|
140
|
+
];
|
|
141
|
+
rootErrors.push(e.projectRoot);
|
|
142
|
+
conflicts.set(e.projectName, rootErrors);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
throw e;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const root in projectRootMap) {
|
|
150
|
+
const project = projectRootMap[root];
|
|
151
|
+
try {
|
|
152
|
+
normalizeTargets(project, sourceMaps, nxJsonConfiguration, workspaceRoot, projects);
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
if (e instanceof error_types_1.WorkspaceValidityError) {
|
|
156
|
+
validityErrors.push(e);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw e;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const errors = [];
|
|
164
|
+
if (conflicts.size > 0) {
|
|
165
|
+
errors.push(new error_types_1.MultipleProjectsWithSameNameError(conflicts, projects));
|
|
166
|
+
}
|
|
167
|
+
if (projectRootsWithNoName.length > 0) {
|
|
168
|
+
errors.push(new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects));
|
|
169
|
+
}
|
|
170
|
+
if (validityErrors.length > 0) {
|
|
171
|
+
errors.push(...validityErrors);
|
|
172
|
+
}
|
|
173
|
+
if (errors.length > 0) {
|
|
174
|
+
throw new AggregateError(errors);
|
|
175
|
+
}
|
|
176
|
+
return projectRootMap;
|
|
177
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { NxJsonConfiguration
|
|
1
|
+
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
|
3
|
-
import { ProjectConfiguration
|
|
3
|
+
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
4
|
+
import { AggregateCreateNodesError, MergeNodesError, MultipleProjectsWithSameNameError, ProjectsWithNoNameError, WorkspaceValidityError } from '../error-types';
|
|
4
5
|
import type { LoadedNxPlugin } from '../plugins/loaded-nx-plugin';
|
|
6
|
+
import { CreateNodesResult } from '../plugins/public-api';
|
|
5
7
|
import type { ConfigurationSourceMaps, SourceInformation } from './project-configuration/source-maps';
|
|
6
|
-
export
|
|
7
|
-
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): {
|
|
8
|
-
previousName?: string;
|
|
9
|
-
};
|
|
10
|
-
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;
|
|
8
|
+
export { mergeTargetConfigurations, readTargetDefaultsForTarget, } from './project-configuration/target-merging';
|
|
11
9
|
export type ConfigurationResult = {
|
|
12
10
|
/**
|
|
13
11
|
* A map of project configurations, keyed by project root.
|
|
@@ -39,39 +37,16 @@ export type ConfigurationResult = {
|
|
|
39
37
|
*/
|
|
40
38
|
export declare function createProjectConfigurationsWithPlugins(root: string, nxJson: NxJsonConfiguration, projectFiles: string[][], // making this parameter allows devkit to pick up newly created projects
|
|
41
39
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
|
40
|
+
export declare function mergeCreateNodesResults(results: (readonly [
|
|
41
|
+
plugin: string,
|
|
42
|
+
file: string,
|
|
43
|
+
result: CreateNodesResult,
|
|
44
|
+
pluginIndex?: number
|
|
45
|
+
])[][], nxJsonConfiguration: NxJsonConfiguration, workspaceRoot: string, errors: (AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | WorkspaceValidityError)[]): {
|
|
46
|
+
projectRootMap: Record<string, ProjectConfiguration>;
|
|
47
|
+
externalNodes: Record<string, ProjectGraphExternalNode>;
|
|
48
|
+
rootMap: Record<string, string>;
|
|
49
|
+
configurationSourceMaps: Record<string, Record<string, SourceInformation>>;
|
|
50
|
+
};
|
|
42
51
|
export declare function findMatchingConfigFiles(projectFiles: string[], pattern: string, include: string[], exclude: string[]): string[];
|
|
43
|
-
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
|
44
|
-
export declare function validateProject(project: ProjectConfiguration, knownProjects: Record<string, ProjectConfiguration>): void;
|
|
45
|
-
export declare function mergeTargetDefaultWithTargetDefinition(targetName: string, project: ProjectConfiguration, targetDefault: Partial<TargetConfiguration>, sourceMap: Record<string, SourceInformation>): TargetConfiguration;
|
|
46
|
-
/**
|
|
47
|
-
* Merges two targets.
|
|
48
|
-
*
|
|
49
|
-
* Most properties from `target` will overwrite any properties from `baseTarget`.
|
|
50
|
-
* Options and configurations are treated differently - they are merged together if the executor definition is compatible.
|
|
51
|
-
*
|
|
52
|
-
* @param target The target definition with higher priority
|
|
53
|
-
* @param baseTarget The target definition that should be overwritten. Can be undefined, in which case the target is returned as-is.
|
|
54
|
-
* @param projectConfigSourceMap The source map to be filled with metadata about where each property came from
|
|
55
|
-
* @param sourceInformation The metadata about where the new target was defined
|
|
56
|
-
* @param targetIdentifier The identifier for the target to merge, used for source map
|
|
57
|
-
* @returns A merged target configuration
|
|
58
|
-
*/
|
|
59
|
-
export declare function mergeTargetConfigurations(target: TargetConfiguration, baseTarget?: TargetConfiguration, projectConfigSourceMap?: Record<string, SourceInformation>, sourceInformation?: SourceInformation, targetIdentifier?: string): TargetConfiguration;
|
|
60
|
-
/**
|
|
61
|
-
* Checks if targets options are compatible - used when merging configurations
|
|
62
|
-
* to avoid merging options for @nx/js:tsc into something like @nx/webpack:webpack.
|
|
63
|
-
*
|
|
64
|
-
* If the executors are both specified and don't match, the options aren't considered
|
|
65
|
-
* "compatible" and shouldn't be merged.
|
|
66
|
-
*/
|
|
67
|
-
export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
|
|
68
|
-
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
|
69
|
-
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
|
70
|
-
/**
|
|
71
|
-
* Expand's `command` syntactic sugar, replaces tokens in options, and adds information from executor schema.
|
|
72
|
-
* @param target The target to normalize
|
|
73
|
-
* @param project The project that the target belongs to
|
|
74
|
-
* @returns The normalized target configuration
|
|
75
|
-
*/
|
|
76
|
-
export declare function normalizeTarget(target: TargetConfiguration, project: ProjectConfiguration, workspaceRoot: string, projectsMap: Record<string, ProjectConfiguration>, errorMsgKey: string): TargetConfiguration<any>;
|
|
77
52
|
//# sourceMappingURL=project-configuration-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-configuration-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/project-graph/utils/project-configuration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"project-configuration-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/project-graph/utils/project-configuration-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAYhF,OAAO,EACL,yBAAyB,EAMzB,eAAe,EACf,iCAAiC,EAEjC,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,wCAAwC,CAAC;AAEhD,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,QAAQ,EAAE;QACR,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAAC;KAC7C,CAAC;IAEF;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IAExD;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEvC,UAAU,EAAE,uBAAuB,CAAC;IAEpC;;OAEG;IACH,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,sCAAsC,CAC1D,IAAI,EAAE,MAAsB,EAC5B,MAAM,EAAE,mBAAmB,EAC3B,YAAY,EAAE,MAAM,EAAE,EAAE,EAAE,wEAAwE;AAClG,OAAO,EAAE,cAAc,EAAE,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAuI9B;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,CAAC,SAAS;IACjB,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,iBAAiB;IACzB,WAAW,CAAC,EAAE,MAAM;CACrB,CAAC,EAAE,EAAE,EACN,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,CACJ,yBAAyB,GACzB,eAAe,GACf,uBAAuB,GACvB,iCAAiC,GACjC,sBAAsB,CACzB,EAAE;;;;;EAoHJ;AAoDD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EAAE,EACjB,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,EAAE,CAuBV"}
|