@nx/workspace 16.8.0-beta.4 → 16.8.0-beta.6

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.
Files changed (52) hide show
  1. package/package.json +29 -29
  2. package/src/executors/counter/counter.impl.js +29 -36
  3. package/src/generators/ci-workflow/ci-workflow.js +22 -21
  4. package/src/generators/convert-to-monorepo/convert-to-monorepo.js +29 -32
  5. package/src/generators/convert-to-nx-project/convert-to-nx-project.js +59 -64
  6. package/src/generators/move/lib/create-project-configuration-in-new-destination.js +6 -5
  7. package/src/generators/move/lib/extract-base-configs.js +13 -16
  8. package/src/generators/move/lib/normalize-schema.js +9 -3
  9. package/src/generators/move/lib/update-eslint-config.js +1 -1
  10. package/src/generators/move/lib/update-imports.js +4 -5
  11. package/src/generators/move/move.js +28 -31
  12. package/src/generators/new/generate-preset.js +4 -8
  13. package/src/generators/new/generate-workspace-files.js +47 -41
  14. package/src/generators/new/new.js +24 -30
  15. package/src/generators/npm-package/npm-package.js +27 -27
  16. package/src/generators/preset/preset.js +182 -188
  17. package/src/generators/remove/lib/check-dependencies.js +12 -15
  18. package/src/generators/remove/lib/check-targets.js +31 -34
  19. package/src/generators/remove/lib/update-tsconfig.js +16 -19
  20. package/src/generators/remove/remove.js +12 -15
  21. package/src/generators/run-commands/run-commands.js +18 -21
  22. package/src/generators/utils/get-npm-package-version.js +1 -1
  23. package/src/generators/utils/presets.d.ts +4 -0
  24. package/src/generators/utils/presets.js +5 -0
  25. package/src/generators/workspace-generator/workspace-generator.js +3 -6
  26. package/src/migrations/update-12-5-0/add-target-dependencies.js +26 -28
  27. package/src/migrations/update-13-0-0/config-locations/config-locations.js +16 -19
  28. package/src/migrations/update-13-0-0/set-default-base-if-not-set.js +16 -21
  29. package/src/migrations/update-13-10-0/update-decorate-cli.js +1 -2
  30. package/src/migrations/update-13-10-0/update-tasks-runner.js +2 -3
  31. package/src/migrations/update-13-2-0/set-parallel-default.js +14 -18
  32. package/src/migrations/update-13-3-0/update-tsc-executor-location.js +17 -20
  33. package/src/migrations/update-13-6-0/remove-old-task-runner-options.js +1 -2
  34. package/src/migrations/update-13-9-0/replace-tao-with-nx.js +2 -3
  35. package/src/migrations/update-13-9-0/update-decorate-cli.js +1 -2
  36. package/src/migrations/update-14-0-0/change-npm-script-executor.js +7 -10
  37. package/src/migrations/update-14-0-0/change-nx-json-presets.js +13 -13
  38. package/src/migrations/update-14-2-0/enable-source-analysis.js +14 -18
  39. package/src/migrations/update-14-8-0/change-run-commands-executor.js +7 -10
  40. package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.js +3 -6
  41. package/src/migrations/update-16-0-0/fix-invalid-babelrc.js +2 -3
  42. package/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.js +51 -60
  43. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  44. package/src/utilities/buildable-libs-utils.js +3 -6
  45. package/src/utilities/default-base.js +1 -1
  46. package/src/utilities/get-import-path.js +1 -1
  47. package/src/utilities/run-tasks-in-serial.js +3 -4
  48. package/src/utilities/typescript/compilation.js +14 -13
  49. package/src/utils/rules/format-files.js +9 -7
  50. package/src/utils/rules/visit-not-ignored-files.js +2 -2
  51. package/src/utils/testing-utils.js +7 -14
  52. package/src/utils/workspace.js +26 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/workspace",
3
- "version": "16.8.0-beta.4",
3
+ "version": "16.8.0-beta.6",
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": {
@@ -33,39 +33,39 @@
33
33
  "requirements": {},
34
34
  "migrations": "./migrations.json",
