nx 24.0.0 → 24.0.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/dist/src/ai/clone-ai-config-repo.js +49 -12
- package/dist/src/command-line/migrate/migrate-commits.d.ts +17 -7
- package/dist/src/command-line/migrate/migrate-commits.js +57 -17
- package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
- package/dist/src/command-line/migrate/run/orchestrator.js +19 -13
- package/dist/src/daemon/client/client.d.ts +4 -0
- package/dist/src/daemon/client/client.js +67 -12
- package/dist/src/daemon/server/handle-process-in-background.js +21 -9
- package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
- package/dist/src/daemon/server/native-js-loader.js +21 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
- package/dist/src/daemon/server/server.d.ts +2 -1
- package/dist/src/daemon/server/server.js +16 -3
- package/dist/src/daemon/server/start.d.ts +1 -0
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +1 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +14 -8
- package/dist/src/executors/run-commands/running-tasks.d.ts +1 -1
- package/dist/src/executors/run-commands/running-tasks.js +126 -77
- package/dist/src/executors/run-commands/schema.json +1 -1
- package/dist/src/native/index.d.ts +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/plugins/js/lock-file/pnpm-parser.js +2 -1
- package/dist/src/tasks-runner/init-tasks-runner.js +103 -61
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
- package/dist/src/tasks-runner/readiness/probes.js +2 -2
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +22 -1
- package/dist/src/tasks-runner/readiness/ready-when.js +25 -2
- package/dist/src/tasks-runner/run-command.d.ts +6 -2
- package/dist/src/tasks-runner/run-command.js +14 -25
- package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
- package/dist/src/tasks-runner/run-outcome.js +39 -0
- package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -2
- package/dist/src/tasks-runner/task-orchestrator.js +92 -21
- package/dist/src/tasks-runner/tasks-schedule.js +4 -5
- package/dist/src/utils/child-process.js +1 -1
- package/dist/src/utils/find-matching-projects.js +9 -6
- package/dist/src/utils/git-utils.d.ts +6 -4
- package/dist/src/utils/git-utils.js +43 -6
- package/dist/src/utils/output.d.ts +4 -3
- package/dist/src/utils/output.js +4 -3
- package/dist/src/utils/package-manager.js +5 -0
- package/package.json +11 -11
- package/schemas/nx-schema.json +6 -0
- package/schemas/project-schema.json +6 -0
|
@@ -40,6 +40,28 @@ const utils_1 = require("./utils");
|
|
|
40
40
|
function resolveBatchTaskStatus(result) {
|
|
41
41
|
return result.status ?? (result.success ? 'success' : 'failure');
|
|
42
42
|
}
|
|
43
|
+
function batchWorkerLogExplains(status) {
|
|
44
|
+
switch (status) {
|
|
45
|
+
case 'failure':
|
|
46
|
+
case 'stopped':
|
|
47
|
+
// The worker never reached it, e.g. `@nx/gradle` after a build failure
|
|
48
|
+
// outside the batch's own tasks
|
|
49
|
+
case 'skipped':
|
|
50
|
+
return true;
|
|
51
|
+
case 'success':
|
|
52
|
+
case 'local-cache':
|
|
53
|
+
case 'local-cache-kept-existing':
|
|
54
|
+
case 'remote-cache':
|
|
55
|
+
return false;
|
|
56
|
+
default: {
|
|
57
|
+
const unhandled = status;
|
|
58
|
+
void unhandled;
|
|
59
|
+
// Batch executors report their statuses untyped, so an unknown one can
|
|
60
|
+
// still arrive here. Nx can't tell it succeeded, so its log is shown
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
43
65
|
/** Whether a path names a file with bytes in it. */
|
|
44
66
|
function hasContent(path) {
|
|
45
67
|
try {
|
|
@@ -253,8 +275,21 @@ class TaskOrchestrator {
|
|
|
253
275
|
*/
|
|
254
276
|
async executeCoordinatorLoop(doNotSkipCache, parallelism) {
|
|
255
277
|
while (true) {
|
|
256
|
-
if (this.
|
|
278
|
+
if (this.stopRequested)
|
|
257
279
|
break;
|
|
280
|
+
// On bail, start nothing new but let running tasks finish. Skip unstarted
|
|
281
|
+
// discrete tasks unless stopped, so the run still reads as interrupted
|
|
282
|
+
if (this.bailed) {
|
|
283
|
+
await Promise.allSettled(this.pendingDiscreteWorkers);
|
|
284
|
+
if (this.stopRequested)
|
|
285
|
+
break;
|
|
286
|
+
for (const task of Object.values(this.taskGraph.tasks)) {
|
|
287
|
+
if (!task.continuous && !this.completedTasks.has(task.id)) {
|
|
288
|
+
this.completedTasks.set(task.id, 'skipped');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
258
293
|
await this.scheduleAfterReadiness();
|
|
259
294
|
// 1. Hash BEFORE processAll so processTask sees hashes set, and so
|
|
260
295
|
// resolveCachedTasksBulk can look them up in the cache. Each task
|
|
@@ -298,6 +333,9 @@ class TaskOrchestrator {
|
|
|
298
333
|
this.openGroup(groupId);
|
|
299
334
|
continue;
|
|
300
335
|
}
|
|
336
|
+
// A task may have failed during one of the awaits above
|
|
337
|
+
if (this.bailed)
|
|
338
|
+
continue;
|
|
301
339
|
// 5. Dispatch cache misses as individual workers
|
|
302
340
|
while (this.pendingDiscreteWorkers.size < parallelism) {
|
|
303
341
|
const task = this.tasksSchedule.nextTask((t) => !t.continuous);
|
|
@@ -767,7 +805,8 @@ class TaskOrchestrator {
|
|
|
767
805
|
// When the batch is being folded, printing is deferred to batch end
|
|
768
806
|
// (printGroupedBatchOutput), which always renders each task through the
|
|
769
807
|
// life cycle and adds the worker's whole log as a fold when the run
|
|
770
|
-
// asked for full output or any task failed or was
|
|
808
|
+
// asked for full output or any task failed, was stopped or was never
|
|
809
|
+
// reached.
|
|
771
810
|
if (status !== 'skipped' && !(0, output_1.shouldGroupBatchOutput)()) {
|
|
772
811
|
this.options.lifeCycle.printTaskTerminalOutput(task, status, result.terminalOutput ?? '');
|
|
773
812
|
}
|
|
@@ -862,7 +901,7 @@ class TaskOrchestrator {
|
|
|
862
901
|
if (!capturedOutputPath || (0, output_1.printsTaskOutput)(this.resolvedOutputStyle)) {
|
|
863
902
|
return;
|
|
864
903
|
}
|
|
865
|
-
const failed = results.some((r) => r.status
|
|
904
|
+
const failed = results.some((r) => batchWorkerLogExplains(r.status));
|
|
866
905
|
if (!failed) {
|
|
867
906
|
return;
|
|
868
907
|
}
|
|
@@ -912,8 +951,9 @@ class TaskOrchestrator {
|
|
|
912
951
|
* those per-project summaries to the worker's stdio at all.
|
|
913
952
|
*
|
|
914
953
|
* The worker's whole captured log is rendered as a fold above them when the
|
|
915
|
-
* run asked for full output, or when any task failed
|
|
916
|
-
*
|
|
954
|
+
* run asked for full output, or when any task failed, was stopped or was
|
|
955
|
+
* never reached.
|
|
956
|
+
* A diagnostic that explains a failure is routinely one no task claimed:
|
|
917
957
|
* `@nx/maven`'s batch impl writes its exit-code dump and failed-task outputs
|
|
918
958
|
* to the worker's stderr via `console.error`, and the Maven JVM it spawns
|
|
919
959
|
* points slf4j at `System.out` because its own stderr carries the result
|
|
@@ -949,7 +989,7 @@ class TaskOrchestrator {
|
|
|
949
989
|
verbose: this.options.verbose,
|
|
950
990
|
outputStyle: this.resolvedOutputStyle,
|
|
951
991
|
});
|
|
952
|
-
const batchOwnsTheDiagnostic = taskResults.some((r) => r.status
|
|
992
|
+
const batchOwnsTheDiagnostic = taskResults.some((r) => batchWorkerLogExplains(r.status));
|
|
953
993
|
if ((0, output_1.printsTaskOutput)(this.resolvedOutputStyle) &&
|
|
954
994
|
(printsFullOutput || batchOwnsTheDiagnostic) &&
|
|
955
995
|
capturedOutputPath) {
|
|
@@ -983,7 +1023,9 @@ class TaskOrchestrator {
|
|
|
983
1023
|
? 'failure'
|
|
984
1024
|
: taskResults.some((r) => r.status === 'stopped')
|
|
985
1025
|
? 'stopped'
|
|
986
|
-
: '
|
|
1026
|
+
: taskResults.some((r) => r.status === 'skipped')
|
|
1027
|
+
? 'skipped'
|
|
1028
|
+
: 'success';
|
|
987
1029
|
output_1.output.logBatchGroup(label, body, worst);
|
|
988
1030
|
if (!redirectLines) {
|
|
989
1031
|
return;
|
|
@@ -1330,7 +1372,10 @@ class TaskOrchestrator {
|
|
|
1330
1372
|
}
|
|
1331
1373
|
if (readyWhen) {
|
|
1332
1374
|
const state = this.armReadiness(task.id);
|
|
1333
|
-
this.pollReadinessRow(task, readyWhen,
|
|
1375
|
+
this.pollReadinessRow(task, readyWhen, {
|
|
1376
|
+
signal: state.abort.signal,
|
|
1377
|
+
ownerObserved: true,
|
|
1378
|
+
}).then(() => {
|
|
1334
1379
|
if (!state.abort.signal.aborted)
|
|
1335
1380
|
state.resolve();
|
|
1336
1381
|
}, (e) => {
|
|
@@ -1384,13 +1429,15 @@ class TaskOrchestrator {
|
|
|
1384
1429
|
env = pipeOutput
|
|
1385
1430
|
? (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, (0, task_env_1.getForceColorForChild)(), this.options.skipNxCache, this.options.captureStderr, null, null)
|
|
1386
1431
|
: (0, task_env_1.getEnvVariablesForTask)(task, taskSpecificEnv, undefined, this.options.skipNxCache, this.options.captureStderr, temporaryOutputPath, streamOutput);
|
|
1387
|
-
|
|
1432
|
+
const readyWhenInputs = (0, ready_when_1.getReadyWhenInputs)(task, this.projectGraph, this.projects, workspace_root_1.workspaceRoot);
|
|
1433
|
+
this.checkReadyWhenBeforeWait(task, env, readyWhenInputs);
|
|
1434
|
+
await this.waitForReadyDependencies(task);
|
|
1435
|
+
Object.assign(env, this.getReadyUrlEnv(task));
|
|
1436
|
+
({ readyWhen, uncheckedReason, readyOnStart } = this.getReadinessCheck(task, () => this.getReadyWhen(task, env, readyWhenInputs)));
|
|
1388
1437
|
if (readyWhen?.kind === 'signal') {
|
|
1389
1438
|
this.readySignal ??= new ready_signal_server_1.ReadySignalServer();
|
|
1390
1439
|
Object.assign(env, await this.readySignal.env(task.id));
|
|
1391
1440
|
}
|
|
1392
|
-
await this.waitForReadyDependencies(task);
|
|
1393
|
-
Object.assign(env, this.getReadyUrlEnv(task));
|
|
1394
1441
|
}
|
|
1395
1442
|
catch (e) {
|
|
1396
1443
|
this.runningTasksService?.removeRunningTask(task.id);
|
|
@@ -1452,8 +1499,34 @@ class TaskOrchestrator {
|
|
|
1452
1499
|
}
|
|
1453
1500
|
// endregion Single Task
|
|
1454
1501
|
// region Readiness
|
|
1455
|
-
getReadyWhen(task, env) {
|
|
1456
|
-
return (0, ready_when_1.getReadyWhen)(task, this.projectGraph, this.projects, workspace_root_1.workspaceRoot, env);
|
|
1502
|
+
getReadyWhen(task, env, inputs) {
|
|
1503
|
+
return (0, ready_when_1.getReadyWhen)(task, this.projectGraph, this.projects, workspace_root_1.workspaceRoot, env, inputs);
|
|
1504
|
+
}
|
|
1505
|
+
// NX_READY_URL is known only after the wait, so fail now only when the
|
|
1506
|
+
// check fails without it and, if a producer may report one, with a URL too
|
|
1507
|
+
checkReadyWhenBeforeWait(task, env, inputs) {
|
|
1508
|
+
const producerIds = (0, ready_when_1.getReadyProducerIds)(task, this.fullTaskGraph);
|
|
1509
|
+
if (!inputs || !producerIds.length) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
const envs = [env];
|
|
1513
|
+
if (producerIds.some((id) => (0, ready_when_1.mayReportReadyUrl)(this.fullTaskGraph.tasks[id], this.projectGraph))) {
|
|
1514
|
+
envs.push({ ...env, [ready_signal_1.READY_URL_ENV]: 'http://localhost/' });
|
|
1515
|
+
}
|
|
1516
|
+
const errors = envs.map((checkEnv) => {
|
|
1517
|
+
try {
|
|
1518
|
+
this.getReadyWhen(task, checkEnv, inputs);
|
|
1519
|
+
return null;
|
|
1520
|
+
}
|
|
1521
|
+
catch (e) {
|
|
1522
|
+
return e;
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
if (errors.every(Boolean)) {
|
|
1526
|
+
this.getReadinessCheck(task, () => {
|
|
1527
|
+
throw errors[errors.length - 1];
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1457
1530
|
}
|
|
1458
1531
|
// Only the process that runs a producer knows the env its probe reads
|
|
1459
1532
|
getReadyWhenWait(task) {
|
|
@@ -1505,11 +1578,7 @@ class TaskOrchestrator {
|
|
|
1505
1578
|
this.taskGraph.tasks[producerId]) {
|
|
1506
1579
|
throw e;
|
|
1507
1580
|
}
|
|
1508
|
-
this.onReadinessHold(producerId);
|
|
1509
|
-
const owned = await this.pollReadinessRow(producer, {
|
|
1510
|
-
timeout: ready_when_1.DEFAULT_READY_TIMEOUT,
|
|
1511
|
-
description: 'invalid',
|
|
1512
|
-
});
|
|
1581
|
+
const owned = await this.pollReadinessRow(producer, { timeout: ready_when_1.DEFAULT_READY_TIMEOUT, description: 'invalid' }, { onPending: () => this.onReadinessHold(producerId) });
|
|
1513
1582
|
if (!owned) {
|
|
1514
1583
|
throw e;
|
|
1515
1584
|
}
|
|
@@ -1527,8 +1596,9 @@ class TaskOrchestrator {
|
|
|
1527
1596
|
await this.readinessOf(producerId).promise;
|
|
1528
1597
|
}
|
|
1529
1598
|
else {
|
|
1530
|
-
this.
|
|
1531
|
-
|
|
1599
|
+
await this.pollReadinessRow(producer, readyWhen, {
|
|
1600
|
+
onPending: () => this.onReadinessHold(producerId),
|
|
1601
|
+
});
|
|
1532
1602
|
}
|
|
1533
1603
|
}
|
|
1534
1604
|
}
|
|
@@ -1550,7 +1620,7 @@ class TaskOrchestrator {
|
|
|
1550
1620
|
// A row absent from the start means no Nx process this one can see owns the
|
|
1551
1621
|
// producer (resolves false), unless the caller already saw the owner: then it
|
|
1552
1622
|
// exited. A row that disappears mid-wait means the producer exited.
|
|
1553
|
-
async pollReadinessRow(producer, readyWhen, signal, ownerObserved = false) {
|
|
1623
|
+
async pollReadinessRow(producer, readyWhen, { signal, ownerObserved = false, onPending, } = {}) {
|
|
1554
1624
|
const deadline = Date.now() + readyWhen.timeout;
|
|
1555
1625
|
let lastStatus = null;
|
|
1556
1626
|
while (true) {
|
|
@@ -1581,6 +1651,7 @@ class TaskOrchestrator {
|
|
|
1581
1651
|
if (Date.now() >= deadline) {
|
|
1582
1652
|
throw (0, ready_when_1.readinessTimeoutError)(producer.id, readyWhen);
|
|
1583
1653
|
}
|
|
1654
|
+
onPending?.();
|
|
1584
1655
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1585
1656
|
}
|
|
1586
1657
|
}
|
|
@@ -279,12 +279,11 @@ class TasksSchedule {
|
|
|
279
279
|
if (!started) {
|
|
280
280
|
return false;
|
|
281
281
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
this.hooks.onReadinessHold?.(
|
|
285
|
-
return false;
|
|
282
|
+
const pendingProducers = this.probedProducersOf(this.taskGraph.tasks[taskId]).filter((id) => this.taskGraph.tasks[id] && !this.readiness.has(id));
|
|
283
|
+
for (const producerId of pendingProducers) {
|
|
284
|
+
this.hooks.onReadinessHold?.(producerId);
|
|
286
285
|
}
|
|
287
|
-
return
|
|
286
|
+
return pendingProducers.length === 0;
|
|
288
287
|
}
|
|
289
288
|
canBeScheduled(taskId) {
|
|
290
289
|
const hasDependenciesCompleted = this.taskGraph.dependencies[taskId].every(({ id }) => this.completedTasks.has(id));
|
|
@@ -112,8 +112,9 @@ function addMatchingProjectsByName(projectNames, projects, pattern, matchedProje
|
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
114
114
|
if (!(0, globs_1.isGlobPattern)(pattern.value)) {
|
|
115
|
+
const escapedValue = pattern.value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
115
116
|
// Custom regex that is basically \b but includes hyphens (-) and excludes underscores (_), so "foo" pattern matches "foo_bar" but not "foo-e2e".
|
|
116
|
-
const regex = new RegExp(`(?<![@a-zA-Z0-9-])${
|
|
117
|
+
const regex = new RegExp(`(?<![@a-zA-Z0-9-])${escapedValue}(?![@a-zA-Z0-9-])`, 'i');
|
|
117
118
|
const matchingProjects = Object.keys(projects).filter((name) => regex.test(name));
|
|
118
119
|
for (const projectName of matchingProjects) {
|
|
119
120
|
if (pattern.exclude) {
|
|
@@ -181,11 +182,13 @@ function parseStringPattern(pattern, projects) {
|
|
|
181
182
|
}
|
|
182
183
|
else {
|
|
183
184
|
const potentialType = pattern.substring(0, indexOfFirstPotentialSeparator);
|
|
184
|
-
return
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
return isValidPatternType(potentialType)
|
|
186
|
+
? {
|
|
187
|
+
type: potentialType,
|
|
188
|
+
value: pattern.substring(indexOfFirstPotentialSeparator + 1),
|
|
189
|
+
exclude: isExclude,
|
|
190
|
+
}
|
|
191
|
+
: { type: 'unlabeled', value: pattern, exclude: isExclude };
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
function isValidPatternType(type) {
|
|
@@ -71,6 +71,8 @@ export declare function getWorkingTreeStatus(directory?: string, excludePaths?:
|
|
|
71
71
|
export declare function hasUncommittedChanges(directory?: string, excludePaths?: string[]): boolean;
|
|
72
72
|
export type PathCommitExposure = 'ignored' | 'tracked' | 'unignored' | 'unknown';
|
|
73
73
|
export declare function getPathCommitExposure(dirPath: string, directory?: string): PathCommitExposure;
|
|
74
|
+
export type PathHeadStatus = 'committed' | 'absent' | 'unknown';
|
|
75
|
+
export declare function getPathHeadStatus(path: string, directory: string): PathHeadStatus;
|
|
74
76
|
export declare function getUncommittedChangesSnapshot(directory?: string): string;
|
|
75
77
|
export declare function commitChanges(commitMessage: string, directory?: string): string | null;
|
|
76
78
|
/**
|
|
@@ -101,10 +103,10 @@ export declare function tryCommitChangesAsync(commitMessage: string, directory:
|
|
|
101
103
|
withoutTerminal?: boolean;
|
|
102
104
|
}): Promise<string | null>;
|
|
103
105
|
/**
|
|
104
|
-
* `git reset --hard <ref>` then `git clean -fd`,
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* never user input.
|
|
106
|
+
* `git reset --hard <ref>` then `git clean -fd`, sparing the
|
|
107
|
+
* `directory`-relative `keepPaths`, staged or not. A kept path `ref` tracks
|
|
108
|
+
* comes back at `ref`'s version. Throws with git's stderr when git fails.
|
|
109
|
+
* `ref` is a sha a caller validated with `GIT_SHA`, never user input.
|
|
108
110
|
*/
|
|
109
111
|
export declare function resetWorkingTree(ref: string, keepPaths: string[], directory: string): void;
|
|
110
112
|
export declare function getLatestCommitSha(directory?: string): string | null;
|
|
@@ -16,6 +16,7 @@ exports.getGitRemoteNames = getGitRemoteNames;
|
|
|
16
16
|
exports.getWorkingTreeStatus = getWorkingTreeStatus;
|
|
17
17
|
exports.hasUncommittedChanges = hasUncommittedChanges;
|
|
18
18
|
exports.getPathCommitExposure = getPathCommitExposure;
|
|
19
|
+
exports.getPathHeadStatus = getPathHeadStatus;
|
|
19
20
|
exports.getUncommittedChangesSnapshot = getUncommittedChangesSnapshot;
|
|
20
21
|
exports.commitChanges = commitChanges;
|
|
21
22
|
exports.tryCommitChanges = tryCommitChanges;
|
|
@@ -674,12 +675,14 @@ function getGitRemoteNames(directory) {
|
|
|
674
675
|
// `excludePaths` are left out of the probe the way `tryCommitChanges` leaves
|
|
675
676
|
// them out of the commit, so a tree dirty only under them reads as clean. An
|
|
676
677
|
// exclude-only pathspec still covers the whole tree, matching `git add -A`.
|
|
678
|
+
// The untracked mode is explicit because `status.showUntrackedFiles=no` would
|
|
679
|
+
// hide new files that `git add -A` still stages.
|
|
677
680
|
function getWorkingTreeStatus(directory, excludePaths = []) {
|
|
678
681
|
const pathspecs = excludePaths
|
|
679
682
|
.map((excludePath) => ` ":(exclude)${excludePath}"`)
|
|
680
683
|
.join('');
|
|
681
684
|
try {
|
|
682
|
-
const out = (0, child_process_1.execSync)(`git status --porcelain${pathspecs ? ` --${pathspecs}` : ''}`, {
|
|
685
|
+
const out = (0, child_process_1.execSync)(`git status --porcelain --untracked-files=normal${pathspecs ? ` --${pathspecs}` : ''}`, {
|
|
683
686
|
encoding: 'utf8',
|
|
684
687
|
cwd: directory,
|
|
685
688
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
@@ -739,6 +742,30 @@ function getPathCommitExposure(dirPath, directory) {
|
|
|
739
742
|
return e?.status === 1 ? 'unignored' : 'unknown';
|
|
740
743
|
}
|
|
741
744
|
}
|
|
745
|
+
// Whether HEAD's tree, not the index, has an entry at the `directory`-relative
|
|
746
|
+
// `path`. An unborn HEAD has none; 'unknown' means git failed.
|
|
747
|
+
function getPathHeadStatus(path, directory) {
|
|
748
|
+
const options = {
|
|
749
|
+
encoding: 'utf8',
|
|
750
|
+
cwd: directory,
|
|
751
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
752
|
+
windowsHide: true,
|
|
753
|
+
};
|
|
754
|
+
try {
|
|
755
|
+
(0, child_process_1.execFileSync)('git', ['rev-parse', '--verify', '-q', 'HEAD'], options);
|
|
756
|
+
}
|
|
757
|
+
catch (e) {
|
|
758
|
+
// --verify -q exits 1 for a ref that does not resolve: an unborn HEAD.
|
|
759
|
+
return e?.status === 1 ? 'absent' : 'unknown';
|
|
760
|
+
}
|
|
761
|
+
try {
|
|
762
|
+
const entries = (0, child_process_1.execFileSync)('git', ['ls-tree', '--name-only', 'HEAD', '--', path], options);
|
|
763
|
+
return entries.trim() === '' ? 'absent' : 'committed';
|
|
764
|
+
}
|
|
765
|
+
catch {
|
|
766
|
+
return 'unknown';
|
|
767
|
+
}
|
|
768
|
+
}
|
|
742
769
|
// Returns a content-sensitive sha1 snapshot of the working tree state for
|
|
743
770
|
// before/after comparison. Hashes three probes:
|
|
744
771
|
// 1. `git diff HEAD` with defensive flags — every byte of tracked-file
|
|
@@ -943,20 +970,30 @@ function collectOutput(child, command, done) {
|
|
|
943
970
|
return child;
|
|
944
971
|
}
|
|
945
972
|
/**
|
|
946
|
-
* `git reset --hard <ref>` then `git clean -fd`,
|
|
947
|
-
*
|
|
948
|
-
*
|
|
949
|
-
* never user input.
|
|
973
|
+
* `git reset --hard <ref>` then `git clean -fd`, sparing the
|
|
974
|
+
* `directory`-relative `keepPaths`, staged or not. A kept path `ref` tracks
|
|
975
|
+
* comes back at `ref`'s version. Throws with git's stderr when git fails.
|
|
976
|
+
* `ref` is a sha a caller validated with `GIT_SHA`, never user input.
|
|
950
977
|
*/
|
|
951
978
|
function resetWorkingTree(ref, keepPaths, directory) {
|
|
979
|
+
// `git clean -e` takes ignore patterns, which resolve from the repository
|
|
980
|
+
// root whatever the cwd, and match at any depth when they hold no slash.
|
|
981
|
+
const prefix = getGitRootRelativePath(directory);
|
|
982
|
+
if (prefix === null) {
|
|
983
|
+
throw new Error(`${directory} is not inside a git repository.`);
|
|
984
|
+
}
|
|
985
|
+
const keepPatterns = keepPaths.map((keepPath) => `/${path_1.posix.join(prefix, keepPath).replace(/[\\*?[]/g, '\\$&')}`);
|
|
952
986
|
const options = {
|
|
953
987
|
encoding: 'utf8',
|
|
954
988
|
stdio: 'pipe',
|
|
955
989
|
cwd: directory,
|
|
956
990
|
windowsHide: true,
|
|
957
991
|
};
|
|
992
|
+
// `reset --hard` deletes a kept path staged since `ref`, so its index entry
|
|
993
|
+
// goes back to `ref` first, leaving it untracked for the clean to skip.
|
|
994
|
+
(0, child_process_1.execFileSync)('git', ['reset', '-q', ref, '--', ...keepPaths], options);
|
|
958
995
|
(0, child_process_1.execFileSync)('git', ['reset', '--hard', ref], options);
|
|
959
|
-
(0, child_process_1.execFileSync)('git', ['clean', '-fd', ...
|
|
996
|
+
(0, child_process_1.execFileSync)('git', ['clean', '-fd', ...keepPatterns.flatMap((pattern) => ['-e', pattern])], options);
|
|
960
997
|
}
|
|
961
998
|
function getLatestCommitSha(directory) {
|
|
962
999
|
try {
|
|
@@ -224,9 +224,10 @@ declare class CLIOutput {
|
|
|
224
224
|
* The batch's own output is copied straight from the file it was captured
|
|
225
225
|
* into, so an arbitrarily long log costs a fixed amount of memory here.
|
|
226
226
|
* Nothing is withheld: this rendering is chosen because the whole log was
|
|
227
|
-
* asked for, because no task claimed any of it, or because a task failed
|
|
228
|
-
* was stopped — in which case repeating claimed bytes
|
|
229
|
-
* blocks is deliberate (see
|
|
227
|
+
* asked for, because no task claimed any of it, or because a task failed,
|
|
228
|
+
* was stopped or was never reached — in which case repeating claimed bytes
|
|
229
|
+
* beside the per-task blocks is deliberate (see
|
|
230
|
+
* TaskOrchestrator.printGroupedBatchOutput).
|
|
230
231
|
*/
|
|
231
232
|
logBatchGroup(label: string, body: {
|
|
232
233
|
capturedOutputPath?: string;
|
package/dist/src/utils/output.js
CHANGED
|
@@ -422,9 +422,10 @@ class CLIOutput {
|
|
|
422
422
|
* The batch's own output is copied straight from the file it was captured
|
|
423
423
|
* into, so an arbitrarily long log costs a fixed amount of memory here.
|
|
424
424
|
* Nothing is withheld: this rendering is chosen because the whole log was
|
|
425
|
-
* asked for, because no task claimed any of it, or because a task failed
|
|
426
|
-
* was stopped — in which case repeating claimed bytes
|
|
427
|
-
* blocks is deliberate (see
|
|
425
|
+
* asked for, because no task claimed any of it, or because a task failed,
|
|
426
|
+
* was stopped or was never reached — in which case repeating claimed bytes
|
|
427
|
+
* beside the per-task blocks is deliberate (see
|
|
428
|
+
* TaskOrchestrator.printGroupedBatchOutput).
|
|
428
429
|
*/
|
|
429
430
|
logBatchGroup(label, body, taskStatus) {
|
|
430
431
|
const grouped = isLogGroupingEnabled();
|
|
@@ -23,6 +23,7 @@ exports.addPackagePathToWorkspaces = addPackagePathToWorkspaces;
|
|
|
23
23
|
const child_process_1 = require("child_process");
|
|
24
24
|
const fs_1 = require("fs");
|
|
25
25
|
const promises_1 = require("node:fs/promises");
|
|
26
|
+
const node_os_1 = require("node:os");
|
|
26
27
|
const path_1 = require("path");
|
|
27
28
|
const semver_1 = require("semver");
|
|
28
29
|
const tmp_1 = require("tmp");
|
|
@@ -335,6 +336,10 @@ function getPackageManagerVersion(packageManager = detectPackageManager(), cwd =
|
|
|
335
336
|
cwd,
|
|
336
337
|
encoding: 'utf-8',
|
|
337
338
|
windowsHide: true,
|
|
339
|
+
// Store discovery creates temporary workspace files even for --version.
|
|
340
|
+
env: packageManager === 'pnpm'
|
|
341
|
+
? { ...process.env, PNPM_CONFIG_STORE_DIR: (0, node_os_1.tmpdir)() }
|
|
342
|
+
: undefined,
|
|
338
343
|
}).trim();
|
|
339
344
|
}
|
|
340
345
|
catch { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "24.0.
|
|
3
|
+
"version": "24.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
|
@@ -150,16 +150,16 @@
|
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
"optionalDependencies": {
|
|
153
|
-
"@nx/nx-darwin-arm64": "24.0.
|
|
154
|
-
"@nx/nx-darwin-x64": "24.0.
|
|
155
|
-
"@nx/nx-freebsd-x64": "24.0.
|
|
156
|
-
"@nx/nx-linux-arm-gnueabihf": "24.0.
|
|
157
|
-
"@nx/nx-linux-arm64-gnu": "24.0.
|
|
158
|
-
"@nx/nx-linux-arm64-musl": "24.0.
|
|
159
|
-
"@nx/nx-linux-x64-gnu": "24.0.
|
|
160
|
-
"@nx/nx-linux-x64-musl": "24.0.
|
|
161
|
-
"@nx/nx-win32-arm64-msvc": "24.0.
|
|
162
|
-
"@nx/nx-win32-x64-msvc": "24.0.
|
|
153
|
+
"@nx/nx-darwin-arm64": "24.0.2",
|
|
154
|
+
"@nx/nx-darwin-x64": "24.0.2",
|
|
155
|
+
"@nx/nx-freebsd-x64": "24.0.2",
|
|
156
|
+
"@nx/nx-linux-arm-gnueabihf": "24.0.2",
|
|
157
|
+
"@nx/nx-linux-arm64-gnu": "24.0.2",
|
|
158
|
+
"@nx/nx-linux-arm64-musl": "24.0.2",
|
|
159
|
+
"@nx/nx-linux-x64-gnu": "24.0.2",
|
|
160
|
+
"@nx/nx-linux-x64-musl": "24.0.2",
|
|
161
|
+
"@nx/nx-win32-arm64-msvc": "24.0.2",
|
|
162
|
+
"@nx/nx-win32-x64-msvc": "24.0.2"
|
|
163
163
|
},
|
|
164
164
|
"nx-migrations": {
|
|
165
165
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
|
@@ -1122,6 +1122,12 @@
|
|
|
1122
1122
|
"enum": ["ignore", "forward"],
|
|
1123
1123
|
"default": "ignore"
|
|
1124
1124
|
},
|
|
1125
|
+
"options": {
|
|
1126
|
+
"type": "string",
|
|
1127
|
+
"description": "Whether to forward task options to the dependency target.",
|
|
1128
|
+
"enum": ["ignore", "forward"],
|
|
1129
|
+
"default": "ignore"
|
|
1130
|
+
},
|
|
1125
1131
|
"inputs": {
|
|
1126
1132
|
"type": "boolean",
|
|
1127
1133
|
"description": "Set to false to keep a continuous dependency's inputs out of this target's hash and affected calculation. Has no effect on dependencies that are not continuous.",
|
|
@@ -103,6 +103,12 @@
|
|
|
103
103
|
"enum": ["ignore", "forward"],
|
|
104
104
|
"default": "ignore"
|
|
105
105
|
},
|
|
106
|
+
"options": {
|
|
107
|
+
"type": "string",
|
|
108
|
+
"description": "Whether to forward task options to the dependency target.",
|
|
109
|
+
"enum": ["ignore", "forward"],
|
|
110
|
+
"default": "ignore"
|
|
111
|
+
},
|
|
106
112
|
"inputs": {
|
|
107
113
|
"type": "boolean",
|
|
108
114
|
"description": "Set to false to keep a continuous dependency's inputs out of this target's hash and affected calculation. Has no effect on dependencies that are not continuous.",
|