nx 19.7.2 → 19.7.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +12 -12
- package/schemas/nx-schema.json +2 -2
- package/src/command-line/add/add.js +2 -2
- package/src/command-line/affected/command-object.js +6 -6
- package/src/command-line/deprecated/command-objects.js +3 -3
- package/src/command-line/generate/generate.js +2 -1
- package/src/command-line/import/command-object.js +8 -6
- package/src/command-line/import/import.d.ts +1 -1
- package/src/command-line/import/import.js +45 -29
- package/src/command-line/import/utils/prepare-source-repo.js +7 -35
- package/src/command-line/init/init-v2.js +6 -2
- package/src/command-line/login/login.js +2 -2
- package/src/command-line/logout/logout.js +2 -2
- package/src/command-line/migrate/migrate.js +2 -2
- package/src/command-line/new/new.js +2 -1
- package/src/command-line/release/changelog.js +2 -2
- package/src/command-line/release/command-object.d.ts +2 -2
- package/src/command-line/release/config/config.js +10 -3
- package/src/command-line/release/plan-check.js +2 -2
- package/src/command-line/release/plan.js +2 -2
- package/src/command-line/release/publish.js +2 -2
- package/src/command-line/release/release.js +2 -2
- package/src/command-line/release/utils/git.d.ts +2 -2
- package/src/command-line/release/utils/git.js +12 -2
- package/src/command-line/release/utils/shared.d.ts +1 -1
- package/src/command-line/release/version.js +6 -1
- package/src/command-line/repair/repair.js +2 -2
- package/src/command-line/run/command-object.js +3 -3
- package/src/command-line/run/run.js +3 -2
- package/src/command-line/run-many/command-object.js +2 -2
- package/src/command-line/show/command-object.js +3 -3
- package/src/command-line/sync/sync.js +69 -11
- package/src/config/nx-json.d.ts +13 -5
- package/src/daemon/client/client.d.ts +3 -3
- package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +2 -2
- package/src/daemon/server/handle-get-sync-generator-changes.js +8 -6
- package/src/daemon/server/sync-generators.d.ts +4 -4
- package/src/daemon/server/sync-generators.js +11 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/native/nx.wasi-browser.js +42 -54
- package/src/native/nx.wasi.cjs +42 -54
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +0 -1
- package/src/nx-cloud/utilities/get-cloud-options.d.ts +1 -0
- package/src/nx-cloud/utilities/get-cloud-options.js +4 -0
- package/src/nx-cloud/utilities/is-workspace-claimed.d.ts +1 -1
- package/src/nx-cloud/utilities/is-workspace-claimed.js +6 -5
- package/src/nx-cloud/utilities/onboarding.js +2 -2
- package/src/plugins/js/utils/register.js +7 -0
- package/src/project-graph/error-types.d.ts +1 -1
- package/src/project-graph/error-types.js +19 -5
- package/src/tasks-runner/cache.js +2 -1
- package/src/tasks-runner/run-command.js +142 -30
- package/src/tasks-runner/task-orchestrator.d.ts +0 -1
- package/src/tasks-runner/task-orchestrator.js +3 -6
- package/src/utils/git-utils.d.ts +3 -2
- package/src/utils/git-utils.index-filter.d.ts +0 -0
- package/src/utils/git-utils.index-filter.js +20 -0
- package/src/utils/git-utils.js +44 -13
- package/src/utils/git-utils.tree-filter.d.ts +11 -0
- package/src/utils/git-utils.tree-filter.js +43 -0
- package/src/utils/handle-errors.d.ts +1 -0
- package/src/utils/handle-errors.js +71 -0
- package/src/utils/nx-cloud-utils.d.ts +0 -1
- package/src/utils/nx-cloud-utils.js +0 -10
- package/src/utils/params.d.ts +0 -1
- package/src/utils/params.js +0 -50
- package/src/utils/plugins/plugin-capabilities.js +4 -1
- package/src/utils/sync-generators.d.ts +35 -6
- package/src/utils/sync-generators.js +144 -47
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.7.
|
3
|
+
"version": "19.7.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": {
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"yargs-parser": "21.1.1",
|
72
72
|
"node-machine-id": "1.1.12",
|
73
73
|
"ora": "5.3.0",
|
74
|
-
"@nrwl/tao": "19.7.
|
74
|
+
"@nrwl/tao": "19.7.4"
|
75
75
|
},
|
76
76
|
"peerDependencies": {
|
77
77
|
"@swc-node/register": "^1.8.0",
|
@@ -86,16 +86,16 @@
|
|
86
86
|
}
|
87
87
|
},
|
88
88
|
"optionalDependencies": {
|
89
|
-
"@nx/nx-darwin-x64": "19.7.
|
90
|
-
"@nx/nx-darwin-arm64": "19.7.
|
91
|
-
"@nx/nx-linux-x64-gnu": "19.7.
|
92
|
-
"@nx/nx-linux-x64-musl": "19.7.
|
93
|
-
"@nx/nx-win32-x64-msvc": "19.7.
|
94
|
-
"@nx/nx-linux-arm64-gnu": "19.7.
|
95
|
-
"@nx/nx-linux-arm64-musl": "19.7.
|
96
|
-
"@nx/nx-linux-arm-gnueabihf": "19.7.
|
97
|
-
"@nx/nx-win32-arm64-msvc": "19.7.
|
98
|
-
"@nx/nx-freebsd-x64": "19.7.
|
89
|
+
"@nx/nx-darwin-x64": "19.7.4",
|
90
|
+
"@nx/nx-darwin-arm64": "19.7.4",
|
91
|
+
"@nx/nx-linux-x64-gnu": "19.7.4",
|
92
|
+
"@nx/nx-linux-x64-musl": "19.7.4",
|
93
|
+
"@nx/nx-win32-x64-msvc": "19.7.4",
|
94
|
+
"@nx/nx-linux-arm64-gnu": "19.7.4",
|
95
|
+
"@nx/nx-linux-arm64-musl": "19.7.4",
|
96
|
+
"@nx/nx-linux-arm-gnueabihf": "19.7.4",
|
97
|
+
"@nx/nx-win32-arm64-msvc": "19.7.4",
|
98
|
+
"@nx/nx-freebsd-x64": "19.7.4"
|
99
99
|
},
|
100
100
|
"nx-migrations": {
|
101
101
|
"migrations": "./migrations.json",
|
package/schemas/nx-schema.json
CHANGED
@@ -634,7 +634,7 @@
|
|
634
634
|
"description": "Custom git commit message to use when committing the changes made by this command"
|
635
635
|
},
|
636
636
|
"commitArgs": {
|
637
|
-
"type": "string",
|
637
|
+
"type": ["string", "array"],
|
638
638
|
"description": "Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes"
|
639
639
|
},
|
640
640
|
"stageChanges": {
|
@@ -650,7 +650,7 @@
|
|
650
650
|
"description": "Custom git tag message to use when tagging the changes made by this command. This defaults to be the same value as the tag itself."
|
651
651
|
},
|
652
652
|
"tagArgs": {
|
653
|
-
"type": "string",
|
653
|
+
"type": ["string", "array"],
|
654
654
|
"description": "Additional arguments to pass to the `git tag` command invoked behind the scenes"
|
655
655
|
}
|
656
656
|
}
|
@@ -12,13 +12,13 @@ const fileutils_1 = require("../../utils/fileutils");
|
|
12
12
|
const logger_1 = require("../../utils/logger");
|
13
13
|
const output_1 = require("../../utils/output");
|
14
14
|
const package_manager_1 = require("../../utils/package-manager");
|
15
|
-
const
|
15
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
16
16
|
const plugins_1 = require("../../utils/plugins");
|
17
17
|
const versions_1 = require("../../utils/versions");
|
18
18
|
const workspace_root_1 = require("../../utils/workspace-root");
|
19
19
|
const add_nx_scripts_1 = require("../init/implementation/dot-nx/add-nx-scripts");
|
20
20
|
function addHandler(options) {
|
21
|
-
return (0,
|
21
|
+
return (0, handle_errors_1.handleErrors)(options.verbose, async () => {
|
22
22
|
output_1.output.addNewline();
|
23
23
|
const [pkgName, version] = parsePackageSpecifier(options.packageSpecifier);
|
24
24
|
const nxJson = (0, nx_json_1.readNxJson)();
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsAffectedE2ECommand = exports.yargsAffectedLintCommand = exports.yargsAffectedBuildCommand = exports.yargsAffectedTestCommand = exports.yargsAffectedCommand = void 0;
|
4
4
|
const documentation_1 = require("../yargs-utils/documentation");
|
5
5
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
6
|
-
const
|
6
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
7
7
|
exports.yargsAffectedCommand = {
|
8
8
|
command: 'affected',
|
9
9
|
describe: 'Run target for affected projects.',
|
@@ -18,7 +18,7 @@ exports.yargsAffectedCommand = {
|
|
18
18
|
}
|
19
19
|
}), 'affected'),
|
20
20
|
handler: async (args) => {
|
21
|
-
const exitCode = await (0,
|
21
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
22
22
|
return (await Promise.resolve().then(() => require('./affected'))).affected('affected', (0, shared_options_1.withOverrides)(args));
|
23
23
|
});
|
24
24
|
process.exit(exitCode);
|
@@ -29,7 +29,7 @@ exports.yargsAffectedTestCommand = {
|
|
29
29
|
describe: false,
|
30
30
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
|
31
31
|
handler: async (args) => {
|
32
|
-
const exitCode = await (0,
|
32
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
33
33
|
return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
|
34
34
|
...(0, shared_options_1.withOverrides)(args),
|
35
35
|
target: 'test',
|
@@ -43,7 +43,7 @@ exports.yargsAffectedBuildCommand = {
|
|
43
43
|
describe: false,
|
44
44
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
|
45
45
|
handler: async (args) => {
|
46
|
-
const exitCode = await (0,
|
46
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
47
47
|
return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
|
48
48
|
...(0, shared_options_1.withOverrides)(args),
|
49
49
|
target: 'build',
|
@@ -57,7 +57,7 @@ exports.yargsAffectedLintCommand = {
|
|
57
57
|
describe: false,
|
58
58
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
|
59
59
|
handler: async (args) => {
|
60
|
-
const exitCode = await (0,
|
60
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
61
61
|
return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
|
62
62
|
...(0, shared_options_1.withOverrides)(args),
|
63
63
|
target: 'lint',
|
@@ -71,7 +71,7 @@ exports.yargsAffectedE2ECommand = {
|
|
71
71
|
describe: false,
|
72
72
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withAffectedOptions)((0, shared_options_1.withRunOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withConfiguration)(yargs)))), 'affected'),
|
73
73
|
handler: async (args) => {
|
74
|
-
const exitCode = await (0,
|
74
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
75
75
|
return (await Promise.resolve().then(() => require('./affected'))).affected('affected', {
|
76
76
|
...(0, shared_options_1.withOverrides)(args),
|
77
77
|
target: 'e2e',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsPrintAffectedCommand = exports.yargsAffectedGraphCommand = void 0;
|
4
|
-
const
|
4
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
5
5
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
6
6
|
const command_object_1 = require("../graph/command-object");
|
7
7
|
const affectedGraphDeprecationMessage = 'Use `nx graph --affected`, or `nx affected --graph` instead depending on which best suits your use case. The `affected:graph` command has been removed in Nx 19.';
|
@@ -15,7 +15,7 @@ exports.yargsAffectedGraphCommand = {
|
|
15
15
|
aliases: ['affected:dep-graph'],
|
16
16
|
builder: (yargs) => (0, shared_options_1.withAffectedOptions)((0, command_object_1.withGraphOptions)(yargs)),
|
17
17
|
handler: async (args) => {
|
18
|
-
const exitCode = await (0,
|
18
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(false, () => {
|
19
19
|
throw new Error(affectedGraphDeprecationMessage);
|
20
20
|
});
|
21
21
|
process.exit(exitCode);
|
@@ -39,7 +39,7 @@ exports.yargsPrintAffectedCommand = {
|
|
39
39
|
describe: 'Select the type of projects to be returned (e.g., --type=app).',
|
40
40
|
}),
|
41
41
|
handler: async (args) => {
|
42
|
-
const exitCode = await (0,
|
42
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(false, () => {
|
43
43
|
throw new Error(printAffectedDeprecationMessage);
|
44
44
|
});
|
45
45
|
process.exit(exitCode);
|
@@ -12,6 +12,7 @@ const tree_1 = require("../../generators/tree");
|
|
12
12
|
const project_graph_1 = require("../../project-graph/project-graph");
|
13
13
|
const logger_1 = require("../../utils/logger");
|
14
14
|
const params_1 = require("../../utils/params");
|
15
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
15
16
|
const local_plugins_1 = require("../../utils/plugins/local-plugins");
|
16
17
|
const print_help_1 = require("../../utils/print-help");
|
17
18
|
const workspace_root_1 = require("../../utils/workspace-root");
|
@@ -206,7 +207,7 @@ function printGenHelp(opts, schema, normalizedGeneratorName, aliases) {
|
|
206
207
|
});
|
207
208
|
}
|
208
209
|
async function generate(cwd, args) {
|
209
|
-
return (0,
|
210
|
+
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
210
211
|
const nxJsonConfiguration = (0, configuration_1.readNxJson)();
|
211
212
|
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
212
213
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
@@ -3,21 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsImportCommand = void 0;
|
4
4
|
const documentation_1 = require("../yargs-utils/documentation");
|
5
5
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
6
|
-
const
|
6
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
7
7
|
exports.yargsImportCommand = {
|
8
|
-
command: 'import [
|
8
|
+
command: 'import [sourceRepository] [destinationDirectory]',
|
9
9
|
describe: false,
|
10
10
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withVerbose)(yargs
|
11
|
-
.positional('
|
11
|
+
.positional('sourceRepository', {
|
12
12
|
type: 'string',
|
13
13
|
description: 'The remote URL of the source to import.',
|
14
14
|
})
|
15
|
-
.positional('
|
15
|
+
.positional('destinationDirectory', {
|
16
16
|
type: 'string',
|
17
|
+
alias: 'destination',
|
17
18
|
description: 'The directory in the current workspace to import into.',
|
18
19
|
})
|
19
|
-
.option('
|
20
|
+
.option('sourceDirectory', {
|
20
21
|
type: 'string',
|
22
|
+
alias: 'source',
|
21
23
|
description: 'The directory in the source repository to import from.',
|
22
24
|
})
|
23
25
|
.option('ref', {
|
@@ -34,7 +36,7 @@ exports.yargsImportCommand = {
|
|
34
36
|
default: true,
|
35
37
|
})), 'import'),
|
36
38
|
handler: async (args) => {
|
37
|
-
const exitCode = await (0,
|
39
|
+
const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
38
40
|
return (await Promise.resolve().then(() => require('./import'))).importHandler(args);
|
39
41
|
});
|
40
42
|
process.exit(exitCode);
|
@@ -25,41 +25,40 @@ const needs_install_1 = require("./utils/needs-install");
|
|
25
25
|
const file_utils_1 = require("../../project-graph/file-utils");
|
26
26
|
const importRemoteName = '__tmp_nx_import__';
|
27
27
|
async function importHandler(options) {
|
28
|
-
let {
|
28
|
+
let { sourceRepository, ref, source, destination } = options;
|
29
29
|
output_1.output.log({
|
30
|
-
title: 'Nx will walk you through the process of importing code from
|
30
|
+
title: 'Nx will walk you through the process of importing code from the source repository into this repository:',
|
31
31
|
bodyLines: [
|
32
|
-
`1. Nx will clone the
|
33
|
-
`2.
|
34
|
-
`3. The
|
35
|
-
`4. Nx will recommend plugins to integrate tools used in the imported code
|
36
|
-
`5. The code will be successfully imported into this workspace`,
|
32
|
+
`1. Nx will clone the source repository into a temporary directory`,
|
33
|
+
`2. The project code from the sourceDirectory will be moved to the destinationDirectory on a temporary branch in this repository`,
|
34
|
+
`3. The temporary branch will be merged into the current branch in this repository`,
|
35
|
+
`4. Nx will recommend plugins to integrate any new tools used in the imported code`,
|
37
36
|
'',
|
38
|
-
`Git history will be preserved during this process`,
|
37
|
+
`Git history will be preserved during this process as long as you MERGE these changes. Do NOT squash and do NOT rebase the changes when merging branches. If you would like to UNDO these changes, run "git reset HEAD~1 --hard"`,
|
39
38
|
],
|
40
39
|
});
|
41
40
|
const tempImportDirectory = (0, path_1.join)(tmp_1.tmpdir, 'nx-import');
|
42
|
-
if (!
|
43
|
-
|
41
|
+
if (!sourceRepository) {
|
42
|
+
sourceRepository = (await (0, enquirer_1.prompt)([
|
44
43
|
{
|
45
44
|
type: 'input',
|
46
|
-
name: '
|
45
|
+
name: 'sourceRepository',
|
47
46
|
message: 'What is the URL of the repository you want to import? (This can be a local git repository or a git remote URL)',
|
48
47
|
required: true,
|
49
48
|
},
|
50
|
-
])).
|
49
|
+
])).sourceRepository;
|
51
50
|
}
|
52
51
|
try {
|
53
|
-
const maybeLocalDirectory = await (0, promises_1.stat)(
|
52
|
+
const maybeLocalDirectory = await (0, promises_1.stat)(sourceRepository);
|
54
53
|
if (maybeLocalDirectory.isDirectory()) {
|
55
|
-
|
54
|
+
sourceRepository = (0, path_1.resolve)(sourceRepository);
|
56
55
|
}
|
57
56
|
}
|
58
57
|
catch (e) {
|
59
58
|
// It's a remote url
|
60
59
|
}
|
61
|
-
const
|
62
|
-
const spinner = createSpinner(`Cloning ${
|
60
|
+
const sourceTempRepoPath = (0, path_1.join)(tempImportDirectory, 'repo');
|
61
|
+
const spinner = createSpinner(`Cloning ${sourceRepository} into a temporary directory: ${sourceTempRepoPath} (Use --depth to limit commit history and speed up clone times)`).start();
|
63
62
|
try {
|
64
63
|
await (0, promises_1.rm)(tempImportDirectory, { recursive: true });
|
65
64
|
}
|
@@ -67,17 +66,17 @@ async function importHandler(options) {
|
|
67
66
|
await (0, promises_1.mkdir)(tempImportDirectory, { recursive: true });
|
68
67
|
let sourceGitClient;
|
69
68
|
try {
|
70
|
-
sourceGitClient = await (0, git_utils_1.cloneFromUpstream)(
|
69
|
+
sourceGitClient = await (0, git_utils_1.cloneFromUpstream)(sourceRepository, sourceTempRepoPath, {
|
71
70
|
originName: importRemoteName,
|
72
71
|
depth: options.depth,
|
73
72
|
});
|
74
73
|
}
|
75
74
|
catch (e) {
|
76
|
-
spinner.fail(`Failed to clone ${
|
77
|
-
let errorMessage = `Failed to clone ${
|
75
|
+
spinner.fail(`Failed to clone ${sourceRepository} into ${sourceTempRepoPath}`);
|
76
|
+
let errorMessage = `Failed to clone ${sourceRepository} into ${sourceTempRepoPath}. Please double check the remote and try again.\n${e.message}`;
|
78
77
|
throw new Error(errorMessage);
|
79
78
|
}
|
80
|
-
spinner.succeed(`Cloned into ${
|
79
|
+
spinner.succeed(`Cloned into ${sourceTempRepoPath}`);
|
81
80
|
// Detecting the package manager before preparing the source repo for import.
|
82
81
|
const sourcePackageManager = (0, package_manager_1.detectPackageManager)(sourceGitClient.root);
|
83
82
|
if (!ref) {
|
@@ -116,14 +115,17 @@ async function importHandler(options) {
|
|
116
115
|
},
|
117
116
|
])).destination;
|
118
117
|
}
|
119
|
-
const absSource = (0, path_1.join)(
|
118
|
+
const absSource = (0, path_1.join)(sourceTempRepoPath, source);
|
119
|
+
if ((0, path_1.isAbsolute)(destination)) {
|
120
|
+
throw new Error(`The destination directory must be a relative path in this repository.`);
|
121
|
+
}
|
120
122
|
const absDestination = (0, path_1.join)(process.cwd(), destination);
|
121
123
|
const destinationGitClient = new git_utils_1.GitRepository(process.cwd());
|
122
124
|
await assertDestinationEmpty(destinationGitClient, absDestination);
|
123
125
|
const tempImportBranch = getTempImportBranch(ref);
|
124
126
|
await sourceGitClient.addFetchRemote(importRemoteName, ref);
|
125
127
|
await sourceGitClient.fetch(importRemoteName, ref);
|
126
|
-
spinner.succeed(`Fetched ${ref} from ${
|
128
|
+
spinner.succeed(`Fetched ${ref} from ${sourceRepository}`);
|
127
129
|
spinner.start(`Checking out a temporary branch, ${tempImportBranch} based on ${ref}`);
|
128
130
|
await sourceGitClient.checkout(tempImportBranch, {
|
129
131
|
new: true,
|
@@ -134,14 +136,15 @@ async function importHandler(options) {
|
|
134
136
|
await (0, promises_1.stat)(absSource);
|
135
137
|
}
|
136
138
|
catch (e) {
|
137
|
-
throw new Error(`The source directory ${source} does not exist in ${
|
139
|
+
throw new Error(`The source directory ${source} does not exist in ${sourceRepository}. Please double check to make sure it exists.`);
|
138
140
|
}
|
139
141
|
const packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
|
140
142
|
const originalPackageWorkspaces = await (0, needs_install_1.getPackagesInPackageManagerWorkspace)(packageManager);
|
143
|
+
const sourceIsNxWorkspace = (0, node_fs_1.existsSync)((0, path_1.join)(sourceGitClient.root, 'nx.json'));
|
141
144
|
const relativeDestination = (0, path_1.relative)(destinationGitClient.root, absDestination);
|
142
|
-
await (0, prepare_source_repo_1.prepareSourceRepo)(sourceGitClient, ref, source, relativeDestination, tempImportBranch,
|
143
|
-
await createTemporaryRemote(destinationGitClient, (0, path_1.join)(
|
144
|
-
await (0, merge_remote_source_1.mergeRemoteSource)(destinationGitClient,
|
145
|
+
await (0, prepare_source_repo_1.prepareSourceRepo)(sourceGitClient, ref, source, relativeDestination, tempImportBranch, sourceRepository);
|
146
|
+
await createTemporaryRemote(destinationGitClient, (0, path_1.join)(sourceTempRepoPath, '.git'), importRemoteName);
|
147
|
+
await (0, merge_remote_source_1.mergeRemoteSource)(destinationGitClient, sourceRepository, tempImportBranch, destination, importRemoteName, ref);
|
145
148
|
spinner.start('Cleaning up temporary files and remotes');
|
146
149
|
await (0, promises_1.rm)(tempImportDirectory, { recursive: true });
|
147
150
|
await destinationGitClient.deleteGitRemote(importRemoteName);
|
@@ -202,13 +205,25 @@ async function importHandler(options) {
|
|
202
205
|
});
|
203
206
|
}
|
204
207
|
await warnOnMissingWorkspacesEntry(packageManager, pmc, relativeDestination);
|
208
|
+
if (source != destination) {
|
209
|
+
output_1.output.warn({
|
210
|
+
title: `Check configuration files`,
|
211
|
+
bodyLines: [
|
212
|
+
`The source directory (${source}) and destination directory (${destination}) are different.`,
|
213
|
+
`You may need to update configuration files to match the directory in this repository.`,
|
214
|
+
sourceIsNxWorkspace
|
215
|
+
? `For example, path options in project.json such as "main", "tsConfig", and "outputPath" need to be updated.`
|
216
|
+
: `For example, relative paths in tsconfig.json and other tooling configuration files may need to be updated.`,
|
217
|
+
],
|
218
|
+
});
|
219
|
+
}
|
205
220
|
// When only a subdirectory is imported, there might be devDependencies in the root package.json file
|
206
221
|
// that needs to be ported over as well.
|
207
222
|
if (ref) {
|
208
223
|
output_1.output.log({
|
209
224
|
title: `Check root dependencies`,
|
210
225
|
bodyLines: [
|
211
|
-
`"dependencies" and "devDependencies" are not imported from the source repository (${
|
226
|
+
`"dependencies" and "devDependencies" are not imported from the source repository (${sourceRepository}).`,
|
212
227
|
`You may need to add some of those dependencies to this workspace in order to run tasks successfully.`,
|
213
228
|
],
|
214
229
|
});
|
@@ -217,8 +232,9 @@ async function importHandler(options) {
|
|
217
232
|
title: `Merging these changes into ${(0, command_line_utils_1.getBaseRef)(nxJson)}`,
|
218
233
|
bodyLines: [
|
219
234
|
`MERGE these changes when merging these changes.`,
|
220
|
-
`Do NOT squash
|
221
|
-
`If you
|
235
|
+
`Do NOT squash these commits when merging these changes.`,
|
236
|
+
`If you rebase, make sure to use "--rebase-merges" to preserve merge commits.`,
|
237
|
+
`To UNDO these changes, run "git reset HEAD~1 --hard"`,
|
222
238
|
],
|
223
239
|
});
|
224
240
|
}
|
@@ -3,46 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareSourceRepo = prepareSourceRepo;
|
4
4
|
const createSpinner = require("ora");
|
5
5
|
const path_1 = require("path");
|
6
|
-
const promises_1 = require("node:fs/promises");
|
7
6
|
async function prepareSourceRepo(gitClient, ref, source, relativeDestination, tempImportBranch, sourceRemoteUrl) {
|
8
7
|
const spinner = createSpinner().start(`Fetching ${ref} from ${sourceRemoteUrl}`);
|
9
8
|
const relativeSourceDir = (0, path_1.relative)(gitClient.root, (0, path_1.join)(gitClient.root, source));
|
10
|
-
if (
|
11
|
-
|
12
|
-
|
13
|
-
await gitClient.filterRepo(relativeSourceDir);
|
14
|
-
}
|
15
|
-
else {
|
16
|
-
spinner.start(`Filtering git history to only include files in ${relativeSourceDir} (this might take a few minutes -- install git-filter-repo for faster performance)`);
|
17
|
-
await gitClient.filterBranch(relativeSourceDir, tempImportBranch);
|
18
|
-
}
|
19
|
-
spinner.succeed(`Filtered git history to only include files in ${relativeSourceDir}`);
|
9
|
+
if (await gitClient.hasFilterRepoInstalled()) {
|
10
|
+
spinner.start(`Filtering git history to only include files in ${relativeSourceDir}`);
|
11
|
+
await gitClient.filterRepo(relativeSourceDir, relativeDestination);
|
20
12
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
const files = await gitClient.getGitFiles('.');
|
25
|
-
try {
|
26
|
-
await (0, promises_1.rm)(destinationInSource, {
|
27
|
-
recursive: true,
|
28
|
-
});
|
13
|
+
else {
|
14
|
+
spinner.start(`Filtering git history to only include files in ${relativeSourceDir} (this might take a few minutes -- install git-filter-repo for faster performance)`);
|
15
|
+
await gitClient.filterBranch(relativeSourceDir, relativeDestination, tempImportBranch);
|
29
16
|
}
|
30
|
-
|
31
|
-
await (0, promises_1.mkdir)(destinationInSource, { recursive: true });
|
32
|
-
for (const file of files) {
|
33
|
-
spinner.start(`Moving files and git history to ${destinationInSource}: ${file}`);
|
34
|
-
const newPath = (0, path_1.join)(destinationInSource, file);
|
35
|
-
await (0, promises_1.mkdir)((0, path_1.dirname)(newPath), { recursive: true });
|
36
|
-
try {
|
37
|
-
await gitClient.move(file, newPath);
|
38
|
-
}
|
39
|
-
catch {
|
40
|
-
await wait(100);
|
41
|
-
await gitClient.move(file, newPath);
|
42
|
-
}
|
43
|
-
}
|
44
|
-
await gitClient.commit(`chore(repo): move ${source} to ${relativeDestination} to prepare to be imported`);
|
45
|
-
await gitClient.amendCommit();
|
17
|
+
spinner.succeed(`Filtered git history to only include files in ${relativeSourceDir}`);
|
46
18
|
spinner.succeed(`${sourceRemoteUrl} has been prepared to be imported into this workspace on a temporary branch: ${tempImportBranch} in ${gitClient.root}`);
|
47
19
|
}
|
48
20
|
function wait(ms) {
|
@@ -128,7 +128,7 @@ const npmPackageToPluginMap = {
|
|
128
128
|
'@remix-run/dev': '@nx/remix',
|
129
129
|
};
|
130
130
|
async function detectPlugins(nxJson, interactive) {
|
131
|
-
let files = ['package.json'].concat(
|
131
|
+
let files = ['package.json'].concat((0, workspace_context_1.globWithWorkspaceContextSync)(process.cwd(), ['**/*/package.json']));
|
132
132
|
const currentPlugins = new Set((nxJson.plugins ?? []).map((p) => {
|
133
133
|
const plugin = typeof p === 'string' ? p : p.plugin;
|
134
134
|
return (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(plugin);
|
@@ -155,7 +155,11 @@ async function detectPlugins(nxJson, interactive) {
|
|
155
155
|
}
|
156
156
|
}
|
157
157
|
}
|
158
|
-
|
158
|
+
let gradlewFiles = ['gradlew', 'gradlew.bat'].concat((0, workspace_context_1.globWithWorkspaceContextSync)(process.cwd(), [
|
159
|
+
'**/gradlew',
|
160
|
+
'**/gradlew.bat',
|
161
|
+
]));
|
162
|
+
if (gradlewFiles.some((f) => (0, fs_1.existsSync)(f))) {
|
159
163
|
detectedPlugins.add('@nx/gradle');
|
160
164
|
}
|
161
165
|
// Remove existing plugins
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loginHandler = loginHandler;
|
4
4
|
const update_manager_1 = require("../../nx-cloud/update-manager");
|
5
5
|
const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
|
6
|
-
const
|
6
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
7
7
|
function loginHandler(args) {
|
8
8
|
if (args.nxCloudUrl) {
|
9
9
|
process.env.NX_CLOUD_API = args.nxCloudUrl;
|
10
10
|
}
|
11
|
-
return (0,
|
11
|
+
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
12
12
|
const nxCloudClient = (await (0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)()))
|
13
13
|
.nxCloudClient;
|
14
14
|
await nxCloudClient.commands.login();
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logoutHandler = logoutHandler;
|
4
4
|
const update_manager_1 = require("../../nx-cloud/update-manager");
|
5
5
|
const get_cloud_options_1 = require("../../nx-cloud/utilities/get-cloud-options");
|
6
|
-
const
|
6
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
7
7
|
function logoutHandler(args) {
|
8
|
-
return (0,
|
8
|
+
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
9
9
|
const nxCloudClient = (await (0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)()))
|
10
10
|
.nxCloudClient;
|
11
11
|
await nxCloudClient.commands.logout();
|
@@ -18,7 +18,7 @@ const logger_1 = require("../../utils/logger");
|
|
18
18
|
const git_utils_1 = require("../../utils/git-utils");
|
19
19
|
const package_json_1 = require("../../utils/package-json");
|
20
20
|
const package_manager_1 = require("../../utils/package-manager");
|
21
|
-
const
|
21
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
22
22
|
const connect_to_nx_cloud_1 = require("../connect/connect-to-nx-cloud");
|
23
23
|
const output_1 = require("../../utils/output");
|
24
24
|
const fs_1 = require("fs");
|
@@ -1041,7 +1041,7 @@ async function runNxMigration(root, collectionPath, collection, name) {
|
|
1041
1041
|
}
|
1042
1042
|
async function migrate(root, args, rawArgs) {
|
1043
1043
|
await client_1.daemonClient.stop();
|
1044
|
-
return (0,
|
1044
|
+
return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
1045
1045
|
const opts = await parseMigrationsOptions(args);
|
1046
1046
|
if (opts.type === 'generateMigrations') {
|
1047
1047
|
await generateMigrationsJsonAndUpdatePackageJson(root, opts);
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newWorkspace = newWorkspace;
|
4
4
|
const tree_1 = require("../../generators/tree");
|
5
5
|
const params_1 = require("../../utils/params");
|
6
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
6
7
|
const generator_utils_1 = require("../generate/generator-utils");
|
7
8
|
function removeSpecialFlags(generatorOptions) {
|
8
9
|
delete generatorOptions.interactive;
|
@@ -12,7 +13,7 @@ function removeSpecialFlags(generatorOptions) {
|
|
12
13
|
delete generatorOptions['$0'];
|
13
14
|
}
|
14
15
|
async function newWorkspace(cwd, args) {
|
15
|
-
return (0,
|
16
|
+
return (0, handle_errors_1.handleErrors)(process.env.NX_VERBOSE_LOGGING === 'true' || args.verbose, async () => {
|
16
17
|
const isInteractive = args.interactive;
|
17
18
|
const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)('@nx/workspace/generators.json', 'new', null, {});
|
18
19
|
removeSpecialFlags(args);
|
@@ -16,7 +16,7 @@ const project_graph_1 = require("../../project-graph/project-graph");
|
|
16
16
|
const utils_1 = require("../../tasks-runner/utils");
|
17
17
|
const is_ci_1 = require("../../utils/is-ci");
|
18
18
|
const output_1 = require("../../utils/output");
|
19
|
-
const
|
19
|
+
const handle_errors_1 = require("../../utils/handle-errors");
|
20
20
|
const path_1 = require("../../utils/path");
|
21
21
|
const workspace_root_1 = require("../../utils/workspace-root");
|
22
22
|
const config_1 = require("./config/config");
|
@@ -32,7 +32,7 @@ const print_config_1 = require("./utils/print-config");
|
|
32
32
|
const resolve_changelog_renderer_1 = require("./utils/resolve-changelog-renderer");
|
33
33
|
const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
|
34
34
|
const shared_1 = require("./utils/shared");
|
35
|
-
const releaseChangelogCLIHandler = (args) => (0,
|
35
|
+
const releaseChangelogCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args));
|
36
36
|
exports.releaseChangelogCLIHandler = releaseChangelogCLIHandler;
|
37
37
|
function createAPI(overrideReleaseConfig) {
|
38
38
|
/**
|
@@ -14,10 +14,10 @@ interface GitCommitAndTagOptions {
|
|
14
14
|
stageChanges?: boolean;
|
15
15
|
gitCommit?: boolean;
|
16
16
|
gitCommitMessage?: string;
|
17
|
-
gitCommitArgs?: string;
|
17
|
+
gitCommitArgs?: string | string[];
|
18
18
|
gitTag?: boolean;
|
19
19
|
gitTagMessage?: string;
|
20
|
-
gitTagArgs?: string;
|
20
|
+
gitTagArgs?: string | string[];
|
21
21
|
}
|
22
22
|
export type VersionOptions = NxReleaseArgs & GitCommitAndTagOptions & VersionPlanArgs & FirstReleaseArgs & {
|
23
23
|
specifier?: string;
|
@@ -21,6 +21,7 @@ const fileutils_1 = require("../../../utils/fileutils");
|
|
21
21
|
const find_matching_projects_1 = require("../../../utils/find-matching-projects");
|
22
22
|
const output_1 = require("../../../utils/output");
|
23
23
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
24
|
+
const path_1 = require("../../../utils/path");
|
24
25
|
const resolve_changelog_renderer_1 = require("../utils/resolve-changelog-renderer");
|
25
26
|
const resolve_nx_json_error_message_1 = require("../utils/resolve-nx-json-error-message");
|
26
27
|
const conventional_commits_1 = require("./conventional-commits");
|
@@ -154,6 +155,7 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
154
155
|
conventionalCommits: false,
|
155
156
|
generator: '@nx/js:release-version',
|
156
157
|
generatorOptions: {},
|
158
|
+
groupPreVersionCommand: '',
|
157
159
|
},
|
158
160
|
changelog: {
|
159
161
|
createRelease: false,
|
@@ -205,7 +207,9 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
205
207
|
WORKSPACE_DEFAULTS.versionPlans);
|
206
208
|
const rootConventionalCommitsConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.conventionalCommits], fillUnspecifiedConventionalCommitsProperties(normalizeConventionalCommitsConfig(userConfig.conventionalCommits)));
|
207
209
|
// these options are not supported at the group level, only the root/command level
|
208
|
-
const rootVersionWithoutGlobalOptions = {
|
210
|
+
const rootVersionWithoutGlobalOptions = {
|
211
|
+
...rootVersionConfig,
|
212
|
+
};
|
209
213
|
delete rootVersionWithoutGlobalOptions.git;
|
210
214
|
delete rootVersionWithoutGlobalOptions.preVersionCommand;
|
211
215
|
// Apply conventionalCommits shorthand to the final group defaults if explicitly configured in the original user config
|
@@ -315,7 +319,10 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
315
319
|
projects: matchingProjects,
|
316
320
|
version: deepMergeDefaults(
|
317
321
|
// First apply any group level defaults, then apply actual root level config, then group level config
|
318
|
-
[
|
322
|
+
[
|
323
|
+
GROUP_DEFAULTS.version,
|
324
|
+
{ ...rootVersionWithoutGlobalOptions, groupPreVersionCommand: '' },
|
325
|
+
], releaseGroup.version),
|
319
326
|
// If the user has set any changelog config at all, including at the root level, then use one set of defaults, otherwise default to false for the whole feature
|
320
327
|
changelog: releaseGroup.changelog || rootChangelogConfig.projectChangelogs
|
321
328
|
? deepMergeDefaults(groupChangelogDefaults, releaseGroup.changelog || {})
|
@@ -657,7 +664,7 @@ async function getDefaultProjects(projectGraph, projectFileMap) {
|
|
657
664
|
function isProjectPublic(project, projectGraph, projectFileMap) {
|
658
665
|
const projectNode = projectGraph.nodes[project];
|
659
666
|
const packageJsonPath = (0, node_path_1.join)(projectNode.data.root, 'package.json');
|
660
|
-
if (!projectFileMap[project]?.find((f) => f.file === packageJsonPath)) {
|
667
|
+
if (!projectFileMap[project]?.find((f) => f.file === (0, path_1.normalizePath)(packageJsonPath))) {
|
661
668
|
return false;
|
662
669
|
}
|
663
670
|
try {
|