nx 18.2.3 → 18.3.0-beta.0

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/bin/init-local.js CHANGED
@@ -126,7 +126,7 @@ function handleAngularCLIFallbacks(workspace) {
126
126
  if (!process.argv[3]) {
127
127
  console.log(`"ng completion" is not natively supported by Nx.
128
128
  Instead, you could try an Nx Editor Plugin for a visual tool to run Nx commands. If you're using VSCode, you can use the Nx Console plugin, or if you're using WebStorm, you could use one of the available community plugins.
129
- For more information, see https://nx.dev/features/integrate-with-editors`);
129
+ For more information, see https://nx.dev/getting-started/editor-setup`);
130
130
  }
131
131
  }
132
132
  else if (process.argv[2] === 'cache') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "18.2.3",
3
+ "version": "18.3.0-beta.0",
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.2.3"
69
+ "@nrwl/tao": "18.3.0-beta.0"
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.2.3",
85
- "@nx/nx-darwin-arm64": "18.2.3",
86
- "@nx/nx-linux-x64-gnu": "18.2.3",
87
- "@nx/nx-linux-x64-musl": "18.2.3",
88
- "@nx/nx-win32-x64-msvc": "18.2.3",
89
- "@nx/nx-linux-arm64-gnu": "18.2.3",
90
- "@nx/nx-linux-arm64-musl": "18.2.3",
91
- "@nx/nx-linux-arm-gnueabihf": "18.2.3",
92
- "@nx/nx-win32-arm64-msvc": "18.2.3",
93
- "@nx/nx-freebsd-x64": "18.2.3"
84
+ "@nx/nx-darwin-x64": "18.3.0-beta.0",
85
+ "@nx/nx-darwin-arm64": "18.3.0-beta.0",
86
+ "@nx/nx-linux-x64-gnu": "18.3.0-beta.0",
87
+ "@nx/nx-linux-x64-musl": "18.3.0-beta.0",
88
+ "@nx/nx-win32-x64-msvc": "18.3.0-beta.0",
89
+ "@nx/nx-linux-arm64-gnu": "18.3.0-beta.0",
90
+ "@nx/nx-linux-arm64-musl": "18.3.0-beta.0",
91
+ "@nx/nx-linux-arm-gnueabihf": "18.3.0-beta.0",
92
+ "@nx/nx-win32-arm64-msvc": "18.3.0-beta.0",
93
+ "@nx/nx-freebsd-x64": "18.3.0-beta.0"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -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.push(...g.error.errors);
165
+ errors.concat(g.error.errors);
166
166
  }
167
167
  else {
168
168
  return {
@@ -39,13 +39,10 @@ export interface NormalizedRunCommandsOptions extends RunCommandsOptions {
39
39
  parsedArgs: {
40
40
  [k: string]: any;
41
41
  };
42
- unparsedCommandArgs?: {
43
- [k: string]: string;
44
- };
45
42
  args?: string;
46
43
  }
47
44
  export default function (options: RunCommandsOptions, context: ExecutorContext): Promise<{
48
45
  success: boolean;
49
46
  terminalOutput: string;
50
47
  }>;
51
- export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions' | 'unparsedCommandArgs'>, forwardAllArgs: boolean): string;
48
+ export declare function interpolateArgsIntoCommand(command: string, opts: Pick<NormalizedRunCommandsOptions, 'args' | 'parsedArgs' | '__unparsed__' | 'unknownOptions'>, forwardAllArgs: boolean): string;
@@ -129,7 +129,6 @@ 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;
133
132
  options.commands.forEach((c) => {
134
133
  c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
135
134
  });
@@ -163,15 +162,12 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
163
162
  !commandConfig.prefix &&
164
163
  !isParallel &&
165
164
  usePty) {
166
- let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
167
- if (streamOutput) {
168
- process.stdout.write(terminalOutput);
169
- }
170
165
  const cp = pseudoTerminal.runCommand(commandConfig.command, {
171
166
  cwd,
172
167
  jsEnv: env,
173
168
  quiet: !streamOutput,
174
169
  });
170
+ let terminalOutput = '';
175
171
  return new Promise((res) => {
176
172
  cp.onOutput((output) => {
177
173
  terminalOutput += output;
@@ -192,10 +188,7 @@ async function createProcess(pseudoTerminal, commandConfig, readyWhen, color, cw
192
188
  return nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput);
193
189
  }
194
190
  function nodeProcess(commandConfig, cwd, env, readyWhen, streamOutput = true) {
195
- let terminalOutput = chalk.dim('> ') + commandConfig.command + '\r\n\r\n';
196
- if (streamOutput) {
197
- process.stdout.write(terminalOutput);
198
- }
191
+ let terminalOutput = '';
199
192
  return new Promise((res) => {
200
193
  const childProcess = (0, child_process_1.exec)(commandConfig.command, {
201
194
  maxBuffer: exports.LARGE_BUFFER,
@@ -304,10 +297,7 @@ function interpolateArgsIntoCommand(command, opts, forwardAllArgs) {
304
297
  args += ` ${opts.args}`;
305
298
  }
306
299
  if (opts.__unparsed__?.length > 0) {
307
- const filterdParsedOptions = filterPropKeysFromUnParsedOptions(opts.__unparsed__, opts.unparsedCommandArgs);
308
- if (filterdParsedOptions.length > 0) {
309
- args += ` ${filterdParsedOptions.join(' ')}`;
310
- }
300
+ args += ` ${opts.__unparsed__.join(' ')}`;
311
301
  }
312
302
  return `${command}${args}`;
313
303
  }
@@ -324,40 +314,3 @@ function parseArgs(unparsedCommandArgs, unknownOptions, args) {
324
314
  configuration: { 'camel-case-expansion': false },
325
315
  });
326
316
  }
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;