35
35
  "packageGroup": {
36
- "@nrwl/js": "16.8.0-beta.4",
37
- "@nrwl/jest": "16.8.0-beta.4",
38
- "@nrwl/linter": "16.8.0-beta.4",
39
- "@nrwl/angular": "16.8.0-beta.4",
40
- "@nrwl/cypress": "16.8.0-beta.4",
41
- "@nrwl/detox": "16.8.0-beta.4",
42
- "@nrwl/devkit": "16.8.0-beta.4",
43
- "@nrwl/esbuild": "16.8.0-beta.4",
44
- "@nrwl/eslint-plugin-nx": "16.8.0-beta.4",
45
- "@nrwl/expo": "16.8.0-beta.4",
46
- "@nrwl/express": "16.8.0-beta.4",
47
- "@nrwl/nest": "16.8.0-beta.4",
48
- "@nrwl/next": "16.8.0-beta.4",
49
- "@nrwl/node": "16.8.0-beta.4",
36
+ "@nrwl/js": "16.8.0-beta.6",
37
+ "@nrwl/jest": "16.8.0-beta.6",
38
+ "@nrwl/linter": "16.8.0-beta.6",
39
+ "@nrwl/angular": "16.8.0-beta.6",
40
+ "@nrwl/cypress": "16.8.0-beta.6",
41
+ "@nrwl/detox": "16.8.0-beta.6",
42
+ "@nrwl/devkit": "16.8.0-beta.6",
43
+ "@nrwl/esbuild": "16.8.0-beta.6",
44
+ "@nrwl/eslint-plugin-nx": "16.8.0-beta.6",
45
+ "@nrwl/expo": "16.8.0-beta.6",
46
+ "@nrwl/express": "16.8.0-beta.6",
47
+ "@nrwl/nest": "16.8.0-beta.6",
48
+ "@nrwl/next": "16.8.0-beta.6",
49
+ "@nrwl/node": "16.8.0-beta.6",
50
50
  "nx-cloud": "latest",
51
- "@nrwl/nx-plugin": "16.8.0-beta.4",
52
- "@nrwl/react-native": "16.8.0-beta.4",
53
- "@nrwl/react": "16.8.0-beta.4",
54
- "@nrwl/rollup": "16.8.0-beta.4",
55
- "@nrwl/storybook": "16.8.0-beta.4",
56
- "@nrwl/tao": "16.8.0-beta.4",
57
- "@nrwl/vite": "16.8.0-beta.4",
58
- "@nrwl/web": "16.8.0-beta.4",
59
- "@nrwl/webpack": "16.8.0-beta.4",
60
- "nx": "16.8.0-beta.4"
51
+ "@nrwl/nx-plugin": "16.8.0-beta.6",
52
+ "@nrwl/react-native": "16.8.0-beta.6",
53
+ "@nrwl/react": "16.8.0-beta.6",
54
+ "@nrwl/rollup": "16.8.0-beta.6",
55
+ "@nrwl/storybook": "16.8.0-beta.6",
56
+ "@nrwl/tao": "16.8.0-beta.6",
57
+ "@nrwl/vite": "16.8.0-beta.6",
58
+ "@nrwl/web": "16.8.0-beta.6",
59
+ "@nrwl/webpack": "16.8.0-beta.6",
60
+ "nx": "16.8.0-beta.6"
61
61
  }
62
62
  },
63
63
  "dependencies": {
64
- "@nrwl/workspace": "16.8.0-beta.4",
65
- "@nx/devkit": "16.8.0-beta.4",
64
+ "@nrwl/workspace": "16.8.0-beta.6",
65
+ "@nx/devkit": "16.8.0-beta.6",
66
66
  "chalk": "^4.1.0",
67
67
  "ignore": "^5.0.4",
68
- "nx": "16.8.0-beta.4",
68
+ "nx": "16.8.0-beta.6",
69
69
  "rxjs": "^7.8.0",
70
70
  "tslib": "^2.3.0",
71
71
  "yargs-parser": "21.1.1"
@@ -74,5 +74,5 @@
74
74
  "access": "public"
75
75
  },
76
76
  "type": "commonjs",
