nx 18.1.0 → 18.1.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/bin/init-local.js +13 -1
- package/package.json +12 -12
- package/release/changelog-renderer/index.d.ts +2 -0
- package/release/changelog-renderer/index.js +4 -18
- package/schemas/nx-schema.json +62 -1
- package/schemas/project-schema.json +20 -0
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-nest.js +2 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +2 -2
- package/src/command-line/init/implementation/utils.d.ts +1 -3
- package/src/command-line/init/implementation/utils.js +9 -16
- package/src/command-line/init/init-v2.js +3 -2
- package/src/command-line/release/changelog.js +17 -14
- package/src/command-line/release/command-object.d.ts +1 -0
- package/src/command-line/release/config/config.d.ts +12 -15
- package/src/command-line/release/config/config.js +151 -22
- package/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/src/command-line/release/config/conventional-commits.js +98 -0
- package/src/command-line/release/publish.js +4 -3
- package/src/command-line/release/release.js +12 -11
- package/src/command-line/release/utils/git.js +30 -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 -13
- package/src/command-line/release/utils/semver.d.ts +2 -8
- package/src/command-line/release/utils/semver.js +4 -1
- package/src/command-line/release/utils/shared.d.ts +5 -1
- package/src/command-line/release/version.d.ts +6 -1
- package/src/command-line/release/version.js +71 -19
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/command-line/run/run.js +16 -6
- package/src/config/nx-json.d.ts +31 -0
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/styles.css +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +1 -0
- package/src/devkit-exports.d.ts +1 -2
- package/src/devkit-internals.d.ts +0 -1
- package/src/devkit-internals.js +1 -3
- package/src/executors/run-commands/run-commands.impl.d.ts +7 -1
- package/src/executors/run-commands/run-commands.impl.js +120 -55
- package/src/executors/run-script/run-script.impl.js +6 -6
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -4
- package/src/migrations/update-17-2-0/move-default-base.d.ts +1 -1
- package/src/migrations/update-17-2-0/move-default-base.js +3 -1
- package/src/migrations/update-17-3-0/nx-release-path.js +0 -1
- package/src/native/index.d.ts +14 -11
- package/src/native/index.js +3 -4
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/index.js +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
- package/src/plugins/js/lock-file/lock-file.js +15 -3
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -2
- package/src/project-graph/build-project-graph.js +8 -11
- package/src/project-graph/file-utils.js +6 -4
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +3 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +4 -4
- package/src/project-graph/utils/project-configuration-utils.js +58 -17
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -8
- package/src/project-graph/utils/retrieve-workspace-files.js +18 -20
- package/src/tasks-runner/fork.js +7 -7
- package/src/tasks-runner/forked-process-task-runner.d.ts +4 -5
- package/src/tasks-runner/forked-process-task-runner.js +28 -21
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +16 -13
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +8 -7
- package/src/tasks-runner/{psuedo-ipc.d.ts → pseudo-ipc.d.ts} +7 -7
- package/src/tasks-runner/{psuedo-ipc.js → pseudo-ipc.js} +9 -9
- package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
- package/src/tasks-runner/pseudo-terminal.js +159 -0
- package/src/tasks-runner/task-orchestrator.js +49 -31
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/ignore.js +1 -1
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +45 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +7 -8
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -18
- package/src/project-graph/plugins/internal-api.js +0 -48
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -4
- package/src/project-graph/plugins/plugin-pool.js +0 -216
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -115
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -26
- package/src/project-graph/plugins/worker-api.js +0 -177
@@ -0,0 +1,43 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { ChildProcess, RustPseudoTerminal } from '../native';
|
3
|
+
import { PseudoIPCServer } from './pseudo-ipc';
|
4
|
+
import { Serializable } from 'child_process';
|
5
|
+
export declare function getPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
|
6
|
+
export declare class PseudoTerminal {
|
7
|
+
private rustPseudoTerminal;
|
8
|
+
private pseudoIPCPath;
|
9
|
+
private pseudoIPC;
|
10
|
+
private initialized;
|
11
|
+
static isSupported(): boolean;
|
12
|
+
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
13
|
+
init(): Promise<void>;
|
14
|
+
runCommand(command: string, { cwd, jsEnv, quiet, }?: {
|
15
|
+
cwd?: string;
|
16
|
+
jsEnv?: Record<string, string>;
|
17
|
+
quiet?: boolean;
|
18
|
+
}): PseudoTtyProcess;
|
19
|
+
fork(id: string, script: string, { cwd, jsEnv, quiet, }: {
|
20
|
+
cwd?: string;
|
21
|
+
jsEnv?: Record<string, string>;
|
22
|
+
quiet?: boolean;
|
23
|
+
}): Promise<PseudoTtyProcessWithSend>;
|
24
|
+
sendMessageToChildren(message: Serializable): void;
|
25
|
+
onMessageFromChildren(callback: (message: Serializable) => void): void;
|
26
|
+
private setupProcessListeners;
|
27
|
+
private shutdownPseudoIPC;
|
28
|
+
}
|
29
|
+
export declare class PseudoTtyProcess {
|
30
|
+
private childProcess;
|
31
|
+
isAlive: boolean;
|
32
|
+
exitCallbacks: any[];
|
33
|
+
constructor(childProcess: ChildProcess);
|
34
|
+
onExit(callback: (code: number) => void): void;
|
35
|
+
onOutput(callback: (message: string) => void): void;
|
36
|
+
kill(): void;
|
37
|
+
}
|
38
|
+
export declare class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
39
|
+
private id;
|
40
|
+
private pseudoIpc;
|
41
|
+
constructor(_childProcess: ChildProcess, id: string, pseudoIpc: PseudoIPCServer);
|
42
|
+
send(message: Serializable): void;
|
43
|
+
}
|
@@ -0,0 +1,159 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerminal = exports.getPseudoTerminal = void 0;
|
4
|
+
const native_1 = require("../native");
|
5
|
+
const pseudo_ipc_1 = require("./pseudo-ipc");
|
6
|
+
const socket_utils_1 = require("../daemon/socket-utils");
|
7
|
+
const os = require("os");
|
8
|
+
let pseudoTerminal;
|
9
|
+
function getPseudoTerminal(skipSupportCheck = false) {
|
10
|
+
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
11
|
+
throw new Error('Pseudo terminal is not supported on this platform.');
|
12
|
+
}
|
13
|
+
pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
|
14
|
+
return pseudoTerminal;
|
15
|
+
}
|
16
|
+
exports.getPseudoTerminal = getPseudoTerminal;
|
17
|
+
class PseudoTerminal {
|
18
|
+
static isSupported() {
|
19
|
+
return process.stdout.isTTY && supportedPtyPlatform();
|
20
|
+
}
|
21
|
+
constructor(rustPseudoTerminal) {
|
22
|
+
this.rustPseudoTerminal = rustPseudoTerminal;
|
23
|
+
this.pseudoIPCPath = (0, socket_utils_1.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
|
24
|
+
this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
|
25
|
+
this.initialized = false;
|
26
|
+
this.setupProcessListeners();
|
27
|
+
}
|
28
|
+
async init() {
|
29
|
+
if (this.initialized) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
await this.pseudoIPC.init();
|
33
|
+
this.initialized = true;
|
34
|
+
}
|
35
|
+
runCommand(command, { cwd, jsEnv, quiet, } = {}) {
|
36
|
+
return new PseudoTtyProcess(this.rustPseudoTerminal.runCommand(command, cwd, jsEnv, quiet));
|
37
|
+
}
|
38
|
+
async fork(id, script, { cwd, jsEnv, quiet, }) {
|
39
|
+
if (!this.initialized) {
|
40
|
+
throw new Error('Call init() before forking processes');
|
41
|
+
}
|
42
|
+
const cp = new PseudoTtyProcessWithSend(this.rustPseudoTerminal.fork(id, script, this.pseudoIPCPath, cwd, jsEnv, quiet), id, this.pseudoIPC);
|
43
|
+
await this.pseudoIPC.waitForChildReady(id);
|
44
|
+
return cp;
|
45
|
+
}
|
46
|
+
sendMessageToChildren(message) {
|
47
|
+
this.pseudoIPC.sendMessageToChildren(message);
|
48
|
+
}
|
49
|
+
onMessageFromChildren(callback) {
|
50
|
+
this.pseudoIPC.onMessageFromChildren(callback);
|
51
|
+
}
|
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
|
+
}
|
75
|
+
exports.PseudoTerminal = PseudoTerminal;
|
76
|
+
class PseudoTtyProcess {
|
77
|
+
constructor(childProcess) {
|
78
|
+
this.childProcess = childProcess;
|
79
|
+
this.isAlive = true;
|
80
|
+
this.exitCallbacks = [];
|
81
|
+
childProcess.onExit((message) => {
|
82
|
+
this.isAlive = false;
|
83
|
+
const exitCode = messageToCode(message);
|
84
|
+
this.exitCallbacks.forEach((cb) => cb(exitCode));
|
85
|
+
});
|
86
|
+
}
|
87
|
+
onExit(callback) {
|
88
|
+
this.exitCallbacks.push(callback);
|
89
|
+
}
|
90
|
+
onOutput(callback) {
|
91
|
+
this.childProcess.onOutput(callback);
|
92
|
+
}
|
93
|
+
kill() {
|
94
|
+
try {
|
95
|
+
this.childProcess.kill();
|
96
|
+
}
|
97
|
+
catch {
|
98
|
+
// when the child process completes before we explicitly call kill, this will throw
|
99
|
+
// do nothing
|
100
|
+
}
|
101
|
+
finally {
|
102
|
+
if (this.isAlive == true) {
|
103
|
+
this.isAlive = false;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
}
|
108
|
+
exports.PseudoTtyProcess = PseudoTtyProcess;
|
109
|
+
class PseudoTtyProcessWithSend extends PseudoTtyProcess {
|
110
|
+
constructor(_childProcess, id, pseudoIpc) {
|
111
|
+
super(_childProcess);
|
112
|
+
this.id = id;
|
113
|
+
this.pseudoIpc = pseudoIpc;
|
114
|
+
}
|
115
|
+
send(message) {
|
116
|
+
this.pseudoIpc.sendMessageToChild(this.id, message);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
exports.PseudoTtyProcessWithSend = PseudoTtyProcessWithSend;
|
120
|
+
function messageToCode(message) {
|
121
|
+
if (message.startsWith('Terminated by ')) {
|
122
|
+
switch (message.replace('Terminated by ', '').trim()) {
|
123
|
+
case 'Termination':
|
124
|
+
return 143;
|
125
|
+
case 'Interrupt':
|
126
|
+
return 130;
|
127
|
+
default:
|
128
|
+
return 128;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
else if (message.startsWith('Exited with code ')) {
|
132
|
+
return parseInt(message.replace('Exited with code ', '').trim());
|
133
|
+
}
|
134
|
+
else if (message === 'Success') {
|
135
|
+
return 0;
|
136
|
+
}
|
137
|
+
else {
|
138
|
+
return 1;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
function supportedPtyPlatform() {
|
142
|
+
if (process.platform !== 'win32') {
|
143
|
+
return true;
|
144
|
+
}
|
145
|
+
let windowsVersion = os.release().split('.');
|
146
|
+
let windowsBuild = windowsVersion[2];
|
147
|
+
if (!windowsBuild) {
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
// Mininum supported Windows version:
|
151
|
+
// https://en.wikipedia.org/wiki/Windows_10,_version_1809
|
152
|
+
// https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
|
153
|
+
if (+windowsBuild < 17763) {
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
else {
|
157
|
+
return true;
|
158
|
+
}
|
159
|
+
}
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskOrchestrator = void 0;
|
4
4
|
const events_1 = require("events");
|
5
5
|
const perf_hooks_1 = require("perf_hooks");
|
6
|
+
const path_1 = require("path");
|
7
|
+
const run_commands_impl_1 = require("../executors/run-commands/run-commands.impl");
|
6
8
|
const forked_process_task_runner_1 = require("./forked-process-task-runner");
|
7
9
|
const cache_1 = require("./cache");
|
8
10
|
const utils_1 = require("./utils");
|
9
11
|
const tasks_schedule_1 = require("./tasks-schedule");
|
10
12
|
const hash_task_1 = require("../hasher/hash-task");
|
11
13
|
const task_env_1 = require("./task-env");
|
12
|
-
const
|
14
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
15
|
+
const output_1 = require("../utils/output");
|
16
|
+
const params_1 = require("../utils/params");
|
13
17
|
class TaskOrchestrator {
|
14
18
|
// endregion internal state
|
15
19
|
constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
|
@@ -49,7 +53,6 @@ class TaskOrchestrator {
|
|
49
53
|
await Promise.all(threads);
|
50
54
|
perf_hooks_1.performance.mark('task-execution:end');
|
51
55
|
perf_hooks_1.performance.measure('task-execution', 'task-execution:start', 'task-execution:end');
|
52
|
-
this.forkedProcessTaskRunner.destroy();
|
53
56
|
this.cache.removeOldCacheRecords();
|
54
57
|
return this.completedTasks;
|
55
58
|
}
|
@@ -205,20 +208,53 @@ class TaskOrchestrator {
|
|
205
208
|
let results = doNotSkipCache ? await this.applyCachedResults([task]) : [];
|
206
209
|
// the task wasn't cached
|
207
210
|
if (results.length === 0) {
|
208
|
-
|
209
|
-
const
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
211
|
+
const shouldPrefix = streamOutput && process.env.NX_PREFIX_OUTPUT === 'true';
|
212
|
+
const targetConfiguration = (0, utils_1.getTargetConfigurationForTask)(task, this.projectGraph);
|
213
|
+
if (process.env.NX_RUN_COMMANDS_DIRECTLY !== 'false' &&
|
214
|
+
targetConfiguration.executor === 'nx:run-commands' &&
|
215
|
+
!shouldPrefix) {
|
216
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
217
|
+
const isRunOne = this.initiatingProject != null;
|
218
|
+
const combinedOptions = (0, params_1.combineOptionsForExecutor)(task.overrides, task.target.configuration ?? targetConfiguration.defaultConfiguration, targetConfiguration, schema, task.target.project, (0, path_1.relative)(task.projectRoot ?? workspace_root_1.workspaceRoot, process.cwd()), process.env.NX_VERBOSE_LOGGING === 'true');
|
219
|
+
if (streamOutput) {
|
220
|
+
const args = (0, utils_1.getPrintableCommandArgsForTask)(task);
|
221
|
+
output_1.output.logCommand(args.join(' '));
|
222
|
+
}
|
223
|
+
const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
|
224
|
+
...combinedOptions,
|
225
|
+
env,
|
226
|
+
usePty: isRunOne && !this.tasksSchedule.hasTasks(),
|
227
|
+
streamOutput,
|
228
|
+
}, {
|
229
|
+
root: workspace_root_1.workspaceRoot, // only root is needed in runCommandsImpl
|
230
|
+
});
|
231
|
+
const status = success ? 'success' : 'failure';
|
232
|
+
if (!streamOutput) {
|
233
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, status, terminalOutput);
|
234
|
+
}
|
235
|
+
results.push({
|
236
|
+
task,
|
237
|
+
status,
|
238
|
+
terminalOutput,
|
239
|
+
});
|
240
|
+
}
|
241
|
+
else {
|
242
|
+
// cache prep
|
243
|
+
const { code, terminalOutput } = await this.runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput);
|
244
|
+
results.push({
|
245
|
+
task,
|
246
|
+
status: code === 0 ? 'success' : 'failure',
|
247
|
+
terminalOutput,
|
248
|
+
});
|
249
|
+
}
|
215
250
|
}
|
216
251
|
await this.postRunSteps([task], results, doNotSkipCache, { groupId });
|
217
252
|
}
|
218
253
|
async runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput) {
|
219
254
|
try {
|
220
|
-
|
221
|
-
|
255
|
+
const usePtyFork = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false';
|
256
|
+
// Disable the pseudo terminal if this is a run-many
|
257
|
+
const disablePseudoTerminal = !this.initiatingProject;
|
222
258
|
// execution
|
223
259
|
const { code, terminalOutput } = usePtyFork
|
224
260
|
? await this.forkedProcessTaskRunner.forkProcess(task, {
|
@@ -227,6 +263,7 @@ class TaskOrchestrator {
|
|
227
263
|
pipeOutput,
|
228
264
|
taskGraph: this.taskGraph,
|
229
265
|
env,
|
266
|
+
disablePseudoTerminal,
|
230
267
|
})
|
231
268
|
: await this.forkedProcessTaskRunner.forkProcessLegacy(task, {
|
232
269
|
temporaryOutputPath,
|
@@ -338,7 +375,7 @@ class TaskOrchestrator {
|
|
338
375
|
if (process.env.NX_NATIVE_COMMAND_RUNNER !== 'false') {
|
339
376
|
return true;
|
340
377
|
}
|
341
|
-
const { schema } =
|
378
|
+
const { schema } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
342
379
|
return (schema.outputCapture === 'pipe' ||
|
343
380
|
process.env.NX_STREAM_OUTPUT === 'true');
|
344
381
|
}
|
@@ -376,22 +413,3 @@ class TaskOrchestrator {
|
|
376
413
|
}
|
377
414
|
}
|
378
415
|
exports.TaskOrchestrator = TaskOrchestrator;
|
379
|
-
function supportedPtyPlatform() {
|
380
|
-
if (process.platform !== 'win32') {
|
381
|
-
return true;
|
382
|
-
}
|
383
|
-
let windowsVersion = os.release().split('.');
|
384
|
-
let windowsBuild = windowsVersion[2];
|
385
|
-
if (!windowsBuild) {
|
386
|
-
return false;
|
387
|
-
}
|
388
|
-
// Mininum supported Windows version:
|
389
|
-
// https://en.wikipedia.org/wiki/Windows_10,_version_1809
|
390
|
-
// https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
|
391
|
-
if (+windowsBuild < 17763) {
|
392
|
-
return false;
|
393
|
-
}
|
394
|
-
else {
|
395
|
-
return true;
|
396
|
-
}
|
397
|
-
}
|
@@ -89,7 +89,7 @@ class TasksSchedule {
|
|
89
89
|
const batchMap = {};
|
90
90
|
for (const root of this.notScheduledTaskGraph.roots) {
|
91
91
|
const rootTask = this.notScheduledTaskGraph.tasks[root];
|
92
|
-
const executorName =
|
92
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(rootTask, this.projectGraph);
|
93
93
|
await this.processTaskForBatches(batchMap, rootTask, executorName, true);
|
94
94
|
}
|
95
95
|
for (const [executorName, taskGraph] of Object.entries(batchMap)) {
|
@@ -105,8 +105,8 @@ class TasksSchedule {
|
|
105
105
|
if (!this.canBatchTaskBeScheduled(task.id, batches[rootExecutorName])) {
|
106
106
|
return;
|
107
107
|
}
|
108
|
-
const { batchImplementationFactory } =
|
109
|
-
const executorName =
|
108
|
+
const { batchImplementationFactory } = (0, utils_1.getExecutorForTask)(task, this.projectGraph);
|
109
|
+
const executorName = (0, utils_1.getExecutorNameForTask)(task, this.projectGraph);
|
110
110
|
if (rootExecutorName !== executorName) {
|
111
111
|
return;
|
112
112
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Task, TaskGraph } from '../config/task-graph';
|
2
2
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
3
|
-
import { TargetDependencyConfig } from '../config/workspace-json-project-json';
|
4
|
-
import { CustomHasher } from '../config/misc-interfaces';
|
3
|
+
import { TargetConfiguration, TargetDependencyConfig } from '../config/workspace-json-project-json';
|
4
|
+
import { CustomHasher, ExecutorConfig } from '../config/misc-interfaces';
|
5
5
|
export declare function getCommandAsString(execCommand: string, task: Task): string;
|
6
6
|
export declare function getDependencyConfigs({ project, target }: {
|
7
7
|
project: string;
|
@@ -23,12 +23,13 @@ export declare function transformLegacyOutputs(projectRoot: string, error: Inval
|
|
23
23
|
export declare function getOutputsForTargetAndConfiguration(task: Task, node: ProjectGraphProjectNode): string[];
|
24
24
|
export declare function getOutputsForTargetAndConfiguration(target: Task['target'] | Task, overrides: Task['overrides'] | ProjectGraphProjectNode, node: ProjectGraphProjectNode): string[];
|
25
25
|
export declare function interpolate(template: string, data: any): string;
|
26
|
-
export declare function
|
27
|
-
export declare function
|
26
|
+
export declare function getTargetConfigurationForTask(task: Task, projectGraph: ProjectGraph): TargetConfiguration | undefined;
|
27
|
+
export declare function getExecutorNameForTask(task: Task, projectGraph: ProjectGraph): string;
|
28
|
+
export declare function getExecutorForTask(task: Task, projectGraph: ProjectGraph): ExecutorConfig & {
|
28
29
|
isNgCompat: boolean;
|
29
30
|
isNxExecutor: boolean;
|
30
|
-
}
|
31
|
-
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph):
|
31
|
+
};
|
32
|
+
export declare function getCustomHasher(task: Task, projectGraph: ProjectGraph): CustomHasher | null;
|
32
33
|
export declare function removeTasksFromTaskGraph(graph: TaskGraph, ids: string[]): TaskGraph;
|
33
34
|
export declare function removeIdsFromGraph<T>(graph: {
|
34
35
|
roots: string[];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
|
3
|
+
exports.unparse = exports.isCacheableTask = exports.shouldStreamOutput = exports.getSerializedArgsForTask = exports.getPrintableCommandArgsForTask = exports.getCliPath = exports.calculateReverseDeps = exports.removeIdsFromGraph = exports.removeTasksFromTaskGraph = exports.getCustomHasher = exports.getExecutorForTask = exports.getExecutorNameForTask = exports.getTargetConfigurationForTask = exports.interpolate = exports.getOutputsForTargetAndConfiguration = exports.transformLegacyOutputs = exports.validateOutputs = exports.getOutputs = exports.expandDependencyConfigSyntaxSugar = exports.getDependencyConfigs = exports.getCommandAsString = void 0;
|
4
4
|
const output_1 = require("../utils/output");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -177,19 +177,23 @@ function interpolate(template, data) {
|
|
177
177
|
});
|
178
178
|
}
|
179
179
|
exports.interpolate = interpolate;
|
180
|
-
|
180
|
+
function getTargetConfigurationForTask(task, projectGraph) {
|
181
181
|
const project = projectGraph.nodes[task.target.project].data;
|
182
|
-
return project.targets[task.target.target]
|
182
|
+
return project.targets[task.target.target];
|
183
|
+
}
|
184
|
+
exports.getTargetConfigurationForTask = getTargetConfigurationForTask;
|
185
|
+
function getExecutorNameForTask(task, projectGraph) {
|
186
|
+
return getTargetConfigurationForTask(task, projectGraph)?.executor;
|
183
187
|
}
|
184
188
|
exports.getExecutorNameForTask = getExecutorNameForTask;
|
185
|
-
|
186
|
-
const executor =
|
189
|
+
function getExecutorForTask(task, projectGraph) {
|
190
|
+
const executor = getExecutorNameForTask(task, projectGraph);
|
187
191
|
const [nodeModule, executorName] = executor.split(':');
|
188
192
|
return (0, executor_utils_1.getExecutorInformation)(nodeModule, executorName, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph).projects);
|
189
193
|
}
|
190
194
|
exports.getExecutorForTask = getExecutorForTask;
|
191
|
-
|
192
|
-
const factory =
|
195
|
+
function getCustomHasher(task, projectGraph) {
|
196
|
+
const factory = getExecutorForTask(task, projectGraph).hasherFactory;
|
193
197
|
return factory ? factory() : null;
|
194
198
|
}
|
195
199
|
exports.getCustomHasher = getCustomHasher;
|
package/src/utils/ignore.js
CHANGED
@@ -27,7 +27,7 @@ function getIgnoredGlobs(root = workspace_root_1.workspaceRoot, prependRoot = tr
|
|
27
27
|
}
|
28
28
|
exports.getIgnoredGlobs = getIgnoredGlobs;
|
29
29
|
function getAlwaysIgnore(root) {
|
30
|
-
const paths = ['node_modules', '**/node_modules', '.git'];
|
30
|
+
const paths = ['node_modules', '**/node_modules', '.git', '.nx', '.vscode'];
|
31
31
|
return root ? paths.map((x) => (0, path_1.joinPathFragments)(root, x)) : paths;
|
32
32
|
}
|
33
33
|
exports.getAlwaysIgnore = getAlwaysIgnore;
|
package/src/utils/logger.d.ts
CHANGED
package/src/utils/logger.js
CHANGED
@@ -1,21 +1,25 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { ProjectConfiguration } from '
|
4
|
-
import { NxJsonConfiguration } from '
|
5
|
-
import {
|
1
|
+
import { FileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
|
2
|
+
import { PackageJson } from './package-json';
|
3
|
+
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
4
|
+
import { NxJsonConfiguration, PluginConfiguration } from '../config/nx-json';
|
5
|
+
import { NxPluginV1 } from './nx-plugin.deprecated';
|
6
|
+
import { RawProjectGraphDependency } from '../project-graph/project-graph-builder';
|
6
7
|
/**
|
7
8
|
* Context for {@link CreateNodesFunction}
|
8
9
|
*/
|
9
10
|
export interface CreateNodesContext {
|
10
11
|
readonly nxJsonConfiguration: NxJsonConfiguration;
|
11
12
|
readonly workspaceRoot: string;
|
13
|
+
/**
|
14
|
+
* The subset of configuration files which match the createNodes pattern
|
15
|
+
*/
|
16
|
+
readonly configFiles: string[];
|
12
17
|
}
|
13
18
|
/**
|
14
19
|
* A function which parses a configuration file into a set of nodes.
|
15
20
|
* Used for creating nodes for the {@link ProjectGraph}
|
16
21
|
*/
|
17
22
|
export type CreateNodesFunction<T = unknown> = (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext) => CreateNodesResult | Promise<CreateNodesResult>;
|
18
|
-
export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
19
23
|
export interface CreateNodesResult {
|
20
24
|
/**
|
21
25
|
* A map of project root -> project configuration
|
@@ -30,7 +34,7 @@ export interface CreateNodesResult {
|
|
30
34
|
* A pair of file patterns and {@link CreateNodesFunction}
|
31
35
|
*/
|
32
36
|
export type CreateNodes<T = unknown> = readonly [
|
33
|
-
|
37
|
+
configFilePattern: string,
|
34
38
|
createNodesFunction: CreateNodesFunction<T>
|
35
39
|
];
|
36
40
|
/**
|
@@ -79,7 +83,41 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
79
83
|
*/
|
80
84
|
createDependencies?: CreateDependencies<TOptions>;
|
81
85
|
};
|
86
|
+
export * from './nx-plugin.deprecated';
|
82
87
|
/**
|
83
88
|
* A plugin for Nx
|
84
89
|
*/
|
85
90
|
export type NxPlugin = NxPluginV1 | NxPluginV2;
|
91
|
+
export type LoadedNxPlugin = {
|
92
|
+
plugin: NxPluginV2 & Pick<NxPluginV1, 'processProjectGraph'>;
|
93
|
+
options?: unknown;
|
94
|
+
};
|
95
|
+
export declare const nxPluginCache: Map<string, LoadedNxPlugin['plugin']>;
|
96
|
+
export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
|
97
|
+
pluginPath: string;
|
98
|
+
name: any;
|
99
|
+
};
|
100
|
+
export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): Promise<LoadedNxPlugin>;
|
101
|
+
export declare function loadNxPlugins(plugins: PluginConfiguration[], paths?: string[], root?: string, projects?: Record<string, ProjectConfiguration>): Promise<LoadedNxPlugin[]>;
|
102
|
+
export declare function ensurePluginIsV2(plugin: NxPlugin): NxPluginV2;
|
103
|
+
export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
|
104
|
+
export declare function isNxPluginV1(plugin: NxPlugin): plugin is NxPluginV1;
|
105
|
+
export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
|
106
|
+
path: string;
|
107
|
+
json: PackageJson;
|
108
|
+
};
|
109
|
+
export declare function resolveLocalNxPlugin(importPath: string, nxJsonConfiguration: NxJsonConfiguration, projects: Record<string, ProjectConfiguration>, root?: string): {
|
110
|
+
path: string;
|
111
|
+
projectConfig: ProjectConfiguration;
|
112
|
+
} | null;
|
113
|
+
/**
|
114
|
+
* Register swc-node or ts-node if they are not currently registered
|
115
|
+
* with some default settings which work well for Nx plugins.
|
116
|
+
*/
|
117
|
+
export declare function registerPluginTSTranspiler(): void;
|
118
|
+
/**
|
119
|
+
* Unregister the ts-node transpiler if it is registered
|
120
|
+
*/
|
121
|
+
export declare function unregisterPluginTSTranspiler(): void;
|
122
|
+
export declare function getDefaultPlugins(root: string): Promise<LoadedNxPlugin[]>;
|
123
|
+
type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ProjectGraphProcessor } from '../config/project-graph';
|
2
2
|
import { TargetConfiguration } from '../config/workspace-json-project-json';
|
3
|
-
import {
|
3
|
+
import { LoadedNxPlugin } from './nx-plugin';
|
4
4
|
/**
|
5
5
|
* @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 19
|
6
6
|
*/
|
@@ -28,6 +28,4 @@ export type NxPluginV1 = {
|
|
28
28
|
/**
|
29
29
|
* @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
|
30
30
|
*/
|
31
|
-
export declare function getDefaultPluginsSync(root: string):
|
32
|
-
plugin: NxPluginV2;
|
33
|
-
}[];
|
31
|
+
export declare function getDefaultPluginsSync(root: string): LoadedNxPlugin[];
|
@@ -4,7 +4,7 @@ exports.getDefaultPluginsSync = void 0;
|
|
4
4
|
const angular_json_1 = require("../adapter/angular-json");
|
5
5
|
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
6
6
|
const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
|
7
|
-
const
|
7
|
+
const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
|
8
8
|
/**
|
9
9
|
* @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
|
10
10
|
*/
|
@@ -14,9 +14,9 @@ function getDefaultPluginsSync(root) {
|
|
14
14
|
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
15
15
|
? [require('../adapter/angular-json').NxAngularJsonPlugin]
|
16
16
|
: []),
|
17
|
-
target_defaults_plugin_1.
|
18
|
-
|
19
|
-
project_json_1.
|
17
|
+
target_defaults_plugin_1.TargetDefaultsPlugin,
|
18
|
+
(0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root),
|
19
|
+
project_json_1.ProjectJsonProjectsPlugin,
|
20
20
|
];
|
21
21
|
return plugins.map((p) => ({
|
22
22
|
plugin: p,
|