nx 19.5.0-canary.20240705-653cad2 → 19.5.0-canary.20240709-92e09d9
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +30 -26
- package/src/command-line/graph/graph.js +7 -2
- package/src/command-line/watch/watch.js +6 -0
- package/src/commands-runner/create-command-graph.js +32 -10
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.d.ts +1 -0
- package/src/daemon/client/client.js +14 -2
- package/src/devkit-exports.d.ts +1 -0
- package/src/devkit-exports.js +3 -1
- package/src/native/browser.js +1 -0
- package/src/native/index.d.ts +178 -138
- package/src/native/index.js +16 -0
- package/src/native/native-bindings.js +352 -238
- package/src/native/nx.wasi-browser.js +108 -0
- package/src/native/nx.wasi.cjs +139 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/native/wasi-worker-browser.mjs +32 -0
- package/src/native/wasi-worker.mjs +63 -0
- package/src/project-graph/plugins/isolation/messaging.d.ts +1 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/src/project-graph/utils/project-configuration-utils.js +3 -1
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/create-task-graph.d.ts +2 -1
- package/src/tasks-runner/create-task-graph.js +14 -30
- package/src/tasks-runner/pseudo-terminal.js +3 -0
- package/src/tasks-runner/task-graph-utils.d.ts +1 -1
- package/src/tasks-runner/task-graph-utils.js +4 -4
- package/src/tasks-runner/utils.d.ts +15 -2
- package/src/tasks-runner/utils.js +88 -24
- package/src/utils/find-matching-projects.d.ts +4 -0
- package/src/utils/find-matching-projects.js +7 -4
- package/src/utils/serializable-error.js +6 -0
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = void 0;
|
4
|
-
const output_1 = require("../utils/output");
|
3
|
+
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.normalizeTargetDependencyWithStringProjects = exports.getOutputs = exports.readProjectAndTargetFromTargetString = exports.expandWildcardTargetConfiguration = exports.expandDependencyConfigSyntaxSugar = exports.normalizeDependencyConfigProjects = exports.normalizeDependencyConfigDefinition = exports.getDependencyConfigs = void 0;
|
5
4
|
const path_1 = require("path");
|
6
5
|
const posix_1 = require("path/posix");
|
7
6
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -11,28 +10,35 @@ const serialize_overrides_into_command_line_1 = require("../utils/serialize-over
|
|
11
10
|
const split_target_1 = require("../utils/split-target");
|
12
11
|
const executor_utils_1 = require("../command-line/run/executor-utils");
|
13
12
|
const project_graph_1 = require("../project-graph/project-graph");
|
14
|
-
|
13
|
+
const find_matching_projects_1 = require("../utils/find-matching-projects");
|
14
|
+
const minimatch_1 = require("minimatch");
|
15
|
+
function getDependencyConfigs({ project, target }, extraTargetDependencies, projectGraph, allTargetNames) {
|
15
16
|
const dependencyConfigs = (projectGraph.nodes[project].data?.targets[target]?.dependsOn ??
|
16
17
|
// This is passed into `run-command` from programmatic invocations
|
17
18
|
extraTargetDependencies[target] ??
|
18
|
-
[]).
|
19
|
-
? expandDependencyConfigSyntaxSugar(config, projectGraph)
|
20
|
-
: config);
|
21
|
-
for (const dependencyConfig of dependencyConfigs) {
|
22
|
-
if (dependencyConfig.projects && dependencyConfig.dependencies) {
|
23
|
-
output_1.output.error({
|
24
|
-
title: `dependsOn is improperly configured for ${project}:${target}`,
|
25
|
-
bodyLines: [
|
26
|
-
`dependsOn.projects and dependsOn.dependencies cannot be used together.`,
|
27
|
-
],
|
28
|
-
});
|
29
|
-
process.exit(1);
|
30
|
-
}
|
31
|
-
}
|
19
|
+
[]).flatMap((config) => normalizeDependencyConfigDefinition(config, project, projectGraph, allTargetNames));
|
32
20
|
return dependencyConfigs;
|
33
21
|
}
|
34
22
|
exports.getDependencyConfigs = getDependencyConfigs;
|
23
|
+
function normalizeDependencyConfigDefinition(definition, currentProject, graph, allTargetNames) {
|
24
|
+
return expandWildcardTargetConfiguration(normalizeDependencyConfigProjects(expandDependencyConfigSyntaxSugar(definition, graph), currentProject, graph), allTargetNames);
|
25
|
+
}
|
26
|
+
exports.normalizeDependencyConfigDefinition = normalizeDependencyConfigDefinition;
|
27
|
+
function normalizeDependencyConfigProjects(dependencyConfig, currentProject, graph) {
|
28
|
+
const noStringConfig = normalizeTargetDependencyWithStringProjects(dependencyConfig);
|
29
|
+
if (noStringConfig.projects) {
|
30
|
+
dependencyConfig.projects = (0, find_matching_projects_1.findMatchingProjects)(noStringConfig.projects, graph.nodes);
|
31
|
+
}
|
32
|
+
else if (!noStringConfig.dependencies) {
|
33
|
+
dependencyConfig.projects = [currentProject];
|
34
|
+
}
|
35
|
+
return dependencyConfig;
|
36
|
+
}
|
37
|
+
exports.normalizeDependencyConfigProjects = normalizeDependencyConfigProjects;
|
35
38
|
function expandDependencyConfigSyntaxSugar(dependencyConfigString, graph) {
|
39
|
+
if (typeof dependencyConfigString !== 'string') {
|
40
|
+
return dependencyConfigString;
|
41
|
+
}
|
36
42
|
const [dependencies, targetString] = dependencyConfigString.startsWith('^')
|
37
43
|
? [true, dependencyConfigString.substring(1)]
|
38
44
|
: [false, dependencyConfigString];
|
@@ -44,26 +50,84 @@ function expandDependencyConfigSyntaxSugar(dependencyConfigString, graph) {
|
|
44
50
|
dependencies: true,
|
45
51
|
};
|
46
52
|
}
|
53
|
+
const { projects, target } = readProjectAndTargetFromTargetString(targetString, graph.nodes);
|
54
|
+
return projects ? { projects, target } : { target };
|
55
|
+
}
|
56
|
+
exports.expandDependencyConfigSyntaxSugar = expandDependencyConfigSyntaxSugar;
|
57
|
+
// Weakmap let's the cache get cleared by garbage collector if allTargetNames is no longer used
|
58
|
+
const patternResultCache = new WeakMap();
|
59
|
+
function expandWildcardTargetConfiguration(dependencyConfig, allTargetNames) {
|
60
|
+
if (!find_matching_projects_1.GLOB_CHARACTERS.some((char) => dependencyConfig.target.includes(char))) {
|
61
|
+
return [dependencyConfig];
|
62
|
+
}
|
63
|
+
let cache = patternResultCache.get(allTargetNames);
|
64
|
+
if (!cache) {
|
65
|
+
cache = new Map();
|
66
|
+
patternResultCache.set(allTargetNames, cache);
|
67
|
+
}
|
68
|
+
const cachedResult = cache.get(dependencyConfig.target);
|
69
|
+
if (cachedResult) {
|
70
|
+
return cachedResult;
|
71
|
+
}
|
72
|
+
const matcher = minimatch_1.minimatch.filter(dependencyConfig.target);
|
73
|
+
const matchingTargets = allTargetNames.filter((t) => matcher(t));
|
74
|
+
const result = matchingTargets.map((t) => ({
|
75
|
+
...dependencyConfig,
|
76
|
+
target: t,
|
77
|
+
}));
|
78
|
+
cache.set(dependencyConfig.target, result);
|
79
|
+
return result;
|
80
|
+
}
|
81
|
+
exports.expandWildcardTargetConfiguration = expandWildcardTargetConfiguration;
|
82
|
+
function readProjectAndTargetFromTargetString(targetString, projects) {
|
47
83
|
// Support for both `project:target` and `target:with:colons` syntax
|
48
84
|
const [maybeProject, ...segments] = (0, split_target_1.splitByColons)(targetString);
|
49
|
-
// if no additional segments are provided, then the string references
|
50
|
-
// a target of the same project
|
51
85
|
if (!segments.length) {
|
86
|
+
// if no additional segments are provided, then the string references
|
87
|
+
// a target of the same project
|
52
88
|
return { target: maybeProject };
|
53
89
|
}
|
54
|
-
|
90
|
+
else if (maybeProject in projects) {
|
55
91
|
// Only the first segment could be a project. If it is, the rest is a target.
|
56
92
|
// If its not, then the whole targetString was a target with colons in its name.
|
57
|
-
|
93
|
+
return { projects: [maybeProject], target: segments.join(':') };
|
94
|
+
}
|
95
|
+
else {
|
58
96
|
// If the first segment is a project, then we have a specific project. Otherwise, we don't.
|
59
|
-
|
60
|
-
}
|
97
|
+
return { target: targetString };
|
98
|
+
}
|
61
99
|
}
|
62
|
-
exports.
|
100
|
+
exports.readProjectAndTargetFromTargetString = readProjectAndTargetFromTargetString;
|
63
101
|
function getOutputs(p, target, overrides) {
|
64
102
|
return getOutputsForTargetAndConfiguration(target, overrides, p[target.project]);
|
65
103
|
}
|
66
104
|
exports.getOutputs = getOutputs;
|
105
|
+
function normalizeTargetDependencyWithStringProjects(dependencyConfig) {
|
106
|
+
if (typeof dependencyConfig.projects === 'string') {
|
107
|
+
/** LERNA SUPPORT START - Remove in v20 */
|
108
|
+
// Lerna uses `dependencies` in `prepNxOptions`, so we need to maintain
|
109
|
+
// support for it until lerna can be updated to use the syntax.
|
110
|
+
//
|
111
|
+
// This should have been removed in v17, but the updates to lerna had not
|
112
|
+
// been made yet.
|
113
|
+
//
|
114
|
+
// TODO(@agentender): Remove this part in v20
|
115
|
+
if (dependencyConfig.projects === 'self') {
|
116
|
+
delete dependencyConfig.projects;
|
117
|
+
}
|
118
|
+
else if (dependencyConfig.projects === 'dependencies') {
|
119
|
+
dependencyConfig.dependencies = true;
|
120
|
+
delete dependencyConfig.projects;
|
121
|
+
return;
|
122
|
+
/** LERNA SUPPORT END - Remove in v20 */
|
123
|
+
}
|
124
|
+
else {
|
125
|
+
dependencyConfig.projects = [dependencyConfig.projects];
|
126
|
+
}
|
127
|
+
}
|
128
|
+
return dependencyConfig;
|
129
|
+
}
|
130
|
+
exports.normalizeTargetDependencyWithStringProjects = normalizeTargetDependencyWithStringProjects;
|
67
131
|
class InvalidOutputsError extends Error {
|
68
132
|
constructor(outputs, invalidOutputs) {
|
69
133
|
super(InvalidOutputsError.createMessage(invalidOutputs));
|
@@ -1,4 +1,8 @@
|
|
1
1
|
import type { ProjectGraphProjectNode } from '../config/project-graph';
|
2
|
+
/**
|
3
|
+
* The presence of these characters in a string indicates that it might be a glob pattern.
|
4
|
+
*/
|
5
|
+
export declare const GLOB_CHARACTERS: string[];
|
2
6
|
/**
|
3
7
|
* Find matching project names given a list of potential project names or globs.
|
4
8
|
*
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getMatchingStringsWithCache = exports.findMatchingProjects = void 0;
|
3
|
+
exports.getMatchingStringsWithCache = exports.findMatchingProjects = exports.GLOB_CHARACTERS = void 0;
|
4
4
|
const minimatch_1 = require("minimatch");
|
5
5
|
const validPatternTypes = [
|
6
6
|
'name', // Pattern is based on the project's name
|
@@ -8,7 +8,10 @@ const validPatternTypes = [
|
|
8
8
|
'directory', // Pattern is based on the project's root directory
|
9
9
|
'unlabeled', // Pattern was passed without specifying a type
|
10
10
|
];
|
11
|
-
|
11
|
+
/**
|
12
|
+
* The presence of these characters in a string indicates that it might be a glob pattern.
|
13
|
+
*/
|
14
|
+
exports.GLOB_CHARACTERS = ['*', '|', '{', '}', '(', ')'];
|
12
15
|
/**
|
13
16
|
* Find matching project names given a list of potential project names or globs.
|
14
17
|
*
|
@@ -110,7 +113,7 @@ function addMatchingProjectsByName(projectNames, projects, pattern, matchedProje
|
|
110
113
|
}
|
111
114
|
return;
|
112
115
|
}
|
113
|
-
if (!
|
116
|
+
if (!exports.GLOB_CHARACTERS.some((c) => pattern.value.includes(c))) {
|
114
117
|
return;
|
115
118
|
}
|
116
119
|
const matchedProjectNames = (0, exports.getMatchingStringsWithCache)(pattern.value, projectNames);
|
@@ -135,7 +138,7 @@ function addMatchingProjectsByTag(projectNames, projects, pattern, matchedProjec
|
|
135
138
|
}
|
136
139
|
continue;
|
137
140
|
}
|
138
|
-
if (!
|
141
|
+
if (!exports.GLOB_CHARACTERS.some((c) => pattern.value.includes(c))) {
|
139
142
|
continue;
|
140
143
|
}
|
141
144
|
if ((0, exports.getMatchingStringsWithCache)(pattern.value, tags).length) {
|
@@ -17,6 +17,12 @@ function createSerializableError(error) {
|
|
17
17
|
value = value.map((v) => {
|
18
18
|
if (typeof v === 'object' && v instanceof Error) {
|
19
19
|
return createSerializableError(v);
|
20
|
+
// Support for AggregateCreateNodesError
|
21
|
+
}
|
22
|
+
else if (Array.isArray(v) &&
|
23
|
+
v.length === 2 &&
|
24
|
+
v[1] instanceof Error) {
|
25
|
+
return [v[0], createSerializableError(v[1])];
|
20
26
|
}
|
21
27
|
return v;
|
22
28
|
});
|