nx 18.1.1 → 18.2.0-beta.0
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/package.json +12 -12
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/add/add.js +1 -1
- package/src/command-line/affected/command-object.js +49 -22
- package/src/command-line/generate/generate.js +3 -3
- package/src/command-line/init/init-v2.js +43 -31
- package/src/command-line/run/command-object.js +9 -2
- package/src/command-line/run/run-one.js +1 -1
- package/src/command-line/run/run.js +15 -5
- package/src/command-line/run-many/command-object.js +4 -1
- package/src/command-line/show/command-object.d.ts +2 -0
- package/src/command-line/show/command-object.js +19 -2
- package/src/config/workspace-json-project-json.d.ts +4 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/daemon/client/client.js +19 -7
- package/src/daemon/daemon-project-graph-error.d.ts +8 -0
- package/src/daemon/daemon-project-graph-error.js +13 -0
- package/src/daemon/server/handle-hash-tasks.js +11 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +55 -6
- package/src/daemon/server/shutdown-utils.js +1 -3
- package/src/daemon/socket-utils.js +7 -1
- package/src/executors/run-commands/run-commands.impl.js +15 -9
- package/src/executors/run-script/run-script.impl.js +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 +2 -2
- package/src/plugins/js/versions.d.ts +1 -1
- package/src/plugins/js/versions.js +1 -1
- package/src/project-graph/build-project-graph.d.ts +18 -1
- package/src/project-graph/build-project-graph.js +71 -24
- package/src/project-graph/project-graph.d.ts +23 -2
- package/src/project-graph/project-graph.js +117 -14
- package/src/project-graph/utils/project-configuration-utils.d.ts +27 -4
- package/src/project-graph/utils/project-configuration-utils.js +176 -45
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +6 -14
- package/src/project-graph/utils/retrieve-workspace-files.js +3 -16
- package/src/tasks-runner/forked-process-task-runner.d.ts +2 -1
- package/src/tasks-runner/forked-process-task-runner.js +19 -8
- package/src/tasks-runner/pseudo-terminal.d.ts +2 -1
- package/src/tasks-runner/pseudo-terminal.js +27 -1
- package/src/tasks-runner/task-orchestrator.js +4 -22
- package/src/utils/output.d.ts +1 -1
- package/src/utils/params.d.ts +2 -2
- package/src/utils/params.js +14 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.configurationGlobs = exports.
|
3
|
+
exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
5
5
|
const installation_directory_1 = require("../../utils/installation-directory");
|
6
6
|
const angular_json_1 = require("../../adapter/angular-json");
|
@@ -58,7 +58,7 @@ exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfig
|
|
58
58
|
function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
|
59
59
|
const globPatterns = configurationGlobs(plugins);
|
60
60
|
const workspaceFiles = (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
|
61
|
-
return createProjectConfigurations(workspaceRoot, nxJson, workspaceFiles, plugins);
|
61
|
+
return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
|
62
62
|
}
|
63
63
|
function retrieveProjectConfigurationPaths(root, plugins) {
|
64
64
|
const projectGlobPatterns = configurationGlobs(plugins);
|
@@ -76,7 +76,7 @@ async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
|
76
76
|
return projectsWithoutPluginCache.get(cacheKey);
|
77
77
|
}
|
78
78
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns) ?? [];
|
79
|
-
const { projects } = await createProjectConfigurations(root, nxJson, projectFiles, [
|
79
|
+
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, [
|
80
80
|
{ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) },
|
81
81
|
{ plugin: project_json_1.ProjectJsonProjectsPlugin },
|
82
82
|
]);
|
@@ -84,19 +84,6 @@ async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
|
84
84
|
return projects;
|
85
85
|
}
|
86
86
|
exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
|
87
|
-
async function createProjectConfigurations(workspaceRoot, nxJson, configFiles, plugins) {
|
88
|
-
perf_hooks_1.performance.mark('build-project-configs:start');
|
89
|
-
const { projects, externalNodes, rootMap, sourceMaps } = await (0, project_configuration_utils_1.buildProjectsConfigurationsFromProjectPathsAndPlugins)(nxJson, configFiles, plugins, workspaceRoot);
|
90
|
-
perf_hooks_1.performance.mark('build-project-configs:end');
|
91
|
-
perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
|
92
|
-
return {
|
93
|
-
projects,
|
94
|
-
externalNodes,
|
95
|
-
projectRootMap: rootMap,
|
96
|
-
sourceMaps,
|
97
|
-
};
|
98
|
-
}
|
99
|
-
exports.createProjectConfigurations = createProjectConfigurations;
|
100
87
|
function configurationGlobs(plugins) {
|
101
88
|
const globPatterns = [];
|
102
89
|
for (const { plugin } of plugins) {
|
@@ -22,12 +22,13 @@ export declare class ForkedProcessTaskRunner {
|
|
22
22
|
code: number;
|
23
23
|
terminalOutput: string;
|
24
24
|
}>;
|
25
|
-
forkProcess(task: Task, { temporaryOutputPath, streamOutput,
|
25
|
+
forkProcess(task: Task, { temporaryOutputPath, streamOutput, taskGraph, env, disablePseudoTerminal, }: {
|
26
26
|
temporaryOutputPath: string;
|
27
27
|
streamOutput: boolean;
|
28
28
|
pipeOutput: boolean;
|
29
29
|
taskGraph: TaskGraph;
|
30
30
|
env: NodeJS.ProcessEnv;
|
31
|
+
disablePseudoTerminal: boolean;
|
31
32
|
}): Promise<{
|
32
33
|
code: number;
|
33
34
|
terminalOutput: string;
|
@@ -21,10 +21,14 @@ class ForkedProcessTaskRunner {
|
|
21
21
|
this.cliPath = (0, utils_1.getCliPath)();
|
22
22
|
this.verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
23
23
|
this.processes = new Set();
|
24
|
-
this.pseudoTerminal =
|
24
|
+
this.pseudoTerminal = pseudo_terminal_1.PseudoTerminal.isSupported()
|
25
|
+
? (0, pseudo_terminal_1.getPseudoTerminal)()
|
26
|
+
: null;
|
25
27
|
}
|
26
28
|
async init() {
|
27
|
-
|
29
|
+
if (this.pseudoTerminal) {
|
30
|
+
await this.pseudoTerminal.init();
|
31
|
+
}
|
28
32
|
this.setupProcessEventListeners();
|
29
33
|
}
|
30
34
|
// TODO: vsavkin delegate terminal output printing
|
@@ -104,11 +108,14 @@ class ForkedProcessTaskRunner {
|
|
104
108
|
env,
|
105
109
|
});
|
106
110
|
}
|
107
|
-
async forkProcess(task, { temporaryOutputPath, streamOutput,
|
111
|
+
async forkProcess(task, { temporaryOutputPath, streamOutput, taskGraph, env, disablePseudoTerminal, }) {
|
108
112
|
const shouldPrefix = streamOutput && process.env.NX_PREFIX_OUTPUT === 'true';
|
109
113
|
// streamOutput would be false if we are running multiple targets
|
110
114
|
// there's no point in running the commands in a pty if we are not streaming the output
|
111
|
-
if (!
|
115
|
+
if (!this.pseudoTerminal ||
|
116
|
+
disablePseudoTerminal ||
|
117
|
+
!streamOutput ||
|
118
|
+
shouldPrefix) {
|
112
119
|
return this.forkProcessWithPrefixAndNotTTY(task, {
|
113
120
|
temporaryOutputPath,
|
114
121
|
streamOutput,
|
@@ -303,13 +310,17 @@ class ForkedProcessTaskRunner {
|
|
303
310
|
(0, fs_1.writeFileSync)(outputPath, content);
|
304
311
|
}
|
305
312
|
setupProcessEventListeners() {
|
306
|
-
this.pseudoTerminal
|
307
|
-
|
308
|
-
|
313
|
+
if (this.pseudoTerminal) {
|
314
|
+
this.pseudoTerminal.onMessageFromChildren((message) => {
|
315
|
+
process.send(message);
|
316
|
+
});
|
317
|
+
}
|
309
318
|
// When the nx process gets a message, it will be sent into the task's process
|
310
319
|
process.on('message', (message) => {
|
311
320
|
// this.publisher.publish(message.toString());
|
312
|
-
this.pseudoTerminal
|
321
|
+
if (this.pseudoTerminal) {
|
322
|
+
this.pseudoTerminal.sendMessageToChildren(message);
|
323
|
+
}
|
313
324
|
this.processes.forEach((p) => {
|
314
325
|
if ('connected' in p && p.connected) {
|
315
326
|
p.send(message);
|
@@ -2,12 +2,13 @@
|
|
2
2
|
import { ChildProcess, RustPseudoTerminal } from '../native';
|
3
3
|
import { PseudoIPCServer } from './pseudo-ipc';
|
4
4
|
import { Serializable } from 'child_process';
|
5
|
-
export declare function getPseudoTerminal(): PseudoTerminal;
|
5
|
+
export declare function getPseudoTerminal(skipSupportCheck?: boolean): PseudoTerminal;
|
6
6
|
export declare class PseudoTerminal {
|
7
7
|
private rustPseudoTerminal;
|
8
8
|
private pseudoIPCPath;
|
9
9
|
private pseudoIPC;
|
10
10
|
private initialized;
|
11
|
+
static isSupported(): boolean;
|
11
12
|
constructor(rustPseudoTerminal: RustPseudoTerminal);
|
12
13
|
init(): Promise<void>;
|
13
14
|
runCommand(command: string, { cwd, jsEnv, quiet, }?: {
|
@@ -4,13 +4,20 @@ exports.PseudoTtyProcessWithSend = exports.PseudoTtyProcess = exports.PseudoTerm
|
|
4
4
|
const native_1 = require("../native");
|
5
5
|
const pseudo_ipc_1 = require("./pseudo-ipc");
|
6
6
|
const socket_utils_1 = require("../daemon/socket-utils");
|
7
|
+
const os = require("os");
|
7
8
|
let pseudoTerminal;
|
8
|
-
function getPseudoTerminal() {
|
9
|
+
function getPseudoTerminal(skipSupportCheck = false) {
|
10
|
+
if (!skipSupportCheck && !PseudoTerminal.isSupported()) {
|
11
|
+
throw new Error('Pseudo terminal is not supported on this platform.');
|
12
|
+
}
|
9
13
|
pseudoTerminal ??= new PseudoTerminal(new native_1.RustPseudoTerminal());
|
10
14
|
return pseudoTerminal;
|
11
15
|
}
|
12
16
|
exports.getPseudoTerminal = getPseudoTerminal;
|
13
17
|
class PseudoTerminal {
|
18
|
+
static isSupported() {
|
19
|
+
return process.stdout.isTTY && supportedPtyPlatform();
|
20
|
+
}
|
14
21
|
constructor(rustPseudoTerminal) {
|
15
22
|
this.rustPseudoTerminal = rustPseudoTerminal;
|
16
23
|
this.pseudoIPCPath = (0, socket_utils_1.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
|
@@ -131,3 +138,22 @@ function messageToCode(message) {
|
|
131
138
|
return 1;
|
132
139
|
}
|
133
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
|
+
}
|
@@ -11,7 +11,6 @@ const utils_1 = require("./utils");
|
|
11
11
|
const tasks_schedule_1 = require("./tasks-schedule");
|
12
12
|
const hash_task_1 = require("../hasher/hash-task");
|
13
13
|
const task_env_1 = require("./task-env");
|
14
|
-
const os = require("os");
|
15
14
|
const workspace_root_1 = require("../utils/workspace-root");
|
16
15
|
const output_1 = require("../utils/output");
|
17
16
|
const params_1 = require("../utils/params");
|
@@ -253,8 +252,9 @@ class TaskOrchestrator {
|
|
253
252
|
}
|
254
253
|
async runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput) {
|
255
254
|
try {
|
256
|
-
|
257
|
-
|
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;
|
258
258
|
// execution
|
259
259
|
const { code, terminalOutput } = usePtyFork
|
260
260
|
? await this.forkedProcessTaskRunner.forkProcess(task, {
|
@@ -263,6 +263,7 @@ class TaskOrchestrator {
|
|
263
263
|
pipeOutput,
|
264
264
|
taskGraph: this.taskGraph,
|
265
265
|
env,
|
266
|
+
disablePseudoTerminal,
|
266
267
|
})
|
267
268
|
: await this.forkedProcessTaskRunner.forkProcessLegacy(task, {
|
268
269
|
temporaryOutputPath,
|
@@ -412,22 +413,3 @@ class TaskOrchestrator {
|
|
412
413
|
}
|
413
414
|
}
|
414
415
|
exports.TaskOrchestrator = TaskOrchestrator;
|
415
|
-
function supportedPtyPlatform() {
|
416
|
-
if (process.platform !== 'win32') {
|
417
|
-
return true;
|
418
|
-
}
|
419
|
-
let windowsVersion = os.release().split('.');
|
420
|
-
let windowsBuild = windowsVersion[2];
|
421
|
-
if (!windowsBuild) {
|
422
|
-
return false;
|
423
|
-
}
|
424
|
-
// Mininum supported Windows version:
|
425
|
-
// https://en.wikipedia.org/wiki/Windows_10,_version_1809
|
426
|
-
// https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
|
427
|
-
if (+windowsBuild < 17763) {
|
428
|
-
return false;
|
429
|
-
}
|
430
|
-
else {
|
431
|
-
return true;
|
432
|
-
}
|
433
|
-
}
|
package/src/utils/output.d.ts
CHANGED
package/src/utils/params.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { NxJsonConfiguration } from '../config/nx-json';
|
2
|
-
import { TargetConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
1
|
+
import type { NxJsonConfiguration } from '../config/nx-json';
|
2
|
+
import type { TargetConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
3
3
|
type PropertyDescription = {
|
4
4
|
type?: string | string[];
|
5
5
|
required?: string[];
|
package/src/utils/params.js
CHANGED
@@ -13,6 +13,20 @@ async function handleErrors(isVerbose, fn) {
|
|
13
13
|
if (err.constructor.name === 'UnsuccessfulWorkflowExecution') {
|
14
14
|
logger_1.logger.error('The generator workflow failed. See above.');
|
15
15
|
}
|
16
|
+
else if (err.name === 'ProjectGraphError') {
|
17
|
+
const projectGraphError = err;
|
18
|
+
let title = projectGraphError.message;
|
19
|
+
if (isVerbose) {
|
20
|
+
title += ' See errors below.';
|
21
|
+
}
|
22
|
+
const bodyLines = isVerbose
|
23
|
+
? [projectGraphError.stack]
|
24
|
+
: ['Pass --verbose to see the stacktraces.'];
|
25
|
+
output_1.output.error({
|
26
|
+
title,
|
27
|
+
bodyLines: bodyLines,
|
28
|
+
});
|
29
|
+
}
|
16
30
|
else {
|
17
31
|
const lines = (err.message ? err.message : err.toString()).split('\n');
|
18
32
|
const bodyLines = lines.slice(1);
|