nx 24.0.6 → 24.1.0-beta.1
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/dist/bin/init-local.js +2 -4
- package/dist/bin/nx-cloud.js +2 -1
- package/dist/bin/nx.js +12 -14
- package/dist/bin/run-executor.js +5 -0
- package/dist/src/adapter/compat.d.ts +1 -1
- package/dist/src/adapter/compat.js +1 -0
- package/dist/src/adapter/ngcli-adapter.js +7 -20
- package/dist/src/command-line/completion/scripts/bash.sh +9 -2
- package/dist/src/command-line/completion/scripts/fish.fish +10 -2
- package/dist/src/command-line/completion/scripts/zsh.zsh +8 -2
- package/dist/src/command-line/completion/scripts.js +18 -8
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -1
- package/dist/src/command-line/conformance/command-object.d.ts +3 -0
- package/dist/src/command-line/conformance/command-object.js +66 -0
- package/dist/src/command-line/generate/generate.js +14 -27
- package/dist/src/command-line/generate/generator-utils.d.ts +1 -0
- package/dist/src/command-line/generate/generator-utils.js +9 -0
- package/dist/src/command-line/graph/graph.js +1 -7
- package/dist/src/command-line/import/import.js +26 -2
- package/dist/src/command-line/import/utils/ai-output.d.ts +9 -1
- package/dist/src/command-line/import/utils/ai-output.js +20 -1
- package/dist/src/command-line/import/utils/prepare-source-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +2 -2
- package/dist/src/command-line/init/init-v2.js +2 -2
- package/dist/src/command-line/migrate/migrate.js +1 -4
- package/dist/src/command-line/migrate/prompt-files.js +5 -5
- package/dist/src/command-line/migrate/run/orchestrator.js +2 -3
- package/dist/src/command-line/migrate/run/worker.js +7 -5
- package/dist/src/command-line/migrate/run-migration-process.js +3 -2
- package/dist/src/command-line/nx-commands.d.ts +1 -1
- package/dist/src/command-line/nx-commands.js +82 -132
- package/dist/src/command-line/release/changelog.js +8 -39
- package/dist/src/command-line/release/command-object.d.ts +1 -0
- package/dist/src/command-line/release/command-object.js +4 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.js +1 -1
- package/dist/src/command-line/release/release.js +6 -4
- package/dist/src/command-line/release/utils/diff.js +0 -14
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/release/utils/resolve-nx-json-error-message.js +2 -24
- package/dist/src/command-line/report/report.js +1 -1
- package/dist/src/command-line/run/executor-utils.js +1 -1
- package/dist/src/command-line/show/show-target/utils.js +1 -1
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/commands-runner/get-command-projects.js +0 -3
- package/dist/src/config/misc-interfaces.d.ts +0 -1
- package/dist/src/config/nx-json.d.ts +117 -0
- package/dist/src/config/workspace-json-project-json.d.ts +6 -7
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +13 -20
- package/dist/src/devkit-exports.d.ts +1 -1
- package/dist/src/devkit-internals.d.ts +11 -4
- package/dist/src/devkit-internals.js +27 -5
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +1 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +35 -13
- package/dist/src/hasher/hash-task.js +4 -4
- package/dist/src/hasher/task-hasher.js +2 -2
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.d.ts +4 -0
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.js +117 -0
- package/dist/src/migrations/update-24-1-0/replace-powerpack-conformance.md +38 -0
- package/dist/src/native/index.d.ts +6 -4
- package/dist/src/native/index.js +5 -0
- package/dist/src/native/native-bindings.js +1 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/native/transform-objects.d.ts +2 -0
- package/dist/src/native/transform-objects.js +15 -0
- package/dist/src/nx-cloud/utilities/environment.js +0 -17
- package/dist/src/plugins/js/lock-file/bun-parser.d.ts +1 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +5 -5
- package/dist/src/plugins/js/lock-file/lock-file-names.d.ts +6 -0
- package/dist/src/plugins/js/lock-file/lock-file-names.js +16 -0
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +1 -2
- package/dist/src/plugins/js/lock-file/lock-file.js +24 -31
- package/dist/src/plugins/js/lock-file/npm-parser.js +1 -2
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +50 -2
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +5 -0
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +75 -13
- package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.js +1 -1
- package/dist/src/plugins/js/utils/register.js +13 -6
- package/dist/src/project-graph/affected/affected-tasks.js +1 -1
- package/dist/src/project-graph/build-project-graph.js +5 -2
- package/dist/src/project-graph/nx-deps-cache.d.ts +3 -2
- package/dist/src/project-graph/nx-deps-cache.js +8 -2
- package/dist/src/project-graph/utils/project-graph-paths.d.ts +8 -0
- package/dist/src/project-graph/utils/project-graph-paths.js +170 -0
- package/dist/src/tasks-runner/batch/run-batch.js +3 -13
- package/dist/src/tasks-runner/cache.js +19 -18
- package/dist/src/tasks-runner/run-command.js +12 -10
- package/dist/src/tasks-runner/task-orchestrator.d.ts +1 -0
- package/dist/src/tasks-runner/task-orchestrator.js +14 -3
- package/dist/src/tasks-runner/utils.js +1 -12
- package/dist/src/ultracache/overrides.js +1 -1
- package/dist/src/utils/child-process.js +2 -1
- package/dist/src/utils/code-frames.js +0 -1
- package/dist/src/utils/db-connection.js +6 -4
- package/dist/src/utils/find-workspace-root.js +2 -4
- package/dist/src/utils/git-utils.d.ts +5 -0
- package/dist/src/utils/git-utils.js +23 -1
- package/dist/src/utils/handle-import.js +6 -0
- package/dist/src/utils/installation-directory.d.ts +16 -0
- package/dist/src/utils/installation-directory.js +96 -2
- package/dist/src/utils/json.d.ts +7 -0
- package/dist/src/utils/json.js +27 -0
- package/dist/src/utils/min-release-age/behavior/pnpm.js +9 -9
- package/dist/src/utils/min-release-age/behavior/yarn.js +2 -2
- package/dist/src/utils/nx-key.js +11 -8
- package/dist/src/utils/output.d.ts +5 -0
- package/dist/src/utils/output.js +11 -4
- package/dist/src/utils/owned-private-dir.d.ts +10 -0
- package/dist/src/utils/owned-private-dir.js +28 -0
- package/dist/src/utils/plugins/output.js +0 -2
- package/dist/src/utils/require-nx-key.js +6 -4
- package/dist/src/utils/workspace-root.d.ts +12 -0
- package/dist/src/utils/workspace-root.js +56 -7
- package/migrations.json +6 -0
- package/package.json +14 -12
- package/schemas/nx-schema.json +75 -9
- package/schemas/project-schema.json +5 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPath = getPath;
|
|
4
|
+
exports.pathExists = pathExists;
|
|
5
|
+
exports.checkCircularPath = checkCircularPath;
|
|
6
|
+
exports.circularPathHasPair = circularPathHasPair;
|
|
7
|
+
exports.findFilesInCircularPath = findFilesInCircularPath;
|
|
8
|
+
exports.findFilesWithDynamicImports = findFilesWithDynamicImports;
|
|
9
|
+
exports.expandIgnoredCircularDependencies = expandIgnoredCircularDependencies;
|
|
10
|
+
const project_graph_1 = require("../../config/project-graph");
|
|
11
|
+
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
|
12
|
+
const reach = {
|
|
13
|
+
graph: null,
|
|
14
|
+
matrix: null,
|
|
15
|
+
adjList: null,
|
|
16
|
+
};
|
|
17
|
+
function buildMatrix(graph) {
|
|
18
|
+
const nodes = Object.keys(graph.nodes);
|
|
19
|
+
const nodesLength = nodes.length;
|
|
20
|
+
const adjList = {};
|
|
21
|
+
const matrix = {};
|
|
22
|
+
// create matrix value set
|
|
23
|
+
for (let i = 0; i < nodesLength; i++) {
|
|
24
|
+
const v = nodes[i];
|
|
25
|
+
adjList[v] = [];
|
|
26
|
+
// meeroslav: turns out this is 10x faster than spreading the pre-generated initMatrixValues
|
|
27
|
+
matrix[v] = {};
|
|
28
|
+
}
|
|
29
|
+
const projectsWithDependencies = Object.keys(graph.dependencies);
|
|
30
|
+
for (let i = 0; i < projectsWithDependencies.length; i++) {
|
|
31
|
+
const dependencies = graph.dependencies[projectsWithDependencies[i]];
|
|
32
|
+
for (let j = 0; j < dependencies.length; j++) {
|
|
33
|
+
const dependency = dependencies[j];
|
|
34
|
+
if (graph.nodes[dependency.target]) {
|
|
35
|
+
adjList[dependency.source].push(dependency.target);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const traverse = (s, v) => {
|
|
40
|
+
matrix[s][v] = true;
|
|
41
|
+
const adjListLength = adjList[v].length;
|
|
42
|
+
for (let i = 0; i < adjListLength; i++) {
|
|
43
|
+
const adj = adjList[v][i];
|
|
44
|
+
if (!matrix[s][adj]) {
|
|
45
|
+
traverse(s, adj);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
for (let i = 0; i < nodesLength; i++) {
|
|
50
|
+
const v = nodes[i];
|
|
51
|
+
traverse(v, v);
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
matrix,
|
|
55
|
+
adjList,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function getPath(graph, sourceProjectName, targetProjectName) {
|
|
59
|
+
if (sourceProjectName === targetProjectName)
|
|
60
|
+
return [];
|
|
61
|
+
if (reach.graph !== graph) {
|
|
62
|
+
const { matrix, adjList } = buildMatrix(graph);
|
|
63
|
+
reach.graph = graph;
|
|
64
|
+
reach.matrix = matrix;
|
|
65
|
+
reach.adjList = adjList;
|
|
66
|
+
}
|
|
67
|
+
const adjList = reach.adjList;
|
|
68
|
+
let path = [];
|
|
69
|
+
const queue = [[sourceProjectName, path]];
|
|
70
|
+
const visited = [sourceProjectName];
|
|
71
|
+
while (queue.length > 0) {
|
|
72
|
+
const [current, p] = queue.pop();
|
|
73
|
+
path = [...p, current];
|
|
74
|
+
if (current === targetProjectName)
|
|
75
|
+
break;
|
|
76
|
+
if (!adjList[current])
|
|
77
|
+
break;
|
|
78
|
+
adjList[current]
|
|
79
|
+
.filter((adj) => visited.indexOf(adj) === -1)
|
|
80
|
+
.filter((adj) => reach.matrix[adj][targetProjectName])
|
|
81
|
+
.forEach((adj) => {
|
|
82
|
+
visited.push(adj);
|
|
83
|
+
queue.push([adj, [...path]]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (path.length > 1) {
|
|
87
|
+
return path.map((n) => graph.nodes[n]);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function pathExists(graph, sourceProjectName, targetProjectName) {
|
|
94
|
+
if (sourceProjectName === targetProjectName)
|
|
95
|
+
return true;
|
|
96
|
+
if (reach.graph !== graph) {
|
|
97
|
+
const { matrix, adjList } = buildMatrix(graph);
|
|
98
|
+
reach.graph = graph;
|
|
99
|
+
reach.matrix = matrix;
|
|
100
|
+
reach.adjList = adjList;
|
|
101
|
+
}
|
|
102
|
+
return !!reach.matrix[sourceProjectName][targetProjectName];
|
|
103
|
+
}
|
|
104
|
+
function checkCircularPath(graph, sourceProject, targetProject) {
|
|
105
|
+
if (!graph.nodes[targetProject.name])
|
|
106
|
+
return [];
|
|
107
|
+
return getPath(graph, targetProject.name, sourceProject.name);
|
|
108
|
+
}
|
|
109
|
+
function circularPathHasPair(circularPath, ignored) {
|
|
110
|
+
if (circularPath.length < 2)
|
|
111
|
+
return false;
|
|
112
|
+
for (let i = 0; i < circularPath.length - 1; i++) {
|
|
113
|
+
const dependencyIsIgnored = ignored
|
|
114
|
+
.get(circularPath[i].name)
|
|
115
|
+
?.has(circularPath[i + 1].name);
|
|
116
|
+
if (dependencyIsIgnored) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
function findFilesInCircularPath(projectFileMap, circularPath) {
|
|
123
|
+
const filePathChain = [];
|
|
124
|
+
for (let i = 0; i < circularPath.length - 1; i++) {
|
|
125
|
+
const next = circularPath[i + 1].name;
|
|
126
|
+
const files = projectFileMap[circularPath[i].name] || [];
|
|
127
|
+
filePathChain.push(files
|
|
128
|
+
.filter((file) => file.deps && file.deps.find((d) => (0, project_graph_1.fileDataDepTarget)(d) === next))
|
|
129
|
+
.map((file) => file.file));
|
|
130
|
+
}
|
|
131
|
+
return filePathChain;
|
|
132
|
+
}
|
|
133
|
+
function findFilesWithDynamicImports(projectFileMap, sourceProjectName, targetProjectName) {
|
|
134
|
+
const files = [];
|
|
135
|
+
projectFileMap[sourceProjectName].forEach((file) => {
|
|
136
|
+
if (!file.deps)
|
|
137
|
+
return;
|
|
138
|
+
if (file.deps.some((d) => (0, project_graph_1.fileDataDepTarget)(d) === targetProjectName &&
|
|
139
|
+
(0, project_graph_1.fileDataDepType)(d) === project_graph_1.DependencyType.dynamic)) {
|
|
140
|
+
files.push(file);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
return files;
|
|
144
|
+
}
|
|
145
|
+
function expandIgnoredCircularDependencies(ignoredCircularDependencies, projectGraph) {
|
|
146
|
+
const allowed = new Map();
|
|
147
|
+
for (const [a, b] of ignoredCircularDependencies) {
|
|
148
|
+
const setA = new Set((0, find_matching_projects_1.findMatchingProjects)([a], projectGraph.nodes));
|
|
149
|
+
const setB = new Set((0, find_matching_projects_1.findMatchingProjects)([b], projectGraph.nodes));
|
|
150
|
+
for (const projectA of setA) {
|
|
151
|
+
if (!allowed.has(projectA)) {
|
|
152
|
+
allowed.set(projectA, new Set());
|
|
153
|
+
}
|
|
154
|
+
const currentSetA = allowed.get(projectA);
|
|
155
|
+
for (const projectB of setB) {
|
|
156
|
+
currentSetA.add(projectB);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (const projectB of setB) {
|
|
160
|
+
if (!allowed.has(projectB)) {
|
|
161
|
+
allowed.set(projectB, new Set());
|
|
162
|
+
}
|
|
163
|
+
const currentSetB = allowed.get(projectB);
|
|
164
|
+
for (const projectA of setA) {
|
|
165
|
+
currentSetB.add(projectA);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return allowed;
|
|
170
|
+
}
|
|
@@ -6,6 +6,7 @@ const params_1 = require("../../utils/params");
|
|
|
6
6
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
7
7
|
const configuration_1 = require("../../config/configuration");
|
|
8
8
|
const async_iterator_1 = require("../../utils/async-iterator");
|
|
9
|
+
const output_1 = require("../../utils/output");
|
|
9
10
|
const executor_utils_1 = require("../../command-line/run/executor-utils");
|
|
10
11
|
// Batch workers are inside an Nx run just like task workers (see
|
|
11
12
|
// bin/run-executor.ts) — mark it so nested tooling can detect Nx.
|
|
@@ -64,26 +65,15 @@ async function runTasks(executorName, projectGraph, batchTaskGraph, fullTaskGrap
|
|
|
64
65
|
console.error(isVerbose ? e : e.message);
|
|
65
66
|
// `process.exit` does not wait for pipe writes, so the reason this worker
|
|
66
67
|
// died could otherwise be the one line that never arrives.
|
|
67
|
-
await
|
|
68
|
+
await output_1.output.drain();
|
|
68
69
|
process.exit(1);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Waits until everything written to stdout and stderr so far has reached the
|
|
73
|
-
* pipe. Writes to a pipe are asynchronous, and the parent learns the batch is
|
|
74
|
-
* over through a separate IPC channel - so without this it can be told the batch
|
|
75
|
-
* finished, or see the process exit, while the end of its output is still in
|
|
76
|
-
* memory here. That tail is where a tool reports what went wrong.
|
|
77
|
-
*/
|
|
78
|
-
function flushStdio() {
|
|
79
|
-
const flush = (stream) => new Promise((resolve) => stream.write('', () => resolve()));
|
|
80
|
-
return Promise.all([flush(process.stdout), flush(process.stderr)]).then(() => undefined);
|
|
81
|
-
}
|
|
82
72
|
process.on('message', async (message) => {
|
|
83
73
|
switch (message.type) {
|
|
84
74
|
case batch_messages_1.BatchMessageType.RunTasks: {
|
|
85
75
|
const results = await runTasks(message.executorName, message.projectGraph, message.batchTaskGraph, message.fullTaskGraph);
|
|
86
|
-
await
|
|
76
|
+
await output_1.output.drain();
|
|
87
77
|
process.send({
|
|
88
78
|
type: batch_messages_1.BatchMessageType.CompleteBatchExecution,
|
|
89
79
|
results,
|
|
@@ -28,6 +28,7 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
|
28
28
|
const default_tasks_runner_1 = require("./default-tasks-runner");
|
|
29
29
|
const task_io_service_1 = require("./task-io-service");
|
|
30
30
|
const handle_import_1 = require("../utils/handle-import");
|
|
31
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
|
31
32
|
// This function is called once during tasks runner initialization. It checks if the db cache is enabled and logs a warning if it is not.
|
|
32
33
|
function dbCacheEnabled() {
|
|
33
34
|
// ...but if on wasm and the the db cache isnt supported we shouldn't warn
|
|
@@ -107,12 +108,11 @@ class DbCache {
|
|
|
107
108
|
// didn't find it locally but we have a remote cache
|
|
108
109
|
// attempt remote cache
|
|
109
110
|
const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
111
|
+
const terminalOutput = res
|
|
112
|
+
? this.applyRemoteCacheResults(task, res)
|
|
113
|
+
: null;
|
|
114
|
+
if (terminalOutput !== null) {
|
|
115
|
+
return { ...res, terminalOutput, remote: true };
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
118
|
return null;
|
|
@@ -158,12 +158,11 @@ class DbCache {
|
|
|
158
158
|
if (remoteMisses.length > 0) {
|
|
159
159
|
await Promise.all(remoteMisses.map(async (task) => {
|
|
160
160
|
const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
});
|
|
161
|
+
const terminalOutput = res
|
|
162
|
+
? this.applyRemoteCacheResults(task, res)
|
|
163
|
+
: null;
|
|
164
|
+
if (terminalOutput !== null) {
|
|
165
|
+
results.set(task.hash, { ...res, terminalOutput, remote: true });
|
|
167
166
|
}
|
|
168
167
|
}));
|
|
169
168
|
}
|
|
@@ -173,8 +172,8 @@ class DbCache {
|
|
|
173
172
|
return this.cache.getCacheSize();
|
|
174
173
|
}
|
|
175
174
|
applyRemoteCacheResults(task, res) {
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
175
|
+
const terminalOutput = this.cache.applyRemoteCacheResults(task.hash, res, task.outputs);
|
|
176
|
+
if (terminalOutput === null) {
|
|
178
177
|
output_1.output.warn({
|
|
179
178
|
title: `Ignoring the remote cache result for ${task.id}`,
|
|
180
179
|
bodyLines: [
|
|
@@ -182,7 +181,7 @@ class DbCache {
|
|
|
182
181
|
],
|
|
183
182
|
});
|
|
184
183
|
}
|
|
185
|
-
return
|
|
184
|
+
return terminalOutput;
|
|
186
185
|
}
|
|
187
186
|
async put(task, terminalOutput, outputs, code) {
|
|
188
187
|
return tryAndRetry(async () => {
|
|
@@ -325,9 +324,11 @@ class DbCache {
|
|
|
325
324
|
return getRemoteCache();
|
|
326
325
|
}
|
|
327
326
|
resolvePackage(pkg) {
|
|
328
|
-
return
|
|
329
|
-
|
|
330
|
-
|
|
327
|
+
return (0, installation_directory_1.resolveInstalledPackage)(pkg, [
|
|
328
|
+
process.cwd(),
|
|
329
|
+
workspace_root_1.workspaceRoot,
|
|
330
|
+
__dirname,
|
|
331
|
+
]);
|
|
331
332
|
}
|
|
332
333
|
assertCacheIsValid() {
|
|
333
334
|
// User has customized the cache directory - this could be because they
|
|
@@ -55,6 +55,7 @@ const task_graph_utils_1 = require("./task-graph-utils");
|
|
|
55
55
|
const utils_1 = require("./utils");
|
|
56
56
|
const run_outcome_1 = require("./run-outcome");
|
|
57
57
|
const handle_import_1 = require("../utils/handle-import");
|
|
58
|
+
const installation_directory_1 = require("../utils/installation-directory");
|
|
58
59
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
59
60
|
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
|
60
61
|
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
|
@@ -187,7 +188,7 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
|
187
188
|
/**
|
|
188
189
|
* Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
|
|
189
190
|
*/
|
|
190
|
-
const createPatchedLogWrite = (
|
|
191
|
+
const createPatchedLogWrite = (isError) => {
|
|
191
192
|
// @ts-ignore
|
|
192
193
|
return (chunk, encoding, callback) => {
|
|
193
194
|
if (isError) {
|
|
@@ -200,7 +201,6 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
|
200
201
|
? chunk.toString(encoding)
|
|
201
202
|
: chunk.toString());
|
|
202
203
|
}
|
|
203
|
-
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
|
204
204
|
const stackTrace = new Error().stack;
|
|
205
205
|
const isNxCloudLog = stackTrace.includes(nxCloudClientDir);
|
|
206
206
|
if (isNxCloudLog) {
|
|
@@ -231,8 +231,8 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
|
231
231
|
// No-op the Nx Cloud client logs
|
|
232
232
|
};
|
|
233
233
|
};
|
|
234
|
-
process.stdout.write = createPatchedLogWrite(
|
|
235
|
-
process.stderr.write = createPatchedLogWrite(
|
|
234
|
+
process.stdout.write = createPatchedLogWrite(false);
|
|
235
|
+
process.stderr.write = createPatchedLogWrite(true);
|
|
236
236
|
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
|
237
237
|
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
|
238
238
|
console.error = createPatchedConsoleMethod(originalConsoleError);
|
|
@@ -278,8 +278,8 @@ async function getTerminalOutputLifeCycle(initiatingProject, initiatingTasks, pr
|
|
|
278
278
|
renderIsDone: Promise.resolve(),
|
|
279
279
|
};
|
|
280
280
|
}
|
|
281
|
-
|
|
282
|
-
const useDynamicOutput = shouldUseDynamicLifeCycle(tasks,
|
|
281
|
+
getRunner(nxArgs, nxJson);
|
|
282
|
+
const useDynamicOutput = shouldUseDynamicLifeCycle(tasks, nxArgs.specifiedOutputStyle);
|
|
283
283
|
if (isRunOne) {
|
|
284
284
|
if (useDynamicOutput) {
|
|
285
285
|
return await (0, dynamic_run_one_terminal_output_life_cycle_1.createRunOneDynamicOutputRenderer)({
|
|
@@ -826,7 +826,7 @@ async function convertObservableToPromise(obs) {
|
|
|
826
826
|
});
|
|
827
827
|
});
|
|
828
828
|
}
|
|
829
|
-
function shouldUseDynamicLifeCycle(tasks,
|
|
829
|
+
function shouldUseDynamicLifeCycle(tasks, outputStyle) {
|
|
830
830
|
if (process.env.NX_BATCH_MODE === 'true' ||
|
|
831
831
|
process.env.NX_VERBOSE_LOGGING === 'true' ||
|
|
832
832
|
process.env.NX_TASKS_RUNNER_DYNAMIC_OUTPUT === 'false') {
|
|
@@ -844,16 +844,18 @@ function shouldUseDynamicLifeCycle(tasks, options, outputStyle) {
|
|
|
844
844
|
return !tasks.find((t) => (0, utils_1.shouldStreamOutput)(t, null));
|
|
845
845
|
}
|
|
846
846
|
function loadTasksRunner(modulePath) {
|
|
847
|
+
const isLegacyCloudPackage = modulePath === 'nx-cloud' || modulePath === '@nrwl/nx-cloud';
|
|
847
848
|
try {
|
|
848
|
-
const maybeTasksRunner = require(
|
|
849
|
+
const maybeTasksRunner = require(isLegacyCloudPackage
|
|
850
|
+
? (0, installation_directory_1.resolveInstalledPackage)(modulePath, [__dirname])
|
|
851
|
+
: modulePath);
|
|
849
852
|
// to support both babel and ts formats
|
|
850
853
|
return 'default' in maybeTasksRunner
|
|
851
854
|
? maybeTasksRunner.default
|
|
852
855
|
: maybeTasksRunner;
|
|
853
856
|
}
|
|
854
857
|
catch (e) {
|
|
855
|
-
if (e.code === 'MODULE_NOT_FOUND' &&
|
|
856
|
-
(modulePath === 'nx-cloud' || modulePath === '@nrwl/nx-cloud')) {
|
|
858
|
+
if (e.code === 'MODULE_NOT_FOUND' && isLegacyCloudPackage) {
|
|
857
859
|
return require('../nx-cloud/nx-cloud-tasks-runner-shell')
|
|
858
860
|
.nxCloudTasksRunnerShell;
|
|
859
861
|
}
|
|
@@ -184,6 +184,8 @@ class TaskOrchestrator {
|
|
|
184
184
|
// report them again, and the saved log gets the reason after the transcript
|
|
185
185
|
this.readinessFailures = new Map();
|
|
186
186
|
this.readinessFailureReasons = new Map();
|
|
187
|
+
// Cleanup awaits these, so an aborted command probe finishes its kill first
|
|
188
|
+
this.readinessProbes = new Set();
|
|
187
189
|
this.readinessSettled = false;
|
|
188
190
|
// The url each producer reported with its readiness signal
|
|
189
191
|
this.readyUrls = new Map();
|
|
@@ -371,7 +373,7 @@ class TaskOrchestrator {
|
|
|
371
373
|
// Use a separate groupId space (parallel..parallel+N) so continuous tasks
|
|
372
374
|
// don't consume discrete group slots
|
|
373
375
|
const groupId = this.options.parallel + this.continuousTasksStarted++;
|
|
374
|
-
|
|
376
|
+
await this.startContinuousTask(task, groupId);
|
|
375
377
|
if (this.initializingTaskIds.has(task.id)) {
|
|
376
378
|
await this.continuousTaskExitHandled.get(task.id);
|
|
377
379
|
}
|
|
@@ -1241,10 +1243,12 @@ class TaskOrchestrator {
|
|
|
1241
1243
|
this.runningContinuousTasks.size === 0),
|
|
1242
1244
|
streamOutput: streamOutput && !shouldPrefix,
|
|
1243
1245
|
};
|
|
1246
|
+
// The TUI discards stderr, so run-commands warnings go to the task output
|
|
1247
|
+
const warnings = [];
|
|
1244
1248
|
// As in a forked run, run-commands builds its env on the task env
|
|
1245
1249
|
const runningTask = await (0, run_commands_impl_1.runCommands)(runCommandsOptions, {
|
|
1246
1250
|
root: workspace_root_1.workspaceRoot, // only root is needed in runCommands
|
|
1247
|
-
}, task, env);
|
|
1251
|
+
}, task, env, this.tuiEnabled ? (message) => warnings.push(message) : undefined);
|
|
1248
1252
|
this.runningRunCommandsTasks.set(task.id, runningTask);
|
|
1249
1253
|
runningTask.onExit(() => {
|
|
1250
1254
|
this.runningRunCommandsTasks.delete(task.id);
|
|
@@ -1270,6 +1274,9 @@ class TaskOrchestrator {
|
|
|
1270
1274
|
this.options.lifeCycle.appendTaskOutput(task.id, output, false);
|
|
1271
1275
|
});
|
|
1272
1276
|
}
|
|
1277
|
+
for (const warning of warnings) {
|
|
1278
|
+
this.options.lifeCycle.appendTaskOutput(task.id, `${pc.yellow(warning)}\r\n`, false);
|
|
1279
|
+
}
|
|
1273
1280
|
}
|
|
1274
1281
|
runningTask.onExit((code, terminalOutput) => {
|
|
1275
1282
|
if (!streamOutput && !shouldPrefix) {
|
|
@@ -1690,7 +1697,7 @@ class TaskOrchestrator {
|
|
|
1690
1697
|
startReadinessProbe(task, readyWhen, runningTask) {
|
|
1691
1698
|
const state = this.armReadiness(task.id);
|
|
1692
1699
|
this.options.lifeCycle.setTaskReadiness?.(task.id, 0 /* TaskReadiness.Pending */);
|
|
1693
|
-
(0, probes_1.waitForReadiness)(readyWhen, {
|
|
1700
|
+
const probe = (0, probes_1.waitForReadiness)(readyWhen, {
|
|
1694
1701
|
taskId: task.id,
|
|
1695
1702
|
runningTask,
|
|
1696
1703
|
cwd: workspace_root_1.workspaceRoot,
|
|
@@ -1709,6 +1716,8 @@ class TaskOrchestrator {
|
|
|
1709
1716
|
this.recordReadiness(task, 2 /* TaskReadiness.Failed */);
|
|
1710
1717
|
this.failReadiness(task, state, e);
|
|
1711
1718
|
});
|
|
1719
|
+
this.readinessProbes.add(probe);
|
|
1720
|
+
probe.finally(() => this.readinessProbes.delete(probe));
|
|
1712
1721
|
}
|
|
1713
1722
|
// A verdict against a producer something in this run waits for fails the
|
|
1714
1723
|
// producer, and the skip propagation covers the waiters. Without a waiter
|
|
@@ -2216,6 +2225,7 @@ class TaskOrchestrator {
|
|
|
2216
2225
|
async performCleanup() {
|
|
2217
2226
|
// Waiters must not sit out a probe once the run is stopping
|
|
2218
2227
|
this.abortAllReadiness();
|
|
2228
|
+
const probesStopped = Promise.allSettled(this.readinessProbes);
|
|
2219
2229
|
this.readySignal?.close();
|
|
2220
2230
|
// Mark all running tasks for intentional stop
|
|
2221
2231
|
const reason = this.stopRequested ? 'interrupted' : 'fulfilled';
|
|
@@ -2243,6 +2253,7 @@ class TaskOrchestrator {
|
|
|
2243
2253
|
const continuousTaskIds = new Set(continuousSnapshot.map(([id]) => id));
|
|
2244
2254
|
await Promise.all([
|
|
2245
2255
|
forkedCleanup,
|
|
2256
|
+
probesStopped,
|
|
2246
2257
|
...continuousSnapshot.map(async ([taskId, { runningTask }]) => {
|
|
2247
2258
|
try {
|
|
2248
2259
|
await runningTask.kill();
|
|
@@ -147,17 +147,6 @@ function normalizeTargetDependencyWithStringProjects(dependencyConfig) {
|
|
|
147
147
|
}
|
|
148
148
|
return dependencyConfig;
|
|
149
149
|
}
|
|
150
|
-
class InvalidOutputsError extends Error {
|
|
151
|
-
constructor(outputs, invalidOutputs) {
|
|
152
|
-
super(InvalidOutputsError.createMessage(invalidOutputs));
|
|
153
|
-
this.outputs = outputs;
|
|
154
|
-
this.invalidOutputs = invalidOutputs;
|
|
155
|
-
}
|
|
156
|
-
static createMessage(invalidOutputs) {
|
|
157
|
-
const invalidOutputsList = '\n - ' + Array.from(invalidOutputs).join('\n - ');
|
|
158
|
-
return `The following outputs are invalid:${invalidOutputsList}\nPlease run "nx repair" to repair your configuration`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
150
|
function assertOutputsAreValidType(outputs) {
|
|
162
151
|
if (!Array.isArray(outputs)) {
|
|
163
152
|
throw new Error("The 'outputs' field must be an array");
|
|
@@ -379,7 +368,7 @@ function getExecutorForTask(task, projects) {
|
|
|
379
368
|
const [nodeModule, executorName] = (0, executor_utils_1.parseExecutor)(executor);
|
|
380
369
|
return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, projects);
|
|
381
370
|
}
|
|
382
|
-
// TODO(v25): remove custom hasher support.
|
|
371
|
+
// TODO(v25): remove custom hasher support (NXC-5052).
|
|
383
372
|
function getCustomHasher(task, projects) {
|
|
384
373
|
const factory = getExecutorForTask(task, projects).hasherFactory;
|
|
385
374
|
if (!factory) {
|
|
@@ -19,7 +19,7 @@ function customHasherTaskIds(projectGraph, taskGraph) {
|
|
|
19
19
|
return memoized;
|
|
20
20
|
}
|
|
21
21
|
const projects = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects;
|
|
22
|
-
// TODO(v25): remove custom hasher support.
|
|
22
|
+
// TODO(v25): remove custom hasher support (NXC-5052).
|
|
23
23
|
const ids = Object.values(taskGraph.tasks)
|
|
24
24
|
.filter((task) => {
|
|
25
25
|
try {
|
|
@@ -96,7 +96,8 @@ function findInstalledNxBin(root) {
|
|
|
96
96
|
for (let dir = root;; dir = (0, path_1.dirname)(dir)) {
|
|
97
97
|
// The nearest install wins, so an unusable manifest there ends the search
|
|
98
98
|
// rather than deferring to an ancestor.
|
|
99
|
-
if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'node_modules', 'nx', 'package.json'))
|
|
99
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'node_modules', 'nx', 'package.json')) &&
|
|
100
|
+
(0, workspace_root_1.isTrustedNxInstall)((0, path_1.join)(dir, 'node_modules'), root)) {
|
|
100
101
|
return readInstalledNxBin(dir);
|
|
101
102
|
}
|
|
102
103
|
if (dir === (0, path_1.dirname)(dir)) {
|
|
@@ -24,8 +24,9 @@ function sharedWorkspaceDataDirectory(root) {
|
|
|
24
24
|
}
|
|
25
25
|
function getDbConnection(opts = {}) {
|
|
26
26
|
opts.directory ??= sharedWorkspaceDataDirectory(workspace_root_1.workspaceRoot);
|
|
27
|
-
const
|
|
28
|
-
const
|
|
27
|
+
const dbName = opts.dbName ?? (process.env.NX_DB_NAME || undefined);
|
|
28
|
+
const key = JSON.stringify([opts.directory, dbName]);
|
|
29
|
+
const connection = getEntryOrSet(dbConnectionMap, key, () => (0, native_1.connectToNxDb)(opts.directory, dbName));
|
|
29
30
|
return connection;
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
@@ -36,8 +37,9 @@ function getDbConnection(opts = {}) {
|
|
|
36
37
|
*/
|
|
37
38
|
function getLocalDbConnection(opts = {}) {
|
|
38
39
|
const directory = (0, cache_directory_1.workspaceDataDirectoryForWorkspace)(workspace_root_1.workspaceRoot);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
40
|
+
const dbName = opts.dbName ?? (process.env.NX_DB_NAME || undefined);
|
|
41
|
+
const key = JSON.stringify([directory, dbName]);
|
|
42
|
+
const connection = getEntryOrSet(dbConnectionMap, key, () => (0, native_1.connectToNxDb)(directory, dbName));
|
|
41
43
|
return connection;
|
|
42
44
|
}
|
|
43
45
|
function removeDbConnections() {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findWorkspaceRoot = findWorkspaceRoot;
|
|
4
4
|
const workspace_root_1 = require("./workspace-root");
|
|
5
|
+
const installation_directory_1 = require("./installation-directory");
|
|
5
6
|
/**
|
|
6
7
|
* Recursive function that walks back up the directory
|
|
7
8
|
* tree to try and find a workspace file.
|
|
@@ -21,10 +22,7 @@ function findWorkspaceRoot(dir) {
|
|
|
21
22
|
}
|
|
22
23
|
function isAngularCliInstalled(root) {
|
|
23
24
|
try {
|
|
24
|
-
|
|
25
|
-
require.resolve('@angular/cli', {
|
|
26
|
-
paths: [root],
|
|
27
|
-
});
|
|
25
|
+
(0, installation_directory_1.resolveInstalledPackage)('@angular/cli', [root], root);
|
|
28
26
|
return true;
|
|
29
27
|
}
|
|
30
28
|
catch {
|
|
@@ -2,6 +2,11 @@ export declare function cloneFromUpstream(url: string, destination: string, { or
|
|
|
2
2
|
originName: string;
|
|
3
3
|
depth?: number;
|
|
4
4
|
}): Promise<GitRepository>;
|
|
5
|
+
/**
|
|
6
|
+
* Whether `directory` is itself a repository `git clone` accepts: a working
|
|
7
|
+
* tree root or a bare repository, but not a directory nested inside one.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isCloneableGitRepository(directory: string): Promise<boolean>;
|
|
5
10
|
export declare class GitRepository {
|
|
6
11
|
private directory;
|
|
7
12
|
root: string;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GIT_SHA = exports.GitRepository = void 0;
|
|
4
4
|
exports.cloneFromUpstream = cloneFromUpstream;
|
|
5
|
+
exports.isCloneableGitRepository = isCloneableGitRepository;
|
|
5
6
|
exports.parseVcsRemoteUrl = parseVcsRemoteUrl;
|
|
6
7
|
exports.locateGitDir = locateGitDir;
|
|
7
8
|
exports.getVcsRemoteInfo = getVcsRemoteInfo;
|
|
@@ -58,6 +59,22 @@ async function cloneFromUpstream(url, destination, { originName, depth } = {
|
|
|
58
59
|
});
|
|
59
60
|
return new GitRepository(destination);
|
|
60
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether `directory` is itself a repository `git clone` accepts: a working
|
|
64
|
+
* tree root or a bare repository, but not a directory nested inside one.
|
|
65
|
+
*/
|
|
66
|
+
async function isCloneableGitRepository(directory) {
|
|
67
|
+
for (const gitDir of [(0, path_1.join)(directory, '.git'), directory]) {
|
|
68
|
+
try {
|
|
69
|
+
await execFileAsync('git', ['rev-parse', '--resolve-git-dir', gitDir], {
|
|
70
|
+
windowsHide: true,
|
|
71
|
+
});
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
61
78
|
class GitRepository {
|
|
62
79
|
constructor(directory) {
|
|
63
80
|
this.directory = directory;
|
|
@@ -542,6 +559,7 @@ function getGitRootPath(cwd) {
|
|
|
542
559
|
return (0, child_process_1.execFileSync)('git', ['rev-parse', '--show-toplevel'], {
|
|
543
560
|
cwd,
|
|
544
561
|
windowsHide: true,
|
|
562
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
545
563
|
})
|
|
546
564
|
.toString()
|
|
547
565
|
.trim();
|
|
@@ -630,7 +648,11 @@ function getGitRepositoryStatus(directory) {
|
|
|
630
648
|
}
|
|
631
649
|
catch (err) {
|
|
632
650
|
const stderr = err?.stderr?.toString() ?? '';
|
|
633
|
-
|
|
651
|
+
// Anchored to git's own message so a path quoted in another error, such
|
|
652
|
+
// as a broken included config file, cannot match.
|
|
653
|
+
return /^fatal: not a git repository/im.test(stderr)
|
|
654
|
+
? 'not-git'
|
|
655
|
+
: 'unknown';
|
|
634
656
|
}
|
|
635
657
|
}
|
|
636
658
|
// Checked-out branch name, or null when there isn't one to act on: a detached
|
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleImport = handleImport;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
+
const node_module_1 = require("node:module");
|
|
6
|
+
// Node passes a stand-in require, without a cache, require.extensions or
|
|
7
|
+
// Module._load, when an ESM loader hook supplies this module's source, as
|
|
8
|
+
// Yarn PnP does.
|
|
9
|
+
if (!require.cache)
|
|
10
|
+
require = (0, node_module_1.createRequire)(__filename);
|
|
5
11
|
const STRIP_TYPES_DOCS_URL = 'https://nx.dev/docs/reference/environment-variables#nx-prefer-node-strip-types';
|
|
6
12
|
/**
|
|
7
13
|
* Dynamically imports a module using CJS require().
|
|
@@ -8,3 +8,19 @@ export declare function getNxRequirePaths(root?: string): string[];
|
|
|
8
8
|
* see what the workspace installs.
|
|
9
9
|
*/
|
|
10
10
|
export declare function resolveFromWorkspace(specifier: string, root?: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The directory holding the outermost `node_modules` of each path. The
|
|
13
|
+
* separator is kept so `/node_modules` yields `/`, not an empty path.
|
|
14
|
+
*/
|
|
15
|
+
export declare function installationRootsOf(paths: string[]): string[];
|
|
16
|
+
/**
|
|
17
|
+
* `require.resolve(specifier, { paths })` limited to `node_modules`
|
|
18
|
+
* directories inside `root`, the workspace, or this nx installation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveInstalledPackage(specifier: string, paths: string[], root?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves `nx/bin/nx.js` from the first `node_modules` Node searches from `dir`
|
|
23
|
+
* that holds it, refusing it when it fails `isTrustedNxInstall` for the
|
|
24
|
+
* workspace at `root`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveNxBinFrom(dir: string, root?: string): string;
|