@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.
- package/package.json +29 -29
- package/src/executors/counter/counter.impl.js +29 -36
- package/src/generators/ci-workflow/ci-workflow.js +22 -21
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +29 -32
- package/src/generators/convert-to-nx-project/convert-to-nx-project.js +59 -64
- package/src/generators/move/lib/create-project-configuration-in-new-destination.js +6 -5
- package/src/generators/move/lib/extract-base-configs.js +13 -16
- package/src/generators/move/lib/normalize-schema.js +9 -3
- package/src/generators/move/lib/update-eslint-config.js +1 -1
- package/src/generators/move/lib/update-imports.js +4 -5
- package/src/generators/move/move.js +28 -31
- package/src/generators/new/generate-preset.js +4 -8
- package/src/generators/new/generate-workspace-files.js +47 -41
- package/src/generators/new/new.js +24 -30
- package/src/generators/npm-package/npm-package.js +27 -27
- package/src/generators/preset/preset.js +182 -188
- package/src/generators/remove/lib/check-dependencies.js +12 -15
- package/src/generators/remove/lib/check-targets.js +31 -34
- package/src/generators/remove/lib/update-tsconfig.js +16 -19
- package/src/generators/remove/remove.js +12 -15
- package/src/generators/run-commands/run-commands.js +18 -21
- package/src/generators/utils/get-npm-package-version.js +1 -1
- package/src/generators/utils/presets.d.ts +4 -0
- package/src/generators/utils/presets.js +5 -0
- package/src/generators/workspace-generator/workspace-generator.js +3 -6
- package/src/migrations/update-12-5-0/add-target-dependencies.js +26 -28
- package/src/migrations/update-13-0-0/config-locations/config-locations.js +16 -19
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js +16 -21
- package/src/migrations/update-13-10-0/update-decorate-cli.js +1 -2
- package/src/migrations/update-13-10-0/update-tasks-runner.js +2 -3
- package/src/migrations/update-13-2-0/set-parallel-default.js +14 -18
- package/src/migrations/update-13-3-0/update-tsc-executor-location.js +17 -20
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.js +1 -2
- package/src/migrations/update-13-9-0/replace-tao-with-nx.js +2 -3
- package/src/migrations/update-13-9-0/update-decorate-cli.js +1 -2
- package/src/migrations/update-14-0-0/change-npm-script-executor.js +7 -10
- package/src/migrations/update-14-0-0/change-nx-json-presets.js +13 -13
- package/src/migrations/update-14-2-0/enable-source-analysis.js +14 -18
- package/src/migrations/update-14-8-0/change-run-commands-executor.js +7 -10
- package/src/migrations/update-15-7-0/split-configuration-into-project-json-files.js +3 -6
- package/src/migrations/update-16-0-0/fix-invalid-babelrc.js +2 -3
- package/src/migrations/update-16-0-0/move-workspace-generators-to-local-plugin.js +51 -60
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/utilities/buildable-libs-utils.js +3 -6
- package/src/utilities/default-base.js +1 -1
- package/src/utilities/get-import-path.js +1 -1
- package/src/utilities/run-tasks-in-serial.js +3 -4
- package/src/utilities/typescript/compilation.js +14 -13
- package/src/utils/rules/format-files.js +9 -7
- package/src/utils/rules/visit-not-ignored-files.js +2 -2
- package/src/utils/testing-utils.js +7 -14
- 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.
|
|
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.
|
|
37
|
-
"@nrwl/jest": "16.8.0-beta.
|
|
38
|
-
"@nrwl/linter": "16.8.0-beta.
|
|
39
|
-
"@nrwl/angular": "16.8.0-beta.
|
|
40
|
-
"@nrwl/cypress": "16.8.0-beta.
|
|
41
|
-
"@nrwl/detox": "16.8.0-beta.
|
|
42
|
-
"@nrwl/devkit": "16.8.0-beta.
|
|
43
|
-
"@nrwl/esbuild": "16.8.0-beta.
|
|
44
|
-
"@nrwl/eslint-plugin-nx": "16.8.0-beta.
|
|
45
|
-
"@nrwl/expo": "16.8.0-beta.
|
|
46
|
-
"@nrwl/express": "16.8.0-beta.
|
|
47
|
-
"@nrwl/nest": "16.8.0-beta.
|
|
48
|
-
"@nrwl/next": "16.8.0-beta.
|
|
49
|
-
"@nrwl/node": "16.8.0-beta.
|
|
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.
|
|
52
|
-
"@nrwl/react-native": "16.8.0-beta.
|
|
53
|
-
"@nrwl/react": "16.8.0-beta.
|
|
54
|
-
"@nrwl/rollup": "16.8.0-beta.
|
|
55
|
-
"@nrwl/storybook": "16.8.0-beta.
|
|
56
|
-
"@nrwl/tao": "16.8.0-beta.
|
|
57
|
-
"@nrwl/vite": "16.8.0-beta.
|
|
58
|
-
"@nrwl/web": "16.8.0-beta.
|
|
59
|
-
"@nrwl/webpack": "16.8.0-beta.
|
|
60
|
-
"nx": "16.8.0-beta.
|
|
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.
|
|
65
|
-
"@nx/devkit": "16.8.0-beta.
|
|
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.
|
|
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": "
|
|
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
|
|
8
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
}
|
|
72
|
-
if (!schema.skipFormat) {
|
|
73
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
59
|
+
leftOverProjects[projectName] = config;
|
|
74
60
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
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 =
|
|
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 (
|
|
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
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
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
|
|
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 =
|
|
10
|
-
return
|
|
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
|
|
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 =
|
|
33
|
-
mainEntryPointImportPath = Object.keys(
|
|
34
|
-
secondaryEntryPointImportPaths = Object.keys(
|
|
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
|
|
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,
|