77
- "gitHead": "c9aad2dc8c2b34531cf61549bff872e68c481e4e"
77
+ "gitHead": "0cc6ba996f2ef09f00b932c8eacf42de642457f3"
78
78
  }
@@ -1,47 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.batchCounter = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const os_1 = require("os");
6
- function wait() {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- return new Promise((res) => {
9
- setTimeout(() => res(), 1000);
10
- });
5
+ async function wait() {
6
+ return new Promise((res) => {
7
+ setTimeout(() => res(), 1000);
11
8
  });
12
9
  }
13
- function counter(opts) {
14
- return tslib_1.__asyncGenerator(this, arguments, function* counter_1() {
15
- for (let i = 0; i < opts.to; ++i) {
16
- console.log(i);
17
- yield yield tslib_1.__await({ success: false });
18
- yield tslib_1.__await(wait());
19
- }
20
- yield yield tslib_1.__await({ success: opts.result });
21
- });
10
+ async function* counter(opts) {
11
+ for (let i = 0; i < opts.to; ++i) {
12
+ console.log(i);
13
+ yield { success: false };
14
+ await wait();
15
+ }
16
+ yield { success: opts.result };
22
17
  }
23
18
  exports.default = counter;
24
- function batchCounter(taskGraph, inputs) {
25
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
- const result = {};
27
- const results = yield Promise.all(taskGraph.roots
28
- .map((rootTaskId) => [rootTaskId, inputs[rootTaskId]])
29
- .map(([taskId, options]) => tslib_1.__awaiter(this, void 0, void 0, function* () {
30
- let terminalOutput = '';
31
- for (let i = 0; i < options.to; ++i) {
32
- console.log(i);
33
- terminalOutput += i + os_1.EOL;
34
- yield wait();
35
- }
36
- return [taskId, options.result, terminalOutput];
37
- })));
38
- for (const [taskId, taskResult, terminalOutput] of results) {
39
- result[taskId] = {
40
- success: taskResult,
41
- terminalOutput,
42
- };
19
+ async function batchCounter(taskGraph, inputs) {
20
+ const result = {};
21
+ const results = await Promise.all(taskGraph.roots
22
+ .map((rootTaskId) => [rootTaskId, inputs[rootTaskId]])
23
+ .map(async ([taskId, options]) => {
24
+ let terminalOutput = '';
25
+ for (let i = 0; i < options.to; ++i) {
26
+ console.log(i);
27
+ terminalOutput += i + os_1.EOL;
28
+ await wait();
43
29
  }
44
- return result;
45
- });
30
+ return [taskId, options.result, terminalOutput];
31
+ }));
32
+ for (const [taskId, taskResult, terminalOutput] of results) {
33
+ result[taskId] = {
34
+ success: taskResult,
35
+ terminalOutput,
36
+ };
37
+ }
38
+ return result;
46
39
  }
47
40
  exports.batchCounter = batchCounter;
@@ -1,25 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ciWorkflowGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const default_base_1 = require("../../utilities/default-base");
7
6
  const path_1 = require("path");
8
- function ciWorkflowGenerator(host, schema) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- const ci = schema.ci;
11
- const options = normalizeOptions(schema);
12
- const nxJson = (0, devkit_1.readJson)(host, 'nx.json');
13
- const nxCloudUsed = Object.values(nxJson.tasksRunnerOptions).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud');
14
- if (!nxCloudUsed) {
15
- throw new Error('This workspace is not connected to Nx Cloud.');
16
- }
17
- if (ci === 'bitbucket-pipelines' && defaultBranchNeedsOriginPrefix(nxJson)) {
18
- (0, devkit_1.writeJson)(host, 'nx.json', appendOriginPrefix(nxJson));
19
- }
20
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', ci), '', options);
21
- yield (0, devkit_1.formatFiles)(host);
22
- });
7
+ async function ciWorkflowGenerator(host, schema) {
8
+ const ci = schema.ci;
9
+ const options = normalizeOptions(schema);
10
+ const nxJson = (0, devkit_1.readJson)(host, 'nx.json');
11
+ const nxCloudUsed = Object.values(nxJson.tasksRunnerOptions).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud');
12
+ if (!nxCloudUsed) {
13
+ throw new Error('This workspace is not connected to Nx Cloud.');
14
+ }
15
+ if (ci === 'bitbucket-pipelines' && defaultBranchNeedsOriginPrefix(nxJson)) {
16
+ (0, devkit_1.writeJson)(host, 'nx.json', appendOriginPrefix(nxJson));
17
+ }
18
+ (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', ci), '', options);
19
+ await (0, devkit_1.formatFiles)(host);
23
20
  }
24
21
  exports.ciWorkflowGenerator = ciWorkflowGenerator;
25
22
  function normalizeOptions(options) {
@@ -35,12 +32,16 @@ function normalizeOptions(options) {
35
32
  };
36
33
  }
37
34
  function defaultBranchNeedsOriginPrefix(nxJson) {
38
- var _a, _b;
39
- return !((_b = (_a = nxJson.affected) === null || _a === void 0 ? void 0 : _a.defaultBase) === null || _b === void 0 ? void 0 : _b.startsWith('origin/'));
35
+ return !nxJson.affected?.defaultBase?.startsWith('origin/');
40
36
  }
41
37
  function appendOriginPrefix(nxJson) {
42
- var _a, _b;
43
- return Object.assign(Object.assign({}, nxJson), { affected: Object.assign(Object.assign({}, ((_a = nxJson.affected) !== null && _a !== void 0 ? _a : {})), { defaultBase: ((_b = nxJson.affected) === null || _b === void 0 ? void 0 : _b.defaultBase)
38
+ return {
39
+ ...nxJson,
40
+ affected: {
41
+ ...(nxJson.affected ?? {}),
42
+ defaultBase: nxJson.affected?.defaultBase
44
43
  ? `origin/${nxJson.affected.defaultBase}`
45
- : 'origin/main' }) });
44
+ : 'origin/main',
45
+ },
46
+ };
46
47
  }
@@ -1,40 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.monorepoSchematic = exports.monorepoGenerator = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const move_1 = require("../move/move");
7
- function monorepoGenerator(tree, options) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- const projects = (0, devkit_1.getProjects)(tree);
10
- const nxJson = (0, devkit_1.readNxJson)(tree);
11
- (0, devkit_1.updateNxJson)(tree, nxJson);
12
- let rootProject;
13
- const projectsToMove = [];
14
- // Need to determine libs vs packages directory base on the type of root project.
15
- for (const [, project] of projects) {
16
- if (project.root === '.')
17
- rootProject = project;
18
- projectsToMove.push(project);
19
- }
20
- // Currently, Nx only handles apps+libs or packages. You cannot mix and match them.
21
- // If the standalone project is an app (React, Angular, etc), then use apps+libs.
22
- // Otherwise, for TS standalone (lib), use packages.
23
- const isRootProjectApp = rootProject.projectType === 'application';
24
- const appsDir = isRootProjectApp ? 'apps' : 'packages';
25
- const libsDir = isRootProjectApp ? 'libs' : 'packages';
26
- for (const project of projectsToMove) {
27
- yield (0, move_1.moveGenerator)(tree, {
28
- projectName: project.name,
29
- newProjectName: project.name,
30
- destination: project.projectType === 'application'
31
- ? (0, devkit_1.joinPathFragments)(appsDir, project.root === '.' ? project.name : project.root)
32
- : (0, devkit_1.joinPathFragments)(libsDir, project.root === '.' ? project.name : project.root),
33
- destinationRelativeToRoot: true,
34
- updateImportPath: project.projectType === 'library',
35
- });
36
- }
37
- });
6
+ async function monorepoGenerator(tree, options) {
7
+ const projects = (0, devkit_1.getProjects)(tree);
8
+ const nxJson = (0, devkit_1.readNxJson)(tree);
9
+ (0, devkit_1.updateNxJson)(tree, nxJson);
10
+ let rootProject;
11
+ const projectsToMove = [];
12
+ // Need to determine libs vs packages directory base on the type of root project.
13
+ for (const [, project] of projects) {
14
+ if (project.root === '.')
15
+ rootProject = project;
16
+ projectsToMove.push(project);
17
+ }
18
+ // Currently, Nx only handles apps+libs or packages. You cannot mix and match them.
19
+ // If the standalone project is an app (React, Angular, etc), then use apps+libs.
20
+ // Otherwise, for TS standalone (lib), use packages.
21
+ const isRootProjectApp = rootProject.projectType === 'application';
22
+ const appsDir = isRootProjectApp ? 'apps' : 'packages';
23
+ const libsDir = isRootProjectApp ? 'libs' : 'packages';
24
+ for (const project of projectsToMove) {
25
+ await (0, move_1.moveGenerator)(tree, {
26
+ projectName: project.name,
27
+ newProjectName: project.name,
28
+ destination: project.projectType === 'application'
29
+ ? (0, devkit_1.joinPathFragments)(appsDir, project.root === '.' ? project.name : project.root)
30
+ : (0, devkit_1.joinPathFragments)(libsDir, project.root === '.' ? project.name : project.root),
31
+ destinationRelativeToRoot: true,
32
+ updateImportPath: project.projectType === 'library',
33
+ });
34
+ }
38
35
  }
