nx 18.0.4 → 18.0.5

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.
Files changed (38) hide show
  1. package/package.json +13 -12
  2. package/src/command-line/add/add.js +3 -1
  3. package/src/command-line/graph/graph.js +1 -1
  4. package/src/command-line/init/init-v2.js +16 -11
  5. package/src/command-line/migrate/command-object.js +17 -2
  6. package/src/command-line/migrate/migrate.js +13 -1
  7. package/src/command-line/release/changelog.d.ts +16 -1
  8. package/src/command-line/release/changelog.js +104 -194
  9. package/src/command-line/release/command-object.d.ts +1 -0
  10. package/src/command-line/release/release.js +56 -3
  11. package/src/command-line/release/utils/git.d.ts +5 -1
  12. package/src/command-line/release/utils/git.js +26 -11
  13. package/src/command-line/release/utils/github.d.ts +4 -8
  14. package/src/command-line/release/utils/github.js +61 -2
  15. package/src/command-line/release/utils/shared.d.ts +1 -0
  16. package/src/command-line/release/utils/shared.js +3 -1
  17. package/src/core/graph/3rdpartylicenses.txt +0 -51
  18. package/src/core/graph/main.js +1 -1
  19. package/src/core/graph/polyfills.js +1 -1
  20. package/src/core/graph/runtime.js +1 -1
  21. package/src/core/graph/styles.js +1 -1
  22. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +3 -3
  23. package/src/plugins/js/utils/register.js +1 -0
  24. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +2 -3
  25. package/src/plugins/target-defaults/target-defaults-plugin.js +24 -32
  26. package/src/project-graph/utils/project-configuration-utils.js +13 -6
  27. package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +20 -23
  28. package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +16 -16
  29. package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +1 -1
  30. package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
  31. package/src/tasks-runner/task-orchestrator.js +23 -1
  32. package/src/utils/json.js +3 -1
  33. package/src/utils/logger.js +1 -1
  34. package/src/utils/output.d.ts +0 -1
  35. package/src/utils/output.js +6 -7
  36. package/src/utils/package-json.d.ts +1 -1
  37. package/src/utils/package-json.js +12 -11
  38. package/src/utils/plugins/core-plugins.js +4 -0
@@ -1 +1 @@
1
- (()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={2:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
1
+ (()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={666:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3],{33767:(s,e,k)=>{k.r(e)}},s=>{var e;e=33767,s(s.s=e)}]);
1
+ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{33767:()=>{}},s=>{var e;e=33767,s(s.s=e)}]);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
4
4
  const nx_json_1 = require("../../generators/utils/nx-json");
5
5
  const json_1 = require("../../generators/utils/json");
6
- const logger_1 = require("../../utils/logger");
6
+ const output_1 = require("../../utils/output");
7
7
  const path_1 = require("../../utils/path");
