nx 21.0.0-beta.1 → 21.0.0-beta.11
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/migrations.json +15 -35
- package/package.json +12 -12
- package/release/index.d.ts +1 -1
- package/release/index.js +2 -1
- package/schemas/nx-schema.json +187 -35
- package/schemas/project-schema.json +5 -0
- package/src/adapter/angular-json.js +11 -0
- 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 +52 -38
- 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 +6 -2
- package/src/command-line/init/implementation/utils.js +110 -45
- 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 +70 -39
- package/src/command-line/migrate/migrate-ui-api.d.ts +58 -0
- package/src/command-line/migrate/migrate-ui-api.js +227 -0
- package/src/command-line/migrate/migrate.d.ts +23 -4
- package/src/command-line/migrate/migrate.js +138 -86
- 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 +8 -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 +139 -45
- 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 +252 -0
- package/src/command-line/release/version/release-group-processor.js +1057 -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 +93 -0
- package/src/command-line/release/version/test-utils.js +415 -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 +171 -0
- package/src/command-line/release/version/version-actions.js +195 -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 +84 -262
- package/src/command-line/repair/repair.js +8 -3
- 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/executor-utils.d.ts +6 -1
- package/src/command-line/run/executor-utils.js +10 -1
- package/src/command-line/run/run.js +2 -2
- 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/misc-interfaces.d.ts +20 -2
- package/src/config/nx-json.d.ts +158 -18
- 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-exports.d.ts +1 -1
- package/src/devkit-internals.d.ts +3 -2
- package/src/devkit-internals.js +5 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +2 -5
- package/src/executors/run-commands/run-commands.impl.js +14 -42
- package/src/executors/run-commands/running-tasks.d.ts +9 -4
- package/src/executors/run-commands/running-tasks.js +103 -30
- 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/migrations/update-21-0-0/release-version-config-changes.d.ts +2 -0
- package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
- package/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
- package/src/migrations/{update-18-0-0/disable-crystal-for-existing-workspaces.js → update-21-0-0/remove-legacy-cache.js} +10 -4
- package/src/native/index.d.ts +98 -19
- package/src/native/index.js +16 -2
- package/src/native/native-bindings.js +7 -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/index.d.ts +2 -1
- package/src/plugins/js/index.js +8 -1
- 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 +8 -6
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- 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 +4 -2
- 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/file-utils.d.ts +1 -10
- package/src/project-graph/file-utils.js +2 -77
- 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/loaded-nx-plugin.js +1 -5
- package/src/project-graph/plugins/public-api.d.ts +1 -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 +3 -3
- package/src/project-graph/utils/project-configuration-utils.js +54 -21
- 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 +4 -5
- package/src/tasks-runner/cache.d.ts +21 -8
- package/src/tasks-runner/cache.js +106 -38
- package/src/tasks-runner/create-task-graph.d.ts +0 -1
- package/src/tasks-runner/create-task-graph.js +11 -11
- package/src/tasks-runner/default-tasks-runner.js +5 -14
- package/src/tasks-runner/forked-process-task-runner.d.ts +8 -3
- package/src/tasks-runner/forked-process-task-runner.js +59 -46
- package/src/tasks-runner/init-tasks-runner.d.ts +15 -1
- package/src/tasks-runner/init-tasks-runner.js +62 -2
- package/src/tasks-runner/is-tui-enabled.d.ts +2 -0
- package/src/tasks-runner/is-tui-enabled.js +64 -0
- package/src/tasks-runner/life-cycle.d.ts +14 -3
- package/src/tasks-runner/life-cycle.js +37 -2
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.d.ts +2 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +15 -7
- package/src/tasks-runner/life-cycles/task-history-life-cycle.d.ts +5 -0
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +35 -5
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.d.ts +18 -0
- package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +230 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +11 -7
- package/src/tasks-runner/pseudo-terminal.js +47 -35
- package/src/tasks-runner/run-command.d.ts +4 -1
- package/src/tasks-runner/run-command.js +219 -63
- package/src/tasks-runner/running-tasks/node-child-process.js +4 -11
- package/src/tasks-runner/running-tasks/running-task.d.ts +3 -0
- package/src/tasks-runner/running-tasks/shared-running-task.d.ts +14 -0
- package/src/tasks-runner/running-tasks/shared-running-task.js +30 -0
- package/src/tasks-runner/task-env.d.ts +1 -4
- package/src/tasks-runner/task-env.js +2 -0
- package/src/tasks-runner/task-graph-utils.d.ts +3 -0
- package/src/tasks-runner/task-graph-utils.js +31 -2
- package/src/tasks-runner/task-orchestrator.d.ts +26 -10
- package/src/tasks-runner/task-orchestrator.js +221 -57
- package/src/tasks-runner/tasks-runner.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.d.ts +1 -0
- package/src/tasks-runner/tasks-schedule.js +9 -0
- package/src/tasks-runner/utils.d.ts +2 -2
- package/src/tasks-runner/utils.js +18 -12
- 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/git-utils.d.ts +1 -1
- package/src/utils/git-utils.js +8 -3
- 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-json.d.ts +1 -1
- package/src/utils/package-json.js +16 -2
- 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/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
- package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
- package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
- package/src/migrations/update-17-2-0/move-default-base.js +0 -21
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
- package/src/utils/powerpack.d.ts +0 -5
- package/src/utils/powerpack.js +0 -33
- /package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/remove-legacy-cache.d.ts} +0 -0
@@ -1,17 +1,28 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.initTasksRunner = initTasksRunner;
|
4
|
-
|
4
|
+
exports.runDiscreteTasks = runDiscreteTasks;
|
5
|
+
exports.runContinuousTasks = runContinuousTasks;
|
6
|
+
const nx_json_1 = require("../config/nx-json");
|
5
7
|
const project_graph_1 = require("../project-graph/project-graph");
|
6
8
|
const run_command_1 = require("./run-command");
|
7
9
|
const invoke_runner_terminal_output_life_cycle_1 = require("./life-cycles/invoke-runner-terminal-output-life-cycle");
|
8
10
|
const perf_hooks_1 = require("perf_hooks");
|
9
11
|
const utils_1 = require("./utils");
|
10
12
|
const dotenv_1 = require("../utils/dotenv");
|
13
|
+
const life_cycle_1 = require("./life-cycle");
|
14
|
+
const task_orchestrator_1 = require("./task-orchestrator");
|
15
|
+
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
16
|
+
const client_1 = require("../daemon/client/client");
|
17
|
+
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
18
|
+
/**
|
19
|
+
* This function is deprecated. Do not use this
|
20
|
+
* @deprecated This function is deprecated. Do not use this
|
21
|
+
*/
|
11
22
|
async function initTasksRunner(nxArgs) {
|
12
23
|
perf_hooks_1.performance.mark('init-local');
|
13
24
|
(0, dotenv_1.loadRootEnvFiles)();
|
14
|
-
const nxJson = (0,
|
25
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
15
26
|
if (nxArgs.verbose) {
|
16
27
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
17
28
|
}
|
@@ -50,6 +61,7 @@ async function initTasksRunner(nxArgs) {
|
|
50
61
|
nxArgs: { ...nxArgs, parallel: opts.parallel },
|
51
62
|
loadDotEnvFiles: true,
|
52
63
|
initiatingProject: null,
|
64
|
+
initiatingTasks: [],
|
53
65
|
});
|
54
66
|
return {
|
55
67
|
status: Object.values(taskResults).some((taskResult) => taskResult.status === 'failure' || taskResult.status === 'skipped')
|
@@ -61,3 +73,51 @@ async function initTasksRunner(nxArgs) {
|
|
61
73
|
},
|
62
74
|
};
|
63
75
|
}
|
76
|
+
async function createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
77
|
+
(0, dotenv_1.loadRootEnvFiles)();
|
78
|
+
const invokeRunnerTerminalLifecycle = new invoke_runner_terminal_output_life_cycle_1.InvokeRunnerTerminalOutputLifeCycle(tasks);
|
79
|
+
const taskResultsLifecycle = new task_results_life_cycle_1.TaskResultsLifeCycle();
|
80
|
+
const compositedLifeCycle = new life_cycle_1.CompositeLifeCycle([
|
81
|
+
...(0, run_command_1.constructLifeCycles)(invokeRunnerTerminalLifecycle),
|
82
|
+
taskResultsLifecycle,
|
83
|
+
lifeCycle,
|
84
|
+
]);
|
85
|
+
const { runnerOptions: options } = (0, run_command_1.getRunner)({}, nxJson);
|
86
|
+
let hasher = (0, create_task_hasher_1.createTaskHasher)(projectGraph, nxJson, options);
|
87
|
+
const taskGraph = {
|
88
|
+
roots: tasks.map((task) => task.id),
|
89
|
+
tasks: tasks.reduce((acc, task) => {
|
90
|
+
acc[task.id] = task;
|
91
|
+
return acc;
|
92
|
+
}, {}),
|
93
|
+
dependencies: tasks.reduce((acc, task) => {
|
94
|
+
acc[task.id] = [];
|
95
|
+
return acc;
|
96
|
+
}, {}),
|
97
|
+
continuousDependencies: tasks.reduce((acc, task) => {
|
98
|
+
acc[task.id] = [];
|
99
|
+
return acc;
|
100
|
+
}, {}),
|
101
|
+
};
|
102
|
+
const nxArgs = {
|
103
|
+
...options,
|
104
|
+
parallel: tasks.length,
|
105
|
+
lifeCycle: compositedLifeCycle,
|
106
|
+
};
|
107
|
+
(0, run_command_1.setEnvVarsBasedOnArgs)(nxArgs, true);
|
108
|
+
const orchestrator = new task_orchestrator_1.TaskOrchestrator(hasher, null, [], projectGraph, taskGraph, nxJson, nxArgs, false, client_1.daemonClient, undefined, taskGraphForHashing);
|
109
|
+
await orchestrator.init();
|
110
|
+
orchestrator.processTasks(tasks.map((task) => task.id));
|
111
|
+
return orchestrator;
|
112
|
+
}
|
113
|
+
async function runDiscreteTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
114
|
+
const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
|
115
|
+
return tasks.map((task, index) => orchestrator.applyFromCacheOrRunTask(true, task, index));
|
116
|
+
}
|
117
|
+
async function runContinuousTasks(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle) {
|
118
|
+
const orchestrator = await createOrchestrator(tasks, projectGraph, taskGraphForHashing, nxJson, lifeCycle);
|
119
|
+
return tasks.reduce((current, task, index) => {
|
120
|
+
current[task.id] = orchestrator.startContinuousTask(task, index);
|
121
|
+
return current;
|
122
|
+
}, {});
|
123
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isTuiEnabled = isTuiEnabled;
|
4
|
+
const devkit_internals_1 = require("../devkit-internals");
|
5
|
+
const is_ci_1 = require("../utils/is-ci");
|
6
|
+
let tuiEnabled = undefined;
|
7
|
+
function isTuiEnabled(nxJson, skipCapableCheck = false) {
|
8
|
+
if (tuiEnabled !== undefined) {
|
9
|
+
return tuiEnabled;
|
10
|
+
}
|
11
|
+
// If the current terminal/environment is not capable of displaying the TUI, we don't run it
|
12
|
+
const isWindows = process.platform === 'win32';
|
13
|
+
const isCapable = skipCapableCheck || (process.stderr.isTTY && isUnicodeSupported());
|
14
|
+
if (!isCapable) {
|
15
|
+
tuiEnabled = false;
|
16
|
+
process.env.NX_TUI = 'false';
|
17
|
+
return tuiEnabled;
|
18
|
+
}
|
19
|
+
// The environment variable takes precedence over the nx.json config
|
20
|
+
if (typeof process.env.NX_TUI === 'string') {
|
21
|
+
tuiEnabled = process.env.NX_TUI === 'true';
|
22
|
+
return tuiEnabled;
|
23
|
+
}
|
24
|
+
// Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
|
25
|
+
// TODO(@JamesHenry): Remove this check once Windows issues are fixed.
|
26
|
+
if ((0, is_ci_1.isCI)() || isWindows) {
|
27
|
+
tuiEnabled = false;
|
28
|
+
process.env.NX_TUI = 'false';
|
29
|
+
return tuiEnabled;
|
30
|
+
}
|
31
|
+
// Only read from disk if nx.json config is not already provided (and we have not been able to determine tuiEnabled based on the above checks)
|
32
|
+
if (!nxJson) {
|
33
|
+
nxJson = (0, devkit_internals_1.readNxJsonFromDisk)();
|
34
|
+
}
|
35
|
+
// Respect user config
|
36
|
+
if (typeof nxJson.tui?.enabled === 'boolean') {
|
37
|
+
tuiEnabled = Boolean(nxJson.tui?.enabled);
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
// Default to enabling the TUI if the system is capable of displaying it
|
41
|
+
tuiEnabled = true;
|
42
|
+
}
|
43
|
+
// Also set the environment variable for consistency and ease of checking on the rust side, for example
|
44
|
+
process.env.NX_TUI = tuiEnabled.toString();
|
45
|
+
return tuiEnabled;
|
46
|
+
}
|
47
|
+
// Credit to https://github.com/sindresorhus/is-unicode-supported/blob/e0373335038856c63034c8eef6ac43ee3827a601/index.js
|
48
|
+
function isUnicodeSupported() {
|
49
|
+
const { env } = process;
|
50
|
+
const { TERM, TERM_PROGRAM } = env;
|
51
|
+
if (process.platform !== 'win32') {
|
52
|
+
return TERM !== 'linux'; // Linux console (kernel)
|
53
|
+
}
|
54
|
+
return (Boolean(env.WT_SESSION) || // Windows Terminal
|
55
|
+
Boolean(env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
|
56
|
+
env.ConEmuTask === '{cmd::Cmder}' || // ConEmu and cmder
|
57
|
+
TERM_PROGRAM === 'Terminus-Sublime' ||
|
58
|
+
TERM_PROGRAM === 'vscode' ||
|
59
|
+
TERM === 'xterm-256color' ||
|
60
|
+
TERM === 'alacritty' ||
|
61
|
+
TERM === 'rxvt-unicode' ||
|
62
|
+
TERM === 'rxvt-unicode-256color' ||
|
63
|
+
env.TERMINAL_EMULATOR === 'JetBrains-JediTerm');
|
64
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { TaskStatus } from './tasks-runner';
|
2
1
|
import { Task } from '../config/task-graph';
|
2
|
+
import { ExternalObject, TaskStatus as NativeTaskStatus } from '../native';
|
3
|
+
import { TaskStatus } from './tasks-runner';
|
3
4
|
/**
|
4
5
|
* The result of a completed {@link Task}
|
5
6
|
*/
|
@@ -17,7 +18,7 @@ export interface TaskMetadata {
|
|
17
18
|
groupId: number;
|
18
19
|
}
|
19
20
|
export interface LifeCycle {
|
20
|
-
startCommand?(): void | Promise<void>;
|
21
|
+
startCommand?(parallel?: number): void | Promise<void>;
|
21
22
|
endCommand?(): void | Promise<void>;
|
22
23
|
scheduleTask?(task: Task): void | Promise<void>;
|
23
24
|
/**
|
@@ -35,11 +36,16 @@ export interface LifeCycle {
|
|
35
36
|
startTasks?(task: Task[], metadata: TaskMetadata): void | Promise<void>;
|
36
37
|
endTasks?(taskResults: TaskResult[], metadata: TaskMetadata): void | Promise<void>;
|
37
38
|
printTaskTerminalOutput?(task: Task, status: TaskStatus, output: string): void;
|
39
|
+
registerRunningTask?(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
40
|
+
registerRunningTaskWithEmptyParser?(taskId: string): void;
|
41
|
+
appendTaskOutput?(taskId: string, output: string): void;
|
42
|
+
setTaskStatus?(taskId: string, status: NativeTaskStatus): void;
|
43
|
+
registerForcedShutdownCallback?(callback: () => void): void;
|
38
44
|
}
|
39
45
|
export declare class CompositeLifeCycle implements LifeCycle {
|
40
46
|
private readonly lifeCycles;
|
41
47
|
constructor(lifeCycles: LifeCycle[]);
|
42
|
-
startCommand(): Promise<void>;
|
48
|
+
startCommand(parallel?: number): Promise<void>;
|
43
49
|
endCommand(): Promise<void>;
|
44
50
|
scheduleTask(task: Task): Promise<void>;
|
45
51
|
startTask(task: Task): void;
|
@@ -47,4 +53,9 @@ export declare class CompositeLifeCycle implements LifeCycle {
|
|
47
53
|
startTasks(tasks: Task[], metadata: TaskMetadata): Promise<void>;
|
48
54
|
endTasks(taskResults: TaskResult[], metadata: TaskMetadata): Promise<void>;
|
49
55
|
printTaskTerminalOutput(task: Task, status: TaskStatus, output: string): void;
|
56
|
+
registerRunningTask(taskId: string, parserAndWriter: ExternalObject<[any, any]>): void;
|
57
|
+
registerRunningTaskWithEmptyParser(taskId: string): void;
|
58
|
+
appendTaskOutput(taskId: string, output: string): void;
|
59
|
+
setTaskStatus(taskId: string, status: NativeTaskStatus): void;
|
60
|
+
registerForcedShutdownCallback(callback: () => void): void;
|
50
61
|
}
|
@@ -5,10 +5,10 @@ class CompositeLifeCycle {
|
|
5
5
|
constructor(lifeCycles) {
|
6
6
|
this.lifeCycles = lifeCycles;
|
7
7
|
}
|
8
|
-
async startCommand() {
|
8
|
+
async startCommand(parallel) {
|
9
9
|
for (let l of this.lifeCycles) {
|
10
10
|
if (l.startCommand) {
|
11
|
-
await l.startCommand();
|
11
|
+
await l.startCommand(parallel);
|
12
12
|
}
|
13
13
|
}
|
14
14
|
}
|
@@ -67,5 +67,40 @@ class CompositeLifeCycle {
|
|
67
67
|
}
|
68
68
|
}
|
69
69
|
}
|
70
|
+
registerRunningTask(taskId, parserAndWriter) {
|
71
|
+
for (let l of this.lifeCycles) {
|
72
|
+
if (l.registerRunningTask) {
|
73
|
+
l.registerRunningTask(taskId, parserAndWriter);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
}
|
77
|
+
registerRunningTaskWithEmptyParser(taskId) {
|
78
|
+
for (let l of this.lifeCycles) {
|
79
|
+
if (l.registerRunningTaskWithEmptyParser) {
|
80
|
+
l.registerRunningTaskWithEmptyParser(taskId);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
appendTaskOutput(taskId, output) {
|
85
|
+
for (let l of this.lifeCycles) {
|
86
|
+
if (l.appendTaskOutput) {
|
87
|
+
l.appendTaskOutput(taskId, output);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
setTaskStatus(taskId, status) {
|
92
|
+
for (let l of this.lifeCycles) {
|
93
|
+
if (l.setTaskStatus) {
|
94
|
+
l.setTaskStatus(taskId, status);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
registerForcedShutdownCallback(callback) {
|
99
|
+
for (let l of this.lifeCycles) {
|
100
|
+
if (l.registerForcedShutdownCallback) {
|
101
|
+
l.registerForcedShutdownCallback(callback);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
70
105
|
}
|
71
106
|
exports.CompositeLifeCycle = CompositeLifeCycle;
|
@@ -3,7 +3,9 @@ import { LifeCycle, TaskResult } from '../life-cycle';
|
|
3
3
|
export declare class LegacyTaskHistoryLifeCycle implements LifeCycle {
|
4
4
|
private startTimings;
|
5
5
|
private taskRuns;
|
6
|
+
private flakyTasks;
|
6
7
|
startTasks(tasks: Task[]): void;
|
7
8
|
endTasks(taskResults: TaskResult[]): Promise<void>;
|
8
9
|
endCommand(): Promise<void>;
|
10
|
+
printFlakyTasksMessage(): void;
|
9
11
|
}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.LegacyTaskHistoryLifeCycle = void 0;
|
4
|
-
const serialize_target_1 = require("../../utils/serialize-target");
|
5
|
-
const output_1 = require("../../utils/output");
|
6
4
|
const legacy_task_history_1 = require("../../utils/legacy-task-history");
|
5
|
+
const output_1 = require("../../utils/output");
|
6
|
+
const serialize_target_1 = require("../../utils/serialize-target");
|
7
|
+
const is_tui_enabled_1 = require("../is-tui-enabled");
|
7
8
|
class LegacyTaskHistoryLifeCycle {
|
8
9
|
constructor() {
|
9
10
|
this.startTimings = {};
|
@@ -30,20 +31,27 @@ class LegacyTaskHistoryLifeCycle {
|
|
30
31
|
async endCommand() {
|
31
32
|
await (0, legacy_task_history_1.writeTaskRunsToHistory)(this.taskRuns);
|
32
33
|
const history = await (0, legacy_task_history_1.getHistoryForHashes)(this.taskRuns.map((t) => t.hash));
|
33
|
-
|
34
|
+
this.flakyTasks = [];
|
34
35
|
// check if any hash has different exit codes => flaky
|
35
36
|
for (let hash in history) {
|
36
37
|
if (history[hash].length > 1 &&
|
37
38
|
history[hash].some((run) => run.code !== history[hash][0].code)) {
|
38
|
-
flakyTasks.push((0, serialize_target_1.serializeTarget)(history[hash][0].project, history[hash][0].target, history[hash][0].configuration));
|
39
|
+
this.flakyTasks.push((0, serialize_target_1.serializeTarget)(history[hash][0].project, history[hash][0].target, history[hash][0].configuration));
|
39
40
|
}
|
40
41
|
}
|
41
|
-
|
42
|
+
// Do not directly print output when using the TUI
|
43
|
+
if ((0, is_tui_enabled_1.isTuiEnabled)()) {
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
this.printFlakyTasksMessage();
|
47
|
+
}
|
48
|
+
printFlakyTasksMessage() {
|
49
|
+
if (this.flakyTasks.length > 0) {
|
42
50
|
output_1.output.warn({
|
43
|
-
title: `Nx detected ${flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
51
|
+
title: `Nx detected ${this.flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
44
52
|
bodyLines: [
|
45
53
|
,
|
46
|
-
...flakyTasks.map((t) => ` ${t}`),
|
54
|
+
...this.flakyTasks.map((t) => ` ${t}`),
|
47
55
|
'',
|
48
56
|
`Flaky tasks can disrupt your CI pipeline. Automatically retry them with Nx Cloud. Learn more at https://nx.dev/ci/features/flaky-tasks`,
|
49
57
|
],
|
@@ -1,10 +1,15 @@
|
|
1
1
|
import { Task } from '../../config/task-graph';
|
2
2
|
import { LifeCycle, TaskResult } from '../life-cycle';
|
3
|
+
import { LegacyTaskHistoryLifeCycle } from './task-history-life-cycle-old';
|
4
|
+
export declare function getTasksHistoryLifeCycle(): TaskHistoryLifeCycle | LegacyTaskHistoryLifeCycle | null;
|
3
5
|
export declare class TaskHistoryLifeCycle implements LifeCycle {
|
4
6
|
private startTimings;
|
5
7
|
private taskRuns;
|
6
8
|
private taskHistory;
|
9
|
+
private flakyTasks;
|
10
|
+
constructor();
|
7
11
|
startTasks(tasks: Task[]): void;
|
8
12
|
endTasks(taskResults: TaskResult[]): Promise<void>;
|
9
13
|
endCommand(): Promise<void>;
|
14
|
+
printFlakyTasksMessage(): void;
|
10
15
|
}
|
@@ -1,14 +1,37 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.TaskHistoryLifeCycle = void 0;
|
4
|
-
|
4
|
+
exports.getTasksHistoryLifeCycle = getTasksHistoryLifeCycle;
|
5
|
+
const native_1 = require("../../native");
|
5
6
|
const output_1 = require("../../utils/output");
|
7
|
+
const serialize_target_1 = require("../../utils/serialize-target");
|
6
8
|
const task_history_1 = require("../../utils/task-history");
|
9
|
+
const is_tui_enabled_1 = require("../is-tui-enabled");
|
10
|
+
const task_history_life_cycle_old_1 = require("./task-history-life-cycle-old");
|
11
|
+
const nx_cloud_utils_1 = require("../../utils/nx-cloud-utils");
|
12
|
+
const nx_json_1 = require("../../config/nx-json");
|
13
|
+
let tasksHistoryLifeCycle;
|
14
|
+
function getTasksHistoryLifeCycle() {
|
15
|
+
if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
|
16
|
+
if (!tasksHistoryLifeCycle) {
|
17
|
+
tasksHistoryLifeCycle =
|
18
|
+
process.env.NX_DISABLE_DB !== 'true' && !native_1.IS_WASM
|
19
|
+
? new TaskHistoryLifeCycle()
|
20
|
+
: new task_history_life_cycle_old_1.LegacyTaskHistoryLifeCycle();
|
21
|
+
}
|
22
|
+
return tasksHistoryLifeCycle;
|
23
|
+
}
|
24
|
+
return null;
|
25
|
+
}
|
7
26
|
class TaskHistoryLifeCycle {
|
8
27
|
constructor() {
|
9
28
|
this.startTimings = {};
|
10
29
|
this.taskRuns = new Map();
|
11
30
|
this.taskHistory = (0, task_history_1.getTaskHistory)();
|
31
|
+
if (tasksHistoryLifeCycle) {
|
32
|
+
throw new Error('TaskHistoryLifeCycle is a singleton and should not be instantiated multiple times');
|
33
|
+
}
|
34
|
+
tasksHistoryLifeCycle = this;
|
12
35
|
}
|
13
36
|
startTasks(tasks) {
|
14
37
|
for (let task of tasks) {
|
@@ -35,13 +58,20 @@ class TaskHistoryLifeCycle {
|
|
35
58
|
return;
|
36
59
|
}
|
37
60
|
await this.taskHistory.recordTaskRuns(entries.map(([_, v]) => v));
|
38
|
-
|
39
|
-
|
61
|
+
this.flakyTasks = await this.taskHistory.getFlakyTasks(entries.map(([hash]) => hash));
|
62
|
+
// Do not directly print output when using the TUI
|
63
|
+
if ((0, is_tui_enabled_1.isTuiEnabled)()) {
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
this.printFlakyTasksMessage();
|
67
|
+
}
|
68
|
+
printFlakyTasksMessage() {
|
69
|
+
if (this.flakyTasks.length > 0) {
|
40
70
|
output_1.output.warn({
|
41
|
-
title: `Nx detected ${flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
71
|
+
title: `Nx detected ${this.flakyTasks.length === 1 ? 'a flaky task' : ' flaky tasks'}`,
|
42
72
|
bodyLines: [
|
43
73
|
,
|
44
|
-
...flakyTasks.map((hash) => {
|
74
|
+
...this.flakyTasks.map((hash) => {
|
45
75
|
const taskRun = this.taskRuns.get(hash);
|
46
76
|
return ` ${(0, serialize_target_1.serializeTarget)(taskRun.target.project, taskRun.target.target, taskRun.target.configuration)}`;
|
47
77
|
}),
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { Task } from '../../config/task-graph';
|
2
|
+
import type { LifeCycle } from '../life-cycle';
|
3
|
+
export declare function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides, initiatingProject, initiatingTasks, resolveRenderIsDonePromise, }: {
|
4
|
+
projectNames: string[];
|
5
|
+
tasks: Task[];
|
6
|
+
args: {
|
7
|
+
targets?: string[];
|
8
|
+
configuration?: string;
|
9
|
+
parallel?: number;
|
10
|
+
};
|
11
|
+
overrides: Record<string, unknown>;
|
12
|
+
initiatingProject: string;
|
13
|
+
initiatingTasks: Task[];
|
14
|
+
resolveRenderIsDonePromise: (value: void) => void;
|
15
|
+
}): {
|
16
|
+
lifeCycle: Partial<LifeCycle>;
|
17
|
+
printSummary: () => void;
|
18
|
+
};
|
@@ -0,0 +1,230 @@
|
|
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 task_history_life_cycle_1 = require("./task-history-life-cycle");
|
11
|
+
const LEFT_PAD = ` `;
|
12
|
+
const SPACER = ` `;
|
13
|
+
const EXTENDED_LEFT_PAD = ` `;
|
14
|
+
function getTuiTerminalSummaryLifeCycle({ projectNames, tasks, args, overrides, initiatingProject, initiatingTasks, resolveRenderIsDonePromise, }) {
|
15
|
+
const lifeCycle = {};
|
16
|
+
const start = process.hrtime();
|
17
|
+
const targets = args.targets;
|
18
|
+
const totalTasks = tasks.length;
|
19
|
+
let totalCachedTasks = 0;
|
20
|
+
let totalSuccessfulTasks = 0;
|
21
|
+
let totalFailedTasks = 0;
|
22
|
+
let totalCompletedTasks = 0;
|
23
|
+
let timeTakenText;
|
24
|
+
const failedTasks = new Set();
|
25
|
+
const inProgressTasks = new Set();
|
26
|
+
const stoppedTasks = new Set();
|
27
|
+
const tasksToTerminalOutputs = {};
|
28
|
+
const taskIdsInOrderOfCompletion = [];
|
29
|
+
lifeCycle.startTasks = (tasks) => {
|
30
|
+
for (let t of tasks) {
|
31
|
+
inProgressTasks.add(t.id);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
lifeCycle.printTaskTerminalOutput = (task, taskStatus, terminalOutput) => {
|
35
|
+
taskIdsInOrderOfCompletion.push(task.id);
|
36
|
+
tasksToTerminalOutputs[task.id] = { terminalOutput, taskStatus };
|
37
|
+
};
|
38
|
+
lifeCycle.setTaskStatus = (taskId, taskStatus) => {
|
39
|
+
if (taskStatus === 9 /* NativeTaskStatus.Stopped */) {
|
40
|
+
stoppedTasks.add(taskId);
|
41
|
+
inProgressTasks.delete(taskId);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
lifeCycle.endTasks = (taskResults) => {
|
45
|
+
for (const { task, status } of taskResults) {
|
46
|
+
totalCompletedTasks++;
|
47
|
+
inProgressTasks.delete(task.id);
|
48
|
+
switch (status) {
|
49
|
+
case 'remote-cache':
|
50
|
+
case 'local-cache':
|
51
|
+
case 'local-cache-kept-existing':
|
52
|
+
totalCachedTasks++;
|
53
|
+
totalSuccessfulTasks++;
|
54
|
+
break;
|
55
|
+
case 'success':
|
56
|
+
totalSuccessfulTasks++;
|
57
|
+
break;
|
58
|
+
case 'failure':
|
59
|
+
totalFailedTasks++;
|
60
|
+
failedTasks.add(task.id);
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
};
|
65
|
+
lifeCycle.endCommand = () => {
|
66
|
+
timeTakenText = (0, pretty_time_1.prettyTime)(process.hrtime(start));
|
67
|
+
resolveRenderIsDonePromise();
|
68
|
+
};
|
69
|
+
const printSummary = () => {
|
70
|
+
const isRunOne = initiatingProject && targets?.length === 1;
|
71
|
+
// Handles when the user interrupts the process
|
72
|
+
timeTakenText ??= (0, pretty_time_1.prettyTime)(process.hrtime(start));
|
73
|
+
if (totalTasks === 0) {
|
74
|
+
console.log(`\n${output_1.output.applyNxPrefix('gray', 'No tasks were run')}\n`);
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
if (isRunOne) {
|
78
|
+
printRunOneSummary();
|
79
|
+
}
|
80
|
+
else {
|
81
|
+
printRunManySummary();
|
82
|
+
}
|
83
|
+
(0, task_history_life_cycle_1.getTasksHistoryLifeCycle)()?.printFlakyTasksMessage();
|
84
|
+
};
|
85
|
+
const printRunOneSummary = () => {
|
86
|
+
let lines = [];
|
87
|
+
const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;
|
88
|
+
// Prints task outputs in the order they were completed
|
89
|
+
// above the summary, since run-one should print all task results.
|
90
|
+
for (const taskId of taskIdsInOrderOfCompletion) {
|
91
|
+
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
|
92
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
93
|
+
}
|
94
|
+
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
95
|
+
if (!failure) {
|
96
|
+
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)([initiatingProject], targets, tasks)}`;
|
97
|
+
const taskOverridesLines = [];
|
98
|
+
if (Object.keys(overrides).length > 0) {
|
99
|
+
taskOverridesLines.push('');
|
100
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
101
|
+
Object.entries(overrides)
|
102
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
103
|
+
.forEach((arg) => taskOverridesLines.push(arg));
|
104
|
+
}
|
105
|
+
lines.push(output_1.output.applyNxPrefix('green', output_1.output.colors.green(text) + output_1.output.dim(` (${timeTakenText})`)), ...taskOverridesLines);
|
106
|
+
if (totalCachedTasks > 0) {
|
107
|
+
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.`));
|
108
|
+
}
|
109
|
+
lines = [output_1.output.colors.green(lines.join(node_os_1.EOL))];
|
110
|
+
}
|
111
|
+
else if (totalCompletedTasks + stoppedTasks.size === totalTasks) {
|
112
|
+
let text = `Ran target ${output_1.output.bold(targets[0])} for project ${output_1.output.bold(initiatingProject)}`;
|
113
|
+
if (tasks.length > 1) {
|
114
|
+
text += ` and ${output_1.output.bold(tasks.length - 1)} task(s) they depend on`;
|
115
|
+
}
|
116
|
+
const taskOverridesLines = [];
|
117
|
+
if (Object.keys(overrides).length > 0) {
|
118
|
+
taskOverridesLines.push('');
|
119
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
120
|
+
Object.entries(overrides)
|
121
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
122
|
+
.forEach((arg) => taskOverridesLines.push(arg));
|
123
|
+
}
|
124
|
+
const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
|
125
|
+
lines = [
|
126
|
+
output_1.output.colors.red([
|
127
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
|
128
|
+
...taskOverridesLines,
|
129
|
+
'',
|
130
|
+
`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
|
131
|
+
`${LEFT_PAD}${output_1.output.dim(figures.tick)}${SPACER}${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
|
132
|
+
...viewLogs,
|
133
|
+
].join(node_os_1.EOL)),
|
134
|
+
];
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
lines = [
|
138
|
+
...output_1.output.getVerticalSeparatorLines('red'),
|
139
|
+
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})`)),
|
140
|
+
];
|
141
|
+
}
|
142
|
+
// adds some vertical space after the summary to avoid bunching against terminal
|
143
|
+
lines.push('');
|
144
|
+
console.log(lines.join(node_os_1.EOL));
|
145
|
+
};
|
146
|
+
const printRunManySummary = () => {
|
147
|
+
console.log('');
|
148
|
+
const lines = [];
|
149
|
+
const failure = totalSuccessfulTasks + stoppedTasks.size !== totalTasks;
|
150
|
+
for (const taskId of taskIdsInOrderOfCompletion) {
|
151
|
+
const { terminalOutput, taskStatus } = tasksToTerminalOutputs[taskId];
|
152
|
+
if (taskStatus === 'failure') {
|
153
|
+
output_1.output.logCommandOutput(taskId, taskStatus, terminalOutput);
|
154
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
lines.push(`${LEFT_PAD}${output_1.output.colors.green(figures.tick)}${SPACER}${output_1.output.colors.gray('nx run ')}${taskId}`);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
lines.push(...output_1.output.getVerticalSeparatorLines(failure ? 'red' : 'green'));
|
161
|
+
if (totalSuccessfulTasks + stoppedTasks.size === totalTasks) {
|
162
|
+
const successSummaryRows = [];
|
163
|
+
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
164
|
+
const taskOverridesRows = [];
|
165
|
+
if (Object.keys(overrides).length > 0) {
|
166
|
+
taskOverridesRows.push('');
|
167
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
168
|
+
Object.entries(overrides)
|
169
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
170
|
+
.forEach((arg) => taskOverridesRows.push(arg));
|
171
|
+
}
|
172
|
+
successSummaryRows.push(...[
|
173
|
+
output_1.output.applyNxPrefix('green', output_1.output.colors.green(text) + output_1.output.dim.white(` (${timeTakenText})`)),
|
174
|
+
...taskOverridesRows,
|
175
|
+
]);
|
176
|
+
if (totalCachedTasks > 0) {
|
177
|
+
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.`));
|
178
|
+
}
|
179
|
+
lines.push(successSummaryRows.join(node_os_1.EOL));
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
const text = `${inProgressTasks.size ? 'Cancelled while running' : 'Ran'} ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
183
|
+
const taskOverridesRows = [];
|
184
|
+
if (Object.keys(overrides).length > 0) {
|
185
|
+
taskOverridesRows.push('');
|
186
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
187
|
+
Object.entries(overrides)
|
188
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
189
|
+
.forEach((arg) => taskOverridesRows.push(arg));
|
190
|
+
}
|
191
|
+
const numFailedToPrint = 5;
|
192
|
+
const failedTasksForPrinting = Array.from(failedTasks).slice(0, numFailedToPrint);
|
193
|
+
const failureSummaryRows = [
|
194
|
+
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim.white(` (${timeTakenText})`)),
|
195
|
+
...taskOverridesRows,
|
196
|
+
'',
|
197
|
+
];
|
198
|
+
if (totalCompletedTasks > 0) {
|
199
|
+
if (totalSuccessfulTasks > 0) {
|
200
|
+
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]`)}`), '');
|
201
|
+
}
|
202
|
+
if (totalFailedTasks > 0) {
|
203
|
+
failureSummaryRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)}${SPACER}${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`, '', `${failedTasksForPrinting
|
204
|
+
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
205
|
+
.join('\n')}`, '');
|
206
|
+
if (failedTasks.size > numFailedToPrint) {
|
207
|
+
failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
|
208
|
+
}
|
209
|
+
}
|
210
|
+
if (totalCompletedTasks !== totalTasks) {
|
211
|
+
const remainingTasks = totalTasks - totalCompletedTasks;
|
212
|
+
if (inProgressTasks.size) {
|
213
|
+
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)
|
214
|
+
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
215
|
+
.join(node_os_1.EOL)}`, '');
|
216
|
+
}
|
217
|
+
if (remainingTasks - inProgressTasks.size > 0) {
|
218
|
+
failureSummaryRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.colors.red(figures.ellipsis)}${SPACER}${remainingTasks - inProgressTasks.size}${`/${totalTasks}`} targets had not started.`), '');
|
219
|
+
}
|
220
|
+
}
|
221
|
+
failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
|
222
|
+
lines.push(output_1.output.colors.red(failureSummaryRows.join(node_os_1.EOL)));
|
223
|
+
}
|
224
|
+
}
|
225
|
+
// adds some vertical space after the summary to avoid bunching against terminal
|
226
|
+
lines.push('');
|
227
|
+
console.log(lines.join(node_os_1.EOL));
|
228
|
+
};
|
229
|
+
return { lifeCycle, printSummary };
|
230
|
+
}
|