nx 20.1.0-canary.20241108-6882ad1 → 20.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -11
- package/src/command-line/generate/command-object.js +1 -2
- package/src/command-line/generate/generate.d.ts +1 -1
- package/src/command-line/generate/generate.js +3 -1
- package/src/command-line/init/command-object.js +8 -4
- package/src/command-line/migrate/command-object.js +2 -96
- package/src/command-line/migrate/migrate.d.ts +1 -0
- package/src/command-line/migrate/migrate.js +89 -0
- package/src/command-line/release/command-object.js +3 -5
- package/src/command-line/release/utils/git.js +25 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +3 -0
- package/src/command-line/yargs-utils/shared-options.js +19 -0
- package/src/core/graph/main.js +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/project-graph/error-types.d.ts +1 -1
- package/src/project-graph/plugins/internal-api.d.ts +0 -4
- package/src/project-graph/plugins/internal-api.js +1 -6
- package/src/project-graph/plugins/isolation/messaging.d.ts +1 -5
- package/src/project-graph/plugins/isolation/plugin-pool.js +0 -22
- package/src/project-graph/plugins/isolation/plugin-worker.js +16 -15
- package/src/tasks-runner/create-task-graph.js +1 -1
- package/src/tasks-runner/run-command.js +2 -2
- package/src/utils/assert-workspace-validity.js +4 -0
- package/src/utils/command-line-utils.d.ts +0 -3
- package/src/utils/command-line-utils.js +2 -20
- package/src/utils/find-matching-projects.js +2 -1
- package/src/utils/handle-errors.js +3 -3
Binary file
|
@@ -18,7 +18,7 @@ export declare class ProjectGraphError extends Error {
|
|
18
18
|
*/
|
19
19
|
getPartialProjectGraph(): ProjectGraph;
|
20
20
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
21
|
-
getErrors(): (AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError |
|
21
|
+
getErrors(): (AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | CreateMetadataError | WorkspaceValidityError)[];
|
22
22
|
}
|
23
23
|
export declare class MultipleProjectsWithSameNameError extends Error {
|
24
24
|
conflicts: Map<string, string[]>;
|
@@ -18,9 +18,5 @@ export type CreateNodesResultWithContext = CreateNodesResult & {
|
|
18
18
|
file: string;
|
19
19
|
pluginName: string;
|
20
20
|
};
|
21
|
-
export declare const nxPluginCache: Map<unknown, [
|
22
|
-
Promise<LoadedNxPlugin>,
|
23
|
-
() => void
|
24
|
-
]>;
|
25
21
|
export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<readonly [LoadedNxPlugin[], () => void]>;
|
26
22
|
export declare function getDefaultPlugins(root: string): Promise<string[]>;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
// This file contains the bits and bobs of the internal API for loading and interacting with Nx plugins.
|
3
3
|
// For the public API, used by plugin authors, see `./public-api.ts`.
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
-
exports.
|
5
|
+
exports.LoadedNxPlugin = void 0;
|
6
6
|
exports.loadNxPlugins = loadNxPlugins;
|
7
7
|
exports.getDefaultPlugins = getDefaultPlugins;
|
8
8
|
const path_1 = require("path");
|
@@ -65,11 +65,6 @@ class LoadedNxPlugin {
|
|
65
65
|
}
|
66
66
|
}
|
67
67
|
exports.LoadedNxPlugin = LoadedNxPlugin;
|
68
|
-
// Short lived cache (cleared between cmd runs)
|
69
|
-
// holding resolved nx plugin objects.
|
70
|
-
// Allows loaded plugins to not be reloaded when
|
71
|
-
// referenced multiple times.
|
72
|
-
exports.nxPluginCache = new Map();
|
73
68
|
function isIsolationEnabled() {
|
74
69
|
// Explicitly enabled, regardless of further conditions
|
75
70
|
if (process.env.NX_ISOLATE_PLUGINS === 'true') {
|
@@ -86,11 +86,7 @@ export interface PluginCreateMetadataResult {
|
|
86
86
|
tx: string;
|
87
87
|
};
|
88
88
|
}
|
89
|
-
export
|
90
|
-
type: 'shutdown';
|
91
|
-
payload: {};
|
92
|
-
}
|
93
|
-
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerShutdownMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginCreateMetadataMessage;
|
89
|
+
export type PluginWorkerMessage = PluginWorkerLoadMessage | PluginWorkerCreateNodesMessage | PluginCreateDependenciesMessage | PluginCreateMetadataMessage;
|
94
90
|
export type PluginWorkerResult = PluginWorkerLoadResult | PluginWorkerCreateNodesResult | PluginCreateDependenciesResult | PluginCreateMetadataResult;
|
95
91
|
export declare function isPluginWorkerMessage(message: Serializable): message is PluginWorkerMessage;
|
96
92
|
export declare function isPluginWorkerResult(message: Serializable): message is PluginWorkerResult;
|
@@ -4,12 +4,8 @@ exports.loadRemoteNxPlugin = loadRemoteNxPlugin;
|
|
4
4
|
const child_process_1 = require("child_process");
|
5
5
|
const path = require("path");
|
6
6
|
const net_1 = require("net");
|
7
|
-
// TODO (@AgentEnder): After scoped verbose logging is implemented, re-add verbose logs here.
|
8
|
-
// import { logger } from '../../utils/logger';
|
9
|
-
const internal_api_1 = require("../internal-api");
|
10
7
|
const socket_utils_1 = require("../../../daemon/socket-utils");
|
11
8
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
12
|
-
const exit_codes_1 = require("../../../utils/exit-codes");
|
13
9
|
const messaging_1 = require("./messaging");
|
14
10
|
const cleanupFunctions = new Set();
|
15
11
|
const pluginNames = new Map();
|
@@ -29,7 +25,6 @@ async function loadRemoteNxPlugin(plugin, root) {
|
|
29
25
|
const exitHandler = createWorkerExitHandler(worker, pendingPromises);
|
30
26
|
const cleanupFunction = () => {
|
31
27
|
worker.off('exit', exitHandler);
|
32
|
-
shutdownPluginWorker(socket);
|
33
28
|
socket.destroy();
|
34
29
|
nxPluginWorkerCache.delete(cacheKey);
|
35
30
|
};
|
@@ -55,9 +50,6 @@ async function loadRemoteNxPlugin(plugin, root) {
|
|
55
50
|
nxPluginWorkerCache.set(cacheKey, pluginPromise);
|
56
51
|
return [pluginPromise, cleanupFunction];
|
57
52
|
}
|
58
|
-
function shutdownPluginWorker(socket) {
|
59
|
-
(0, messaging_1.sendMessageOverSocket)(socket, { type: 'shutdown', payload: {} });
|
60
|
-
}
|
61
53
|
/**
|
62
54
|
* Creates a message handler for the given worker.
|
63
55
|
* @param worker Instance of plugin-worker
|
@@ -172,20 +164,6 @@ function createWorkerExitHandler(worker, pendingPromises) {
|
|
172
164
|
}
|
173
165
|
};
|
174
166
|
}
|
175
|
-
let cleanedUp = false;
|
176
|
-
const exitHandler = () => {
|
177
|
-
internal_api_1.nxPluginCache.clear();
|
178
|
-
for (const fn of cleanupFunctions) {
|
179
|
-
fn();
|
180
|
-
}
|
181
|
-
cleanedUp = true;
|
182
|
-
};
|
183
|
-
process.on('exit', exitHandler);
|
184
|
-
process.on('SIGINT', () => {
|
185
|
-
exitHandler();
|
186
|
-
process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
|
187
|
-
});
|
188
|
-
process.on('SIGTERM', exitHandler);
|
189
167
|
function registerPendingPromise(tx, pending, callback, context) {
|
190
168
|
let resolver, rejector, timeout;
|
191
169
|
const promise = new Promise((res, rej) => {
|
@@ -49,21 +49,6 @@ const server = (0, net_1.createServer)((socket) => {
|
|
49
49
|
};
|
50
50
|
}
|
51
51
|
},
|
52
|
-
shutdown: async () => {
|
53
|
-
// Stops accepting new connections, but existing connections are
|
54
|
-
// not closed immediately.
|
55
|
-
server.close(() => {
|
56
|
-
try {
|
57
|
-
(0, fs_1.unlinkSync)(socketPath);
|
58
|
-
}
|
59
|
-
catch (e) { }
|
60
|
-
process.exit(0);
|
61
|
-
});
|
62
|
-
// Closes existing connection.
|
63
|
-
socket.end();
|
64
|
-
// Destroys the socket once it's fully closed.
|
65
|
-
socket.destroySoon();
|
66
|
-
},
|
67
52
|
createNodes: async ({ configFiles, context, tx }) => {
|
68
53
|
try {
|
69
54
|
const result = await plugin.createNodes[1](configFiles, context);
|
@@ -123,6 +108,22 @@ const server = (0, net_1.createServer)((socket) => {
|
|
123
108
|
},
|
124
109
|
});
|
125
110
|
}));
|
111
|
+
// There should only ever be one host -> worker connection
|
112
|
+
// since the worker is spawned per host process. As such,
|
113
|
+
// we can safely close the worker when the host disconnects.
|
114
|
+
socket.on('end', () => {
|
115
|
+
// Stops accepting new connections, but existing connections are
|
116
|
+
// not closed immediately.
|
117
|
+
server.close(() => {
|
118
|
+
try {
|
119
|
+
(0, fs_1.unlinkSync)(socketPath);
|
120
|
+
}
|
121
|
+
catch (e) { }
|
122
|
+
process.exit(0);
|
123
|
+
});
|
124
|
+
// Destroys the socket once it's fully closed.
|
125
|
+
socket.destroySoon();
|
126
|
+
});
|
126
127
|
});
|
127
128
|
server.listen(socketPath);
|
128
129
|
const exitHandler = (exitCode) => () => {
|
@@ -140,7 +140,7 @@ class ProcessTasks {
|
|
140
140
|
}
|
141
141
|
}
|
142
142
|
else {
|
143
|
-
const dummyId = this.getId(depProject.name, DUMMY_TASK_TARGET, undefined);
|
143
|
+
const dummyId = this.getId(depProject.name, task.target.target + DUMMY_TASK_TARGET, undefined);
|
144
144
|
this.dependencies[task.id].push(dummyId);
|
145
145
|
this.dependencies[dummyId] ??= [];
|
146
146
|
const noopTask = this.createDummyTask(dummyId, task);
|
@@ -298,7 +298,7 @@ async function promptForApplyingSyncGeneratorChanges() {
|
|
298
298
|
try {
|
299
299
|
const promptConfig = {
|
300
300
|
name: 'applyChanges',
|
301
|
-
type: '
|
301
|
+
type: 'autocomplete',
|
302
302
|
message: 'Would you like to sync the identified changes to get your workspace up to date?',
|
303
303
|
choices: [
|
304
304
|
{
|
@@ -322,7 +322,7 @@ async function confirmRunningTasksWithSyncFailures() {
|
|
322
322
|
try {
|
323
323
|
const promptConfig = {
|
324
324
|
name: 'runTasks',
|
325
|
-
type: '
|
325
|
+
type: 'autocomplete',
|
326
326
|
message: 'Would you like to ignore the sync failures and continue running the tasks?',
|
327
327
|
choices: [
|
328
328
|
{
|
@@ -75,6 +75,10 @@ function detectAndSetInvalidProjectGlobValues(map, sourceName, desiredImplicitDe
|
|
75
75
|
const projectName = implicit.startsWith('!')
|
76
76
|
? implicit.substring(1)
|
77
77
|
: implicit;
|
78
|
+
// Do not error on cross-workspace implicit dependency references
|
79
|
+
if (projectName.startsWith('nx-cloud:')) {
|
80
|
+
return false;
|
81
|
+
}
|
78
82
|
return !(projectConfigurations[projectName] ||
|
79
83
|
(0, find_matching_projects_1.findMatchingProjects)([implicit], projects).length);
|
80
84
|
});
|
@@ -48,9 +48,6 @@ export declare function splitArgsIntoNxArgsAndOverrides(args: {
|
|
48
48
|
__overrides_unparsed__: string[];
|
49
49
|
};
|
50
50
|
};
|
51
|
-
export declare function readParallelFromArgsAndEnv(args: {
|
52
|
-
[k: string]: any;
|
53
|
-
}): number;
|
54
51
|
export declare function parseFiles(options: NxArgs): {
|
55
52
|
files: string[];
|
56
53
|
};
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createOverrides = createOverrides;
|
4
4
|
exports.getBaseRef = getBaseRef;
|
5
5
|
exports.splitArgsIntoNxArgsAndOverrides = splitArgsIntoNxArgsAndOverrides;
|
6
|
-
exports.readParallelFromArgsAndEnv = readParallelFromArgsAndEnv;
|
7
6
|
exports.parseFiles = parseFiles;
|
8
7
|
exports.getProjectRoots = getProjectRoots;
|
9
8
|
exports.readGraphFileFromGraphArg = readGraphFileFromGraphArg;
|
@@ -12,6 +11,7 @@ const file_utils_1 = require("../project-graph/file-utils");
|
|
12
11
|
const output_1 = require("./output");
|
13
12
|
const child_process_1 = require("child_process");
|
14
13
|
const workspace_root_1 = require("./workspace-root");
|
14
|
+
const shared_options_1 = require("../command-line/yargs-utils/shared-options");
|
15
15
|
function createOverrides(__overrides_unparsed__ = []) {
|
16
16
|
let overrides = yargsParser(__overrides_unparsed__, {
|
17
17
|
configuration: {
|
@@ -116,27 +116,9 @@ function splitArgsIntoNxArgsAndOverrides(args, mode, options = { printWarnings:
|
|
116
116
|
nxArgs.skipNxCache = process.env.NX_SKIP_NX_CACHE === 'true';
|
117
117
|
}
|
118
118
|
normalizeNxArgsRunner(nxArgs, nxJson, options);
|
119
|
-
nxArgs['parallel'] = readParallelFromArgsAndEnv(args);
|
119
|
+
nxArgs['parallel'] = (0, shared_options_1.readParallelFromArgsAndEnv)(args);
|
120
120
|
return { nxArgs, overrides };
|
121
121
|
}
|
122
|
-
function readParallelFromArgsAndEnv(args) {
|
123
|
-
if (args['parallel'] === 'false' || args['parallel'] === false) {
|
124
|
-
return 1;
|
125
|
-
}
|
126
|
-
else if (args['parallel'] === 'true' ||
|
127
|
-
args['parallel'] === true ||
|
128
|
-
args['parallel'] === '' ||
|
129
|
-
// dont require passing --parallel if NX_PARALLEL is set, but allow overriding it
|
130
|
-
(process.env.NX_PARALLEL && args['parallel'] === undefined)) {
|
131
|
-
return Number(args['maxParallel'] ||
|
132
|
-
args['max-parallel'] ||
|
133
|
-
process.env.NX_PARALLEL ||
|
134
|
-
3);
|
135
|
-
}
|
136
|
-
else if (args['parallel'] !== undefined) {
|
137
|
-
return Number(args['parallel']);
|
138
|
-
}
|
139
|
-
}
|
140
122
|
function normalizeNxArgsRunner(nxArgs, nxJson, options) {
|
141
123
|
if (!nxArgs.runner) {
|
142
124
|
const envKey = 'NX_TASKS_RUNNER';
|
@@ -33,7 +33,8 @@ function findMatchingProjects(patterns = [], projects) {
|
|
33
33
|
patterns.unshift('*');
|
34
34
|
}
|
35
35
|
for (const stringPattern of patterns) {
|
36
|
-
|
36
|
+
// Do not waste time attempting to look up cross-workspace references which will never match
|
37
|
+
if (!stringPattern.length || stringPattern.startsWith('nx-cloud:')) {
|
37
38
|
continue;
|
38
39
|
}
|
39
40
|
const pattern = parseStringPattern(stringPattern, projects);
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.handleErrors = handleErrors;
|
4
|
-
const client_1 = require("../daemon/client/client");
|
5
4
|
const logger_1 = require("./logger");
|
6
5
|
const output_1 = require("./output");
|
7
6
|
async function handleErrors(isVerbose, fn) {
|
@@ -50,8 +49,9 @@ async function handleErrors(isVerbose, fn) {
|
|
50
49
|
bodyLines,
|
51
50
|
});
|
52
51
|
}
|
53
|
-
|
54
|
-
|
52
|
+
const { daemonClient } = await Promise.resolve().then(() => require('../daemon/client/client'));
|
53
|
+
if (daemonClient.enabled()) {
|
54
|
+
daemonClient.reset();
|
55
55
|
}
|
56
56
|
return 1;
|
57
57
|
}
|