39
36
  exports.monorepoGenerator = monorepoGenerator;
40
37
  exports.default = monorepoGenerator;
@@ -1,83 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToNxProjectSchematic = exports.convertToNxProjectGenerator = exports.validateSchema = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path_1 = require("path");
7
6
  const angular_json_1 = require("nx/src/adapter/angular-json");
8
7
  const output_1 = require("../../utils/output");
9
- function validateSchema(schema, configName) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- if (schema.project && schema.all) {
12
- throw new Error('--project and --all are mutually exclusive');
13
- }
14
- if (schema.project && schema.reformat) {
15
- throw new Error('--project and --reformat are mutually exclusive');
16
- }
17
- if (schema.all && schema.reformat) {
18
- throw new Error('--all and --reformat are mutually exclusive');
19
- }
20
- if ((configName === 'workspace.json' && schema.project) ||
21
- (configName === 'workspace.json' && schema.reformat)) {
22
- throw new Error('workspace.json is no longer supported. Please pass --all to convert all projects and remove workspace.json.');
23
- }
24
- if (!schema.project && !schema.all && !schema.reformat) {
25
- schema.all = true;
26
- }
27
- });
8
+ async function validateSchema(schema, configName) {
9
+ if (schema.project && schema.all) {
10
+ throw new Error('--project and --all are mutually exclusive');
11
+ }
12
+ if (schema.project && schema.reformat) {
13
+ throw new Error('--project and --reformat are mutually exclusive');
14
+ }
15
+ if (schema.all && schema.reformat) {
16
+ throw new Error('--all and --reformat are mutually exclusive');
17
+ }
18
+ if ((configName === 'workspace.json' && schema.project) ||
19
+ (configName === 'workspace.json' && schema.reformat)) {
20
+ throw new Error('workspace.json is no longer supported. Please pass --all to convert all projects and remove workspace.json.');
21
+ }
22
+ if (!schema.project && !schema.all && !schema.reformat) {
23
+ schema.all = true;
24
+ }
28
25
  }
