@storm-software/git-tools 2.130.40 → 2.131.7
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/README.md +1 -1
- package/bin/{chunk-3RY4CGUX.js → chunk-32WE3MHJ.js} +3 -3
- package/bin/{chunk-3RY4CGUX.js.map → chunk-32WE3MHJ.js.map} +1 -1
- package/bin/chunk-4EOHM2UV.cjs +16 -0
- package/bin/{chunk-ROM64JTJ.cjs.map → chunk-4EOHM2UV.cjs.map} +1 -1
- package/bin/{chunk-PTYTYIPG.cjs → chunk-4ILBJTRR.cjs} +9 -3
- package/bin/chunk-4ILBJTRR.cjs.map +1 -0
- package/bin/{chunk-BHWWH5OI.js → chunk-7ES3CGZQ.js} +9 -4
- package/bin/chunk-7ES3CGZQ.js.map +1 -0
- package/bin/{chunk-Y6YU46VF.js → chunk-ABI4JM6L.js} +3 -3
- package/bin/{chunk-Y6YU46VF.js.map → chunk-ABI4JM6L.js.map} +1 -1
- package/bin/{chunk-UIGOGTUM.cjs → chunk-AQ5YHZ3Z.cjs} +4 -4
- package/bin/{chunk-UIGOGTUM.cjs.map → chunk-AQ5YHZ3Z.cjs.map} +1 -1
- package/bin/{chunk-IEGXPTOH.js → chunk-AZGQVIYO.js} +4 -4
- package/bin/{chunk-IEGXPTOH.js.map → chunk-AZGQVIYO.js.map} +1 -1
- package/bin/{chunk-6V4HD3QJ.js → chunk-CDUCLZJV.js} +4 -4
- package/bin/{chunk-6V4HD3QJ.js.map → chunk-CDUCLZJV.js.map} +1 -1
- package/bin/{chunk-GU7L3IBA.js → chunk-CVTLZKKX.js} +4 -4
- package/bin/{chunk-GU7L3IBA.js.map → chunk-CVTLZKKX.js.map} +1 -1
- package/bin/{chunk-THX6DU6T.cjs → chunk-DPKFBB3S.cjs} +7 -7
- package/bin/{chunk-THX6DU6T.cjs.map → chunk-DPKFBB3S.cjs.map} +1 -1
- package/bin/{chunk-V6PBXXP5.js → chunk-IAZL2KCV.js} +4 -4
- package/bin/{chunk-V6PBXXP5.js.map → chunk-IAZL2KCV.js.map} +1 -1
- package/bin/{chunk-FH5OSXAJ.cjs → chunk-MTAYUS7E.cjs} +18 -2
- package/bin/chunk-MTAYUS7E.cjs.map +1 -0
- package/bin/{chunk-DNLVUV64.js → chunk-NOZEXVLA.js} +4 -4
- package/bin/{chunk-DNLVUV64.js.map → chunk-NOZEXVLA.js.map} +1 -1
- package/bin/{chunk-LR2WNL25.cjs → chunk-OGGY5I23.cjs} +7 -7
- package/bin/{chunk-LR2WNL25.cjs.map → chunk-OGGY5I23.cjs.map} +1 -1
- package/bin/chunk-POFLIQQB.cjs +18 -0
- package/bin/{chunk-USGU6ZVC.cjs.map → chunk-POFLIQQB.cjs.map} +1 -1
- package/bin/chunk-RPK5AKGK.js +39 -0
- package/bin/chunk-RPK5AKGK.js.map +1 -0
- package/bin/{chunk-27LFN4VQ.cjs → chunk-RZNFHUM6.cjs} +7 -7
- package/bin/{chunk-27LFN4VQ.cjs.map → chunk-RZNFHUM6.cjs.map} +1 -1
- package/bin/{chunk-MY767YV7.cjs → chunk-W5P2IM2W.cjs} +6 -6
- package/bin/{chunk-MY767YV7.cjs.map → chunk-W5P2IM2W.cjs.map} +1 -1
- package/bin/git.cjs +1439 -225
- package/bin/git.cjs.map +1 -1
- package/bin/git.js +1334 -123
- package/bin/git.js.map +1 -1
- package/bin/post-checkout.cjs +8 -8
- package/bin/post-checkout.js +3 -3
- package/bin/post-commit.cjs +8 -8
- package/bin/post-commit.js +3 -3
- package/bin/post-merge.cjs +8 -8
- package/bin/post-merge.js +3 -3
- package/bin/pre-commit.cjs +7 -7
- package/bin/pre-commit.js +2 -2
- package/bin/pre-install.cjs +8 -8
- package/bin/pre-install.js +3 -3
- package/bin/pre-push.cjs +7 -7
- package/bin/pre-push.js +2 -2
- package/bin/prepare.cjs +8 -8
- package/bin/prepare.js +3 -3
- package/bin/version-warning.cjs +5 -5
- package/bin/version-warning.js +1 -1
- package/dist/{chunk-GTHIKJY7.cjs → chunk-VOWQJXPC.cjs} +215 -50
- package/dist/{chunk-VBTXRYZY.js → chunk-ZDXX5TWI.js} +211 -53
- package/dist/index.cjs +41 -9
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/release/config.cjs +41 -9
- package/dist/release/config.d.cts +100 -7
- package/dist/release/config.d.ts +100 -7
- package/dist/release/config.js +1 -1
- package/package.json +11 -8
- package/bin/chunk-BHWWH5OI.js.map +0 -1
- package/bin/chunk-FH5OSXAJ.cjs.map +0 -1
- package/bin/chunk-G3YPGVPS.js +0 -24
- package/bin/chunk-G3YPGVPS.js.map +0 -1
- package/bin/chunk-PTYTYIPG.cjs.map +0 -1
- package/bin/chunk-ROM64JTJ.cjs +0 -16
- package/bin/chunk-USGU6ZVC.cjs +0 -18
package/bin/git.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { postCheckoutHook } from './chunk-
|
|
3
|
-
import { postCommitHook } from './chunk-
|
|
4
|
-
import { postMergeHook } from './chunk-
|
|
5
|
-
import { preCommitHook } from './chunk-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import { prePushHook } from './chunk-
|
|
2
|
+
import { postCheckoutHook } from './chunk-IAZL2KCV.js';
|
|
3
|
+
import { postCommitHook } from './chunk-CVTLZKKX.js';
|
|
4
|
+
import { postMergeHook } from './chunk-CDUCLZJV.js';
|
|
5
|
+
import { preCommitHook } from './chunk-32WE3MHJ.js';
|
|
6
|
+
import './chunk-NOZEXVLA.js';
|
|
7
|
+
import { prePushHook } from './chunk-ABI4JM6L.js';
|
|
8
8
|
import './chunk-HBLWPOJV.js';
|
|
9
|
-
import { prepareHook } from './chunk-
|
|
10
|
-
import { run } from './chunk-
|
|
11
|
-
import { getConfig, handleProcess, writeSuccess, exitWithSuccess, exitWithError, writeInfo, brandIcon, findWorkspaceRootSafe, writeFatal, getWorkspaceConfig, joinPaths, writeDebug, isVerbose, writeWarning,
|
|
9
|
+
import { prepareHook } from './chunk-AZGQVIYO.js';
|
|
10
|
+
import { run, runAsync } from './chunk-RPK5AKGK.js';
|
|
11
|
+
import { defu, getConfig, handleProcess, writeSuccess, exitWithSuccess, exitWithError, writeInfo, brandIcon, findWorkspaceRootSafe, writeFatal, getWorkspaceConfig, joinPaths, writeDebug, isVerbose, writeWarning, writeTrace, __require, STORM_DEFAULT_RELEASE_BANNER } from './chunk-7ES3CGZQ.js';
|
|
12
12
|
import TOML from '@ltd/j-toml';
|
|
13
13
|
import { Command } from 'commander';
|
|
14
14
|
import '@inquirer/checkbox';
|
|
@@ -42,24 +42,36 @@ import anchor from 'anchor-markdown-header';
|
|
|
42
42
|
import { Parser } from 'htmlparser2';
|
|
43
43
|
import _ from 'underscore';
|
|
44
44
|
import updateSection from 'update-section';
|
|
45
|
-
import {
|
|
45
|
+
import { createProjectGraphAsync as createProjectGraphAsync$2, readProjectsConfigurationFromProjectGraph as readProjectsConfigurationFromProjectGraph$2, readCachedProjectGraph as readCachedProjectGraph$1, output, joinPathFragments } from '@nx/devkit';
|
|
46
46
|
import axios from 'axios';
|
|
47
47
|
import { homedir } from 'node:os';
|
|
48
48
|
import { defaultCreateReleaseProvider, GithubRemoteReleaseClient } from 'nx/src/command-line/release/utils/remote-release-clients/github';
|
|
49
49
|
import { parse } from 'yaml';
|
|
50
50
|
import chalk from 'chalk';
|
|
51
|
-
import { printAndFlushChanges } from 'nx/src/command-line/release/utils/print-changes';
|
|
51
|
+
import { printAndFlushChanges as printAndFlushChanges$1 } from 'nx/src/command-line/release/utils/print-changes';
|
|
52
52
|
import { createGitTagValues, handleDuplicateGitTags, createCommitMessageValues, isPrerelease, shouldPreferDockerVersionForReleaseGroup, ReleaseVersion, noDiffInChangelogMessage } from 'nx/src/command-line/release/utils/shared';
|
|
53
53
|
import { interpolate } from 'nx/src/tasks-runner/utils';
|
|
54
54
|
import { execCommand } from 'nx/src/command-line/release/utils/exec-command.js';
|
|
55
|
-
import { getCommitHash, getLatestGitTagForPattern, getFirstGitCommit, gitPush, getGitDiff, parseCommits
|
|
56
|
-
import { prerelease, major } from 'semver';
|
|
55
|
+
import { getCommitHash, getLatestGitTagForPattern, getFirstGitCommit, gitPush, gitAdd, getGitDiff, parseCommits } from 'nx/src/command-line/release/utils/git';
|
|
56
|
+
import semver, { prerelease, major } from 'semver';
|
|
57
|
+
import clone from 'nanoclone';
|
|
57
58
|
import { ReleaseClient } from 'nx/release';
|
|
59
|
+
import { readRawVersionPlans, setResolvedVersionPlansOnGroups } from 'nx/src/command-line/release/config/version-plans';
|
|
60
|
+
import { printAndFlushChanges } from 'nx/src/command-line/release/utils/print-changes.js';
|
|
61
|
+
import { createReleaseGraph } from 'nx/src/command-line/release/utils/release-graph';
|
|
62
|
+
import { validateResolvedVersionPlansAgainstFilter } from 'nx/src/command-line/release/utils/version-plan-utils';
|
|
58
63
|
import { readNxJson } from 'nx/src/config/nx-json';
|
|
59
64
|
import { FsTree } from 'nx/src/generators/tree';
|
|
60
65
|
import { createFileMapUsingProjectGraph } from 'nx/src/project-graph/file-map-utils';
|
|
66
|
+
import importsPlugin from 'prettier-plugin-organize-imports';
|
|
61
67
|
import DefaultChangelogRenderer from 'nx/release/changelog-renderer';
|
|
62
68
|
import { DEFAULT_CONVENTIONAL_COMMITS_CONFIG } from 'nx/src/command-line/release/config/conventional-commits';
|
|
69
|
+
import { findMatchingProjects } from 'nx/src/utils/find-matching-projects';
|
|
70
|
+
import { IMPLICIT_DEFAULT_RELEASE_GROUP } from 'nx/src/command-line/release/config/config.js';
|
|
71
|
+
import { deriveSpecifierFromConventionalCommits } from 'nx/src/command-line/release/version/derive-specifier-from-conventional-commits';
|
|
72
|
+
import { deriveSpecifierFromVersionPlan } from 'nx/src/command-line/release/version/deriver-specifier-from-version-plans';
|
|
73
|
+
import { ReleaseGroupProcessor } from 'nx/src/command-line/release/version/release-group-processor';
|
|
74
|
+
import { NOOP_VERSION_ACTIONS } from 'nx/src/command-line/release/version/version-actions.js';
|
|
63
75
|
|
|
64
76
|
function parseCargoToml(cargoString) {
|
|
65
77
|
if (!cargoString) {
|
|
@@ -1278,11 +1290,11 @@ var formatCommitMessage = (state, workspaceConfig) => {
|
|
|
1278
1290
|
const scope = workspaceConfig.variant !== "minimal" && typeof answers.scope === "string" && answers.scope ? answers.scope.trim() : "";
|
|
1279
1291
|
const subject = answers.subject?.trim();
|
|
1280
1292
|
const type = answers.type;
|
|
1281
|
-
const
|
|
1293
|
+
const format4 = config5.settings.format || (workspaceConfig.variant !== "minimal" ? "{type}({scope}): {emoji}{subject}" : "{type}: {emoji}{subject}");
|
|
1282
1294
|
const body = answers.body && typeof answers.body === "string" ? wrap(answers.body || "", wrapOptions) : "";
|
|
1283
1295
|
const breaking = answers.breakingBody && typeof answers.breakingBody === "string" ? wrap(answers.breakingBody || "", wrapOptions) : "";
|
|
1284
1296
|
const issues = answers.issuesBody && typeof answers.issuesBody === "string" ? wrap(answers.issuesBody || "", wrapOptions) : "";
|
|
1285
|
-
const head =
|
|
1297
|
+
const head = format4.replace(/\{emoji\}/g, config5.settings.disableEmoji ? "" : `${emoji} `).replace(/\{scope\}/g, scope).replace(/\{subject\}/g, subject || "").replace(/\{type\}/g, type || "");
|
|
1286
1298
|
let msg = head;
|
|
1287
1299
|
if (body) {
|
|
1288
1300
|
msg += `
|
|
@@ -1988,7 +2000,7 @@ var runReadme = async ({
|
|
|
1988
2000
|
project,
|
|
1989
2001
|
output: output3,
|
|
1990
2002
|
clean = true,
|
|
1991
|
-
prettier = true,
|
|
2003
|
+
prettier: prettier2 = true,
|
|
1992
2004
|
workspace = false
|
|
1993
2005
|
}) => {
|
|
1994
2006
|
const projectGraph = await createProjectGraphAsync({
|
|
@@ -2023,7 +2035,7 @@ var runReadme = async ({
|
|
|
2023
2035
|
templates,
|
|
2024
2036
|
output: output3,
|
|
2025
2037
|
clean,
|
|
2026
|
-
prettier
|
|
2038
|
+
prettier: prettier2
|
|
2027
2039
|
});
|
|
2028
2040
|
} else {
|
|
2029
2041
|
for (const projectName of Object.keys(projectConfigs.projects)) {
|
|
@@ -2031,12 +2043,12 @@ var runReadme = async ({
|
|
|
2031
2043
|
templates,
|
|
2032
2044
|
output: output3,
|
|
2033
2045
|
clean,
|
|
2034
|
-
prettier
|
|
2046
|
+
prettier: prettier2
|
|
2035
2047
|
});
|
|
2036
2048
|
}
|
|
2037
2049
|
}
|
|
2038
2050
|
};
|
|
2039
|
-
var runProjectReadme = async (projectName, { templates, output: output3, clean = true, prettier = true }) => {
|
|
2051
|
+
var runProjectReadme = async (projectName, { templates, output: output3, clean = true, prettier: prettier2 = true }) => {
|
|
2040
2052
|
const projectGraph = await createProjectGraphAsync({
|
|
2041
2053
|
exitOnError: true
|
|
2042
2054
|
});
|
|
@@ -2124,10 +2136,10 @@ var runProjectReadme = async (projectName, { templates, output: output3, clean =
|
|
|
2124
2136
|
}
|
|
2125
2137
|
}
|
|
2126
2138
|
}
|
|
2127
|
-
if (
|
|
2128
|
-
const
|
|
2139
|
+
if (prettier2) {
|
|
2140
|
+
const prettier3 = await import('prettier');
|
|
2129
2141
|
console.info("Formatting output with Prettier");
|
|
2130
|
-
newContent = await
|
|
2142
|
+
newContent = await prettier3.format(newContent, {
|
|
2131
2143
|
parser: "markdown",
|
|
2132
2144
|
trailingComma: "none",
|
|
2133
2145
|
tabWidth: 2,
|
|
@@ -2614,7 +2626,7 @@ async function generateChangelogForProjects({
|
|
|
2614
2626
|
workspaceConfig
|
|
2615
2627
|
);
|
|
2616
2628
|
tree.write(filePath, content);
|
|
2617
|
-
printAndFlushChanges(
|
|
2629
|
+
printAndFlushChanges$1(
|
|
2618
2630
|
tree,
|
|
2619
2631
|
!!args.dryRun,
|
|
2620
2632
|
3,
|
|
@@ -3003,6 +3015,54 @@ async function isUserAnOrganizationMember(userId, config5, remoteName = "origin"
|
|
|
3003
3015
|
return false;
|
|
3004
3016
|
}
|
|
3005
3017
|
}
|
|
3018
|
+
|
|
3019
|
+
// src/utilities/logs.ts
|
|
3020
|
+
function formatNxLog(message) {
|
|
3021
|
+
const { title, bodyLines } = message;
|
|
3022
|
+
return `${title}${bodyLines && bodyLines.length > 0 ? `
|
|
3023
|
+
${bodyLines.map((line) => ` ${line}`).join("\n")}` : ""}`;
|
|
3024
|
+
}
|
|
3025
|
+
async function format3(path, data) {
|
|
3026
|
+
let code = data;
|
|
3027
|
+
try {
|
|
3028
|
+
const resolvedConfig = await resolveConfig(path);
|
|
3029
|
+
if (resolvedConfig) {
|
|
3030
|
+
code = await format(
|
|
3031
|
+
data,
|
|
3032
|
+
defu(
|
|
3033
|
+
{
|
|
3034
|
+
absolutePath: path,
|
|
3035
|
+
...resolvedConfig
|
|
3036
|
+
},
|
|
3037
|
+
path.endsWith(".ts") || path.endsWith(".tsx") ? { plugins: [importsPlugin] } : {}
|
|
3038
|
+
)
|
|
3039
|
+
);
|
|
3040
|
+
}
|
|
3041
|
+
} catch (error) {
|
|
3042
|
+
throw new Error(
|
|
3043
|
+
`Failed to format file at ${path} with Prettier: ${error.message}`,
|
|
3044
|
+
{ cause: error }
|
|
3045
|
+
);
|
|
3046
|
+
}
|
|
3047
|
+
return code;
|
|
3048
|
+
}
|
|
3049
|
+
async function formatChangedFiles(tree) {
|
|
3050
|
+
if (process.env.NX_SKIP_FORMAT === "true") {
|
|
3051
|
+
return;
|
|
3052
|
+
}
|
|
3053
|
+
const files = new Set(
|
|
3054
|
+
tree.listChanges().filter((file) => file.type !== "DELETE")
|
|
3055
|
+
);
|
|
3056
|
+
const results = await Promise.all(
|
|
3057
|
+
Array.from(files).filter((file) => file.content && file.path).map(async (file) => [
|
|
3058
|
+
file.path,
|
|
3059
|
+
await format3(file.path, file.content?.toString("utf-8") ?? "")
|
|
3060
|
+
])
|
|
3061
|
+
);
|
|
3062
|
+
for (const [path, content] of results) {
|
|
3063
|
+
tree.write(path, content);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3006
3066
|
var StormChangelogRenderer = class extends DefaultChangelogRenderer {
|
|
3007
3067
|
/**
|
|
3008
3068
|
* The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
|
|
@@ -3206,38 +3266,112 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer {
|
|
|
3206
3266
|
}
|
|
3207
3267
|
};
|
|
3208
3268
|
|
|
3209
|
-
// src/
|
|
3269
|
+
// ../package-constants/src/tags.ts
|
|
3270
|
+
var ProjectTagConstants = {
|
|
3271
|
+
Language: {
|
|
3272
|
+
TAG_ID: "language",
|
|
3273
|
+
TYPESCRIPT: "typescript",
|
|
3274
|
+
RUST: "rust"
|
|
3275
|
+
}};
|
|
3276
|
+
var formatProjectTag = (variant, value) => {
|
|
3277
|
+
return `${variant}:${value}`;
|
|
3278
|
+
};
|
|
3279
|
+
var hasProjectTag = (project, variant) => {
|
|
3280
|
+
project.tags = project.tags ?? [];
|
|
3281
|
+
const prefix = formatProjectTag(variant, "");
|
|
3282
|
+
return project.tags.some(
|
|
3283
|
+
(tag) => tag.startsWith(prefix) && tag.length > prefix.length
|
|
3284
|
+
);
|
|
3285
|
+
};
|
|
3286
|
+
var getProjectTag = (project, variant) => {
|
|
3287
|
+
if (!hasProjectTag(project, variant)) {
|
|
3288
|
+
return void 0;
|
|
3289
|
+
}
|
|
3290
|
+
project.tags = project.tags ?? [];
|
|
3291
|
+
const prefix = formatProjectTag(variant, "");
|
|
3292
|
+
const tag = project.tags.find((tag2) => tag2.startsWith(prefix));
|
|
3293
|
+
return tag?.replace(prefix, "");
|
|
3294
|
+
};
|
|
3295
|
+
var isEqualProjectTag = (project, variant, value) => {
|
|
3296
|
+
const tag = getProjectTag(project, variant);
|
|
3297
|
+
return !!(tag && tag?.toUpperCase() === value.toUpperCase());
|
|
3298
|
+
};
|
|
3210
3299
|
var DEFAULT_CONVENTIONAL_COMMITS_CONFIG2 = {
|
|
3211
3300
|
useCommitScope: true,
|
|
3212
3301
|
questions: DEFAULT_MONOREPO_COMMIT_QUESTIONS,
|
|
3213
3302
|
types: DEFAULT_COMMIT_TYPES
|
|
3214
3303
|
};
|
|
3215
|
-
var
|
|
3304
|
+
var DEFAULT_INDEPENDENT_RELEASE_TAG_PATTERN = "{projectName}@{version}";
|
|
3305
|
+
var DEFAULT_FIXED_RELEASE_TAG_PATTERN = "{releaseGroupName}@{version}";
|
|
3306
|
+
var DEFAULT_COMMIT_MESSAGE = "release(monorepo): Publish v{version} release updates";
|
|
3307
|
+
var DEFAULT_RELEASE_GROUP_GIT_CONFIG = {
|
|
3308
|
+
commit: false,
|
|
3309
|
+
commitMessage: DEFAULT_COMMIT_MESSAGE,
|
|
3310
|
+
commitArgs: "",
|
|
3311
|
+
tag: false,
|
|
3312
|
+
tagMessage: "",
|
|
3313
|
+
tagArgs: "",
|
|
3314
|
+
stageChanges: false,
|
|
3315
|
+
pushArgs: ""
|
|
3316
|
+
};
|
|
3317
|
+
var DEFAULT_VERSION_RELEASE_CONFIG = {
|
|
3318
|
+
currentVersionResolver: "git-tag",
|
|
3319
|
+
fallbackCurrentVersionResolver: "disk",
|
|
3320
|
+
specifierSource: "conventional-commits",
|
|
3321
|
+
groupPreVersionCommand: "pnpm build",
|
|
3322
|
+
preserveLocalDependencyProtocols: true,
|
|
3323
|
+
preserveMatchingDependencyRanges: true,
|
|
3324
|
+
logUnchangedProjects: true,
|
|
3325
|
+
updateDependents: "always",
|
|
3326
|
+
git: {
|
|
3327
|
+
...DEFAULT_RELEASE_GROUP_GIT_CONFIG,
|
|
3328
|
+
stageChanges: true
|
|
3329
|
+
}
|
|
3330
|
+
};
|
|
3331
|
+
var DEFAULT_CHANGELOG_RELEASE_CONFIG = {
|
|
3332
|
+
createRelease: "github",
|
|
3333
|
+
entryWhenNoChanges: "This was a version bump only for {projectName} to align it with other projects, there were no code changes.",
|
|
3334
|
+
file: false,
|
|
3335
|
+
renderOptions: {
|
|
3336
|
+
authors: false,
|
|
3337
|
+
commitReferences: true,
|
|
3338
|
+
versionTitleDate: true
|
|
3339
|
+
},
|
|
3340
|
+
git: {
|
|
3341
|
+
...DEFAULT_RELEASE_GROUP_GIT_CONFIG,
|
|
3342
|
+
commit: true,
|
|
3343
|
+
tag: true,
|
|
3344
|
+
push: true
|
|
3345
|
+
}
|
|
3346
|
+
};
|
|
3216
3347
|
var DEFAULT_RELEASE_GROUP_CONFIG = {
|
|
3217
3348
|
projectsRelationship: "independent",
|
|
3218
3349
|
changelog: {
|
|
3219
|
-
|
|
3220
|
-
entryWhenNoChanges: false,
|
|
3221
|
-
file: false,
|
|
3222
|
-
renderOptions: {
|
|
3223
|
-
authors: false,
|
|
3224
|
-
commitReferences: true,
|
|
3225
|
-
versionTitleDate: true
|
|
3226
|
-
}
|
|
3350
|
+
...DEFAULT_CHANGELOG_RELEASE_CONFIG
|
|
3227
3351
|
},
|
|
3228
3352
|
version: {
|
|
3229
|
-
|
|
3230
|
-
fallbackCurrentVersionResolver: "disk",
|
|
3231
|
-
specifierSource: "conventional-commits",
|
|
3232
|
-
groupPreVersionCommand: "pnpm build"
|
|
3353
|
+
...DEFAULT_VERSION_RELEASE_CONFIG
|
|
3233
3354
|
},
|
|
3234
|
-
releaseTag: {
|
|
3355
|
+
releaseTag: {
|
|
3356
|
+
pattern: DEFAULT_INDEPENDENT_RELEASE_TAG_PATTERN,
|
|
3357
|
+
preferDockerVersion: false
|
|
3358
|
+
},
|
|
3359
|
+
versionPlans: false
|
|
3360
|
+
};
|
|
3361
|
+
var DEFAULT_INDEPENDENT_RELEASE_GROUP_CONFIG = {
|
|
3362
|
+
projectsRelationship: "independent",
|
|
3363
|
+
releaseTag: {
|
|
3364
|
+
pattern: DEFAULT_INDEPENDENT_RELEASE_TAG_PATTERN
|
|
3365
|
+
}
|
|
3366
|
+
};
|
|
3367
|
+
var DEFAULT_FIXED_RELEASE_GROUP_CONFIG = {
|
|
3368
|
+
projectsRelationship: "fixed",
|
|
3369
|
+
releaseTag: {
|
|
3370
|
+
pattern: DEFAULT_FIXED_RELEASE_TAG_PATTERN
|
|
3371
|
+
}
|
|
3235
3372
|
};
|
|
3236
3373
|
var DEFAULT_JS_RELEASE_GROUP_CONFIG = {
|
|
3237
|
-
...DEFAULT_RELEASE_GROUP_CONFIG,
|
|
3238
|
-
projects: ["packages/*"],
|
|
3239
3374
|
version: {
|
|
3240
|
-
...DEFAULT_RELEASE_GROUP_CONFIG.version,
|
|
3241
3375
|
versionActions: "@storm-software/workspace-tools/release/js-version-actions",
|
|
3242
3376
|
versionActionsOptions: {
|
|
3243
3377
|
currentVersionResolver: "git-tag",
|
|
@@ -3253,10 +3387,7 @@ var DEFAULT_JS_RELEASE_GROUP_CONFIG = {
|
|
|
3253
3387
|
}
|
|
3254
3388
|
};
|
|
3255
3389
|
var DEFAULT_RUST_RELEASE_GROUP_CONFIG = {
|
|
3256
|
-
...DEFAULT_RELEASE_GROUP_CONFIG,
|
|
3257
|
-
projects: ["crates/*"],
|
|
3258
3390
|
version: {
|
|
3259
|
-
...DEFAULT_RELEASE_GROUP_CONFIG.version,
|
|
3260
3391
|
versionActions: "@storm-software/workspace-tools/release/rust-version-actions",
|
|
3261
3392
|
versionActionsOptions: {
|
|
3262
3393
|
currentVersionResolver: "git-tag",
|
|
@@ -3268,40 +3399,123 @@ var DEFAULT_RUST_RELEASE_GROUP_CONFIG = {
|
|
|
3268
3399
|
var DEFAULT_RELEASE_CONFIG = {
|
|
3269
3400
|
conventionalCommits: DEFAULT_CONVENTIONAL_COMMITS_CONFIG2,
|
|
3270
3401
|
groups: {
|
|
3271
|
-
packages:
|
|
3272
|
-
|
|
3402
|
+
packages: defu(
|
|
3403
|
+
{
|
|
3404
|
+
projects: ["packages/*"]
|
|
3405
|
+
},
|
|
3406
|
+
DEFAULT_JS_RELEASE_GROUP_CONFIG,
|
|
3407
|
+
DEFAULT_RELEASE_GROUP_CONFIG
|
|
3408
|
+
),
|
|
3409
|
+
crates: defu(
|
|
3410
|
+
{
|
|
3411
|
+
projects: ["crates/*"]
|
|
3412
|
+
},
|
|
3413
|
+
DEFAULT_RUST_RELEASE_GROUP_CONFIG,
|
|
3414
|
+
DEFAULT_RELEASE_GROUP_CONFIG
|
|
3415
|
+
)
|
|
3273
3416
|
},
|
|
3274
3417
|
changelog: {
|
|
3418
|
+
...DEFAULT_CHANGELOG_RELEASE_CONFIG,
|
|
3275
3419
|
automaticFromRef: true,
|
|
3276
3420
|
workspaceChangelog: false,
|
|
3277
3421
|
projectChangelogs: true
|
|
3278
3422
|
},
|
|
3279
|
-
releaseTag: {
|
|
3423
|
+
releaseTag: {
|
|
3424
|
+
pattern: DEFAULT_INDEPENDENT_RELEASE_TAG_PATTERN,
|
|
3425
|
+
preferDockerVersion: false
|
|
3426
|
+
},
|
|
3427
|
+
version: {
|
|
3428
|
+
...DEFAULT_VERSION_RELEASE_CONFIG
|
|
3429
|
+
}
|
|
3280
3430
|
};
|
|
3281
|
-
function
|
|
3431
|
+
function mergeReleaseGroupConfig(config5, defaultConfig, workspaceConfig) {
|
|
3432
|
+
return defu(
|
|
3433
|
+
{
|
|
3434
|
+
...omit(defaultConfig, ["changelog", "version"]),
|
|
3435
|
+
...config5
|
|
3436
|
+
},
|
|
3437
|
+
{
|
|
3438
|
+
version: {
|
|
3439
|
+
...defaultConfig.version
|
|
3440
|
+
}
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
changelog: {
|
|
3444
|
+
...typeof defaultConfig.changelog === "object" ? defaultConfig.changelog : {},
|
|
3445
|
+
renderer: StormChangelogRenderer,
|
|
3446
|
+
renderOptions: {
|
|
3447
|
+
...typeof defaultConfig.changelog === "object" && defaultConfig.changelog.renderOptions || {},
|
|
3448
|
+
workspaceConfig
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
}
|
|
3452
|
+
);
|
|
3453
|
+
}
|
|
3454
|
+
function getReleaseGroupConfig(projectGraph, releaseConfig, workspaceConfig) {
|
|
3455
|
+
const alreadyMatchedProjects = /* @__PURE__ */ new Set();
|
|
3282
3456
|
return !releaseConfig?.groups || Object.keys(releaseConfig.groups).length === 0 ? {} : Object.fromEntries(
|
|
3283
3457
|
Object.entries(releaseConfig.groups).map(([name, group]) => {
|
|
3284
|
-
const
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
{
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
renderOptions: {
|
|
3299
|
-
...DEFAULT_RELEASE_GROUP_CONFIG.changelog.renderOptions,
|
|
3300
|
-
workspaceConfig
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3458
|
+
const matchingProjects = findMatchingProjects(
|
|
3459
|
+
typeof group.projects === "string" ? [group.projects] : group.projects,
|
|
3460
|
+
projectGraph.nodes
|
|
3461
|
+
);
|
|
3462
|
+
if (!matchingProjects.length) {
|
|
3463
|
+
throw new Error(
|
|
3464
|
+
`Release group "${name}" does not have any matching projects.`
|
|
3465
|
+
);
|
|
3466
|
+
}
|
|
3467
|
+
for (const project of matchingProjects) {
|
|
3468
|
+
if (alreadyMatchedProjects.has(project)) {
|
|
3469
|
+
throw new Error(
|
|
3470
|
+
`Project "${project}" is included in more than one release group. Please ensure that each project is only included in one release group, or remove the "projects" property from the release group configuration to allow it to be included in the same release group as other projects with overlapping globs.`
|
|
3471
|
+
);
|
|
3303
3472
|
}
|
|
3473
|
+
alreadyMatchedProjects.add(project);
|
|
3474
|
+
}
|
|
3475
|
+
let languageDefaultConfig = {};
|
|
3476
|
+
if (matchingProjects.every(
|
|
3477
|
+
(project) => projectGraph.nodes[project]?.data && (projectGraph.nodes[project]?.data.metadata?.js || isEqualProjectTag(
|
|
3478
|
+
projectGraph.nodes[project]?.data,
|
|
3479
|
+
ProjectTagConstants.Language.TAG_ID,
|
|
3480
|
+
ProjectTagConstants.Language.TYPESCRIPT
|
|
3481
|
+
) || projectGraph.nodes[project]?.data.metadata?.root && existsSync$1(
|
|
3482
|
+
joinPaths(
|
|
3483
|
+
projectGraph.nodes[project]?.data.metadata?.root,
|
|
3484
|
+
"package.json"
|
|
3485
|
+
)
|
|
3486
|
+
))
|
|
3487
|
+
)) {
|
|
3488
|
+
languageDefaultConfig = defu(
|
|
3489
|
+
DEFAULT_JS_RELEASE_GROUP_CONFIG,
|
|
3490
|
+
DEFAULT_RELEASE_GROUP_CONFIG
|
|
3491
|
+
);
|
|
3492
|
+
} else if (matchingProjects.every(
|
|
3493
|
+
(project) => projectGraph.nodes[project]?.data && (projectGraph.nodes[project]?.data.metadata?.rust || projectGraph.nodes[project]?.data.metadata?.cargo || isEqualProjectTag(
|
|
3494
|
+
projectGraph.nodes[project]?.data,
|
|
3495
|
+
ProjectTagConstants.Language.TAG_ID,
|
|
3496
|
+
ProjectTagConstants.Language.RUST
|
|
3497
|
+
) || projectGraph.nodes[project]?.data.metadata?.root && existsSync$1(
|
|
3498
|
+
joinPaths(
|
|
3499
|
+
projectGraph.nodes[project]?.data.metadata?.root,
|
|
3500
|
+
"Cargo.toml"
|
|
3501
|
+
)
|
|
3502
|
+
))
|
|
3503
|
+
)) {
|
|
3504
|
+
languageDefaultConfig = defu(
|
|
3505
|
+
DEFAULT_RUST_RELEASE_GROUP_CONFIG,
|
|
3506
|
+
DEFAULT_RELEASE_GROUP_CONFIG
|
|
3507
|
+
);
|
|
3508
|
+
}
|
|
3509
|
+
const config5 = mergeReleaseGroupConfig(
|
|
3510
|
+
group,
|
|
3511
|
+
defu(
|
|
3512
|
+
languageDefaultConfig,
|
|
3513
|
+
group.projectsRelationship === "fixed" ? DEFAULT_FIXED_RELEASE_GROUP_CONFIG : DEFAULT_INDEPENDENT_RELEASE_GROUP_CONFIG,
|
|
3514
|
+
DEFAULT_RELEASE_GROUP_CONFIG
|
|
3515
|
+
),
|
|
3516
|
+
workspaceConfig
|
|
3304
3517
|
);
|
|
3518
|
+
config5.projects = matchingProjects;
|
|
3305
3519
|
if (workspaceConfig?.workspaceRoot) {
|
|
3306
3520
|
if (config5.changelog?.renderer && typeof config5.changelog?.renderer === "string" && config5.changelog?.renderer?.toString().startsWith("./")) {
|
|
3307
3521
|
config5.changelog.renderer = joinPaths(
|
|
@@ -3320,6 +3534,658 @@ function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
|
|
|
3320
3534
|
})
|
|
3321
3535
|
);
|
|
3322
3536
|
}
|
|
3537
|
+
var StormReleaseGroupProcessor = class extends ReleaseGroupProcessor {
|
|
3538
|
+
constructor(tree, workspaceConfig, projectGraph, nxReleaseConfig, releaseGraph, versionOptions) {
|
|
3539
|
+
super(tree, projectGraph, nxReleaseConfig, releaseGraph, {
|
|
3540
|
+
dryRun: !!versionOptions.dryRun,
|
|
3541
|
+
verbose: versionOptions.verbose || isVerbose(workspaceConfig.logLevel),
|
|
3542
|
+
firstRelease: !!versionOptions.firstRelease,
|
|
3543
|
+
preid: versionOptions.preid ?? workspaceConfig.preid ?? "",
|
|
3544
|
+
userGivenSpecifier: versionOptions.specifier,
|
|
3545
|
+
filters: {
|
|
3546
|
+
projects: versionOptions.projects,
|
|
3547
|
+
groups: versionOptions.groups
|
|
3548
|
+
},
|
|
3549
|
+
versionActionsOptionsOverrides: versionOptions.versionActionsOptionsOverrides
|
|
3550
|
+
});
|
|
3551
|
+
this.workspaceConfig = workspaceConfig;
|
|
3552
|
+
this.versionOptions = versionOptions;
|
|
3553
|
+
this.#tree = tree;
|
|
3554
|
+
this.#projectGraph = projectGraph;
|
|
3555
|
+
this.#nxReleaseConfig = nxReleaseConfig;
|
|
3556
|
+
this.#releaseGraph = releaseGraph;
|
|
3557
|
+
}
|
|
3558
|
+
#tree;
|
|
3559
|
+
#projectGraph;
|
|
3560
|
+
#nxReleaseConfig;
|
|
3561
|
+
#releaseGraph;
|
|
3562
|
+
/**
|
|
3563
|
+
* Track any version plan files that have been processed so that we can delete them after versioning is complete,
|
|
3564
|
+
* while leaving any unprocessed files in place.
|
|
3565
|
+
*/
|
|
3566
|
+
#processedVersionPlanFiles = /* @__PURE__ */ new Set();
|
|
3567
|
+
/**
|
|
3568
|
+
* Tracks which release groups have already been processed to avoid
|
|
3569
|
+
* processing them multiple times. Used during the group traversal.
|
|
3570
|
+
*/
|
|
3571
|
+
#processedGroups = /* @__PURE__ */ new Set();
|
|
3572
|
+
/**
|
|
3573
|
+
* Keeps track of which projects have already had their versions bumped.
|
|
3574
|
+
* This is used to avoid redundant version bumping and to determine which
|
|
3575
|
+
* projects need their dependencies updated.
|
|
3576
|
+
*/
|
|
3577
|
+
#bumpedProjects = /* @__PURE__ */ new Set();
|
|
3578
|
+
/**
|
|
3579
|
+
* versionData that will ultimately be returned to the nx release version handler by getVersionData()
|
|
3580
|
+
*/
|
|
3581
|
+
#versionData = /* @__PURE__ */ new Map();
|
|
3582
|
+
getReleaseGroupNameForProject(projectName) {
|
|
3583
|
+
const group = this.#releaseGraph.projectToReleaseGroup.get(projectName);
|
|
3584
|
+
return group ? group.name : null;
|
|
3585
|
+
}
|
|
3586
|
+
getNextGroup() {
|
|
3587
|
+
for (const [groupName, groupNode] of this.#releaseGraph.groupGraph) {
|
|
3588
|
+
if (!this.#processedGroups.has(groupName) && Array.from(groupNode.dependencies).every(
|
|
3589
|
+
(dep) => this.#processedGroups.has(dep)
|
|
3590
|
+
)) {
|
|
3591
|
+
return groupName;
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
return null;
|
|
3595
|
+
}
|
|
3596
|
+
flushAllProjectLoggers() {
|
|
3597
|
+
for (const projectLogger of this.#releaseGraph.projectLoggers.values()) {
|
|
3598
|
+
projectLogger.flush();
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
deleteProcessedVersionPlanFiles() {
|
|
3602
|
+
for (const versionPlanPath of this.#processedVersionPlanFiles) {
|
|
3603
|
+
this.#tree.delete(versionPlanPath);
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
getVersionData() {
|
|
3607
|
+
return Object.fromEntries(this.#versionData);
|
|
3608
|
+
}
|
|
3609
|
+
/**
|
|
3610
|
+
* Invoke the afterAllProjectsVersioned functions for each unique versionActions type.
|
|
3611
|
+
* This can be useful for performing actions like updating a workspace level lock file.
|
|
3612
|
+
*
|
|
3613
|
+
* Because the tree has already been flushed to disk at this point, each afterAllProjectsVersioned
|
|
3614
|
+
* function is responsible for returning the list of changed and deleted files that it affected.
|
|
3615
|
+
*
|
|
3616
|
+
* The root level `release.version.versionActionsOptions` is what is passed in here because this
|
|
3617
|
+
* is a one time action for the whole workspace. Release group and project level overrides are
|
|
3618
|
+
* not applicable.
|
|
3619
|
+
*/
|
|
3620
|
+
async afterAllProjectsVersioned(rootVersionActionsOptions) {
|
|
3621
|
+
const changedFiles = /* @__PURE__ */ new Set();
|
|
3622
|
+
const deletedFiles = /* @__PURE__ */ new Set();
|
|
3623
|
+
for (const [, afterAllProjectsVersioned] of this.#releaseGraph.uniqueAfterAllProjectsVersioned) {
|
|
3624
|
+
const {
|
|
3625
|
+
changedFiles: changedFilesForVersionActions,
|
|
3626
|
+
deletedFiles: deletedFilesForVersionActions
|
|
3627
|
+
} = await afterAllProjectsVersioned(this.#tree.root, {
|
|
3628
|
+
dryRun: this.versionOptions.dryRun,
|
|
3629
|
+
verbose: this.versionOptions.verbose || isVerbose(this.workspaceConfig.logLevel),
|
|
3630
|
+
rootVersionActionsOptions
|
|
3631
|
+
});
|
|
3632
|
+
for (const file of changedFilesForVersionActions) {
|
|
3633
|
+
changedFiles.add(file);
|
|
3634
|
+
}
|
|
3635
|
+
for (const file of deletedFilesForVersionActions) {
|
|
3636
|
+
deletedFiles.add(file);
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
return {
|
|
3640
|
+
changedFiles: Array.from(changedFiles),
|
|
3641
|
+
deletedFiles: Array.from(deletedFiles)
|
|
3642
|
+
};
|
|
3643
|
+
}
|
|
3644
|
+
async processDockerProjects(dockerVersionScheme, dockerVersion) {
|
|
3645
|
+
const dockerProjects = /* @__PURE__ */ new Map();
|
|
3646
|
+
for (const project of this.#versionData.keys()) {
|
|
3647
|
+
const hasDockerTechnology = Object.values(
|
|
3648
|
+
this.#projectGraph.nodes[project]?.data?.targets ?? []
|
|
3649
|
+
).some(({ metadata }) => metadata?.technologies?.includes("docker"));
|
|
3650
|
+
if (!hasDockerTechnology) {
|
|
3651
|
+
continue;
|
|
3652
|
+
}
|
|
3653
|
+
const finalConfigForProject = this.#releaseGraph.finalConfigsByProject.get(project);
|
|
3654
|
+
dockerProjects.set(project, finalConfigForProject);
|
|
3655
|
+
}
|
|
3656
|
+
if (dockerProjects.size === 0) {
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
let handleDockerVersion;
|
|
3660
|
+
try {
|
|
3661
|
+
const dockerVersionUtilsPath = "@nx/docker/release/version-utils";
|
|
3662
|
+
const { handleDockerVersion: _handleDockerVersion } = __require(dockerVersionUtilsPath);
|
|
3663
|
+
handleDockerVersion = _handleDockerVersion;
|
|
3664
|
+
} catch (e) {
|
|
3665
|
+
console.error(
|
|
3666
|
+
"Could not find `@nx/docker`. Please run `nx add @nx/docker` before attempting to release Docker images."
|
|
3667
|
+
);
|
|
3668
|
+
throw e;
|
|
3669
|
+
}
|
|
3670
|
+
for (const [project, finalConfigForProject] of dockerProjects.entries()) {
|
|
3671
|
+
const projectNode = this.#projectGraph.nodes[project];
|
|
3672
|
+
const projectVersionData = this.#versionData.get(project);
|
|
3673
|
+
const { newVersion, logs } = await handleDockerVersion(
|
|
3674
|
+
this.workspaceConfig.workspaceRoot,
|
|
3675
|
+
projectNode,
|
|
3676
|
+
finalConfigForProject,
|
|
3677
|
+
dockerVersionScheme,
|
|
3678
|
+
dockerVersion,
|
|
3679
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
3680
|
+
projectVersionData?.newVersion
|
|
3681
|
+
);
|
|
3682
|
+
logs.forEach(
|
|
3683
|
+
(log) => this.#getProjectLoggerForProject(project).buffer(log)
|
|
3684
|
+
);
|
|
3685
|
+
const newVersionData = {
|
|
3686
|
+
...projectVersionData,
|
|
3687
|
+
dockerVersion: newVersion
|
|
3688
|
+
};
|
|
3689
|
+
this.#versionData.set(project, newVersionData);
|
|
3690
|
+
}
|
|
3691
|
+
this.flushAllProjectLoggers();
|
|
3692
|
+
}
|
|
3693
|
+
async processGroups() {
|
|
3694
|
+
const processOrder = [];
|
|
3695
|
+
for (const nextGroup of this.#releaseGraph.sortedReleaseGroups) {
|
|
3696
|
+
if (this.#processedGroups.has(nextGroup)) {
|
|
3697
|
+
continue;
|
|
3698
|
+
}
|
|
3699
|
+
if (!this.#releaseGraph.groupGraph.has(nextGroup)) {
|
|
3700
|
+
continue;
|
|
3701
|
+
}
|
|
3702
|
+
const allDependenciesProcessed = Array.from(
|
|
3703
|
+
this.#releaseGraph.groupGraph.get(nextGroup).dependencies
|
|
3704
|
+
).every((dep) => this.#processedGroups.has(dep));
|
|
3705
|
+
if (!allDependenciesProcessed) {
|
|
3706
|
+
for (const dep of this.#releaseGraph.groupGraph.get(nextGroup).dependencies) {
|
|
3707
|
+
if (!this.#processedGroups.has(dep)) {
|
|
3708
|
+
if (!this.#releaseGraph.groupGraph.has(dep)) {
|
|
3709
|
+
continue;
|
|
3710
|
+
}
|
|
3711
|
+
await this.#processGroup(dep);
|
|
3712
|
+
this.#processedGroups.add(dep);
|
|
3713
|
+
processOrder.push(dep);
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
3717
|
+
await this.#processGroup(nextGroup);
|
|
3718
|
+
this.#processedGroups.add(nextGroup);
|
|
3719
|
+
processOrder.push(nextGroup);
|
|
3720
|
+
}
|
|
3721
|
+
return processOrder;
|
|
3722
|
+
}
|
|
3723
|
+
async #bumpVersions(releaseGroup) {
|
|
3724
|
+
if (releaseGroup.projectsRelationship === "fixed") {
|
|
3725
|
+
return this.#bumpFixedVersionGroup(releaseGroup);
|
|
3726
|
+
} else {
|
|
3727
|
+
return this.#bumpIndependentVersionGroup(releaseGroup);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
async #processGroup(releaseGroupName) {
|
|
3731
|
+
const groupNode = this.#releaseGraph.groupGraph.get(releaseGroupName);
|
|
3732
|
+
await this.#bumpVersions(groupNode.group);
|
|
3733
|
+
for (const project of groupNode.group.projects) {
|
|
3734
|
+
const projectLogger = this.#releaseGraph.projectLoggers.get(project);
|
|
3735
|
+
if (!projectLogger) {
|
|
3736
|
+
throw new Error(
|
|
3737
|
+
`No project logger found for project ${project} in release group ${releaseGroupName}. This should never happen.`
|
|
3738
|
+
);
|
|
3739
|
+
}
|
|
3740
|
+
projectLogger.flush();
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
async #bumpFixedVersionGroup(releaseGroup) {
|
|
3744
|
+
if (releaseGroup.projects.length === 0) {
|
|
3745
|
+
return false;
|
|
3746
|
+
}
|
|
3747
|
+
let bumped = false;
|
|
3748
|
+
const firstProject = releaseGroup.projects.reduce((acc, project) => {
|
|
3749
|
+
const currentVersion = this.#getCurrentCachedVersionForProject(project);
|
|
3750
|
+
if (currentVersion && semver.gt(currentVersion, acc)) {
|
|
3751
|
+
return currentVersion;
|
|
3752
|
+
}
|
|
3753
|
+
return acc;
|
|
3754
|
+
}, "");
|
|
3755
|
+
const {
|
|
3756
|
+
newVersionInput,
|
|
3757
|
+
newVersionInputReason,
|
|
3758
|
+
newVersionInputReasonData
|
|
3759
|
+
} = await this.#determineVersionBumpForProject(releaseGroup, firstProject);
|
|
3760
|
+
if (newVersionInput === "none") {
|
|
3761
|
+
let bumpedByDependency = false;
|
|
3762
|
+
const sortedProjects2 = this.#releaseGraph.sortedProjects.get(releaseGroup.name) || [];
|
|
3763
|
+
for (const project of sortedProjects2) {
|
|
3764
|
+
const dependencies = this.#projectGraph.dependencies[project] || [];
|
|
3765
|
+
for (const dep of dependencies) {
|
|
3766
|
+
const depGroup = this.getReleaseGroupNameForProject(dep.target);
|
|
3767
|
+
if (depGroup && depGroup !== releaseGroup.name && this.#processedGroups.has(depGroup)) {
|
|
3768
|
+
const depGroupBumpType = await this.#getFixedReleaseGroupBumpType(depGroup);
|
|
3769
|
+
if (depGroupBumpType !== "none") {
|
|
3770
|
+
bumpedByDependency = true;
|
|
3771
|
+
const depBumpType = this.#determineSideEffectBump(
|
|
3772
|
+
releaseGroup,
|
|
3773
|
+
depGroupBumpType
|
|
3774
|
+
);
|
|
3775
|
+
await this.#bumpVersionForProject(
|
|
3776
|
+
project,
|
|
3777
|
+
depBumpType,
|
|
3778
|
+
"DEPENDENCY_ACROSS_GROUPS_WAS_BUMPED",
|
|
3779
|
+
{}
|
|
3780
|
+
);
|
|
3781
|
+
this.#bumpedProjects.add(project);
|
|
3782
|
+
await this.#updateDependenciesForProject(project);
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
}
|
|
3787
|
+
if (bumpedByDependency) {
|
|
3788
|
+
for (const project of sortedProjects2) {
|
|
3789
|
+
if (!this.#bumpedProjects.has(project)) {
|
|
3790
|
+
await this.#bumpVersionForProject(
|
|
3791
|
+
project,
|
|
3792
|
+
this.#applyPreidToBumpType("patch", project),
|
|
3793
|
+
"OTHER_PROJECT_IN_FIXED_GROUP_WAS_BUMPED_DUE_TO_DEPENDENCY",
|
|
3794
|
+
{}
|
|
3795
|
+
);
|
|
3796
|
+
this.#bumpedProjects.add(project);
|
|
3797
|
+
await this.#updateDependenciesForProject(project);
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
} else {
|
|
3801
|
+
for (const project of releaseGroup.projects) {
|
|
3802
|
+
this.#versionData.set(project, {
|
|
3803
|
+
currentVersion: this.#getCurrentCachedVersionForProject(
|
|
3804
|
+
project
|
|
3805
|
+
),
|
|
3806
|
+
newVersion: null,
|
|
3807
|
+
dockerVersion: null,
|
|
3808
|
+
dependentProjects: this.#getOriginalDependentProjects(project)
|
|
3809
|
+
});
|
|
3810
|
+
if (project === firstProject) {
|
|
3811
|
+
continue;
|
|
3812
|
+
}
|
|
3813
|
+
const projectLogger = this.#getProjectLoggerForProject(project);
|
|
3814
|
+
projectLogger.buffer(
|
|
3815
|
+
`\u{1F6AB} Skipping versioning for ${project} as it is a part of a fixed release group with ${firstProject} and no dependency bumps were detected`
|
|
3816
|
+
);
|
|
3817
|
+
}
|
|
3818
|
+
}
|
|
3819
|
+
return bumpedByDependency;
|
|
3820
|
+
}
|
|
3821
|
+
const { newVersion } = await this.#calculateNewVersion(
|
|
3822
|
+
firstProject,
|
|
3823
|
+
newVersionInput,
|
|
3824
|
+
newVersionInputReason,
|
|
3825
|
+
newVersionInputReasonData
|
|
3826
|
+
);
|
|
3827
|
+
const sortedProjects = this.#releaseGraph.sortedProjects.get(releaseGroup.name) || releaseGroup.projects;
|
|
3828
|
+
for (const project of sortedProjects) {
|
|
3829
|
+
const versionActions = this.#getVersionActionsForProject(project);
|
|
3830
|
+
const projectLogger = this.#getProjectLoggerForProject(project);
|
|
3831
|
+
const currentVersion = this.#getCurrentCachedVersionForProject(
|
|
3832
|
+
project
|
|
3833
|
+
);
|
|
3834
|
+
if (project !== firstProject) {
|
|
3835
|
+
projectLogger.buffer(
|
|
3836
|
+
`\u2753 Applied version ${newVersion} directly, because the project is a member of a fixed release group containing ${firstProject}`
|
|
3837
|
+
);
|
|
3838
|
+
}
|
|
3839
|
+
const logMessages = await versionActions.updateProjectVersion(
|
|
3840
|
+
this.#tree,
|
|
3841
|
+
newVersion
|
|
3842
|
+
);
|
|
3843
|
+
for (const logMessage of logMessages) {
|
|
3844
|
+
projectLogger.buffer(logMessage);
|
|
3845
|
+
}
|
|
3846
|
+
this.#bumpedProjects.add(project);
|
|
3847
|
+
bumped = true;
|
|
3848
|
+
this.#versionData.set(project, {
|
|
3849
|
+
currentVersion,
|
|
3850
|
+
newVersion,
|
|
3851
|
+
dependentProjects: this.#getOriginalDependentProjects(project)
|
|
3852
|
+
});
|
|
3853
|
+
}
|
|
3854
|
+
if (bumped) {
|
|
3855
|
+
for (const project of sortedProjects) {
|
|
3856
|
+
await this.#updateDependenciesForProject(project);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
return bumped;
|
|
3860
|
+
}
|
|
3861
|
+
#getOriginalDependentProjects(project) {
|
|
3862
|
+
return this.#releaseGraph.originalDependentProjectsPerProject.get(project) || [];
|
|
3863
|
+
}
|
|
3864
|
+
async #updateDependenciesForProject(projectName) {
|
|
3865
|
+
if (!this.#releaseGraph.allProjectsToProcess.has(projectName)) {
|
|
3866
|
+
throw new Error(
|
|
3867
|
+
`Unable to find ${projectName} in allProjectsToProcess, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
3868
|
+
);
|
|
3869
|
+
}
|
|
3870
|
+
const versionActions = this.#getVersionActionsForProject(projectName);
|
|
3871
|
+
const cachedFinalConfigForProject = this.#getCachedFinalConfigForProject(projectName);
|
|
3872
|
+
const dependenciesToUpdate = {};
|
|
3873
|
+
const dependencies = this.#projectGraph.dependencies[projectName] || [];
|
|
3874
|
+
for (const dep of dependencies) {
|
|
3875
|
+
if (this.#releaseGraph.allProjectsToProcess.has(dep.target)) {
|
|
3876
|
+
const targetVersionData = this.#versionData.get(dep.target);
|
|
3877
|
+
if (targetVersionData) {
|
|
3878
|
+
const { currentVersion: currentDependencyVersion } = await versionActions.readCurrentVersionOfDependency(
|
|
3879
|
+
this.#tree,
|
|
3880
|
+
this.#projectGraph,
|
|
3881
|
+
dep.target
|
|
3882
|
+
);
|
|
3883
|
+
if (!currentDependencyVersion) {
|
|
3884
|
+
continue;
|
|
3885
|
+
}
|
|
3886
|
+
let finalPrefix = "";
|
|
3887
|
+
if (cachedFinalConfigForProject.versionPrefix === "auto") {
|
|
3888
|
+
const prefixMatch = currentDependencyVersion?.match(/^([~^=])/);
|
|
3889
|
+
finalPrefix = prefixMatch ? prefixMatch[1] : "";
|
|
3890
|
+
} else if (cachedFinalConfigForProject.versionPrefix && ["~", "^", "="].includes(cachedFinalConfigForProject.versionPrefix)) {
|
|
3891
|
+
finalPrefix = cachedFinalConfigForProject.versionPrefix;
|
|
3892
|
+
}
|
|
3893
|
+
const newVersion = targetVersionData.newVersion ?? this.#releaseGraph.cachedCurrentVersions.get(dep.target) ?? currentDependencyVersion;
|
|
3894
|
+
const cleanNewVersion = newVersion.replace(/^[~^=]/, "");
|
|
3895
|
+
dependenciesToUpdate[dep.target] = `${finalPrefix}${cleanNewVersion}`;
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
}
|
|
3899
|
+
const projectLogger = this.#getProjectLoggerForProject(projectName);
|
|
3900
|
+
const logMessages = await versionActions.updateProjectDependencies(
|
|
3901
|
+
this.#tree,
|
|
3902
|
+
this.#projectGraph,
|
|
3903
|
+
dependenciesToUpdate
|
|
3904
|
+
);
|
|
3905
|
+
for (const logMessage of logMessages) {
|
|
3906
|
+
projectLogger.buffer(logMessage);
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
#getVersionActionsForProject(projectName) {
|
|
3910
|
+
const versionActions = this.#releaseGraph.projectsToVersionActions.get(projectName);
|
|
3911
|
+
if (!versionActions) {
|
|
3912
|
+
throw new Error(
|
|
3913
|
+
`No versionActions found for project ${projectName}, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
3914
|
+
);
|
|
3915
|
+
}
|
|
3916
|
+
return versionActions;
|
|
3917
|
+
}
|
|
3918
|
+
async #getFixedReleaseGroupBumpType(releaseGroupName) {
|
|
3919
|
+
const releaseGroup = this.#releaseGraph.groupGraph.get(releaseGroupName).group;
|
|
3920
|
+
const releaseGroupFilteredProjects = this.#releaseGraph.releaseGroupToFilteredProjects.get(releaseGroup);
|
|
3921
|
+
if (!releaseGroupFilteredProjects || releaseGroupFilteredProjects.size === 0) {
|
|
3922
|
+
return "none";
|
|
3923
|
+
}
|
|
3924
|
+
const anyProject = releaseGroupFilteredProjects.values().next().value;
|
|
3925
|
+
const { currentVersion, newVersion } = this.#versionData.get(anyProject);
|
|
3926
|
+
if (newVersion) {
|
|
3927
|
+
return semver.diff(currentVersion, newVersion);
|
|
3928
|
+
}
|
|
3929
|
+
return (await this.#determineVersionBumpForProject(releaseGroup, anyProject)).newVersionInput;
|
|
3930
|
+
}
|
|
3931
|
+
// TODO: Support influencing the side effect bump in a future version, always patch for now like in legacy versioning
|
|
3932
|
+
#determineSideEffectBump(releaseGroup, dependencyBumpType) {
|
|
3933
|
+
const anyProject = releaseGroup.projects[0];
|
|
3934
|
+
return this.#applyPreidToBumpType("patch", anyProject);
|
|
3935
|
+
}
|
|
3936
|
+
/**
|
|
3937
|
+
* When a preid is set (e.g. --preid rc) and the project has opted in via
|
|
3938
|
+
* `applyPreidToDependents`, convert a "patch" side-effect bump into a
|
|
3939
|
+
* "prepatch" so that semver.inc() actually applies the preid.
|
|
3940
|
+
* semver.inc('1.0.0', 'patch', 'rc') ignores preid and returns '1.0.1'.
|
|
3941
|
+
* semver.inc('1.0.0', 'prepatch', 'rc') returns '1.0.1-rc.0' as expected.
|
|
3942
|
+
*/
|
|
3943
|
+
#applyPreidToBumpType(bumpType, projectName) {
|
|
3944
|
+
if (!(this.versionOptions.preid && this.workspaceConfig.preid) || bumpType === "none" || bumpType.startsWith("pre")) {
|
|
3945
|
+
return bumpType;
|
|
3946
|
+
}
|
|
3947
|
+
const finalConfig = this.#getCachedFinalConfigForProject(projectName);
|
|
3948
|
+
if (!finalConfig.applyPreidToDependents) {
|
|
3949
|
+
return bumpType;
|
|
3950
|
+
}
|
|
3951
|
+
switch (bumpType) {
|
|
3952
|
+
case "major":
|
|
3953
|
+
return "premajor";
|
|
3954
|
+
case "minor":
|
|
3955
|
+
return "preminor";
|
|
3956
|
+
case "patch":
|
|
3957
|
+
return "prepatch";
|
|
3958
|
+
default:
|
|
3959
|
+
return bumpType;
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
#getCachedFinalConfigForProject(projectName) {
|
|
3963
|
+
const cachedFinalConfig = this.#releaseGraph.finalConfigsByProject.get(projectName);
|
|
3964
|
+
if (!cachedFinalConfig) {
|
|
3965
|
+
throw new Error(
|
|
3966
|
+
`Unexpected error: No cached config found for project ${projectName}, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
3967
|
+
);
|
|
3968
|
+
}
|
|
3969
|
+
return cachedFinalConfig;
|
|
3970
|
+
}
|
|
3971
|
+
async #bumpIndependentVersionGroup(releaseGroup) {
|
|
3972
|
+
const releaseGroupFilteredProjects = this.#releaseGraph.releaseGroupToFilteredProjects.get(releaseGroup);
|
|
3973
|
+
let bumped = false;
|
|
3974
|
+
const projectBumpTypes = /* @__PURE__ */ new Map();
|
|
3975
|
+
const projectsToUpdate = /* @__PURE__ */ new Set();
|
|
3976
|
+
if (releaseGroupFilteredProjects && releaseGroupFilteredProjects.size > 0) {
|
|
3977
|
+
for (const project of releaseGroupFilteredProjects) {
|
|
3978
|
+
const {
|
|
3979
|
+
newVersionInput: bumpType,
|
|
3980
|
+
newVersionInputReason: bumpTypeReason,
|
|
3981
|
+
newVersionInputReasonData: bumpTypeReasonData
|
|
3982
|
+
} = await this.#determineVersionBumpForProject(releaseGroup, project);
|
|
3983
|
+
projectBumpTypes.set(project, {
|
|
3984
|
+
bumpType,
|
|
3985
|
+
bumpTypeReason,
|
|
3986
|
+
bumpTypeReasonData
|
|
3987
|
+
});
|
|
3988
|
+
if (bumpType !== "none") {
|
|
3989
|
+
projectsToUpdate.add(project);
|
|
3990
|
+
}
|
|
3991
|
+
}
|
|
3992
|
+
const sortedProjects = this.#releaseGraph.sortedProjects.get(releaseGroup.name) || [];
|
|
3993
|
+
for (const project of sortedProjects) {
|
|
3994
|
+
if (projectsToUpdate.has(project) && releaseGroupFilteredProjects?.has(project)) {
|
|
3995
|
+
const {
|
|
3996
|
+
bumpType: finalBumpType,
|
|
3997
|
+
bumpTypeReason: finalBumpTypeReason,
|
|
3998
|
+
bumpTypeReasonData: finalBumpTypeReasonData
|
|
3999
|
+
} = projectBumpTypes.get(project);
|
|
4000
|
+
if (finalBumpType !== "none") {
|
|
4001
|
+
await this.#bumpVersionForProject(
|
|
4002
|
+
project,
|
|
4003
|
+
finalBumpType,
|
|
4004
|
+
finalBumpTypeReason,
|
|
4005
|
+
finalBumpTypeReasonData
|
|
4006
|
+
);
|
|
4007
|
+
this.#bumpedProjects.add(project);
|
|
4008
|
+
bumped = true;
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
for (const project of sortedProjects) {
|
|
4013
|
+
if (projectsToUpdate.has(project) && releaseGroupFilteredProjects?.has(project)) {
|
|
4014
|
+
await this.#updateDependenciesForProject(project);
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
return bumped;
|
|
4019
|
+
}
|
|
4020
|
+
#getCurrentCachedVersionForProject(projectName) {
|
|
4021
|
+
return this.#releaseGraph.cachedCurrentVersions.get(projectName) || null;
|
|
4022
|
+
}
|
|
4023
|
+
async #calculateNewVersion(project, newVersionInput, newVersionInputReason, newVersionInputReasonData) {
|
|
4024
|
+
const currentVersion = this.#getCurrentCachedVersionForProject(project);
|
|
4025
|
+
const versionActions = this.#getVersionActionsForProject(project);
|
|
4026
|
+
const { newVersion, logText } = await versionActions.calculateNewVersion(
|
|
4027
|
+
currentVersion,
|
|
4028
|
+
newVersionInput,
|
|
4029
|
+
newVersionInputReason,
|
|
4030
|
+
newVersionInputReasonData,
|
|
4031
|
+
this.versionOptions.preid || this.workspaceConfig.preid || ""
|
|
4032
|
+
);
|
|
4033
|
+
const projectLogger = this.#getProjectLoggerForProject(project);
|
|
4034
|
+
projectLogger.buffer(logText);
|
|
4035
|
+
return { currentVersion, newVersion };
|
|
4036
|
+
}
|
|
4037
|
+
async #bumpVersionForProject(projectName, bumpType, bumpTypeReason, bumpTypeReasonData) {
|
|
4038
|
+
const projectLogger = this.#getProjectLoggerForProject(projectName);
|
|
4039
|
+
if (bumpType === "none") {
|
|
4040
|
+
projectLogger.buffer(
|
|
4041
|
+
`\u23E9 Skipping bump for ${projectName} as bump type is "none"`
|
|
4042
|
+
);
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
const versionActions = this.#getVersionActionsForProject(projectName);
|
|
4046
|
+
const { currentVersion, newVersion } = await this.#calculateNewVersion(
|
|
4047
|
+
projectName,
|
|
4048
|
+
bumpType,
|
|
4049
|
+
bumpTypeReason,
|
|
4050
|
+
bumpTypeReasonData
|
|
4051
|
+
);
|
|
4052
|
+
const logMessages = await versionActions.updateProjectVersion(
|
|
4053
|
+
this.#tree,
|
|
4054
|
+
newVersion
|
|
4055
|
+
);
|
|
4056
|
+
for (const logMessage of logMessages) {
|
|
4057
|
+
projectLogger.buffer(logMessage);
|
|
4058
|
+
}
|
|
4059
|
+
this.#versionData.set(projectName, {
|
|
4060
|
+
currentVersion,
|
|
4061
|
+
newVersion,
|
|
4062
|
+
dependentProjects: this.#getOriginalDependentProjects(projectName)
|
|
4063
|
+
});
|
|
4064
|
+
this.#bumpedProjects.add(projectName);
|
|
4065
|
+
const releaseGroupName = this.getReleaseGroupNameForProject(projectName);
|
|
4066
|
+
if (!releaseGroupName) {
|
|
4067
|
+
projectLogger.buffer(
|
|
4068
|
+
`\u26A0\uFE0F Cannot find release group for ${projectName}, skipping dependent updates`
|
|
4069
|
+
);
|
|
4070
|
+
return;
|
|
4071
|
+
}
|
|
4072
|
+
const releaseGroup = this.#releaseGraph.groupGraph.get(releaseGroupName).group;
|
|
4073
|
+
const releaseGroupVersionConfig = releaseGroup.version;
|
|
4074
|
+
const updateDependents = releaseGroupVersionConfig?.updateDependents || "always";
|
|
4075
|
+
if (updateDependents === "auto" || updateDependents === "always") {
|
|
4076
|
+
const dependents = this.#getNonImplicitDependentsForProject(projectName);
|
|
4077
|
+
const dependentsToProcess = dependents.filter(
|
|
4078
|
+
(dep) => this.#releaseGraph.allProjectsToProcess.has(dep)
|
|
4079
|
+
);
|
|
4080
|
+
await this.#updateDependenciesForDependents(dependentsToProcess);
|
|
4081
|
+
for (const dependent of dependentsToProcess) {
|
|
4082
|
+
if (!this.#bumpedProjects.has(dependent)) {
|
|
4083
|
+
await this.#bumpVersionForProject(
|
|
4084
|
+
dependent,
|
|
4085
|
+
this.#applyPreidToBumpType("patch", dependent),
|
|
4086
|
+
"DEPENDENCY_WAS_BUMPED",
|
|
4087
|
+
{}
|
|
4088
|
+
);
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
} else {
|
|
4092
|
+
const releaseGroupText = releaseGroupName !== IMPLICIT_DEFAULT_RELEASE_GROUP ? ` in release group "${releaseGroupName}" ` : " ";
|
|
4093
|
+
projectLogger.buffer(
|
|
4094
|
+
`\u23E9 Skipping dependent updates as "updateDependents"${releaseGroupText}is not "auto"`
|
|
4095
|
+
);
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
#getProjectDependents(project) {
|
|
4099
|
+
return this.#releaseGraph.projectToDependents.get(project) || /* @__PURE__ */ new Set();
|
|
4100
|
+
}
|
|
4101
|
+
#getNonImplicitDependentsForProject(project) {
|
|
4102
|
+
return Array.from(this.#getProjectDependents(project));
|
|
4103
|
+
}
|
|
4104
|
+
async #updateDependenciesForDependents(dependents) {
|
|
4105
|
+
for (const dependent of dependents) {
|
|
4106
|
+
if (!this.#releaseGraph?.allProjectsToProcess.has(dependent)) {
|
|
4107
|
+
throw new Error(
|
|
4108
|
+
`Unable to find project "${dependent}" in allProjectsToProcess, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
4109
|
+
);
|
|
4110
|
+
}
|
|
4111
|
+
await this.#updateDependenciesForProject(dependent);
|
|
4112
|
+
}
|
|
4113
|
+
}
|
|
4114
|
+
async #determineVersionBumpForProject(releaseGroup, projectName) {
|
|
4115
|
+
if (this.versionOptions.specifier) {
|
|
4116
|
+
return {
|
|
4117
|
+
newVersionInput: this.versionOptions.specifier,
|
|
4118
|
+
newVersionInputReason: "USER_SPECIFIER",
|
|
4119
|
+
newVersionInputReasonData: {}
|
|
4120
|
+
};
|
|
4121
|
+
}
|
|
4122
|
+
const projectGraphNode = this.#projectGraph.nodes[projectName];
|
|
4123
|
+
const projectLogger = this.#getProjectLoggerForProject(projectName);
|
|
4124
|
+
const cachedFinalConfigForProject = this.#getCachedFinalConfigForProject(projectName);
|
|
4125
|
+
if (cachedFinalConfigForProject.specifierSource === "conventional-commits") {
|
|
4126
|
+
const currentVersion = this.#getCurrentCachedVersionForProject(projectName);
|
|
4127
|
+
const bumpType = await deriveSpecifierFromConventionalCommits(
|
|
4128
|
+
{
|
|
4129
|
+
...this.#nxReleaseConfig,
|
|
4130
|
+
git: this.#nxReleaseConfig.git ?? {}
|
|
4131
|
+
},
|
|
4132
|
+
this.#projectGraph,
|
|
4133
|
+
projectLogger,
|
|
4134
|
+
releaseGroup,
|
|
4135
|
+
projectGraphNode,
|
|
4136
|
+
!!semver.prerelease(currentVersion ?? ""),
|
|
4137
|
+
this.#releaseGraph.cachedLatestMatchingGitTag.get(projectName),
|
|
4138
|
+
this.#releaseGraph,
|
|
4139
|
+
cachedFinalConfigForProject.fallbackCurrentVersionResolver,
|
|
4140
|
+
this.versionOptions.preid || this.workspaceConfig.preid || ""
|
|
4141
|
+
);
|
|
4142
|
+
return {
|
|
4143
|
+
newVersionInput: bumpType,
|
|
4144
|
+
newVersionInputReason: "CONVENTIONAL_COMMITS",
|
|
4145
|
+
newVersionInputReasonData: {}
|
|
4146
|
+
};
|
|
4147
|
+
}
|
|
4148
|
+
if (releaseGroup.versionPlans) {
|
|
4149
|
+
const currentVersion = this.#getCurrentCachedVersionForProject(projectName);
|
|
4150
|
+
const { bumpType, versionPlanPath } = await deriveSpecifierFromVersionPlan(
|
|
4151
|
+
projectLogger,
|
|
4152
|
+
releaseGroup,
|
|
4153
|
+
projectGraphNode,
|
|
4154
|
+
currentVersion
|
|
4155
|
+
);
|
|
4156
|
+
if (bumpType !== "none") {
|
|
4157
|
+
this.#processedVersionPlanFiles.add(versionPlanPath);
|
|
4158
|
+
}
|
|
4159
|
+
return {
|
|
4160
|
+
newVersionInput: bumpType,
|
|
4161
|
+
newVersionInputReason: "VERSION_PLANS",
|
|
4162
|
+
newVersionInputReasonData: {
|
|
4163
|
+
versionPlanPath
|
|
4164
|
+
}
|
|
4165
|
+
};
|
|
4166
|
+
}
|
|
4167
|
+
const versionActions = this.#getVersionActionsForProject(projectName);
|
|
4168
|
+
if (versionActions instanceof NOOP_VERSION_ACTIONS) {
|
|
4169
|
+
return {
|
|
4170
|
+
newVersionInput: "none",
|
|
4171
|
+
newVersionInputReason: "NOOP_VERSION_ACTIONS",
|
|
4172
|
+
newVersionInputReasonData: {}
|
|
4173
|
+
};
|
|
4174
|
+
}
|
|
4175
|
+
throw new Error(
|
|
4176
|
+
`Unhandled version bump config, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
4177
|
+
);
|
|
4178
|
+
}
|
|
4179
|
+
#getProjectLoggerForProject(projectName) {
|
|
4180
|
+
const projectLogger = this.#releaseGraph.projectLoggers.get(projectName);
|
|
4181
|
+
if (!projectLogger) {
|
|
4182
|
+
throw new Error(
|
|
4183
|
+
`No project logger found for project ${projectName}, please report this as a bug on https://github.com/nrwl/nx/issues`
|
|
4184
|
+
);
|
|
4185
|
+
}
|
|
4186
|
+
return projectLogger;
|
|
4187
|
+
}
|
|
4188
|
+
};
|
|
3323
4189
|
|
|
3324
4190
|
// src/release/release-client.ts
|
|
3325
4191
|
var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
@@ -3327,24 +4193,66 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3327
4193
|
if (!workspaceConfig) {
|
|
3328
4194
|
workspaceConfig = await getWorkspaceConfig();
|
|
3329
4195
|
}
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
}
|
|
3334
|
-
projectGraph = await createProjectGraphAsync$2({
|
|
3335
|
-
exitOnError: true,
|
|
3336
|
-
resetDaemonClient: true
|
|
3337
|
-
});
|
|
3338
|
-
}
|
|
4196
|
+
const projectGraph = await createProjectGraphAsync$2({
|
|
4197
|
+
exitOnError: true,
|
|
4198
|
+
resetDaemonClient: true
|
|
4199
|
+
});
|
|
3339
4200
|
if (!projectGraph) {
|
|
3340
4201
|
throw new Error(
|
|
3341
4202
|
"Failed to load the project graph. Please run `nx reset`, then run the `storm-git commit` command again."
|
|
3342
4203
|
);
|
|
3343
4204
|
}
|
|
4205
|
+
let nxJson;
|
|
4206
|
+
if (!ignoreNxJsonConfig && existsSync(joinPaths(workspaceConfig.workspaceRoot, "nx.json"))) {
|
|
4207
|
+
nxJson = readNxJson();
|
|
4208
|
+
}
|
|
4209
|
+
const config5 = defu(
|
|
4210
|
+
{
|
|
4211
|
+
changelog: {
|
|
4212
|
+
renderOptions: {
|
|
4213
|
+
workspaceConfig
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
},
|
|
4217
|
+
{
|
|
4218
|
+
groups: getReleaseGroupConfig(
|
|
4219
|
+
projectGraph,
|
|
4220
|
+
releaseConfig,
|
|
4221
|
+
workspaceConfig
|
|
4222
|
+
)
|
|
4223
|
+
},
|
|
4224
|
+
{
|
|
4225
|
+
groups: getReleaseGroupConfig(
|
|
4226
|
+
projectGraph,
|
|
4227
|
+
nxJson.release ?? {},
|
|
4228
|
+
workspaceConfig
|
|
4229
|
+
)
|
|
4230
|
+
},
|
|
4231
|
+
omit(releaseConfig, ["groups"]),
|
|
4232
|
+
nxJson.release ? omit(nxJson.release, ["groups"]) : {},
|
|
4233
|
+
omit(DEFAULT_RELEASE_CONFIG, ["groups"])
|
|
4234
|
+
);
|
|
4235
|
+
const normalizedConfig = clone(config5);
|
|
4236
|
+
if (workspaceConfig.preid) {
|
|
4237
|
+
normalizedConfig.groups = Object.fromEntries(
|
|
4238
|
+
Object.entries(normalizedConfig.groups ?? {}).map(([name, group]) => {
|
|
4239
|
+
return [
|
|
4240
|
+
name,
|
|
4241
|
+
{
|
|
4242
|
+
...group,
|
|
4243
|
+
version: {
|
|
4244
|
+
...group.version,
|
|
4245
|
+
preid: workspaceConfig.preid
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
];
|
|
4249
|
+
})
|
|
4250
|
+
);
|
|
4251
|
+
}
|
|
3344
4252
|
return new _StormReleaseClient(
|
|
3345
4253
|
projectGraph,
|
|
3346
|
-
|
|
3347
|
-
|
|
4254
|
+
config5,
|
|
4255
|
+
normalizedConfig,
|
|
3348
4256
|
workspaceConfig
|
|
3349
4257
|
);
|
|
3350
4258
|
}
|
|
@@ -3352,6 +4260,10 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3352
4260
|
* The release configuration used by this release client.
|
|
3353
4261
|
*/
|
|
3354
4262
|
config;
|
|
4263
|
+
/**
|
|
4264
|
+
* The normalized release configuration used by this release client.
|
|
4265
|
+
*/
|
|
4266
|
+
normalizedConfig;
|
|
3355
4267
|
/**
|
|
3356
4268
|
* The workspace configuration used by this release client.
|
|
3357
4269
|
*/
|
|
@@ -3376,40 +4288,16 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3376
4288
|
* @param ignoreNxJsonConfig - Whether to ignore the nx.json configuration and use only the provided {@link releaseConfig}. Default is false.
|
|
3377
4289
|
* @param workspaceConfig - Optional Storm workspace configuration object for logging purposes.
|
|
3378
4290
|
*/
|
|
3379
|
-
constructor(projectGraph,
|
|
3380
|
-
|
|
3381
|
-
if (!ignoreNxJsonConfig && existsSync(joinPaths(workspaceConfig.workspaceRoot, "nx.json"))) {
|
|
3382
|
-
nxJson = readNxJson();
|
|
3383
|
-
}
|
|
3384
|
-
const config5 = defu(
|
|
3385
|
-
{
|
|
3386
|
-
changelog: {
|
|
3387
|
-
renderOptions: {
|
|
3388
|
-
workspaceConfig
|
|
3389
|
-
}
|
|
3390
|
-
}
|
|
3391
|
-
},
|
|
3392
|
-
{
|
|
3393
|
-
groups: getReleaseGroupConfig(releaseConfig, workspaceConfig)
|
|
3394
|
-
},
|
|
3395
|
-
{
|
|
3396
|
-
groups: getReleaseGroupConfig(
|
|
3397
|
-
nxJson.release ?? {},
|
|
3398
|
-
workspaceConfig
|
|
3399
|
-
)
|
|
3400
|
-
},
|
|
3401
|
-
omit(releaseConfig, ["groups"]),
|
|
3402
|
-
nxJson.release ? omit(nxJson.release, ["groups"]) : {},
|
|
3403
|
-
omit(DEFAULT_RELEASE_CONFIG, ["groups"])
|
|
3404
|
-
);
|
|
3405
|
-
super(config5, true);
|
|
4291
|
+
constructor(projectGraph, config5, normalizedConfig, workspaceConfig) {
|
|
4292
|
+
super(normalizedConfig, true);
|
|
3406
4293
|
writeDebug(
|
|
3407
4294
|
"Executing release with the following configuration",
|
|
3408
4295
|
workspaceConfig
|
|
3409
4296
|
);
|
|
3410
|
-
writeDebug(
|
|
4297
|
+
writeDebug(normalizedConfig, workspaceConfig);
|
|
3411
4298
|
this.projectGraph = projectGraph;
|
|
3412
4299
|
this.config = config5;
|
|
4300
|
+
this.normalizedConfig = normalizedConfig;
|
|
3413
4301
|
this.workspaceConfig = workspaceConfig;
|
|
3414
4302
|
this.tree = new FsTree(workspaceConfig.workspaceRoot, false);
|
|
3415
4303
|
this.projectConfigurations = readProjectsConfigurationFromProjectGraph$2(projectGraph);
|
|
@@ -3425,8 +4313,19 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3425
4313
|
v.newVersion ? extractPreid(v.newVersion) : void 0
|
|
3426
4314
|
])
|
|
3427
4315
|
);
|
|
4316
|
+
const releaseGraph = options.releaseGraph ?? await createReleaseGraph({
|
|
4317
|
+
tree: this.tree,
|
|
4318
|
+
projectGraph: this.projectGraph,
|
|
4319
|
+
nxReleaseConfig: this.normalizedConfig,
|
|
4320
|
+
filters: {
|
|
4321
|
+
projects: options.projects,
|
|
4322
|
+
groups: options.groups
|
|
4323
|
+
},
|
|
4324
|
+
firstRelease: !!options.firstRelease,
|
|
4325
|
+
verbose: isVerbose(this.workspaceConfig.logLevel)
|
|
4326
|
+
});
|
|
3428
4327
|
const projectToAdditionalDependencyBumps = /* @__PURE__ */ new Map();
|
|
3429
|
-
for (const releaseGroup of
|
|
4328
|
+
for (const releaseGroup of releaseGraph.releaseGroups) {
|
|
3430
4329
|
if (releaseGroup.projectsRelationship !== "independent") {
|
|
3431
4330
|
continue;
|
|
3432
4331
|
}
|
|
@@ -3454,12 +4353,12 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3454
4353
|
}
|
|
3455
4354
|
}
|
|
3456
4355
|
const allProjectChangelogs = {};
|
|
3457
|
-
for (const releaseGroup of
|
|
4356
|
+
for (const releaseGroup of releaseGraph.releaseGroups) {
|
|
3458
4357
|
const config5 = releaseGroup.changelog;
|
|
3459
4358
|
if (config5 === false) {
|
|
3460
4359
|
continue;
|
|
3461
4360
|
}
|
|
3462
|
-
if (!
|
|
4361
|
+
if (!releaseGraph.releaseGroupToFilteredProjects.has(releaseGroup)) {
|
|
3463
4362
|
throw new Error(
|
|
3464
4363
|
`No filtered projects found for release group ${releaseGroup.name}`
|
|
3465
4364
|
);
|
|
@@ -3468,9 +4367,7 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3468
4367
|
// If the user has passed a list of projects, we need to use the filtered list of projects within the release group, plus any dependents
|
|
3469
4368
|
Array.from(
|
|
3470
4369
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
3471
|
-
|
|
3472
|
-
releaseGroup
|
|
3473
|
-
)
|
|
4370
|
+
releaseGraph.releaseGroupToFilteredProjects.get(releaseGroup)
|
|
3474
4371
|
).flatMap((project) => {
|
|
3475
4372
|
return [
|
|
3476
4373
|
project,
|
|
@@ -3493,9 +4390,10 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3493
4390
|
projectName: project.name,
|
|
3494
4391
|
releaseGroupName: releaseGroup.name
|
|
3495
4392
|
},
|
|
4393
|
+
releaseGraph.resolveRepositoryTags.bind(releaseGraph),
|
|
3496
4394
|
{
|
|
3497
4395
|
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3498
|
-
preid: projectsPreid[project.name],
|
|
4396
|
+
preid: projectsPreid[project.name] || this.workspaceConfig.preid,
|
|
3499
4397
|
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3500
4398
|
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
3501
4399
|
}
|
|
@@ -3549,7 +4447,7 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3549
4447
|
fileMap.nonProjectFiles
|
|
3550
4448
|
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3551
4449
|
})),
|
|
3552
|
-
this.
|
|
4450
|
+
this.normalizedConfig.conventionalCommits
|
|
3553
4451
|
);
|
|
3554
4452
|
writeDebug(
|
|
3555
4453
|
`Running changelog generation for the ${releaseGroup.name} release group`,
|
|
@@ -3583,12 +4481,15 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3583
4481
|
let changes = [];
|
|
3584
4482
|
let fromRef = options.from || (await getLatestGitTagForPattern(
|
|
3585
4483
|
releaseGroup.releaseTag.pattern,
|
|
3586
|
-
{
|
|
4484
|
+
{
|
|
4485
|
+
releaseGroupName: releaseGroup.name
|
|
4486
|
+
},
|
|
4487
|
+
releaseGraph.resolveRepositoryTags.bind(releaseGraph),
|
|
3587
4488
|
{
|
|
3588
4489
|
checkAllBranchesWhen: releaseGroup.releaseTag.checkAllBranchesWhen,
|
|
3589
|
-
preid: Object.keys(projectsPreid)[0] ? projectsPreid?.[Object.keys(projectsPreid)[0]] :
|
|
4490
|
+
preid: Object.keys(projectsPreid)[0] && projectsPreid?.[Object.keys(projectsPreid)[0]] ? projectsPreid?.[Object.keys(projectsPreid)[0]] : this.workspaceConfig.preid,
|
|
3590
4491
|
requireSemver: releaseGroup.releaseTag.requireSemver,
|
|
3591
|
-
strictPreid: releaseGroup.releaseTag.strictPreid
|
|
4492
|
+
strictPreid: releaseGroup.releaseTag.strictPreid || this.workspaceConfig.preid !== void 0
|
|
3592
4493
|
}
|
|
3593
4494
|
))?.tag;
|
|
3594
4495
|
if (!fromRef) {
|
|
@@ -3620,7 +4521,7 @@ var StormReleaseClient = class _StormReleaseClient extends ReleaseClient {
|
|
|
3620
4521
|
fileMap.nonProjectFiles
|
|
3621
4522
|
) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
|
|
3622
4523
|
})),
|
|
3623
|
-
this.
|
|
4524
|
+
this.normalizedConfig.conventionalCommits
|
|
3624
4525
|
);
|
|
3625
4526
|
writeDebug(
|
|
3626
4527
|
`Running changelog generation for the ${releaseGroup.name} release group`,
|
|
@@ -3676,7 +4577,7 @@ ${Object.keys(allProjectChangelogs).map((p) => ` - ${p}`).join("\n")}
|
|
|
3676
4577
|
options.releaseGraph.releaseGroups,
|
|
3677
4578
|
options.releaseGraph.releaseGroupToFilteredProjects,
|
|
3678
4579
|
options.versionData,
|
|
3679
|
-
options.gitCommitMessage || this.
|
|
4580
|
+
options.gitCommitMessage || this.normalizedConfig.changelog?.git?.commitMessage || DEFAULT_COMMIT_MESSAGE
|
|
3680
4581
|
);
|
|
3681
4582
|
const changes = this.tree.listChanges();
|
|
3682
4583
|
if (!changes.length) {
|
|
@@ -3699,7 +4600,7 @@ ${Object.keys(allProjectChangelogs).map((p) => ` - ${p}`).join("\n")}
|
|
|
3699
4600
|
isDryRun: !!options.dryRun,
|
|
3700
4601
|
isVerbose: !!options.verbose,
|
|
3701
4602
|
gitCommitMessages: commitMessageValues,
|
|
3702
|
-
gitCommitArgs: options.gitCommitArgs || this.
|
|
4603
|
+
gitCommitArgs: options.gitCommitArgs || this.normalizedConfig.changelog?.git?.commitArgs
|
|
3703
4604
|
});
|
|
3704
4605
|
latestCommit = await getCommitHash("HEAD");
|
|
3705
4606
|
writeDebug(
|
|
@@ -3709,8 +4610,8 @@ ${Object.keys(allProjectChangelogs).map((p) => ` - ${p}`).join("\n")}
|
|
|
3709
4610
|
for (const tag of gitTagValues) {
|
|
3710
4611
|
await gitTag({
|
|
3711
4612
|
tag,
|
|
3712
|
-
message: options.gitTagMessage || this.
|
|
3713
|
-
additionalArgs: options.gitTagArgs || this.
|
|
4613
|
+
message: options.gitTagMessage || this.normalizedConfig.changelog?.git?.tagMessage,
|
|
4614
|
+
additionalArgs: options.gitTagArgs || this.normalizedConfig.changelog?.git?.tagArgs,
|
|
3714
4615
|
dryRun: options.dryRun,
|
|
3715
4616
|
verbose: options.verbose
|
|
3716
4617
|
});
|
|
@@ -3723,13 +4624,323 @@ ${Object.keys(allProjectChangelogs).map((p) => ` - ${p}`).join("\n")}
|
|
|
3723
4624
|
gitRemote: options.gitRemote,
|
|
3724
4625
|
dryRun: options.dryRun,
|
|
3725
4626
|
verbose: options.verbose,
|
|
3726
|
-
additionalArgs: options.gitPushArgs || this.
|
|
4627
|
+
additionalArgs: options.gitPushArgs || this.normalizedConfig.changelog?.git?.pushArgs
|
|
3727
4628
|
});
|
|
3728
4629
|
for (const postGitTask of postGitTasks) {
|
|
3729
4630
|
await postGitTask(latestCommit);
|
|
3730
4631
|
}
|
|
3731
4632
|
return;
|
|
3732
4633
|
};
|
|
4634
|
+
releaseVersion = async (options) => {
|
|
4635
|
+
const verbose = options.verbose || isVerbose(this.workspaceConfig.logLevel);
|
|
4636
|
+
this.projectGraph = await createProjectGraphAsync$2({
|
|
4637
|
+
exitOnError: true,
|
|
4638
|
+
resetDaemonClient: true
|
|
4639
|
+
});
|
|
4640
|
+
if (!this.projectGraph) {
|
|
4641
|
+
throw new Error(
|
|
4642
|
+
"Failed to load the project graph. Please run `nx reset`, then run the `storm-git commit` command again."
|
|
4643
|
+
);
|
|
4644
|
+
}
|
|
4645
|
+
const releaseGraph = options.releaseGraph ?? await createReleaseGraph({
|
|
4646
|
+
tree: this.tree,
|
|
4647
|
+
projectGraph: this.projectGraph,
|
|
4648
|
+
nxReleaseConfig: this.normalizedConfig,
|
|
4649
|
+
filters: {
|
|
4650
|
+
projects: options.projects,
|
|
4651
|
+
groups: options.groups
|
|
4652
|
+
},
|
|
4653
|
+
firstRelease: !!options.firstRelease,
|
|
4654
|
+
verbose,
|
|
4655
|
+
preid: options.preid ?? this.workspaceConfig.preid,
|
|
4656
|
+
versionActionsOptionsOverrides: options.versionActionsOptionsOverrides
|
|
4657
|
+
});
|
|
4658
|
+
if (releaseGraph.filterLog && process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG !== "true") {
|
|
4659
|
+
writeDebug(formatNxLog(releaseGraph.filterLog), this.workspaceConfig);
|
|
4660
|
+
}
|
|
4661
|
+
if (!options.specifier) {
|
|
4662
|
+
const rawVersionPlans = await readRawVersionPlans();
|
|
4663
|
+
await setResolvedVersionPlansOnGroups(
|
|
4664
|
+
rawVersionPlans,
|
|
4665
|
+
releaseGraph.releaseGroups,
|
|
4666
|
+
Object.keys(this.projectGraph.nodes),
|
|
4667
|
+
verbose
|
|
4668
|
+
);
|
|
4669
|
+
const versionPlanValidationError = validateResolvedVersionPlansAgainstFilter(
|
|
4670
|
+
releaseGraph.releaseGroups,
|
|
4671
|
+
releaseGraph.releaseGroupToFilteredProjects
|
|
4672
|
+
);
|
|
4673
|
+
if (versionPlanValidationError) {
|
|
4674
|
+
throw new Error(formatNxLog(versionPlanValidationError));
|
|
4675
|
+
}
|
|
4676
|
+
} else {
|
|
4677
|
+
if (verbose && releaseGraph.releaseGroups.some((g) => !!g.versionPlans)) {
|
|
4678
|
+
writeDebug(
|
|
4679
|
+
`Skipping version plan discovery as a specifier was provided`,
|
|
4680
|
+
this.workspaceConfig
|
|
4681
|
+
);
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
if (options.deleteVersionPlans === void 0) {
|
|
4685
|
+
options.deleteVersionPlans = false;
|
|
4686
|
+
}
|
|
4687
|
+
if (this.normalizedConfig.version?.preVersionCommand) {
|
|
4688
|
+
writeDebug(
|
|
4689
|
+
"Executing the following pre-version command: \n" + this.normalizedConfig.version.preVersionCommand,
|
|
4690
|
+
this.workspaceConfig
|
|
4691
|
+
);
|
|
4692
|
+
try {
|
|
4693
|
+
const childProcess2 = runAsync(
|
|
4694
|
+
this.workspaceConfig,
|
|
4695
|
+
this.normalizedConfig.version.preVersionCommand,
|
|
4696
|
+
this.workspaceConfig.workspaceRoot,
|
|
4697
|
+
{
|
|
4698
|
+
...process.env,
|
|
4699
|
+
NX_DRY_RUN: options.dryRun ? "true" : "false"
|
|
4700
|
+
}
|
|
4701
|
+
);
|
|
4702
|
+
if (options.verbose) {
|
|
4703
|
+
childProcess2.stdout?.pipe(process.stdout);
|
|
4704
|
+
childProcess2.stderr?.pipe(process.stderr);
|
|
4705
|
+
}
|
|
4706
|
+
await childProcess2;
|
|
4707
|
+
} catch (e) {
|
|
4708
|
+
throw new Error(
|
|
4709
|
+
formatNxLog({
|
|
4710
|
+
title: `The pre-version command failed. See the full output above.`,
|
|
4711
|
+
bodyLines: [this.normalizedConfig.version.preVersionCommand, e]
|
|
4712
|
+
})
|
|
4713
|
+
);
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
for (const groupName of releaseGraph.sortedReleaseGroups) {
|
|
4717
|
+
const releaseGroup = releaseGraph.releaseGroups.find(
|
|
4718
|
+
(g) => g.name === groupName
|
|
4719
|
+
);
|
|
4720
|
+
if (!releaseGroup) {
|
|
4721
|
+
continue;
|
|
4722
|
+
}
|
|
4723
|
+
if (releaseGroup.version?.groupPreVersionCommand) {
|
|
4724
|
+
writeDebug(
|
|
4725
|
+
`Executing the ${releaseGroup.name} release group's pre-version command:
|
|
4726
|
+
` + releaseGroup.version?.groupPreVersionCommand,
|
|
4727
|
+
this.workspaceConfig
|
|
4728
|
+
);
|
|
4729
|
+
try {
|
|
4730
|
+
const childProcess2 = runAsync(
|
|
4731
|
+
this.workspaceConfig,
|
|
4732
|
+
releaseGroup.version?.groupPreVersionCommand,
|
|
4733
|
+
this.workspaceConfig.workspaceRoot,
|
|
4734
|
+
{
|
|
4735
|
+
...process.env,
|
|
4736
|
+
NX_DRY_RUN: options.dryRun ? "true" : "false"
|
|
4737
|
+
}
|
|
4738
|
+
);
|
|
4739
|
+
if (options.verbose) {
|
|
4740
|
+
childProcess2.stdout?.pipe(process.stdout);
|
|
4741
|
+
childProcess2.stderr?.pipe(process.stderr);
|
|
4742
|
+
}
|
|
4743
|
+
await childProcess2;
|
|
4744
|
+
} catch (e) {
|
|
4745
|
+
throw new Error(
|
|
4746
|
+
formatNxLog({
|
|
4747
|
+
title: `The ${releaseGroup.name} release group's pre-version command failed. See the full output above.`,
|
|
4748
|
+
bodyLines: [releaseGroup.version?.groupPreVersionCommand, e]
|
|
4749
|
+
})
|
|
4750
|
+
);
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
await releaseGraph.validate(this.tree);
|
|
4755
|
+
const commitMessage = options.gitCommitMessage || this.normalizedConfig.version?.git?.commitMessage;
|
|
4756
|
+
const additionalChangedFiles = /* @__PURE__ */ new Set();
|
|
4757
|
+
const additionalDeletedFiles = /* @__PURE__ */ new Set();
|
|
4758
|
+
const processor = new StormReleaseGroupProcessor(
|
|
4759
|
+
this.tree,
|
|
4760
|
+
this.workspaceConfig,
|
|
4761
|
+
this.projectGraph,
|
|
4762
|
+
this.normalizedConfig,
|
|
4763
|
+
releaseGraph,
|
|
4764
|
+
options
|
|
4765
|
+
);
|
|
4766
|
+
try {
|
|
4767
|
+
await processor.processGroups();
|
|
4768
|
+
if (options.deleteVersionPlans) {
|
|
4769
|
+
processor.deleteProcessedVersionPlanFiles();
|
|
4770
|
+
}
|
|
4771
|
+
} catch (err) {
|
|
4772
|
+
processor.flushAllProjectLoggers();
|
|
4773
|
+
throw err;
|
|
4774
|
+
}
|
|
4775
|
+
await formatChangedFiles(this.tree);
|
|
4776
|
+
printAndFlushChanges(this.tree, !!options.dryRun);
|
|
4777
|
+
const { changedFiles: changed, deletedFiles: deleted } = await processor.afterAllProjectsVersioned({
|
|
4778
|
+
...this.normalizedConfig.version.versionActionsOptions,
|
|
4779
|
+
...options.versionActionsOptionsOverrides ?? {}
|
|
4780
|
+
});
|
|
4781
|
+
changed.forEach((f) => additionalChangedFiles.add(f));
|
|
4782
|
+
deleted.forEach((f) => additionalDeletedFiles.add(f));
|
|
4783
|
+
if (this.normalizedConfig.docker && typeof this.normalizedConfig.docker === "object" && this.normalizedConfig.docker?.preVersionCommand) {
|
|
4784
|
+
writeDebug(
|
|
4785
|
+
`Executing the docker pre-version command:
|
|
4786
|
+
` + this.normalizedConfig.docker.preVersionCommand,
|
|
4787
|
+
this.workspaceConfig
|
|
4788
|
+
);
|
|
4789
|
+
try {
|
|
4790
|
+
const childProcess2 = runAsync(
|
|
4791
|
+
this.workspaceConfig,
|
|
4792
|
+
this.normalizedConfig.docker.preVersionCommand,
|
|
4793
|
+
this.workspaceConfig.workspaceRoot,
|
|
4794
|
+
{
|
|
4795
|
+
...process.env,
|
|
4796
|
+
NX_DRY_RUN: options.dryRun ? "true" : "false"
|
|
4797
|
+
}
|
|
4798
|
+
);
|
|
4799
|
+
if (options.verbose) {
|
|
4800
|
+
childProcess2.stdout?.pipe(process.stdout);
|
|
4801
|
+
childProcess2.stderr?.pipe(process.stderr);
|
|
4802
|
+
}
|
|
4803
|
+
await childProcess2;
|
|
4804
|
+
} catch (e) {
|
|
4805
|
+
throw new Error(
|
|
4806
|
+
formatNxLog({
|
|
4807
|
+
title: `The docker pre-version command failed. See the full output above.`,
|
|
4808
|
+
bodyLines: [this.normalizedConfig.docker.preVersionCommand, e]
|
|
4809
|
+
})
|
|
4810
|
+
);
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
for (const groupName of releaseGraph.sortedReleaseGroups) {
|
|
4814
|
+
const releaseGroup = releaseGraph.releaseGroups.find(
|
|
4815
|
+
(g) => g.name === groupName
|
|
4816
|
+
);
|
|
4817
|
+
if (!releaseGroup) {
|
|
4818
|
+
continue;
|
|
4819
|
+
}
|
|
4820
|
+
if (releaseGroup.docker?.groupPreVersionCommand) {
|
|
4821
|
+
writeDebug(
|
|
4822
|
+
`Executing the ${releaseGroup.name} release group's docker pre-version command:
|
|
4823
|
+
` + releaseGroup.docker?.groupPreVersionCommand,
|
|
4824
|
+
this.workspaceConfig
|
|
4825
|
+
);
|
|
4826
|
+
try {
|
|
4827
|
+
const childProcess2 = runAsync(
|
|
4828
|
+
this.workspaceConfig,
|
|
4829
|
+
releaseGroup.docker?.groupPreVersionCommand,
|
|
4830
|
+
this.workspaceConfig.workspaceRoot,
|
|
4831
|
+
{
|
|
4832
|
+
...process.env,
|
|
4833
|
+
NX_DRY_RUN: options.dryRun ? "true" : "false"
|
|
4834
|
+
}
|
|
4835
|
+
);
|
|
4836
|
+
if (options.verbose) {
|
|
4837
|
+
childProcess2.stdout?.pipe(process.stdout);
|
|
4838
|
+
childProcess2.stderr?.pipe(process.stderr);
|
|
4839
|
+
}
|
|
4840
|
+
await childProcess2;
|
|
4841
|
+
} catch (e) {
|
|
4842
|
+
throw new Error(
|
|
4843
|
+
formatNxLog({
|
|
4844
|
+
title: `The ${releaseGroup.name} release group's docker pre-version command failed. See the full output above.`,
|
|
4845
|
+
bodyLines: [releaseGroup.docker?.groupPreVersionCommand, e]
|
|
4846
|
+
})
|
|
4847
|
+
);
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
if (this.normalizedConfig.docker || releaseGraph.releaseGroups.some((rg) => rg.docker)) {
|
|
4852
|
+
writeWarning(
|
|
4853
|
+
formatNxLog({
|
|
4854
|
+
title: "Warning",
|
|
4855
|
+
bodyLines: [
|
|
4856
|
+
`Docker support is experimental. Breaking changes may occur and not adhere to semver versioning.`
|
|
4857
|
+
]
|
|
4858
|
+
})
|
|
4859
|
+
);
|
|
4860
|
+
}
|
|
4861
|
+
await processor.processDockerProjects(
|
|
4862
|
+
options.dockerVersionScheme,
|
|
4863
|
+
options.dockerVersion
|
|
4864
|
+
);
|
|
4865
|
+
const versionData = processor.getVersionData();
|
|
4866
|
+
const gitTagValues = options.gitTag ?? this.normalizedConfig.version?.git?.tag ? createGitTagValues(
|
|
4867
|
+
releaseGraph.releaseGroups,
|
|
4868
|
+
releaseGraph.releaseGroupToFilteredProjects,
|
|
4869
|
+
versionData
|
|
4870
|
+
) : [];
|
|
4871
|
+
handleDuplicateGitTags(gitTagValues);
|
|
4872
|
+
let workspaceVersion = void 0;
|
|
4873
|
+
if (releaseGraph.releaseGroups.length === 1) {
|
|
4874
|
+
const releaseGroup = releaseGraph.releaseGroups[0];
|
|
4875
|
+
if (releaseGroup?.projectsRelationship === "fixed") {
|
|
4876
|
+
const releaseGroupProjectNames = Array.from(
|
|
4877
|
+
releaseGraph.releaseGroupToFilteredProjects.get(releaseGroup)
|
|
4878
|
+
);
|
|
4879
|
+
workspaceVersion = versionData[releaseGroupProjectNames[0]].newVersion;
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
const changedFiles = [
|
|
4883
|
+
...this.tree.listChanges().map((f) => f.path),
|
|
4884
|
+
...additionalChangedFiles
|
|
4885
|
+
];
|
|
4886
|
+
const deletedFiles = Array.from(additionalDeletedFiles);
|
|
4887
|
+
if (!changedFiles.length && !deletedFiles.length) {
|
|
4888
|
+
return {
|
|
4889
|
+
workspaceVersion,
|
|
4890
|
+
projectsVersionData: versionData,
|
|
4891
|
+
releaseGraph
|
|
4892
|
+
};
|
|
4893
|
+
}
|
|
4894
|
+
if (options.gitCommit ?? this.normalizedConfig.version?.git?.commit) {
|
|
4895
|
+
await commitChanges({
|
|
4896
|
+
changedFiles,
|
|
4897
|
+
deletedFiles,
|
|
4898
|
+
isDryRun: !!options.dryRun,
|
|
4899
|
+
isVerbose: !!options.verbose,
|
|
4900
|
+
gitCommitMessages: createCommitMessageValues(
|
|
4901
|
+
releaseGraph.releaseGroups,
|
|
4902
|
+
releaseGraph.releaseGroupToFilteredProjects,
|
|
4903
|
+
versionData,
|
|
4904
|
+
commitMessage
|
|
4905
|
+
),
|
|
4906
|
+
gitCommitArgs: options.gitCommitArgs || this.normalizedConfig.version?.git?.commitArgs
|
|
4907
|
+
});
|
|
4908
|
+
} else if (options.stageChanges ?? this.normalizedConfig.version?.git?.stageChanges) {
|
|
4909
|
+
writeDebug(`Staging changed files with git`);
|
|
4910
|
+
await gitAdd({
|
|
4911
|
+
changedFiles,
|
|
4912
|
+
deletedFiles,
|
|
4913
|
+
dryRun: options.dryRun,
|
|
4914
|
+
verbose
|
|
4915
|
+
});
|
|
4916
|
+
}
|
|
4917
|
+
if (options.gitTag ?? this.normalizedConfig.version?.git?.tag) {
|
|
4918
|
+
writeDebug(`Tagging commit with git`);
|
|
4919
|
+
for (const tag of gitTagValues) {
|
|
4920
|
+
await gitTag({
|
|
4921
|
+
tag,
|
|
4922
|
+
message: options.gitTagMessage || this.normalizedConfig.version?.git?.tagMessage,
|
|
4923
|
+
additionalArgs: options.gitTagArgs || this.normalizedConfig.version?.git?.tagArgs,
|
|
4924
|
+
dryRun: options.dryRun,
|
|
4925
|
+
verbose: options.verbose
|
|
4926
|
+
});
|
|
4927
|
+
}
|
|
4928
|
+
}
|
|
4929
|
+
if (options.gitPush ?? this.normalizedConfig.version?.git?.push) {
|
|
4930
|
+
writeDebug(`Pushing to git remote "${options.gitRemote ?? "origin"}"`);
|
|
4931
|
+
await gitPush({
|
|
4932
|
+
gitRemote: options.gitRemote,
|
|
4933
|
+
dryRun: options.dryRun,
|
|
4934
|
+
verbose: options.verbose,
|
|
4935
|
+
additionalArgs: options.gitPushArgs || this.normalizedConfig.version?.git?.pushArgs
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4938
|
+
return {
|
|
4939
|
+
workspaceVersion,
|
|
4940
|
+
projectsVersionData: versionData,
|
|
4941
|
+
releaseGraph
|
|
4942
|
+
};
|
|
4943
|
+
};
|
|
3733
4944
|
};
|
|
3734
4945
|
|
|
3735
4946
|
// src/release/run.ts
|