@nx/devkit 22.7.0-beta.1 → 22.7.0-beta.2

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": "22.7.0-beta.1",
3
+ "version": "22.7.0-beta.2",
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": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "jest": "^30.0.2",
41
- "nx": "22.7.0-beta.1"
41
+ "nx": "22.7.0-beta.2"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "nx": ">= 21 <= 23 || ^22.0.0-0"
package/project.json CHANGED
@@ -7,7 +7,12 @@
7
7
  "build": {
8
8
  "outputs": ["{workspaceRoot}/dist/packages/devkit/README.md"],
9
9
  "command": "node ./scripts/copy-readme.js devkit",
10
- "dependsOn": ["^build", "build-base", "legacy-post-build"]
10
+ "dependsOn": [
11
+ "^build",
12
+ "nx:legacy-post-build",
13
+ "build-base",
14
+ "legacy-post-build"
15
+ ]
11
16
  },
12
17
  "legacy-post-build": {
13
18
  "executor": "@nx/workspace-plugin:legacy-post-build",
@@ -1 +1 @@
1
- {"version":3,"file":"parse-target-string.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/executors/parse-target-string.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EAEZ,MAAM,EACP,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,GACzB,MAAM,CAAC;AACV;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,eAAe,GACnB,MAAM,CAAC;AA2CV;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,MAAM,EACN,aAAa,GACd,EAAE,MAAM,GAAG,MAAM,CAIjB"}
1
+ {"version":3,"file":"parse-target-string.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/executors/parse-target-string.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EAEZ,MAAM,EACP,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,YAAY,GACzB,MAAM,CAAC;AACV;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,eAAe,GACnB,MAAM,CAAC;AAiDV;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,MAAM,EACN,aAAa,GACd,EAAE,MAAM,GAAG,MAAM,CAIjB"}
@@ -23,7 +23,10 @@ function parseTargetString(targetString, projectGraphOrCtx) {
23
23
  maybeProject !== projectGraphOrCtx.projectName) {
24
24
  targetString = `${projectGraphOrCtx.projectName}:${targetString}`;
25
25
  }
26
- const [project, target, configuration] = (0, devkit_internals_1.splitTarget)(targetString, projectGraph);
26
+ const currentProject = projectGraphOrCtx && 'projectName' in projectGraphOrCtx
27
+ ? projectGraphOrCtx.projectName
28
+ : undefined;
29
+ const [project, target, configuration] = (0, devkit_internals_1.splitTarget)(targetString, projectGraph, { currentProject });
27
30
  if (!project || !target) {
28
31
  throw new Error(`Invalid Target String: ${targetString}`);
29
32
  }
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatFiles = formatFiles;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_exports_1 = require("nx/src/devkit-exports");
5
6
  const devkit_internals_1 = require("nx/src/devkit-internals");
6
- const path = require("path");
7
+ const path = tslib_1.__importStar(require("path"));
7
8
  /**
8
9
  * Formats all the created or updated files using Prettier
9
10
  * @param tree - the file system tree
@@ -31,7 +32,7 @@ async function formatFiles(tree, options = {}) {
31
32
  }
32
33
  let prettier;
33
34
  try {
34
- prettier = await Promise.resolve().then(() => require('prettier'));
35
+ prettier = await Promise.resolve().then(() => tslib_1.__importStar(require('prettier')));
35
36
  /**
36
37
  * Even after we discovered prettier in node_modules, we need to be sure that the user is intentionally using prettier
37
38
  * before proceeding to format with it.
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OverwriteStrategy = void 0;
4
4
  exports.generateFiles = generateFiles;
5
+ const tslib_1 = require("tslib");
5
6
  const fs_1 = require("fs");
6
- const path = require("path");
7
+ const path = tslib_1.__importStar(require("path"));
7
8
  const binary_extensions_1 = require("../utils/binary-extensions");
8
9
  const devkit_exports_1 = require("nx/src/devkit-exports");
9
10
  /**
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.addBuildTargetDefaults = addBuildTargetDefaults;
4
37
  exports.addE2eCiTargetDefaults = addE2eCiTargetDefaults;
@@ -25,7 +58,7 @@ async function addE2eCiTargetDefaults(tree, e2ePlugin, buildTarget, pathToE2ECon
25
58
  if (!e2ePluginRegistrations.length) {
26
59
  return;
27
60
  }
28
- const resolvedE2ePlugin = await Promise.resolve(`${e2ePlugin}`).then(s => require(s));
61
+ const resolvedE2ePlugin = await Promise.resolve(`${e2ePlugin}`).then(s => __importStar(require(s)));
29
62
  const e2ePluginGlob = resolvedE2ePlugin.createNodesV2?.[0] ?? resolvedE2ePlugin.createNodes?.[0];
30
63
  let foundPluginForApplication;
31
64
  for (let i = 0; i < e2ePluginRegistrations.length; i++) {
@@ -4,7 +4,8 @@ import { PackageManager, Tree } from 'nx/src/devkit-exports';
4
4
  * `package.json` hasn't changed at all or it hasn't changed since the last invocation.
5
5
  *
6
6
  * @param tree - the file system tree
7
- * @param alwaysRun - always run the command even if `package.json` hasn't changed.
7
+ * @param ensureInstall - ensure install runs even if `package.json` hasn't changed,
8
+ * unless install already ran this generator cycle.
8
9
  */
9
- export declare function installPackagesTask(tree: Tree, alwaysRun?: boolean, cwd?: string, packageManager?: PackageManager): void;
10
+ export declare function installPackagesTask(tree: Tree, ensureInstall?: boolean, cwd?: string, packageManager?: PackageManager): void;
10
11
  //# sourceMappingURL=install-packages-task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"install-packages-task.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/tasks/install-packages-task.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,cAAc,EACd,IAAI,EACL,MAAM,uBAAuB,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,SAAS,GAAE,OAAe,EAC1B,GAAG,GAAE,MAAW,EAChB,cAAc,GAAE,cAA2D,GAC1E,IAAI,CAoCN"}
1
+ {"version":3,"file":"install-packages-task.d.ts","sourceRoot":"","sources":["../../../../../packages/devkit/src/tasks/install-packages-task.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,cAAc,EACd,IAAI,EACL,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,aAAa,GAAE,OAAe,EAC9B,GAAG,GAAE,MAAW,EAChB,cAAc,GAAE,cAA2D,GAC1E,IAAI,CAmCN"}
@@ -9,25 +9,28 @@ const devkit_exports_1 = require("nx/src/devkit-exports");
9
9
  * `package.json` hasn't changed at all or it hasn't changed since the last invocation.
10
10
  *
11
11
  * @param tree - the file system tree
12
- * @param alwaysRun - always run the command even if `package.json` hasn't changed.
12
+ * @param ensureInstall - ensure install runs even if `package.json` hasn't changed,
13
+ * unless install already ran this generator cycle.
13
14
  */
14
- function installPackagesTask(tree, alwaysRun = false, cwd = '', packageManager = (0, devkit_exports_1.detectPackageManager)((0, path_1.join)(tree.root, cwd))) {
15
- if (!tree
15
+ function installPackagesTask(tree, ensureInstall = false, cwd = '', packageManager = (0, devkit_exports_1.detectPackageManager)((0, path_1.join)(tree.root, cwd))) {
16
+ const packageJsonPath = (0, devkit_exports_1.joinPathFragments)(cwd, 'package.json');
17
+ const packageJsonChanged = tree
16
18
  .listChanges()
17
- .find((f) => f.path === (0, devkit_exports_1.joinPathFragments)(cwd, 'package.json')) &&
18
- !alwaysRun) {
19
+ .some((f) => f.path === packageJsonPath);
20
+ if (!packageJsonChanged && !ensureInstall) {
19
21
  return;
20
22
  }
21
- const packageJsonValue = tree.read((0, devkit_exports_1.joinPathFragments)(cwd, 'package.json'), 'utf-8');
22
- let storedPackageJsonValue = global['__packageJsonInstallCache__'];
23
- // Don't install again if install was already executed with package.json
24
- if (storedPackageJsonValue != packageJsonValue || alwaysRun) {
23
+ const packageJsonValue = tree.read(packageJsonPath, 'utf-8');
24
+ const storedPackageJsonValue = global['__packageJsonInstallCache__'];
25
+ const installAlreadyRan = storedPackageJsonValue != null;
26
+ const packageJsonDiffers = storedPackageJsonValue != packageJsonValue;
27
+ if (packageJsonDiffers || (ensureInstall && !installAlreadyRan)) {
25
28
  global['__packageJsonInstallCache__'] = packageJsonValue;
26
29
  const pmc = (0, devkit_exports_1.getPackageManagerCommand)(packageManager);
27
30
  const execSyncOptions = {
28
31
  cwd: (0, path_1.join)(tree.root, cwd),
29
32
  stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
30
- windowsHide: false,
33
+ windowsHide: true,
31
34
  };
32
35
  // ensure local registry from process is not interfering with the install
33
36
  // when we start the process from temp folder the local registry would override the custom registry
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addPlugin = addPlugin;
4
4
  exports.addPluginV1 = addPluginV1;
5
5
  exports.generateCombinations = generateCombinations;
6
- const yargs = require("yargs-parser");
6
+ const tslib_1 = require("tslib");
7
+ const yargs_parser_1 = tslib_1.__importDefault(require("yargs-parser"));
7
8
  const devkit_exports_1 = require("nx/src/devkit-exports");
8
9
  const devkit_internals_1 = require("nx/src/devkit-internals");
9
10
  /**
@@ -159,7 +160,7 @@ function processProject(tree, projectRoot, projectConfiguration) {
159
160
  * - if command has same args, regardless of order => replace removing args
160
161
  * - if command has less args or with different value => replace leaving args
161
162
  */
162
- const parsedCommand = yargs(command, {
163
+ const parsedCommand = (0, yargs_parser_1.default)(command, {
163
164
  configuration: { 'strip-dashed': true },
164
165
  });
165
166
  // this assumes there are no positional args in the command, everything is a command or subcommand
@@ -172,7 +173,7 @@ function processProject(tree, projectRoot, projectConfiguration) {
172
173
  }
173
174
  for (const match of matches) {
174
175
  // parse the matched command within the script
175
- const parsedScript = yargs(match, {
176
+ const parsedScript = (0, yargs_parser_1.default)(match, {
176
177
  configuration: { 'strip-dashed': true },
177
178
  });
178
179
  let hasArgsWithDifferentValues = false;
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.findPluginForConfigFile = findPluginForConfigFile;
4
37
  const devkit_exports_1 = require("nx/src/devkit-exports");
@@ -17,7 +50,7 @@ async function findPluginForConfigFile(tree, pluginName, pathToConfigFile) {
17
50
  return plugin;
18
51
  }
19
52
  if (plugin.include || plugin.exclude) {
20
- const resolvedPlugin = await Promise.resolve(`${pluginName}`).then(s => require(s));
53
+ const resolvedPlugin = await Promise.resolve(`${pluginName}`).then(s => __importStar(require(s)));
21
54
  const pluginGlob = resolvedPlugin.createNodesV2?.[0] ?? resolvedPlugin.createNodes?.[0];
22
55
  const matchingConfigFile = (0, devkit_internals_1.findMatchingConfigFiles)([pathToConfigFile], pluginGlob, plugin.include, plugin.exclude);
23
56
  if (matchingConfigFile.length) {