nx 20.0.0-beta.0 → 20.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +2 -1
- package/bin/nx.js +10 -2
- package/package.json +12 -12
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/activate-powerpack/activate-powerpack.js +3 -1
- package/src/command-line/add/add.js +4 -2
- package/src/command-line/connect/view-logs.js +1 -0
- package/src/command-line/exec/exec.js +6 -1
- package/src/command-line/format/format.js +3 -1
- package/src/command-line/graph/graph.js +1 -0
- package/src/command-line/init/implementation/angular/integrated-workspace.js +4 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -2
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +3 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -0
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +3 -1
- package/src/command-line/init/implementation/react/index.js +17 -5
- package/src/command-line/init/implementation/utils.js +5 -1
- package/src/command-line/init/init-v1.js +1 -0
- package/src/command-line/init/init-v2.js +2 -1
- package/src/command-line/migrate/command-object.js +4 -0
- package/src/command-line/migrate/migrate.js +1 -1
- package/src/command-line/release/config/version-plans.js +3 -1
- package/src/command-line/release/utils/exec-command.js +1 -0
- package/src/command-line/release/utils/github.js +1 -0
- package/src/command-line/release/utils/launch-editor.js +6 -1
- package/src/command-line/release/version.js +1 -0
- package/src/command-line/report/report.d.ts +3 -1
- package/src/command-line/report/report.js +17 -2
- package/src/command-line/run/run.js +1 -0
- package/src/command-line/sync/sync.js +5 -4
- package/src/command-line/watch/watch.js +1 -0
- package/src/config/nx-json.d.ts +4 -0
- package/src/daemon/client/client.d.ts +4 -1
- package/src/daemon/client/generate-help-output.js +1 -0
- package/src/daemon/server/sync-generators.d.ts +4 -1
- package/src/daemon/server/sync-generators.js +33 -15
- package/src/executors/run-commands/run-commands.impl.js +1 -0
- package/src/executors/run-script/run-script.impl.js +1 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/project-graph/file-utils.js +1 -0
- package/src/tasks-runner/cache.d.ts +3 -1
- package/src/tasks-runner/cache.js +12 -13
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.d.ts +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.js +27 -15
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +3 -0
- package/src/tasks-runner/task-orchestrator.d.ts +3 -1
- package/src/tasks-runner/task-orchestrator.js +3 -2
- package/src/tasks-runner/tasks-schedule.js +1 -1
- package/src/utils/ab-testing.js +4 -1
- package/src/utils/child-process.js +5 -3
- package/src/utils/command-line-utils.js +7 -1
- package/src/utils/default-base.js +5 -2
- package/src/utils/git-utils.index-filter.js +2 -1
- package/src/utils/git-utils.js +4 -0
- package/src/utils/git-utils.tree-filter.js +3 -1
- package/src/utils/powerpack.d.ts +1 -1
- package/src/utils/powerpack.js +3 -8
- package/src/utils/sync-generators.d.ts +13 -3
- package/src/utils/sync-generators.js +99 -25
- package/src/utils/task-history.d.ts +2 -2
- package/src/utils/task-history.js +4 -1
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SyncError = void 0;
|
3
4
|
exports.getSyncGeneratorChanges = getSyncGeneratorChanges;
|
4
5
|
exports.flushSyncGeneratorChanges = flushSyncGeneratorChanges;
|
5
6
|
exports.collectAllRegisteredSyncGenerators = collectAllRegisteredSyncGenerators;
|
@@ -22,6 +23,15 @@ const project_graph_1 = require("../project-graph/project-graph");
|
|
22
23
|
const workspace_context_1 = require("./workspace-context");
|
23
24
|
const workspace_root_1 = require("./workspace-root");
|
24
25
|
const chalk = require("chalk");
|
26
|
+
class SyncError extends Error {
|
27
|
+
constructor(title, bodyLines) {
|
28
|
+
super(title);
|
29
|
+
this.title = title;
|
30
|
+
this.bodyLines = bodyLines;
|
31
|
+
this.name = this.constructor.name;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
exports.SyncError = SyncError;
|
25
35
|
async function getSyncGeneratorChanges(generators) {
|
26
36
|
perf_hooks_1.performance.mark('get-sync-generators-changes:start');
|
27
37
|
let results;
|
@@ -43,10 +53,12 @@ async function flushSyncGeneratorChanges(results) {
|
|
43
53
|
}
|
44
54
|
async function collectAllRegisteredSyncGenerators(projectGraph, nxJson) {
|
45
55
|
if (!client_1.daemonClient.enabled()) {
|
46
|
-
return
|
47
|
-
...
|
48
|
-
|
49
|
-
|
56
|
+
return {
|
57
|
+
globalGenerators: [...collectRegisteredGlobalSyncGenerators()],
|
58
|
+
taskGenerators: [
|
59
|
+
...collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph, nxJson),
|
60
|
+
],
|
61
|
+
};
|
50
62
|
}
|
51
63
|
return await client_1.daemonClient.getRegisteredSyncGenerators();
|
52
64
|
}
|
@@ -75,7 +87,7 @@ async function runSyncGenerator(tree, generatorSpecifier, projects) {
|
|
75
87
|
catch (e) {
|
76
88
|
return {
|
77
89
|
generatorName: generatorSpecifier,
|
78
|
-
error:
|
90
|
+
error: toSerializableError(e),
|
79
91
|
};
|
80
92
|
}
|
81
93
|
}
|
@@ -140,28 +152,48 @@ function getSyncGeneratorSuccessResultsMessageLines(results) {
|
|
140
152
|
}
|
141
153
|
return messageLines;
|
142
154
|
}
|
143
|
-
function getFailedSyncGeneratorsFixMessageLines(results, verbose) {
|
155
|
+
function getFailedSyncGeneratorsFixMessageLines(results, verbose, globalGeneratorSet = new Set()) {
|
144
156
|
const messageLines = [];
|
145
|
-
const
|
157
|
+
const globalGenerators = [];
|
158
|
+
const taskGenerators = [];
|
159
|
+
let isFirst = true;
|
146
160
|
for (const result of results) {
|
147
161
|
if ('error' in result) {
|
148
|
-
|
149
|
-
|
150
|
-
|
162
|
+
if (!isFirst) {
|
163
|
+
messageLines.push('');
|
164
|
+
}
|
165
|
+
isFirst = false;
|
166
|
+
messageLines.push(`The ${chalk.bold(result.generatorName)} sync generator reported the following error:`, '', errorToString(result.error, verbose));
|
167
|
+
if (globalGeneratorSet.has(result.generatorName)) {
|
168
|
+
globalGenerators.push(result.generatorName);
|
169
|
+
}
|
170
|
+
else {
|
171
|
+
taskGenerators.push(result.generatorName);
|
172
|
+
}
|
151
173
|
}
|
152
174
|
}
|
153
|
-
messageLines.push(...getFailedSyncGeneratorsMessageLines(
|
175
|
+
messageLines.push(...getFailedSyncGeneratorsMessageLines(taskGenerators, globalGenerators, verbose));
|
154
176
|
return messageLines;
|
155
177
|
}
|
156
|
-
function getFlushFailureMessageLines(result, verbose) {
|
178
|
+
function getFlushFailureMessageLines(result, verbose, globalGeneratorSet = new Set()) {
|
157
179
|
const messageLines = [];
|
158
|
-
const
|
180
|
+
const globalGenerators = [];
|
181
|
+
const taskGenerators = [];
|
182
|
+
let isFirst = true;
|
159
183
|
for (const failure of result.generatorFailures) {
|
160
|
-
|
161
|
-
|
162
|
-
|
184
|
+
if (!isFirst) {
|
185
|
+
messageLines.push('');
|
186
|
+
}
|
187
|
+
isFirst = false;
|
188
|
+
messageLines.push(`The ${chalk.bold(failure.generator)} sync generator failed to apply its changes with the following error:`, '', errorToString(failure.error, verbose));
|
189
|
+
if (globalGeneratorSet.has(failure.generator)) {
|
190
|
+
globalGenerators.push(failure.generator);
|
191
|
+
}
|
192
|
+
else {
|
193
|
+
taskGenerators.push(failure.generator);
|
194
|
+
}
|
163
195
|
}
|
164
|
-
messageLines.push(...getFailedSyncGeneratorsMessageLines(
|
196
|
+
messageLines.push(...getFailedSyncGeneratorsMessageLines(taskGenerators, globalGenerators, verbose));
|
165
197
|
if (result.generalFailure) {
|
166
198
|
if (messageLines.length > 0) {
|
167
199
|
messageLines.push('');
|
@@ -242,7 +274,7 @@ async function flushSyncGeneratorChangesToDisk(results) {
|
|
242
274
|
catch (e) {
|
243
275
|
generatorFailures.push({
|
244
276
|
generator: result.generatorName,
|
245
|
-
error:
|
277
|
+
error: toSerializableError(e),
|
246
278
|
});
|
247
279
|
}
|
248
280
|
}
|
@@ -255,25 +287,67 @@ async function flushSyncGeneratorChangesToDisk(results) {
|
|
255
287
|
catch (e) {
|
256
288
|
return {
|
257
289
|
generatorFailures,
|
258
|
-
generalFailure:
|
290
|
+
generalFailure: toSerializableError(e),
|
259
291
|
};
|
260
292
|
}
|
261
293
|
return generatorFailures.length > 0
|
262
294
|
? { generatorFailures }
|
263
295
|
: { success: true };
|
264
296
|
}
|
265
|
-
function getFailedSyncGeneratorsMessageLines(
|
297
|
+
function getFailedSyncGeneratorsMessageLines(taskGenerators, globalGenerators, verbose) {
|
266
298
|
const messageLines = [];
|
267
|
-
if (
|
299
|
+
if (taskGenerators.length + globalGenerators.length === 1) {
|
268
300
|
messageLines.push('', verbose
|
269
301
|
? 'Please check the error above and address the issue.'
|
270
|
-
: 'Please check the error above and address the issue. You can provide the `--verbose` flag to get more details.'
|
302
|
+
: 'Please check the error above and address the issue. You can provide the `--verbose` flag to get more details.');
|
303
|
+
if (taskGenerators.length === 1) {
|
304
|
+
messageLines.push(`If needed, you can disable the failing sync generator by setting \`sync.disabledTaskSyncGenerators: ["${taskGenerators[0]}"]\` in your \`nx.json\`.`);
|
305
|
+
}
|
306
|
+
else {
|
307
|
+
messageLines.push(`If needed, you can remove the failing global sync generator "${globalGenerators[0]}" from the \`sync.globalGenerators\` array in your \`nx.json\`.`);
|
308
|
+
}
|
271
309
|
}
|
272
|
-
else if (
|
273
|
-
const generatorsString = generators.map((g) => `"${g}"`).join(', ');
|
310
|
+
else if (taskGenerators.length + globalGenerators.length > 1) {
|
274
311
|
messageLines.push('', verbose
|
275
312
|
? 'Please check the errors above and address the issues.'
|
276
|
-
: 'Please check the errors above and address the issues. You can provide the `--verbose` flag to get more details.'
|
313
|
+
: 'Please check the errors above and address the issues. You can provide the `--verbose` flag to get more details.');
|
314
|
+
if (taskGenerators.length > 0) {
|
315
|
+
const generatorsString = taskGenerators.map((g) => `"${g}"`).join(', ');
|
316
|
+
messageLines.push(`If needed, you can disable the failing task sync generators by setting \`sync.disabledTaskSyncGenerators: [${generatorsString}]\` in your \`nx.json\`.`);
|
317
|
+
}
|
318
|
+
if (globalGenerators.length > 0) {
|
319
|
+
const lastGenerator = globalGenerators.pop();
|
320
|
+
const generatorsString = globalGenerators.length > 0
|
321
|
+
? `${globalGenerators
|
322
|
+
.map((g) => `"${g}"`)
|
323
|
+
.join(', ')} and "${lastGenerator}"`
|
324
|
+
: `"${lastGenerator}"`;
|
325
|
+
messageLines.push(`If needed, you can remove the failing global sync generators ${generatorsString} from the \`sync.globalGenerators\` array in your \`nx.json\`.`);
|
326
|
+
}
|
277
327
|
}
|
278
328
|
return messageLines;
|
279
329
|
}
|
330
|
+
function errorToString(error, verbose) {
|
331
|
+
if (error.title) {
|
332
|
+
let message = ` ${chalk.red(error.title)}`;
|
333
|
+
if (error.bodyLines?.length) {
|
334
|
+
message += `
|
335
|
+
|
336
|
+
${error.bodyLines
|
337
|
+
.map((bodyLine) => `${bodyLine.split('\n').join('\n ')}`)
|
338
|
+
.join('\n ')}`;
|
339
|
+
return message;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
return ` ${chalk.red(error.message)}${verbose && error.stack ? '\n ' + error.stack : ''}`;
|
343
|
+
}
|
344
|
+
function toSerializableError(error) {
|
345
|
+
return error instanceof SyncError
|
346
|
+
? {
|
347
|
+
title: error.title,
|
348
|
+
bodyLines: error.bodyLines,
|
349
|
+
message: error.message,
|
350
|
+
stack: error.stack,
|
351
|
+
}
|
352
|
+
: { message: error.message, stack: error.stack };
|
353
|
+
}
|
@@ -12,6 +12,6 @@ export declare class TaskHistory {
|
|
12
12
|
}
|
13
13
|
/**
|
14
14
|
* This function returns the singleton instance of TaskHistory
|
15
|
-
* @returns singleton instance of TaskHistory
|
15
|
+
* @returns singleton instance of TaskHistory, null if database is disabled or WASM is not enabled
|
16
16
|
*/
|
17
|
-
export declare function getTaskHistory(): TaskHistory;
|
17
|
+
export declare function getTaskHistory(): TaskHistory | null;
|
@@ -38,9 +38,12 @@ exports.TaskHistory = TaskHistory;
|
|
38
38
|
let taskHistory;
|
39
39
|
/**
|
40
40
|
* This function returns the singleton instance of TaskHistory
|
41
|
-
* @returns singleton instance of TaskHistory
|
41
|
+
* @returns singleton instance of TaskHistory, null if database is disabled or WASM is not enabled
|
42
42
|
*/
|
43
43
|
function getTaskHistory() {
|
44
|
+
if (process.env.NX_DISABLE_DB === 'true' || !native_1.IS_WASM) {
|
45
|
+
return null;
|
46
|
+
}
|
44
47
|
if (!taskHistory) {
|
45
48
|
taskHistory = new TaskHistory();
|
46
49
|
}
|