@nx/devkit 17.0.0-rc.0 → 17.0.0-rc.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": "17.0.0-rc.0",
3
+ "version": "17.0.0-rc.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.",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "tmp": "~0.2.1",
35
35
  "tslib": "^2.3.0",
36
36
  "semver": "7.5.3",
37
- "@nrwl/devkit": "17.0.0-rc.0"
37
+ "@nrwl/devkit": "17.0.0-rc.2"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "nx": ">= 16 <= 18"
@@ -7,9 +7,16 @@ const nx_1 = require("../../nx");
7
7
  const names_1 = require("../utils/names");
8
8
  const { createProjectRootMappingsFromProjectConfigurations, findProjectForPath, getProjects, joinPathFragments, logger, normalizePath, output, workspaceRoot, } = (0, nx_1.requireNx)();
9
9
  async function determineArtifactNameAndDirectoryOptions(tree, options) {
10
+ if (!options.nameAndDirectoryFormat &&
11
+ (process.env.NX_INTERACTIVE !== 'true' || !isTTY())) {
12
+ options.nameAndDirectoryFormat = 'derived';
13
+ }
10
14
  const formats = getNameAndDirectoryOptionFormats(tree, options);
11
15
  const format = options.nameAndDirectoryFormat ?? (await determineFormat(formats, options));
12
16
  validateResolvedProject(tree, formats[format]?.project, options, formats[format]?.directory);
17
+ if (format === 'derived' && options.callingGenerator) {
18
+ logDeprecationMessage(options, formats);
19
+ }
13
20
  return {
14
21
  ...formats[format],
15
22
  nameAndDirectoryFormat: format,
@@ -20,10 +27,6 @@ async function determineFormat(formats, options) {
20
27
  if (!formats.derived) {
21
28
  return 'as-provided';
22
29
  }
23
- if (process.env.NX_INTERACTIVE !== 'true' || !isTTY()) {
24
- logDeprecationMessage(options, formats);
25
- return 'derived';
26
- }
27
30
  const asProvidedDescription = `As provided: ${formats['as-provided'].filePath}`;
28
31
  const asProvidedSelectedValue = formats['as-provided'].filePath;
29
32
  const derivedDescription = `Derived: ${formats['derived'].filePath}`;
@@ -47,9 +50,6 @@ async function determineFormat(formats, options) {
47
50
  ],
48
51
  initial: 'as-provided',
49
52
  }).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
50
- if (result === 'derived' && options.callingGenerator) {
51
- logDeprecationMessage(options, formats);
52
- }
53
53
  return result;
54
54
  }
55
55
  function logDeprecationMessage(options, formats) {
@@ -41,3 +41,7 @@ export type ProjectNameAndRootOptions = {
41
41
  export declare function determineProjectNameAndRootOptions(tree: Tree, options: ProjectGenerationOptions): Promise<ProjectNameAndRootOptions & {
42
42
  projectNameAndRootFormat: ProjectNameAndRootFormat;
43
43
  }>;
44
+ /**
45
+ * Function for setting cwd during testing
46
+ */
47
+ export declare function setCwd(path: string): void;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.determineProjectNameAndRootOptions = void 0;
3
+ exports.setCwd = exports.determineProjectNameAndRootOptions = void 0;
4
4
  const enquirer_1 = require("enquirer");
5
5
  const path_1 = require("path");
6
6
  const nx_1 = require("../../nx");
7
7
  const get_workspace_layout_1 = require("../utils/get-workspace-layout");
8
8
  const names_1 = require("../utils/names");
9
- const { joinPathFragments, normalizePath, logger, readJson, readNxJson, updateNxJson, stripIndents, workspaceRoot, } = (0, nx_1.requireNx)();
9
+ const { joinPathFragments, normalizePath, logger, readJson, stripIndents, workspaceRoot, } = (0, nx_1.requireNx)();
10
10
  const deprecationWarning = stripIndents `
11
11
  In Nx 18, generating projects will no longer derive the name and root.
12
12
  Please provide the exact project name and root in the future.`;
@@ -199,11 +199,6 @@ function getImportPath(npmScope, name) {
199
199
  return npmScope ? `${npmScope === '@' ? '' : '@'}${npmScope}/${name}` : name;
200
200
  }
201
201
  function getNpmScope(tree) {
202
- const nxJson = readNxJson(tree);
203
- // TODO(v17): Remove reading this from nx.json
204
- if (nxJson?.npmScope) {
205
- return nxJson.npmScope;
206
- }
207
202
  const { name } = tree.exists('package.json')
208
203
  ? readJson(tree, 'package.json')
209
204
  : { name: null };
@@ -223,3 +218,10 @@ function getCwd() {
223
218
  ? process.env.INIT_CWD
224
219
  : process.cwd();
225
220
  }
221
+ /**
222
+ * Function for setting cwd during testing
223
+ */
224
+ function setCwd(path) {
225
+ process.env.INIT_CWD = (0, path_1.join)(workspaceRoot, path);
226
+ }
227
+ exports.setCwd = setCwd;
@@ -29,6 +29,12 @@ function installPackagesTask(tree, alwaysRun = false, cwd = '', packageManager =
29
29
  cwd: (0, path_1.join)(tree.root, cwd),
30
30
  stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
31
31
  };
32
+ // ensure local registry from process is not interfering with the install
33
+ // when we start the process from temp folder the local registry would override the custom registry
34
+ if (process.env.npm_config_registry &&
35
+ process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
36
+ delete process.env.npm_config_registry;
37
+ }
32
38
  (0, child_process_1.execSync)(pmc.install, execSyncOptions);
33
39
  }
34
40
  }
@@ -6,7 +6,7 @@ import type { Tree } from 'nx/src/generators/tree';
6
6
  * Example:
7
7
  *
8
8
  * ```typescript
9
- * { appsDir: 'apps', libsDir: 'libs', npmScope: 'myorg' }
9
+ * { appsDir: 'apps', libsDir: 'libs' }
10
10
  * ```
11
11
  * @param tree - file system tree
12
12
  */
@@ -14,10 +14,6 @@ export declare function getWorkspaceLayout(tree: Tree): {
14
14
  appsDir: string;
15
15
  libsDir: string;
16
16
  standaloneAsDefault: boolean;
17
- /**
18
- * @deprecated This will be removed in Nx 17. Use {@link getNpmScope} instead.
19
- */
20
- npmScope: string;
21
17
  };
22
18
  /**
23
19
  * Experimental
@@ -10,7 +10,7 @@ const { readNxJson } = (0, nx_1.requireNx)();
10
10
  * Example:
11
11
  *
12
12
  * ```typescript
13
- * { appsDir: 'apps', libsDir: 'libs', npmScope: 'myorg' }
13
+ * { appsDir: 'apps', libsDir: 'libs' }
14
14
  * ```
15
15
  * @param tree - file system tree
16
16
  */
@@ -21,7 +21,6 @@ function getWorkspaceLayout(tree) {
21
21
  inOrderOfPreference(tree, ['apps', 'packages'], '.'),
22
22
  libsDir: nxJson?.workspaceLayout?.libsDir ??
23
23
  inOrderOfPreference(tree, ['libs', 'packages'], '.'),
24
- npmScope: nxJson?.npmScope,
25
24
  standaloneAsDefault: true,
26
25
  };
27
26
  }