nx 23.0.0-beta.2 → 23.0.0-beta.4
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/src/command-line/show/show-target/info.d.ts +1 -0
- package/dist/src/command-line/show/show-target/info.js +98 -16
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/project-graph/build-project-graph.d.ts +5 -0
- package/dist/src/project-graph/build-project-graph.js +6 -2
- package/dist/src/project-graph/file-map-utils.d.ts +5 -0
- package/dist/src/project-graph/file-map-utils.js +10 -1
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
- package/dist/src/utils/logger.d.ts +12 -1
- package/dist/src/utils/logger.js +57 -36
- package/dist/src/utils/output.d.ts +3 -2
- package/dist/src/utils/output.js +29 -28
- package/dist/src/utils/perf-logging.js +2 -1
- package/package.json +18 -11
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showTargetInfoHandler = showTargetInfoHandler;
|
|
4
4
|
const task_hasher_1 = require("../../../hasher/task-hasher");
|
|
5
|
+
const create_task_graph_1 = require("../../../tasks-runner/create-task-graph");
|
|
5
6
|
const utils_1 = require("../../../tasks-runner/utils");
|
|
6
7
|
const utils_2 = require("./utils");
|
|
7
8
|
// ── Handler ─────────────────────────────────────────────────────────
|
|
@@ -22,7 +23,7 @@ function resolveTargetInfoData(t) {
|
|
|
22
23
|
const extraTargetDeps = Object.fromEntries(Object.entries(nxJson.targetDefaults ?? {})
|
|
23
24
|
.filter(([, config]) => config.dependsOn)
|
|
24
25
|
.map(([name, config]) => [name, config.dependsOn]));
|
|
25
|
-
const depConfigs = (0, utils_1.getDependencyConfigs)({ project: projectName, target: targetName }, extraTargetDeps, graph, [...allTargetNames]);
|
|
26
|
+
const depConfigs = (0, utils_1.getDependencyConfigs)({ project: projectName, target: targetName }, extraTargetDeps, graph, [...allTargetNames]) ?? [];
|
|
26
27
|
// Determine the hoisted command value and which option key it came from
|
|
27
28
|
let command;
|
|
28
29
|
let commandSourceKey;
|
|
@@ -43,18 +44,7 @@ function resolveTargetInfoData(t) {
|
|
|
43
44
|
command = targetConfig.options.script;
|
|
44
45
|
commandSourceKey = 'options.script';
|
|
45
46
|
}
|
|
46
|
-
const dependsOn =
|
|
47
|
-
const depSourceIndices = [];
|
|
48
|
-
if (depConfigs && depConfigs.length > 0) {
|
|
49
|
-
for (let i = 0; i < depConfigs.length; i++) {
|
|
50
|
-
const dep = depConfigs[i];
|
|
51
|
-
const projects = resolveDependencyProjects(dep, projectName, graph);
|
|
52
|
-
for (const p of projects) {
|
|
53
|
-
dependsOn.push(`${p}:${dep.target}`);
|
|
54
|
-
depSourceIndices.push(i);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
47
|
+
const { dependsOn, depSourceIndices, transitiveTasks } = resolveTaskGraphDependencies(graph, extraTargetDeps, projectName, targetName, configuration, depConfigs);
|
|
58
48
|
const configurations = Object.keys(targetConfig.configurations ?? {});
|
|
59
49
|
const targetSourceMap = extractTargetSourceMap(node.data.root, targetName, sourceMaps);
|
|
60
50
|
const usesCustomHasher = (0, utils_2.hasCustomHasher)(projectName, targetName, graph);
|
|
@@ -68,6 +58,7 @@ function resolveTargetInfoData(t) {
|
|
|
68
58
|
...(dependsOn.length > 0
|
|
69
59
|
? { dependsOn, _depSources: depSourceIndices }
|
|
70
60
|
: {}),
|
|
61
|
+
...(transitiveTasks.length > 0 ? { transitiveTasks } : {}),
|
|
71
62
|
parallelism: targetConfig.parallelism ?? true,
|
|
72
63
|
continuous: targetConfig.continuous ?? false,
|
|
73
64
|
cache: targetConfig.cache ?? false,
|
|
@@ -110,6 +101,93 @@ function resolveDependencyProjects(dep, projectName, graph) {
|
|
|
110
101
|
}
|
|
111
102
|
return [projectName];
|
|
112
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Builds a task graph rooted at the requested target and returns:
|
|
106
|
+
* - `dependsOn`: direct task dependencies of the root, with real
|
|
107
|
+
* project/target resolution applied.
|
|
108
|
+
* - `depSourceIndices`: for each direct dep, the index of the original
|
|
109
|
+
* depConfig it corresponds to (for source-map hints), or -1 if unknown.
|
|
110
|
+
* - `transitiveTasks`: task IDs reachable through the direct deps (not
|
|
111
|
+
* the root, not direct deps).
|
|
112
|
+
*
|
|
113
|
+
* If `createTaskGraph` throws (e.g. circular dependencies), falls back to
|
|
114
|
+
* the `depConfig`-based resolution so the output still shows the configured
|
|
115
|
+
* list rather than silently collapsing to empty.
|
|
116
|
+
*/
|
|
117
|
+
function resolveTaskGraphDependencies(graph, extraTargetDeps, projectName, targetName, configuration, depConfigs) {
|
|
118
|
+
try {
|
|
119
|
+
const taskGraph = (0, create_task_graph_1.createTaskGraph)(graph, extraTargetDeps, [projectName], [targetName], configuration, {});
|
|
120
|
+
const rootId = (0, utils_1.createTaskId)(projectName, targetName, configuration);
|
|
121
|
+
const directDeps = taskGraph.dependencies[rootId] ?? [];
|
|
122
|
+
const directDepSet = new Set(directDeps);
|
|
123
|
+
const depSourceIndices = directDeps.map((depTaskId) => {
|
|
124
|
+
const task = taskGraph.tasks[depTaskId];
|
|
125
|
+
if (!task)
|
|
126
|
+
return -1;
|
|
127
|
+
return findDepConfigIndex(task.target, depConfigs, projectName, graph);
|
|
128
|
+
});
|
|
129
|
+
// `Object.keys(dependencies)` gives the set of real (non-dummy) tasks
|
|
130
|
+
// in the graph — `filterDummyTasks` (called inside `createTaskGraph`)
|
|
131
|
+
// removes dummy entries from `dependencies` but leaves them in `tasks`.
|
|
132
|
+
const transitiveTasks = Object.keys(taskGraph.dependencies).filter((id) => id !== rootId && !directDepSet.has(id));
|
|
133
|
+
return { dependsOn: directDeps, depSourceIndices, transitiveTasks };
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return {
|
|
137
|
+
...resolveDependsOnFromConfigs(depConfigs, projectName, graph),
|
|
138
|
+
transitiveTasks: [],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function resolveDependsOnFromConfigs(depConfigs, projectName, graph) {
|
|
143
|
+
const dependsOn = [];
|
|
144
|
+
const depSourceIndices = [];
|
|
145
|
+
for (let i = 0; i < depConfigs.length; i++) {
|
|
146
|
+
const dep = depConfigs[i];
|
|
147
|
+
const projects = resolveDependencyProjects(dep, projectName, graph);
|
|
148
|
+
for (const p of projects) {
|
|
149
|
+
dependsOn.push(`${p}:${dep.target}`);
|
|
150
|
+
depSourceIndices.push(i);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return { dependsOn, depSourceIndices };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Builds the summary line shown beneath the direct `Depends On` list.
|
|
157
|
+
*
|
|
158
|
+
* Up to 3 unique target names: list them (`and 5 build, compile transitive tasks`).
|
|
159
|
+
* Beyond that: collapse to the count alone (`and 12 transitive tasks`).
|
|
160
|
+
*/
|
|
161
|
+
function formatTransitiveSummary(taskIds) {
|
|
162
|
+
const count = taskIds.length;
|
|
163
|
+
const plural = count === 1 ? 'task' : 'tasks';
|
|
164
|
+
const targetNames = uniqueTargetNames(taskIds);
|
|
165
|
+
if (targetNames.length === 0 || targetNames.length > 3) {
|
|
166
|
+
return `and ${count} transitive ${plural}`;
|
|
167
|
+
}
|
|
168
|
+
return `and ${count} ${targetNames.join(', ')} transitive ${plural}`;
|
|
169
|
+
}
|
|
170
|
+
function uniqueTargetNames(taskIds) {
|
|
171
|
+
const set = new Set();
|
|
172
|
+
for (const id of taskIds) {
|
|
173
|
+
// task ids are `project:target` or `project:target:config`
|
|
174
|
+
const parts = id.split(':');
|
|
175
|
+
if (parts.length >= 2)
|
|
176
|
+
set.add(parts[1]);
|
|
177
|
+
}
|
|
178
|
+
return [...set].sort();
|
|
179
|
+
}
|
|
180
|
+
function findDepConfigIndex(taskTarget, depConfigs, rootProject, graph) {
|
|
181
|
+
for (let i = 0; i < depConfigs.length; i++) {
|
|
182
|
+
const dep = depConfigs[i];
|
|
183
|
+
if (dep.target !== taskTarget.target)
|
|
184
|
+
continue;
|
|
185
|
+
const resolved = resolveDependencyProjects(dep, rootProject, graph);
|
|
186
|
+
if (resolved.includes(taskTarget.project))
|
|
187
|
+
return i;
|
|
188
|
+
}
|
|
189
|
+
return -1;
|
|
190
|
+
}
|
|
113
191
|
/**
|
|
114
192
|
* Expands named inputs (e.g. "production") to their definitions while
|
|
115
193
|
* tracking which original input index each expanded item came from.
|
|
@@ -216,11 +294,15 @@ function renderTargetInfo(data, args) {
|
|
|
216
294
|
if (data.dependsOn && data.dependsOn.length > 0) {
|
|
217
295
|
console.log(`${c.bold('Depends On')}:`);
|
|
218
296
|
for (let i = 0; i < data.dependsOn.length; i++) {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
297
|
+
const srcIdx = data._depSources?.[i];
|
|
298
|
+
const hint = srcIdx !== undefined && srcIdx >= 0
|
|
299
|
+
? sourceHint(`dependsOn.${srcIdx}`, 'dependsOn')
|
|
300
|
+
: sourceHint('dependsOn');
|
|
222
301
|
console.log(` ${data.dependsOn[i]}${hint}`);
|
|
223
302
|
}
|
|
303
|
+
if (data.transitiveTasks && data.transitiveTasks.length > 0) {
|
|
304
|
+
console.log(` ${c.dim(formatTransitiveSummary(data.transitiveTasks))}`);
|
|
305
|
+
}
|
|
224
306
|
}
|
|
225
307
|
console.log(`${c.bold('Parallelism')}: ${data.parallelism}${sourceHint('parallelism')}`);
|
|
226
308
|
console.log(`${c.bold('Continuous')}: ${data.continuous}${sourceHint('continuous')}`);
|