nx 19.6.0-canary.20240809-d3747e0 → 19.6.0-canary.20240814-6d83ae2
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/post-install.js +9 -0
- package/package.json +12 -12
- package/schemas/nx-schema.json +55 -4
- package/schemas/project-schema.json +7 -0
- package/src/adapter/compat.d.ts +1 -1
- package/src/adapter/compat.js +1 -0
- package/src/command-line/import/command-object.d.ts +2 -0
- package/src/command-line/import/command-object.js +38 -0
- package/src/command-line/import/import.d.ts +21 -0
- package/src/command-line/import/import.js +173 -0
- package/src/command-line/import/utils/merge-remote-source.d.ts +2 -0
- package/src/command-line/import/utils/merge-remote-source.js +14 -0
- package/src/command-line/import/utils/needs-install.d.ts +3 -0
- package/src/command-line/import/utils/needs-install.js +31 -0
- package/src/command-line/import/utils/prepare-source-repo.d.ts +2 -0
- package/src/command-line/import/utils/prepare-source-repo.js +104 -0
- package/src/command-line/init/init-v2.d.ts +7 -0
- package/src/command-line/init/init-v2.js +49 -16
- package/src/command-line/nx-commands.js +33 -28
- package/src/command-line/release/changelog.js +9 -9
- package/src/command-line/release/command-object.d.ts +12 -3
- package/src/command-line/release/command-object.js +16 -1
- package/src/command-line/release/config/config.js +4 -2
- package/src/command-line/release/config/filter-release-groups.d.ts +2 -2
- package/src/command-line/release/config/filter-release-groups.js +1 -1
- package/src/command-line/release/config/version-plans.d.ts +1 -1
- package/src/command-line/release/config/version-plans.js +12 -12
- package/src/command-line/release/plan-check.d.ts +4 -0
- package/src/command-line/release/plan-check.js +225 -0
- package/src/command-line/release/plan.js +1 -1
- package/src/command-line/release/release.js +3 -3
- package/src/command-line/release/version.js +1 -1
- package/src/command-line/sync/command-object.d.ts +6 -0
- package/src/command-line/sync/command-object.js +25 -0
- package/src/command-line/sync/sync.d.ts +6 -0
- package/src/command-line/sync/sync.js +30 -0
- package/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- package/src/config/nx-json.d.ts +32 -2
- package/src/config/workspace-json-project-json.d.ts +5 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/cache.d.ts +1 -0
- package/src/daemon/cache.js +25 -18
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.js +42 -1
- package/src/daemon/message-types/flush-sync-generator-changes-to-disk.d.ts +6 -0
- package/src/daemon/message-types/flush-sync-generator-changes-to-disk.js +11 -0
- package/src/daemon/message-types/force-shutdown.d.ts +5 -0
- package/src/daemon/message-types/force-shutdown.js +11 -0
- package/src/daemon/message-types/get-registered-sync-generators.d.ts +5 -0
- package/src/daemon/message-types/get-registered-sync-generators.js +11 -0
- package/src/daemon/message-types/get-sync-generator-changes.d.ts +6 -0
- package/src/daemon/message-types/get-sync-generator-changes.js +11 -0
- package/src/daemon/message-types/update-workspace-context.d.ts +8 -0
- package/src/daemon/message-types/update-workspace-context.js +11 -0
- package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.d.ts +2 -0
- package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +11 -0
- package/src/daemon/server/handle-force-shutdown.d.ts +5 -0
- package/src/daemon/server/handle-force-shutdown.js +18 -0
- package/src/daemon/server/handle-get-registered-sync-generators.d.ts +2 -0
- package/src/daemon/server/handle-get-registered-sync-generators.js +11 -0
- package/src/daemon/server/handle-get-sync-generator-changes.d.ts +2 -0
- package/src/daemon/server/handle-get-sync-generator-changes.js +17 -0
- package/src/daemon/server/handle-request-shutdown.js +2 -0
- package/src/daemon/server/handle-update-workspace-context.d.ts +2 -0
- package/src/daemon/server/handle-update-workspace-context.js +11 -0
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +20 -3
- package/src/daemon/server/server.d.ts +1 -0
- package/src/daemon/server/server.js +39 -0
- package/src/daemon/server/shutdown-utils.d.ts +2 -1
- package/src/daemon/server/shutdown-utils.js +11 -4
- package/src/daemon/server/sync-generators.d.ts +6 -0
- package/src/daemon/server/sync-generators.js +202 -0
- package/src/daemon/server/watcher.js +3 -0
- package/src/daemon/socket-utils.js +18 -5
- package/src/daemon/tmp-dir.js +2 -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/nx-cloud/models/onboarding-status.d.ts +1 -0
- package/src/nx-cloud/models/onboarding-status.js +2 -0
- package/src/nx-cloud/utilities/is-workspace-claimed.d.ts +1 -0
- package/src/nx-cloud/utilities/is-workspace-claimed.js +24 -0
- package/src/nx-cloud/utilities/onboarding.d.ts +5 -0
- package/src/nx-cloud/utilities/onboarding.js +28 -0
- package/src/project-graph/plugins/internal-api.js +16 -5
- package/src/project-graph/plugins/isolation/messaging.d.ts +5 -1
- package/src/project-graph/plugins/isolation/messaging.js +1 -0
- package/src/project-graph/plugins/isolation/plugin-pool.js +4 -6
- package/src/project-graph/plugins/isolation/plugin-worker.js +15 -0
- package/src/project-graph/utils/project-configuration-utils.js +5 -2
- package/src/tasks-runner/run-command.d.ts +1 -1
- package/src/tasks-runner/run-command.js +117 -2
- package/src/utils/command-line-utils.d.ts +1 -0
- package/src/utils/command-line-utils.js +6 -3
- package/src/utils/git-utils.d.ts +35 -0
- package/src/utils/git-utils.js +111 -0
- package/src/utils/package-manager.js +1 -1
- package/src/utils/plugins/output.js +1 -1
- package/src/utils/squash.d.ts +1 -0
- package/src/utils/squash.js +12 -0
- package/src/utils/sync-generators.d.ts +22 -0
- package/src/utils/sync-generators.js +161 -0
- package/src/utils/workspace-context.d.ts +2 -1
- package/src/utils/workspace-context.js +18 -1
- package/src/daemon/message-types/update-context-files.d.ts +0 -7
- package/src/daemon/message-types/update-context-files.js +0 -11
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.installPlugins = installPlugins;
|
3
4
|
exports.initHandler = initHandler;
|
5
|
+
exports.detectPlugins = detectPlugins;
|
4
6
|
const fs_1 = require("fs");
|
5
7
|
const semver_1 = require("semver");
|
6
8
|
const output_1 = require("../../utils/output");
|
@@ -17,6 +19,22 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
17
19
|
const connect_to_nx_cloud_1 = require("../connect/connect-to-nx-cloud");
|
18
20
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
19
21
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
22
|
+
const nx_json_1 = require("../../config/nx-json");
|
23
|
+
const get_package_name_from_import_path_1 = require("../../utils/get-package-name-from-import-path");
|
24
|
+
function installPlugins(repoRoot, plugins, pmc, updatePackageScripts) {
|
25
|
+
if (plugins.length === 0) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
(0, utils_1.addDepsToPackageJson)(repoRoot, plugins);
|
29
|
+
(0, utils_1.runInstall)(repoRoot, pmc);
|
30
|
+
output_1.output.log({ title: '🔨 Configuring plugins' });
|
31
|
+
for (const plugin of plugins) {
|
32
|
+
(0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} --no-interactive`, {
|
33
|
+
stdio: [0, 1, 2],
|
34
|
+
cwd: repoRoot,
|
35
|
+
});
|
36
|
+
}
|
37
|
+
}
|
20
38
|
async function initHandler(options) {
|
21
39
|
process.env.NX_RUNNING_NX_INIT = 'true';
|
22
40
|
const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
|
@@ -31,9 +49,10 @@ async function initHandler(options) {
|
|
31
49
|
console.log('Setting Nx up installation in `.nx`. You can run Nx commands like: `./nx.bat --help`');
|
32
50
|
}
|
33
51
|
(0, add_nx_scripts_1.generateDotNxSetup)(version);
|
34
|
-
const
|
52
|
+
const nxJson = (0, nx_json_1.readNxJson)(process.cwd());
|
53
|
+
const { plugins } = await detectPlugins(nxJson, options.interactive);
|
35
54
|
plugins.forEach((plugin) => {
|
36
|
-
(0,
|
55
|
+
(0, child_process_1.runNxSync)(`add ${plugin}`, {
|
37
56
|
stdio: 'inherit',
|
38
57
|
});
|
39
58
|
});
|
@@ -52,8 +71,6 @@ async function initHandler(options) {
|
|
52
71
|
});
|
53
72
|
return;
|
54
73
|
}
|
55
|
-
output_1.output.log({ title: '🧐 Checking dependencies' });
|
56
|
-
const { plugins, updatePackageScripts } = await detectPlugins();
|
57
74
|
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
58
75
|
if ((0, utils_1.isMonorepo)(packageJson)) {
|
59
76
|
await (0, add_nx_to_monorepo_1.addNxToMonorepo)({
|
@@ -76,18 +93,11 @@ async function initHandler(options) {
|
|
76
93
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
77
94
|
(0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
|
78
95
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
79
|
-
(0,
|
96
|
+
const nxJson = (0, nx_json_1.readNxJson)(repoRoot);
|
97
|
+
output_1.output.log({ title: '🧐 Checking dependencies' });
|
98
|
+
const { plugins, updatePackageScripts } = await detectPlugins(nxJson, options.interactive);
|
80
99
|
output_1.output.log({ title: '📦 Installing Nx' });
|
81
|
-
(
|
82
|
-
if (plugins.length > 0) {
|
83
|
-
output_1.output.log({ title: '🔨 Configuring plugins' });
|
84
|
-
for (const plugin of plugins) {
|
85
|
-
(0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} --no-interactive`, {
|
86
|
-
stdio: [0, 1, 2],
|
87
|
-
cwd: repoRoot,
|
88
|
-
});
|
89
|
-
}
|
90
|
-
}
|
100
|
+
installPlugins(repoRoot, plugins, pmc, updatePackageScripts);
|
91
101
|
if (useNxCloud) {
|
92
102
|
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
93
103
|
await (0, utils_1.initCloud)('nx-init');
|
@@ -117,8 +127,12 @@ const npmPackageToPluginMap = {
|
|
117
127
|
'react-native': '@nx/react-native',
|
118
128
|
'@remix-run/dev': '@nx/remix',
|
119
129
|
};
|
120
|
-
async function detectPlugins() {
|
130
|
+
async function detectPlugins(nxJson, interactive) {
|
121
131
|
let files = ['package.json'].concat(await (0, workspace_context_1.globWithWorkspaceContext)(process.cwd(), ['**/*/package.json']));
|
132
|
+
const currentPlugins = new Set((nxJson.plugins ?? []).map((p) => {
|
133
|
+
const plugin = typeof p === 'string' ? p : p.plugin;
|
134
|
+
return (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(plugin);
|
135
|
+
}));
|
122
136
|
const detectedPlugins = new Set();
|
123
137
|
for (const file of files) {
|
124
138
|
if (!(0, fs_1.existsSync)(file))
|
@@ -144,6 +158,12 @@ async function detectPlugins() {
|
|
144
158
|
if ((0, fs_1.existsSync)('gradlew') || (0, fs_1.existsSync)('gradlew.bat')) {
|
145
159
|
detectedPlugins.add('@nx/gradle');
|
146
160
|
}
|
161
|
+
// Remove existing plugins
|
162
|
+
for (const plugin of detectedPlugins) {
|
163
|
+
if (currentPlugins.has(plugin)) {
|
164
|
+
detectedPlugins.delete(plugin);
|
165
|
+
}
|
166
|
+
}
|
147
167
|
const plugins = Array.from(detectedPlugins);
|
148
168
|
if (plugins.length === 0) {
|
149
169
|
return {
|
@@ -151,6 +171,19 @@ async function detectPlugins() {
|
|
151
171
|
updatePackageScripts: false,
|
152
172
|
};
|
153
173
|
}
|
174
|
+
if (!interactive) {
|
175
|
+
output_1.output.log({
|
176
|
+
title: `Recommended Plugins:`,
|
177
|
+
bodyLines: [
|
178
|
+
`Adding these Nx plugins to integrate with the tools used in your workspace:`,
|
179
|
+
...plugins.map((p) => `- ${p}`),
|
180
|
+
],
|
181
|
+
});
|
182
|
+
return {
|
183
|
+
plugins,
|
184
|
+
updatePackageScripts: true,
|
185
|
+
};
|
186
|
+
}
|
154
187
|
output_1.output.log({
|
155
188
|
title: `Recommended Plugins:`,
|
156
189
|
bodyLines: [
|
@@ -10,20 +10,22 @@ const command_object_4 = require("./graph/command-object");
|
|
10
10
|
const command_object_5 = require("./exec/command-object");
|
11
11
|
const command_object_6 = require("./format/command-object");
|
12
12
|
const command_object_7 = require("./generate/command-object");
|
13
|
-
const command_object_8 = require("./
|
14
|
-
const command_object_9 = require("./
|
15
|
-
const command_object_10 = require("./
|
16
|
-
const command_object_11 = require("./
|
17
|
-
const command_object_12 = require("./
|
18
|
-
const command_object_13 = require("./
|
19
|
-
const command_object_14 = require("./
|
20
|
-
const command_object_15 = require("./run
|
21
|
-
const command_object_16 = require("./
|
22
|
-
const command_object_17 = require("./
|
23
|
-
const command_object_18 = require("./
|
24
|
-
const command_object_19 = require("./
|
25
|
-
const command_object_20 = require("./
|
13
|
+
const command_object_8 = require("./import/command-object");
|
14
|
+
const command_object_9 = require("./init/command-object");
|
15
|
+
const command_object_10 = require("./list/command-object");
|
16
|
+
const command_object_11 = require("./migrate/command-object");
|
17
|
+
const command_object_12 = require("./new/command-object");
|
18
|
+
const command_object_13 = require("./repair/command-object");
|
19
|
+
const command_object_14 = require("./report/command-object");
|
20
|
+
const command_object_15 = require("./run/command-object");
|
21
|
+
const command_object_16 = require("./run-many/command-object");
|
22
|
+
const command_object_17 = require("./show/command-object");
|
23
|
+
const command_object_18 = require("./watch/command-object");
|
24
|
+
const command_object_19 = require("./reset/command-object");
|
25
|
+
const command_object_20 = require("./release/command-object");
|
26
|
+
const command_object_21 = require("./add/command-object");
|
26
27
|
const command_objects_1 = require("./deprecated/command-objects");
|
28
|
+
const command_object_22 = require("./sync/command-object");
|
27
29
|
// Ensure that the output takes up the available width of the terminal.
|
28
30
|
yargs.wrap(yargs.terminalWidth());
|
29
31
|
exports.parserConfiguration = {
|
@@ -40,7 +42,7 @@ exports.commandsObject = yargs
|
|
40
42
|
.parserConfiguration(exports.parserConfiguration)
|
41
43
|
.usage(chalk.bold('Smart Monorepos · Fast CI'))
|
42
44
|
.demandCommand(1, '')
|
43
|
-
.command(
|
45
|
+
.command(command_object_21.yargsAddCommand)
|
44
46
|
.command(command_object_1.yargsAffectedBuildCommand)
|
45
47
|
.command(command_object_1.yargsAffectedCommand)
|
46
48
|
.command(command_object_1.yargsAffectedE2ECommand)
|
@@ -54,22 +56,25 @@ exports.commandsObject = yargs
|
|
54
56
|
.command(command_object_6.yargsFormatCheckCommand)
|
55
57
|
.command(command_object_6.yargsFormatWriteCommand)
|
56
58
|
.command(command_object_7.yargsGenerateCommand)
|
57
|
-
.command(command_object_8.
|
58
|
-
.command(
|
59
|
-
.command(
|
60
|
-
.command(command_object_10.
|
61
|
-
.command(command_object_11.
|
59
|
+
.command(command_object_8.yargsImportCommand)
|
60
|
+
.command(command_object_9.yargsInitCommand)
|
61
|
+
.command(command_object_11.yargsInternalMigrateCommand)
|
62
|
+
.command(command_object_10.yargsListCommand)
|
63
|
+
.command(command_object_11.yargsMigrateCommand)
|
64
|
+
.command(command_object_12.yargsNewCommand)
|
62
65
|
.command(command_objects_1.yargsPrintAffectedCommand)
|
63
|
-
.command(
|
64
|
-
.command(
|
65
|
-
.command(
|
66
|
-
.command(
|
67
|
-
.command(
|
68
|
-
.command(
|
69
|
-
.command(
|
66
|
+
.command(command_object_20.yargsReleaseCommand)
|
67
|
+
.command(command_object_13.yargsRepairCommand)
|
68
|
+
.command(command_object_14.yargsReportCommand)
|
69
|
+
.command(command_object_19.yargsResetCommand)
|
70
|
+
.command(command_object_15.yargsRunCommand)
|
71
|
+
.command(command_object_16.yargsRunManyCommand)
|
72
|
+
.command(command_object_17.yargsShowCommand)
|
73
|
+
.command(command_object_22.yargsSyncCommand)
|
74
|
+
.command(command_object_22.yargsSyncCheckCommand)
|
70
75
|
.command(command_object_2.yargsViewLogsCommand)
|
71
|
-
.command(
|
72
|
-
.command(
|
76
|
+
.command(command_object_18.yargsWatchCommand)
|
77
|
+
.command(command_object_15.yargsNxInfixCommand)
|
73
78
|
.scriptName('nx')
|
74
79
|
.help()
|
75
80
|
// NOTE: we handle --version in nx.ts, this just tells yargs that the option exists
|
@@ -84,7 +84,7 @@ function createAPI(overrideReleaseConfig) {
|
|
84
84
|
process.exit(1);
|
85
85
|
}
|
86
86
|
const rawVersionPlans = await (0, version_plans_1.readRawVersionPlans)();
|
87
|
-
(0, version_plans_1.
|
87
|
+
(0, version_plans_1.setResolvedVersionPlansOnGroups)(rawVersionPlans, releaseGroups, Object.keys(projectGraph.nodes));
|
88
88
|
if (args.deleteVersionPlans === undefined) {
|
89
89
|
// default to deleting version plans in this command instead of after versioning
|
90
90
|
args.deleteVersionPlans = true;
|
@@ -140,12 +140,12 @@ function createAPI(overrideReleaseConfig) {
|
|
140
140
|
// TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
|
141
141
|
let workspaceChangelogCommits = [];
|
142
142
|
// If there are multiple release groups, we'll just skip the workspace changelog anyway.
|
143
|
-
const versionPlansEnabledForWorkspaceChangelog = releaseGroups[0].
|
143
|
+
const versionPlansEnabledForWorkspaceChangelog = releaseGroups[0].resolvedVersionPlans;
|
144
144
|
if (versionPlansEnabledForWorkspaceChangelog) {
|
145
145
|
if (releaseGroups.length === 1) {
|
146
146
|
const releaseGroup = releaseGroups[0];
|
147
147
|
if (releaseGroup.projectsRelationship === 'fixed') {
|
148
|
-
const versionPlans = releaseGroup.
|
148
|
+
const versionPlans = releaseGroup.resolvedVersionPlans;
|
149
149
|
workspaceChangelogChanges = versionPlans
|
150
150
|
.flatMap((vp) => {
|
151
151
|
const releaseType = versionPlanSemverReleaseTypeToChangelogType(vp.groupVersionBump);
|
@@ -296,8 +296,8 @@ function createAPI(overrideReleaseConfig) {
|
|
296
296
|
let changes = null;
|
297
297
|
// TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
|
298
298
|
let commits;
|
299
|
-
if (releaseGroup.
|
300
|
-
changes = releaseGroup.
|
299
|
+
if (releaseGroup.resolvedVersionPlans) {
|
300
|
+
changes = releaseGroup.resolvedVersionPlans
|
301
301
|
.map((vp) => {
|
302
302
|
const bumpForProject = vp.projectVersionBumps[project.name];
|
303
303
|
if (!bumpForProject) {
|
@@ -396,8 +396,8 @@ function createAPI(overrideReleaseConfig) {
|
|
396
396
|
let changes = [];
|
397
397
|
// TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
|
398
398
|
let commits = [];
|
399
|
-
if (releaseGroup.
|
400
|
-
changes = releaseGroup.
|
399
|
+
if (releaseGroup.resolvedVersionPlans) {
|
400
|
+
changes = releaseGroup.resolvedVersionPlans
|
401
401
|
.flatMap((vp) => {
|
402
402
|
const releaseType = versionPlanSemverReleaseTypeToChangelogType(vp.groupVersionBump);
|
403
403
|
const changes = !vp.triggeredByProjects
|
@@ -585,8 +585,8 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
|
|
585
585
|
if (args.deleteVersionPlans && !args.dryRun) {
|
586
586
|
const planFiles = new Set();
|
587
587
|
releaseGroups.forEach((group) => {
|
588
|
-
if (group.
|
589
|
-
group.
|
588
|
+
if (group.resolvedVersionPlans) {
|
589
|
+
group.resolvedVersionPlans.forEach((plan) => {
|
590
590
|
(0, fs_extra_1.removeSync)(plan.absolutePath);
|
591
591
|
planFiles.add(plan.relativePath);
|
592
592
|
});
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { CommandModule } from 'yargs';
|
2
2
|
import { OutputStyle, RunManyOptions } from '../yargs-utils/shared-options';
|
3
3
|
import { VersionData } from './utils/shared';
|
4
|
-
export interface
|
4
|
+
export interface BaseNxReleaseArgs {
|
5
|
+
verbose?: boolean;
|
6
|
+
printConfig?: boolean | 'debug';
|
7
|
+
}
|
8
|
+
export interface NxReleaseArgs extends BaseNxReleaseArgs {
|
5
9
|
groups?: string[];
|
6
10
|
projects?: string[];
|
7
11
|
dryRun?: boolean;
|
8
|
-
verbose?: boolean;
|
9
|
-
printConfig?: boolean | 'debug';
|
10
12
|
}
|
11
13
|
interface GitCommitAndTagOptions {
|
12
14
|
stageChanges?: boolean;
|
@@ -43,6 +45,13 @@ export type PlanOptions = NxReleaseArgs & {
|
|
43
45
|
bump?: string;
|
44
46
|
message?: string;
|
45
47
|
};
|
48
|
+
export type PlanCheckOptions = BaseNxReleaseArgs & {
|
49
|
+
base?: string;
|
50
|
+
head?: string;
|
51
|
+
files?: string;
|
52
|
+
uncommitted?: boolean;
|
53
|
+
untracked?: boolean;
|
54
|
+
};
|
46
55
|
export type ReleaseOptions = NxReleaseArgs & FirstReleaseArgs & {
|
47
56
|
yes?: boolean;
|
48
57
|
skipPublish?: boolean;
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsReleaseCommand = void 0;
|
4
4
|
const yargs_1 = require("yargs");
|
5
5
|
const nx_json_1 = require("../../config/nx-json");
|
6
|
+
const command_line_utils_1 = require("../../utils/command-line-utils");
|
6
7
|
const logger_1 = require("../../utils/logger");
|
7
8
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
8
|
-
const command_line_utils_1 = require("../../utils/command-line-utils");
|
9
9
|
exports.yargsReleaseCommand = {
|
10
10
|
command: 'release',
|
11
11
|
describe: 'Orchestrate versioning and publishing of applications and libraries',
|
@@ -15,6 +15,7 @@ exports.yargsReleaseCommand = {
|
|
15
15
|
.command(changelogCommand)
|
16
16
|
.command(publishCommand)
|
17
17
|
.command(planCommand)
|
18
|
+
.command(planCheckCommand)
|
18
19
|
.demandCommand()
|
19
20
|
// Error on typos/mistyped CLI args, there is no reason to support arbitrary unknown args for these commands
|
20
21
|
.strictOptions()
|
@@ -206,6 +207,7 @@ const publishCommand = {
|
|
206
207
|
const planCommand = {
|
207
208
|
command: 'plan [bump]',
|
208
209
|
aliases: ['pl'],
|
210
|
+
// TODO: Remove this when docs are added
|
209
211
|
// Create a plan to pick a new version and generate a changelog entry.
|
210
212
|
// Hidden for now until the feature is more stable
|
211
213
|
describe: false,
|
@@ -237,6 +239,19 @@ const planCommand = {
|
|
237
239
|
process.exit(result);
|
238
240
|
},
|
239
241
|
};
|
242
|
+
const planCheckCommand = {
|
243
|
+
command: 'plan:check',
|
244
|
+
// TODO: Remove this when docs are added
|
245
|
+
// Create a plan to pick a new version and generate a changelog entry.
|
246
|
+
// Hidden for now until the feature is more stable
|
247
|
+
describe: false,
|
248
|
+
builder: (yargs) => (0, shared_options_1.withAffectedOptions)(yargs),
|
249
|
+
handler: async (args) => {
|
250
|
+
const release = await Promise.resolve().then(() => require('./plan-check'));
|
251
|
+
const result = await release.releasePlanCheckCLIHandler(args);
|
252
|
+
process.exit(result);
|
253
|
+
},
|
254
|
+
};
|
240
255
|
function coerceParallelOption(args) {
|
241
256
|
return {
|
242
257
|
...args,
|
@@ -144,7 +144,8 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
144
144
|
? defaultIndependentReleaseTagPattern
|
145
145
|
: defaultFixedReleaseTagPattern),
|
146
146
|
conventionalCommits: conventional_commits_1.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
|
147
|
-
versionPlans:
|
147
|
+
versionPlans: (userConfig.versionPlans ||
|
148
|
+
false),
|
148
149
|
};
|
149
150
|
const groupProjectsRelationship = userConfig.projectsRelationship || WORKSPACE_DEFAULTS.projectsRelationship;
|
150
151
|
const GROUP_DEFAULTS = {
|
@@ -200,7 +201,8 @@ async function createNxReleaseConfig(projectGraph, projectFileMap, userConfig =
|
|
200
201
|
git: userConfig.git,
|
201
202
|
},
|
202
203
|
], normalizeTrueToEmptyObject(userConfig.changelog));
|
203
|
-
const rootVersionPlansConfig = userConfig.versionPlans ??
|
204
|
+
const rootVersionPlansConfig = (userConfig.versionPlans ??
|
205
|
+
WORKSPACE_DEFAULTS.versionPlans);
|
204
206
|
const rootConventionalCommitsConfig = deepMergeDefaults([WORKSPACE_DEFAULTS.conventionalCommits], fillUnspecifiedConventionalCommitsProperties(normalizeConventionalCommitsConfig(userConfig.conventionalCommits)));
|
205
207
|
// these options are not supported at the group level, only the root/command level
|
206
208
|
const rootVersionWithoutGlobalOptions = { ...rootVersionConfig };
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { ProjectGraph } from '../../../config/project-graph';
|
2
2
|
import { NxReleaseConfig } from './config';
|
3
3
|
import { GroupVersionPlan, ProjectsVersionPlan } from './version-plans';
|
4
|
-
export type ReleaseGroupWithName =
|
4
|
+
export type ReleaseGroupWithName = NxReleaseConfig['groups'][string] & {
|
5
5
|
name: string;
|
6
|
-
|
6
|
+
resolvedVersionPlans: (ProjectsVersionPlan | GroupVersionPlan)[] | false;
|
7
7
|
};
|
8
8
|
export declare function filterReleaseGroups(projectGraph: ProjectGraph, nxReleaseConfig: NxReleaseConfig, projectsFilter?: string[], groupsFilter?: string[]): {
|
9
9
|
error: null | {
|
@@ -9,7 +9,7 @@ function filterReleaseGroups(projectGraph, nxReleaseConfig, projectsFilter, grou
|
|
9
9
|
return {
|
10
10
|
...group,
|
11
11
|
name,
|
12
|
-
|
12
|
+
resolvedVersionPlans: group.versionPlans ? [] : false,
|
13
13
|
};
|
14
14
|
});
|
15
15
|
const filteredProjectToReleaseGroup = new Map();
|
@@ -25,5 +25,5 @@ export interface ProjectsVersionPlan extends VersionPlan {
|
|
25
25
|
projectVersionBumps: Record<string, ReleaseType>;
|
26
26
|
}
|
27
27
|
export declare function readRawVersionPlans(): Promise<RawVersionPlan[]>;
|
28
|
-
export declare function
|
28
|
+
export declare function setResolvedVersionPlansOnGroups(rawVersionPlans: RawVersionPlan[], releaseGroups: ReleaseGroupWithName[], allProjectNamesInWorkspace: string[]): ReleaseGroupWithName[];
|
29
29
|
export declare function getVersionPlansAbsolutePath(): string;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readRawVersionPlans = readRawVersionPlans;
|
4
|
-
exports.
|
4
|
+
exports.setResolvedVersionPlansOnGroups = setResolvedVersionPlansOnGroups;
|
5
5
|
exports.getVersionPlansAbsolutePath = getVersionPlansAbsolutePath;
|
6
6
|
const fs_1 = require("fs");
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
@@ -35,7 +35,7 @@ async function readRawVersionPlans() {
|
|
35
35
|
}
|
36
36
|
return versionPlans;
|
37
37
|
}
|
38
|
-
function
|
38
|
+
function setResolvedVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNamesInWorkspace) {
|
39
39
|
const groupsByName = releaseGroups.reduce((acc, group) => acc.set(group.name, group), new Map());
|
40
40
|
const isDefaultGroup = isDefault(releaseGroups);
|
41
41
|
for (const rawVersionPlan of rawVersionPlans) {
|
@@ -45,7 +45,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
45
45
|
for (const [key, value] of Object.entries(rawVersionPlan.content)) {
|
46
46
|
if (groupsByName.has(key)) {
|
47
47
|
const group = groupsByName.get(key);
|
48
|
-
if (!group.
|
48
|
+
if (!group.resolvedVersionPlans) {
|
49
49
|
if (isDefaultGroup) {
|
50
50
|
throw new Error(`Found a version bump in '${rawVersionPlan.fileName}' but version plans are not enabled.`);
|
51
51
|
}
|
@@ -69,7 +69,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
69
69
|
throw new Error(`Found a version bump for group '${key}' in '${rawVersionPlan.fileName}' with an invalid release type. Please specify one of ${semver_1.RELEASE_TYPES.join(', ')}.`);
|
70
70
|
}
|
71
71
|
}
|
72
|
-
const existingPlan = (group.
|
72
|
+
const existingPlan = (group.resolvedVersionPlans.find((plan) => plan.fileName === rawVersionPlan.fileName));
|
73
73
|
if (existingPlan) {
|
74
74
|
if (existingPlan.groupVersionBump !== value) {
|
75
75
|
if (isDefaultGroup) {
|
@@ -81,7 +81,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
81
81
|
}
|
82
82
|
}
|
83
83
|
else {
|
84
|
-
group.
|
84
|
+
group.resolvedVersionPlans.push({
|
85
85
|
absolutePath: rawVersionPlan.absolutePath,
|
86
86
|
relativePath: rawVersionPlan.relativePath,
|
87
87
|
fileName: rawVersionPlan.fileName,
|
@@ -104,7 +104,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
104
104
|
throw new Error(`Found a version bump for project '${key}' in '${rawVersionPlan.fileName}' but the project is not in any configured release groups.`);
|
105
105
|
}
|
106
106
|
}
|
107
|
-
if (!groupForProject.
|
107
|
+
if (!groupForProject.resolvedVersionPlans) {
|
108
108
|
if (isDefaultGroup) {
|
109
109
|
throw new Error(`Found a version bump for project '${key}' in '${rawVersionPlan.fileName}' but version plans are not enabled.`);
|
110
110
|
}
|
@@ -116,12 +116,12 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
116
116
|
throw new Error(`Found a version bump for project '${key}' in '${rawVersionPlan.fileName}' with an invalid release type. Please specify one of ${semver_1.RELEASE_TYPES.join(', ')}.`);
|
117
117
|
}
|
118
118
|
if (groupForProject.projectsRelationship === 'independent') {
|
119
|
-
const existingPlan = (groupForProject.
|
119
|
+
const existingPlan = (groupForProject.resolvedVersionPlans.find((plan) => plan.fileName === rawVersionPlan.fileName));
|
120
120
|
if (existingPlan) {
|
121
121
|
existingPlan.projectVersionBumps[key] = value;
|
122
122
|
}
|
123
123
|
else {
|
124
|
-
groupForProject.
|
124
|
+
groupForProject.resolvedVersionPlans.push({
|
125
125
|
absolutePath: rawVersionPlan.absolutePath,
|
126
126
|
relativePath: rawVersionPlan.relativePath,
|
127
127
|
fileName: rawVersionPlan.fileName,
|
@@ -134,7 +134,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
134
134
|
}
|
135
135
|
}
|
136
136
|
else {
|
137
|
-
const existingPlan = (groupForProject.
|
137
|
+
const existingPlan = (groupForProject.resolvedVersionPlans.find((plan) => plan.fileName === rawVersionPlan.fileName));
|
138
138
|
// This can occur if the same fixed release group has multiple entries for different projects within
|
139
139
|
// the same version plan file. This will be the case when users are using the default release group.
|
140
140
|
if (existingPlan) {
|
@@ -151,7 +151,7 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
151
151
|
}
|
152
152
|
}
|
153
153
|
else {
|
154
|
-
groupForProject.
|
154
|
+
groupForProject.resolvedVersionPlans.push({
|
155
155
|
absolutePath: rawVersionPlan.absolutePath,
|
156
156
|
relativePath: rawVersionPlan.relativePath,
|
157
157
|
fileName: rawVersionPlan.fileName,
|
@@ -169,8 +169,8 @@ function setVersionPlansOnGroups(rawVersionPlans, releaseGroups, allProjectNames
|
|
169
169
|
}
|
170
170
|
// Order the plans from newest to oldest
|
171
171
|
releaseGroups.forEach((group) => {
|
172
|
-
if (group.
|
173
|
-
group.
|
172
|
+
if (group.resolvedVersionPlans) {
|
173
|
+
group.resolvedVersionPlans.sort((a, b) => b.createdOnMs - a.createdOnMs);
|
174
174
|
}
|
175
175
|
});
|
176
176
|
return releaseGroups;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { NxReleaseConfiguration } from '../../config/nx-json';
|
2
|
+
import { PlanCheckOptions, PlanOptions } from './command-object';
|
3
|
+
export declare const releasePlanCheckCLIHandler: (args: PlanCheckOptions) => Promise<number>;
|
4
|
+
export declare function createAPI(overrideReleaseConfig: NxReleaseConfiguration): (args: PlanOptions) => Promise<number>;
|