nx 16.7.0-beta.1 โ 16.7.0-beta.4
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/.eslintrc.json +1 -0
- package/bin/init-local.js +0 -1
- package/bin/nx.js +20 -0
- package/package.json +15 -15
- package/plugins/package-json-workspaces.d.ts +13 -0
- package/plugins/package-json-workspaces.js +111 -0
- package/plugins/project-json.d.ts +4 -0
- package/plugins/project-json.js +28 -0
- package/src/adapter/angular-json.d.ts +1 -0
- package/src/adapter/angular-json.js +26 -10
- package/src/command-line/generate/generate.js +7 -8
- package/src/command-line/init/command-object.js +8 -3
- package/src/command-line/init/implementation/angular/standalone-workspace.js +6 -1
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +6 -1
- package/src/command-line/init/implementation/react/index.js +1 -10
- package/src/command-line/init/init.d.ts +1 -0
- package/src/command-line/init/init.js +1 -11
- package/src/command-line/list/list.js +3 -1
- package/src/command-line/report/report.js +4 -3
- package/src/command-line/run/executor-utils.js +12 -3
- package/src/command-line/run/run.js +5 -26
- package/src/config/project-graph.d.ts +2 -0
- package/src/config/workspaces.d.ts +2 -25
- package/src/config/workspaces.js +7 -288
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +7 -5
- package/src/devkit-exports.d.ts +2 -2
- package/src/devkit-exports.js +2 -1
- package/src/generators/utils/project-configuration.js +50 -19
- package/src/native/index.d.ts +7 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +4 -2
- package/src/project-graph/affected/locators/project-glob-changes.js +5 -12
- package/src/project-graph/build-nodes/workspace-projects.d.ts +6 -2
- package/src/project-graph/build-nodes/workspace-projects.js +31 -18
- package/src/project-graph/build-project-graph.d.ts +2 -2
- package/src/project-graph/build-project-graph.js +41 -6
- package/src/project-graph/nx-deps-cache.js +6 -5
- package/src/project-graph/project-graph-builder.d.ts +34 -3
- package/src/project-graph/project-graph-builder.js +81 -49
- package/src/project-graph/project-graph.js +2 -2
- package/src/project-graph/utils/project-configuration-utils.d.ts +13 -0
- package/src/project-graph/utils/project-configuration-utils.js +162 -0
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +9 -2
- package/src/project-graph/utils/retrieve-workspace-files.js +50 -40
- package/src/tasks-runner/forked-process-task-runner.d.ts +2 -2
- package/src/tasks-runner/forked-process-task-runner.js +65 -20
- package/src/utils/find-matching-projects.js +7 -1
- package/src/utils/globs.d.ts +1 -0
- package/src/utils/globs.js +8 -0
- package/src/utils/nx-plugin.d.ts +77 -14
- package/src/utils/nx-plugin.deprecated.d.ts +26 -0
- package/src/utils/nx-plugin.deprecated.js +2 -0
- package/src/utils/nx-plugin.js +33 -19
- package/src/utils/plugins/local-plugins.d.ts +2 -1
- package/src/utils/plugins/local-plugins.js +12 -4
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +11 -4
- package/src/command-line/init/implementation/react/setup-e2e-project.d.ts +0 -1
- package/src/command-line/init/implementation/react/setup-e2e-project.js +0 -41
package/.eslintrc.json
CHANGED
package/bin/init-local.js
CHANGED
|
@@ -16,7 +16,6 @@ function initLocal(workspace) {
|
|
|
16
16
|
process.env.NX_CLI_SET = 'true';
|
|
17
17
|
try {
|
|
18
18
|
perf_hooks_1.performance.mark('init-local');
|
|
19
|
-
require('nx/src/utils/perf-logging');
|
|
20
19
|
monkeyPatchRequire();
|
|
21
20
|
if (workspace.type !== 'nx' && shouldDelegateToAngularCLI()) {
|
|
22
21
|
console.warn((0, strip_indents_1.stripIndents) `Using Nx to run Angular CLI commands is deprecated and will be removed in a future version.
|
package/bin/nx.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
const find_workspace_root_1 = require("../src/utils/find-workspace-root");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
|
+
const dotenv_1 = require("dotenv");
|
|
6
7
|
const init_local_1 = require("./init-local");
|
|
7
8
|
const output_1 = require("../src/utils/output");
|
|
8
9
|
const installation_directory_1 = require("../src/utils/installation-directory");
|
|
@@ -12,12 +13,18 @@ const package_json_1 = require("../src/utils/package-json");
|
|
|
12
13
|
const child_process_1 = require("child_process");
|
|
13
14
|
const path_1 = require("path");
|
|
14
15
|
const assert_supported_platform_1 = require("../src/native/assert-supported-platform");
|
|
16
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
15
17
|
function main() {
|
|
16
18
|
if (process.argv[2] !== 'report' &&
|
|
17
19
|
process.argv[2] !== '--version' &&
|
|
18
20
|
process.argv[2] !== '--help') {
|
|
19
21
|
(0, assert_supported_platform_1.assertSupportedPlatform)();
|
|
20
22
|
}
|
|
23
|
+
require('nx/src/utils/perf-logging');
|
|
24
|
+
perf_hooks_1.performance.mark('loading dotenv files:start');
|
|
25
|
+
loadDotEnvFiles();
|
|
26
|
+
perf_hooks_1.performance.mark('loading dotenv files:end');
|
|
27
|
+
perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
|
|
21
28
|
const workspace = (0, find_workspace_root_1.findWorkspaceRoot)(process.cwd());
|
|
22
29
|
// new is a special case because there is no local workspace to load
|
|
23
30
|
if (process.argv[2] === 'new' ||
|
|
@@ -71,6 +78,19 @@ function main() {
|
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* This loads dotenv files from:
|
|
83
|
+
* - .env
|
|
84
|
+
* - .local.env
|
|
85
|
+
* - .env.local
|
|
86
|
+
*/
|
|
87
|
+
function loadDotEnvFiles() {
|
|
88
|
+
for (const file of ['.env', '.local.env', '.env.local']) {
|
|
89
|
+
(0, dotenv_1.config)({
|
|
90
|
+
path: file,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
74
94
|
function handleNoWorkspace(globalNxVersion) {
|
|
75
95
|
output_1.output.log({
|
|
76
96
|
title: `The current directory isn't part of an Nx workspace.`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "16.7.0-beta.
|
|
3
|
+
"version": "16.7.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nx.dev",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nrwl/tao": "16.7.0-beta.
|
|
35
|
+
"@nrwl/tao": "16.7.0-beta.4",
|
|
36
36
|
"@parcel/watcher": "2.0.4",
|
|
37
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
38
38
|
"@yarnpkg/parsers": "3.0.0-rc.46",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"cli-cursor": "3.1.0",
|
|
43
43
|
"cli-spinners": "2.6.1",
|
|
44
44
|
"cliui": "^7.0.2",
|
|
45
|
-
"dotenv": "~
|
|
45
|
+
"dotenv": "~16.3.1",
|
|
46
46
|
"enquirer": "~2.3.6",
|
|
47
47
|
"fast-glob": "3.2.7",
|
|
48
48
|
"figures": "3.2.0",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-arm64": "16.7.0-beta.
|
|
85
|
-
"@nx/nx-darwin-x64": "16.7.0-beta.
|
|
86
|
-
"@nx/nx-freebsd-x64": "16.7.0-beta.
|
|
87
|
-
"@nx/nx-linux-arm-gnueabihf": "16.7.0-beta.
|
|
88
|
-
"@nx/nx-linux-arm64-gnu": "16.7.0-beta.
|
|
89
|
-
"@nx/nx-linux-arm64-musl": "16.7.0-beta.
|
|
90
|
-
"@nx/nx-linux-x64-gnu": "16.7.0-beta.
|
|
91
|
-
"@nx/nx-linux-x64-musl": "16.7.0-beta.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "16.7.0-beta.
|
|
93
|
-
"@nx/nx-win32-x64-msvc": "16.7.0-beta.
|
|
84
|
+
"@nx/nx-darwin-arm64": "16.7.0-beta.4",
|
|
85
|
+
"@nx/nx-darwin-x64": "16.7.0-beta.4",
|
|
86
|
+
"@nx/nx-freebsd-x64": "16.7.0-beta.4",
|
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "16.7.0-beta.4",
|
|
88
|
+
"@nx/nx-linux-arm64-gnu": "16.7.0-beta.4",
|
|
89
|
+
"@nx/nx-linux-arm64-musl": "16.7.0-beta.4",
|
|
90
|
+
"@nx/nx-linux-x64-gnu": "16.7.0-beta.4",
|
|
91
|
+
"@nx/nx-linux-x64-musl": "16.7.0-beta.4",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "16.7.0-beta.4",
|
|
93
|
+
"@nx/nx-win32-x64-msvc": "16.7.0-beta.4"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
|
@@ -176,6 +176,6 @@
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
"main": "./bin/nx.js",
|
|
179
|
-
"
|
|
180
|
-
"gitHead": "
|
|
179
|
+
"type": "commonjs",
|
|
180
|
+
"gitHead": "dcbba686b182737b66ebbfb9db372769e77ba005"
|
|
181
181
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NxJsonConfiguration } from '../src/config/nx-json';
|
|
2
|
+
import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
|
|
3
|
+
import { NxPluginV2 } from '../src/utils/nx-plugin';
|
|
4
|
+
export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
|
|
5
|
+
export declare function buildProjectConfigurationFromPackageJson(packageJson: {
|
|
6
|
+
name: string;
|
|
7
|
+
}, path: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Get the package.json globs from package manager workspaces
|
|
12
|
+
*/
|
|
13
|
+
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string, readJson?: <T extends Object>(path: string) => T): string[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const nx_json_1 = require("../src/config/nx-json");
|
|
7
|
+
const workspaces_1 = require("../src/config/workspaces");
|
|
8
|
+
const fileutils_1 = require("../src/utils/fileutils");
|
|
9
|
+
const globs_1 = require("../src/utils/globs");
|
|
10
|
+
const logger_1 = require("../src/utils/logger");
|
|
11
|
+
const output_1 = require("../src/utils/output");
|
|
12
|
+
const path_1 = require("../src/utils/path");
|
|
13
|
+
function getNxPackageJsonWorkspacesPlugin(root) {
|
|
14
|
+
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
|
|
15
|
+
return {
|
|
16
|
+
name: 'nx-core-build-package-json-nodes',
|
|
17
|
+
createNodes: [
|
|
18
|
+
(0, globs_1.combineGlobPatterns)(getGlobPatternsFromPackageManagerWorkspaces(root, readJson)),
|
|
19
|
+
(pkgJsonPath) => {
|
|
20
|
+
const json = readJson(pkgJsonPath);
|
|
21
|
+
return {
|
|
22
|
+
projects: {
|
|
23
|
+
[json.name]: buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root)),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
|
|
31
|
+
function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
const normalizedPath = path.split('\\').join('/');
|
|
34
|
+
const directory = (0, node_path_1.dirname)(normalizedPath);
|
|
35
|
+
if (!packageJson.name && directory === '.') {
|
|
36
|
+
throw new Error('Nx requires the root package.json to specify a name if it is being used as an Nx project.');
|
|
37
|
+
}
|
|
38
|
+
let name = (_a = packageJson.name) !== null && _a !== void 0 ? _a : (0, workspaces_1.toProjectName)(normalizedPath);
|
|
39
|
+
if (nxJson === null || nxJson === void 0 ? void 0 : nxJson.npmScope) {
|
|
40
|
+
const npmPrefix = `@${nxJson.npmScope}/`;
|
|
41
|
+
if (name.startsWith(npmPrefix)) {
|
|
42
|
+
name = name.replace(npmPrefix, '');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const projectType = ((_b = nxJson === null || nxJson === void 0 ? void 0 : nxJson.workspaceLayout) === null || _b === void 0 ? void 0 : _b.appsDir) != ((_c = nxJson === null || nxJson === void 0 ? void 0 : nxJson.workspaceLayout) === null || _c === void 0 ? void 0 : _c.libsDir) &&
|
|
46
|
+
((_d = nxJson === null || nxJson === void 0 ? void 0 : nxJson.workspaceLayout) === null || _d === void 0 ? void 0 : _d.appsDir) &&
|
|
47
|
+
directory.startsWith(nxJson.workspaceLayout.appsDir)
|
|
48
|
+
? 'application'
|
|
49
|
+
: 'library';
|
|
50
|
+
return {
|
|
51
|
+
root: directory,
|
|
52
|
+
sourceRoot: directory,
|
|
53
|
+
name,
|
|
54
|
+
projectType,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
|
|
58
|
+
/**
|
|
59
|
+
* Get the package.json globs from package manager workspaces
|
|
60
|
+
*/
|
|
61
|
+
function getGlobPatternsFromPackageManagerWorkspaces(root, readJson = (path) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, path)) // making this an arg allows us to reuse in devkit
|
|
62
|
+
) {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
try {
|
|
65
|
+
const patterns = [];
|
|
66
|
+
const packageJson = readJson('package.json');
|
|
67
|
+
patterns.push(...normalizePatterns(Array.isArray(packageJson.workspaces)
|
|
68
|
+
? packageJson.workspaces
|
|
69
|
+
: (_b = (_a = packageJson.workspaces) === null || _a === void 0 ? void 0 : _a.packages) !== null && _b !== void 0 ? _b : []));
|
|
70
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, 'pnpm-workspace.yaml'))) {
|
|
71
|
+
try {
|
|
72
|
+
const { packages } = (0, fileutils_1.readYamlFile)((0, node_path_1.join)(root, 'pnpm-workspace.yaml'));
|
|
73
|
+
patterns.push(...normalizePatterns(packages || []));
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
output_1.output.warn({
|
|
77
|
+
title: `${logger_1.NX_PREFIX} Unable to parse pnpm-workspace.yaml`,
|
|
78
|
+
bodyLines: [e.toString()],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, 'lerna.json'))) {
|
|
83
|
+
try {
|
|
84
|
+
const { packages } = readJson('lerna.json');
|
|
85
|
+
patterns.push(...normalizePatterns((packages === null || packages === void 0 ? void 0 : packages.length) > 0 ? packages : ['packages/*']));
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
output_1.output.warn({
|
|
89
|
+
title: `${logger_1.NX_PREFIX} Unable to parse lerna.json`,
|
|
90
|
+
bodyLines: [e.toString()],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Merge patterns from workspaces definitions
|
|
95
|
+
// TODO(@AgentEnder): update logic after better way to determine root project inclusion
|
|
96
|
+
// Include the root project
|
|
97
|
+
return packageJson.nx ? patterns.concat('package.json') : patterns;
|
|
98
|
+
}
|
|
99
|
+
catch (_c) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.getGlobPatternsFromPackageManagerWorkspaces = getGlobPatternsFromPackageManagerWorkspaces;
|
|
104
|
+
function normalizePatterns(patterns) {
|
|
105
|
+
return patterns.map((pattern) => removeRelativePath(pattern.endsWith('/package.json')
|
|
106
|
+
? pattern
|
|
107
|
+
: (0, path_1.joinPathFragments)(pattern, 'package.json')));
|
|
108
|
+
}
|
|
109
|
+
function removeRelativePath(pattern) {
|
|
110
|
+
return pattern.startsWith('./') ? pattern.substring(2) : pattern;
|
|
111
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
|
|
2
|
+
import { NxPluginV2 } from '../src/utils/nx-plugin';
|
|
3
|
+
export declare function getNxProjectJsonPlugin(root: string): NxPluginV2;
|
|
4
|
+
export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildProjectFromProjectJson = exports.getNxProjectJsonPlugin = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const workspaces_1 = require("../src/config/workspaces");
|
|
6
|
+
const fileutils_1 = require("../src/utils/fileutils");
|
|
7
|
+
function getNxProjectJsonPlugin(root) {
|
|
8
|
+
return {
|
|
9
|
+
name: 'nx-core-build-project-json-nodes',
|
|
10
|
+
createNodes: [
|
|
11
|
+
'{project.json,**/project.json}',
|
|
12
|
+
(file) => {
|
|
13
|
+
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, file));
|
|
14
|
+
const project = buildProjectFromProjectJson(json, file);
|
|
15
|
+
return {
|
|
16
|
+
projects: {
|
|
17
|
+
[project.name]: project,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.getNxProjectJsonPlugin = getNxProjectJsonPlugin;
|
|
25
|
+
function buildProjectFromProjectJson(json, path) {
|
|
26
|
+
return Object.assign({ name: (0, workspaces_1.toProjectName)(path), root: (0, node_path_1.dirname)(path) }, json);
|
|
27
|
+
}
|
|
28
|
+
exports.buildProjectFromProjectJson = buildProjectFromProjectJson;
|
|
@@ -8,3 +8,4 @@ export declare function mergeAngularJsonAndProjects(projects: {
|
|
|
8
8
|
};
|
|
9
9
|
export declare function toNewFormat(w: any): ProjectsConfigurations;
|
|
10
10
|
export declare function toOldFormat(w: any): any;
|
|
11
|
+
export declare function renamePropertyWithStableKeys(obj: any, from: string, to: string): void;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toOldFormat = exports.toNewFormat = exports.mergeAngularJsonAndProjects = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = void 0;
|
|
3
|
+
exports.renamePropertyWithStableKeys = exports.toOldFormat = exports.toNewFormat = exports.mergeAngularJsonAndProjects = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fileutils_1 = require("../utils/fileutils");
|
|
7
|
-
const workspaces_1 = require("../config/workspaces");
|
|
8
7
|
function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
|
|
9
8
|
if ((0, fs_1.existsSync)(path.join(root, 'angular.json')) &&
|
|
10
9
|
// Include projects from angular.json if explicitly required.
|
|
@@ -56,19 +55,19 @@ exports.mergeAngularJsonAndProjects = mergeAngularJsonAndProjects;
|
|
|
56
55
|
function toNewFormat(w) {
|
|
57
56
|
Object.values(w.projects || {}).forEach((projectConfig) => {
|
|
58
57
|
if (projectConfig.architect) {
|
|
59
|
-
|
|
58
|
+
renamePropertyWithStableKeys(projectConfig, 'architect', 'targets');
|
|
60
59
|
}
|
|
61
60
|
if (projectConfig.schematics) {
|
|
62
|
-
|
|
61
|
+
renamePropertyWithStableKeys(projectConfig, 'schematics', 'generators');
|
|
63
62
|
}
|
|
64
63
|
Object.values(projectConfig.targets || {}).forEach((target) => {
|
|
65
64
|
if (target.builder !== undefined) {
|
|
66
|
-
|
|
65
|
+
renamePropertyWithStableKeys(target, 'builder', 'executor');
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
});
|
|
70
69
|
if (w.schematics) {
|
|
71
|
-
|
|
70
|
+
renamePropertyWithStableKeys(w, 'schematics', 'generators');
|
|
72
71
|
}
|
|
73
72
|
if (w.version !== 2) {
|
|
74
73
|
w.version = 2;
|
|
@@ -82,20 +81,20 @@ function toOldFormat(w) {
|
|
|
82
81
|
throw new Error("'project.json' files are incompatible with version 1 workspace schemas.");
|
|
83
82
|
}
|
|
84
83
|
if (projectConfig.targets) {
|
|
85
|
-
|
|
84
|
+
renamePropertyWithStableKeys(projectConfig, 'targets', 'architect');
|
|
86
85
|
}
|
|
87
86
|
if (projectConfig.generators) {
|
|
88
|
-
|
|
87
|
+
renamePropertyWithStableKeys(projectConfig, 'generators', 'schematics');
|
|
89
88
|
}
|
|
90
89
|
delete projectConfig.name;
|
|
91
90
|
Object.values(projectConfig.architect || {}).forEach((target) => {
|
|
92
91
|
if (target.executor !== undefined) {
|
|
93
|
-
|
|
92
|
+
renamePropertyWithStableKeys(target, 'executor', 'builder');
|
|
94
93
|
}
|
|
95
94
|
});
|
|
96
95
|
});
|
|
97
96
|
if (w.generators) {
|
|
98
|
-
|
|
97
|
+
renamePropertyWithStableKeys(w, 'generators', 'schematics');
|
|
99
98
|
}
|
|
100
99
|
if (w.version !== 1) {
|
|
101
100
|
w.version = 1;
|
|
@@ -103,3 +102,20 @@ function toOldFormat(w) {
|
|
|
103
102
|
return w;
|
|
104
103
|
}
|
|
105
104
|
exports.toOldFormat = toOldFormat;
|
|
105
|
+
// we have to do it this way to preserve the order of properties
|
|
106
|
+
// not to screw up the formatting
|
|
107
|
+
function renamePropertyWithStableKeys(obj, from, to) {
|
|
108
|
+
const copy = Object.assign({}, obj);
|
|
109
|
+
Object.keys(obj).forEach((k) => {
|
|
110
|
+
delete obj[k];
|
|
111
|
+
});
|
|
112
|
+
Object.keys(copy).forEach((k) => {
|
|
113
|
+
if (k === from) {
|
|
114
|
+
obj[to] = copy[k];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
obj[k] = copy[k];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.renamePropertyWithStableKeys = renamePropertyWithStableKeys;
|
|
@@ -4,8 +4,8 @@ exports.workspaceGenerators = exports.generate = exports.printGenHelp = exports.
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const enquirer_1 = require("enquirer");
|
|
7
|
+
const path_1 = require("path");
|
|
7
8
|
const configuration_1 = require("../../config/configuration");
|
|
8
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
9
9
|
const tree_1 = require("../../generators/tree");
|
|
10
10
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
11
11
|
const logger_1 = require("../../utils/logger");
|
|
@@ -31,9 +31,9 @@ function printChanges(fileChanges) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.printChanges = printChanges;
|
|
34
|
-
function promptForCollection(generatorName,
|
|
34
|
+
function promptForCollection(generatorName, interactive, projectsConfiguration) {
|
|
35
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)(projectsConfiguration);
|
|
36
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)(projectsConfiguration, (0, configuration_1.readNxJson)());
|
|
37
37
|
const installedCollections = Array.from(new Set((0, installed_plugins_1.findInstalledPlugins)().map((x) => x.name)));
|
|
38
38
|
const choicesMap = new Set();
|
|
39
39
|
const deprecatedChoices = new Set();
|
|
@@ -148,7 +148,7 @@ function parseGeneratorString(value) {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
function convertToGenerateOptions(generatorOptions,
|
|
151
|
+
function convertToGenerateOptions(generatorOptions, defaultCollectionName, mode, projectsConfiguration) {
|
|
152
152
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
153
153
|
let collectionName = null;
|
|
154
154
|
let generatorName = null;
|
|
@@ -161,7 +161,7 @@ function convertToGenerateOptions(generatorOptions, ws, defaultCollectionName, m
|
|
|
161
161
|
generatorName = generator;
|
|
162
162
|
}
|
|
163
163
|
else if (!defaultCollectionName) {
|
|
164
|
-
const generatorString = yield promptForCollection(generatorDescriptor,
|
|
164
|
+
const generatorString = yield promptForCollection(generatorDescriptor, interactive, projectsConfiguration);
|
|
165
165
|
const parsedGeneratorString = parseGeneratorString(generatorString);
|
|
166
166
|
collectionName = parsedGeneratorString.collection;
|
|
167
167
|
generatorName = parsedGeneratorString.generator;
|
|
@@ -220,12 +220,11 @@ function generate(cwd, args) {
|
|
|
220
220
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
|
221
221
|
}
|
|
222
222
|
const verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
223
|
-
const ws = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot);
|
|
224
223
|
const nxJsonConfiguration = (0, configuration_1.readNxJson)();
|
|
225
224
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
226
225
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
227
226
|
return (0, params_1.handleErrors)(verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
const opts = yield convertToGenerateOptions(args,
|
|
227
|
+
const opts = yield convertToGenerateOptions(args, readDefaultCollection(nxJsonConfiguration), 'generate', projectsConfigurations);
|
|
229
228
|
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot);
|
|
230
229
|
if (deprecated) {
|
|
231
230
|
logger_1.logger.warn([
|
|
@@ -240,7 +239,7 @@ function generate(cwd, args) {
|
|
|
240
239
|
printGenHelp(opts, schema, normalizedGeneratorName, aliases);
|
|
241
240
|
return 0;
|
|
242
241
|
}
|
|
243
|
-
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration),
|
|
242
|
+
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration), (0, path_1.relative)(cwd, workspace_root_1.workspaceRoot), verbose);
|
|
244
243
|
if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
|
|
245
244
|
const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
|
|
246
245
|
const implementation = implementationFactory();
|
|
@@ -14,7 +14,7 @@ exports.yargsInitCommand = {
|
|
|
14
14
|
};
|
|
15
15
|
function withInitOptions(yargs) {
|
|
16
16
|
return yargs
|
|
17
|
-
.
|
|
17
|
+
.option('nxCloud', {
|
|
18
18
|
type: 'boolean',
|
|
19
19
|
description: 'Set up distributed caching with Nx Cloud.',
|
|
20
20
|
})
|
|
@@ -32,18 +32,23 @@ function withInitOptions(yargs) {
|
|
|
32
32
|
describe: 'Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.',
|
|
33
33
|
type: 'boolean',
|
|
34
34
|
default: false,
|
|
35
|
+
})
|
|
36
|
+
.option('useDotNxInstallation', {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
|
|
39
|
+
default: false,
|
|
35
40
|
})
|
|
36
41
|
.option('force', {
|
|
37
42
|
describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
|
|
38
43
|
type: 'boolean',
|
|
39
44
|
default: false,
|
|
40
45
|
})
|
|
41
|
-
.
|
|
46
|
+
.option('vite', {
|
|
42
47
|
type: 'boolean',
|
|
43
48
|
description: 'Use Vite as the bundler. Only for CRA projects.',
|
|
44
49
|
default: true,
|
|
45
50
|
})
|
|
46
|
-
.
|
|
51
|
+
.option('cacheable', {
|
|
47
52
|
type: 'string',
|
|
48
53
|
description: 'Comma-separated list of cacheable operations. Only used for internal testing.',
|
|
49
54
|
coerce: shared_options_1.parseCSV,
|
|
@@ -48,7 +48,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
48
48
|
karmaProjectConfigFile ? '!{projectRoot}/karma.conf.js' : undefined,
|
|
49
49
|
].filter(Boolean)
|
|
50
50
|
: []),
|
|
51
|
-
eslintProjectConfigFile
|
|
51
|
+
...(eslintProjectConfigFile
|
|
52
|
+
? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.js']
|
|
53
|
+
: []),
|
|
52
54
|
].filter(Boolean),
|
|
53
55
|
};
|
|
54
56
|
nxJson.targetDefaults = {};
|
|
@@ -73,6 +75,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
73
75
|
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
|
|
74
76
|
inputs.push('{workspaceRoot}/.eslintrc.json');
|
|
75
77
|
}
|
|
78
|
+
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.js'))) {
|
|
79
|
+
inputs.push('{workspaceRoot}/eslint.config.js');
|
|
80
|
+
}
|
|
76
81
|
nxJson.targetDefaults.lint = { inputs };
|
|
77
82
|
}
|
|
78
83
|
if (workspaceTargets.includes('e2e')) {
|
|
@@ -46,10 +46,15 @@ function writeMinimalNxJson(host, version) {
|
|
|
46
46
|
default: {
|
|
47
47
|
runner: 'nx/tasks-runners/default',
|
|
48
48
|
options: {
|
|
49
|
-
cacheableOperations: [],
|
|
49
|
+
cacheableOperations: ['build', 'lint', 'test', 'e2e'],
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
targetDefaults: {
|
|
54
|
+
build: {
|
|
55
|
+
dependsOn: ['^build'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
53
58
|
installation: {
|
|
54
59
|
version: version.trimEnd(),
|
|
55
60
|
},
|
|
@@ -14,7 +14,6 @@ const check_for_uncommitted_changes_1 = require("./check-for-uncommitted-changes
|
|
|
14
14
|
const clean_up_files_1 = require("./clean-up-files");
|
|
15
15
|
const read_name_from_package_json_1 = require("./read-name-from-package-json");
|
|
16
16
|
const rename_js_to_jsx_1 = require("./rename-js-to-jsx");
|
|
17
|
-
const setup_e2e_project_1 = require("./setup-e2e-project");
|
|
18
17
|
const tsconfig_setup_1 = require("./tsconfig-setup");
|
|
19
18
|
const write_craco_config_1 = require("./write-craco-config");
|
|
20
19
|
const write_vite_config_1 = require("./write-vite-config");
|
|
@@ -129,7 +128,7 @@ function reorgnizeWorkspaceStructure(options) {
|
|
|
129
128
|
}
|
|
130
129
|
function createTempWorkspace(options) {
|
|
131
130
|
(0, fs_extra_1.removeSync)('temp-workspace');
|
|
132
|
-
(0, child_process_1.execSync)(`npx ${options.npxYesFlagNeeded ? '-y' : ''} create-nx-workspace@latest temp-workspace --appName=${options.reactAppName} --preset=react-monorepo --style=css --bundler=${options.isVite ? 'vite' : 'webpack'} --packageManager=${options.packageManager} ${options.nxCloud ? '--nxCloud' : '--nxCloud=false'}`, { stdio: [0, 1, 2] });
|
|
131
|
+
(0, child_process_1.execSync)(`npx ${options.npxYesFlagNeeded ? '-y' : ''} create-nx-workspace@latest temp-workspace --appName=${options.reactAppName} --preset=react-monorepo --style=css --bundler=${options.isVite ? 'vite' : 'webpack'} --packageManager=${options.packageManager} ${options.nxCloud ? '--nxCloud' : '--nxCloud=false'} ${options.addE2e ? '--e2eTestRunner=cypress' : '--e2eTestRunner=none'}`, { stdio: [0, 1, 2] });
|
|
133
132
|
output_1.output.log({ title: '๐ Welcome to Nx!' });
|
|
134
133
|
output_1.output.log({ title: '๐งน Clearing unused files' });
|
|
135
134
|
(0, fs_extra_1.copySync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName, 'project.json'), 'project.json');
|
|
@@ -228,14 +227,6 @@ function cleanUpUnusedFilesAndAddConfigFiles(options) {
|
|
|
228
227
|
(0, clean_up_files_1.cleanUpFiles)(options.reactAppName, options.isStandalone);
|
|
229
228
|
output_1.output.log({ title: "๐ Extend the app's tsconfig.json from the base" });
|
|
230
229
|
(0, tsconfig_setup_1.setupTsConfig)(options.reactAppName, options.isStandalone);
|
|
231
|
-
if (options.addE2e && !options.isStandalone) {
|
|
232
|
-
output_1.output.log({ title: '๐ Setup e2e tests' });
|
|
233
|
-
(0, setup_e2e_project_1.setupE2eProject)(options.reactAppName);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
(0, fs_extra_1.removeSync)((0, path_1.join)('apps', `${options.reactAppName}-e2e`));
|
|
237
|
-
(0, child_process_1.execSync)(`${options.pmc.rm} cypress @nx/cypress eslint-plugin-cypress`);
|
|
238
|
-
}
|
|
239
230
|
if (options.isStandalone) {
|
|
240
231
|
(0, fs_extra_1.removeSync)('apps');
|
|
241
232
|
}
|
|
@@ -6,7 +6,6 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const enquirer_1 = require("enquirer");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
|
-
const parser = require("yargs-parser");
|
|
10
9
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
|
11
10
|
const add_nx_to_nest_1 = require("./implementation/add-nx-to-nest");
|
|
12
11
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
|
@@ -21,20 +20,11 @@ function initHandler(options) {
|
|
|
21
20
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
// strip the 'init' command itself so we don't forward it
|
|
23
22
|
const args = process.argv.slice(3).join(' ');
|
|
24
|
-
const flags = parser(args, {
|
|
25
|
-
boolean: ['useDotNxInstallation'],
|
|
26
|
-
alias: {
|
|
27
|
-
useDotNxInstallation: ['encapsulated'],
|
|
28
|
-
},
|
|
29
|
-
default: {
|
|
30
|
-
useDotNxInstallation: false,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
23
|
const version = (_a = process.env.NX_VERSION) !== null && _a !== void 0 ? _a : ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
|
|
34
24
|
if (process.env.NX_VERSION) {
|
|
35
25
|
console.log(`Using version ${process.env.NX_VERSION}`);
|
|
36
26
|
}
|
|
37
|
-
if (
|
|
27
|
+
if (options.useDotNxInstallation === true) {
|
|
38
28
|
setupDotNxInstallation(version);
|
|
39
29
|
}
|
|
40
30
|
else if ((0, fs_1.existsSync)('package.json')) {
|
|
@@ -7,6 +7,7 @@ const output_1 = require("../../utils/output");
|
|
|
7
7
|
const plugins_1 = require("../../utils/plugins");
|
|
8
8
|
const local_plugins_1 = require("../../utils/plugins/local-plugins");
|
|
9
9
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
10
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
10
11
|
/**
|
|
11
12
|
* List available plugins or capabilities within a specific plugin
|
|
12
13
|
*
|
|
@@ -21,9 +22,10 @@ function listHandler(args) {
|
|
|
21
22
|
yield (0, plugins_1.listPluginCapabilities)(args.plugin);
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
25
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
24
26
|
const corePlugins = (0, plugins_1.fetchCorePlugins)();
|
|
25
27
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
26
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
|
|
28
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
27
29
|
const installedPlugins = yield (0, plugins_1.getInstalledPluginsAndCapabilities)(workspace_root_1.workspaceRoot);
|
|
28
30
|
if (localPlugins.size) {
|
|
29
31
|
(0, local_plugins_1.listLocalWorkspacePlugins)(localPlugins);
|
|
@@ -13,6 +13,7 @@ const project_graph_1 = require("../../project-graph/project-graph");
|
|
|
13
13
|
const semver_1 = require("semver");
|
|
14
14
|
const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
|
|
15
15
|
const installation_directory_1 = require("../../utils/installation-directory");
|
|
16
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
16
17
|
const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
|
|
17
18
|
exports.packagesWeCareAbout = [
|
|
18
19
|
'lerna',
|
|
@@ -89,7 +90,7 @@ function getReportData() {
|
|
|
89
90
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
91
|
const pm = (0, package_manager_1.detectPackageManager)();
|
|
91
92
|
const pmVersion = (0, package_manager_1.getPackageManagerVersion)(pm);
|
|
92
|
-
const localPlugins = yield findLocalPlugins();
|
|
93
|
+
const localPlugins = yield findLocalPlugins((0, nx_json_1.readNxJson)());
|
|
93
94
|
const communityPlugins = findInstalledCommunityPlugins();
|
|
94
95
|
let projectGraphError = null;
|
|
95
96
|
if (isNativeAvailable()) {
|
|
@@ -124,11 +125,11 @@ function getReportData() {
|
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
exports.getReportData = getReportData;
|
|
127
|
-
function findLocalPlugins() {
|
|
128
|
+
function findLocalPlugins(nxJson) {
|
|
128
129
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
130
|
try {
|
|
130
131
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
131
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
|
|
132
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
132
133
|
return Array.from(localPlugins.keys());
|
|
133
134
|
}
|
|
134
135
|
catch (_a) {
|