nx 18.1.0-canary.20240220-003b961 → 18.1.0-canary.20240221-abc0cf8
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/command-line/migrate/command-object.js +17 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/plugins/target-defaults/target-defaults-plugin.js +4 -8
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +20 -23
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +16 -16
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +1 -1
- package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
- package/src/utils/logger.js +1 -1
- package/src/utils/output.d.ts +0 -1
- package/src/utils/output.js +6 -7
- package/src/utils/package-json.d.ts +1 -1
- package/src/utils/package-json.js +10 -9
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3],{22232:(s,e,k)=>{k.r(e)}},s=>{var e;e=22232,s(s.s=e)}]);
|
@@ -6,6 +6,7 @@ const node_fs_1 = require("node:fs");
|
|
6
6
|
const node_path_1 = require("node:path");
|
7
7
|
const fileutils_1 = require("../../utils/fileutils");
|
8
8
|
const globs_1 = require("../../utils/globs");
|
9
|
+
const package_json_1 = require("../../utils/package-json");
|
9
10
|
const package_json_workspaces_1 = require("../package-json-workspaces");
|
10
11
|
/**
|
11
12
|
* This symbol marks that a target provides information which should modify a target already registered
|
@@ -37,16 +38,11 @@ exports.TargetDefaultsPlugin = {
|
|
37
38
|
}
|
38
39
|
const projectJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'));
|
39
40
|
const packageJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'package.json'));
|
40
|
-
const includedScripts = packageJson?.nx?.includedScripts;
|
41
41
|
const projectDefinedTargets = new Set([
|
42
|
-
...Object.keys(packageJson?.scripts ?? {}).filter((script) => {
|
43
|
-
if (includedScripts) {
|
44
|
-
return includedScripts.includes(script);
|
45
|
-
}
|
46
|
-
return true;
|
47
|
-
}),
|
48
42
|
...Object.keys(projectJson?.targets ?? {}),
|
49
|
-
...
|
43
|
+
...(packageJson
|
44
|
+
? Object.keys((0, package_json_1.readTargetsFromPackageJson)(packageJson))
|
45
|
+
: []),
|
50
46
|
]);
|
51
47
|
const executorToTargetMap = getExecutorToTargetMap(packageJson, projectJson);
|
52
48
|
const modifiedTargets = {};
|
@@ -9,6 +9,8 @@ const output_1 = require("../../utils/output");
|
|
9
9
|
const pretty_time_1 = require("./pretty-time");
|
10
10
|
const formatting_utils_1 = require("./formatting-utils");
|
11
11
|
const view_logs_utils_1 = require("./view-logs-utils");
|
12
|
+
const LEFT_PAD = ` `;
|
13
|
+
const EXTENDED_LEFT_PAD = ` `;
|
12
14
|
/**
|
13
15
|
* The following function is responsible for creating a life cycle with dynamic
|
14
16
|
* outputs, meaning previous outputs can be rewritten or modified as new outputs
|
@@ -74,7 +76,7 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
74
76
|
// Create vertical breathing room for cursor position under the pinned footer
|
75
77
|
lines.push('');
|
76
78
|
for (const line of lines) {
|
77
|
-
output_1.output.overwriteLine(
|
79
|
+
output_1.output.overwriteLine(line);
|
78
80
|
}
|
79
81
|
pinnedFooterNumLines = lines.length + additionalLines;
|
80
82
|
// clear any possible text below the cursor's position
|
@@ -143,10 +145,10 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
143
145
|
const runningTasks = taskRows.filter((row) => row.status === 'running');
|
144
146
|
const remainingTasks = totalTasks - totalCompletedTasks;
|
145
147
|
if (runningTasks.length > 0) {
|
146
|
-
additionalFooterRows.push(output_1.output.dim(
|
148
|
+
additionalFooterRows.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.colors.cyan(figures.arrowRight)} Executing ${runningTasks.length}/${remainingTasks} remaining tasks${runningTasks.length > 1 ? ' in parallel' : ''}...`));
|
147
149
|
additionalFooterRows.push('');
|
148
150
|
for (const runningTask of runningTasks) {
|
149
|
-
additionalFooterRows.push(
|
151
|
+
additionalFooterRows.push(`${LEFT_PAD}${output_1.output.dim.cyan(cli_spinners_1.dots.frames[currentFrame])} ${output_1.output.formatCommand(runningTask.task.id)}`);
|
150
152
|
}
|
151
153
|
/**
|
152
154
|
* Reduce layout thrashing by ensuring that there is a relatively consistent
|
@@ -170,21 +172,20 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
170
172
|
additionalFooterRows.push('');
|
171
173
|
}
|
172
174
|
if (totalSuccessfulTasks > 0) {
|
173
|
-
additionalFooterRows.push(
|
175
|
+
additionalFooterRows.push(`${LEFT_PAD}${output_1.output.colors.green(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`);
|
174
176
|
}
|
175
177
|
if (totalFailedTasks > 0) {
|
176
|
-
additionalFooterRows.push(
|
178
|
+
additionalFooterRows.push(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`);
|
177
179
|
}
|
178
180
|
moveCursorToStartOfPinnedFooter();
|
179
181
|
if (additionalFooterRows.length > 1) {
|
180
182
|
const text = `Running ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
181
183
|
const taskOverridesRows = [];
|
182
184
|
if (Object.keys(overrides).length > 0) {
|
183
|
-
const leftPadding = `${output_1.output.X_PADDING} `;
|
184
185
|
taskOverridesRows.push('');
|
185
|
-
taskOverridesRows.push(`${
|
186
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.cyan('With additional flags:')}`);
|
186
187
|
Object.entries(overrides)
|
187
|
-
.map(([flag, value]) => output_1.output.dim.cyan((0, formatting_utils_1.formatFlags)(
|
188
|
+
.map(([flag, value]) => output_1.output.dim.cyan((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
188
189
|
.forEach((arg) => taskOverridesRows.push(arg));
|
189
190
|
}
|
190
191
|
const pinnedFooterLines = [
|
@@ -221,11 +222,10 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
221
222
|
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
222
223
|
const taskOverridesRows = [];
|
223
224
|
if (Object.keys(overrides).length > 0) {
|
224
|
-
const leftPadding = `${output_1.output.X_PADDING} `;
|
225
225
|
taskOverridesRows.push('');
|
226
|
-
taskOverridesRows.push(`${
|
226
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
227
227
|
Object.entries(overrides)
|
228
|
-
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(
|
228
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
229
229
|
.forEach((arg) => taskOverridesRows.push(arg));
|
230
230
|
}
|
231
231
|
const pinnedFooterLines = [
|
@@ -233,7 +233,7 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
233
233
|
...taskOverridesRows,
|
234
234
|
];
|
235
235
|
if (totalCachedTasks > 0) {
|
236
|
-
pinnedFooterLines.push(output_1.output.dim(`${os_1.EOL}
|
236
|
+
pinnedFooterLines.push(output_1.output.dim(`${os_1.EOL}Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
|
237
237
|
}
|
238
238
|
renderPinnedFooter(pinnedFooterLines, 'green');
|
239
239
|
}
|
@@ -241,11 +241,10 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
241
241
|
const text = `Ran ${(0, formatting_utils_1.formatTargetsAndProjects)(projectNames, targets, tasks)}`;
|
242
242
|
const taskOverridesRows = [];
|
243
243
|
if (Object.keys(overrides).length > 0) {
|
244
|
-
const leftPadding = `${output_1.output.X_PADDING} `;
|
245
244
|
taskOverridesRows.push('');
|
246
|
-
taskOverridesRows.push(`${
|
245
|
+
taskOverridesRows.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
247
246
|
Object.entries(overrides)
|
248
|
-
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(
|
247
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
249
248
|
.forEach((arg) => taskOverridesRows.push(arg));
|
250
249
|
}
|
251
250
|
const numFailedToPrint = 5;
|
@@ -254,15 +253,15 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
254
253
|
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim.white(` (${timeTakenText})`)),
|
255
254
|
...taskOverridesRows,
|
256
255
|
'',
|
257
|
-
output_1.output.dim(
|
256
|
+
output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`),
|
258
257
|
'',
|
259
|
-
|
258
|
+
`${LEFT_PAD}${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`,
|
260
259
|
`${failedTasksForPrinting
|
261
|
-
.map((t) =>
|
260
|
+
.map((t) => `${EXTENDED_LEFT_PAD}${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
|
262
261
|
.join('\n ')}`,
|
263
262
|
];
|
264
263
|
if (failedTasks.size > numFailedToPrint) {
|
265
|
-
failureSummaryRows.push(output_1.output.dim(
|
264
|
+
failureSummaryRows.push(output_1.output.dim(`${EXTENDED_LEFT_PAD}...and ${failedTasks.size - numFailedToPrint} more...`));
|
266
265
|
}
|
267
266
|
failureSummaryRows.push(...(0, view_logs_utils_1.viewLogsFooterRows)(failedTasks.size));
|
268
267
|
renderPinnedFooter(failureSummaryRows, 'red');
|
@@ -314,8 +313,7 @@ async function createRunManyDynamicOutputRenderer({ projectNames, tasks, args, o
|
|
314
313
|
}
|
315
314
|
exports.createRunManyDynamicOutputRenderer = createRunManyDynamicOutputRenderer;
|
316
315
|
function writeCompletedTaskResultLine(line) {
|
317
|
-
|
318
|
-
output_1.output.overwriteLine(output_1.output.X_PADDING + additionalXPadding + line);
|
316
|
+
output_1.output.overwriteLine(LEFT_PAD + line);
|
319
317
|
}
|
320
318
|
/**
|
321
319
|
* There's not much we can do in order to "neaten up" the outputs of
|
@@ -326,7 +324,6 @@ function writeCompletedTaskResultLine(line) {
|
|
326
324
|
function writeCommandOutputBlock(commandOutput) {
|
327
325
|
commandOutput = commandOutput || '';
|
328
326
|
commandOutput = commandOutput.trimStart();
|
329
|
-
const additionalXPadding = ' ';
|
330
327
|
const lines = commandOutput.split(os_1.EOL);
|
331
328
|
let totalTrailingEmptyLines = 0;
|
332
329
|
for (let i = lines.length - 1; i >= 0; i--) {
|
@@ -341,5 +338,5 @@ function writeCommandOutputBlock(commandOutput) {
|
|
341
338
|
}
|
342
339
|
lines.push('');
|
343
340
|
// Indent the command output to make it look more "designed" in the context of the dynamic output
|
344
|
-
lines.forEach((l) => output_1.output.overwriteLine(`${
|
341
|
+
lines.forEach((l) => output_1.output.overwriteLine(`${EXTENDED_LEFT_PAD}${l}`));
|
345
342
|
}
|
@@ -9,6 +9,8 @@ const output_1 = require("../../utils/output");
|
|
9
9
|
const pretty_time_1 = require("./pretty-time");
|
10
10
|
const formatting_utils_1 = require("./formatting-utils");
|
11
11
|
const view_logs_utils_1 = require("./view-logs-utils");
|
12
|
+
const LEFT_PAD = ` `;
|
13
|
+
const EXTENDED_LEFT_PAD = ` `;
|
12
14
|
/**
|
13
15
|
* The following function is responsible for creating a life cycle with dynamic
|
14
16
|
* outputs, meaning previous outputs can be rewritten or modified as new outputs
|
@@ -57,7 +59,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
57
59
|
const moveCursorToStartOfDependentTargetLines = () => {
|
58
60
|
readline.moveCursor(process.stdout, 0, -dependentTargetsNumLines);
|
59
61
|
};
|
60
|
-
const renderLines = (lines, dividerColor = 'cyan', renderDivider = true
|
62
|
+
const renderLines = (lines, dividerColor = 'cyan', renderDivider = true) => {
|
61
63
|
let additionalLines = 0;
|
62
64
|
if (renderDivider) {
|
63
65
|
const dividerLines = output_1.output.getVerticalSeparatorLines(dividerColor);
|
@@ -68,7 +70,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
68
70
|
lines.push('');
|
69
71
|
}
|
70
72
|
for (const line of lines) {
|
71
|
-
output_1.output.overwriteLine(
|
73
|
+
output_1.output.overwriteLine(line);
|
72
74
|
}
|
73
75
|
dependentTargetsNumLines = lines.length + additionalLines;
|
74
76
|
// clear any possible text below the cursor's position
|
@@ -86,7 +88,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
86
88
|
switch (state) {
|
87
89
|
case 'EXECUTING_DEPENDENT_TARGETS':
|
88
90
|
if (totalFailedTasks === 0) {
|
89
|
-
linesToRender.push(
|
91
|
+
linesToRender.push(`${LEFT_PAD}${output_1.output.colors.cyan(cli_spinners_1.dots.frames[dependentTargetsCurrentFrame])} ${output_1.output.dim(`Nx is waiting on ${remainingDependentTasksNotFromInitiatingProject} dependent project tasks before running tasks from`)} ${initiatingProject}${output_1.output.dim('...')}`);
|
90
92
|
if (totalSuccessfulTasks > 0) {
|
91
93
|
linesToRender.push('');
|
92
94
|
}
|
@@ -94,14 +96,14 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
94
96
|
break;
|
95
97
|
}
|
96
98
|
if (totalFailedTasks > 0) {
|
97
|
-
linesToRender.push(output_1.output.colors.red.dim(
|
99
|
+
linesToRender.push(output_1.output.colors.red.dim(`${LEFT_PAD}${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} dependent project tasks failed (see below)`));
|
98
100
|
}
|
99
101
|
if (totalSuccessfulTasks > 0) {
|
100
|
-
linesToRender.push(output_1.output.dim(
|
102
|
+
linesToRender.push(output_1.output.dim(`${LEFT_PAD}${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} dependent project tasks succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`));
|
101
103
|
}
|
102
104
|
moveCursorToStartOfDependentTargetLines();
|
103
105
|
if (linesToRender.length > 1) {
|
104
|
-
renderLines(linesToRender, 'gray', renderDivider && state !== 'EXECUTING_DEPENDENT_TARGETS'
|
106
|
+
renderLines(linesToRender, 'gray', renderDivider && state !== 'EXECUTING_DEPENDENT_TARGETS');
|
105
107
|
}
|
106
108
|
else {
|
107
109
|
renderLines([]);
|
@@ -120,7 +122,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
120
122
|
renderDependentTargets(false);
|
121
123
|
if (totalDependentTasksNotFromInitiatingProject > 0) {
|
122
124
|
output_1.output.addNewline();
|
123
|
-
process.stdout.write(
|
125
|
+
process.stdout.write(`${LEFT_PAD}${output_1.output.dim('Hint: you can run the command with')} --verbose ${output_1.output.dim('to see the full dependent project outputs')}` + os_1.EOL);
|
124
126
|
output_1.output.addVerticalSeparator('gray');
|
125
127
|
}
|
126
128
|
}
|
@@ -176,11 +178,10 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
176
178
|
const text = `Successfully ran ${(0, formatting_utils_1.formatTargetsAndProjects)([initiatingProject], [targetName], tasks)}`;
|
177
179
|
const taskOverridesLines = [];
|
178
180
|
if (Object.keys(overrides).length > 0) {
|
179
|
-
const leftPadding = `${output_1.output.X_PADDING} `;
|
180
181
|
taskOverridesLines.push('');
|
181
|
-
taskOverridesLines.push(`${
|
182
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.green('With additional flags:')}`);
|
182
183
|
Object.entries(overrides)
|
183
|
-
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(
|
184
|
+
.map(([flag, value]) => output_1.output.dim.green((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
184
185
|
.forEach((arg) => taskOverridesLines.push(arg));
|
185
186
|
}
|
186
187
|
const pinnedFooterLines = [
|
@@ -188,7 +189,7 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
188
189
|
...taskOverridesLines,
|
189
190
|
];
|
190
191
|
if (totalCachedTasks > 0) {
|
191
|
-
pinnedFooterLines.push(output_1.output.dim(`${os_1.EOL}
|
192
|
+
pinnedFooterLines.push(output_1.output.dim(`${os_1.EOL}Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
|
192
193
|
}
|
193
194
|
renderLines(pinnedFooterLines, 'green');
|
194
195
|
}
|
@@ -200,11 +201,10 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
200
201
|
}
|
201
202
|
const taskOverridesLines = [];
|
202
203
|
if (Object.keys(overrides).length > 0) {
|
203
|
-
const leftPadding = `${output_1.output.X_PADDING} `;
|
204
204
|
taskOverridesLines.push('');
|
205
|
-
taskOverridesLines.push(`${
|
205
|
+
taskOverridesLines.push(`${EXTENDED_LEFT_PAD}${output_1.output.dim.red('With additional flags:')}`);
|
206
206
|
Object.entries(overrides)
|
207
|
-
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(
|
207
|
+
.map(([flag, value]) => output_1.output.dim.red((0, formatting_utils_1.formatFlags)(EXTENDED_LEFT_PAD, flag, value)))
|
208
208
|
.forEach((arg) => taskOverridesLines.push(arg));
|
209
209
|
}
|
210
210
|
const viewLogs = (0, view_logs_utils_1.viewLogsFooterRows)(totalFailedTasks);
|
@@ -212,8 +212,8 @@ async function createRunOneDynamicOutputRenderer({ initiatingProject, tasks, arg
|
|
212
212
|
output_1.output.applyNxPrefix('red', output_1.output.colors.red(text) + output_1.output.dim(` (${timeTakenText})`)),
|
213
213
|
...taskOverridesLines,
|
214
214
|
'',
|
215
|
-
|
216
|
-
|
215
|
+
`${LEFT_PAD}${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
|
216
|
+
`${LEFT_PAD}${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
|
217
217
|
...viewLogs,
|
218
218
|
], 'red');
|
219
219
|
}
|
@@ -27,7 +27,7 @@ class StaticRunManyTerminalOutputLifeCycle {
|
|
27
27
|
output_1.output.logSingleLine(`No projects with ${(0, formatting_utils_1.formatTargetsAndProjects)(this.projectNames, this.args.targets, this.tasks)} were run`);
|
28
28
|
return;
|
29
29
|
}
|
30
|
-
const bodyLines = this.projectNames.map((affectedProject) =>
|
30
|
+
const bodyLines = this.projectNames.map((affectedProject) => `${output_1.output.dim('-')} ${affectedProject}`);
|
31
31
|
if (Object.keys(this.taskOverrides).length > 0) {
|
32
32
|
bodyLines.push('');
|
33
33
|
bodyLines.push(`${output_1.output.dim('With additional flags:')}`);
|
@@ -7,7 +7,7 @@ const output_1 = require("../../utils/output");
|
|
7
7
|
const VIEW_LOGS_MESSAGE = `Hint: Try "nx view-logs" to get structured, searchable errors logs in your browser.`;
|
8
8
|
function viewLogsFooterRows(failedTasks) {
|
9
9
|
if (failedTasks >= 2 && !(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
|
10
|
-
return [``, output_1.output.dim(
|
10
|
+
return [``, output_1.output.dim(` ${VIEW_LOGS_MESSAGE}`)];
|
11
11
|
}
|
12
12
|
else {
|
13
13
|
return [];
|
package/src/utils/logger.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.stripIndent = exports.logger = exports.NX_ERROR = exports.NX_PREFIX = void 0;
|
4
4
|
const chalk = require("chalk");
|
5
|
-
exports.NX_PREFIX =
|
5
|
+
exports.NX_PREFIX = chalk.inverse(chalk.bold(chalk.cyan(' NX ')));
|
6
6
|
exports.NX_ERROR = chalk.inverse(chalk.bold(chalk.red(' ERROR ')));
|
7
7
|
exports.logger = {
|
8
8
|
warn: (s) => console.warn(chalk.bold(chalk.yellow(s))),
|
package/src/utils/output.d.ts
CHANGED
package/src/utils/output.js
CHANGED
@@ -16,7 +16,6 @@ if ((0, is_ci_1.isCI)() && !forceColor) {
|
|
16
16
|
}
|
17
17
|
class CLIOutput {
|
18
18
|
constructor() {
|
19
|
-
this.X_PADDING = ' ';
|
20
19
|
this.cliName = 'NX';
|
21
20
|
this.formatCommand = (taskId) => `${chalk.dim('nx run')} ${taskId}`;
|
22
21
|
/**
|
@@ -41,7 +40,7 @@ class CLIOutput {
|
|
41
40
|
*/
|
42
41
|
get VERTICAL_SEPARATOR() {
|
43
42
|
let divider = '';
|
44
|
-
for (let i = 0; i < process.stdout.columns -
|
43
|
+
for (let i = 0; i < process.stdout.columns - 1; i++) {
|
45
44
|
divider += '\u2014';
|
46
45
|
}
|
47
46
|
return divider;
|
@@ -58,22 +57,22 @@ class CLIOutput {
|
|
58
57
|
process.stdout.write(os_1.EOL);
|
59
58
|
}
|
60
59
|
writeOutputTitle({ color, title, }) {
|
61
|
-
this.writeToStdOut(
|
60
|
+
this.writeToStdOut(`${this.applyNxPrefix(color, title)}${os_1.EOL}`);
|
62
61
|
}
|
63
62
|
writeOptionalOutputBody(bodyLines) {
|
64
63
|
if (!bodyLines) {
|
65
64
|
return;
|
66
65
|
}
|
67
66
|
this.addNewline();
|
68
|
-
bodyLines.forEach((bodyLine) => this.writeToStdOut(
|
67
|
+
bodyLines.forEach((bodyLine) => this.writeToStdOut(`${bodyLine}${os_1.EOL}`));
|
69
68
|
}
|
70
69
|
applyNxPrefix(color = 'cyan', text) {
|
71
70
|
let nxPrefix = '';
|
72
71
|
if (chalk[color]) {
|
73
|
-
nxPrefix =
|
72
|
+
nxPrefix = chalk.reset.inverse.bold[color](` ${this.cliName} `);
|
74
73
|
}
|
75
74
|
else {
|
76
|
-
nxPrefix =
|
75
|
+
nxPrefix = chalk.reset.inverse.bold.keyword(color)(` ${this.cliName} `);
|
77
76
|
}
|
78
77
|
return `${nxPrefix} ${text}`;
|
79
78
|
}
|
@@ -92,7 +91,7 @@ class CLIOutput {
|
|
92
91
|
return ['', this.getVerticalSeparator(color), ''];
|
93
92
|
}
|
94
93
|
getVerticalSeparator(color) {
|
95
|
-
return
|
94
|
+
return chalk.dim[color](this.VERTICAL_SEPARATOR);
|
96
95
|
}
|
97
96
|
error({ title, slug, bodyLines }) {
|
98
97
|
this.addNewline();
|
@@ -64,7 +64,7 @@ export declare function normalizePackageGroup(packageGroup: PackageGroup): Array
|
|
64
64
|
export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
|
65
65
|
packageGroup?: ArrayPackageGroup;
|
66
66
|
};
|
67
|
-
export declare function buildTargetFromScript(script: string
|
67
|
+
export declare function buildTargetFromScript(script: string): TargetConfiguration;
|
68
68
|
export declare function readTargetsFromPackageJson(packageJson: PackageJson): Record<string, TargetConfiguration<any>>;
|
69
69
|
/**
|
70
70
|
* Uses `require.resolve` to read the package.json for a module.
|
@@ -5,6 +5,7 @@ const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
6
6
|
const fileutils_1 = require("./fileutils");
|
7
7
|
const installation_directory_1 = require("./installation-directory");
|
8
|
+
const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
|
8
9
|
function normalizePackageGroup(packageGroup) {
|
9
10
|
return Array.isArray(packageGroup)
|
10
11
|
? packageGroup.map((x) => typeof x === 'string' ? { package: x, version: '*' } : x)
|
@@ -37,13 +38,10 @@ function readNxMigrateConfig(json) {
|
|
37
38
|
};
|
38
39
|
}
|
39
40
|
exports.readNxMigrateConfig = readNxMigrateConfig;
|
40
|
-
function buildTargetFromScript(script
|
41
|
-
const nxTargetConfiguration = nx?.targets?.[script] || {};
|
41
|
+
function buildTargetFromScript(script) {
|
42
42
|
return {
|
43
|
-
...nxTargetConfiguration,
|
44
43
|
executor: 'nx:run-script',
|
45
44
|
options: {
|
46
|
-
...(nxTargetConfiguration.options || {}),
|
47
45
|
script,
|
48
46
|
},
|
49
47
|
};
|
@@ -52,11 +50,14 @@ exports.buildTargetFromScript = buildTargetFromScript;
|
|
52
50
|
function readTargetsFromPackageJson(packageJson) {
|
53
51
|
const { scripts, nx } = packageJson;
|
54
52
|
const res = {};
|
55
|
-
Object.keys(scripts
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
53
|
+
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
54
|
+
//
|
55
|
+
for (const script of includedScripts) {
|
56
|
+
res[script] = buildTargetFromScript(script);
|
57
|
+
}
|
58
|
+
for (const targetName in nx?.targets) {
|
59
|
+
res[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(nx?.targets[targetName], res[targetName]);
|
60
|
+
}
|
60
61
|
/**
|
61
62
|
* Add implicit nx-release-publish target for all package.json files that are
|
62
63
|
* not marked as `"private": true` to allow for lightweight configuration for
|