nx 20.2.0-rc.0 → 20.2.1
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/bin/nx.js +20 -5
- package/package.json +15 -14
- package/src/command-line/import/import.js +24 -38
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/package-json/create-nodes.js +2 -2
- package/src/project-graph/file-utils.d.ts +1 -1
- package/src/project-graph/file-utils.js +2 -2
- package/src/utils/package-manager.d.ts +14 -0
- package/src/utils/package-manager.js +87 -1
package/bin/nx.js
CHANGED
@@ -17,6 +17,7 @@ const perf_hooks_1 = require("perf_hooks");
|
|
17
17
|
const workspace_context_1 = require("../src/utils/workspace-context");
|
18
18
|
const client_1 = require("../src/daemon/client/client");
|
19
19
|
const db_connection_1 = require("../src/utils/db-connection");
|
20
|
+
const exit_codes_1 = require("../src/utils/exit-codes");
|
20
21
|
function main() {
|
21
22
|
if (process.argv[2] !== 'report' &&
|
22
23
|
process.argv[2] !== '--version' &&
|
@@ -214,11 +215,25 @@ const getLatestVersionOfNx = ((fn) => {
|
|
214
215
|
let cache = null;
|
215
216
|
return () => cache || (cache = fn());
|
216
217
|
})(_getLatestVersionOfNx);
|
217
|
-
function nxCleanup() {
|
218
|
+
function nxCleanup(signal) {
|
218
219
|
(0, db_connection_1.removeDbConnections)();
|
220
|
+
if (signal) {
|
221
|
+
process.exit((0, exit_codes_1.signalToCode)(signal));
|
222
|
+
}
|
223
|
+
else {
|
224
|
+
process.exit();
|
225
|
+
}
|
219
226
|
}
|
220
|
-
process.on('exit',
|
221
|
-
|
222
|
-
|
223
|
-
process.on('
|
227
|
+
process.on('exit', () => {
|
228
|
+
nxCleanup();
|
229
|
+
});
|
230
|
+
process.on('SIGINT', () => {
|
231
|
+
nxCleanup('SIGINT');
|
232
|
+
});
|
233
|
+
process.on('SIGTERM', () => {
|
234
|
+
nxCleanup('SIGTERM');
|
235
|
+
});
|
236
|
+
process.on('SIGHUP', () => {
|
237
|
+
nxCleanup('SIGHUP');
|
238
|
+
});
|
224
239
|
main();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.2.
|
3
|
+
"version": "20.2.1",
|
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": {
|
@@ -54,18 +54,19 @@
|
|
54
54
|
"jsonc-parser": "3.2.0",
|
55
55
|
"lines-and-columns": "2.0.3",
|
56
56
|
"minimatch": "9.0.3",
|
57
|
+
"node-machine-id": "1.1.12",
|
57
58
|
"npm-run-path": "^4.0.1",
|
58
59
|
"open": "^8.4.0",
|
60
|
+
"ora": "5.3.0",
|
59
61
|
"semver": "^7.5.3",
|
60
62
|
"string-width": "^4.2.3",
|
61
63
|
"tar-stream": "~2.2.0",
|
62
64
|
"tmp": "~0.2.1",
|
63
65
|
"tsconfig-paths": "^4.1.2",
|
64
66
|
"tslib": "^2.3.0",
|
67
|
+
"yaml": "^2.6.0",
|
65
68
|
"yargs": "^17.6.2",
|
66
|
-
"yargs-parser": "21.1.1"
|
67
|
-
"node-machine-id": "1.1.12",
|
68
|
-
"ora": "5.3.0"
|
69
|
+
"yargs-parser": "21.1.1"
|
69
70
|
},
|
70
71
|
"peerDependencies": {
|
71
72
|
"@swc-node/register": "^1.8.0",
|
@@ -80,16 +81,16 @@
|
|
80
81
|
}
|
81
82
|
},
|
82
83
|
"optionalDependencies": {
|
83
|
-
"@nx/nx-darwin-
|
84
|
-
"@nx/nx-darwin-
|
85
|
-
"@nx/nx-
|
86
|
-
"@nx/nx-linux-
|
87
|
-
"@nx/nx-
|
88
|
-
"@nx/nx-linux-arm64-
|
89
|
-
"@nx/nx-linux-
|
90
|
-
"@nx/nx-linux-
|
91
|
-
"@nx/nx-win32-arm64-msvc": "20.2.
|
92
|
-
"@nx/nx-
|
84
|
+
"@nx/nx-darwin-arm64": "20.2.1",
|
85
|
+
"@nx/nx-darwin-x64": "20.2.1",
|
86
|
+
"@nx/nx-freebsd-x64": "20.2.1",
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "20.2.1",
|
88
|
+
"@nx/nx-linux-arm64-gnu": "20.2.1",
|
89
|
+
"@nx/nx-linux-arm64-musl": "20.2.1",
|
90
|
+
"@nx/nx-linux-x64-gnu": "20.2.1",
|
91
|
+
"@nx/nx-linux-x64-musl": "20.2.1",
|
92
|
+
"@nx/nx-win32-arm64-msvc": "20.2.1",
|
93
|
+
"@nx/nx-win32-x64-msvc": "20.2.1"
|
93
94
|
},
|
94
95
|
"nx-migrations": {
|
95
96
|
"migrations": "./migrations.json",
|
@@ -2,10 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.importHandler = importHandler;
|
4
4
|
const path_1 = require("path");
|
5
|
-
const minimatch_1 = require("minimatch");
|
6
5
|
const node_fs_1 = require("node:fs");
|
7
6
|
const chalk = require("chalk");
|
8
|
-
const js_yaml_1 = require("@zkochan/js-yaml");
|
9
7
|
const git_utils_1 = require("../../utils/git-utils");
|
10
8
|
const promises_1 = require("node:fs/promises");
|
11
9
|
const tmp_1 = require("tmp");
|
@@ -22,7 +20,7 @@ const command_line_utils_1 = require("../../utils/command-line-utils");
|
|
22
20
|
const prepare_source_repo_1 = require("./utils/prepare-source-repo");
|
23
21
|
const merge_remote_source_1 = require("./utils/merge-remote-source");
|
24
22
|
const needs_install_1 = require("./utils/needs-install");
|
25
|
-
const
|
23
|
+
const minimatch_1 = require("minimatch");
|
26
24
|
const importRemoteName = '__tmp_nx_import__';
|
27
25
|
async function importHandler(options) {
|
28
26
|
process.env.NX_RUNNING_NX_IMPORT = 'true';
|
@@ -166,6 +164,7 @@ async function importHandler(options) {
|
|
166
164
|
],
|
167
165
|
});
|
168
166
|
}
|
167
|
+
await handleMissingWorkspacesEntry(packageManager, pmc, relativeDestination, destinationGitClient);
|
169
168
|
// If install fails, we should continue since the errors could be resolved later.
|
170
169
|
let installFailed = false;
|
171
170
|
if (plugins.length > 0) {
|
@@ -208,7 +207,6 @@ async function importHandler(options) {
|
|
208
207
|
],
|
209
208
|
});
|
210
209
|
}
|
211
|
-
await warnOnMissingWorkspacesEntry(packageManager, pmc, relativeDestination);
|
212
210
|
if (source != destination) {
|
213
211
|
output_1.output.warn({
|
214
212
|
title: `Check configuration files`,
|
@@ -259,9 +257,10 @@ async function createTemporaryRemote(destinationGitClient, sourceRemoteUrl, remo
|
|
259
257
|
await destinationGitClient.addGitRemote(remoteName, sourceRemoteUrl);
|
260
258
|
await destinationGitClient.fetch(remoteName);
|
261
259
|
}
|
262
|
-
|
263
|
-
|
264
|
-
|
260
|
+
/**
|
261
|
+
* If the user imports a project that isn't in the workspaces entry, we should add that path to the workspaces entry.
|
262
|
+
*/
|
263
|
+
async function handleMissingWorkspacesEntry(pm, pmc, pkgPath, destinationGitClient) {
|
265
264
|
if (!(0, package_manager_1.isWorkspacesEnabled)(pm, workspace_root_1.workspaceRoot)) {
|
266
265
|
output_1.output.warn({
|
267
266
|
title: `Missing workspaces in package.json`,
|
@@ -292,37 +291,24 @@ async function warnOnMissingWorkspacesEntry(pm, pmc, pkgPath) {
|
|
292
291
|
});
|
293
292
|
}
|
294
293
|
else {
|
295
|
-
|
296
|
-
|
297
|
-
if (
|
298
|
-
|
299
|
-
workspaces = packageJson.workspaces;
|
300
|
-
}
|
301
|
-
else if (pm === 'pnpm') {
|
302
|
-
const yamlPath = (0, path_1.join)(workspace_root_1.workspaceRoot, 'pnpm-workspace.yaml');
|
303
|
-
if ((0, node_fs_1.existsSync)(yamlPath)) {
|
304
|
-
const yamlContent = await node_fs_1.promises.readFile(yamlPath, 'utf-8');
|
305
|
-
const yaml = (0, js_yaml_1.load)(yamlContent);
|
306
|
-
workspaces = yaml.packages;
|
307
|
-
}
|
308
|
-
}
|
309
|
-
if (workspaces) {
|
310
|
-
const isPkgIncluded = workspaces.some((w) => (0, minimatch_1.minimatch)(pkgPath, w));
|
311
|
-
if (!isPkgIncluded) {
|
312
|
-
const pkgsDir = (0, path_1.dirname)(pkgPath);
|
313
|
-
output_1.output.warn({
|
314
|
-
title: `Project missing in workspaces`,
|
315
|
-
bodyLines: pm === 'npm' || pm === 'yarn' || pm === 'bun'
|
316
|
-
? [
|
317
|
-
`The imported project (${pkgPath}) is missing the "workspaces" field in package.json.`,
|
318
|
-
`Add "${pkgsDir}/*" to workspaces run "${pmc.install}".`,
|
319
|
-
]
|
320
|
-
: [
|
321
|
-
`The imported project (${pkgPath}) is missing the "packages" field in pnpm-workspaces.yaml.`,
|
322
|
-
`Add "${pkgsDir}/*" to packages run "${pmc.install}".`,
|
323
|
-
],
|
324
|
-
});
|
325
|
-
}
|
294
|
+
let workspaces = (0, package_manager_1.getPackageWorkspaces)(pm, workspace_root_1.workspaceRoot);
|
295
|
+
const isPkgIncluded = workspaces.some((w) => (0, minimatch_1.minimatch)(pkgPath, w));
|
296
|
+
if (isPkgIncluded) {
|
297
|
+
return;
|
326
298
|
}
|
299
|
+
(0, package_manager_1.addPackagePathToWorkspaces)(pkgPath, pm, workspaces, workspace_root_1.workspaceRoot);
|
300
|
+
await destinationGitClient.amendCommit();
|
301
|
+
output_1.output.success({
|
302
|
+
title: `Project added in workspaces`,
|
303
|
+
bodyLines: pm === 'npm' || pm === 'yarn' || pm === 'bun'
|
304
|
+
? [
|
305
|
+
`The imported project (${chalk.bold(pkgPath)}) is missing the "workspaces" field in package.json.`,
|
306
|
+
`Added "${chalk.bold(pkgPath)}" to workspaces.`,
|
307
|
+
]
|
308
|
+
: [
|
309
|
+
`The imported project (${chalk.bold(pkgPath)}) is missing the "packages" field in pnpm-workspaces.yaml.`,
|
310
|
+
`Added "${chalk.bold(pkgPath)}" to packages.`,
|
311
|
+
],
|
312
|
+
});
|
327
313
|
}
|
328
314
|
}
|