nx 19.8.0 โ 19.8.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.json +11 -2
- package/bin/nx.js +10 -2
- package/package.json +12 -13
- package/schemas/nx-schema.json +26 -21
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/activate-powerpack/activate-powerpack.js +3 -1
- package/src/command-line/add/add.js +4 -2
- package/src/command-line/connect/view-logs.js +1 -0
- package/src/command-line/exec/exec.js +6 -1
- package/src/command-line/format/format.js +3 -1
- package/src/command-line/graph/graph.js +10 -9
- package/src/command-line/init/implementation/add-nx-to-nest.js +5 -5
- package/src/command-line/init/implementation/angular/integrated-workspace.js +4 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -2
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +3 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +1 -0
- package/src/command-line/init/implementation/react/check-for-uncommitted-changes.js +3 -1
- package/src/command-line/init/implementation/react/clean-up-files.js +7 -7
- package/src/command-line/init/implementation/react/index.js +36 -17
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +3 -3
- package/src/command-line/init/implementation/utils.js +5 -1
- package/src/command-line/init/init-v1.js +1 -0
- package/src/command-line/init/init-v2.js +2 -1
- package/src/command-line/migrate/command-object.js +4 -0
- package/src/command-line/migrate/migrate.js +1 -1
- package/src/command-line/release/changelog.js +1 -2
- package/src/command-line/release/config/version-plans.js +9 -8
- package/src/command-line/release/plan.js +6 -5
- package/src/command-line/release/release.js +2 -2
- package/src/command-line/release/utils/exec-command.js +1 -0
- package/src/command-line/release/utils/github.js +1 -0
- package/src/command-line/release/utils/launch-editor.js +6 -1
- package/src/command-line/release/version.js +6 -3
- package/src/command-line/report/report.d.ts +3 -1
- package/src/command-line/report/report.js +17 -2
- package/src/command-line/reset/reset.js +4 -4
- package/src/command-line/run/run.js +1 -0
- package/src/command-line/sync/sync.js +5 -4
- package/src/command-line/watch/watch.js +1 -0
- package/src/config/nx-json.d.ts +4 -0
- package/src/daemon/cache.d.ts +1 -2
- package/src/daemon/cache.js +12 -21
- package/src/daemon/client/client.d.ts +4 -1
- package/src/daemon/client/client.js +9 -8
- package/src/daemon/client/generate-help-output.js +1 -0
- package/src/daemon/server/sync-generators.d.ts +4 -1
- package/src/daemon/server/sync-generators.js +33 -15
- package/src/daemon/tmp-dir.js +6 -7
- package/src/executors/run-commands/run-commands.impl.js +1 -0
- package/src/executors/run-script/run-script.impl.js +1 -0
- package/src/generators/tree.d.ts +1 -1
- package/src/generators/tree.js +11 -11
- package/src/native/index.d.ts +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +1 -1
- package/src/plugins/js/index.js +1 -2
- package/src/project-graph/file-utils.js +1 -0
- package/src/project-graph/nx-deps-cache.js +5 -6
- package/src/tasks-runner/cache.d.ts +3 -1
- package/src/tasks-runner/cache.js +29 -29
- package/src/tasks-runner/default-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.d.ts +1 -1
- package/src/tasks-runner/life-cycles/formatting-utils.js +27 -15
- package/src/tasks-runner/life-cycles/task-history-life-cycle.js +3 -0
- package/src/tasks-runner/remove-old-cache-records.js +2 -3
- package/src/tasks-runner/task-orchestrator.d.ts +3 -1
- package/src/tasks-runner/task-orchestrator.js +3 -2
- package/src/tasks-runner/tasks-schedule.js +1 -1
- package/src/utils/ab-testing.js +4 -1
- package/src/utils/child-process.js +5 -3
- package/src/utils/command-line-utils.js +7 -1
- package/src/utils/default-base.js +5 -2
- package/src/utils/fileutils.d.ts +9 -1
- package/src/utils/fileutils.js +29 -12
- package/src/utils/git-utils.index-filter.js +2 -1
- package/src/utils/git-utils.js +4 -0
- package/src/utils/git-utils.tree-filter.js +3 -1
- package/src/utils/ignore.js +2 -2
- package/src/utils/package-manager.js +2 -2
- package/src/utils/powerpack.d.ts +1 -1
- package/src/utils/powerpack.js +3 -8
- package/src/utils/sync-generators.d.ts +13 -3
- package/src/utils/sync-generators.js +99 -25
- package/src/utils/task-history.d.ts +2 -2
- package/src/utils/task-history.js +4 -1
package/.eslintrc.json
CHANGED
@@ -5,7 +5,15 @@
|
|
5
5
|
"overrides": [
|
6
6
|
{
|
7
7
|
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
8
|
-
"rules": {
|
8
|
+
"rules": {
|
9
|
+
"no-restricted-imports": [
|
10
|
+
"error",
|
11
|
+
{
|
12
|
+
"name": "fs-extra",
|
13
|
+
"message": "Please use equivalent utilities from `node:fs` instead."
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
9
17
|
},
|
10
18
|
{
|
11
19
|
"files": ["*.ts"],
|
@@ -111,7 +119,8 @@
|
|
111
119
|
"@nx/nx-linux-arm64-musl",
|
112
120
|
"@nx/nx-linux-arm-gnueabihf",
|
113
121
|
"@nx/nx-win32-arm64-msvc",
|
114
|
-
"@nx/nx-freebsd-x64"
|
122
|
+
"@nx/nx-freebsd-x64",
|
123
|
+
"@nx/powerpack-license"
|
115
124
|
]
|
116
125
|
}
|
117
126
|
]
|
package/bin/nx.js
CHANGED
@@ -200,11 +200,19 @@ function getLocalNxVersion(workspace) {
|
|
200
200
|
}
|
201
201
|
function _getLatestVersionOfNx() {
|
202
202
|
try {
|
203
|
-
return (0, child_process_1.execSync)('npm view nx@latest version'
|
203
|
+
return (0, child_process_1.execSync)('npm view nx@latest version', {
|
204
|
+
windowsHide: true,
|
205
|
+
})
|
206
|
+
.toString()
|
207
|
+
.trim();
|
204
208
|
}
|
205
209
|
catch {
|
206
210
|
try {
|
207
|
-
return (0, child_process_1.execSync)('pnpm view nx@latest version'
|
211
|
+
return (0, child_process_1.execSync)('pnpm view nx@latest version', {
|
212
|
+
windowsHide: true,
|
213
|
+
})
|
214
|
+
.toString()
|
215
|
+
.trim();
|
208
216
|
}
|
209
217
|
catch {
|
210
218
|
return null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.8.
|
3
|
+
"version": "19.8.2",
|
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": {
|
@@ -49,7 +49,6 @@
|
|
49
49
|
"figures": "3.2.0",
|
50
50
|
"flat": "^5.0.2",
|
51
51
|
"front-matter": "^4.0.2",
|
52
|
-
"fs-extra": "^11.1.0",
|
53
52
|
"ignore": "^5.0.4",
|
54
53
|
"jest-diff": "^29.4.1",
|
55
54
|
"jsonc-parser": "3.2.0",
|
@@ -68,7 +67,7 @@
|
|
68
67
|
"yargs-parser": "21.1.1",
|
69
68
|
"node-machine-id": "1.1.12",
|
70
69
|
"ora": "5.3.0",
|
71
|
-
"@nrwl/tao": "19.8.
|
70
|
+
"@nrwl/tao": "19.8.2"
|
72
71
|
},
|
73
72
|
"peerDependencies": {
|
74
73
|
"@swc-node/register": "^1.8.0",
|
@@ -83,16 +82,16 @@
|
|
83
82
|
}
|
84
83
|
},
|
85
84
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-x64": "19.8.
|
87
|
-
"@nx/nx-darwin-arm64": "19.8.
|
88
|
-
"@nx/nx-linux-x64-gnu": "19.8.
|
89
|
-
"@nx/nx-linux-x64-musl": "19.8.
|
90
|
-
"@nx/nx-win32-x64-msvc": "19.8.
|
91
|
-
"@nx/nx-linux-arm64-gnu": "19.8.
|
92
|
-
"@nx/nx-linux-arm64-musl": "19.8.
|
93
|
-
"@nx/nx-linux-arm-gnueabihf": "19.8.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "19.8.
|
95
|
-
"@nx/nx-freebsd-x64": "19.8.
|
85
|
+
"@nx/nx-darwin-x64": "19.8.2",
|
86
|
+
"@nx/nx-darwin-arm64": "19.8.2",
|
87
|
+
"@nx/nx-linux-x64-gnu": "19.8.2",
|
88
|
+
"@nx/nx-linux-x64-musl": "19.8.2",
|
89
|
+
"@nx/nx-win32-x64-msvc": "19.8.2",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "19.8.2",
|
91
|
+
"@nx/nx-linux-arm64-musl": "19.8.2",
|
92
|
+
"@nx/nx-linux-arm-gnueabihf": "19.8.2",
|
93
|
+
"@nx/nx-win32-arm64-msvc": "19.8.2",
|
94
|
+
"@nx/nx-freebsd-x64": "19.8.2"
|
96
95
|
},
|
97
96
|
"nx-migrations": {
|
98
97
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
@@ -152,25 +152,7 @@
|
|
152
152
|
]
|
153
153
|
},
|
154
154
|
"version": {
|
155
|
-
"
|
156
|
-
{
|
157
|
-
"$ref": "#/definitions/NxReleaseVersionConfiguration"
|
158
|
-
},
|
159
|
-
{
|
160
|
-
"allOf": [
|
161
|
-
{
|
162
|
-
"not": {
|
163
|
-
"required": ["git"]
|
164
|
-
}
|
165
|
-
},
|
166
|
-
{
|
167
|
-
"not": {
|
168
|
-
"required": ["preVersionCommand"]
|
169
|
-
}
|
170
|
-
}
|
171
|
-
]
|
172
|
-
}
|
173
|
-
]
|
155
|
+
"$ref": "#/definitions/NxReleaseGroupVersionConfiguration"
|
174
156
|
},
|
175
157
|
"changelog": {
|
176
158
|
"oneOf": [
|
@@ -675,9 +657,32 @@
|
|
675
657
|
},
|
676
658
|
"preVersionCommand": {
|
677
659
|
"type": "string",
|
678
|
-
"description": "A command to run after validation of nx release configuration, but before versioning begins.
|
660
|
+
"description": "A command to run after validation of nx release configuration, but before versioning begins. Useful for preparing build artifacts. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
|
679
661
|
}
|
680
|
-
}
|
662
|
+
},
|
663
|
+
"additionalProperties": false
|
664
|
+
},
|
665
|
+
"NxReleaseGroupVersionConfiguration": {
|
666
|
+
"type": "object",
|
667
|
+
"properties": {
|
668
|
+
"conventionalCommits": {
|
669
|
+
"type": "boolean",
|
670
|
+
"description": "Shorthand for enabling the current version of projects to be resolved from git tags, and the next version to be determined by analyzing commit messages according to the Conventional Commits specification.",
|
671
|
+
"default": false
|
672
|
+
},
|
673
|
+
"generator": {
|
674
|
+
"type": "string"
|
675
|
+
},
|
676
|
+
"generatorOptions": {
|
677
|
+
"type": "object",
|
678
|
+
"additionalProperties": true
|
679
|
+
},
|
680
|
+
"groupPreVersionCommand": {
|
681
|
+
"type": "string",
|
682
|
+
"description": "A command to run after validation of nx release configuration AND after the release.version.preVersionCommand (if any), but before versioning begins for this specific group. Useful for preparing build artifacts for the group. If --dry-run is passed, the command is still executed, but with the NX_DRY_RUN environment variable set to 'true'."
|
683
|
+
}
|
684
|
+
},
|
685
|
+
"additionalProperties": false
|
681
686
|
},
|
682
687
|
"NxReleaseChangelogConfiguration": {
|
683
688
|
"type": "object",
|
package/src/adapter/compat.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const allowedProjectExtensions: readonly ["tags", "implicitDependencies", "configFilePath", "$schema", "generators", "namedInputs", "name", "files", "root", "sourceRoot", "projectType", "release", "includedScripts", "metadata"];
|
2
|
-
export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudId", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess", "useInferencePlugins", "neverConnectToCloud", "sync"];
|
2
|
+
export declare const allowedWorkspaceExtensions: readonly ["implicitDependencies", "affected", "defaultBase", "tasksRunnerOptions", "workspaceLayout", "plugins", "targetDefaults", "files", "generators", "namedInputs", "extends", "cli", "pluginsConfig", "defaultProject", "installation", "release", "nxCloudAccessToken", "nxCloudId", "nxCloudUrl", "nxCloudEncryptionKey", "parallel", "cacheDirectory", "useDaemonProcess", "useInferencePlugins", "neverConnectToCloud", "sync", "enableDbCache"];
|
package/src/adapter/compat.js
CHANGED
@@ -20,7 +20,9 @@ async function requirePowerpack() {
|
|
20
20
|
return Promise.resolve().then(() => require('@nx/powerpack-license')).catch(async (e) => {
|
21
21
|
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
|
22
22
|
try {
|
23
|
-
(0, child_process_1.execSync)(`${(0, package_manager_1.getPackageManagerCommand)().addDev} @nx/powerpack-license@latest
|
23
|
+
(0, child_process_1.execSync)(`${(0, package_manager_1.getPackageManagerCommand)().addDev} @nx/powerpack-license@latest`, {
|
24
|
+
windowsHide: true,
|
25
|
+
});
|
24
26
|
// @ts-ignore
|
25
27
|
return await Promise.resolve().then(() => require('@nx/powerpack-license'));
|
26
28
|
}
|
@@ -34,7 +34,9 @@ async function installPackage(pkgName, version, nxJson) {
|
|
34
34
|
spinner.start();
|
35
35
|
if ((0, fs_1.existsSync)('package.json')) {
|
36
36
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
37
|
-
await new Promise((resolve) => (0, child_process_1.exec)(`${pmc.addDev} ${pkgName}@${version}`,
|
37
|
+
await new Promise((resolve) => (0, child_process_1.exec)(`${pmc.addDev} ${pkgName}@${version}`, {
|
38
|
+
windowsHide: true,
|
39
|
+
}, (error, stdout) => {
|
38
40
|
if (error) {
|
39
41
|
spinner.fail();
|
40
42
|
output_1.output.addNewline();
|
@@ -108,7 +110,7 @@ async function initializePlugin(pkgName, options, nxJson) {
|
|
108
110
|
catch (e) {
|
109
111
|
spinner.fail();
|
110
112
|
output_1.output.addNewline();
|
111
|
-
logger_1.logger.error(e
|
113
|
+
logger_1.logger.error(e);
|
112
114
|
output_1.output.error({
|
113
115
|
title: `Failed to initialize ${pkgName}. Please check the error above for more details.`,
|
114
116
|
});
|
@@ -43,6 +43,7 @@ async function viewLogs() {
|
|
43
43
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
44
44
|
(0, child_process_1.execSync)(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
|
45
45
|
stdio: [0, 1, 2],
|
46
|
+
windowsHide: true,
|
46
47
|
});
|
47
48
|
if (!cloudUsed) {
|
48
49
|
output_1.output.note({
|
@@ -34,6 +34,7 @@ async function nxExecCommand(args) {
|
|
34
34
|
NX_PROJECT_NAME: process.env.NX_TASK_TARGET_PROJECT,
|
35
35
|
NX_PROJECT_ROOT_PATH: projectGraph.nodes?.[process.env.NX_TASK_TARGET_PROJECT]?.data?.root,
|
36
36
|
},
|
37
|
+
windowsHide: true,
|
37
38
|
});
|
38
39
|
}
|
39
40
|
else {
|
@@ -66,6 +67,7 @@ async function runScriptAsNxTarget(projectGraph, argv, nxArgs) {
|
|
66
67
|
cwd: projectGraph.nodes?.[projectName]?.data?.root
|
67
68
|
? (0, path_2.joinPathFragments)(workspace_root_1.workspaceRoot, projectGraph.nodes?.[projectName]?.data?.root)
|
68
69
|
: workspace_root_1.workspaceRoot,
|
70
|
+
windowsHide: true,
|
69
71
|
});
|
70
72
|
});
|
71
73
|
}
|
@@ -77,7 +79,10 @@ function runTargetOnProject(scriptDefinition, targetName, project, projectName,
|
|
77
79
|
const pm = (0, package_manager_1.getPackageManagerCommand)();
|
78
80
|
// `targetName` might be an npm script with `:` like: `start:dev`, `start:debug`.
|
79
81
|
const command = `${pm.exec} nx run ${projectName}:\\\"${targetName}\\\" ${extraArgs.join(' ')}`;
|
80
|
-
(0, child_process_1.execSync)(command, {
|
82
|
+
(0, child_process_1.execSync)(command, {
|
83
|
+
stdio: 'inherit',
|
84
|
+
windowsHide: true,
|
85
|
+
});
|
81
86
|
}
|
82
87
|
function readScriptArgV(overrides) {
|
83
88
|
const scriptSeparatorIdx = process.argv.findIndex((el) => el === '--');
|
@@ -144,10 +144,12 @@ function write(patterns) {
|
|
144
144
|
const prettierPath = getPrettierPath();
|
145
145
|
(0, node_child_process_1.execSync)(`node "${prettierPath}" --write --list-different ${regularPatterns.join(' ')}`, {
|
146
146
|
stdio: [0, 1, 2],
|
147
|
+
windowsHide: true,
|
147
148
|
});
|
148
149
|
if (swcrcPatterns.length > 0) {
|
149
150
|
(0, node_child_process_1.execSync)(`node "${prettierPath}" --write --list-different ${swcrcPatterns.join(' ')} --parser json`, {
|
150
151
|
stdio: [0, 1, 2],
|
152
|
+
windowsHide: true,
|
151
153
|
});
|
152
154
|
}
|
153
155
|
}
|
@@ -158,7 +160,7 @@ async function check(patterns) {
|
|
158
160
|
}
|
159
161
|
const prettierPath = getPrettierPath();
|
160
162
|
return new Promise((resolve) => {
|
161
|
-
(0, node_child_process_1.exec)(`node "${prettierPath}" --list-different ${patterns.join(' ')}`, { encoding: 'utf-8' }, (error, stdout) => {
|
163
|
+
(0, node_child_process_1.exec)(`node "${prettierPath}" --list-different ${patterns.join(' ')}`, { encoding: 'utf-8', windowsHide: true }, (error, stdout) => {
|
162
164
|
if (error) {
|
163
165
|
// The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated.
|
164
166
|
resolve(stdout.trim().split('\n'));
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateGraph = generateGraph;
|
4
4
|
const crypto_1 = require("crypto");
|
5
5
|
const node_child_process_1 = require("node:child_process");
|
6
|
-
const
|
7
|
-
const fs_extra_1 = require("fs-extra");
|
6
|
+
const node_fs_1 = require("node:fs");
|
8
7
|
const http = require("http");
|
9
8
|
const minimatch_1 = require("minimatch");
|
10
9
|
const node_url_1 = require("node:url");
|
@@ -225,7 +224,7 @@ async function generateGraph(args, affectedProjects) {
|
|
225
224
|
process.exit(1);
|
226
225
|
}
|
227
226
|
}
|
228
|
-
let html = (0,
|
227
|
+
let html = (0, node_fs_1.readFileSync)((0, path_1.join)(__dirname, '../../core/graph/index.html'), 'utf-8');
|
229
228
|
prunedGraph = filterGraph(prunedGraph, args.focus || null, args.exclude || []);
|
230
229
|
if (args.file) {
|
231
230
|
// stdout is a magical constant that doesn't actually write a file
|
@@ -243,7 +242,7 @@ async function generateGraph(args, affectedProjects) {
|
|
243
242
|
if (ext === '.html') {
|
244
243
|
const assetsFolder = (0, path_1.join)(fileFolderPath, 'static');
|
245
244
|
const assets = [];
|
246
|
-
(0,
|
245
|
+
(0, node_fs_1.cpSync)((0, path_1.join)(__dirname, '../../core/graph'), assetsFolder, {
|
247
246
|
filter: (_src, dest) => {
|
248
247
|
const isntHtml = !/index\.html/.test(dest);
|
249
248
|
if (isntHtml && dest.includes('.')) {
|
@@ -251,6 +250,7 @@ async function generateGraph(args, affectedProjects) {
|
|
251
250
|
}
|
252
251
|
return isntHtml;
|
253
252
|
},
|
253
|
+
recursive: true,
|
254
254
|
});
|
255
255
|
const { projectGraphClientResponse } = await createProjectGraphAndSourceMapClientResponse(affectedProjects);
|
256
256
|
const taskGraphClientResponse = await createTaskGraphClientResponse();
|
@@ -260,15 +260,15 @@ async function generateGraph(args, affectedProjects) {
|
|
260
260
|
html = html.replace(/href="styles/g, 'href="static/styles');
|
261
261
|
html = html.replace(/<base href="\/".*>/g, '');
|
262
262
|
html = html.replace(/type="module"/g, '');
|
263
|
-
(0,
|
264
|
-
(0,
|
263
|
+
(0, node_fs_1.writeFileSync)(fullFilePath, html);
|
264
|
+
(0, node_fs_1.writeFileSync)((0, path_1.join)(assetsFolder, 'environment.js'), environmentJs);
|
265
265
|
output_1.output.success({
|
266
266
|
title: `HTML output created in ${fileFolderPath}`,
|
267
267
|
bodyLines: [fileFolderPath, ...assets],
|
268
268
|
});
|
269
269
|
}
|
270
270
|
else if (ext === '.json') {
|
271
|
-
(0,
|
271
|
+
(0, node_fs_1.mkdirSync)((0, path_1.dirname)(fullFilePath), { recursive: true });
|
272
272
|
const json = await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets);
|
273
273
|
(0, fileutils_1.writeJsonFile)(fullFilePath, json);
|
274
274
|
output_1.output.success({
|
@@ -394,13 +394,13 @@ async function startServer(html, environmentJs, host, port = 4211, watchForChang
|
|
394
394
|
}
|
395
395
|
let pathname = (0, path_1.join)(__dirname, '../../core/graph/', sanitizePath);
|
396
396
|
// if the file is not found or is a directory, return index.html
|
397
|
-
if (!(0,
|
397
|
+
if (!(0, node_fs_1.existsSync)(pathname) || (0, node_fs_1.statSync)(pathname).isDirectory()) {
|
398
398
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
399
399
|
res.end(html);
|
400
400
|
return;
|
401
401
|
}
|
402
402
|
try {
|
403
|
-
const data = (0,
|
403
|
+
const data = (0, node_fs_1.readFileSync)(pathname);
|
404
404
|
const ext = (0, path_1.parse)(pathname).ext;
|
405
405
|
res.setHeader('Content-type', mimeType[ext] || 'text/plain');
|
406
406
|
res.end(data);
|
@@ -801,5 +801,6 @@ function getHelpTextFromTarget(projectName, targetName) {
|
|
801
801
|
throw new Error(`No help command found for ${projectName}:${targetName}`);
|
802
802
|
return (0, node_child_process_1.execSync)(command, {
|
803
803
|
cwd: target.options?.cwd ?? workspace_root_1.workspaceRoot,
|
804
|
+
windowsHide: true,
|
804
805
|
}).toString();
|
805
806
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addNxToNest = addNxToNest;
|
4
4
|
const enquirer = require("enquirer");
|
5
|
-
const
|
5
|
+
const node_fs_1 = require("node:fs");
|
6
6
|
const path_1 = require("path");
|
7
7
|
const fileutils_1 = require("../../../utils/fileutils");
|
8
8
|
const output_1 = require("../../../utils/output");
|
@@ -214,7 +214,7 @@ function getJestOptions(isE2E, repoRoot, packageName, existingOptions) {
|
|
214
214
|
function tryCreateJestPreset(repoRoot) {
|
215
215
|
const jestPresetPath = (0, path_1.join)(repoRoot, 'jest.preset.js');
|
216
216
|
if (!(0, fileutils_1.fileExists)(jestPresetPath)) {
|
217
|
-
(0,
|
217
|
+
(0, node_fs_1.writeFileSync)(jestPresetPath, `
|
218
218
|
const nxPreset = require('@nx/jest/preset').default;
|
219
219
|
module.exports = {...nxPreset};
|
220
220
|
`, 'utf8');
|
@@ -231,8 +231,8 @@ function addJestTargets(repoRoot, packageName, projectJson, packageJson) {
|
|
231
231
|
if (isPresetCreated) {
|
232
232
|
unitTestOptions['preset'] = e2eTestOptions['preset'] = './jest.preset.js';
|
233
233
|
}
|
234
|
-
(0,
|
235
|
-
(0,
|
234
|
+
(0, node_fs_1.writeFileSync)(unitTestConfigPath, `export default ${JSON.stringify(unitTestOptions, null, 2)}`, 'utf8');
|
235
|
+
(0, node_fs_1.writeFileSync)(e2eTestConfigPath, `export default ${JSON.stringify(e2eTestOptions, null, 2)}`, 'utf8');
|
236
236
|
projectJson.targets['test'] = {
|
237
237
|
executor: '@nx/jest:jest',
|
238
238
|
outputs: [`{workspaceRoot}/coverage/${packageName}`],
|
@@ -312,7 +312,7 @@ function updateTsConfig(repoRoot, sourceRoot) {
|
|
312
312
|
}
|
313
313
|
function removeFile(repoRoot, file) {
|
314
314
|
const path = (0, path_1.join)(repoRoot, file);
|
315
|
-
(0,
|
315
|
+
(0, node_fs_1.unlinkSync)(path);
|
316
316
|
}
|
317
317
|
function mergeWithDefaultConfig(config) {
|
318
318
|
const defaultNestCliConfigurations = {
|
@@ -5,5 +5,8 @@ const child_process_1 = require("child_process");
|
|
5
5
|
const package_manager_1 = require("../../../../utils/package-manager");
|
6
6
|
function setupIntegratedWorkspace() {
|
7
7
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
8
|
-
(0, child_process_1.execSync)(`${pmc.exec} nx g @nx/angular:ng-add`, {
|
8
|
+
(0, child_process_1.execSync)(`${pmc.exec} nx g @nx/angular:ng-add`, {
|
9
|
+
stdio: [0, 1, 2],
|
10
|
+
windowsHide: true,
|
11
|
+
});
|
9
12
|
}
|
@@ -82,7 +82,10 @@ async function getLegacyMigrationFunctionIfApplicable(repoRoot, options) {
|
|
82
82
|
unscopedPkgName,
|
83
83
|
}, pmc);
|
84
84
|
output_1.output.log({ title: '๐ Setting up workspace' });
|
85
|
-
(0, child_process_1.execSync)(`${pmc.exec} ${legacyMigrationCommand}`, {
|
85
|
+
(0, child_process_1.execSync)(`${pmc.exec} ${legacyMigrationCommand}`, {
|
86
|
+
stdio: [0, 1, 2],
|
87
|
+
windowsHide: true,
|
88
|
+
});
|
86
89
|
if (useNxCloud) {
|
87
90
|
output_1.output.log({ title: '๐ ๏ธ Setting up Nx Cloud' });
|
88
91
|
await (0, utils_1.initCloud)('nx-init-angular');
|
@@ -107,7 +110,7 @@ async function installDependencies(repoRoot, pkgInfo, pmc) {
|
|
107
110
|
json.dependencies = (0, object_sort_1.sortObjectByKeys)(json.dependencies);
|
108
111
|
}
|
109
112
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
110
|
-
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2] });
|
113
|
+
(0, child_process_1.execSync)(pmc.install, { stdio: [0, 1, 2], windowsHide: true });
|
111
114
|
}
|
112
115
|
async function resolvePackageVersion(packageName, version) {
|
113
116
|
try {
|
@@ -62,7 +62,9 @@ function generateDotNxSetup(version) {
|
|
62
62
|
}
|
63
63
|
function normalizeVersionForNxJson(pkg, version) {
|
64
64
|
if (!(0, semver_1.valid)(version)) {
|
65
|
-
version = (0, child_process_1.execSync)(`npm view ${pkg}@${version} version
|
65
|
+
version = (0, child_process_1.execSync)(`npm view ${pkg}@${version} version`, {
|
66
|
+
windowsHide: true,
|
67
|
+
}).toString();
|
66
68
|
}
|
67
69
|
return version.trimEnd();
|
68
70
|
}
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkForUncommittedChanges = checkForUncommittedChanges;
|
4
4
|
const child_process_1 = require("child_process");
|
5
5
|
function checkForUncommittedChanges() {
|
6
|
-
const gitResult = (0, child_process_1.execSync)('git status --porcelain'
|
6
|
+
const gitResult = (0, child_process_1.execSync)('git status --porcelain', {
|
7
|
+
windowsHide: true,
|
8
|
+
}).toString();
|
7
9
|
const filteredResults = gitResult
|
8
10
|
.split('\n')
|
9
11
|
.filter((line) => !line.includes('.nx') && line.trim().length > 0);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.cleanUpFiles = cleanUpFiles;
|
4
|
-
const
|
4
|
+
const node_fs_1 = require("node:fs");
|
5
5
|
const fileutils_1 = require("../../../../utils/fileutils");
|
6
6
|
function cleanUpFiles(appName, isStandalone) {
|
7
7
|
// Delete targets from project since we delegate to npm scripts.
|
@@ -19,12 +19,12 @@ function cleanUpFiles(appName, isStandalone) {
|
|
19
19
|
}
|
20
20
|
}
|
21
21
|
(0, fileutils_1.writeJsonFile)(projectJsonPath, json);
|
22
|
-
(0,
|
22
|
+
(0, node_fs_1.rmSync)('temp-workspace', { recursive: true, force: true });
|
23
23
|
if (isStandalone) {
|
24
|
-
(0,
|
25
|
-
(0,
|
26
|
-
(0,
|
27
|
-
(0,
|
28
|
-
(0,
|
24
|
+
(0, node_fs_1.rmSync)('babel.config.json', { recursive: true, force: true });
|
25
|
+
(0, node_fs_1.rmSync)('jest.preset.js', { recursive: true, force: true });
|
26
|
+
(0, node_fs_1.rmSync)('jest.config.ts', { recursive: true, force: true });
|
27
|
+
(0, node_fs_1.rmSync)('libs', { recursive: true, force: true });
|
28
|
+
(0, node_fs_1.rmSync)('tools', { recursive: true, force: true });
|
29
29
|
}
|
30
30
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.addNxToCraRepo = addNxToCraRepo;
|
4
4
|
const child_process_1 = require("child_process");
|
5
|
-
const
|
5
|
+
const node_fs_1 = require("node:fs");
|
6
6
|
const path_1 = require("path");
|
7
7
|
const fileutils_1 = require("../../../../utils/fileutils");
|
8
8
|
const output_1 = require("../../../../utils/output");
|
@@ -41,6 +41,7 @@ function installDependencies(options) {
|
|
41
41
|
}
|
42
42
|
(0, child_process_1.execSync)(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
|
43
43
|
stdio: [0, 1, 2],
|
44
|
+
windowsHide: true,
|
44
45
|
});
|
45
46
|
}
|
46
47
|
async function normalizeOptions(options) {
|
@@ -54,7 +55,9 @@ async function normalizeOptions(options) {
|
|
54
55
|
...packageJson.devDependencies,
|
55
56
|
};
|
56
57
|
const isCRA5 = /^[^~]?5/.test(deps['react-scripts']);
|
57
|
-
const npmVersion = (0, child_process_1.execSync)('npm -v'
|
58
|
+
const npmVersion = (0, child_process_1.execSync)('npm -v', {
|
59
|
+
windowsHide: true,
|
60
|
+
}).toString();
|
58
61
|
// Should remove this check 04/2023 once Node 14 & npm 6 reach EOL
|
59
62
|
const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx
|
60
63
|
const isVite = options.vite;
|
@@ -86,8 +89,14 @@ async function reorgnizeWorkspaceStructure(options) {
|
|
86
89
|
moveFilesToTempWorkspace(options);
|
87
90
|
await addBundler(options);
|
88
91
|
output_1.output.log({ title: '๐งถ Updating .gitignore file' });
|
89
|
-
(0, child_process_1.execSync)(`echo "node_modules" >> .gitignore`, {
|
90
|
-
|
92
|
+
(0, child_process_1.execSync)(`echo "node_modules" >> .gitignore`, {
|
93
|
+
stdio: [0, 1, 2],
|
94
|
+
windowsHide: true,
|
95
|
+
});
|
96
|
+
(0, child_process_1.execSync)(`echo "dist" >> .gitignore`, {
|
97
|
+
stdio: [0, 1, 2],
|
98
|
+
windowsHide: true,
|
99
|
+
});
|
91
100
|
process.chdir('..');
|
92
101
|
copyFromTempWorkspaceToRoot();
|
93
102
|
cleanUpUnusedFilesAndAddConfigFiles(options);
|
@@ -107,13 +116,16 @@ async function reorgnizeWorkspaceStructure(options) {
|
|
107
116
|
}
|
108
117
|
}
|
109
118
|
function createTempWorkspace(options) {
|
110
|
-
(0,
|
111
|
-
(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=yes' : '--nxCloud=skip'} ${options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none'}`, { stdio: [0, 1, 2] });
|
119
|
+
(0, node_fs_1.rmSync)('temp-workspace', { recursive: true, force: true });
|
120
|
+
(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=yes' : '--nxCloud=skip'} ${options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none'}`, { stdio: [0, 1, 2], windowsHide: true });
|
112
121
|
output_1.output.log({ title: '๐ Welcome to Nx!' });
|
113
122
|
output_1.output.log({ title: '๐งน Clearing unused files' });
|
114
|
-
(0,
|
115
|
-
(0,
|
116
|
-
|
123
|
+
(0, node_fs_1.cpSync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName, 'project.json'), 'project.json', { recursive: true });
|
124
|
+
(0, node_fs_1.rmSync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName), {
|
125
|
+
recursive: true,
|
126
|
+
force: true,
|
127
|
+
});
|
128
|
+
(0, node_fs_1.rmSync)('node_modules', { recursive: true, force: true });
|
117
129
|
}
|
118
130
|
function copyPackageJsonDepsFromTempWorkspace() {
|
119
131
|
const repoRoot = process.cwd();
|
@@ -142,6 +154,12 @@ function overridePackageDeps(depConfigName, base, override) {
|
|
142
154
|
});
|
143
155
|
return base;
|
144
156
|
}
|
157
|
+
function moveSync(src, dest) {
|
158
|
+
const destParentDir = (0, path_1.dirname)(dest);
|
159
|
+
(0, node_fs_1.mkdirSync)(destParentDir, { recursive: true });
|
160
|
+
(0, node_fs_1.rmSync)(dest, { recursive: true, force: true });
|
161
|
+
return (0, node_fs_1.renameSync)(src, dest);
|
162
|
+
}
|
145
163
|
function moveFilesToTempWorkspace(options) {
|
146
164
|
output_1.output.log({ title: '๐ Moving your React app in your new Nx workspace' });
|
147
165
|
copyPackageJsonDepsFromTempWorkspace();
|
@@ -160,11 +178,9 @@ function moveFilesToTempWorkspace(options) {
|
|
160
178
|
const filesToMove = [...requiredCraFiles, ...optionalCraFiles].filter(Boolean);
|
161
179
|
filesToMove.forEach((f) => {
|
162
180
|
try {
|
163
|
-
|
181
|
+
moveSync(f, options.isStandalone
|
164
182
|
? (0, path_1.join)('temp-workspace', f)
|
165
|
-
: (0, path_1.join)('temp-workspace', 'apps', options.reactAppName, f)
|
166
|
-
overwrite: true,
|
167
|
-
});
|
183
|
+
: (0, path_1.join)('temp-workspace', 'apps', options.reactAppName, f));
|
168
184
|
}
|
169
185
|
catch (error) {
|
170
186
|
if (requiredCraFiles.includes(f)) {
|
@@ -191,13 +207,16 @@ async function addBundler(options) {
|
|
191
207
|
output_1.output.log({
|
192
208
|
title: '๐ฌ Skip CRA preflight check since Nx manages the monorepo',
|
193
209
|
});
|
194
|
-
(0, child_process_1.execSync)(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, {
|
210
|
+
(0, child_process_1.execSync)(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, {
|
211
|
+
stdio: [0, 1, 2],
|
212
|
+
windowsHide: true,
|
213
|
+
});
|
195
214
|
}
|
196
215
|
}
|
197
216
|
function copyFromTempWorkspaceToRoot() {
|
198
217
|
output_1.output.log({ title: '๐ Folder restructuring.' });
|
199
|
-
(0,
|
200
|
-
|
218
|
+
(0, node_fs_1.readdirSync)('temp-workspace').forEach((f) => {
|
219
|
+
moveSync((0, path_1.join)('temp-workspace', f), f);
|
201
220
|
});
|
202
221
|
}
|
203
222
|
function cleanUpUnusedFilesAndAddConfigFiles(options) {
|
@@ -206,6 +225,6 @@ function cleanUpUnusedFilesAndAddConfigFiles(options) {
|
|
206
225
|
output_1.output.log({ title: "๐ Extend the app's tsconfig.json from the base" });
|
207
226
|
(0, tsconfig_setup_1.setupTsConfig)(options.reactAppName, options.isStandalone);
|
208
227
|
if (options.isStandalone) {
|
209
|
-
(0,
|
228
|
+
(0, node_fs_1.rmSync)('apps', { recursive: true, force: true });
|
210
229
|
}
|
211
230
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.renameJsToJsx = renameJsToJsx;
|
4
|
-
const
|
4
|
+
const node_fs_1 = require("node:fs");
|
5
5
|
const workspace_context_1 = require("../../../../utils/workspace-context");
|
6
6
|
const fileutils_1 = require("../../../../utils/fileutils");
|
7
7
|
// Vite cannot process JSX like <div> or <Header> unless the file is named .jsx or .tsx
|
@@ -11,11 +11,11 @@ async function renameJsToJsx(appName, isStandalone) {
|
|
11
11
|
]);
|
12
12
|
files.forEach((file) => {
|
13
13
|
if ((0, fileutils_1.fileExists)(file)) {
|
14
|
-
const content = (0,
|
14
|
+
const content = (0, node_fs_1.readFileSync)(file).toString();
|
15
15
|
// Try to detect JSX before renaming to .jsx
|
16
16
|
// Files like setupTests.js from CRA should not be renamed
|
17
17
|
if (/<[a-zA-Z0-9]+/.test(content)) {
|
18
|
-
(0,
|
18
|
+
(0, node_fs_1.renameSync)(file, `${file}x`);
|
19
19
|
}
|
20
20
|
}
|
21
21
|
});
|