nx 18.3.0-canary.20240405-fc8d5ba → 18.3.0-canary.20240406-a9e554f

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.3.0-canary.20240405-fc8d5ba",
3
+ "version": "18.3.0-canary.20240406-a9e554f",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "18.3.0-canary.20240405-fc8d5ba"
69
+ "@nrwl/tao": "18.3.0-canary.20240406-a9e554f"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "18.3.0-canary.20240405-fc8d5ba",
85
- "@nx/nx-darwin-arm64": "18.3.0-canary.20240405-fc8d5ba",
86
- "@nx/nx-linux-x64-gnu": "18.3.0-canary.20240405-fc8d5ba",
87
- "@nx/nx-linux-x64-musl": "18.3.0-canary.20240405-fc8d5ba",
88
- "@nx/nx-win32-x64-msvc": "18.3.0-canary.20240405-fc8d5ba",
89
- "@nx/nx-linux-arm64-gnu": "18.3.0-canary.20240405-fc8d5ba",
90
- "@nx/nx-linux-arm64-musl": "18.3.0-canary.20240405-fc8d5ba",
91
- "@nx/nx-linux-arm-gnueabihf": "18.3.0-canary.20240405-fc8d5ba",
92
- "@nx/nx-win32-arm64-msvc": "18.3.0-canary.20240405-fc8d5ba",
93
- "@nx/nx-freebsd-x64": "18.3.0-canary.20240405-fc8d5ba"
84
+ "@nx/nx-darwin-x64": "18.3.0-canary.20240406-a9e554f",
85
+ "@nx/nx-darwin-arm64": "18.3.0-canary.20240406-a9e554f",
86
+ "@nx/nx-linux-x64-gnu": "18.3.0-canary.20240406-a9e554f",
87
+ "@nx/nx-linux-x64-musl": "18.3.0-canary.20240406-a9e554f",
88
+ "@nx/nx-win32-x64-msvc": "18.3.0-canary.20240406-a9e554f",
89
+ "@nx/nx-linux-arm64-gnu": "18.3.0-canary.20240406-a9e554f",
90
+ "@nx/nx-linux-arm64-musl": "18.3.0-canary.20240406-a9e554f",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.3.0-canary.20240406-a9e554f",
92
+ "@nx/nx-win32-arm64-msvc": "18.3.0-canary.20240406-a9e554f",
93
+ "@nx/nx-freebsd-x64": "18.3.0-canary.20240406-a9e554f"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -100,7 +100,7 @@ async function reorgnizeWorkspaceStructure(options) {
100
100
  ? `npx nx build ${options.reactAppName}`
101
101
  : 'npm run build';
102
102
  (0, utils_1.printFinalMessage)({
103
- learnMoreLink: 'https://nx.dev/recipes/react/migration-cra',
103
+ learnMoreLink: 'https://nx.dev/recipes/adopting-nx/adding-to-existing-project',
104
104
  bodyLines: [
105
105
  `- Execute "${buildCommand}" twice to see the computation caching in action.`,
106
106
  ],
@@ -1,5 +1,6 @@
1
1
  import { PackageManager } from '../../utils/package-manager';
2
2
  import { PackageJson } from '../../utils/package-json';
3
+ import { NxJsonConfiguration } from '../../config/nx-json';
3
4
  export declare const packagesWeCareAbout: string[];
4
5
  export declare const patternsWeIgnoreInCommunityReport: Array<string | RegExp>;
5
6
  /**
@@ -16,6 +17,7 @@ export interface ReportData {
16
17
  pmVersion: string;
17
18
  localPlugins: string[];
18
19
  communityPlugins: PackageJson[];
20
+ registeredPlugins: string[];
19
21
  packageVersionsWeCareAbout: {
20
22
  package: string;
21
23
  version: string;
@@ -41,6 +43,7 @@ interface OutOfSyncPackageGroup {
41
43
  }
42
44
  export declare function findMisalignedPackagesForPackage(base: PackageJson): undefined | OutOfSyncPackageGroup;
43
45
  export declare function findInstalledCommunityPlugins(): PackageJson[];
46
+ export declare function findRegisteredPluginsBeingUsed(nxJson: NxJsonConfiguration): string[];
44
47
  export declare function findInstalledPackagesWeCareAbout(): {
45
48
  package: string;
46
49
  version: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findInstalledPackagesWeCareAbout = exports.findInstalledCommunityPlugins = exports.findMisalignedPackagesForPackage = exports.getReportData = exports.reportHandler = exports.patternsWeIgnoreInCommunityReport = exports.packagesWeCareAbout = void 0;
3
+ exports.findInstalledPackagesWeCareAbout = exports.findRegisteredPluginsBeingUsed = exports.findInstalledCommunityPlugins = exports.findMisalignedPackagesForPackage = exports.getReportData = exports.reportHandler = exports.patternsWeIgnoreInCommunityReport = exports.packagesWeCareAbout = void 0;
4
4
  const chalk = require("chalk");
5
5
  const output_1 = require("../../utils/output");
6
6
  const path_1 = require("path");
@@ -36,7 +36,7 @@ const LINE_SEPARATOR = '---------------------------------------';
36
36
  *
37
37
  */
38
38
  async function reportHandler() {
39
- const { pm, pmVersion, localPlugins, communityPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, } = await getReportData();
39
+ const { pm, pmVersion, localPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, } = await getReportData();
40
40
  const bodyLines = [
41
41
  `Node : ${process.versions.node}`,
42
42
  `OS : ${process.platform}-${process.arch}`,
@@ -47,6 +47,13 @@ async function reportHandler() {
47
47
  packageVersionsWeCareAbout.forEach((p) => {
48
48
  bodyLines.push(`${chalk.green(p.package.padEnd(padding))} : ${chalk.bold(p.version)}`);
49
49
  });
50
+ if (registeredPlugins.length) {
51
+ bodyLines.push(LINE_SEPARATOR);
52
+ bodyLines.push('Registered Plugins:');
53
+ for (const plugin of registeredPlugins) {
54
+ bodyLines.push(`${chalk.green(plugin)}`);
55
+ }
56
+ }
50
57
  if (communityPlugins.length) {
51
58
  bodyLines.push(LINE_SEPARATOR);
52
59
  padding = Math.max(...communityPlugins.map((x) => x.name.length)) + 1;
@@ -86,8 +93,10 @@ exports.reportHandler = reportHandler;
86
93
  async function getReportData() {
87
94
  const pm = (0, package_manager_1.detectPackageManager)();
88
95
  const pmVersion = (0, package_manager_1.getPackageManagerVersion)(pm);
89
- const localPlugins = await findLocalPlugins((0, nx_json_1.readNxJson)());
96
+ const nxJson = (0, nx_json_1.readNxJson)();
97
+ const localPlugins = await findLocalPlugins(nxJson);
90
98
  const communityPlugins = findInstalledCommunityPlugins();
99
+ const registeredPlugins = findRegisteredPluginsBeingUsed(nxJson);
91
100
  let projectGraphError = null;
92
101
  if (isNativeAvailable()) {
93
102
  try {
@@ -114,6 +123,7 @@ async function getReportData() {
114
123
  pmVersion,
115
124
  localPlugins,
116
125
  communityPlugins,
126
+ registeredPlugins,
117
127
  packageVersionsWeCareAbout,
118
128
  outOfSyncPackageGroup,
119
129
  projectGraphError,
@@ -178,6 +188,13 @@ function findInstalledCommunityPlugins() {
178
188
  : pattern.test(dep.name)));
179
189
  }
180
190
  exports.findInstalledCommunityPlugins = findInstalledCommunityPlugins;
191
+ function findRegisteredPluginsBeingUsed(nxJson) {
192
+ if (!nxJson.plugins) {
193
+ return [];
194
+ }
195
+ return nxJson.plugins.map((plugin) => typeof plugin === 'object' ? plugin.plugin : plugin);
196
+ }
197
+ exports.findRegisteredPluginsBeingUsed = findRegisteredPluginsBeingUsed;
181
198
  function findInstalledPackagesWeCareAbout() {
182
199
  const packagesWeMayCareAbout = {};
183
200
  // TODO (v19): Remove workaround for hiding @nrwl packages when matching @nx package is found.
@@ -99,10 +99,18 @@ export interface ProjectConfiguration {
99
99
  release?: {
100
100
  version?: Pick<NxReleaseVersionConfiguration, 'generator' | 'generatorOptions'>;
101
101
  };
102
- metadata?: {
103
- technologies?: string[];
104
- targetGroups?: Record<string, string[]>;
105
- };
102
+ /**
103
+ * Metadata about the project
104
+ */
105
+ metadata?: ProjectMetadata;
106
+ }
107
+ export interface ProjectMetadata {
108
+ technologies?: string[];
109
+ targetGroups?: Record<string, string[]>;
110
+ }
111
+ export interface TargetMetadata {
112
+ description?: string;
113
+ technologies?: string[];
106
114
  }
107
115
  export interface TargetDependencyConfig {
108
116
  /**
@@ -190,4 +198,8 @@ export interface TargetConfiguration<T = any> {
190
198
  * Determines if Nx is able to cache a given target.
191
199
  */
192
200
  cache?: boolean;
201
+ /**
202
+ * Metadata about the target
203
+ */
204
+ metadata?: TargetMetadata;
193
205
  }
@@ -162,7 +162,7 @@ async function processFilesAndCreateAndSerializeProjectGraph() {
162
162
  const errors = [...(projectConfigurationsError?.errors ?? [])];
163
163
  if (g.error) {
164
164
  if (g.error instanceof build_project_graph_1.CreateDependenciesError) {
165
- errors.concat(g.error.errors);
165
+ errors.push(...g.error.errors);
166
166
  }
167
167
  else {
168
168
  return {
@@ -39,10 +39,13 @@ export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
39
39
  parsedArgs: {
40
40
  [k: string]: any;
41
41
  };
42
+ unparsedCommandArgs?: {
43
+ [k: string]: string;
44
+ };
42
45
  args?: string;
43
46
  }
44
47
  export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
45
48
  success: boolean;
46
49
  terminalOutput: string;
47
50
  }>;
48
- export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions'>, forwardAllArgs: boolean): string;
51
+ export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions' | 'unparsedCommandArgs'>, forwardAllArgs: boolean): string;
@@ -129,6 +129,7 @@ function normalizeOptions(options) {
129
129
  .filter((p) => propKeys.indexOf(p) === -1 && unparsedCommandArgs[p] === undefined)
130
130
  .reduce((m, c) => ((m[c] = options[c]), m), {});
131
131
  options.parsedArgs = parseArgs(unparsedCommandArgs, options.unknownOptions, options.args);
132
+ options.unparsedCommandArgs = unparsedCommandArgs;
132
133
  options.commands.forEach((c) => {
133
134
  c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
134
135
  });
@@ -162,12 +163,15 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
162
163
  !commandConfig.prefix &&
163
164
  !isParallel &&
164
165
  usePty) {
166
+ let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
167
+ if (streamOutput) {
168
+ process.stdout.write(terminalOutput);
169
+ }
165
170
  const cp = pseudoTerminal.runCommand(commandConfig.command, {
166
171
  cwd,
167
172
  jsEnv: env,
168
173
  quiet: !streamOutput,
169
174
  });
170
- let terminalOutput = '';
171
175
  return new Promise((res) => {
172
176
  cp.onOutput((output) => {
173
177
  terminalOutput += output;
@@ -188,7 +192,10 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
188
192
  return nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput);
189
193
  }
190
194
  function nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput = true) {
191
- let terminalOutput = '';
195
+ let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
196
+ if (streamOutput) {
197
+ process.stdout.write(terminalOutput);
198
+ }
192
199
  return new Promise((res) => {
193
200
  const childProcess = (0, child_process_1.exec)(commandConfig.command, {
194
201
  maxBuffer: exports.LARGE_BUFFER,
@@ -297,7 +304,10 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
297
304
  args += ` ${opts.args}`;
298
305
  }
299
306
  if (opts.__unparsed__?.length > 0) {
300
- args += ` ${opts.__unparsed__.join(' ')}`;
307
+ const filterdParsedOptions = filterPropKeysFromUnParsedOptions(opts.__unparsed__, opts.unparsedCommandArgs);
308
+ if (filterdParsedOptions.length > 0) {
309
+ args += ` ${filterdParsedOptions.join(' ')}`;
310
+ }
301
311
  }
302
312
  return `${command}${args}`;
303
313
  }
@@ -314,3 +324,40 @@ function parseArgs(unparsedCommandArgs, unknownOptions, args) {
314
324
  configuration: { 'camel-case-expansion': false },
315
325
  });
316
326
  }
327
+ /**
328
+ * This function filters out the prop keys from the unparsed options
329
+ * @param __unparsed__ e.g. ['--prop1', 'value1', '--prop2=value2', '--args=test']
330
+ * @param unparsedCommandArgs e.g. { prop1: 'value1', prop2: 'value2', args: 'test'}
331
+ * @returns filtered options that are not part of the propKeys array e.g. ['--prop1', 'value1', '--prop2=value2']
332
+ */
333
+ function filterPropKeysFromUnParsedOptions(__unparsed__, unparsedCommandArgs = {}) {
334
+ const parsedOptions = [];
335
+ for (let index = 0; index < __unparsed__.length; index++) {
336
+ const element = __unparsed__[index];
337
+ if (element.startsWith('--')) {
338
+ const key = element.replace('--', '');
339
+ if (element.includes('=')) {
340
+ if (!propKeys.includes(key.split('=')[0].split('.')[0])) {
341
+ // check if the key is part of the propKeys array
342
+ parsedOptions.push(element);
343
+ }
344
+ }
345
+ else {
346
+ // check if the next element is a value for the key
347
+ if (propKeys.includes(key)) {
348
+ if (index + 1 < __unparsed__.length &&
349
+ __unparsed__[index + 1] === unparsedCommandArgs[key]) {
350
+ index++; // skip the next element
351
+ }
352
+ }
353
+ else {
354
+ parsedOptions.push(element);
355
+ }
356
+ }
357
+ }
358
+ else {
359
+ parsedOptions.push(element);
360
+ }
361
+ }
362
+ return parsedOptions;
363
+ }
@@ -104,6 +104,9 @@ skipCommandNormalization) {
104
104
  }
105
105
  }
106
106
  }
107
+ if (project.metadata) {
108
+ updatedProjectConfiguration.metadata = mergeMetadata(sourceMap, sourceInformation, 'metadata', project.metadata, matchingProject.metadata);
109
+ }
107
110
  if (project.targets) {
108
111
  // We merge the targets with special handling, so clear this back to the
109
112
  // targets as defined originally before merging.
@@ -134,68 +137,69 @@ skipCommandNormalization) {
134
137
  updatedProjectConfiguration.targets[targetName] = mergedTarget;
135
138
  }
136
139
  }
137
- if (project.metadata) {
138
- if (sourceMap) {
139
- sourceMap['targets'] ??= sourceInformation;
140
- }
141
- for (const [metadataKey, value] of Object.entries({
142
- ...project.metadata,
143
- })) {
144
- const existingValue = matchingProject.metadata?.[metadataKey];
145
- if (Array.isArray(value) && Array.isArray(existingValue)) {
146
- for (const item of [...value]) {
147
- const newLength = updatedProjectConfiguration.metadata[metadataKey].push(item);
148
- if (sourceMap) {
149
- sourceMap[`metadata.${metadataKey}.${newLength - 1}`] =
150
- sourceInformation;
151
- }
140
+ projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
141
+ }
142
+ exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
143
+ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
144
+ const result = {
145
+ ...(matchingMetadata ?? {}),
146
+ };
147
+ for (const [metadataKey, value] of Object.entries(metadata)) {
148
+ const existingValue = matchingMetadata?.[metadataKey];
149
+ if (Array.isArray(value) && Array.isArray(existingValue)) {
150
+ for (const item of [...value]) {
151
+ const newLength = result[metadataKey].push(item);
152
+ if (sourceMap) {
153
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${newLength - 1}`] =
154
+ sourceInformation;
152
155
  }
153
156
  }
154
- else if (Array.isArray(value) && existingValue === undefined) {
155
- updatedProjectConfiguration.metadata ??= {};
156
- updatedProjectConfiguration.metadata[metadataKey] ??= value;
157
+ }
158
+ else if (Array.isArray(value) && existingValue === undefined) {
159
+ result[metadataKey] ??= value;
160
+ if (sourceMap) {
161
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
162
+ }
163
+ for (let i = 0; i < value.length; i++) {
157
164
  if (sourceMap) {
158
- sourceMap[`metadata.${metadataKey}`] = sourceInformation;
159
- }
160
- for (let i = 0; i < value.length; i++) {
161
- if (sourceMap) {
162
- sourceMap[`metadata.${metadataKey}.${i}`] = sourceInformation;
163
- }
165
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${i}`] =
166
+ sourceInformation;
164
167
  }
165
168
  }
166
- else if (typeof value === 'object' &&
167
- typeof existingValue === 'object') {
168
- for (const key in value) {
169
- const existingValue = matchingProject.metadata?.[metadataKey]?.[key];
170
- if (Array.isArray(value[key]) && Array.isArray(existingValue)) {
171
- for (const item of value[key]) {
172
- const i = updatedProjectConfiguration.metadata[metadataKey][key].push(item);
173
- if (sourceMap) {
174
- sourceMap[`metadata.${metadataKey}.${key}.${i - 1}`] =
175
- sourceInformation;
176
- }
177
- }
178
- }
179
- else {
180
- updatedProjectConfiguration.metadata[metadataKey] = value;
169
+ }
170
+ else if (typeof value === 'object' && typeof existingValue === 'object') {
171
+ for (const key in value) {
172
+ const existingValue = matchingMetadata?.[metadataKey]?.[key];
173
+ if (Array.isArray(value[key]) && Array.isArray(existingValue)) {
174
+ for (const item of value[key]) {
175
+ const i = result[metadataKey][key].push(item);
181
176
  if (sourceMap) {
182
- sourceMap[`metadata.${metadataKey}`] = sourceInformation;
177
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${key}.${i - 1}`] =
178
+ sourceInformation;
183
179
  }
184
180
  }
185
181
  }
182
+ else {
183
+ result[metadataKey] = value;
184
+ if (sourceMap) {
185
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
186
+ sourceInformation;
187
+ }
188
+ }
186
189
  }
187
- else {
188
- updatedProjectConfiguration.metadata[metadataKey] = value;
189
- if (sourceMap) {
190
- sourceMap[`metadata.${metadataKey}`] = sourceInformation;
191
- if (typeof value === 'object') {
192
- for (const k in value) {
193
- sourceMap[`metadata.${metadataKey}.${k}`] = sourceInformation;
194
- if (Array.isArray(value[k])) {
195
- for (let i = 0; i < value[k].length; i++) {
196
- sourceMap[`metadata.${metadataKey}.${k}.${i}`] =
197
- sourceInformation;
198
- }
190
+ }
191
+ else {
192
+ result[metadataKey] = value;
193
+ if (sourceMap) {
194
+ sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
195
+ if (typeof value === 'object') {
196
+ for (const k in value) {
197
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}`] =
198
+ sourceInformation;
199
+ if (Array.isArray(value[k])) {
200
+ for (let i = 0; i < value[k].length; i++) {
201
+ sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}.${i}`] =
202
+ sourceInformation;
199
203
  }
200
204
  }
201
205
  }
@@ -203,9 +207,8 @@ skipCommandNormalization) {
203
207
  }
204
208
  }
205
209
  }
206
- projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
210
+ return result;
207
211
  }
208
- exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
209
212
  /**
210
213
  * Transforms a list of project paths into a map of project configurations.
211
214
  *
@@ -481,6 +484,9 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
481
484
  if (target.configurations || defaultConfigurations) {
482
485
  result.configurations = mergeConfigurations(target.configurations, isCompatible ? defaultConfigurations : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
483
486
  }
487
+ if (target.metadata) {
488
+ result.metadata = mergeMetadata(projectConfigSourceMap, sourceInformation, `${targetIdentifier}.metadata`, target.metadata, baseTarget?.metadata);
489
+ }
484
490
  return result;
485
491
  }
486
492
  exports.mergeTargetConfigurations = mergeTargetConfigurations;