29
26
  exports.validateSchema = validateSchema;
30
- function convertToNxProjectGenerator(host, schema) {
31
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
32
- const configName = host.exists('angular.json')
33
- ? 'angular.json'
34
- : 'workspace.json';
35
- if (!host.exists(configName))
36
- return;
37
- yield validateSchema(schema, configName);
38
- const projects = (0, angular_json_1.toNewFormat)((0, devkit_1.readJson)(host, configName)).projects;
39
- const leftOverProjects = {};
40
- for (const projectName of Object.keys(projects)) {
41
- const config = projects[projectName];
42
- if ((!schema.project || schema.project === projectName) &&
43
- !schema.reformat) {
44
- if (typeof config === 'string') {
45
- // configuration is in project.json
46
- const projectConfig = (0, devkit_1.readJson)(host, (0, path_1.join)(config, 'project.json'));
47
- if (projectConfig.name !== projectName) {
48
- projectConfig.name = projectName;
49
- projectConfig.root = config;
50
- (0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfig);
51
- }
52
- }
53
- else {
54
- // configuration is an object in workspace.json
55
- const path = (0, path_1.join)(config.root, 'project.json');
56
- if (!host.exists(path)) {
57
- projects[projectName].name = projectName;
58
- (0, devkit_1.addProjectConfiguration)(host, path, projects[projectName]);
59
- }
27
+ async function convertToNxProjectGenerator(host, schema) {
28
+ const configName = host.exists('angular.json')
29
+ ? 'angular.json'
30
+ : 'workspace.json';
31
+ if (!host.exists(configName))
32
+ return;
33
+ await validateSchema(schema, configName);
34
+ const projects = (0, angular_json_1.toNewFormat)((0, devkit_1.readJson)(host, configName)).projects;
35
+ const leftOverProjects = {};
36
+ for (const projectName of Object.keys(projects)) {
37
+ const config = projects[projectName];
38
+ if ((!schema.project || schema.project === projectName) &&
39
+ !schema.reformat) {
40
+ if (typeof config === 'string') {
41
+ // configuration is in project.json
42
+ const projectConfig = (0, devkit_1.readJson)(host, (0, path_1.join)(config, 'project.json'));
43
+ if (projectConfig.name !== projectName) {
44
+ projectConfig.name = projectName;
45
+ projectConfig.root = config;
46
+ (0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfig);
60
47
  }
61
48
  }
62
49
  else {
63
- leftOverProjects[projectName] = config;
50
+ // configuration is an object in workspace.json
51
+ const path = (0, path_1.join)(config.root, 'project.json');
52
+ if (!host.exists(path)) {
53
+ projects[projectName].name = projectName;
54
+ (0, devkit_1.addProjectConfiguration)(host, path, projects[projectName]);
55
+ }
64
56
  }
65
57
  }
66
- if (Object.keys(leftOverProjects).length > 0) {
67
- (0, devkit_1.writeJson)(host, 'angular.json', (0, angular_json_1.toOldFormat)({ version: 1, projects: leftOverProjects }));
68
- }
69
58
  else {
70
- host.delete(configName);
71
- }
72
- if (!schema.skipFormat) {
73
- yield (0, devkit_1.formatFiles)(host);
59
+ leftOverProjects[projectName] = config;
74
60
  }
75
- output_1.output.note({
76
- title: 'Use "nx show projects" to read the list of projects.',
77
- bodyLines: [
78
- `If you read the list of projects from ${configName}, use "nx show projects" instead.`,
79
- ],
80
- });
61
+ }
62
+ if (Object.keys(leftOverProjects).length > 0) {
63
+ (0, devkit_1.writeJson)(host, 'angular.json', (0, angular_json_1.toOldFormat)({ version: 1, projects: leftOverProjects }));
64
+ }
65
+ else {
66
+ host.delete(configName);
67
+ }
68
+ if (!schema.skipFormat) {
69
+ await (0, devkit_1.formatFiles)(host);
70
+ }
71
+ output_1.output.note({
72
+ title: 'Use "nx show projects" to read the list of projects.',
73
+ bodyLines: [
74
+ `If you read the list of projects from ${configName}, use "nx show projects" instead.`,
75
+ ],
81
76
  });
82
77
  }
83
78
  exports.convertToNxProjectGenerator = convertToNxProjectGenerator;
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createProjectConfigurationInNewDestination = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  function createProjectConfigurationInNewDestination(tree, schema, projectConfig) {
7
- var _a;
8
6
  projectConfig.name = schema.newProjectName;
9
7
  const isRootProject = projectConfig.root === '.';
10
8
  // Subtle bug if project name === path, where the updated name was being overrideen.
11
- const { name } = projectConfig, rest = tslib_1.__rest(projectConfig, ["name"]);
9
+ const { name, ...rest } = projectConfig;
12
10
  // replace old root path with new one
13
11
  let newProjectString = JSON.stringify(rest);
14
12
  if (isRootProject) {
@@ -21,7 +19,10 @@ function createProjectConfigurationInNewDestination(tree, schema, projectConfig)
21
19
  else {
22
20
  newProjectString = newProjectString.replace(new RegExp(projectConfig.root, 'g'), schema.relativeToRootDestination);
23
21
  }
24
- const newProject = Object.assign({ name }, JSON.parse(newProjectString));
22
+ const newProject = {
23
+ name,
24
+ ...JSON.parse(newProjectString),
25
+ };
25
26
  newProject.root = schema.relativeToRootDestination;
26
27
  // Correct "e2e" target and config since part of the rename will be wrong unless we make the project name "e2e" more unique.
27
28
  // e.g. my-app-e2e is safer to search and replace than "e2e".
@@ -30,7 +31,7 @@ function createProjectConfigurationInNewDestination(tree, schema, projectConfig)
30
31
  const wrongName = schema.relativeToRootDestination;
31
32
  if (targetName !== wrongName)
32
33
  continue;
33
- if (((_a = targetConfig.options) === null || _a === void 0 ? void 0 : _a.testingType) === wrongName) {
34
+ if (targetConfig.options?.testingType === wrongName) {
34
35
  targetConfig.options.testingType = 'e2e';
35
36
  }
36
37
  newProject.targets['e2e'] = targetConfig;
@@ -1,32 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.maybeExtractEslintConfigIfRootProject = exports.maybeExtractJestConfigBase = exports.maybeExtractTsConfigBase = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  function maybeExtractTsConfigBase(tree) {
7
6
  let extractTsConfigBase;
8
7
  try {
9
8
  extractTsConfigBase = require('@nx/' + 'js').extractTsConfigBase;
10
9
  }
11
- catch (_a) {
10
+ catch {
12
11
  // Not installed, skip
13
12
  return;
14
13
  }
15
14
  extractTsConfigBase(tree);
16
15
  }
17
16
  exports.maybeExtractTsConfigBase = maybeExtractTsConfigBase;
18
- function maybeExtractJestConfigBase(tree) {
19
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- let jestInitGenerator;
21
- try {
22
- jestInitGenerator = require('@nx/' + 'jest').jestInitGenerator;
23
- }
24
- catch (_a) {
25
- // Not installed, skip
26
- return;
27
- }
28
- yield jestInitGenerator(tree, {});
29
- });
17
+ async function maybeExtractJestConfigBase(tree) {
18
+ let jestInitGenerator;
19
+ try {
20
+ jestInitGenerator = require('@nx/' + 'jest').jestInitGenerator;
21
+ }
22
+ catch {
23
+ // Not installed, skip
24
+ return;
25
+ }
26
+ await jestInitGenerator(tree, {});
30
27
  }
31
28
  exports.maybeExtractJestConfigBase = maybeExtractJestConfigBase;
32
29
  function maybeExtractEslintConfigIfRootProject(tree, rootProject) {
@@ -39,12 +36,12 @@ function maybeExtractEslintConfigIfRootProject(tree, rootProject) {
39
36
  migrateConfigToMonorepoStyle = require('@nx/' +
40
37
  'linter/src/generators/init/init-migration').migrateConfigToMonorepoStyle;
41
38
  }
42
- catch (_a) {
39
+ catch {
43
40
  // linter not install
44
41
  }
45
42
  // Only need to handle migrating the root rootProject.
46
43
  // If other libs/apps exist, then this migration is already done by `@nx/linter:lint-rootProject` generator.
47
- migrateConfigToMonorepoStyle === null || migrateConfigToMonorepoStyle === void 0 ? void 0 : migrateConfigToMonorepoStyle([rootProject.name], tree, tree.exists((0, devkit_1.joinPathFragments)(rootProject.root, 'jest.config.ts')) ||
44
+ migrateConfigToMonorepoStyle?.([rootProject.name], tree, tree.exists((0, devkit_1.joinPathFragments)(rootProject.root, 'jest.config.ts')) ||
48
45
  tree.exists((0, devkit_1.joinPathFragments)(rootProject.root, 'jest.config.js'))
49
46
  ? 'jest'
50
47
  : 'none');
@@ -4,9 +4,15 @@ exports.normalizeSchema = void 0;
4
4
  const utils_1 = require("./utils");
5
5
  const get_import_path_1 = require("../../../utilities/get-import-path");
6
6
  function normalizeSchema(tree, schema, projectConfiguration) {
7
- var _a, _b;
8
7
  const destination = (0, utils_1.normalizePathSlashes)(schema.destination);
9
- const newProjectName = (_a = schema.newProjectName) !== null && _a !== void 0 ? _a : (0, utils_1.getNewProjectName)(destination);
10
- return Object.assign(Object.assign({}, schema), { destination, importPath: (_b = schema.importPath) !== null && _b !== void 0 ? _b : (0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, destination)), newProjectName, relativeToRootDestination: (0, utils_1.getDestination)(tree, schema, projectConfiguration) });
8
+ const newProjectName = schema.newProjectName ?? (0, utils_1.getNewProjectName)(destination);
9
+ return {
10
+ ...schema,
11
+ destination,
12
+ importPath: schema.importPath ??
13
+ (0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, destination)),
14
+ newProjectName,
15
+ relativeToRootDestination: (0, utils_1.getDestination)(tree, schema, projectConfiguration),
16
+ };
11
17
  }
12
18
  exports.normalizeSchema = normalizeSchema;
@@ -18,7 +18,7 @@ function updateEslintConfig(tree, schema, project) {
18
18
  } = require('@nx/linter/src/generators/utils/eslint-file');
19
19
  updateRelativePathsInConfig(tree, project.root, schema.relativeToRootDestination);
20
20
  }
21
- catch (_a) {
21
+ catch {
22
22
  devkit_1.output.warn({
23
23
  title: `Could not update the eslint config file.`,
24
24
  bodyLines: [
@@ -14,7 +14,6 @@ let tsModule;
14
14
  * @param schema The options provided to the schematic
15
15
  */
16
16
  function updateImports(tree, schema, project) {
17
- var _a, _b, _c, _d, _e;
18
17
  if (project.projectType === 'application') {
19
18
  // These shouldn't be imported anywhere?
20
19
  return;
@@ -29,12 +28,12 @@ function updateImports(tree, schema, project) {
29
28
  let secondaryEntryPointImportPaths;
30
29
  if (tree.exists(tsConfigPath)) {
31
30
  tsConfig = (0, devkit_1.readJson)(tree, tsConfigPath);
32
- const sourceRoot = (_a = project.sourceRoot) !== null && _a !== void 0 ? _a : (0, devkit_1.joinPathFragments)(project.root, 'src');
33
- mainEntryPointImportPath = Object.keys((_c = (_b = tsConfig.compilerOptions) === null || _b === void 0 ? void 0 : _b.paths) !== null && _c !== void 0 ? _c : {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(sourceRoot))));
34
- secondaryEntryPointImportPaths = Object.keys((_e = (_d = tsConfig.compilerOptions) === null || _d === void 0 ? void 0 : _d.paths) !== null && _e !== void 0 ? _e : {}).filter((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(project.root)) &&
31
+ const sourceRoot = project.sourceRoot ?? (0, devkit_1.joinPathFragments)(project.root, 'src');
32
+ mainEntryPointImportPath = Object.keys(tsConfig.compilerOptions?.paths ?? {}).find((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(sourceRoot))));
33
+ secondaryEntryPointImportPaths = Object.keys(tsConfig.compilerOptions?.paths ?? {}).filter((path) => tsConfig.compilerOptions.paths[path].some((x) => x.startsWith(ensureTrailingSlash(project.root)) &&
35
34
  !x.startsWith(ensureTrailingSlash(sourceRoot))));
36
35
  }
37
- mainEntryPointImportPath !== null && mainEntryPointImportPath !== void 0 ? mainEntryPointImportPath : (mainEntryPointImportPath = (0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, project.root.slice(libsDir.length).replace(/^\/|\\/, ''))));
36
+ mainEntryPointImportPath ??= (0, utils_1.normalizePathSlashes)((0, get_import_path_1.getImportPath)(tree, project.root.slice(libsDir.length).replace(/^\/|\\/, '')));
38
37
  const projectRefs = [
39
38
  {
40
39
  from: mainEntryPointImportPath,