nx 21.0.0-beta.1 → 21.0.0-beta.3
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/.eslintrc.json +5 -1
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +186 -35
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +3 -0
- package/src/command-line/add/add.js +6 -16
- package/src/command-line/affected/command-object.js +6 -6
- package/src/command-line/examples.js +0 -4
- package/src/command-line/exec/command-object.js +1 -1
- package/src/command-line/generate/generator-utils.js +8 -3
- package/src/command-line/import/import.js +1 -1
- package/src/command-line/init/command-object.js +18 -6
- package/src/command-line/init/configure-plugins.d.ts +6 -7
- package/src/command-line/init/configure-plugins.js +47 -35
- package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
- package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
- package/src/command-line/init/implementation/check-compatible-with-plugins.js +7 -1
- package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
- package/src/command-line/init/implementation/deduce-default-base.js +53 -0
- package/src/command-line/init/implementation/react/add-vite-commands-to-package-scripts.js +6 -4
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +32 -185
- package/src/command-line/init/implementation/react/write-vite-config.js +19 -3
- package/src/command-line/init/implementation/utils.d.ts +4 -1
- package/src/command-line/init/implementation/utils.js +108 -44
- package/src/command-line/init/init-v1.js +1 -1
- package/src/command-line/init/init-v2.d.ts +1 -0
- package/src/command-line/init/init-v2.js +68 -38
- package/src/command-line/nx-commands.js +19 -5
- package/src/command-line/register/command-object.d.ts +6 -0
- package/src/command-line/{activate-powerpack → register}/command-object.js +9 -9
- package/src/command-line/register/register.d.ts +2 -0
- package/src/command-line/register/register.js +9 -0
- package/src/command-line/release/changelog.js +18 -15
- package/src/command-line/release/command-object.d.ts +2 -0
- package/src/command-line/release/command-object.js +9 -0
- package/src/command-line/release/config/config.d.ts +8 -7
- package/src/command-line/release/config/config.js +129 -42
- package/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/src/command-line/release/config/use-legacy-versioning.js +9 -0
- package/src/command-line/release/index.d.ts +4 -0
- package/src/command-line/release/index.js +6 -1
- package/src/command-line/release/plan-check.js +6 -3
- package/src/command-line/release/plan.js +7 -3
- package/src/command-line/release/publish.js +7 -3
- package/src/command-line/release/release.js +8 -3
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +6 -3
- package/src/command-line/release/utils/git.d.ts +3 -2
- package/src/command-line/release/utils/git.js +65 -9
- package/src/command-line/release/utils/github.js +3 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +2 -1
- package/src/command-line/release/utils/resolve-semver-specifier.js +2 -1
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +8 -0
- package/src/command-line/release/utils/shared-legacy.d.ts +25 -0
- package/src/command-line/release/utils/shared-legacy.js +2 -0
- package/src/command-line/release/utils/shared.d.ts +11 -17
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.d.ts +7 -0
- package/src/command-line/release/version/derive-specifier-from-conventional-commits.js +47 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.d.ts +8 -0
- package/src/command-line/release/version/deriver-specifier-from-version-plans.js +59 -0
- package/src/command-line/release/version/project-logger.d.ts +8 -0
- package/src/command-line/release/version/project-logger.js +45 -0
- package/src/command-line/release/version/release-group-processor.d.ts +251 -0
- package/src/command-line/release/version/release-group-processor.js +1040 -0
- package/src/command-line/release/version/resolve-current-version.d.ts +32 -0
- package/src/command-line/release/version/resolve-current-version.js +241 -0
- package/src/command-line/release/version/test-utils.d.ts +95 -0
- package/src/command-line/release/version/test-utils.js +416 -0
- package/src/command-line/release/version/topological-sort.d.ts +9 -0
- package/src/command-line/release/version/topological-sort.js +41 -0
- package/src/command-line/release/version/version-actions.d.ts +170 -0
- package/src/command-line/release/version/version-actions.js +183 -0
- package/src/command-line/release/version-legacy.d.ts +46 -0
- package/src/command-line/release/version-legacy.js +453 -0
- package/src/command-line/release/version.d.ts +0 -40
- package/src/command-line/release/version.js +80 -262
- package/src/command-line/report/report.d.ts +7 -3
- package/src/command-line/report/report.js +52 -18
- package/src/command-line/run/command-object.js +2 -2
- package/src/command-line/run/run.js +1 -1
- package/src/command-line/run-many/command-object.js +2 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -0
- package/src/command-line/yargs-utils/shared-options.js +20 -0
- package/src/config/nx-json.d.ts +153 -15
- package/src/config/project-graph.d.ts +4 -2
- package/src/config/project-graph.js +8 -0
- package/src/config/workspace-json-project-json.d.ts +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +2 -0
- package/src/daemon/client/client.js +15 -0
- package/src/daemon/message-types/glob.d.ts +7 -0
- package/src/daemon/message-types/glob.js +9 -1
- package/src/daemon/message-types/hash-glob.d.ts +6 -0
- package/src/daemon/message-types/hash-glob.js +9 -1
- package/src/daemon/server/handle-glob.d.ts +1 -0
- package/src/daemon/server/handle-glob.js +8 -0
- package/src/daemon/server/handle-hash-glob.d.ts +1 -0
- package/src/daemon/server/handle-hash-glob.js +8 -0
- package/src/daemon/server/logger.js +2 -1
- package/src/daemon/server/server.js +7 -0
- package/src/devkit-internals.d.ts +2 -1
- package/src/devkit-internals.js +4 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +3 -5
- package/src/executors/run-commands/run-commands.impl.js +14 -42
- package/src/executors/run-commands/running-tasks.d.ts +7 -5
- package/src/executors/run-commands/running-tasks.js +64 -27
- package/src/executors/run-script/run-script.impl.js +4 -3
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +8 -0
- package/src/generators/testing-utils/create-tree.js +5 -1
- package/src/native/index.d.ts +93 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +6 -0
- package/src/native/nx.wasi-browser.js +20 -19
- package/src/native/nx.wasi.cjs +20 -19
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/nx-cloud-tasks-runner-shell.js +3 -3
- package/src/plugins/js/lock-file/lock-file.js +28 -13
- package/src/plugins/js/lock-file/utils/package-json.d.ts +1 -1
- package/src/plugins/js/lock-file/utils/package-json.js +2 -1
- package/src/plugins/js/lock-file/yarn-parser.js +85 -39
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +1 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +10 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +59 -6
- package/src/plugins/js/utils/packages.js +22 -3
- package/src/plugins/js/utils/register.js +1 -0
- package/src/plugins/js/utils/typescript.js +3 -3
- package/src/plugins/package-json/create-nodes.d.ts +1 -1
- package/src/plugins/package-json/create-nodes.js +3 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
- package/src/project-graph/error-types.js +32 -2
- package/src/project-graph/plugins/get-plugins.js +2 -1
- package/src/project-graph/plugins/in-process-loader.js +1 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +12 -6
- package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +2 -2
- package/src/project-graph/project-graph.js +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.js +25 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
- package/src/tasks-runner/batch/batch-messages.d.ts +2 -0
- package/src/tasks-runner/batch/run-batch.js +2 -3
- package/src/tasks-runner/cache.d.ts +20 -6
- package/src/tasks-runner/cache.js +104 -20
- package/src/tasks-runner/create-task-graph.d.ts +1 -1
- package/src/tasks-runner/create-task-graph.js +12 -11
- package/src/tasks-runner/default-tasks-runner.js +4 -13
- package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
- package/src/tasks-runner/forked-process-task-runner.js +56 -46
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +55 -2
- package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
- package/src/tasks-runner/is-tui-enabled.js +58 -0
- package/src/tasks-runner/life-cycle.d.ts +10 -3
- package/src/tasks-runner/life-cycle.js +23 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +7 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +6 -1
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +17 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +221 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +10 -7
- package/src/tasks-runner/pseudo-terminal.js +37 -35
- package/src/tasks-runner/run-command.d.ts +1 -0
- package/src/tasks-runner/run-command.js +180 -23
- package/src/tasks-runner/task-env.d.ts +1 -4
- package/src/tasks-runner/task-env.js +2 -0
- package/src/tasks-runner/task-orchestrator.d.ts +21 -9
- package/src/tasks-runner/task-orchestrator.js +127 -44
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.js +15 -11
- package/src/utils/child-process.d.ts +4 -0
- package/src/utils/child-process.js +23 -30
- package/src/utils/command-line-utils.d.ts +1 -1
- package/src/utils/find-matching-projects.js +2 -2
- package/src/utils/handle-errors.js +15 -0
- package/src/utils/is-ci.js +4 -1
- package/src/utils/is-using-prettier.d.ts +3 -0
- package/src/utils/is-using-prettier.js +62 -0
- package/src/utils/nx-key.d.ts +7 -0
- package/src/utils/nx-key.js +52 -0
- package/src/utils/package-manager.js +2 -2
- package/src/utils/path.js +1 -1
- package/src/utils/require-nx-key.d.ts +1 -0
- package/src/utils/require-nx-key.js +22 -0
- package/src/utils/workspace-context.d.ts +2 -0
- package/src/utils/workspace-context.js +16 -0
- package/src/command-line/activate-powerpack/activate-powerpack.d.ts +0 -2
- package/src/command-line/activate-powerpack/activate-powerpack.js +0 -34
- package/src/command-line/activate-powerpack/command-object.d.ts +0 -6
- package/src/command-line/init/implementation/react/write-craco-config.d.ts +0 -1
- package/src/command-line/init/implementation/react/write-craco-config.js +0 -61
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
@@ -0,0 +1,221 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getTuiTerminalSummaryLifeCycle = getTuiTerminalSummaryLifeCycle;
|
4
|
+
const node_os_1 = require("node:os");
|
5
|
+
const output_1 = require("../../utils/output");
|
6
|
+
const formatting_utils_1 = require("./formatting-utils");
|
7
|
+
const pretty_time_1 = require("./pretty-time");
|
8
|
+
const view_logs_utils_1 = require("./view-logs-utils");
|
9
|
+
const figures = require("figures");
|
10
|
+
const LEFT_PAD = ` `;
|
11
|
+
const SPACER = ` `;
|
12
|
+
const EXTENDED_LEFT_PAD = ` `;
|
13
|
+
function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides, initiatingProject, resolveRenderIsDonePromise, }) {
|
14
|
+
const lifeCycle = {};
|
15
|
+
const start = process.hrtime();
|
16
|
+
const targets = args.targets;
|
17
|
+
const totalTasks = tasks.length;
|
18
|
+
let totalCachedTasks = 0;
|
19
|
+
let totalSuccessfulTasks = 0;
|
20
|
+
let totalFailedTasks = 0;
|
21
|
+
let totalCompletedTasks = 0;
|
22
|
+
let timeTakenText;
|
23
|
+
const failedTasks = new Set();
|
24
|
+
const inProgressTasks = new Set();
|
25
|
+
const tasksToTerminalOutputs = {};
|
26
|
+
const taskIdsInOrderOfCompletion = [];
|
27
|
+
lifeCycle.startTasks = (tasks) => {
|
28
|
+
for (let t of tasks) {
|
29
|
+
inProgressTasks.add(t.id);
|
30
|
+
}
|
31
|
+
};
|
32
|
+
lifeCycle.printTaskTerminalOutput = (task, taskStatus, terminalOutput) => {
|
33
|
+
tasksToTerminalOutputs[task.id] = { terminalOutput, taskStatus };
|
34
|
+
taskIdsInOrderOfCompletion.push(task.id);
|
35
|
+
};
|
36
|
+
lifeCycle.endTasks = (taskResults) => {
|
37
|
+
for (let t of taskResults) {
|
38
|
+
totalCompletedTasks++;
|
39
|
+
inProgressTasks.delete(t.task.id);
|
40
|
+
switch (t.status) {
|
41
|
+
case 'remote-cache':
|
42
|
+
case 'local-cache':
|
43
|
+
case 'local-cache-kept-existing':
|
44
|
+
totalCachedTasks++;
|
45
|
+
totalSuccessfulTasks++;
|
46
|
+
break;
|
47
|
+
case 'success':
|
48
|
+
totalSuccessfulTasks++;
|
49
|
+
break;
|
50
|
+
case 'failure':
|
51
|
+
totalFailedTasks++;
|
52
|
+
failedTasks.add(t.task.id);
|
53
|
+
break;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
};
|
57
|
+
lifeCycle.endCommand = () => {
|
58
|
+
timeTakenText = (0, pretty_time_1.prettyTime)(process.hrtime(start));
|
59
|
+
resolveRenderIsDonePromise();
|
60
|
+
};
|
61
|
+
const printSummary = () => {
|
62
|
+
const isRunOne = initiatingProject && targets?.length === 1;
|
63
|
+
// Handles when the user interrupts the process
|
64
|
+
timeTakenText ??= (0, pretty_time_1.prettyTime)(process.hrtime(start));
|
65
|
+
if (totalTasks === 0) {
|
66
|
+
console.log(`\n${output_1.output.applyNxPrefix('gray', 'No tasks were run')}\n`);
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
if (isRunOne) {
|
70
|
+
printRunOneSummary();
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
printRunManySummary();
|
74
|
+
}
|
75
|
+
};
|
76
|
+
const printRunOneSummary = () => {
|
77
|
+
let lines = [];
|
78
|
+
const failure = totalSuccessfulTasks !== totalTasks;
|
79
|
+
// Prints task outputs in the order they were completed
|
80
|
+
// above the summary, since run-one should print all task results.
|
81
|
+
for (const taskId of taskIdsInOrderOfCompletion) {
|
82
|
+
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
|
83
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
84
|
+
}
|
85
|
+
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
86
|
+
if (!failure) {
|
87
|
+
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)([initiatingProject], targets, tasks)}`;
|
88
|
+
const taskOverridesLines = [];
|
89
|
+
if (Object.keys(overrides).length > 0) {
|
90
|
+
taskOverridesLines.push('');
|
91
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
92
|
+
Object.entries(overrides)
|
93
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
94
|
+
.forEach((arg) => taskOverridesLines.push(arg));
|
95
|
+
}
|
96
|
+
lines.push(output_1.output.applyNxPrefix('green', output_1.output.colors.green(text) + output_1.output.dim(` (${timeTakenText})`)), ...taskOverridesLines);
|
97
|
+
if (totalCachedTasks > 0) {
|
98
|
+
lines.push(output_1.output.dim(`${node_os_1.EOL}Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
|
99
|
+
}
|
100
|
+
lines = [output_1.output.colors.green(lines.join(node_os_1.EOL))];
|
101
|
+
}
|
102
|
+
else if (totalCompletedTasks === totalTasks) {
|
103
|
+
let text = `Ran target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`;
|
104
|
+
if (tasks.length > 1) {
|
105
|
+
text += ` and ${output_1.output.bold(tasks.length - 1)} task(s) they depend on`;
|
106
|
+
}
|
107
|
+
const taskOverridesLines = [];
|
108
|
+
if (Object.keys(overrides).length > 0) {
|
109
|
+
taskOverridesLines.push('');
|
110
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
111
|
+
Object.entries(overrides)
|
112
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
113
|
+
.forEach((arg) => taskOverridesLines.push(arg));
|
114
|
+
}
|
115
|
+
const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
|
116
|
+
lines = [
|
117
|
+
output_1.output.colors.red([
|
118
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
|
119
|
+
...taskOverridesLines,
|
120
|
+
'',
|
121
|
+
`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
|
122
|
+
`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
|
123
|
+
...viewLogs,
|
124
|
+
]),
|
125
|
+
];
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
lines = [
|
129
|
+
...output_1.output.getVerticalSeparatorLines('red'),
|
130
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(`Cancelled running target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`) + output_1.output.dim(` (${timeTakenText})`)),
|
131
|
+
];
|
132
|
+
}
|
133
|
+
// adds some vertical space after the summary to avoid bunching against terminal
|
134
|
+
lines.push('');
|
135
|
+
console.log(lines.join(node_os_1.EOL));
|
136
|
+
};
|
137
|
+
const printRunManySummary = () => {
|
138
|
+
console.log('');
|
139
|
+
const lines = [];
|
140
|
+
const failure = totalSuccessfulTasks !== totalTasks;
|
141
|
+
for (const taskId of taskIdsInOrderOfCompletion) {
|
142
|
+
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
|
143
|
+
if (taskStatus === 'failure') {
|
144
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
145
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
146
|
+
}
|
147
|
+
else {
|
148
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.green(figures.tick)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
152
|
+
if (totalSuccessfulTasks === totalTasks) {
|
153
|
+
const successSummaryRows = [];
|
154
|
+
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
155
|
+
const taskOverridesRows = [];
|
156
|
+
if (Object.keys(overrides).length > 0) {
|
157
|
+
taskOverridesRows.push('');
|
158
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
159
|
+
Object.entries(overrides)
|
160
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
161
|
+
.forEach((arg) => taskOverridesRows.push(arg));
|
162
|
+
}
|
163
|
+
successSummaryRows.push(...[
|
164
|
+
output_1.output.applyNxPrefix('green', output_1.output.colors.green(text) + output_1.output.dim.white(` (${timeTakenText})`)),
|
165
|
+
...taskOverridesRows,
|
166
|
+
]);
|
167
|
+
if (totalCachedTasks > 0) {
|
168
|
+
successSummaryRows.push(output_1.output.dim(`${node_os_1.EOL}Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
|
169
|
+
}
|
170
|
+
lines.push(successSummaryRows.join(node_os_1.EOL));
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
const text = `${inProgressTasks.size ? 'Cancelled while running' : 'Ran'} ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
174
|
+
const taskOverridesRows = [];
|
175
|
+
if (Object.keys(overrides).length > 0) {
|
176
|
+
taskOverridesRows.push('');
|
177
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
178
|
+
Object.entries(overrides)
|
179
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
180
|
+
.forEach((arg) => taskOverridesRows.push(arg));
|
181
|
+
}
|
182
|
+
const numFailedToPrint = 5;
|
183
|
+
const failedTasksForPrinting = Array.from(failedTasks).slice(0, numFailedToPrint);
|
184
|
+
const failureSummaryRows = [
|
185
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim.white(` (${timeTakenText})`)),
|
186
|
+
...taskOverridesRows,
|
187
|
+
'',
|
188
|
+
];
|
189
|
+
if (totalCompletedTasks > 0) {
|
190
|
+
if (totalSuccessfulTasks > 0) {
|
191
|
+
failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`), '');
|
192
|
+
}
|
193
|
+
if (totalFailedTasks > 0) {
|
194
|
+
failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`, '', `${failedTasksForPrinting
|
195
|
+
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
196
|
+
.join('\n')}`, '');
|
197
|
+
if (failedTasks.size > numFailedToPrint) {
|
198
|
+
failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
|
199
|
+
}
|
200
|
+
}
|
201
|
+
if (totalCompletedTasks !== totalTasks) {
|
202
|
+
const remainingTasks = totalTasks - totalCompletedTasks;
|
203
|
+
if (inProgressTasks.size) {
|
204
|
+
failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${inProgressTasks.size}${`/${totalTasks}`} targets were in progress, including the following:`, '', `${Array.from(inProgressTasks)
|
205
|
+
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
206
|
+
.join(node_os_1.EOL)}`, '');
|
207
|
+
}
|
208
|
+
if (remainingTasks - inProgressTasks.size > 0) {
|
209
|
+
failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${remainingTasks - inProgressTasks.size}${`/${totalTasks}`} targets had not started.`), '');
|
210
|
+
}
|
211
|
+
}
|
212
|
+
failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
|
213
|
+
lines.push(output_1.output.colors.red(failureSummaryRows.join(node_os_1.EOL)));
|
214
|
+
}
|
215
|
+
}
|
216
|
+
// adds some vertical space after the summary to avoid bunching against terminal
|
217
|
+
lines.push('');
|
218
|
+
console.log(lines.join(node_os_1.EOL));
|
219
|
+
};
|
220
|
+
return { lifeCycle, printSummary };
|
221
|
+
}
|
@@ -1,7 +1,8 @@
|
|
1
|
+
import { Serializable } from 'child_process';
|
1
2
|
import { ChildProcess, RustPseudoTerminal } from '../native';
|
2
3
|
import { PseudoIPCServer } from './pseudo-ipc';
|
3
|
-
import {
|
4
|
-
export declare function
|
4
|
+
import { RunningTask } from './running-tasks/running-task';
|
5
|
+
export declare function createPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
|
5
6
|
export declare class PseudoTerminal {
|
6
7
|
private rustPseudoTerminal;
|
7
8
|
private pseudoIPCPath;
|
@@ -10,6 +11,7 @@ export declare class PseudoTerminal {
|
|
10
11
|
static isSupported(): boolean;
|
11
12
|
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
12
13
|
init(): Promise<void>;
|
14
|
+
shutdown(): void;
|
13
15
|
runCommand(command: string, { cwd, execArgv, jsEnv, quiet, tty, }?: {
|
14
16
|
cwd?: string;
|
15
17
|
execArgv?: string[];
|
@@ -25,16 +27,15 @@ export declare class PseudoTerminal {
|
|
25
27
|
}): Promise<PseudoTtyProcessWithSend>;
|
26
28
|
sendMessageToChildren(message: Serializable): void;
|
27
29
|
onMessageFromChildren(callback: (message: Serializable) => void): void;
|
28
|
-
private setupProcessListeners;
|
29
|
-
private shutdownPseudoIPC;
|
30
30
|
}
|
31
|
-
export declare class PseudoTtyProcess {
|
31
|
+
export declare class PseudoTtyProcess implements RunningTask {
|
32
|
+
rustPseudoTerminal: RustPseudoTerminal;
|
32
33
|
private childProcess;
|
33
34
|
isAlive: boolean;
|
34
35
|
private exitCallbacks;
|
35
36
|
private outputCallbacks;
|
36
37
|
private terminalOutput;
|
37
|
-
constructor(childProcess: ChildProcess);
|
38
|
+
constructor(rustPseudoTerminal: RustPseudoTerminal, childProcess: ChildProcess);
|
38
39
|
getResults(): Promise<{
|
39
40
|
code: number;
|
40
41
|
terminalOutput: string;
|
@@ -42,10 +43,12 @@ export declare class PseudoTtyProcess {
|
|
42
43
|
onExit(callback: (code: number) => void): void;
|
43
44
|
onOutput(callback: (message: string) => void): void;
|
44
45
|
kill(): void;
|
46
|
+
getParserAndWriter(): import("../native").ExternalObject<[ParserArc, WriterArc]>;
|
45
47
|
}
|
46
48
|
export declare class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
49
|
+
rustPseudoTerminal: RustPseudoTerminal;
|
47
50
|
private id;
|
48
51
|
private pseudoIpc;
|
49
|
-
constructor(_childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
|
52
|
+
constructor(rustPseudoTerminal: RustPseudoTerminal, _childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
|
50
53
|
send(message: Serializable): void;
|
51
54
|
}
|
@@ -1,29 +1,43 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = void 0;
|
4
|
-
exports.
|
4
|
+
exports.createPseudoTerminal = createPseudoTerminal;
|
5
|
+
const os = require("os");
|
6
|
+
const socket_utils_1 = require("../daemon/socket-utils");
|
5
7
|
const native_1 = require("../native");
|
6
8
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
7
|
-
|
8
|
-
const
|
9
|
-
|
10
|
-
|
9
|
+
// Register single event listeners for all pseudo-terminal instances
|
10
|
+
const pseudoTerminalShutdownCallbacks = [];
|
11
|
+
process.on('SIGINT', () => {
|
12
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
13
|
+
});
|
14
|
+
process.on('SIGTERM', () => {
|
15
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
16
|
+
});
|
17
|
+
process.on('SIGHUP', () => {
|
18
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
19
|
+
});
|
20
|
+
process.on('exit', () => {
|
21
|
+
pseudoTerminalShutdownCallbacks.forEach((cb) => cb());
|
22
|
+
});
|
23
|
+
function createPseudoTerminal(skipSupportCheck = false) {
|
11
24
|
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
12
25
|
throw new Error('Pseudo terminal is not supported on this platform.');
|
13
26
|
}
|
14
|
-
pseudoTerminal
|
27
|
+
const pseudoTerminal = new PseudoTerminal(new native_1.RustPseudoTerminal());
|
28
|
+
pseudoTerminalShutdownCallbacks.push(pseudoTerminal.shutdown.bind(pseudoTerminal));
|
15
29
|
return pseudoTerminal;
|
16
30
|
}
|
31
|
+
let id = 0;
|
17
32
|
class PseudoTerminal {
|
18
33
|
static isSupported() {
|
19
34
|
return process.stdout.isTTY && supportedPtyPlatform();
|
20
35
|
}
|
21
36
|
constructor(rustPseudoTerminal) {
|
22
37
|
this.rustPseudoTerminal = rustPseudoTerminal;
|
23
|
-
this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString());
|
38
|
+
this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString() + '-' + id++);
|
24
39
|
this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
|
25
40
|
this.initialized = false;
|
26
|
-
this.setupProcessListeners();
|
27
41
|
}
|
28
42
|
async init() {
|
29
43
|
if (this.initialized) {
|
@@ -32,14 +46,19 @@ class PseudoTerminal {
|
|
32
46
|
await this.pseudoIPC.init();
|
33
47
|
this.initialized = true;
|
34
48
|
}
|
49
|
+
shutdown() {
|
50
|
+
if (this.initialized) {
|
51
|
+
this.pseudoIPC.close();
|
52
|
+
}
|
53
|
+
}
|
35
54
|
runCommand(command, { cwd, execArgv, jsEnv, quiet, tty, } = {}) {
|
36
|
-
return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, execArgv, quiet, tty));
|
55
|
+
return new PseudoTtyProcess(this.rustPseudoTerminal, this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, execArgv, quiet, tty));
|
37
56
|
}
|
38
57
|
async fork(id, script, { cwd, execArgv, jsEnv, quiet, }) {
|
39
58
|
if (!this.initialized) {
|
40
59
|
throw new Error('Call init() before forking processes');
|
41
60
|
}
|
42
|
-
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
|
61
|
+
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal, this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, execArgv, quiet), id, this.pseudoIPC);
|
43
62
|
await this.pseudoIPC.waitForChildReady(id);
|
44
63
|
return cp;
|
45
64
|
}
|
@@ -49,32 +68,11 @@ class PseudoTerminal {
|
|
49
68
|
onMessageFromChildren(callback) {
|
50
69
|
this.pseudoIPC.onMessageFromChildren(callback);
|
51
70
|
}
|
52
|
-
setupProcessListeners() {
|
53
|
-
const shutdown = () => {
|
54
|
-
this.shutdownPseudoIPC();
|
55
|
-
};
|
56
|
-
process.on('SIGINT', () => {
|
57
|
-
this.shutdownPseudoIPC();
|
58
|
-
});
|
59
|
-
process.on('SIGTERM', () => {
|
60
|
-
this.shutdownPseudoIPC();
|
61
|
-
});
|
62
|
-
process.on('SIGHUP', () => {
|
63
|
-
this.shutdownPseudoIPC();
|
64
|
-
});
|
65
|
-
process.on('exit', () => {
|
66
|
-
this.shutdownPseudoIPC();
|
67
|
-
});
|
68
|
-
}
|
69
|
-
shutdownPseudoIPC() {
|
70
|
-
if (this.initialized) {
|
71
|
-
this.pseudoIPC.close();
|
72
|
-
}
|
73
|
-
}
|
74
71
|
}
|
75
72
|
exports.PseudoTerminal = PseudoTerminal;
|
76
73
|
class PseudoTtyProcess {
|
77
|
-
constructor(childProcess) {
|
74
|
+
constructor(rustPseudoTerminal, childProcess) {
|
75
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
78
76
|
this.childProcess = childProcess;
|
79
77
|
this.isAlive = true;
|
80
78
|
this.exitCallbacks = [];
|
@@ -118,11 +116,15 @@ class PseudoTtyProcess {
|
|
118
116
|
}
|
119
117
|
}
|
120
118
|
}
|
119
|
+
getParserAndWriter() {
|
120
|
+
return this.childProcess.getParserAndWriter();
|
121
|
+
}
|
121
122
|
}
|
122
123
|
exports.PseudoTtyProcess = PseudoTtyProcess;
|
123
124
|
class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
124
|
-
constructor(_childProcess, id, pseudoIpc) {
|
125
|
-
super(_childProcess);
|
125
|
+
constructor(rustPseudoTerminal, _childProcess, id, pseudoIpc) {
|
126
|
+
super(rustPseudoTerminal, _childProcess);
|
127
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
126
128
|
this.id = id;
|
127
129
|
this.pseudoIpc = pseudoIpc;
|
128
130
|
}
|
@@ -29,6 +29,7 @@ export declare function invokeTasksRunner({ tasks, projectGraph, taskGraph, life
|
|
29
29
|
}): Promise<{
|
30
30
|
[id: string]: TaskResult;
|
31
31
|
}>;
|
32
|
+
export declare function constructLifeCycles(lifeCycle: LifeCycle): LifeCycle[];
|
32
33
|
export declare function getRunner(nxArgs: NxArgs, nxJson: NxJsonConfiguration): {
|
33
34
|
tasksRunner: TasksRunner;
|
34
35
|
runnerOptions: any;
|