@nx/devkit 19.0.1 → 19.0.3

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/devkit",
3
- "version": "19.0.1",
3
+ "version": "19.0.3",
4
4
  "private": false,
5
5
  "description": "The Nx Devkit is used to customize Nx for different technologies and use cases. It contains many utility functions for reading and writing files, updating configuration, working with Abstract Syntax Trees(ASTs), and more. Learn more about [extending Nx by leveraging the Nx Devkit](https://nx.dev/extending-nx/intro/getting-started) on our docs.",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "semver": "^7.5.3",
37
37
  "yargs-parser": "21.1.1",
38
38
  "minimatch": "9.0.3",
39
- "@nrwl/devkit": "19.0.1"
39
+ "@nrwl/devkit": "19.0.3"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "nx": ">= 17 <= 20"
@@ -1,7 +1,10 @@
1
- import { CreateNodes, ProjectGraph, Tree } from 'nx/src/devkit-exports';
1
+ import type { ConfigurationResult } from 'nx/src/project-graph/utils/project-configuration-utils';
2
+ import { CreateNodes, NxJsonConfiguration, Tree } from 'nx/src/devkit-exports';
3
+ import { LoadedNxPlugin } from 'nx/src/devkit-internals';
2
4
  /**
3
5
  * Iterates through various forms of plugin options to find the one which does not conflict with the current graph
4
6
 
5
7
  */
