@nx/workspace 19.8.0 → 20.0.0-beta.0

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/generators.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "hidden": true
11
11
  },
12
12
  "move": {
13
- "factory": "./src/generators/move/move#moveGeneratorInternal",
13
+ "factory": "./src/generators/move/move",
14
14
  "schema": "./src/generators/move/schema.json",
15
15
  "aliases": ["mv"],
16
16
  "description": "Move an application or library to another folder."
@@ -45,7 +45,7 @@
45
45
  "description": "Fixes projects configuration"
46
46
  },
47
47
  "npm-package": {
48
- "factory": "./src/generators/npm-package/npm-package#npmPackageGeneratorInternal",
48
+ "factory": "./src/generators/npm-package/npm-package#npmPackageGenerator",
49
49
  "schema": "./src/generators/npm-package/schema.json",
50
50
  "description": "Create a minimal NPM package.",
51
51
  "x-type": "library"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/workspace",
3
- "version": "19.8.0",
3
+ "version": "20.0.0-beta.0",
4
4
  "private": false,
5
5
  "description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
6
6
  "repository": {
@@ -61,13 +61,13 @@
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
- "@nx/devkit": "19.8.0",
64
+ "@nx/devkit": "20.0.0-beta.0",
65
65
  "chalk": "^4.1.0",
66
66
  "enquirer": "~2.3.6",
67
67
  "tslib": "^2.3.0",
68
68
  "yargs-parser": "21.1.1",
69
- "nx": "19.8.0",
70
- "@nrwl/workspace": "19.8.0"
69
+ "nx": "20.0.0-beta.0",
70
+ "@nrwl/workspace": "20.0.0-beta.0"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeSchema = normalizeSchema;
4
- const devkit_1 = require("@nx/devkit");
5
- const enquirer_1 = require("enquirer");
6
4
  const get_import_path_1 = require("../../../utilities/get-import-path");
7
5
  const utils_1 = require("./utils");
8
6
  async function normalizeSchema(tree, schema, projectConfiguration) {
@@ -16,25 +14,14 @@ async function normalizeSchema(tree, schema, projectConfiguration) {
16
14
  };
17
15
  }
18
16
  async function determineProjectNameAndRootOptions(tree, options, projectConfiguration) {
19
- if (!options.projectNameAndRootFormat &&
20
- (process.env.NX_INTERACTIVE !== 'true' || !isTTY())) {
21
- options.projectNameAndRootFormat = 'derived';
22
- }
23
- validateName(options.newProjectName, options.projectNameAndRootFormat, projectConfiguration);
24
- const formats = getProjectNameAndRootFormats(tree, options, projectConfiguration);
25
- const format = options.projectNameAndRootFormat ?? (await determineFormat(formats));
26
- if (format === 'derived') {
27
- logDeprecationMessage(formats, options);
28
- }
29
- return formats[format];
17
+ validateName(options.newProjectName, projectConfiguration);
18
+ const projectNameAndRootOptions = getProjectNameAndRootOptions(tree, options, projectConfiguration);
19
+ return projectNameAndRootOptions;
30
20
  }
31
- function validateName(name, projectNameAndRootFormat, projectConfiguration) {
21
+ function validateName(name, projectConfiguration) {
32
22
  if (!name) {
33
23
  return;
34
24
  }
35
- if (projectNameAndRootFormat === 'derived' && name.startsWith('@')) {
36
- throw new Error(`The new project name "${name}" cannot start with "@" when the "projectNameAndRootFormat" is "derived".`);
37
- }
38
25
  /**
39
26
  * Matches two types of project names:
40
27
  *
@@ -60,7 +47,7 @@ function validateName(name, projectNameAndRootFormat, projectConfiguration) {
60
47
  }
61
48
  }
62
49
  }
63
- function getProjectNameAndRootFormats(tree, options, projectConfiguration) {
50
+ function getProjectNameAndRootOptions(tree, options, projectConfiguration) {
64
51
  let destination = (0, utils_1.normalizePathSlashes)(options.destination);
65
52
  if (options.newProjectName &&
66
53
  options.newProjectName.includes('/') &&
@@ -69,75 +56,7 @@ function getProjectNameAndRootFormats(tree, options, projectConfiguration) {
69
56
  `Please provide a valid name without path segments and the full destination with the "--destination" option.`);
70
57
  }
71
58
  const asProvidedOptions = getAsProvidedOptions(tree, { ...options, destination }, projectConfiguration);
72
- if (options.projectNameAndRootFormat === 'as-provided') {
73
- return {
74
- 'as-provided': asProvidedOptions,
75
- derived: undefined,
76
- };
77
- }
78
- if (asProvidedOptions.newProjectName.startsWith('@')) {
79
- if (!options.projectNameAndRootFormat) {
80
- devkit_1.output.warn({
81
- title: `The provided new project name "${asProvidedOptions.newProjectName}" is a scoped project name and this is not supported by the move generator when using the "derived" format.`,
82
- bodyLines: [
83
- `The generator will try to move the project using the "as-provided" format with the new name "${asProvidedOptions.newProjectName}" located at "${asProvidedOptions.destination}".`,
84
- ],
85
- });
86
- return {
87
- 'as-provided': asProvidedOptions,
88
- derived: undefined,
89
- };
90
- }
91
- throw new Error(`The provided new project name "${options.newProjectName}" is a scoped project name and this is not supported by the move generator when using the "derived" format. ` +
92
- `Please provide a name without "@" or use the "as-provided" format.`);
93
- }
94
- const derivedOptions = getDerivedOptions(tree, { ...options, destination }, projectConfiguration);
95
- return {
96
- 'as-provided': asProvidedOptions,
97
- derived: derivedOptions,
98
- };
99
- }
100
- async function determineFormat(formats) {
101
- if (!formats.derived) {
102
- return 'as-provided';
103
- }
104
- const asProvidedDescription = `As provided:
105
- Name: ${formats['as-provided'].newProjectName}
106
- Destination: ${formats['as-provided'].destination}`;
107
- const asProvidedSelectedValue = `${formats['as-provided'].newProjectName} @ ${formats['as-provided'].destination}`;
108
- const derivedDescription = `Derived:
109
- Name: ${formats['derived'].newProjectName}
110
- Destination: ${formats['derived'].destination}`;
111
- const derivedSelectedValue = `${formats['derived'].newProjectName} @ ${formats['derived'].destination}`;
112
- const result = await (0, enquirer_1.prompt)({
113
- type: 'select',
114
- name: 'format',
115
- message: 'What should be the new project name and where should it be moved to?',
116
- choices: [
117
- {
118
- message: asProvidedDescription,
119
- name: asProvidedSelectedValue,
120
- },
121
- {
122
- message: derivedDescription,
123
- name: derivedSelectedValue,
124
- },
125
- ],
126
- initial: 0,
127
- }).then(({ format }) => format === asProvidedSelectedValue ? 'as-provided' : 'derived');
128
- return result;
129
- }
130
- function logDeprecationMessage(formats, options) {
131
- const callingGenerator = process.env.NX_ANGULAR_MOVE_INVOKED === 'true'
132
- ? '@nx/angular:move'
133
- : '@nx/workspace:move';
134
- devkit_1.logger.warn((0, devkit_1.stripIndents) `
135
- In Nx 20, the project name and destination will no longer be derived.
136
- Please provide the exact new project name and destination in the future.
137
- Example: nx g ${callingGenerator} --projectName ${options.projectName} --destination ${formats['derived'].destination}` +
138
- (options.projectName !== formats['derived'].newProjectName
139
- ? ` --newProjectName ${formats['derived'].newProjectName}`
140
- : ''));
59
+ return asProvidedOptions;
141
60
  }
142
61
  function getAsProvidedOptions(tree, options, projectConfiguration) {
143
62
  const newProjectName = options.newProjectName ?? options.projectName;
@@ -164,19 +83,3 @@ function getAsProvidedOptions(tree, options, projectConfiguration) {
164
83
  }
165
84
  return { destination, newProjectName, importPath };
166
85
  }
167
- function getDerivedOptions(tree, options, projectConfiguration) {
168
- const newProjectName = options.newProjectName
169
- ? (0, devkit_1.names)(options.newProjectName).fileName
170
- : (0, utils_1.getNewProjectName)(options.destination);
171
- const destination = (0, utils_1.getDestination)(tree, options, projectConfiguration);
172
- let importPath;
173
- if (projectConfiguration.projectType === 'library') {
174
- importPath =
175
- options.importPath ??
176
- (0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, options.destination));
177
- }
178
- return { destination, newProjectName, importPath };
179
- }
180
- function isTTY() {
181
- return !!process.stdout.isTTY && process.env['CI'] !== 'true';
182
- }
@@ -1,5 +1,4 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from './schema';
3
3
  export declare function moveGenerator(tree: Tree, rawSchema: Schema): Promise<void>;
4
- export declare function moveGeneratorInternal(tree: Tree, rawSchema: Schema): Promise<void>;
5
4
  export default moveGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moveGenerator = moveGenerator;
4
- exports.moveGeneratorInternal = moveGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const check_destination_1 = require("./lib/check-destination");
7
6
  const create_project_configuration_in_new_destination_1 = require("./lib/create-project-configuration-in-new-destination");
@@ -21,12 +20,6 @@ const update_readme_1 = require("./lib/update-readme");
21
20
  const update_storybook_config_1 = require("./lib/update-storybook-config");
22
21
  const extract_base_configs_1 = require("./lib/extract-base-configs");
23
22
  async function moveGenerator(tree, rawSchema) {
24
- await moveGeneratorInternal(tree, {
25
- projectNameAndRootFormat: 'derived',
26
- ...rawSchema,
27
- });
28
- }
29
- async function moveGeneratorInternal(tree, rawSchema) {
30
23
  let projectConfig = (0, devkit_1.readProjectConfiguration)(tree, rawSchema.projectName);
31
24
  const schema = await (0, normalize_schema_1.normalizeSchema)(tree, rawSchema, projectConfig);
32
25
  (0, check_destination_1.checkDestination)(tree, schema, rawSchema.destination);
@@ -5,5 +5,4 @@ export interface ProjectOptions {
5
5
  directory?: string;
6
6
  projectNameAndRootFormat?: ProjectNameAndRootFormat;
7
7
  }
8
- export declare function npmPackageGenerator(tree: Tree, options: ProjectOptions): Promise<void>;
9
- export declare function npmPackageGeneratorInternal(tree: Tree, _options: ProjectOptions): Promise<void>;
8
+ export declare function npmPackageGenerator(tree: Tree, _options: ProjectOptions): Promise<void>;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.npmPackageGenerator = npmPackageGenerator;
4
- exports.npmPackageGeneratorInternal = npmPackageGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
6
  const path_1 = require("path");
@@ -12,7 +11,6 @@ async function normalizeOptions(tree, options) {
12
11
  projectType: 'library',
13
12
  directory: options.directory,
14
13
  projectNameAndRootFormat: options.projectNameAndRootFormat,
15
- callingGenerator: '@nx/workspace:npm-package',
16
14
  });
17
15
  return {
18
16
  ...options,
@@ -31,13 +29,7 @@ function addFiles(projectRoot, tree, options) {
31
29
  });
32
30
  (0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), projectRoot, {});
33
31
  }
34
- async function npmPackageGenerator(tree, options) {
35
- return await npmPackageGeneratorInternal(tree, {
36
- projectNameAndRootFormat: 'derived',
37
- ...options,
38
- });
39
- }
40
- async function npmPackageGeneratorInternal(tree, _options) {
32
+ async function npmPackageGenerator(tree, _options) {
41
33
  const options = await normalizeOptions(tree, _options);
42
34
  (0, devkit_1.addProjectConfiguration)(tree, options.name, {
43
35
  root: options.projectRoot,