@nx/devkit 19.6.0-canary.20240806-a3869a8 → 19.6.0-canary.20240808-333ab77

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.6.0-canary.20240806-a3869a8",
3
+ "version": "19.6.0-canary.20240808-333ab77",
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.6.0-canary.20240806-a3869a8"
39
+ "@nrwl/devkit": "19.6.0-canary.20240808-333ab77"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "nx": ">= 17 <= 20"
@@ -0,0 +1,3 @@
1
+ import { type Tree } from 'nx/src/devkit-exports';
2
+ export declare function addBuildTargetDefaults(tree: Tree, executorName: string, buildTargetName?: string): void;
3
+ export declare function addE2eCiTargetDefaults(tree: Tree, e2ePlugin: string, buildTarget: string, pathToE2EConfigFile: string): Promise<void>;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addBuildTargetDefaults = addBuildTargetDefaults;
4
+ exports.addE2eCiTargetDefaults = addE2eCiTargetDefaults;
5
+ const devkit_exports_1 = require("nx/src/devkit-exports");
6
+ const devkit_internals_1 = require("nx/src/devkit-internals");
7
+ function addBuildTargetDefaults(tree, executorName, buildTargetName = 'build') {
8
+ const nxJson = (0, devkit_exports_1.readNxJson)(tree);
9
+ nxJson.targetDefaults ??= {};
10
+ nxJson.targetDefaults[executorName] ??= {
11
+ cache: true,
12
+ dependsOn: [`^${buildTargetName}`],
13
+ inputs: nxJson.namedInputs && 'production' in nxJson.namedInputs
14
+ ? ['production', '^production']
15
+ : ['default', '^default'],
16
+ };
17
+ (0, devkit_exports_1.updateNxJson)(tree, nxJson);
18
+ }
19
+ async function addE2eCiTargetDefaults(tree, e2ePlugin, buildTarget, pathToE2EConfigFile) {
20
+ const nxJson = (0, devkit_exports_1.readNxJson)(tree);
21
+ if (!nxJson.plugins) {
22
+ return;
23
+ }
24
+ const e2ePluginRegistrations = nxJson.plugins.filter((p) => typeof p === 'string' ? p === e2ePlugin : p.plugin === e2ePlugin);
25
+ if (!e2ePluginRegistrations.length) {
26
+ return;
27
+ }
28
+ const resolvedE2ePlugin = await Promise.resolve(`${e2ePlugin}`).then(s => require(s));
29
+ const e2ePluginGlob = resolvedE2ePlugin.createNodesV2?.[0] ?? resolvedE2ePlugin.createNodes?.[0];
30
+ let foundPluginForApplication;
31
+ for (let i = 0; i < e2ePluginRegistrations.length; i++) {
32
+ let candidatePluginForApplication = e2ePluginRegistrations[i];
33
+ if (typeof candidatePluginForApplication === 'string') {
34
+ foundPluginForApplication = candidatePluginForApplication;
35
+ break;
36
+ }
37
+ const matchingConfigFiles = (0, devkit_internals_1.findMatchingConfigFiles)([pathToE2EConfigFile], e2ePluginGlob, candidatePluginForApplication.include, candidatePluginForApplication.exclude);
38
+ if (matchingConfigFiles.length) {
39
+ foundPluginForApplication = candidatePluginForApplication;
40
+ break;
41
+ }
42
+ }
43
+ if (!foundPluginForApplication) {
44
+ return;
45
+ }
46
+ const ciTargetName = typeof foundPluginForApplication === 'string'
47
+ ? 'e2e-ci'
48
+ : foundPluginForApplication.options?.ciTargetName ?? 'e2e-ci';
49
+ const ciTargetNameGlob = `${ciTargetName}--**/*`;
50
+ nxJson.targetDefaults ??= {};
51
+ const e2eCiTargetDefaults = nxJson.targetDefaults[ciTargetNameGlob];
52
+ if (!e2eCiTargetDefaults) {
53
+ nxJson.targetDefaults[ciTargetNameGlob] = {
54
+ dependsOn: [buildTarget],
55
+ };
56
+ }
57
+ else {
58
+ e2eCiTargetDefaults.dependsOn ??= [];
59
+ if (!e2eCiTargetDefaults.dependsOn.includes(buildTarget)) {
60
+ e2eCiTargetDefaults.dependsOn.push(buildTarget);
61
+ }
62
+ }
63
+ (0, devkit_exports_1.updateNxJson)(tree, nxJson);
64
+ }
@@ -0,0 +1,2 @@
1
+ import { type Tree, type PluginConfiguration } from 'nx/src/devkit-exports';
2
+ export declare function findPluginForConfigFile(tree: Tree, pluginName: string, pathToConfigFile: string): Promise<PluginConfiguration>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findPluginForConfigFile = findPluginForConfigFile;
4
+ const devkit_exports_1 = require("nx/src/devkit-exports");
5
+ const devkit_internals_1 = require("nx/src/devkit-internals");
6
+ async function findPluginForConfigFile(tree, pluginName, pathToConfigFile) {
7
+ const nxJson = (0, devkit_exports_1.readNxJson)(tree);
8
+ if (!nxJson.plugins) {
9
+ return;
10
+ }
11
+ const pluginRegistrations = nxJson.plugins.filter((p) => (typeof p === 'string' ? p === pluginName : p.plugin === pluginName));
12
+ for (const plugin of pluginRegistrations) {
13
+ if (typeof plugin === 'string') {
14
+ return plugin;
15
+ }
16
+ if (!plugin.include && !plugin.exclude) {
17
+ return plugin;
18
+ }
19
+ if (plugin.include || plugin.exclude) {
20
+ const resolvedPlugin = await Promise.resolve(`${pluginName}`).then(s => require(s));
21
+ const pluginGlob = resolvedPlugin.createNodesV2?.[0] ?? resolvedPlugin.createNodes?.[0];
22
+ const matchingConfigFile = (0, devkit_internals_1.findMatchingConfigFiles)([pathToConfigFile], pluginGlob, plugin.include, plugin.exclude);
23
+ if (matchingConfigFile.length) {
24
+ return plugin;
25
+ }
26
+ }
27
+ }
28
+ }
@@ -1,2 +0,0 @@
1
- import { Tree } from 'nx/src/devkit-exports';
2
- export declare function addBuildTargetDefaults(tree: Tree, executorName: string, buildTargetName?: string): void;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addBuildTargetDefaults = addBuildTargetDefaults;
4
- const devkit_exports_1 = require("nx/src/devkit-exports");
5
- function addBuildTargetDefaults(tree, executorName, buildTargetName = 'build') {
6
- const nxJson = (0, devkit_exports_1.readNxJson)(tree);
7
- nxJson.targetDefaults ??= {};
8
- nxJson.targetDefaults[executorName] ??= {
9
- cache: true,
10
- dependsOn: [`^${buildTargetName}`],
11
- inputs: nxJson.namedInputs && 'production' in nxJson.namedInputs
12
- ? ['production', '^production']
13
- : ['default', '^default'],
14
- };
15
- (0, devkit_exports_1.updateNxJson)(tree, nxJson);
16
- }