nx 20.3.0-canary.20241213-0d6667d → 20.3.0-canary.20241217-ee4de0b
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 -11
- package/src/adapter/ngcli-adapter.js +7 -7
- package/src/command-line/add/add.js +21 -45
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/import/import.js +60 -34
- package/src/command-line/init/configure-plugins.d.ts +35 -0
- package/src/command-line/init/configure-plugins.js +189 -0
- package/src/command-line/init/init-v2.d.ts +1 -2
- package/src/command-line/init/init-v2.js +3 -18
- package/src/command-line/run/executor-utils.js +4 -4
- package/src/config/schema-utils.d.ts +4 -3
- package/src/config/schema-utils.js +71 -4
- package/src/config/workspace-json-project-json.d.ts +5 -0
- package/src/daemon/client/client.js +9 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +6 -20
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.d.ts +3 -1
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +12 -1
- package/src/plugins/js/utils/packages.d.ts +3 -0
- package/src/plugins/js/utils/packages.js +25 -0
- package/src/plugins/package-json/create-nodes.js +6 -0
- package/src/project-graph/build-project-graph.js +57 -1
- package/src/project-graph/plugins/internal-api.d.ts +4 -3
- package/src/project-graph/plugins/internal-api.js +2 -2
- package/src/project-graph/plugins/isolation/messaging.d.ts +2 -2
- package/src/project-graph/plugins/loader.js +13 -6
- package/src/project-graph/utils/project-configuration-utils.js +31 -1
- package/src/tasks-runner/forked-process-task-runner.js +30 -8
- package/src/utils/delayed-spinner.d.ts +40 -0
- package/src/utils/delayed-spinner.js +58 -0
- package/src/utils/package-json.d.ts +1 -0
- package/src/utils/package-json.js +5 -1
- package/src/command-line/import/utils/needs-install.d.ts +0 -3
- package/src/command-line/import/utils/needs-install.js +0 -31
@@ -220,24 +220,46 @@ class ForkedProcessTaskRunner {
|
|
220
220
|
}
|
221
221
|
}
|
222
222
|
let outWithErr = [];
|
223
|
+
let exitCode;
|
224
|
+
let stdoutHasEnded = false;
|
225
|
+
let stderrHasEnded = false;
|
226
|
+
let processHasExited = false;
|
227
|
+
const handleProcessEnd = () => {
|
228
|
+
// ensure process has exited and both stdout and stderr have ended before we pass along the logs
|
229
|
+
// if we only wait for the process to exit, we might miss some logs as stdout and stderr might still be streaming
|
230
|
+
if (stdoutHasEnded && stderrHasEnded && processHasExited) {
|
231
|
+
// we didn't print any output as we were running the command
|
232
|
+
// print all the collected output|
|
233
|
+
const terminalOutput = outWithErr.join('');
|
234
|
+
const code = exitCode;
|
235
|
+
if (!streamOutput) {
|
236
|
+
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
237
|
+
}
|
238
|
+
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
239
|
+
res({ code, terminalOutput });
|
240
|
+
}
|
241
|
+
};
|
223
242
|
p.stdout.on('data', (chunk) => {
|
224
243
|
outWithErr.push(chunk.toString());
|
225
244
|
});
|
245
|
+
p.stdout.on('end', () => {
|
246
|
+
stdoutHasEnded = true;
|
247
|
+
handleProcessEnd();
|
248
|
+
});
|
226
249
|
p.stderr.on('data', (chunk) => {
|
227
250
|
outWithErr.push(chunk.toString());
|
228
251
|
});
|
252
|
+
p.stderr.on('end', () => {
|
253
|
+
stderrHasEnded = true;
|
254
|
+
handleProcessEnd();
|
255
|
+
});
|
229
256
|
p.on('exit', (code, signal) => {
|
230
257
|
this.processes.delete(p);
|
231
258
|
if (code === null)
|
232
259
|
code = (0, exit_codes_1.signalToCode)(signal);
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
if (!streamOutput) {
|
237
|
-
this.options.lifeCycle.printTaskTerminalOutput(task, code === 0 ? 'success' : 'failure', terminalOutput);
|
238
|
-
}
|
239
|
-
this.writeTerminalOutput(temporaryOutputPath, terminalOutput);
|
240
|
-
res({ code, terminalOutput });
|
260
|
+
exitCode = code;
|
261
|
+
processHasExited = true;
|
262
|
+
handleProcessEnd();
|
241
263
|
});
|
242
264
|
}
|
243
265
|
catch (e) {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import * as ora from 'ora';
|
2
|
+
/**
|
3
|
+
* A class that allows to delay the creation of a spinner, as well
|
4
|
+
* as schedule updates to the message of the spinner. Useful for
|
5
|
+
* scenarios where one wants to only show a spinner if an operation
|
6
|
+
* takes longer than a certain amount of time.
|
7
|
+
*/
|
8
|
+
export declare class DelayedSpinner {
|
9
|
+
spinner: ora.Ora;
|
10
|
+
timeouts: NodeJS.Timeout[];
|
11
|
+
initial: number;
|
12
|
+
/**
|
13
|
+
* Constructs a new {@link DelayedSpinner} instance.
|
14
|
+
*
|
15
|
+
* @param message The message to display in the spinner
|
16
|
+
* @param ms The number of milliseconds to wait before creating the spinner
|
17
|
+
*/
|
18
|
+
constructor(message: string, ms?: number);
|
19
|
+
/**
|
20
|
+
* Sets the message to display in the spinner.
|
21
|
+
*
|
22
|
+
* @param message The message to display in the spinner
|
23
|
+
* @returns The {@link DelayedSpinner} instance
|
24
|
+
*/
|
25
|
+
setMessage(message: string): this;
|
26
|
+
/**
|
27
|
+
* Schedules an update to the message of the spinner. Useful for
|
28
|
+
* changing the message after a certain amount of time has passed.
|
29
|
+
*
|
30
|
+
* @param message The message to display in the spinner
|
31
|
+
* @param delay How long to wait before updating the message
|
32
|
+
* @returns The {@link DelayedSpinner} instance
|
33
|
+
*/
|
34
|
+
scheduleMessageUpdate(message: string, delay: number): this;
|
35
|
+
/**
|
36
|
+
* Stops the spinner and cleans up any scheduled timeouts.
|
37
|
+
*/
|
38
|
+
cleanup(): void;
|
39
|
+
}
|
40
|
+
export declare const SHOULD_SHOW_SPINNERS: boolean;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SHOULD_SHOW_SPINNERS = exports.DelayedSpinner = void 0;
|
4
|
+
const ora = require("ora");
|
5
|
+
/**
|
6
|
+
* A class that allows to delay the creation of a spinner, as well
|
7
|
+
* as schedule updates to the message of the spinner. Useful for
|
8
|
+
* scenarios where one wants to only show a spinner if an operation
|
9
|
+
* takes longer than a certain amount of time.
|
10
|
+
*/
|
11
|
+
class DelayedSpinner {
|
12
|
+
/**
|
13
|
+
* Constructs a new {@link DelayedSpinner} instance.
|
14
|
+
*
|
15
|
+
* @param message The message to display in the spinner
|
16
|
+
* @param ms The number of milliseconds to wait before creating the spinner
|
17
|
+
*/
|
18
|
+
constructor(message, ms = 500) {
|
19
|
+
this.timeouts = [];
|
20
|
+
this.initial = Date.now();
|
21
|
+
this.timeouts.push(setTimeout(() => {
|
22
|
+
this.spinner = ora(message);
|
23
|
+
}, ms).unref());
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Sets the message to display in the spinner.
|
27
|
+
*
|
28
|
+
* @param message The message to display in the spinner
|
29
|
+
* @returns The {@link DelayedSpinner} instance
|
30
|
+
*/
|
31
|
+
setMessage(message) {
|
32
|
+
this.spinner.text = message;
|
33
|
+
return this;
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* Schedules an update to the message of the spinner. Useful for
|
37
|
+
* changing the message after a certain amount of time has passed.
|
38
|
+
*
|
39
|
+
* @param message The message to display in the spinner
|
40
|
+
* @param delay How long to wait before updating the message
|
41
|
+
* @returns The {@link DelayedSpinner} instance
|
42
|
+
*/
|
43
|
+
scheduleMessageUpdate(message, delay) {
|
44
|
+
this.timeouts.push(setTimeout(() => {
|
45
|
+
this.spinner.text = message;
|
46
|
+
}, delay).unref());
|
47
|
+
return this;
|
48
|
+
}
|
49
|
+
/**
|
50
|
+
* Stops the spinner and cleans up any scheduled timeouts.
|
51
|
+
*/
|
52
|
+
cleanup() {
|
53
|
+
this.spinner?.stop();
|
54
|
+
this.timeouts.forEach((t) => clearTimeout(t));
|
55
|
+
}
|
56
|
+
}
|
57
|
+
exports.DelayedSpinner = DelayedSpinner;
|
58
|
+
exports.SHOULD_SHOW_SPINNERS = process.stdout.isTTY;
|
@@ -58,13 +58,17 @@ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
|
|
58
58
|
}
|
59
59
|
let packageManagerCommand;
|
60
60
|
function getMetadataFromPackageJson(packageJson) {
|
61
|
-
const { scripts, nx, description } = packageJson
|
61
|
+
const { scripts, nx, description, name, exports } = packageJson;
|
62
62
|
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
63
63
|
return {
|
64
64
|
targetGroups: {
|
65
65
|
...(includedScripts.length ? { 'NPM Scripts': includedScripts } : {}),
|
66
66
|
},
|
67
67
|
description,
|
68
|
+
js: {
|
69
|
+
packageName: name,
|
70
|
+
packageExports: exports,
|
71
|
+
},
|
68
72
|
};
|
69
73
|
}
|
70
74
|
function getTagsFromPackageJson(packageJson) {
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { PackageManager } from '../../../utils/package-manager';
|
2
|
-
export declare function getPackagesInPackageManagerWorkspace(packageManager: PackageManager): Promise<Set<string>>;
|
3
|
-
export declare function needsInstall(packageManager: PackageManager, originalPackagesInPackageManagerWorkspaces: Set<string>): Promise<boolean>;
|
@@ -1,31 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getPackagesInPackageManagerWorkspace = getPackagesInPackageManagerWorkspace;
|
4
|
-
exports.needsInstall = needsInstall;
|
5
|
-
const package_manager_1 = require("../../../utils/package-manager");
|
6
|
-
const workspace_root_1 = require("../../../utils/workspace-root");
|
7
|
-
const package_json_1 = require("../../../plugins/package-json");
|
8
|
-
const workspace_context_1 = require("../../../utils/workspace-context");
|
9
|
-
async function getPackagesInPackageManagerWorkspace(packageManager) {
|
10
|
-
if (!(0, package_manager_1.isWorkspacesEnabled)(packageManager, workspace_root_1.workspaceRoot)) {
|
11
|
-
return new Set();
|
12
|
-
}
|
13
|
-
const patterns = (0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(workspace_root_1.workspaceRoot);
|
14
|
-
return new Set(await (0, workspace_context_1.globWithWorkspaceContext)(workspace_root_1.workspaceRoot, patterns));
|
15
|
-
}
|
16
|
-
async function needsInstall(packageManager, originalPackagesInPackageManagerWorkspaces) {
|
17
|
-
if (!(0, package_manager_1.isWorkspacesEnabled)(packageManager, workspace_root_1.workspaceRoot)) {
|
18
|
-
return false;
|
19
|
-
}
|
20
|
-
const updatedPackagesInPackageManagerWorkspaces = await getPackagesInPackageManagerWorkspace(packageManager);
|
21
|
-
if (updatedPackagesInPackageManagerWorkspaces.size !==
|
22
|
-
originalPackagesInPackageManagerWorkspaces.size) {
|
23
|
-
return true;
|
24
|
-
}
|
25
|
-
for (const pkg of updatedPackagesInPackageManagerWorkspaces) {
|
26
|
-
if (!originalPackagesInPackageManagerWorkspaces.has(pkg)) {
|
27
|
-
return true;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
return false;
|
31
|
-
}
|