nx 21.0.0-beta.1 → 21.0.0-beta.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/.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 +3 -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/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.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 +6 -3
- package/src/tasks-runner/forked-process-task-runner.js +29 -28
- 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 +126 -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
@@ -3,25 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCommand = runCommand;
|
4
4
|
exports.runCommandForTasks = runCommandForTasks;
|
5
5
|
exports.invokeTasksRunner = invokeTasksRunner;
|
6
|
+
exports.constructLifeCycles = constructLifeCycles;
|
6
7
|
exports.getRunner = getRunner;
|
7
8
|
exports.getRunnerOptions = getRunnerOptions;
|
8
9
|
const enquirer_1 = require("enquirer");
|
10
|
+
const node_path_1 = require("node:path");
|
11
|
+
const node_util_1 = require("node:util");
|
9
12
|
const ora = require("ora");
|
10
|
-
const path_1 = require("path");
|
11
13
|
const nx_json_1 = require("../config/nx-json");
|
12
14
|
const client_1 = require("../daemon/client/client");
|
13
15
|
const create_task_hasher_1 = require("../hasher/create-task-hasher");
|
14
16
|
const hash_task_1 = require("../hasher/hash-task");
|
15
17
|
const native_1 = require("../native");
|
18
|
+
const tasks_execution_hooks_1 = require("../project-graph/plugins/tasks-execution-hooks");
|
16
19
|
const project_graph_1 = require("../project-graph/project-graph");
|
17
20
|
const fileutils_1 = require("../utils/fileutils");
|
21
|
+
const handle_errors_1 = require("../utils/handle-errors");
|
18
22
|
const is_ci_1 = require("../utils/is-ci");
|
19
23
|
const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
|
24
|
+
const nx_key_1 = require("../utils/nx-key");
|
20
25
|
const output_1 = require("../utils/output");
|
21
|
-
const handle_errors_1 = require("../utils/handle-errors");
|
22
26
|
const sync_generators_1 = require("../utils/sync-generators");
|
23
27
|
const workspace_root_1 = require("../utils/workspace-root");
|
24
28
|
const create_task_graph_1 = require("./create-task-graph");
|
29
|
+
const is_tui_enabled_1 = require("./is-tui-enabled");
|
25
30
|
const life_cycle_1 = require("./life-cycle");
|
26
31
|
const dynamic_run_many_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-many-terminal-output-life-cycle");
|
27
32
|
const dynamic_run_one_terminal_output_life_cycle_1 = require("./life-cycles/dynamic-run-one-terminal-output-life-cycle");
|
@@ -31,19 +36,172 @@ const store_run_information_life_cycle_1 = require("./life-cycles/store-run-info
|
|
31
36
|
const task_history_life_cycle_1 = require("./life-cycles/task-history-life-cycle");
|
32
37
|
const task_history_life_cycle_old_1 = require("./life-cycles/task-history-life-cycle-old");
|
33
38
|
const task_profiling_life_cycle_1 = require("./life-cycles/task-profiling-life-cycle");
|
34
|
-
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
35
39
|
const task_results_life_cycle_1 = require("./life-cycles/task-results-life-cycle");
|
40
|
+
const task_timings_life_cycle_1 = require("./life-cycles/task-timings-life-cycle");
|
41
|
+
const tui_summary_life_cycle_1 = require("./life-cycles/tui-summary-life-cycle");
|
36
42
|
const task_graph_utils_1 = require("./task-graph-utils");
|
37
43
|
const utils_1 = require("./utils");
|
38
44
|
const chalk = require("chalk");
|
39
|
-
const
|
40
|
-
const
|
41
|
-
|
45
|
+
const originalStdoutWrite = process.stdout.write.bind(process.stdout);
|
46
|
+
const originalStderrWrite = process.stderr.write.bind(process.stderr);
|
47
|
+
const originalConsoleLog = console.log.bind(console);
|
48
|
+
const originalConsoleError = console.error.bind(console);
|
49
|
+
async function getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides) {
|
50
|
+
const overridesWithoutHidden = { ...overrides };
|
51
|
+
delete overridesWithoutHidden['__overrides_unparsed__'];
|
52
|
+
if ((0, is_tui_enabled_1.isTuiEnabled)(nxJson)) {
|
53
|
+
const interceptedNxCloudLogs = [];
|
54
|
+
const createPatchedConsoleMethod = (originalMethod) => {
|
55
|
+
return (...args) => {
|
56
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
57
|
+
const stackTrace = new Error().stack;
|
58
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
59
|
+
if (!isNxCloudLog) {
|
60
|
+
return originalMethod(...args);
|
61
|
+
}
|
62
|
+
// No-op the Nx Cloud client logs
|
63
|
+
};
|
64
|
+
};
|
65
|
+
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
66
|
+
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
67
|
+
console.error = createPatchedConsoleMethod(originalConsoleError);
|
68
|
+
const patchedWrite = (_chunk, _encoding, callback) => {
|
69
|
+
// Preserve original behavior around callback and return value, just in case
|
70
|
+
if (callback) {
|
71
|
+
callback();
|
72
|
+
}
|
73
|
+
return true;
|
74
|
+
};
|
75
|
+
process.stdout.write = patchedWrite;
|
76
|
+
process.stderr.write = patchedWrite;
|
77
|
+
const { AppLifeCycle, restoreTerminal } = await Promise.resolve().then(() => require('../native'));
|
78
|
+
let appLifeCycle;
|
79
|
+
const isRunOne = initiatingProject != null;
|
80
|
+
const pinnedTasks = [];
|
81
|
+
const taskText = tasks.length === 1 ? 'task' : 'tasks';
|
82
|
+
const projectText = projectNames.length === 1 ? 'project' : 'projects';
|
83
|
+
let titleText = '';
|
84
|
+
if (isRunOne) {
|
85
|
+
const mainTaskId = (0, create_task_graph_1.createTaskId)(initiatingProject, nxArgs.targets[0], nxArgs.configuration);
|
86
|
+
pinnedTasks.push(mainTaskId);
|
87
|
+
const mainContinuousDependencies = taskGraph.continuousDependencies[mainTaskId];
|
88
|
+
if (mainContinuousDependencies.length > 0) {
|
89
|
+
pinnedTasks.push(mainContinuousDependencies[0]);
|
90
|
+
}
|
91
|
+
const [project, target] = mainTaskId.split(':');
|
92
|
+
titleText = `${target} ${project}`;
|
93
|
+
if (tasks.length > 1) {
|
94
|
+
titleText += `, and ${tasks.length - 1} requisite ${taskText}`;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
titleText =
|
99
|
+
nxArgs.targets.join(', ') +
|
100
|
+
` for ${projectNames.length} ${projectText}`;
|
101
|
+
if (tasks.length > projectNames.length) {
|
102
|
+
titleText += `, and ${tasks.length - projectNames.length} requisite ${taskText}`;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
let resolveRenderIsDonePromise;
|
106
|
+
// Default renderIsDone that will be overridden if the TUI is used
|
107
|
+
let renderIsDone = new Promise((resolve) => (resolveRenderIsDonePromise = resolve));
|
108
|
+
const { lifeCycle: tsLifeCycle, printSummary } = (0, tui_summary_life_cycle_1.getTuiTerminalSummaryLifeCycle)({
|
109
|
+
projectNames,
|
110
|
+
tasks,
|
111
|
+
args: nxArgs,
|
112
|
+
overrides: overridesWithoutHidden,
|
113
|
+
initiatingProject,
|
114
|
+
resolveRenderIsDonePromise,
|
115
|
+
});
|
116
|
+
if (tasks.length === 0) {
|
117
|
+
renderIsDone = renderIsDone.then(() => {
|
118
|
+
// Revert the patched methods
|
119
|
+
process.stdout.write = originalStdoutWrite;
|
120
|
+
process.stderr.write = originalStderrWrite;
|
121
|
+
console.log = originalConsoleLog;
|
122
|
+
console.error = originalConsoleError;
|
123
|
+
printSummary();
|
124
|
+
});
|
125
|
+
}
|
126
|
+
const lifeCycles = [tsLifeCycle];
|
127
|
+
// Only run the TUI if there are tasks to run
|
128
|
+
if (tasks.length > 0) {
|
129
|
+
appLifeCycle = new AppLifeCycle(tasks, pinnedTasks, nxArgs ?? {}, nxJson.tui ?? {}, titleText);
|
130
|
+
lifeCycles.unshift(appLifeCycle);
|
131
|
+
/**
|
132
|
+
* Patch stdout.write and stderr.write methods to pass Nx Cloud client logs to the TUI via the lifecycle
|
133
|
+
*/
|
134
|
+
const createPatchedLogWrite = (originalWrite) => {
|
135
|
+
// @ts-ignore
|
136
|
+
return (chunk, encoding, callback) => {
|
137
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
138
|
+
const stackTrace = new Error().stack;
|
139
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
140
|
+
if (isNxCloudLog) {
|
141
|
+
interceptedNxCloudLogs.push(chunk);
|
142
|
+
// Do not bother to store logs with only whitespace characters, they aren't relevant for the TUI
|
143
|
+
const trimmedChunk = chunk.toString().trim();
|
144
|
+
if (trimmedChunk.length) {
|
145
|
+
// Remove ANSI escape codes, the TUI will control the formatting
|
146
|
+
appLifeCycle?.__setCloudMessage((0, node_util_1.stripVTControlCharacters)(trimmedChunk));
|
147
|
+
}
|
148
|
+
}
|
149
|
+
// Preserve original behavior around callback and return value, just in case
|
150
|
+
if (callback) {
|
151
|
+
callback();
|
152
|
+
}
|
153
|
+
return true;
|
154
|
+
};
|
155
|
+
};
|
156
|
+
const createPatchedConsoleMethod = (originalMethod) => {
|
157
|
+
return (...args) => {
|
158
|
+
// Check if the log came from the Nx Cloud client, otherwise invoke the original write method
|
159
|
+
const stackTrace = new Error().stack;
|
160
|
+
const isNxCloudLog = stackTrace.includes((0, node_path_1.join)(workspace_root_1.workspaceRoot, '.nx', 'cache', 'cloud'));
|
161
|
+
if (!isNxCloudLog) {
|
162
|
+
return originalMethod(...args);
|
163
|
+
}
|
164
|
+
// No-op the Nx Cloud client logs
|
165
|
+
};
|
166
|
+
};
|
167
|
+
process.stdout.write = createPatchedLogWrite(originalStdoutWrite);
|
168
|
+
process.stderr.write = createPatchedLogWrite(originalStderrWrite);
|
169
|
+
// The cloud client calls console.log when NX_VERBOSE_LOGGING is set to true
|
170
|
+
console.log = createPatchedConsoleMethod(originalConsoleLog);
|
171
|
+
console.error = createPatchedConsoleMethod(originalConsoleError);
|
172
|
+
renderIsDone = new Promise((resolve) => {
|
173
|
+
appLifeCycle.__init(() => {
|
174
|
+
resolve();
|
175
|
+
});
|
176
|
+
})
|
177
|
+
.then(() => {
|
178
|
+
restoreTerminal();
|
179
|
+
})
|
180
|
+
.finally(() => {
|
181
|
+
// Revert the patched methods
|
182
|
+
process.stdout.write = originalStdoutWrite;
|
183
|
+
process.stderr.write = originalStderrWrite;
|
184
|
+
console.log = originalConsoleLog;
|
185
|
+
console.error = originalConsoleError;
|
186
|
+
printSummary();
|
187
|
+
// Print the intercepted Nx Cloud logs
|
188
|
+
for (const log of interceptedNxCloudLogs) {
|
189
|
+
const logString = log.toString().trimStart();
|
190
|
+
process.stdout.write(logString);
|
191
|
+
if (logString) {
|
192
|
+
process.stdout.write('\n');
|
193
|
+
}
|
194
|
+
}
|
195
|
+
});
|
196
|
+
}
|
197
|
+
return {
|
198
|
+
lifeCycle: new life_cycle_1.CompositeLifeCycle(lifeCycles),
|
199
|
+
renderIsDone,
|
200
|
+
};
|
201
|
+
}
|
42
202
|
const { runnerOptions } = getRunner(nxArgs, nxJson);
|
43
203
|
const isRunOne = initiatingProject != null;
|
44
204
|
const useDynamicOutput = shouldUseDynamicLifeCycle(tasks, runnerOptions, nxArgs.outputStyle);
|
45
|
-
const overridesWithoutHidden = { ...overrides };
|
46
|
-
delete overridesWithoutHidden['__overrides_unparsed__'];
|
47
205
|
if (isRunOne) {
|
48
206
|
if (useDynamicOutput) {
|
49
207
|
return await (0, dynamic_run_one_terminal_output_life_cycle_1.createRunOneDynamicOutputRenderer)({
|
@@ -129,7 +287,7 @@ async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }
|
|
129
287
|
const projectNames = projectsToRun.map((t) => t.name);
|
130
288
|
const { projectGraph, taskGraph } = await ensureWorkspaceIsInSyncAndGetGraphs(currentProjectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions);
|
131
289
|
const tasks = Object.values(taskGraph.tasks);
|
132
|
-
const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, nxArgs, nxJson, overrides);
|
290
|
+
const { lifeCycle, renderIsDone } = await getTerminalOutputLifeCycle(initiatingProject, projectNames, tasks, taskGraph, nxArgs, nxJson, overrides);
|
133
291
|
const taskResults = await invokeTasksRunner({
|
134
292
|
tasks,
|
135
293
|
projectGraph,
|
@@ -141,12 +299,12 @@ async function runCommandForTasks(projectsToRun, currentProjectGraph, { nxJson }
|
|
141
299
|
initiatingProject,
|
142
300
|
});
|
143
301
|
await renderIsDone;
|
144
|
-
await (0,
|
302
|
+
await (0, nx_key_1.printNxKey)();
|
145
303
|
return taskResults;
|
146
304
|
}
|
147
305
|
async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
|
148
306
|
let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
|
149
|
-
if (nxArgs.skipSync) {
|
307
|
+
if (nxArgs.skipSync || (0, is_ci_1.isCI)()) {
|
150
308
|
return { projectGraph, taskGraph };
|
151
309
|
}
|
152
310
|
// collect unique syncGenerators from the tasks
|
@@ -166,9 +324,8 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
166
324
|
const outOfSyncTitle = 'The workspace is out of sync';
|
167
325
|
const resultBodyLines = (0, sync_generators_1.getSyncGeneratorSuccessResultsMessageLines)(results);
|
168
326
|
const fixMessage = 'Make sure to run `nx sync` to apply the identified changes or set `sync.applyChanges` to `true` in your `nx.json` to apply them automatically when running tasks in interactive environments.';
|
169
|
-
|
170
|
-
|
171
|
-
// If the user is running in CI or is running in a non-TTY environment we
|
327
|
+
if (!process.stdout.isTTY) {
|
328
|
+
// If the user is running a non-TTY environment we
|
172
329
|
// throw an error to stop the execution of the tasks.
|
173
330
|
if (areAllResultsFailures) {
|
174
331
|
output_1.output.error({
|
@@ -216,7 +373,6 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
216
373
|
...resultBodyLines,
|
217
374
|
'',
|
218
375
|
'Your workspace is set to not apply the identified changes automatically (`sync.applyChanges` is set to `false` in your `nx.json`).',
|
219
|
-
willErrorOnCiMessage,
|
220
376
|
fixMessage,
|
221
377
|
],
|
222
378
|
});
|
@@ -235,10 +391,12 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
|
|
235
391
|
title: outOfSyncTitle,
|
236
392
|
bodyLines: [
|
237
393
|
...resultBodyLines,
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
394
|
+
...(nxJson.sync?.applyChanges === true
|
395
|
+
? [
|
396
|
+
'',
|
397
|
+
'Proceeding to sync the identified changes automatically (`sync.applyChanges` is set to `true` in your `nx.json`).',
|
398
|
+
]
|
399
|
+
: []),
|
242
400
|
],
|
243
401
|
});
|
244
402
|
const applyChanges = nxJson.sync?.applyChanges === true ||
|
@@ -535,10 +693,9 @@ function getRunner(nxArgs, nxJson) {
|
|
535
693
|
try {
|
536
694
|
if (isCustomRunnerPath(modulePath)) {
|
537
695
|
output_1.output.warn({
|
538
|
-
title: `Custom task runners will
|
696
|
+
title: `Custom task runners will be replaced by a new API starting with Nx 21.`,
|
539
697
|
bodyLines: [
|
540
|
-
`
|
541
|
-
`For more information, see https://nx.dev/nx-enterprise/powerpack/custom-caching`,
|
698
|
+
`For more information, see https://nx.dev/deprecated/custom-tasks-runner`,
|
542
699
|
],
|
543
700
|
});
|
544
701
|
}
|
@@ -557,7 +714,7 @@ function getTasksRunnerPath(runner, nxJson) {
|
|
557
714
|
let modulePath = nxJson.tasksRunnerOptions?.[runner]?.runner;
|
558
715
|
if (modulePath) {
|
559
716
|
if ((0, fileutils_1.isRelativePath)(modulePath)) {
|
560
|
-
return (0,
|
717
|
+
return (0, node_path_1.join)(workspace_root_1.workspaceRoot, modulePath);
|
561
718
|
}
|
562
719
|
return modulePath;
|
563
720
|
}
|
@@ -1,10 +1,7 @@
|
|
1
1
|
import { Task } from '../config/task-graph';
|
2
2
|
export declare function getEnvVariablesForBatchProcess(skipNxCache: boolean, captureStderr: boolean): NodeJS.ProcessEnv;
|
3
3
|
export declare function getTaskSpecificEnv(task: Task): NodeJS.ProcessEnv;
|
4
|
-
export declare function getEnvVariablesForTask(task: Task, taskSpecificEnv: NodeJS.ProcessEnv, forceColor: string, skipNxCache: boolean, captureStderr: boolean, outputPath: string, streamOutput: boolean):
|
5
|
-
[x: string]: string;
|
6
|
-
TZ?: string;
|
7
|
-
};
|
4
|
+
export declare function getEnvVariablesForTask(task: Task, taskSpecificEnv: NodeJS.ProcessEnv, forceColor: string, skipNxCache: boolean, captureStderr: boolean, outputPath: string, streamOutput: boolean): NodeJS.ProcessEnv;
|
8
5
|
/**
|
9
6
|
* This function loads a .env file and expands the variables in it.
|
10
7
|
* @param filename the .env file to load
|
@@ -75,6 +75,8 @@ function getNxEnvVariablesForTask(task, forceColor, skipNxCache, captureStderr,
|
|
75
75
|
return {
|
76
76
|
...getNxEnvVariablesForForkedProcess(forceColor, skipNxCache, captureStderr, outputPath, streamOutput),
|
77
77
|
...env,
|
78
|
+
// Ensure the TUI does not get spawned within the TUI if ever tasks invoke Nx again
|
79
|
+
NX_TUI: 'false',
|
78
80
|
};
|
79
81
|
}
|
80
82
|
/**
|
@@ -1,11 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
3
|
-
import { TaskStatus } from './tasks-runner';
|
1
|
+
import { NxJsonConfiguration } from '../config/nx-json';
|
4
2
|
import { ProjectGraph } from '../config/project-graph';
|
5
|
-
import { TaskGraph } from '../config/task-graph';
|
3
|
+
import { Task, TaskGraph } from '../config/task-graph';
|
6
4
|
import { DaemonClient } from '../daemon/client/client';
|
7
|
-
import {
|
5
|
+
import { TaskHasher } from '../hasher/task-hasher';
|
8
6
|
import { NxArgs } from '../utils/command-line-utils';
|
7
|
+
import { DefaultTasksRunnerOptions } from './default-tasks-runner';
|
8
|
+
import { RunningTask } from './running-tasks/running-task';
|
9
|
+
import { TaskStatus } from './tasks-runner';
|
9
10
|
export declare class TaskOrchestrator {
|
10
11
|
private readonly hasher;
|
11
12
|
private readonly initiatingProject;
|
@@ -16,9 +17,12 @@ export declare class TaskOrchestrator {
|
|
16
17
|
private readonly bail;
|
17
18
|
private readonly daemon;
|
18
19
|
private readonly outputStyle;
|
20
|
+
private readonly taskGraphForHashing;
|
19
21
|
private taskDetails;
|
20
22
|
private cache;
|
23
|
+
private readonly tuiEnabled;
|
21
24
|
private forkedProcessTaskRunner;
|
25
|
+
private runningTasksService;
|
22
26
|
private tasksSchedule;
|
23
27
|
private batchEnv;
|
24
28
|
private reverseTaskDeps;
|
@@ -30,24 +34,31 @@ export declare class TaskOrchestrator {
|
|
30
34
|
private bailed;
|
31
35
|
private runningContinuousTasks;
|
32
36
|
private cleaningUp;
|
33
|
-
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string);
|
37
|
+
constructor(hasher: TaskHasher, initiatingProject: string | undefined, projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string, taskGraphForHashing?: TaskGraph);
|
38
|
+
init(): Promise<void>;
|
34
39
|
run(): Promise<{
|
35
40
|
[id: string]: TaskStatus;
|
36
41
|
}>;
|
37
42
|
private executeNextBatchOfTasksUsingTaskSchedule;
|
38
|
-
|
43
|
+
processTask(taskId: string): Promise<NodeJS.ProcessEnv>;
|
39
44
|
private processScheduledBatch;
|
40
45
|
private processAllScheduledTasks;
|
41
46
|
private applyCachedResults;
|
42
47
|
private applyCachedResult;
|
43
48
|
private applyFromCacheOrRunBatch;
|
44
49
|
private runBatch;
|
45
|
-
|
50
|
+
applyFromCacheOrRunTask(doNotSkipCache: boolean, task: Task, groupId: number): Promise<{
|
51
|
+
task: Task;
|
52
|
+
code: number;
|
53
|
+
status: TaskStatus;
|
54
|
+
terminalOutput?: string;
|
55
|
+
}>;
|
46
56
|
private runTask;
|
47
57
|
private runTaskInForkedProcess;
|
48
|
-
|
58
|
+
startContinuousTask(task: Task, groupId: number): Promise<RunningTask>;
|
49
59
|
private preRunSteps;
|
50
60
|
private postRunSteps;
|
61
|
+
private scheduleNextTasksAndReleaseThreads;
|
51
62
|
private complete;
|
52
63
|
private pipeOutputCapture;
|
53
64
|
private shouldCacheTaskResult;
|
@@ -57,3 +68,4 @@ export declare class TaskOrchestrator {
|
|
57
68
|
private recordOutputsHash;
|
58
69
|
private cleanup;
|
59
70
|
}
|
71
|
+
export declare function getThreadCount(options: NxArgs & DefaultTasksRunnerOptions, taskGraph: TaskGraph): number;
|