6
- export declare function addPlugin<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodes<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
8
+ export declare function addPlugin<PluginOptions>(tree: Tree, pluginName: string, createNodesTuple: CreateNodes<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
7
9
  export declare function generateCombinations<T>(input: Record<string, T[]>): Record<string, T>[];
10
+ export declare function retrieveProjectConfigurationsWithPartialResult(plugins: LoadedNxPlugin[], workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCombinations = exports.addPlugin = void 0;
3
+ exports.retrieveProjectConfigurationsWithPartialResult = exports.generateCombinations = exports.addPlugin = void 0;
4
4
  const yargs = require("yargs-parser");
5
5
  const devkit_exports_1 = require("nx/src/devkit-exports");
6
6
  const devkit_internals_1 = require("nx/src/devkit-internals");
@@ -8,11 +8,12 @@ const devkit_internals_1 = require("nx/src/devkit-internals");
8
8
  * Iterates through various forms of plugin options to find the one which does not conflict with the current graph
9
9
 
10
10
  */
11
- async function addPlugin(tree, graph, pluginName, createNodesTuple, options, shouldUpdatePackageJsonScripts) {
12
- const graphNodes = Object.values(graph.nodes);
11
+ async function addPlugin(tree, pluginName, createNodesTuple, options, shouldUpdatePackageJsonScripts) {
13
12
  const nxJson = (0, devkit_exports_1.readNxJson)(tree);
14
13
  let pluginOptions;
15
- let projConfigs;
14
+ let projConfigsWithExistingNxJsonPlugins;
15
+ let projConfigsWithNewPlugin;
16
+ let projConfigsWithCorePlugins;
16
17
  const combinations = generateCombinations(options);
17
18
  optionsLoop: for (const _pluginOptions of combinations) {
18
19
  pluginOptions = _pluginOptions;
@@ -24,8 +25,11 @@ async function addPlugin(tree, graph, pluginName, createNodesTuple, options, sho
24
25
  return;
25
26
  }
26
27
  global.NX_GRAPH_CREATION = true;
27
- try {
28
- projConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)([
28
+ const [nxJsonPlugins] = await (0, devkit_internals_1.loadNxPlugins)(nxJson.plugins, tree.root, true);
29
+ projConfigsWithExistingNxJsonPlugins =
30
+ await retrieveProjectConfigurationsWithPartialResult(nxJsonPlugins, tree.root, nxJson);
31
+ projConfigsWithNewPlugin =
32
+ await retrieveProjectConfigurationsWithPartialResult([
29
33
  new devkit_internals_1.LoadedNxPlugin({
30
34
  name: pluginName,
31
35
  createNodes: createNodesTuple,
@@ -34,24 +38,18 @@ async function addPlugin(tree, graph, pluginName, createNodesTuple, options, sho
34
38
  options: pluginOptions,
35
39
  }),
36
40
  ], tree.root, nxJson);
37
- }
38
- catch (e) {
39
- // Errors are okay for this because we're only running 1 plugin
40
- if (e instanceof devkit_internals_1.ProjectConfigurationsError) {
41
- projConfigs = e.partialProjectConfigurationsResult;
42
- }
43
- else {
44
- throw e;
45
- }
46
- }
41
+ const [corePlugins] = await (0, devkit_internals_1.loadNxPlugins)([], tree.root);
42
+ projConfigsWithCorePlugins =
43
+ await retrieveProjectConfigurationsWithPartialResult(corePlugins, tree.root, nxJson);
47
44
  global.NX_GRAPH_CREATION = false;
48
- for (const projConfig of Object.values(projConfigs.projects)) {
49
- const node = graphNodes.find((node) => node.data.root === projConfig.root);
50
- if (!node) {
51
- continue;
52
- }
45
+ for (const projConfig of Object.values(projConfigsWithNewPlugin.projects)) {
53
46
  for (const targetName in projConfig.targets) {
54
- if (node.data.targets[targetName]) {
47
+ const existingPluginCreatedTarget = projConfigsWithExistingNxJsonPlugins?.projects?.[projConfig.root]
48
+ ?.targets?.[targetName];
49
+ const corePluginsCreatedTarget = projConfigsWithCorePlugins?.projects?.[projConfig.root]?.targets?.[targetName];
50
+ if (existingPluginCreatedTarget ||
51
+ (corePluginsCreatedTarget &&
52
+ !(0, devkit_internals_1.deepEquals)(corePluginsCreatedTarget, (0, devkit_internals_1.mergeTargetConfigurations)(corePluginsCreatedTarget, projConfig.targets[targetName])))) {
55
53
  // Conflicting Target Name, check the next one
56
54
  pluginOptions = null;
57
55
  continue optionsLoop;
@@ -69,7 +67,7 @@ async function addPlugin(tree, graph, pluginName, createNodesTuple, options, sho
69
67
  });
70
68
  (0, devkit_exports_1.updateNxJson)(tree, nxJson);
71
69
  if (shouldUpdatePackageJsonScripts) {
72
- updatePackageScripts(tree, projConfigs);
70
+ updatePackageScripts(tree, projConfigsWithNewPlugin);
73
71
  }
74
72
  }
75
73
  exports.addPlugin = addPlugin;
@@ -240,3 +238,20 @@ function _generateCombinations(input) {
240
238
  return first.flatMap((value) => partialCombinations.map((combination) => [value, ...combination]));
241
239
  }
242
240
  }
241
+ async function retrieveProjectConfigurationsWithPartialResult(plugins, workspaceRoot, nxJson) {
242
+ let projConfigs;
243
+ try {
244
+ projConfigs = await (0, devkit_internals_1.retrieveProjectConfigurations)(plugins, workspaceRoot, nxJson);
245
+ }
246
+ catch (e) {
247
+ // Errors are okay for this because we're only running 1 plugin
248
+ if (e instanceof devkit_internals_1.ProjectConfigurationsError) {
249
+ projConfigs = e.partialProjectConfigurationsResult;
250
+ }
251
+ else {
252
+ throw e;
253
+ }
254
+ }
255
+ return projConfigs;
256
+ }
257
+ exports.retrieveProjectConfigurationsWithPartialResult = retrieveProjectConfigurationsWithPartialResult;
@@ -15,6 +15,7 @@ const binaryExtensions = new Set([
15
15
  '.ai',
16
16
  '.aif',
17
17
  '.aiff',
18
+ '.als',
18
19
  '.alz',
19
20
  '.ape',
20
21
  '.apk',
@@ -139,6 +140,7 @@ const binaryExtensions = new Set([
139
140
  '.mxu',
140
141
  '.nef',
141
142
  '.npx',
143
+ '.npy',
142
144
  '.numbers',
143
145
  '.nupkg',
144
146
  '.o',
@@ -159,6 +161,8 @@ const binaryExtensions = new Set([
159
161
  '.pea',
160
162
  '.pgm',
161
163
  '.pic',
164
+ '.pkg',
165
+ '.plist',
162
166
  '.png',
163
167
  '.pnm',
164
168
  '.pot',