@nx/devkit 23.0.0-beta.22 → 23.0.0-beta.23

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.
@@ -1,5 +1,5 @@
1
1
  import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json';
2
- import { type CreateNodesV2, type NxJsonConfiguration, type ProjectGraph, type TargetConfiguration, type Tree } from 'nx/src/devkit-exports';
2
+ import { type CreateNodes, type NxJsonConfiguration, type ProjectGraph, type TargetConfiguration, type Tree } from 'nx/src/devkit-exports';
3
3
  import { logger as devkitLogger } from 'nx/src/devkit-exports';
4
4
  export type InferredTargetConfiguration = TargetConfiguration & {
5
5
  name: string;
@@ -14,14 +14,14 @@ export declare class NoTargetsToMigrateError extends Error {
14
14
  constructor();
15
15
  }
16
16
  export declare function readTargetDefaultsForExecutor(executor: string, targetDefaults: NxJsonConfiguration['targetDefaults'] | undefined): Partial<TargetConfiguration> | undefined;
17
- export declare function migrateProjectExecutorsToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, pluginPath: string, createNodesV2: CreateNodesV2<T>, defaultPluginOptions: T, migrations: Array<{
17
+ export declare function migrateProjectExecutorsToPlugin<T>(tree: Tree, projectGraph: ProjectGraph, pluginPath: string, createNodesV2: CreateNodes<T>, defaultPluginOptions: T, migrations: Array<{
18
18
  executors: string[];
19
19
  targetPluginOptionMapper: (targetName: string) => Partial<T>;
20
20
  postTargetTransformer: PostTargetTransformer;
21
21
  skipProjectFilter?: SkipProjectFilter;
22
22
  skipTargetFilter?: SkipTargetFilter;
23
23
  }>, specificProjectToMigrate?: string, logger?: typeof devkitLogger): Promise<Map<string, Record<string, string>>>;
24
- export declare function migrateProjectExecutorsToPluginV1<T>(tree: Tree, projectGraph: ProjectGraph, pluginPath: string, createNodes: CreateNodesV2<T>, defaultPluginOptions: T, migrations: Array<{
24
+ export declare function migrateProjectExecutorsToPluginV1<T>(tree: Tree, projectGraph: ProjectGraph, pluginPath: string, createNodes: CreateNodes<T>, defaultPluginOptions: T, migrations: Array<{
25
25
  executors: string[];
26
26
  targetPluginOptionMapper: (targetName: string) => Partial<T>;
27
27
  postTargetTransformer: PostTargetTransformer;
@@ -7,6 +7,7 @@ exports.addBuildTargetDefaults = addBuildTargetDefaults;
7
7
  exports.addE2eCiTargetDefaults = addE2eCiTargetDefaults;
8
8
  const devkit_exports_1 = require("nx/src/devkit-exports");
9
9
  const devkit_internals_1 = require("nx/src/devkit-internals");
10
+ const minimatch_1 = require("minimatch");
10
11
  const semver_1 = require("semver");
11
12
  const package_json_1 = require("../utils/package-json");
12
13
  const normalize_target_defaults_1 = require("../utils/normalize-target-defaults");
@@ -183,7 +184,12 @@ async function addE2eCiTargetDefaults(tree, e2ePlugin, buildTarget, pathToE2ECon
183
184
  return;
184
185
  }
185
186
  const resolvedE2ePlugin = await import(e2ePlugin);
186
- const e2ePluginGlob = resolvedE2ePlugin.createNodesV2?.[0] ?? resolvedE2ePlugin.createNodes?.[0];
187
+ const e2ePluginGlob = resolvedE2ePlugin.createNodes?.[0] ?? resolvedE2ePlugin.createNodesV2?.[0];
188
+ // The e2e config file must be one this plugin actually processes (its path
189
+ // matches the plugin's createNodes glob) before the registration's
190
+ // include/exclude filters are applied.
191
+ const e2eConfigMatchesPluginGlob = !e2ePluginGlob ||
192
+ (0, minimatch_1.minimatch)(pathToE2EConfigFile, e2ePluginGlob, { dot: true });
187
193
  let foundPluginForApplication;
188
194
  for (let i = 0; i < e2ePluginRegistrations.length; i++) {
189
195
  let candidatePluginForApplication = e2ePluginRegistrations[i];
@@ -191,7 +197,9 @@ async function addE2eCiTargetDefaults(tree, e2ePlugin, buildTarget, pathToE2ECon
191
197
  foundPluginForApplication = candidatePluginForApplication;
192
198
  break;
193
199
  }
194
- const matchingConfigFiles = (0, devkit_internals_1.findMatchingConfigFiles)([pathToE2EConfigFile], e2ePluginGlob, candidatePluginForApplication.include, candidatePluginForApplication.exclude);
200
+ const matchingConfigFiles = e2eConfigMatchesPluginGlob
201
+ ? (0, devkit_internals_1.findMatchingConfigFiles)([pathToE2EConfigFile], candidatePluginForApplication.include, candidatePluginForApplication.exclude)
202
+ : [];
195
203
  if (matchingConfigFiles.length) {
196
204
  foundPluginForApplication = candidatePluginForApplication;
197
205
  break;
@@ -1,13 +1,13 @@
1
- import { CreateNodesV2, ProjectGraph, Tree } from 'nx/src/devkit-exports';
1
+ import { CreateNodes, ProjectGraph, Tree } from 'nx/src/devkit-exports';
2
2
  /**
3
3
  * Iterates through various forms of plugin options to find the one which does not conflict with the current graph
4
4
 
5
5
  */
6
- export declare function addPlugin<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodesV2<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
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>;
7
7
  /**
8
8
  * @deprecated Use `addPlugin` instead
9
9
  * Iterates through various forms of plugin options to find the one which does not conflict with the current graph
10
10
 
11
11
  */
12
- export declare function addPluginV1<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodesV2<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
12
+ export declare function addPluginV1<PluginOptions>(tree: Tree, graph: ProjectGraph, pluginName: string, createNodesTuple: CreateNodes<PluginOptions>, options: Partial<Record<keyof PluginOptions, PluginOptions[keyof PluginOptions][]>>, shouldUpdatePackageJsonScripts: boolean): Promise<void>;
13
13
  export declare function generateCombinations<T>(input: Record<string, T[]>): Record<string, T>[];
@@ -14,7 +14,7 @@ const devkit_internals_1 = require("nx/src/devkit-internals");
14
14
  async function addPlugin(tree, graph, pluginName, createNodesTuple, options, shouldUpdatePackageJsonScripts) {
15
15
  return _addPluginInternal(tree, graph, pluginName, (pluginOptions) => new devkit_internals_1.LoadedNxPlugin({
16
16
  name: pluginName,
17
- createNodesV2: createNodesTuple,
17
+ createNodes: createNodesTuple,
18
18
  }, {
19
19
  plugin: pluginName,
20
20
  options: pluginOptions,
@@ -1,8 +1,8 @@
1
- import { CreateNodesContextV2 } from 'nx/src/devkit-exports';
1
+ import { CreateNodesContext } from 'nx/src/devkit-exports';
2
2
  /**
3
3
  * @deprecated Use {@link calculateHashesForCreateNodes} instead, which batches
4
4
  * workspace-context hashing across multiple project roots in a single call.
5
5
  * This will be removed in Nx 24.
6
6
  */
7
- export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContextV2, additionalGlobs?: string[]): Promise<string>;
8
- export declare function calculateHashesForCreateNodes(projectRoots: string[], options: object, context: CreateNodesContextV2, additionalGlobs?: string[][]): Promise<string[]>;
7
+ export declare function calculateHashForCreateNodes(projectRoot: string, options: object, context: CreateNodesContext, additionalGlobs?: string[]): Promise<string>;
8
+ export declare function calculateHashesForCreateNodes(projectRoots: string[], options: object, context: CreateNodesContext, additionalGlobs?: string[][]): Promise<string[]>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findPluginForConfigFile = findPluginForConfigFile;
4
4
  const devkit_exports_1 = require("nx/src/devkit-exports");
5
5
  const devkit_internals_1 = require("nx/src/devkit-internals");
6
+ const minimatch_1 = require("minimatch");
6
7
  async function findPluginForConfigFile(tree, pluginName, pathToConfigFile) {
7
8
  const nxJson = (0, devkit_exports_1.readNxJson)(tree);
8
9
  if (!nxJson.plugins) {
@@ -18,8 +19,13 @@ async function findPluginForConfigFile(tree, pluginName, pathToConfigFile) {
18
19
  }
19
20
  if (plugin.include || plugin.exclude) {
20
21
  const resolvedPlugin = await import(pluginName);
21
- const pluginGlob = resolvedPlugin.createNodesV2?.[0] ?? resolvedPlugin.createNodes?.[0];
22
- const matchingConfigFile = (0, devkit_internals_1.findMatchingConfigFiles)([pathToConfigFile], pluginGlob, plugin.include, plugin.exclude);
22
+ const pluginGlob = resolvedPlugin.createNodes?.[0] ?? resolvedPlugin.createNodesV2?.[0];
23
+ // The file must be one this plugin actually processes (its path matches
24
+ // the plugin's createNodes glob) before the registration's include/exclude
25
+ // filters are applied.
26
+ const matchingConfigFile = !pluginGlob || (0, minimatch_1.minimatch)(pathToConfigFile, pluginGlob, { dot: true })
27
+ ? (0, devkit_internals_1.findMatchingConfigFiles)([pathToConfigFile], plugin.include, plugin.exclude)
28
+ : [];
23
29
  if (matchingConfigFile.length) {
24
30
  return plugin;
25
31
  }
@@ -1,8 +1,8 @@
1
1
  import type { InputDefinition } from 'nx/src/config/workspace-json-project-json';
2
- import { CreateNodesContextV2 } from 'nx/src/devkit-exports';
2
+ import { CreateNodesContext } from 'nx/src/devkit-exports';
3
3
  /**
4
4
  * Get the named inputs available for a directory
5
5
  */
6
- export declare function getNamedInputs(directory: string, context: CreateNodesContextV2): {
6
+ export declare function getNamedInputs(directory: string, context: CreateNodesContext): {
7
7
  [inputName: string]: (string | InputDefinition)[];
8
8
  };
@@ -456,7 +456,7 @@ function ensurePackage(pkgOrTree, requiredVersionOrPackage, maybeRequiredVersion
456
456
  if (process.env.NX_DRY_RUN && process.env.NX_DRY_RUN !== 'false') {
457
457
  throw new Error('NOTE: This generator does not support --dry-run. If you are running this in Nx Console, it should execute fine once you hit the "Generate" button.\n');
458
458
  }
459
- const { tempDir } = (0, devkit_internals_1.installPackageToTmp)(pkg, requiredVersion);
459
+ const { tempDir } = (0, devkit_internals_1.installPackageToTmp)(pkg, requiredVersion, (0, devkit_exports_1.detectPackageManager)(devkit_exports_1.workspaceRoot));
460
460
  addToNodePath((0, path_1.join)(devkit_exports_1.workspaceRoot, 'node_modules'));
461
461
  addToNodePath((0, path_1.join)(tempDir, 'node_modules'));
462
462
  // Re-initialize the added paths into require
@@ -1,2 +1,2 @@
1
- import { CreateNodesV2, Tree } from 'nx/src/devkit-exports';
2
- export declare function replaceProjectConfigurationsWithPlugin<T = unknown>(tree: Tree, rootMappings: Map<string, string>, pluginPath: string, createNodes: CreateNodesV2<T>, pluginOptions: T): Promise<void>;
1
+ import { CreateNodes, Tree } from 'nx/src/devkit-exports';
2
+ export declare function replaceProjectConfigurationsWithPlugin<T = unknown>(tree: Tree, rootMappings: Map<string, string>, pluginPath: string, createNodes: CreateNodes<T>, pluginOptions: T): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/devkit",
3
- "version": "23.0.0-beta.22",
3
+ "version": "23.0.0-beta.23",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "jest": "30.3.0",
63
- "nx": "23.0.0-beta.22"
63
+ "nx": "23.0.0-beta.23"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "nx": ">= 22 <= 24 || ^23.0.0-0"