8
8
  async function update(tree) {
9
9
  if (!tree.exists('nx.json')) {
@@ -37,7 +37,7 @@ function warnNpmScopeHasChanged(tree, nxJson) {
37
37
  }
38
38
  const packageJsonName = (0, json_1.readJson)(tree, 'package.json').name;
39
39
  if (newScope) {
40
- logger_1.logger.warn({
40
+ output_1.output.warn({
41
41
  title: 'npmScope has been removed from nx.json',
42
42
  bodyLines: [
43
43
  'This will now be read from package.json',
@@ -50,7 +50,7 @@ function warnNpmScopeHasChanged(tree, nxJson) {
50
50
  }
51
51
  else {
52
52
  // There is no scope in package.json
53
- logger_1.logger.warn({
53
+ output_1.output.warn({
54
54
  title: 'npmScope has been removed from nx.json',
55
55
  bodyLines: [
56
56
  'This will now be read from package.json',
@@ -67,6 +67,7 @@ function getTranspiler(compilerOptions) {
67
67
  }
68
68
  compilerOptions.lib = ['es2021'];
69
69
  compilerOptions.module = ts.ModuleKind.CommonJS;
70
+ compilerOptions.moduleResolution = ts.ModuleResolutionKind.Node10;
70
71
  compilerOptions.target = ts.ScriptTarget.ES2021;
71
72
  compilerOptions.inlineSourceMap = true;
72
73
  compilerOptions.skipLibCheck = true;
@@ -1,6 +1,5 @@
1
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
1
+ import { TargetConfiguration } from '../../config/workspace-json-project-json';
2
2
  import { NxPluginV2 } from '../../utils/nx-plugin';
3
- import { PackageJson } from '../../utils/package-json';
4
3
  /**
5
4
  * This symbol marks that a target provides information which should modify a target already registered
6
5
  * on the project via other plugins. If the target has not already been registered, and this symbol is true,
@@ -17,7 +16,7 @@ export declare const TargetDefaultsPlugin: NxPluginV2;
17
16
  * being scrapped. By adding enough information from the project.json / package.json,
18
17
  * we can make sure that the target after merging is compatible with the defined target.
19
18
  */
20
- export declare function getTargetInfo(target: string, projectJson: Pick<ProjectConfiguration, 'targets'>, packageJson: Pick<PackageJson, 'scripts' | 'nx'>): {
19
+ export declare function getTargetInfo(target: string, projectJsonTargets: Record<string, TargetConfiguration>, packageJsonTargets: Record<string, TargetConfiguration>): {
21
20
  command: string;
22
21
  executor?: undefined;
23
22
  options?: undefined;
@@ -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,18 +38,12 @@ 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
+ const packageJsonTargets = (0, package_json_1.readTargetsFromPackageJson)(packageJson);
41
42
  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
43
  ...Object.keys(projectJson?.targets ?? {}),
49
- ...Object.keys(packageJson?.nx?.targets ?? {}),
44
+ ...(packageJson ? Object.keys(packageJsonTargets) : []),
50
45
  ]);
51
- const executorToTargetMap = getExecutorToTargetMap(packageJson, projectJson);
46
+ const executorToTargetMap = getExecutorToTargetMap(packageJsonTargets, projectJson?.targets);
52
47
  const modifiedTargets = {};
53
48
  for (const defaultSpecifier in targetDefaults) {
54
49
  const targetNames = executorToTargetMap.get(defaultSpecifier) ?? new Set();
@@ -59,7 +54,7 @@ exports.TargetDefaultsPlugin = {
59
54
  if (!modifiedTargets[targetName] || targetName !== defaultSpecifier) {
60
55
  const defaults = JSON.parse(JSON.stringify(targetDefaults[defaultSpecifier]));
61
56
  modifiedTargets[targetName] = {
62
- ...getTargetInfo(targetName, projectJson, packageJson),
57
+ ...getTargetInfo(targetName, projectJson?.targets, packageJsonTargets),
63
58
  ...defaults,
64
59
  };
65
60
  }
@@ -80,17 +75,14 @@ exports.TargetDefaultsPlugin = {
80
75
  },
81
76
  ],
82
77
  };
83
- function getExecutorToTargetMap(packageJson, projectJson) {
78
+ function getExecutorToTargetMap(packageJsonTargets, projectJsonTargets) {
84
79
  const executorToTargetMap = new Map();
85
80
  const targets = Object.keys({
86
- ...projectJson?.targets,
87
- ...packageJson?.scripts,
88
- ...packageJson?.nx?.targets,
81
+ ...projectJsonTargets,
82
+ ...packageJsonTargets,
89
83
  });
90
84
  for (const target of targets) {
91
- const executor = projectJson?.targets?.[target]?.executor ??
92
- packageJson?.nx?.targets?.[target]?.executor ??
93
- 'nx:run-script';
85
+ const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
94
86
  const targetsForExecutor = executorToTargetMap.get(executor) ?? new Set();
95
87
  targetsForExecutor.add(target);
96
88
  executorToTargetMap.set(executor, targetsForExecutor);
@@ -114,10 +106,10 @@ function readJsonOrNull(path) {
114
106
  * being scrapped. By adding enough information from the project.json / package.json,
115
107
  * we can make sure that the target after merging is compatible with the defined target.
116
108
  */
117
- function getTargetInfo(target, projectJson, packageJson) {
118
- const projectJsonTarget = projectJson?.targets?.[target];
119
- const packageJsonTarget = packageJson?.nx?.targets?.[target];
120
- const executor = getTargetExecutor(target, projectJson, packageJson);
109
+ function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
110
+ const projectJsonTarget = projectJsonTargets?.[target];
111
+ const packageJsonTarget = packageJsonTargets?.[target];
112
+ const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
121
113
  const targetOptions = {
122
114
  ...packageJsonTarget?.options,
123
115
  ...projectJsonTarget?.options,
@@ -162,17 +154,17 @@ function getTargetInfo(target, projectJson, packageJson) {
162
154
  return {};
163
155
  }
164
156
  exports.getTargetInfo = getTargetInfo;
165
- function getTargetExecutor(target, projectJson, packageJson) {
166
- const projectJsonTarget = projectJson?.targets?.[target];
167
- const packageJsonTarget = packageJson?.nx?.targets?.[target];
168
- const packageJsonScript = packageJson?.scripts?.[target];
169
- if (projectJsonTarget?.command) {
170
- return 'nx:run-commands';
157
+ function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
158
+ const projectJsonTargetConfiguration = projectJsonTargets?.[target];
159
+ const packageJsonTargetConfiguration = packageJsonTargets?.[target];
160
+ if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
161
+ return packageJsonTargetConfiguration?.executor ?? 'nx:run-script';
171
162
  }
172
- if (!projectJsonTarget?.executor &&
173
- !packageJsonTarget?.executor &&
174
- packageJsonScript) {
175
- return 'nx:run-script';
163
+ if (projectJsonTargetConfiguration?.executor) {
164
+ return projectJsonTargetConfiguration.executor;
165
+ }
166
+ if (projectJsonTargetConfiguration?.command) {
167
+ return 'nx:run-commands';
176
168
  }
177
- return projectJsonTarget?.executor ?? packageJsonTarget?.executor;
169
+ return null;
178
170
  }
@@ -108,13 +108,13 @@ skipCommandNormalization) {
108
108
  !matchingProject.targets?.[targetName]) {
109
109
  continue;
110
110
  }
111
+ const mergedTarget = mergeTargetConfigurations(skipCommandNormalization
112
+ ? target
113
+ : resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
111
114
  // We don't want the symbol to live on past the merge process
112
- if (target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET])
113
- delete target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET];
114
- updatedProjectConfiguration.targets[targetName] =
115
- mergeTargetConfigurations(skipCommandNormalization
116
- ? target
117
- : resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
115
+ if (mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET])
116
+ delete mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET];
117
+ updatedProjectConfiguration.targets[targetName] = mergedTarget;
118
118
  }
119
119
  }
120
120
  projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
@@ -288,6 +288,13 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
288
288
  // Target is "compatible", e.g. executor is defined only once or is the same
289
289
  // in both places. This means that it is likely safe to merge
290
290
  const isCompatible = isCompatibleTarget(baseTargetProperties, target);
291
+ // If the targets are not compatible, we would normally overwrite the old target
292
+ // with the new one. However, we have a special case for targets that have the
293
+ // ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
294
+ // equaling info that should have only been used to modify the existing target.
295
+ if (!isCompatible && target[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET]) {
296
+ return baseTarget;
297
+ }
291
298
  if (!isCompatible && projectConfigSourceMap) {
292
299
  // if the target is not compatible, we will simply override the options
293
300
  // we have to delete old entries from the source map
@@ -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(output_1.output.X_PADDING + line);
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(` ${output_1.output.colors.cyan(figures.arrowRight)} Executing ${runningTasks.length}/${remainingTasks} remaining tasks${runningTasks.length > 1 ? ' in parallel' : ''}...`));
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(` ${output_1.output.dim.cyan(cli_spinners_1.dots.frames[currentFrame])} ${output_1.output.formatCommand(runningTask.task.id)}`);
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(` ${output_1.output.colors.green(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`);
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(` ${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`);
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(`${leftPadding}${output_1.output.dim.cyan('With additional flags:')}`);
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)(leftPadding, flag, value)))
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(`${leftPadding}${output_1.output.dim.green('With additional flags:')}`);
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)(leftPadding, flag, value)))
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} Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
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(`${leftPadding}${output_1.output.dim.red('With additional flags:')}`);
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)(leftPadding, flag, value)))
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(` ${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`),
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
- ` ${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`,
258
+ `${LEFT_PAD}${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} targets failed, including the following:`,
260
259
  `${failedTasksForPrinting
261
- .map((t) => ` ${output_1.output.colors.red('-')} ${output_1.output.formatCommand(t.toString())}`)
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(` ...and ${failedTasks.size - numFailedToPrint} more...`));
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
- const additionalXPadding = ' ';
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(`${output_1.output.X_PADDING}${additionalXPadding}${l}`));
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, skipPadding = false) => {
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((skipPadding ? '' : output_1.output.X_PADDING) + line);
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(` ${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('...')}`);
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(` ${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} dependent project tasks failed (see below)`));
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(` ${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} dependent project tasks succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`));
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', true);
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(` ${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);
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(`${leftPadding}${output_1.output.dim.green('With additional flags:')}`);
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)(leftPadding, flag, value)))
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} Nx read the output from the cache instead of running the command for ${totalCachedTasks} out of ${totalTasks} tasks.`));
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(`${leftPadding}${output_1.output.dim.red('With additional flags:')}`);
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)(leftPadding, flag, value)))
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
- ` ${output_1.output.colors.red(figures.cross)} ${totalFailedTasks}${`/${totalCompletedTasks}`} failed`,
216
- ` ${output_1.output.dim(figures.tick)} ${totalSuccessfulTasks}${`/${totalCompletedTasks}`} succeeded ${output_1.output.dim(`[${totalCachedTasks} read from cache]`)}`,
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) => ` ${output_1.output.dim('-')} ${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(`${output_1.output.X_PADDING} ${VIEW_LOGS_MESSAGE}`)];
10
+ return [``, output_1.output.dim(` ${VIEW_LOGS_MESSAGE}`)];
11
11
  }
12
12
  else {
13
13
  return [];
@@ -9,6 +9,7 @@ const utils_1 = require("./utils");
9
9
  const tasks_schedule_1 = require("./tasks-schedule");
10
10
  const hash_task_1 = require("../hasher/hash-task");
11
11
  const task_env_1 = require("./task-env");
12
+ const os = require("os");
12
13
  class TaskOrchestrator {
13
14
  // endregion internal state
14
15
  constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon) {
@@ -216,8 +217,10 @@ class TaskOrchestrator {
216
217
  }
217
218
  async runTaskInForkedProcess(task, env, pipeOutput, temporaryOutputPath, streamOutput) {
218
219
  try {
220
+ let usePtyFork = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
221
+ supportedPtyPlatform();
219
222
  // execution
220
- const { code, terminalOutput } = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false'
223
+ const { code, terminalOutput } = usePtyFork
221
224
  ? await this.forkedProcessTaskRunner.forkProcess(task, {
222
225
  temporaryOutputPath,
223
226
  streamOutput,
@@ -373,3 +376,22 @@ class TaskOrchestrator {
373
376
  }
374
377
  }
375
378
  exports.TaskOrchestrator = TaskOrchestrator;
379
+ function supportedPtyPlatform() {
380
+ if (process.platform !== 'win32') {
381
+ return true;
382
+ }
383
+ let windowsVersion = os.release().split('.');
384
+ let windowsBuild = windowsVersion[2];
385
+ if (!windowsBuild) {
386
+ return false;
387
+ }
388
+ // Mininum supported Windows version:
389
+ // https://en.wikipedia.org/wiki/Windows_10,_version_1809
390
+ // https://learn.microsoft.com/en-us/windows/console/createpseudoconsole#requirements
391
+ if (+windowsBuild < 17763) {
392
+ return false;
393
+ }
394
+ else {
395
+ return true;
396
+ }
397
+ }
package/src/utils/json.js CHANGED
@@ -15,7 +15,9 @@ const code_frames_1 = require("./code-frames");
15
15
  */
16
16
  function parseJson(input, options) {
17
17
  try {
18
- return JSON.parse(input);
18
+ if (options?.expectComments !== true) {
19
+ return JSON.parse(input);
20
+ }
19
21
  }
20
22
  catch { }
21
23
  options = { allowTrailingComma: true, ...options };
@@ -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 = `${chalk.cyan('>')} ${chalk.inverse(chalk.bold(chalk.cyan(' NX ')))}`;
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))),
@@ -19,7 +19,6 @@ export interface CLISuccessMessageConfig {
19
19
  bodyLines?: string[];
20
20
  }
21
21
  declare class CLIOutput {
22
- readonly X_PADDING = " ";
23
22
  cliName: string;
24
23
  formatCommand: (taskId: string) => string;
25
24
  /**
@@ -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 - this.X_PADDING.length * 2; i++) {
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(` ${this.applyNxPrefix(color, title)}${os_1.EOL}`);
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(` ${bodyLine}${os_1.EOL}`));
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 = `${chalk[color]('>')} ${chalk.reset.inverse.bold[color](` ${this.cliName} `)}`;
72
+ nxPrefix = chalk.reset.inverse.bold[color](` ${this.cliName} `);
74
73
  }
75
74
  else {
76
- nxPrefix = `${chalk.keyword(color)('>')} ${chalk.reset.inverse.bold.keyword(color)(` ${this.cliName} `)}`;
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 `${this.X_PADDING}${chalk.dim[color](this.VERTICAL_SEPARATOR)}`;
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, nx: NxProjectPackageJsonConfiguration): TargetConfiguration;
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.