@storm-software/git-tools 2.123.16 → 2.123.18

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/bin/{chunk-SWXHQXUT.cjs → chunk-AU5PZKTN.cjs} +2 -0
  3. package/bin/chunk-AU5PZKTN.cjs.map +1 -0
  4. package/bin/{chunk-G3JMIIRF.cjs → chunk-EHPPIARR.cjs} +12 -17
  5. package/bin/chunk-EHPPIARR.cjs.map +1 -0
  6. package/bin/{chunk-L64XVBGM.cjs → chunk-FH5OSXAJ.cjs} +2 -0
  7. package/bin/chunk-FH5OSXAJ.cjs.map +1 -0
  8. package/bin/{chunk-S5PS23TL.js → chunk-G3YPGVPS.js} +2 -0
  9. package/bin/chunk-G3YPGVPS.js.map +1 -0
  10. package/bin/{chunk-AMSZ7DVW.js → chunk-Q3DQKTOI.js} +2 -0
  11. package/bin/chunk-Q3DQKTOI.js.map +1 -0
  12. package/bin/{chunk-K3LWFM6S.js → chunk-VBJB46HW.js} +13 -17
  13. package/bin/chunk-VBJB46HW.js.map +1 -0
  14. package/bin/git.cjs +642 -1563
  15. package/bin/git.cjs.map +1 -0
  16. package/bin/git.js +589 -1510
  17. package/bin/git.js.map +1 -0
  18. package/bin/post-checkout.cjs +16 -14
  19. package/bin/post-checkout.cjs.map +1 -0
  20. package/bin/post-checkout.js +5 -3
  21. package/bin/post-checkout.js.map +1 -0
  22. package/bin/post-commit.cjs +16 -14
  23. package/bin/post-commit.cjs.map +1 -0
  24. package/bin/post-commit.js +5 -3
  25. package/bin/post-commit.js.map +1 -0
  26. package/bin/post-merge.cjs +16 -14
  27. package/bin/post-merge.cjs.map +1 -0
  28. package/bin/post-merge.js +5 -3
  29. package/bin/post-merge.js.map +1 -0
  30. package/bin/pre-commit.cjs +14 -12
  31. package/bin/pre-commit.cjs.map +1 -0
  32. package/bin/pre-commit.js +4 -2
  33. package/bin/pre-commit.js.map +1 -0
  34. package/bin/pre-install.cjs +13 -11
  35. package/bin/pre-install.cjs.map +1 -0
  36. package/bin/pre-install.js +4 -2
  37. package/bin/pre-install.js.map +1 -0
  38. package/bin/pre-push.cjs +21 -19
  39. package/bin/pre-push.cjs.map +1 -0
  40. package/bin/pre-push.js +5 -3
  41. package/bin/pre-push.js.map +1 -0
  42. package/bin/prepare.cjs +11 -9
  43. package/bin/prepare.cjs.map +1 -0
  44. package/bin/prepare.js +4 -2
  45. package/bin/prepare.js.map +1 -0
  46. package/bin/version-warning.cjs +9 -7
  47. package/bin/version-warning.cjs.map +1 -0
  48. package/bin/version-warning.js +4 -2
  49. package/bin/version-warning.js.map +1 -0
  50. package/dist/chunk-3GGWHKRP.js +3 -6
  51. package/dist/chunk-4VPJA7YJ.cjs +9 -9
  52. package/dist/chunk-5XU2KBM6.js +1 -3
  53. package/dist/chunk-F7OO6L26.cjs +11 -16
  54. package/dist/chunk-JCEVFJCA.js +4 -14
  55. package/dist/chunk-KZRVQ5RZ.js +3 -11
  56. package/dist/chunk-NY53WLGC.cjs +16 -23
  57. package/dist/chunk-NZHEQPL3.cjs +82 -0
  58. package/dist/chunk-PKEX4GUO.js +75 -0
  59. package/dist/chunk-YBAE6I5L.cjs +3 -3
  60. package/dist/commit/minimal.cjs +11 -3
  61. package/dist/commit/minimal.js +3 -10
  62. package/dist/commit/monorepo.cjs +11 -3
  63. package/dist/commit/monorepo.js +4 -11
  64. package/dist/commitlint/minimal.cjs +4 -5
  65. package/dist/commitlint/minimal.js +3 -6
  66. package/dist/commitlint/monorepo.cjs +4 -5
  67. package/dist/commitlint/monorepo.js +3 -6
  68. package/dist/index.cjs +36 -14
  69. package/dist/index.d.cts +2 -2
  70. package/dist/index.d.ts +2 -2
  71. package/dist/index.js +5 -20
  72. package/dist/release/config.cjs +26 -6
  73. package/dist/release/config.d.cts +21 -242
  74. package/dist/release/config.d.ts +21 -242
  75. package/dist/release/config.js +5 -14
  76. package/dist/types.cjs +7 -3
  77. package/dist/types.d.cts +90 -94
  78. package/dist/types.d.ts +90 -94
  79. package/dist/types.js +1 -6
  80. package/package.json +12 -12
  81. package/dist/chunk-GOKUSEH3.cjs +0 -77
  82. package/dist/chunk-YCEUZFMU.js +0 -77
package/bin/git.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var chunkL64XVBGM_cjs = require('./chunk-L64XVBGM.cjs');
5
- var chunkG3JMIIRF_cjs = require('./chunk-G3JMIIRF.cjs');
4
+ var chunkFH5OSXAJ_cjs = require('./chunk-FH5OSXAJ.cjs');
5
+ var chunkEHPPIARR_cjs = require('./chunk-EHPPIARR.cjs');
6
6
  var TOML = require('@ltd/j-toml');
7
7
  var commander = require('commander');
8
8
  var prompts = require('@inquirer/prompts');
@@ -25,38 +25,24 @@ var htmlparser2 = require('htmlparser2');
25
25
  var _ = require('underscore');
26
26
  var updateSection = require('update-section');
27
27
  var devkit = require('@nx/devkit');
28
- var publish_js = require('nx/src/command-line/release/publish.js');
29
- var version_js = require('nx/src/command-line/release/version.js');
30
- var nxJson_js = require('nx/src/config/nx-json.js');
31
- var enquirer = require('enquirer');
32
- var config$1 = require('nx/src/command-line/release/config/config');
33
- var deepMergeJson = require('nx/src/command-line/release/config/deep-merge-json');
34
- var filterReleaseGroups = require('nx/src/command-line/release/config/filter-release-groups');
35
- var versionPlans = require('nx/src/command-line/release/config/version-plans');
36
- var git = require('nx/src/command-line/release/utils/git');
37
- var launchEditor = require('nx/src/command-line/release/utils/launch-editor');
28
+ var axios = require('axios');
29
+ require('enquirer');
30
+ var os = require('os');
38
31
  var printChanges = require('nx/src/command-line/release/utils/print-changes');
39
- var printConfig = require('nx/src/command-line/release/utils/print-config');
40
32
  var github = require('nx/src/command-line/release/utils/remote-release-clients/github');
41
- var resolveNxJsonErrorMessage = require('nx/src/command-line/release/utils/resolve-nx-json-error-message');
42
33
  var shared = require('nx/src/command-line/release/utils/shared');
34
+ var yaml = require('yaml');
35
+ var prettier = require('prettier');
36
+ var release = require('nx/release');
37
+ var changelog = require('nx/src/command-line/release/changelog');
38
+ var git = require('nx/src/command-line/release/utils/git');
43
39
  var nxJson = require('nx/src/config/nx-json');
44
40
  var tree = require('nx/src/generators/tree');
45
- var fileMapUtils = require('nx/src/project-graph/file-map-utils');
46
- var utils = require('nx/src/tasks-runner/utils');
47
- var isCi = require('nx/src/utils/is-ci');
48
- var output = require('nx/src/utils/output');
49
- var path = require('nx/src/utils/path');
50
- var workspaceRoot = require('nx/src/utils/workspace-root');
51
- var semver = require('semver');
52
- var tmp = require('tmp');
53
- var prettier = require('prettier');
54
41
  var execCommand_js = require('nx/src/command-line/release/utils/exec-command.js');
55
- var axios = require('axios');
42
+ var utils = require('nx/src/tasks-runner/utils');
56
43
  var DefaultChangelogRenderer = require('nx/release/changelog-renderer');
57
44
  var conventionalCommits = require('nx/src/command-line/release/config/conventional-commits');
58
- var os = require('os');
59
- var yaml = require('yaml');
45
+ var semver = require('semver');
60
46
 
61
47
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
62
48
 
@@ -402,9 +388,9 @@ function getRuleFromScopeEnum(scopeEnum) {
402
388
 
403
389
  // ../conventional-changelog/src/index.ts
404
390
  async function createPreset(variant = "monorepo") {
405
- const workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
391
+ const workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
406
392
  if (variant === "minimal") {
407
- return chunkG3JMIIRF_cjs.defu(
393
+ return chunkEHPPIARR_cjs.defu(
408
394
  await createBasePreset__default.default({ ...COMMIT_CONFIGS.minimal.changelogs.props }),
409
395
  {
410
396
  ...COMMIT_CONFIGS.minimal,
@@ -418,7 +404,7 @@ async function createPreset(variant = "monorepo") {
418
404
  );
419
405
  }
420
406
  const nxScopes = await getNxScopes({ config: workspaceConfig });
421
- return chunkG3JMIIRF_cjs.defu(
407
+ return chunkEHPPIARR_cjs.defu(
422
408
  await createBasePreset__default.default({
423
409
  ...COMMIT_CONFIGS.monorepo.changelogs.props,
424
410
  scope: nxScopes
@@ -941,10 +927,10 @@ async function lint(message, config5) {
941
927
  throw new Error(`Could not find rule implementation for ${name}`);
942
928
  }
943
929
  const executableRule = rule;
944
- const [valid3, message2] = await executableRule(parsed, when, value);
930
+ const [valid2, message2] = await executableRule(parsed, when, value);
945
931
  return {
946
932
  level,
947
- valid: valid3,
933
+ valid: valid2,
948
934
  name,
949
935
  message: message2
950
936
  };
@@ -958,9 +944,9 @@ async function lint(message, config5) {
958
944
  const warnings = results.filter(
959
945
  (result) => result.level === 1 /* Warning */ && !result.valid
960
946
  );
961
- const valid2 = errors.length === 0;
947
+ const valid = errors.length === 0;
962
948
  return {
963
- valid: valid2,
949
+ valid,
964
950
  errors,
965
951
  warnings,
966
952
  input: buildCommitMessage(parsed)
@@ -970,7 +956,7 @@ async function lint(message, config5) {
970
956
  // src/commitlint/run.ts
971
957
  var COMMIT_EDITMSG_PATH = ".git/COMMIT_EDITMSG";
972
958
  async function runCommitLint(workspaceConfig, options) {
973
- chunkG3JMIIRF_cjs.writeInfo(
959
+ chunkEHPPIARR_cjs.writeInfo(
974
960
  "\u{1F4DD} Validating git commit message aligns with the Storm Software specification",
975
961
  workspaceConfig
976
962
  );
@@ -978,7 +964,7 @@ async function runCommitLint(workspaceConfig, options) {
978
964
  if (options.message && options.message !== COMMIT_EDITMSG_PATH) {
979
965
  commitMessage = options.message;
980
966
  } else {
981
- const commitFile = chunkG3JMIIRF_cjs.joinPaths(
967
+ const commitFile = chunkEHPPIARR_cjs.joinPaths(
982
968
  workspaceConfig.workspaceRoot,
983
969
  options.file || options.message || COMMIT_EDITMSG_PATH
984
970
  );
@@ -995,17 +981,17 @@ async function runCommitLint(workspaceConfig, options) {
995
981
  if (upstreamRemote) {
996
982
  const upstreamRemoteIdentifier = upstreamRemote.split(" ")[0]?.trim();
997
983
  if (!upstreamRemoteIdentifier) {
998
- chunkG3JMIIRF_cjs.writeWarning(
984
+ chunkEHPPIARR_cjs.writeWarning(
999
985
  `No upstream remote found for ${workspaceConfig.name}.git. Skipping comparison.`,
1000
986
  workspaceConfig
1001
987
  );
1002
988
  return;
1003
989
  }
1004
- chunkG3JMIIRF_cjs.writeDebug(`Comparing against remote ${upstreamRemoteIdentifier}`);
990
+ chunkEHPPIARR_cjs.writeDebug(`Comparing against remote ${upstreamRemoteIdentifier}`);
1005
991
  const currentBranch = childProcess__default.default.execSync("git branch --show-current").toString().trim();
1006
992
  gitLogCmd = gitLogCmd + ` ${currentBranch} ^${upstreamRemoteIdentifier}/main`;
1007
993
  } else {
1008
- chunkG3JMIIRF_cjs.writeWarning(
994
+ chunkEHPPIARR_cjs.writeWarning(
1009
995
  `No upstream remote found for ${workspaceConfig.name}.git. Skipping comparison against upstream main.`,
1010
996
  workspaceConfig
1011
997
  );
@@ -1013,7 +999,7 @@ async function runCommitLint(workspaceConfig, options) {
1013
999
  }
1014
1000
  commitMessage = childProcess__default.default.execSync(gitLogCmd).toString().trim();
1015
1001
  if (!commitMessage) {
1016
- chunkG3JMIIRF_cjs.writeWarning(
1002
+ chunkEHPPIARR_cjs.writeWarning(
1017
1003
  "No commits found. Skipping commit message validation.",
1018
1004
  workspaceConfig
1019
1005
  );
@@ -1023,7 +1009,7 @@ async function runCommitLint(workspaceConfig, options) {
1023
1009
  const preset = await createPreset(workspaceConfig.variant);
1024
1010
  const report = await lint(commitMessage, preset);
1025
1011
  if (!preset.commitlint.regex.test(commitMessage) || report.errors.length || report.warnings.length) {
1026
- chunkG3JMIIRF_cjs.writeSuccess(
1012
+ chunkEHPPIARR_cjs.writeSuccess(
1027
1013
  `Commit was processing completed successfully!`,
1028
1014
  workspaceConfig
1029
1015
  );
@@ -1235,7 +1221,7 @@ async function createState(workspaceConfig, configPath) {
1235
1221
  const project = projectConfigurations.projects[scope];
1236
1222
  if (project) {
1237
1223
  let description = `${project.name} - ${project.root}`;
1238
- const packageJsonPath = chunkG3JMIIRF_cjs.joinPaths(project.root, "package.json");
1224
+ const packageJsonPath = chunkEHPPIARR_cjs.joinPaths(project.root, "package.json");
1239
1225
  if (fs$1.existsSync(packageJsonPath)) {
1240
1226
  const packageJsonFile = await fs.readFile(packageJsonPath, "utf8");
1241
1227
  const packageJson = JSON.parse(packageJsonFile);
@@ -1309,10 +1295,10 @@ ${closedIssueEmoji}${config5.settings.closedIssueMessage}${issues}`;
1309
1295
 
1310
1296
  // src/commit/run.ts
1311
1297
  async function runCommit(commitizenFile, dryRun = false) {
1312
- const workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
1298
+ const workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
1313
1299
  const state = await createState(workspaceConfig);
1314
1300
  if (dryRun) {
1315
- chunkG3JMIIRF_cjs.writeInfo("Running in dry mode.", workspaceConfig);
1301
+ chunkEHPPIARR_cjs.writeInfo("Running in dry mode.", workspaceConfig);
1316
1302
  }
1317
1303
  console.log(chalkTemplate__default.default`
1318
1304
  {bold.#999999 ----------------------------------------}
@@ -1322,7 +1308,7 @@ async function runCommit(commitizenFile, dryRun = false) {
1322
1308
  `);
1323
1309
  state.answers = await askQuestions(state);
1324
1310
  const message = formatCommitMessage(state, workspaceConfig);
1325
- const commitMsgFile = chunkG3JMIIRF_cjs.joinPaths(getGitDir(), "COMMIT_EDITMSG");
1311
+ const commitMsgFile = chunkEHPPIARR_cjs.joinPaths(getGitDir(), "COMMIT_EDITMSG");
1326
1312
  console.log(chalkTemplate__default.default`
1327
1313
  {bold.#999999 ----------------------------------------}
1328
1314
 
@@ -1335,14 +1321,14 @@ async function runCommit(commitizenFile, dryRun = false) {
1335
1321
  commandItems.push(...["--file", commitMsgFile]);
1336
1322
  const command = shellescape__default.default(commandItems);
1337
1323
  if (dryRun) {
1338
- chunkG3JMIIRF_cjs.writeDebug(
1324
+ chunkEHPPIARR_cjs.writeDebug(
1339
1325
  `Skipping execution [dry-run]: ${command.replace(commitMsgFile, ".git/COMMIT_EDITMSG")}`,
1340
1326
  workspaceConfig
1341
1327
  );
1342
- chunkG3JMIIRF_cjs.writeDebug(`Message [dry-run]: ${message}`, workspaceConfig);
1328
+ chunkEHPPIARR_cjs.writeDebug(`Message [dry-run]: ${message}`, workspaceConfig);
1343
1329
  } else {
1344
1330
  await fs__default.default.writeFile(commitMsgFile, message);
1345
- chunkL64XVBGM_cjs.run(workspaceConfig, command);
1331
+ chunkFH5OSXAJ_cjs.run(workspaceConfig, command);
1346
1332
  }
1347
1333
  }
1348
1334
  async function askQuestions(state) {
@@ -2371,7 +2357,7 @@ async function generateChangelogContent(releaseVersion, filepath, newContent, cu
2371
2357
  const header = await prettier.format(
2372
2358
  `![${(typeof workspaceConfig?.release.banner === "string" ? workspaceConfig.organization ? titleCase(
2373
2359
  typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization.name
2374
- ) : void 0 : workspaceConfig?.release.banner.alt) || "Branded release banner image"}](${bannerUrl || chunkG3JMIIRF_cjs.STORM_DEFAULT_RELEASE_BANNER})
2360
+ ) : void 0 : workspaceConfig?.release.banner.alt) || "Branded release banner image"}](${bannerUrl || chunkEHPPIARR_cjs.STORM_DEFAULT_RELEASE_BANNER})
2375
2361
 
2376
2362
  # Changelog ${project || workspaceConfig?.name ? "for" : ""}${workspaceConfig?.name ? ` ${titleCase(workspaceConfig.name)}` : ""}${project ? `${workspaceConfig?.name ? " -" : ""} ${titleCase(project)}` : ""}
2377
2363
 
@@ -2413,7 +2399,7 @@ function generateChangelogTitle(version, project, workspaceConfig) {
2413
2399
  if (!workspaceConfig?.name || !project) {
2414
2400
  return version;
2415
2401
  }
2416
- return `[${version}](https://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}/releases/tag/${project}%40${version}) (${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)})`;
2402
+ return `[${version}](https://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}/releases/tag/${project}%40${version}) (${(/* @__PURE__ */ new Date()).getMonth() + 1}/${(/* @__PURE__ */ new Date()).getDate()}/${(/* @__PURE__ */ new Date()).getFullYear()})`;
2417
2403
  }
2418
2404
  function parseChangelogMarkdown(contents) {
2419
2405
  const CHANGELOG_RELEASE_HEAD_RE = new RegExp(
@@ -2442,6 +2428,226 @@ function parseChangelogMarkdown(contents) {
2442
2428
  releases
2443
2429
  };
2444
2430
  }
2431
+
2432
+ // src/release/github.ts
2433
+ var StormGithubRemoteReleaseClient = class extends github.GithubRemoteReleaseClient {
2434
+ #remoteRepoData;
2435
+ #workspaceConfig;
2436
+ /**
2437
+ * Creates an instance of {@link StormGithubRemoteReleaseClient}.
2438
+ *
2439
+ * @param remoteRepoData - Data about the remote repository
2440
+ * @param createReleaseConfig - Configuration for creating releases
2441
+ * @param tokenData - Token data for authentication
2442
+ * @param workspaceConfig - The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
2443
+ */
2444
+ constructor(remoteRepoData, createReleaseConfig, tokenData, workspaceConfig) {
2445
+ super(remoteRepoData, createReleaseConfig, tokenData);
2446
+ this.#remoteRepoData = remoteRepoData;
2447
+ this.#workspaceConfig = workspaceConfig;
2448
+ }
2449
+ createPostGitTask(releaseVersion, changelogContents, dryRun) {
2450
+ return async (latestCommit) => {
2451
+ if (!this.#workspaceConfig) {
2452
+ this.#workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
2453
+ }
2454
+ devkit.output.logSingleLine(`Creating GitHub Release`);
2455
+ const name = releaseVersion.gitTag.includes("@") ? releaseVersion.gitTag.replace(new RegExp(`^@${this.#workspaceConfig.name}/`), "").replace(/@.*$/, "") : releaseVersion.gitTag;
2456
+ await this.createOrUpdateRelease(
2457
+ releaseVersion,
2458
+ `![${(typeof this.#workspaceConfig.release.banner === "string" ? this.#workspaceConfig.organization ? titleCase(
2459
+ typeof this.#workspaceConfig.organization === "string" ? this.#workspaceConfig.organization : this.#workspaceConfig.organization.name
2460
+ ) : void 0 : this.#workspaceConfig.release.banner.alt) || "Release banner header"}](${typeof this.#workspaceConfig.release.banner === "string" ? this.#workspaceConfig.release.banner : this.#workspaceConfig.release.banner?.url})
2461
+ ${this.#workspaceConfig.release.header || ""}
2462
+
2463
+ # ${name ? `${titleCase(name)} ` : ""}v${releaseVersion.rawVersion}
2464
+
2465
+ We at [${this.#workspaceConfig.organization ? titleCase(
2466
+ typeof this.#workspaceConfig.organization === "string" ? this.#workspaceConfig.organization : this.#workspaceConfig.organization.name
2467
+ ) : ""}](${this.#workspaceConfig.homepage}) are very excited to announce the v${releaseVersion.rawVersion} release of the ${name ? this.#workspaceConfig.name ? `${titleCase(this.#workspaceConfig.name)} - ${titleCase(name)}` : titleCase(name) : this.#workspaceConfig.name ? titleCase(this.#workspaceConfig.name) : "Storm Software"} project! \u{1F680}
2468
+
2469
+ These changes are released under the ${this.#workspaceConfig.license.includes("license") ? this.#workspaceConfig.license : `${this.#workspaceConfig.license} license`}. You can find more details on [our licensing page](${this.#workspaceConfig.licensing}). You can find guides, API references, and other documentation around this release (and much more) on [our documentation site](${this.#workspaceConfig.docs}).
2470
+
2471
+ If you have any questions or comments, feel free to reach out to the team on [Discord](${this.#workspaceConfig.socials.discord}) or [our contact page](${this.#workspaceConfig.contact}). Please help us spread the word by giving [this repository](https://github.com/${typeof this.#workspaceConfig.organization === "string" ? this.#workspaceConfig.organization : this.#workspaceConfig.organization?.name}/${this.#workspaceConfig.name}) a star \u2B50 on GitHub or [posting on X (Twitter)](https://x.com/intent/tweet?text=Check%20out%20the%20latest%20@${this.#workspaceConfig.socials.twitter}%20release%20${name ? `${titleCase(name)?.replaceAll(" ", "%20")}%20` : ""}v${releaseVersion.rawVersion}%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/${typeof this.#workspaceConfig.organization === "string" ? this.#workspaceConfig.organization : this.#workspaceConfig.organization?.name}/${this.#workspaceConfig.name}/releases/tag/${releaseVersion.gitTag}) about this release!
2472
+
2473
+ ## Release Notes
2474
+
2475
+ ${changelogContents.replaceAll(
2476
+ `## ${generateChangelogTitle(
2477
+ releaseVersion.rawVersion,
2478
+ name,
2479
+ this.#workspaceConfig
2480
+ )}`,
2481
+ ""
2482
+ ).replaceAll(
2483
+ `# ${generateChangelogTitle(releaseVersion.rawVersion, name, this.#workspaceConfig)}`,
2484
+ ""
2485
+ )}
2486
+
2487
+ ---
2488
+
2489
+ ${this.#workspaceConfig.release.footer}
2490
+ `,
2491
+ latestCommit,
2492
+ { dryRun }
2493
+ );
2494
+ };
2495
+ }
2496
+ /**
2497
+ * Get remote repository data, attempting to resolve it if not already set.
2498
+ */
2499
+ getRemoteRepoData() {
2500
+ if (!this.#remoteRepoData) {
2501
+ let githubRepoData = super.getRemoteRepoData();
2502
+ if (!githubRepoData) {
2503
+ githubRepoData = getGitHubRepoData();
2504
+ if (!githubRepoData) {
2505
+ devkit.output.error({
2506
+ title: `Unable to create a GitHub release because the GitHub repo slug could not be determined.`,
2507
+ bodyLines: [
2508
+ `Please ensure you have a valid GitHub remote configured. You can run \`git remote -v\` to list your current remotes.`
2509
+ ]
2510
+ });
2511
+ process.exit(1);
2512
+ }
2513
+ }
2514
+ this.#remoteRepoData = githubRepoData;
2515
+ }
2516
+ return this.#remoteRepoData;
2517
+ }
2518
+ };
2519
+ function getGitHubRepoData(remoteName = "origin", createReleaseConfig = "github") {
2520
+ try {
2521
+ const remoteUrl = childProcess.execSync(`git remote get-url ${remoteName}`, {
2522
+ encoding: "utf8",
2523
+ stdio: "pipe"
2524
+ }).trim();
2525
+ let hostname = github.defaultCreateReleaseProvider.hostname;
2526
+ let apiBaseUrl = github.defaultCreateReleaseProvider.apiBaseUrl;
2527
+ if (createReleaseConfig && typeof createReleaseConfig !== "string") {
2528
+ hostname = createReleaseConfig.hostname;
2529
+ apiBaseUrl = createReleaseConfig.apiBaseUrl;
2530
+ }
2531
+ const escapedHostname = hostname.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2532
+ const regexString = `${escapedHostname}[/:]([\\w.-]+/[\\w.-]+)(\\.git)?`;
2533
+ const regex = new RegExp(regexString);
2534
+ const match = remoteUrl?.match(regex);
2535
+ if (match && match[1]) {
2536
+ return {
2537
+ hostname,
2538
+ apiBaseUrl,
2539
+ // Ensure any trailing .git is stripped
2540
+ slug: match[1].replace(/\.git$/, "")
2541
+ };
2542
+ } else {
2543
+ throw new Error(
2544
+ `Could not extract "user/repo" data from the resolved remote URL: ${remoteUrl}`
2545
+ );
2546
+ }
2547
+ } catch (error) {
2548
+ devkit.output.error({
2549
+ title: `Failed to get GitHub repo data`,
2550
+ bodyLines: [error.message]
2551
+ });
2552
+ return void 0;
2553
+ }
2554
+ }
2555
+ async function resolveTokenData(hostname) {
2556
+ const tokenFromEnv = process.env.STORM_BOT_GITHUB_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
2557
+ if (tokenFromEnv) {
2558
+ return { token: tokenFromEnv, headerName: "Authorization" };
2559
+ }
2560
+ const ghCLIPath = devkit.joinPathFragments(
2561
+ process.env.XDG_CONFIG_HOME || devkit.joinPathFragments(os.homedir(), ".config"),
2562
+ "gh",
2563
+ "hosts.yml"
2564
+ );
2565
+ if (fs$1.existsSync(ghCLIPath)) {
2566
+ const yamlContents = await fs$1.promises.readFile(ghCLIPath, "utf8");
2567
+ const ghCLIConfig = yaml.parse(yamlContents);
2568
+ if (ghCLIConfig[hostname]) {
2569
+ if (ghCLIConfig[hostname].oauth_token) {
2570
+ return ghCLIConfig[hostname].oauth_token;
2571
+ }
2572
+ if (ghCLIConfig[hostname].user && ghCLIConfig[hostname].git_protocol === "ssh") {
2573
+ const token = childProcess.execSync(`gh auth token`, {
2574
+ encoding: "utf8",
2575
+ stdio: "pipe",
2576
+ windowsHide: false
2577
+ }).trim();
2578
+ return { token, headerName: "Authorization" };
2579
+ }
2580
+ }
2581
+ }
2582
+ if (hostname !== "github.com") {
2583
+ console.log(
2584
+ `Warning: It was not possible to automatically resolve a GitHub token from your environment for hostname ${hostname}. If you set the GITHUB_TOKEN or GH_TOKEN environment variable, that will be used for GitHub API requests.`
2585
+ );
2586
+ }
2587
+ throw new Error(
2588
+ `Unable to resolve a GitHub token for hostname ${hostname}. Please set the GITHUB_TOKEN or GH_TOKEN environment variable, or ensure you have an active session via the official gh CLI tool (https://cli.github.com).`
2589
+ );
2590
+ }
2591
+ async function makeGithubRequest(config5, url, opts = {}) {
2592
+ return await axios__default.default(url, {
2593
+ ...opts,
2594
+ baseURL: config5.apiBaseUrl,
2595
+ headers: {
2596
+ ...opts.headers,
2597
+ Authorization: config5.token ? `Bearer ${config5.token}` : void 0
2598
+ }
2599
+ });
2600
+ }
2601
+ async function createGithubRemoteReleaseClient(workspaceConfig, remoteName = "origin") {
2602
+ const repoData = getGitHubRepoData(remoteName, "github");
2603
+ if (!repoData) {
2604
+ throw new Error(
2605
+ `Unable to create a remote release client because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
2606
+ );
2607
+ }
2608
+ return new StormGithubRemoteReleaseClient(
2609
+ repoData,
2610
+ {
2611
+ provider: "github",
2612
+ hostname: repoData.hostname,
2613
+ apiBaseUrl: repoData.apiBaseUrl
2614
+ },
2615
+ await resolveTokenData(repoData.hostname),
2616
+ workspaceConfig
2617
+ );
2618
+ }
2619
+ async function isUserAnOrganizationMember(userId, config5, remoteName = "origin") {
2620
+ try {
2621
+ const repoData = getGitHubRepoData(remoteName, "github");
2622
+ if (!repoData) {
2623
+ throw new Error(
2624
+ `Unable to validate GitHub actor because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
2625
+ );
2626
+ }
2627
+ const tokenData = await resolveTokenData(repoData.hostname);
2628
+ if (!tokenData.token) {
2629
+ throw new Error(
2630
+ `Unable to validate GitHub actor because no token was provided. Please set the GITHUB_TOKEN or GH_TOKEN environment variable, or ensure you have an active session via the official gh CLI tool (https://cli.github.com).`
2631
+ );
2632
+ }
2633
+ const result = await makeGithubRequest(
2634
+ {
2635
+ repo: repoData.slug,
2636
+ hostname: repoData.hostname,
2637
+ apiBaseUrl: repoData.apiBaseUrl,
2638
+ token: tokenData?.token || null
2639
+ },
2640
+ `/orgs/${typeof config5.organization === "string" ? config5.organization : config5.organization?.name}/members/${userId}`,
2641
+ {}
2642
+ );
2643
+ if (result.status !== 204) {
2644
+ return false;
2645
+ }
2646
+ return true;
2647
+ } catch {
2648
+ return false;
2649
+ }
2650
+ }
2445
2651
  function createGitTagValues(releaseGroups, releaseGroupToFilteredProjects, versionData) {
2446
2652
  const tags = [];
2447
2653
  for (const releaseGroup of releaseGroups) {
@@ -2588,30 +2794,45 @@ async function commitChanges({
2588
2794
  verbose: isVerbose2
2589
2795
  });
2590
2796
  }
2797
+
2798
+ // src/utilities/omit.ts
2799
+ function omit(obj, keys) {
2800
+ const result = { ...obj };
2801
+ for (let i = 0; i < keys.length; i++) {
2802
+ const key = keys[i];
2803
+ if (key && key in result) {
2804
+ delete result[key];
2805
+ }
2806
+ }
2807
+ return result;
2808
+ }
2591
2809
  var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.default {
2592
2810
  /**
2593
2811
  * The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
2594
2812
  */
2595
- workspaceConfig = null;
2596
- /**
2597
- * The configuration object for the ChangelogRenderer, which includes the changes, version, project, and other options.
2598
- */
2599
- config;
2813
+ workspaceConfig;
2600
2814
  /**
2601
2815
  * A ChangelogRenderer class takes in the determined changes and other relevant metadata and returns a string, or a Promise of a string of changelog contents (usually markdown).
2602
2816
  *
2603
2817
  * @param config - The configuration object for the ChangelogRenderer
2604
2818
  */
2605
2819
  constructor(config5) {
2606
- super(config5);
2607
- this.config = {
2608
- ...config5,
2609
- repoData: config5.remoteReleaseClient.getRemoteRepoData()
2820
+ const resolvedConfig = {
2821
+ entryWhenNoChanges: false,
2822
+ conventionalCommitsConfig: conventionalCommits.DEFAULT_CONVENTIONAL_COMMITS_CONFIG,
2823
+ ...config5
2610
2824
  };
2825
+ super(resolvedConfig);
2826
+ this.workspaceConfig = config5.changelogRenderOptions.workspaceConfig;
2611
2827
  }
2612
2828
  async render() {
2613
- this.workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
2614
- return await super.render();
2829
+ if (!this.workspaceConfig) {
2830
+ this.workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
2831
+ }
2832
+ this.remoteReleaseClient = await createGithubRemoteReleaseClient(
2833
+ this.workspaceConfig
2834
+ );
2835
+ return super.render();
2615
2836
  }
2616
2837
  preprocessChanges() {
2617
2838
  this.relevantChanges = [...this.changes];
@@ -2690,7 +2911,7 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
2690
2911
  renderDependencyBumps() {
2691
2912
  const markdownLines = ["", "### Updated Dependencies", ""];
2692
2913
  this.dependencyBumps?.forEach(({ dependencyName, newVersion }) => {
2693
- const markdownLine = `- Updated ${dependencyName} to ${newVersion}`;
2914
+ const markdownLine = `- Updated **${dependencyName}** to **v${newVersion}**`;
2694
2915
  if (!markdownLines.includes(markdownLine)) {
2695
2916
  markdownLines.push(markdownLine);
2696
2917
  }
@@ -2720,7 +2941,7 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
2720
2941
  }
2721
2942
  }
2722
2943
  }
2723
- if (this.config.repoData && this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
2944
+ if (this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
2724
2945
  await Promise.all(
2725
2946
  [..._authors.keys()].map(async (authorName) => {
2726
2947
  const meta = _authors.get(authorName);
@@ -2777,7 +2998,7 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
2777
2998
  extraLinesStr = extraLines.filter((l) => l.trim().length > 0).map((l) => `${indentation}${l}`).join("\n");
2778
2999
  }
2779
3000
  let changeLine = "- " + (!this.isVersionPlans && change.scope ? `**${change.scope.trim()}:** ` : "") + description;
2780
- if (this.config.repoData && change.githubReferences) {
3001
+ if (change.githubReferences) {
2781
3002
  changeLine += this.remoteReleaseClient.formatReferences(
2782
3003
  change.githubReferences
2783
3004
  );
@@ -2788,1486 +3009,364 @@ var StormChangelogRenderer = class extends DefaultChangelogRenderer__default.def
2788
3009
  return changeLine;
2789
3010
  }
2790
3011
  };
2791
- function getGitHubRepoData(remoteName = "origin", createReleaseConfig) {
2792
- try {
2793
- const remoteUrl = childProcess.execSync(`git remote get-url ${remoteName}`, {
2794
- encoding: "utf8",
2795
- stdio: "pipe"
2796
- }).trim();
2797
- let hostname = github.defaultCreateReleaseProvider.hostname;
2798
- let apiBaseUrl = github.defaultCreateReleaseProvider.apiBaseUrl;
2799
- if (createReleaseConfig && typeof createReleaseConfig !== "string") {
2800
- hostname = createReleaseConfig.hostname;
2801
- apiBaseUrl = createReleaseConfig.apiBaseUrl;
2802
- }
2803
- const escapedHostname = hostname.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2804
- const regexString = `${escapedHostname}[/:]([\\w.-]+/[\\w.-]+)(\\.git)?`;
2805
- const regex = new RegExp(regexString);
2806
- const match = remoteUrl?.match(regex);
2807
- if (match && match[1]) {
2808
- return {
2809
- hostname,
2810
- apiBaseUrl,
2811
- // Ensure any trailing .git is stripped
2812
- slug: match[1].replace(/\.git$/, "")
2813
- };
2814
- } else {
2815
- throw new Error(
2816
- `Could not extract "user/repo" data from the resolved remote URL: ${remoteUrl}`
2817
- );
3012
+
3013
+ // src/release/config.ts
3014
+ var DEFAULT_CONVENTIONAL_COMMITS_CONFIG2 = {
3015
+ questions: DEFAULT_MONOREPO_COMMIT_QUESTIONS,
3016
+ types: DEFAULT_COMMIT_TYPES
3017
+ };
3018
+ var DEFAULT_RELEASE_TAG_PATTERN = "{projectName}@{version}";
3019
+ var DEFAULT_RELEASE_GROUP_CONFIG = {
3020
+ projectsRelationship: "independent",
3021
+ changelog: {
3022
+ createRelease: "github",
3023
+ entryWhenNoChanges: false,
3024
+ file: false,
3025
+ renderOptions: {
3026
+ authors: false,
3027
+ commitReferences: true,
3028
+ versionTitleDate: true
2818
3029
  }
2819
- } catch (error) {
2820
- devkit.output.error({
2821
- title: `Failed to get GitHub repo data`,
2822
- bodyLines: [error.message]
2823
- });
2824
- return void 0;
3030
+ },
3031
+ version: {
3032
+ currentVersionResolver: "git-tag",
3033
+ specifierSource: "conventional-commits",
3034
+ groupPreVersionCommand: "pnpm build"
3035
+ },
3036
+ releaseTag: { pattern: DEFAULT_RELEASE_TAG_PATTERN }
3037
+ };
3038
+ var DEFAULT_JS_RELEASE_GROUP_CONFIG = {
3039
+ ...DEFAULT_RELEASE_GROUP_CONFIG,
3040
+ projects: ["packages/*"],
3041
+ version: {
3042
+ ...DEFAULT_RELEASE_GROUP_CONFIG.version,
3043
+ versionActions: "@storm-software/workspace-tools/release/js-version-actions",
3044
+ versionActionsOptions: {
3045
+ currentVersionResolver: "git-tag",
3046
+ specifierSource: "conventional-commits"
3047
+ },
3048
+ manifestRootsToUpdate: [
3049
+ "{projectRoot}",
3050
+ {
3051
+ path: "dist/{projectRoot}",
3052
+ preserveLocalDependencyProtocols: false
3053
+ }
3054
+ ]
2825
3055
  }
2826
- }
2827
- async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion, changelogContents, latestCommit, { dryRun }) {
2828
- const githubRepoData = getGitHubRepoData(void 0, createReleaseConfig);
2829
- if (!githubRepoData) {
2830
- devkit.output.error({
2831
- title: `Unable to create a GitHub release because the GitHub repo slug could not be determined.`,
2832
- bodyLines: [
2833
- `Please ensure you have a valid GitHub remote configured. You can run \`git remote -v\` to list your current remotes.`
2834
- ]
2835
- });
2836
- process.exit(1);
3056
+ };
3057
+ var DEFAULT_RUST_RELEASE_GROUP_CONFIG = {
3058
+ ...DEFAULT_RELEASE_GROUP_CONFIG,
3059
+ projects: ["crates/*"],
3060
+ version: {
3061
+ ...DEFAULT_RELEASE_GROUP_CONFIG.version,
3062
+ versionActions: "@storm-software/workspace-tools/release/rust-version-actions",
3063
+ versionActionsOptions: {
3064
+ currentVersionResolver: "git-tag",
3065
+ specifierSource: "conventional-commits"
3066
+ },
3067
+ manifestRootsToUpdate: ["{projectRoot}"]
2837
3068
  }
2838
- const tokenData = await resolveTokenData(githubRepoData.hostname);
2839
- const githubRequestConfig = {
2840
- repo: githubRepoData.slug,
2841
- hostname: githubRepoData.hostname,
2842
- apiBaseUrl: githubRepoData.apiBaseUrl,
2843
- token: tokenData?.token || null
2844
- };
2845
- let existingGithubReleaseForVersion;
2846
- try {
2847
- existingGithubReleaseForVersion = await getGithubReleaseByTag(
2848
- githubRequestConfig,
2849
- releaseVersion.gitTag
2850
- );
2851
- } catch (err) {
2852
- if (err.response?.status === 401) {
2853
- devkit.output.error({
2854
- title: `Unable to resolve data via the GitHub API. You can use any of the following options to resolve this:`,
2855
- bodyLines: [
2856
- "- Set the `GITHUB_TOKEN` or `GH_TOKEN` environment variable to a valid GitHub token with `repo` scope",
2857
- "- Have an active session via the official gh CLI tool (https://cli.github.com) in your current terminal"
2858
- ]
2859
- });
2860
- process.exit(1);
2861
- }
2862
- if (err.response?.status === 404) ; else {
2863
- throw err;
2864
- }
2865
- }
2866
- const logTitle = `https://${githubRepoData.hostname}/${githubRepoData.slug}/releases/tag/${releaseVersion.gitTag}`;
2867
- if (existingGithubReleaseForVersion) {
2868
- console.error(`UPDATE ${logTitle}${dryRun ? " [dry-run]" : ""}`);
2869
- } else {
2870
- console.error(`CREATE ${logTitle}${dryRun ? " [dry-run]" : ""}`);
2871
- }
2872
- console.log("");
2873
- printChanges.printDiff(
2874
- existingGithubReleaseForVersion?.body ? existingGithubReleaseForVersion.body : "",
2875
- changelogContents,
2876
- 3,
2877
- shared.noDiffInChangelogMessage
2878
- );
2879
- if (!dryRun) {
2880
- await createOrUpdateGithubReleaseInternal(
2881
- githubRequestConfig,
2882
- {
2883
- version: releaseVersion.gitTag,
2884
- prerelease: releaseVersion.isPrerelease,
2885
- body: changelogContents,
2886
- commit: latestCommit
2887
- },
2888
- existingGithubReleaseForVersion
2889
- );
2890
- }
2891
- }
2892
- async function createOrUpdateGithubReleaseInternal(githubRequestConfig, release, existingGithubReleaseForVersion) {
2893
- const result = await syncGithubRelease(
2894
- githubRequestConfig,
2895
- release,
2896
- existingGithubReleaseForVersion
2897
- );
2898
- if (result.status === "manual") {
2899
- if (result.error) {
2900
- process.exitCode = 1;
2901
- if (result.error.response?.data) {
2902
- devkit.output.error({
2903
- title: `A GitHub API Error occurred when creating/updating the release`,
2904
- bodyLines: [
2905
- `GitHub Error: ${JSON.stringify(result.error.response.data)}`,
2906
- `---`,
2907
- `Request Data:`,
2908
- `Repo: ${githubRequestConfig.repo}`,
2909
- `Token: ${githubRequestConfig.token}`,
2910
- `Body: ${JSON.stringify(result.requestData)}`
2911
- ]
2912
- });
2913
- } else {
2914
- console.log(result.error);
2915
- console.error(
2916
- `An unknown error occurred while trying to create a release on GitHub, please report this on https://github.com/nrwl/nx (NOTE: make sure to redact your GitHub token from the error message!)`
2917
- );
2918
- }
2919
- }
2920
- const shouldContinueInGitHub = await promptForContinueInGitHub();
2921
- if (!shouldContinueInGitHub) {
2922
- return;
2923
- }
2924
- const open = chunkG3JMIIRF_cjs.__require("open");
2925
- await open(result.url).then(() => {
2926
- console.info(
2927
- `
2928
- Follow up in the browser to manually create the release:
2929
-
2930
- ` + result.url + `
2931
- `
2932
- );
2933
- }).catch(() => {
2934
- console.info(
2935
- `Open this link to manually create a release:
2936
- ` + result.url + "\n"
2937
- );
2938
- });
2939
- if (result.error) {
2940
- console.error(result.error);
2941
- process.exitCode = 1;
2942
- }
2943
- await open(result.url).then(() => {
2944
- console.info(
2945
- `Follow up in the browser to manually create the release.`
2946
- );
2947
- }).catch(() => {
2948
- console.info(
2949
- `Open this link to manually create a release:
2950
- ` + result.url + "\n"
2951
- );
2952
- });
2953
- }
2954
- }
2955
- async function promptForContinueInGitHub() {
2956
- try {
2957
- const reply = await enquirer.prompt([
2958
- {
2959
- name: "open",
2960
- message: "Do you want to finish creating the release manually in your browser?",
2961
- type: "autocomplete",
2962
- choices: [
2963
- {
2964
- name: "Yes",
2965
- hint: "It will pre-populate the form for you"
2966
- },
2967
- {
2968
- name: "No"
2969
- }
2970
- ],
2971
- initial: 0
2972
- }
2973
- ]);
2974
- return reply.open === "Yes";
2975
- } catch {
2976
- process.stdout.write("\x1B[?25h");
2977
- process.exit(1);
2978
- }
2979
- }
2980
- async function syncGithubRelease(githubRequestConfig, release, existingGithubReleaseForVersion) {
2981
- const ghRelease = {
2982
- tag_name: release.version,
2983
- name: release.version,
2984
- body: release.body,
2985
- prerelease: release.prerelease,
2986
- // legacy specifies that the latest release should be determined based on the release creation date and higher semantic version.
2987
- make_latest: "legacy"
2988
- };
2989
- try {
2990
- const newGhRelease = await (existingGithubReleaseForVersion ? updateGithubRelease(
2991
- githubRequestConfig,
2992
- existingGithubReleaseForVersion.id,
2993
- ghRelease
2994
- ) : createGithubRelease(githubRequestConfig, {
2995
- ...ghRelease,
2996
- target_commitish: release.commit
2997
- }));
2998
- return {
2999
- status: existingGithubReleaseForVersion ? "updated" : "created",
3000
- id: newGhRelease.id,
3001
- url: newGhRelease.html_url
3002
- };
3003
- } catch (error) {
3004
- if (process.env.CI) {
3005
- console.error(
3006
- `An error occurred while trying to create a release on GitHub, please report this on https://github.com/storm-software/storm-ops (NOTE: make sure to redact your GitHub token from the error message!): ${typeof error?.message === "string" ? error?.message : `
3069
+ };
3070
+ var DEFAULT_RELEASE_CONFIG = {
3071
+ conventionalCommits: DEFAULT_CONVENTIONAL_COMMITS_CONFIG2,
3072
+ groups: {
3073
+ packages: DEFAULT_JS_RELEASE_GROUP_CONFIG,
3074
+ crates: DEFAULT_RUST_RELEASE_GROUP_CONFIG
3075
+ },
3076
+ changelog: {
3077
+ automaticFromRef: true,
3078
+ workspaceChangelog: false,
3079
+ projectChangelogs: true
3080
+ },
3081
+ releaseTag: { pattern: DEFAULT_RELEASE_TAG_PATTERN }
3082
+ };
3007
3083
 
3008
- ${error}`}`
3009
- );
3010
- throw new Error(
3011
- "`An error occurred while trying to create a release on GitHub in a CI environment",
3084
+ // src/release/release-client.ts
3085
+ function getReleaseGroupConfig(releaseConfig, workspaceConfig) {
3086
+ return !releaseConfig?.groups || Object.keys(releaseConfig.groups).length === 0 ? {} : Object.fromEntries(
3087
+ Object.entries(releaseConfig.groups).map(([name, group]) => {
3088
+ const config5 = chunkEHPPIARR_cjs.defu(
3089
+ {
3090
+ ...omit(DEFAULT_RELEASE_GROUP_CONFIG, ["changelog"]),
3091
+ ...group
3092
+ },
3012
3093
  {
3013
- cause: error
3094
+ changelog: {
3095
+ ...DEFAULT_RELEASE_GROUP_CONFIG.changelog,
3096
+ renderer: StormChangelogRenderer,
3097
+ renderOptions: {
3098
+ ...DEFAULT_RELEASE_GROUP_CONFIG.changelog.renderOptions,
3099
+ workspaceConfig
3100
+ }
3101
+ }
3014
3102
  }
3015
3103
  );
3016
- }
3017
- return {
3018
- status: "manual",
3019
- error,
3020
- url: githubNewReleaseURL(githubRequestConfig, release),
3021
- requestData: ghRelease
3022
- };
3023
- }
3024
- }
3025
- async function resolveTokenData(hostname) {
3026
- const tokenFromEnv = process.env.STORM_BOT_GITHUB_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
3027
- if (tokenFromEnv) {
3028
- return { token: tokenFromEnv, headerName: "Authorization" };
3029
- }
3030
- const ghCLIPath = devkit.joinPathFragments(
3031
- process.env.XDG_CONFIG_HOME || devkit.joinPathFragments(os.homedir(), ".config"),
3032
- "gh",
3033
- "hosts.yml"
3034
- );
3035
- if (fs$1.existsSync(ghCLIPath)) {
3036
- const yamlContents = await fs$1.promises.readFile(ghCLIPath, "utf8");
3037
- const ghCLIConfig = yaml.parse(yamlContents);
3038
- if (ghCLIConfig[hostname]) {
3039
- if (ghCLIConfig[hostname].oauth_token) {
3040
- return ghCLIConfig[hostname].oauth_token;
3041
- }
3042
- if (ghCLIConfig[hostname].user && ghCLIConfig[hostname].git_protocol === "ssh") {
3043
- const token = childProcess.execSync(`gh auth token`, {
3044
- encoding: "utf8",
3045
- stdio: "pipe",
3046
- windowsHide: false
3047
- }).trim();
3048
- return { token, headerName: "Authorization" };
3104
+ if (workspaceConfig?.workspaceRoot) {
3105
+ if (config5.changelog?.renderer && typeof config5.changelog?.renderer === "string" && config5.changelog?.renderer?.toString().startsWith("./")) {
3106
+ config5.changelog.renderer = chunkEHPPIARR_cjs.joinPaths(
3107
+ workspaceConfig.workspaceRoot,
3108
+ config5.changelog.renderer
3109
+ );
3110
+ }
3111
+ if (config5.version?.versionActions && config5.version.versionActions.startsWith("./")) {
3112
+ config5.version.versionActions = chunkEHPPIARR_cjs.joinPaths(
3113
+ workspaceConfig.workspaceRoot,
3114
+ config5.version?.versionActions
3115
+ );
3116
+ }
3049
3117
  }
3050
- }
3051
- }
3052
- if (hostname !== "github.com") {
3053
- console.log(
3054
- `Warning: It was not possible to automatically resolve a GitHub token from your environment for hostname ${hostname}. If you set the GITHUB_TOKEN or GH_TOKEN environment variable, that will be used for GitHub API requests.`
3055
- );
3056
- }
3057
- throw new Error(
3058
- `Unable to resolve a GitHub token for hostname ${hostname}. Please set the GITHUB_TOKEN or GH_TOKEN environment variable, or ensure you have an active session via the official gh CLI tool (https://cli.github.com).`
3118
+ return [name, config5];
3119
+ })
3059
3120
  );
3060
3121
  }
3061
- async function getGithubReleaseByTag(config5, tag) {
3062
- return (await makeGithubRequest(
3063
- config5,
3064
- `/repos/${config5.repo}/releases/tags/${tag}`,
3065
- {}
3066
- )).data;
3067
- }
3068
- async function makeGithubRequest(config5, url, opts = {}) {
3069
- return await axios__default.default(url, {
3070
- ...opts,
3071
- baseURL: config5.apiBaseUrl,
3072
- headers: {
3073
- ...opts.headers,
3074
- Authorization: config5.token ? `Bearer ${config5.token}` : void 0
3122
+ var StormReleaseClient = class _StormReleaseClient extends release.ReleaseClient {
3123
+ static async create(releaseConfig = {}, ignoreNxJsonConfig = false, workspaceConfig) {
3124
+ if (!workspaceConfig) {
3125
+ workspaceConfig = await chunkEHPPIARR_cjs.getWorkspaceConfig();
3075
3126
  }
3076
- });
3077
- }
3078
- async function createGithubRelease(config5, body) {
3079
- return (await makeGithubRequest(config5, `/repos/${config5.repo}/releases`, {
3080
- method: "POST",
3081
- data: body
3082
- })).data;
3083
- }
3084
- async function updateGithubRelease(config5, id, body) {
3085
- return (await makeGithubRequest(config5, `/repos/${config5.repo}/releases/${id}`, {
3086
- method: "PATCH",
3087
- data: body
3088
- })).data;
3089
- }
3090
- function githubNewReleaseURL(config5, release) {
3091
- let url = `https://${config5.hostname}/${config5.repo}/releases/new?tag=${release.version}&title=${release.version}&body=${encodeURIComponent(release.body)}&target=${release.commit}`;
3092
- if (release.prerelease) {
3093
- url += "&prerelease=true";
3094
- }
3095
- return url;
3096
- }
3097
- async function createGithubRemoteReleaseClient(remoteName = "origin") {
3098
- const repoData = getGitHubRepoData(remoteName, "github");
3099
- if (!repoData) {
3100
- throw new Error(
3101
- `Unable to create a remote release client because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
3102
- );
3103
- }
3104
- return new github.GithubRemoteReleaseClient(
3105
- repoData,
3106
- {
3107
- provider: "github",
3108
- hostname: repoData.hostname,
3109
- apiBaseUrl: repoData.apiBaseUrl
3110
- },
3111
- await resolveTokenData(repoData.hostname)
3112
- );
3113
- }
3114
- async function isUserAnOrganizationMember(userId, config5, remoteName = "origin") {
3115
- try {
3116
- const repoData = getGitHubRepoData(remoteName, "github");
3117
- if (!repoData) {
3118
- throw new Error(
3119
- `Unable to validate GitHub actor because the GitHub repo slug could not be determined. Please ensure you have a valid GitHub remote configured.`
3120
- );
3127
+ let projectGraph;
3128
+ try {
3129
+ projectGraph = devkit.readCachedProjectGraph();
3130
+ } catch {
3131
+ projectGraph = await devkit.createProjectGraphAsync({
3132
+ exitOnError: true,
3133
+ resetDaemonClient: true
3134
+ });
3121
3135
  }
3122
- const tokenData = await resolveTokenData(repoData.hostname);
3123
- if (!tokenData.token) {
3136
+ if (!projectGraph) {
3124
3137
  throw new Error(
3125
- `Unable to validate GitHub actor because no token was provided. Please set the GITHUB_TOKEN or GH_TOKEN environment variable, or ensure you have an active session via the official gh CLI tool (https://cli.github.com).`
3138
+ "Failed to load the project graph. Please run `nx reset`, then run the `storm-git commit` command again."
3126
3139
  );
3127
3140
  }
3128
- const result = await makeGithubRequest(
3129
- {
3130
- repo: repoData.slug,
3131
- hostname: repoData.hostname,
3132
- apiBaseUrl: repoData.apiBaseUrl,
3133
- token: tokenData?.token || null
3134
- },
3135
- `/orgs/${typeof config5.organization === "string" ? config5.organization : config5.organization?.name}/members/${userId}`,
3136
- {}
3141
+ return new _StormReleaseClient(
3142
+ projectGraph,
3143
+ releaseConfig,
3144
+ ignoreNxJsonConfig,
3145
+ workspaceConfig
3137
3146
  );
3138
- if (result.status !== 204) {
3139
- return false;
3140
- }
3141
- return true;
3142
- } catch {
3143
- return false;
3144
3147
  }
3145
- }
3146
-
3147
- // src/release/changelog.ts
3148
- function createAPI(overrideReleaseConfig) {
3149
- return async function releaseChangelog(args) {
3150
- const workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
3151
- const projectGraph$1 = await projectGraph.createProjectGraphAsync({ exitOnError: true });
3152
- const nxJson$1 = nxJson.readNxJson();
3153
- const userProvidedReleaseConfig = deepMergeJson.deepMergeJson(
3154
- nxJson$1.release ?? {},
3155
- overrideReleaseConfig ?? {}
3156
- );
3157
- const { error: configError, nxReleaseConfig } = await config$1.createNxReleaseConfig(
3158
- projectGraph$1,
3159
- await fileMapUtils.createProjectFileMapUsingProjectGraph(projectGraph$1),
3160
- userProvidedReleaseConfig
3161
- );
3162
- if (configError) {
3163
- return await config$1.handleNxReleaseConfigError(configError, false);
3164
- }
3165
- if (args.printConfig) {
3166
- return printConfig.printConfigAndExit({
3167
- userProvidedReleaseConfig,
3168
- nxReleaseConfig,
3169
- isDebug: args.printConfig === "debug"
3170
- });
3171
- }
3172
- if ((args.gitCommit === void 0 || args.gitTag === void 0 || args.stageChanges === void 0) && userProvidedReleaseConfig.git) {
3173
- const nxJsonMessage = await resolveNxJsonErrorMessage.resolveNxJsonConfigErrorMessage([
3174
- "release",
3175
- "git"
3176
- ]);
3177
- output.output.error({
3178
- title: `The "release.git" property in nx.json may not be used with the "nx release changelog" subcommand or programmatic API. Instead, configure git options for subcommands directly with "release.version.git" and "release.changelog.git".`,
3179
- bodyLines: [nxJsonMessage]
3180
- });
3181
- process.exit(1);
3182
- }
3183
- const {
3184
- error: filterError,
3185
- filterLog,
3186
- releaseGroups,
3187
- releaseGroupToFilteredProjects
3188
- } = filterReleaseGroups.filterReleaseGroups(
3189
- projectGraph$1,
3190
- nxReleaseConfig,
3191
- args.projects,
3192
- args.groups
3193
- );
3194
- if (filterError) {
3195
- output.output.error(filterError);
3196
- process.exit(1);
3197
- }
3198
- if (filterLog && process.env.NX_RELEASE_INTERNAL_SUPPRESS_FILTER_LOG !== "true") {
3199
- output.output.note(filterLog);
3200
- }
3201
- const rawVersionPlans = await versionPlans.readRawVersionPlans();
3202
- await versionPlans.setResolvedVersionPlansOnGroups(
3203
- rawVersionPlans,
3204
- releaseGroups,
3205
- Object.keys(projectGraph$1.nodes),
3206
- !!args.verbose
3207
- );
3208
- if (args.deleteVersionPlans === void 0) {
3209
- args.deleteVersionPlans = true;
3210
- }
3211
- const changelogGenerationEnabled = !!nxReleaseConfig?.changelog?.workspaceChangelog || nxReleaseConfig?.groups && Object.values(nxReleaseConfig?.groups).some((g) => g.changelog);
3212
- if (!changelogGenerationEnabled) {
3213
- output.output.warn({
3214
- title: `Changelogs are disabled. No changelog entries will be generated`,
3215
- bodyLines: [
3216
- `To explicitly enable changelog generation, configure "release.changelog.workspaceChangelog" or "release.changelog.projectChangelogs" in nx.json.`
3217
- ]
3218
- });
3219
- return {};
3220
- }
3221
- const tree$1 = new tree.FsTree(workspaceRoot.workspaceRoot, !!args.verbose);
3222
- const useAutomaticFromRef = nxReleaseConfig?.changelog?.automaticFromRef || args.firstRelease;
3223
- const { workspaceChangelogVersion, projectsVersionData } = resolveChangelogVersions(
3224
- args,
3225
- releaseGroups,
3226
- releaseGroupToFilteredProjects
3227
- );
3228
- const to = args.to || "HEAD";
3229
- const toSHA = await git.getCommitHash(to);
3230
- const headSHA = to === "HEAD" ? toSHA : await git.getCommitHash("HEAD");
3231
- const autoCommitEnabled = args.gitCommit ?? nxReleaseConfig.changelog?.git.commit;
3232
- if (autoCommitEnabled && headSHA !== toSHA) {
3233
- throw new Error(
3234
- `You are attempting to recreate the changelog for an old release (Head: "${headSHA}", To: "${toSHA}", From: "${args.from}"), but you have enabled auto-commit mode. Please disable auto-commit mode by updating your nx.json, or passing --git-commit=false`
3235
- );
3148
+ #releaseChangelog;
3149
+ /**
3150
+ * The release configuration used by this release client.
3151
+ */
3152
+ config;
3153
+ /**
3154
+ * The workspace configuration used by this release client.
3155
+ */
3156
+ workspaceConfig;
3157
+ /**
3158
+ * The project graph of the workspace.
3159
+ */
3160
+ projectGraph;
3161
+ /**
3162
+ * The project configurations of the workspace.
3163
+ */
3164
+ projectConfigurations;
3165
+ /**
3166
+ * The file system tree used by this release client.
3167
+ */
3168
+ tree;
3169
+ /**
3170
+ * Creates an instance of {@link StormReleaseClient}.
3171
+ *
3172
+ * @param projectGraph - The project graph of the workspace.
3173
+ * @param releaseConfig - Release configuration to use for the current release client. By default, it will be combined with any configuration in `nx.json`, but you can choose to use it as the sole source of truth by setting {@link ignoreNxJsonConfig} to true.
3174
+ * @param ignoreNxJsonConfig - Whether to ignore the nx.json configuration and use only the provided {@link releaseConfig}. Default is false.
3175
+ * @param workspaceConfig - Optional Storm workspace configuration object for logging purposes.
3176
+ */
3177
+ constructor(projectGraph, releaseConfig, ignoreNxJsonConfig, workspaceConfig) {
3178
+ let nxJson$1;
3179
+ if (!ignoreNxJsonConfig && fs$1.existsSync(chunkEHPPIARR_cjs.joinPaths(workspaceConfig.workspaceRoot, "nx.json"))) {
3180
+ nxJson$1 = nxJson.readNxJson();
3236
3181
  }
3237
- const commitMessage = args.gitCommitMessage || nxReleaseConfig.changelog?.git?.commitMessage;
3238
- const commitMessageValues = shared.createCommitMessageValues(
3239
- releaseGroups,
3240
- releaseGroupToFilteredProjects,
3241
- projectsVersionData,
3242
- commitMessage
3243
- );
3244
- const gitTagValues = args.gitTag ?? nxReleaseConfig.changelog?.git.tag ? createGitTagValues(
3245
- releaseGroups,
3246
- releaseGroupToFilteredProjects,
3247
- projectsVersionData
3248
- ) : [];
3249
- shared.handleDuplicateGitTags(gitTagValues);
3250
- const postGitTasks = [];
3251
- let workspaceChangelogChanges = [];
3252
- let workspaceChangelogCommits = [];
3253
- const versionPlansEnabledForWorkspaceChangelog = releaseGroups[0]?.resolvedVersionPlans;
3254
- if (versionPlansEnabledForWorkspaceChangelog) {
3255
- if (releaseGroups.length === 1) {
3256
- const releaseGroup = releaseGroups[0];
3257
- if (releaseGroup?.projectsRelationship === "fixed") {
3258
- const versionPlans = releaseGroup?.resolvedVersionPlans;
3259
- workspaceChangelogChanges = versionPlans.flatMap((vp) => {
3260
- const releaseType = versionPlanSemverReleaseTypeToChangelogType(
3261
- vp.groupVersionBump
3262
- );
3263
- let githubReferences = [];
3264
- let author = void 0;
3265
- const parsedCommit = vp.commit ? git.parseGitCommit(vp.commit, true) : null;
3266
- if (parsedCommit) {
3267
- githubReferences = parsedCommit.references;
3268
- author = parsedCommit.author;
3269
- }
3270
- if (!author) {
3271
- return [];
3272
- }
3273
- const changes = !vp.triggeredByProjects ? {
3274
- type: releaseType.type,
3275
- scope: "",
3276
- description: vp.message,
3277
- body: "",
3278
- isBreaking: releaseType.isBreaking,
3279
- githubReferences,
3280
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
3281
- authors: [author],
3282
- affectedProjects: "*"
3283
- } : vp.triggeredByProjects.map((project) => {
3284
- return {
3285
- type: releaseType.type,
3286
- scope: project,
3287
- description: vp.message,
3288
- body: "",
3289
- isBreaking: releaseType.isBreaking,
3290
- githubReferences,
3291
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
3292
- authors: [author],
3293
- affectedProjects: [project]
3294
- };
3295
- });
3296
- return changes;
3297
- }).filter(Boolean);
3298
- }
3299
- }
3300
- } else {
3301
- let workspaceChangelogFromRef = args.from || (await git.getLatestGitTagForPattern(
3302
- nxReleaseConfig.releaseTagPattern,
3303
- {},
3304
- {
3305
- checkAllBranchesWhen: nxReleaseConfig.releaseTagPatternCheckAllBranchesWhen,
3306
- // preid:
3307
- // workspacePreid ??
3308
- // projectsPreid?.[Object.keys(projectsPreid)[0]],
3309
- releaseTagPatternRequireSemver: nxReleaseConfig.releaseTagPatternRequireSemver,
3310
- releaseTagPatternStrictPreid: nxReleaseConfig.releaseTagPatternStrictPreid
3311
- }
3312
- ))?.tag;
3313
- if (!workspaceChangelogFromRef) {
3314
- if (useAutomaticFromRef) {
3315
- workspaceChangelogFromRef = await git.getFirstGitCommit();
3316
- if (args.verbose) {
3317
- console.log(
3318
- `Determined workspace --from ref from the first commit in the workspace: ${workspaceChangelogFromRef}`
3319
- );
3182
+ const config5 = chunkEHPPIARR_cjs.defu(
3183
+ {
3184
+ changelog: {
3185
+ renderOptions: {
3186
+ workspaceConfig
3320
3187
  }
3321
- } else {
3322
- throw new Error(
3323
- `Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`
3324
- );
3325
3188
  }
3326
- }
3327
- const workspaceChangelogFromSHA = await git.getCommitHash(
3328
- workspaceChangelogFromRef
3329
- );
3330
- workspaceChangelogCommits = await getCommits(
3331
- workspaceChangelogFromSHA,
3332
- toSHA
3333
- );
3334
- workspaceChangelogChanges = filterHiddenChanges(
3335
- workspaceChangelogCommits.map((c) => {
3336
- return {
3337
- type: c.type,
3338
- scope: c.scope,
3339
- description: c.description,
3340
- body: c.body,
3341
- isBreaking: c.isBreaking,
3342
- githubReferences: c.references,
3343
- authors: [c.author],
3344
- shortHash: c.shortHash,
3345
- revertedHashes: c.revertedHashes,
3346
- affectedProjects: "*"
3347
- };
3348
- }),
3349
- nxReleaseConfig.conventionalCommits
3350
- );
3351
- }
3352
- const workspaceChangelog = await generateChangelogForWorkspace({
3353
- tree: tree$1,
3354
- args,
3355
- nxReleaseConfig,
3356
- workspaceChangelogVersion,
3357
- changes: workspaceChangelogChanges,
3358
- // TODO: remove this after the changelog renderer is refactored to remove coupling with git commits
3359
- commits: filterHiddenCommits(
3360
- workspaceChangelogCommits,
3361
- nxReleaseConfig.conventionalCommits
3362
- )
3189
+ },
3190
+ {
3191
+ groups: getReleaseGroupConfig(releaseConfig, workspaceConfig)
3192
+ },
3193
+ {
3194
+ groups: getReleaseGroupConfig(nxJson$1.release ?? {}, workspaceConfig)
3195
+ },
3196
+ omit(releaseConfig, ["groups"]),
3197
+ nxJson$1.release ? omit(nxJson$1.release, ["groups"]) : {},
3198
+ omit(DEFAULT_RELEASE_CONFIG, ["groups"])
3199
+ );
3200
+ super(config5, true);
3201
+ chunkEHPPIARR_cjs.writeDebug(
3202
+ "Executing release with the following configuration",
3203
+ workspaceConfig
3204
+ );
3205
+ chunkEHPPIARR_cjs.writeDebug(config5, workspaceConfig);
3206
+ this.projectGraph = projectGraph;
3207
+ this.config = config5;
3208
+ this.workspaceConfig = workspaceConfig;
3209
+ this.tree = new tree.FsTree(workspaceConfig.workspaceRoot, false);
3210
+ this.#releaseChangelog = changelog.createAPI(config5, true);
3211
+ this.projectConfigurations = devkit.readProjectsConfigurationFromProjectGraph(projectGraph);
3212
+ }
3213
+ releaseChangelog = async (options) => {
3214
+ const result = await this.#releaseChangelog({
3215
+ ...options,
3216
+ gitCommit: false,
3217
+ gitTag: false
3363
3218
  });
3364
- if (workspaceChangelog && shouldCreateGitHubRelease(
3365
- nxReleaseConfig.changelog?.workspaceChangelog,
3366
- args.createRelease
3367
- )) {
3368
- postGitTasks.push(async (latestCommit) => {
3369
- const contents = formatGithubReleaseNotes(
3370
- workspaceChangelog.releaseVersion,
3371
- workspaceChangelog.contents,
3372
- null,
3373
- workspaceConfig
3374
- );
3375
- output.output.logSingleLine(`Creating GitHub Release
3376
-
3377
- ${contents}`);
3378
- await createOrUpdateGithubRelease(
3379
- nxReleaseConfig.changelog?.workspaceChangelog ? nxReleaseConfig.changelog?.workspaceChangelog.createRelease : github.defaultCreateReleaseProvider,
3380
- workspaceChangelog.releaseVersion,
3381
- contents,
3382
- latestCommit,
3383
- { dryRun: !!args.dryRun }
3384
- );
3385
- });
3386
- } else {
3387
- output.output.logSingleLine(
3388
- `Skipping GitHub Release for workspace changelog as it is disabled in the release group configuration`
3389
- );
3390
- }
3391
- const projectToAdditionalDependencyBumps = /* @__PURE__ */ new Map();
3392
- for (const releaseGroup of releaseGroups) {
3393
- if (releaseGroup.projectsRelationship !== "independent") {
3394
- continue;
3395
- }
3396
- for (const project of releaseGroup.projects) {
3397
- if (!projectsVersionData[project]?.newVersion) {
3398
- continue;
3399
- }
3400
- const dependentProjects = (projectsVersionData[project].dependentProjects || []).map((dep) => {
3401
- return {
3402
- dependencyName: dep.source,
3403
- newVersion: projectsVersionData[dep.source]?.newVersion
3404
- };
3405
- }).filter((b) => b.newVersion !== null);
3406
- for (const dependent of dependentProjects) {
3407
- const additionalDependencyBumpsForProject = (projectToAdditionalDependencyBumps.has(dependent.dependencyName) ? projectToAdditionalDependencyBumps.get(dependent.dependencyName) : []) ?? [];
3408
- additionalDependencyBumpsForProject.push({
3409
- dependencyName: project,
3410
- newVersion: projectsVersionData[project].newVersion
3411
- });
3412
- projectToAdditionalDependencyBumps.set(
3413
- dependent.dependencyName,
3414
- additionalDependencyBumpsForProject
3415
- );
3416
- }
3417
- }
3418
- }
3419
- const allProjectChangelogs = {};
3420
- for (const releaseGroup of releaseGroups) {
3421
- const config5 = releaseGroup.changelog;
3422
- if (config5 === false) {
3423
- continue;
3424
- }
3425
- const projects = args.projects?.length ? (
3426
- // 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
3427
- Array.from(releaseGroupToFilteredProjects.get(releaseGroup)).flatMap(
3428
- (project) => {
3429
- return [
3430
- project,
3431
- ...projectsVersionData[project]?.dependentProjects.map(
3432
- (dep) => dep.source
3433
- ) || []
3434
- ];
3435
- }
3436
- )
3437
- ) : (
3438
- // Otherwise, we use the full list of projects within the release group
3439
- releaseGroup.projects
3440
- );
3441
- const projectNodes = projects.map((name) => projectGraph$1.nodes[name]);
3442
- if (releaseGroup.projectsRelationship === "independent") {
3443
- for (const project of projectNodes) {
3444
- let changes = null;
3445
- let commits = void 0;
3446
- if (releaseGroup.resolvedVersionPlans) {
3447
- changes = releaseGroup.resolvedVersionPlans.filter((vp) => vp.projectVersionBumps[project.name]).map((vp) => {
3448
- const bumpForProject = vp.projectVersionBumps[project.name];
3449
- const releaseType = versionPlanSemverReleaseTypeToChangelogType(bumpForProject);
3450
- let githubReferences = [];
3451
- let authors = [];
3452
- const parsedCommit = vp.commit ? git.parseGitCommit(vp.commit, true) : null;
3453
- if (parsedCommit) {
3454
- githubReferences = parsedCommit.references;
3455
- authors = [parsedCommit.author];
3456
- }
3457
- return {
3458
- type: releaseType.type,
3459
- scope: project.name,
3460
- description: vp.message,
3461
- body: "",
3462
- isBreaking: releaseType.isBreaking,
3463
- affectedProjects: Object.keys(vp.projectVersionBumps),
3464
- githubReferences,
3465
- authors
3466
- };
3467
- }).filter(Boolean);
3468
- } else {
3469
- let fromRef = args.from || (await git.getLatestGitTagForPattern(
3470
- releaseGroup.releaseTagPattern,
3471
- {
3472
- projectName: project.name,
3473
- releaseGroupName: releaseGroup.name
3474
- },
3475
- releaseGroup.releaseTagPatternCheckAllBranchesWhen
3476
- ))?.tag;
3477
- if (!fromRef && useAutomaticFromRef) {
3478
- const firstCommit = await git.getFirstGitCommit();
3479
- const allCommits = await getCommits(firstCommit, toSHA);
3480
- const commitsForProject = allCommits.filter(
3481
- (c) => c.affectedFiles.find((f) => f.startsWith(project.data.root))
3219
+ if (result.projectChangelogs) {
3220
+ await Promise.all(
3221
+ Object.entries(result.projectChangelogs).map(
3222
+ async ([project, changelog]) => {
3223
+ if (!this.projectGraph.nodes[project]?.data.root) {
3224
+ chunkEHPPIARR_cjs.writeWarning(
3225
+ `A changelog was generated for ${project}, but it could not be found in the project graph. Skipping writing changelog file.`,
3226
+ this.workspaceConfig
3482
3227
  );
3483
- fromRef = commitsForProject[0]?.shortHash;
3484
- if (args.verbose) {
3485
- console.log(
3486
- `Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`
3487
- );
3228
+ } else if (changelog.contents) {
3229
+ const filePath = chunkEHPPIARR_cjs.joinPaths(
3230
+ this.projectGraph.nodes[project].data.root,
3231
+ "CHANGELOG.md"
3232
+ );
3233
+ let currentContent;
3234
+ if (fs$1.existsSync(filePath)) {
3235
+ currentContent = await fs.readFile(filePath, "utf8");
3488
3236
  }
3489
- commits = commitsForProject;
3490
- }
3491
- if (!fromRef && !commits) {
3492
- throw new Error(
3493
- `Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`
3237
+ chunkEHPPIARR_cjs.writeDebug(
3238
+ `\u270D\uFE0F Writing changelog for project ${project} to ${filePath}`,
3239
+ this.workspaceConfig
3494
3240
  );
3495
- }
3496
- if (!commits) {
3497
- commits = await getCommits(fromRef, toSHA);
3498
- }
3499
- const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(projectGraph$1);
3500
- const fileToProjectMap = createFileToProjectMap(
3501
- fileMap.projectFileMap
3502
- );
3503
- changes = filterHiddenChanges(
3504
- commits.map((c) => ({
3505
- type: c.type,
3506
- scope: c.scope,
3507
- description: c.description,
3508
- body: c.body,
3509
- isBreaking: c.isBreaking,
3510
- githubReferences: c.references,
3511
- // TODO: Implement support for Co-authored-by and adding multiple authors
3512
- authors: [c.author],
3513
- shortHash: c.shortHash,
3514
- revertedHashes: c.revertedHashes,
3515
- affectedProjects: commitChangesNonProjectFiles(
3516
- c,
3517
- fileMap.nonProjectFiles
3518
- ) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
3519
- })),
3520
- nxReleaseConfig.conventionalCommits
3521
- );
3522
- }
3523
- const projectChangelogs = await generateChangelogForProjects({
3524
- tree: tree$1,
3525
- args,
3526
- changes,
3527
- projectsVersionData,
3528
- releaseGroup,
3529
- projects: [project],
3530
- nxReleaseConfig,
3531
- projectToAdditionalDependencyBumps
3532
- });
3533
- for (const [projectName, projectChangelog] of Object.entries(
3534
- projectChangelogs
3535
- )) {
3536
- if (projectChangelogs && shouldCreateGitHubRelease(
3537
- releaseGroup.changelog,
3538
- args.createRelease
3539
- )) {
3540
- postGitTasks.push(async (latestCommit) => {
3541
- const contents = formatGithubReleaseNotes(
3542
- projectChangelog.releaseVersion,
3543
- projectChangelog.contents,
3544
- projectName,
3545
- workspaceConfig
3546
- );
3547
- output.output.logSingleLine(`Creating GitHub Release
3548
-
3549
- ${contents}`);
3550
- await createOrUpdateGithubRelease(
3551
- releaseGroup.changelog ? releaseGroup.changelog.createRelease : github.defaultCreateReleaseProvider,
3552
- projectChangelog.releaseVersion,
3553
- contents,
3554
- latestCommit,
3555
- { dryRun: !!args.dryRun }
3556
- );
3557
- });
3558
- } else {
3559
- output.output.logSingleLine(
3560
- `Skipping GitHub Release for ${projectName} as it is disabled in the release group configuration`
3241
+ const content = await generateChangelogContent(
3242
+ changelog.releaseVersion,
3243
+ filePath,
3244
+ changelog.contents,
3245
+ currentContent,
3246
+ project,
3247
+ this.workspaceConfig
3561
3248
  );
3562
- }
3563
- allProjectChangelogs[projectName] = projectChangelog;
3564
- }
3565
- }
3566
- } else {
3567
- let changes = [];
3568
- let commits = [];
3569
- if (releaseGroup.resolvedVersionPlans) {
3570
- changes = releaseGroup.resolvedVersionPlans.flatMap((vp) => {
3571
- const releaseType = versionPlanSemverReleaseTypeToChangelogType(
3572
- vp.groupVersionBump
3573
- );
3574
- let githubReferences = [];
3575
- let author = void 0;
3576
- const parsedCommit = vp.commit ? git.parseGitCommit(vp.commit, true) : null;
3577
- if (parsedCommit) {
3578
- githubReferences = parsedCommit.references;
3579
- author = parsedCommit.author;
3580
- }
3581
- const changes2 = !vp.triggeredByProjects ? {
3582
- type: releaseType.type,
3583
- scope: "",
3584
- description: vp.message,
3585
- body: "",
3586
- isBreaking: releaseType.isBreaking,
3587
- githubReferences,
3588
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
3589
- authors: [author],
3590
- affectedProjects: "*"
3591
- } : vp.triggeredByProjects.map((project) => {
3592
- return {
3593
- type: releaseType.type,
3594
- scope: project,
3595
- description: vp.message,
3596
- body: "",
3597
- isBreaking: releaseType.isBreaking,
3598
- githubReferences,
3599
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
3600
- authors: [author],
3601
- affectedProjects: [project]
3602
- };
3603
- });
3604
- return changes2;
3605
- }).filter(Boolean);
3606
- } else {
3607
- let fromRef = args.from || (await git.getLatestGitTagForPattern(
3608
- releaseGroup.releaseTagPattern,
3609
- {},
3610
- releaseGroup.releaseTagPatternCheckAllBranchesWhen
3611
- ))?.tag;
3612
- if (!fromRef) {
3613
- if (useAutomaticFromRef) {
3614
- fromRef = await git.getFirstGitCommit();
3615
- if (args.verbose) {
3616
- console.log(
3617
- `Determined release group --from ref from the first commit in the workspace: ${fromRef}`
3618
- );
3619
- }
3620
- } else {
3621
- throw new Error(
3622
- `Unable to determine the previous git tag. If this is the first release of your release group, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`
3249
+ this.tree.write(filePath, content);
3250
+ printChanges.printAndFlushChanges(
3251
+ this.tree,
3252
+ !!options.dryRun,
3253
+ 3,
3254
+ false,
3255
+ shared.noDiffInChangelogMessage,
3256
+ // Only print the change for the current changelog file at this point
3257
+ (f) => f.path === filePath
3623
3258
  );
3624
3259
  }
3625
3260
  }
3626
- const fromSHA = await git.getCommitHash(fromRef);
3627
- const { fileMap } = await fileMapUtils.createFileMapUsingProjectGraph(projectGraph$1);
3628
- const fileToProjectMap = createFileToProjectMap(
3629
- fileMap.projectFileMap
3630
- );
3631
- commits = await getCommits(fromSHA, toSHA);
3632
- changes = filterHiddenChanges(
3633
- commits.map((c) => ({
3634
- type: c.type,
3635
- scope: c.scope,
3636
- description: c.description,
3637
- body: c.body,
3638
- isBreaking: c.isBreaking,
3639
- githubReferences: c.references,
3640
- // TODO: Implement support for Co-authored-by and adding multiple authors
3641
- authors: [c.author],
3642
- shortHash: c.shortHash,
3643
- revertedHashes: c.revertedHashes,
3644
- affectedProjects: commitChangesNonProjectFiles(
3645
- c,
3646
- fileMap.nonProjectFiles
3647
- ) ? "*" : getProjectsAffectedByCommit(c, fileToProjectMap)
3648
- })),
3649
- nxReleaseConfig.conventionalCommits
3650
- );
3651
- }
3652
- const projectChangelogs = await generateChangelogForProjects({
3653
- tree: tree$1,
3654
- args,
3655
- changes,
3656
- projectsVersionData,
3657
- releaseGroup,
3658
- projects: projectNodes,
3659
- nxReleaseConfig,
3660
- projectToAdditionalDependencyBumps
3661
- });
3662
- for (const [projectName, projectChangelog] of Object.entries(
3663
- projectChangelogs
3664
- )) {
3665
- if (projectChangelogs && shouldCreateGitHubRelease(
3666
- releaseGroup.changelog,
3667
- args.createRelease
3668
- )) {
3669
- postGitTasks.push(async (latestCommit) => {
3670
- output.output.logSingleLine(`Creating GitHub Release`);
3671
- await createOrUpdateGithubRelease(
3672
- releaseGroup.changelog ? releaseGroup.changelog.createRelease : github.defaultCreateReleaseProvider,
3673
- projectChangelog.releaseVersion,
3674
- projectChangelog.contents,
3675
- latestCommit,
3676
- { dryRun: !!args.dryRun }
3677
- );
3678
- });
3679
- } else {
3680
- output.output.logSingleLine(
3681
- `Skipping GitHub Release for ${projectName} as it is disabled in the release group configuration`
3682
- );
3683
- }
3684
- allProjectChangelogs[projectName] = projectChangelog;
3685
- }
3686
- }
3261
+ )
3262
+ );
3263
+ this.applyChangesAndExit(options, result);
3687
3264
  }
3688
- await applyChangesAndExit(
3689
- args,
3690
- nxReleaseConfig,
3691
- tree$1,
3692
- toSHA,
3693
- postGitTasks,
3694
- commitMessageValues,
3695
- gitTagValues,
3696
- releaseGroups
3697
- );
3698
- return {
3699
- workspaceChangelog,
3700
- projectChangelogs: allProjectChangelogs
3701
- };
3265
+ return result;
3702
3266
  };
3703
- }
3704
- function resolveChangelogVersions(args, releaseGroups, releaseGroupToFilteredProjects) {
3705
- if (!args.version && !args.versionData) {
3706
- throw new Error(
3707
- `You must provide a version string and/or a versionData object.`
3708
- );
3709
- }
3710
- if (args.version && !semver.valid(args.version)) {
3711
- throw new Error(
3712
- `The given version "${args.version}" is not a valid semver version. Please provide your version in the format "1.0.0", "1.0.0-beta.1" etc`
3713
- );
3714
- }
3715
- const versionData = releaseGroups.reduce(
3716
- (versionData2, releaseGroup) => {
3717
- const releaseGroupProjectNames = Array.from(
3718
- releaseGroupToFilteredProjects.get(releaseGroup)
3719
- );
3720
- for (const projectName of releaseGroupProjectNames) {
3721
- if (!args.versionData) {
3722
- versionData2[projectName] = {
3723
- newVersion: args.version,
3724
- currentVersion: "",
3725
- // not relevant within changelog/commit generation
3726
- dependentProjects: []
3727
- // not relevant within changelog/commit generation
3728
- };
3729
- continue;
3730
- }
3731
- if (!args.versionData[projectName]) {
3732
- throw new Error(
3733
- `The provided versionData object does not contain a version for project "${projectName}". This suggests a filtering mismatch between the version and changelog command invocations.`
3734
- );
3735
- }
3267
+ checkChangelogFilesEnabled() {
3268
+ if (this.config.changelog?.workspaceChangelog && (this.config.changelog?.workspaceChangelog === true || this.config.changelog?.workspaceChangelog.file)) {
3269
+ return true;
3270
+ }
3271
+ for (const releaseGroup of Object.values(this.config.groups)) {
3272
+ if (releaseGroup.changelog && releaseGroup.changelog !== true && releaseGroup.changelog.file) {
3273
+ return true;
3736
3274
  }
3737
- return versionData2;
3738
- },
3739
- args.versionData || {}
3740
- );
3741
- return {
3742
- workspaceChangelogVersion: args.version,
3743
- projectsVersionData: versionData
3744
- };
3745
- }
3746
- async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTasks, commitMessageValues, gitTagValues, releaseGroups) {
3747
- let latestCommit = toSHA;
3748
- const changes = tree.listChanges();
3749
- const changelogFilesEnabled = checkChangelogFilesEnabled(nxReleaseConfig);
3750
- if (changelogFilesEnabled && !changes.length) {
3751
- output.output.warn({
3752
- title: `No changes detected for changelogs`,
3753
- bodyLines: [
3754
- `No changes were detected for any changelog files, so no changelog entries will be generated.`
3755
- ]
3756
- });
3757
- if (!postGitTasks.length) {
3758
- return;
3759
3275
  }
3760
- if (isCi.isCI()) {
3761
- output.output.warn({
3762
- title: `Skipped GitHub release creation because no changes were detected for any changelog files.`
3763
- });
3764
- return;
3276
+ return false;
3277
+ }
3278
+ isCI = () => {
3279
+ if (process.env.CI === "false") {
3280
+ return false;
3765
3281
  }
3766
- const shouldCreateGitHubReleaseAnyway = await promptForGitHubRelease();
3767
- if (!shouldCreateGitHubReleaseAnyway) {
3282
+ return process.env.CI || process.env.TF_BUILD === "true" || process.env.GITHUB_ACTIONS === "true" || process.env.BUILDKITE === "true" || process.env.CIRCLECI === "true" || process.env.CIRRUS_CI === "true" || process.env.TRAVIS === "true" || !!process.env["bamboo.buildKey"] || !!process.env["bamboo_buildKey"] || !!process.env.CODEBUILD_BUILD_ID || !!process.env.GITLAB_CI || !!process.env.HEROKU_TEST_RUN_ID || !!process.env.BUILD_ID || !!process.env.BUILD_NUMBER || !!process.env.BUILD_BUILDID || !!process.env.TEAMCITY_VERSION || !!process.env.JENKINS_URL || !!process.env.HUDSON_URL;
3283
+ };
3284
+ applyChangesAndExit = async (options, result) => {
3285
+ const postGitTasks = Object.values(result.projectChangelogs || {}).map((project) => project.postGitTask).filter(Boolean);
3286
+ const to = options.to || "HEAD";
3287
+ let latestCommit = await git.getCommitHash(to);
3288
+ const gitTagValues = options.gitTag ?? this.config.changelog?.git?.tag ? createGitTagValues(
3289
+ options.releaseGraph.releaseGroups,
3290
+ options.releaseGraph.releaseGroupToFilteredProjects,
3291
+ options.versionData
3292
+ ) : [];
3293
+ shared.handleDuplicateGitTags(gitTagValues);
3294
+ const commitMessageValues = shared.createCommitMessageValues(
3295
+ options.releaseGraph.releaseGroups,
3296
+ options.releaseGraph.releaseGroupToFilteredProjects,
3297
+ options.versionData,
3298
+ options.gitCommitMessage || this.config.changelog?.git?.commitMessage || "release(monorepo): Publish workspace release updates"
3299
+ );
3300
+ const changes = this.tree.listChanges();
3301
+ if (this.checkChangelogFilesEnabled() && !changes.length) {
3302
+ devkit.output.warn({
3303
+ title: `No changes detected for changelogs`,
3304
+ bodyLines: [
3305
+ `No changes were detected for any changelog files, so no changelog entries will be generated.`
3306
+ ]
3307
+ });
3308
+ if (!postGitTasks.length) {
3309
+ return;
3310
+ }
3311
+ for (const postGitTask of postGitTasks) {
3312
+ await postGitTask(latestCommit);
3313
+ }
3768
3314
  return;
3769
3315
  }
3770
- for (const postGitTask of postGitTasks) {
3771
- await postGitTask(latestCommit);
3772
- }
3773
- return;
3774
- }
3775
- const changedFiles = changes.map((f) => f.path);
3776
- let deletedFiles = [];
3777
- if (args.deleteVersionPlans) {
3778
- const planFiles = /* @__PURE__ */ new Set();
3779
- releaseGroups.forEach((group) => {
3780
- if (group.resolvedVersionPlans) {
3781
- group.resolvedVersionPlans.forEach((plan) => {
3782
- if (!args.dryRun) {
3783
- fs$1.rmSync(plan.absolutePath, { recursive: true, force: true });
3784
- if (args.verbose) {
3785
- console.log(`Removing ${plan.relativePath}`);
3786
- }
3787
- } else {
3788
- if (args.verbose) {
3789
- console.log(
3790
- `Would remove ${plan.relativePath}, but --dry-run was set`
3791
- );
3792
- }
3793
- }
3794
- planFiles.add(plan.relativePath);
3795
- });
3796
- }
3797
- });
3798
- deletedFiles = Array.from(planFiles);
3799
- }
3800
- if (args.gitCommit ?? nxReleaseConfig.changelog?.git.commit) {
3316
+ const changedFiles = changes.map((f) => f.path);
3801
3317
  await commitChanges({
3802
3318
  changedFiles,
3803
- deletedFiles,
3804
- isDryRun: !!args.dryRun,
3805
- isVerbose: !!args.verbose,
3319
+ deletedFiles: [],
3320
+ isDryRun: !!options.dryRun,
3321
+ isVerbose: !!options.verbose,
3806
3322
  gitCommitMessages: commitMessageValues,
3807
- gitCommitArgs: args.gitCommitArgs ?? nxReleaseConfig.changelog?.git.commitArgs
3323
+ gitCommitArgs: options.gitCommitArgs || this.config.changelog?.git?.commitArgs
3808
3324
  });
3809
3325
  latestCommit = await git.getCommitHash("HEAD");
3810
- } else if ((args.stageChanges ?? nxReleaseConfig.changelog?.git.stageChanges) && changes.length) {
3811
- chunkG3JMIIRF_cjs.writeDebug(`Staging changed files with git`);
3812
- await git.gitAdd({
3813
- changedFiles,
3814
- deletedFiles,
3815
- dryRun: args.dryRun,
3816
- verbose: args.verbose
3817
- });
3818
- }
3819
- if (args.gitTag ?? nxReleaseConfig.changelog?.git.tag) {
3820
- chunkG3JMIIRF_cjs.writeDebug(`Tagging commit with git`);
3326
+ devkit.output.logSingleLine(`Tagging commit with git`);
3821
3327
  for (const tag of gitTagValues) {
3822
3328
  await gitTag({
3823
3329
  tag,
3824
- message: args.gitTagMessage || nxReleaseConfig.changelog?.git.tagMessage,
3825
- additionalArgs: args.gitTagArgs || nxReleaseConfig.changelog?.git.tagArgs,
3826
- dryRun: args.dryRun,
3827
- verbose: args.verbose
3330
+ message: options.gitTagMessage || this.config.changelog?.git?.tagMessage,
3331
+ additionalArgs: options.gitTagArgs || this.config.changelog?.git?.tagArgs,
3332
+ dryRun: options.dryRun,
3333
+ verbose: options.verbose
3828
3334
  });
3829
3335
  }
3830
- }
3831
- if (args.gitPush ?? nxReleaseConfig.changelog?.git.push) {
3832
- chunkG3JMIIRF_cjs.writeDebug(`Pushing to git remote "${args.gitRemote}"`);
3833
- await git.gitPush({
3834
- gitRemote: args.gitRemote,
3835
- dryRun: args.dryRun,
3836
- verbose: args.verbose
3837
- });
3838
- }
3839
- for (const postGitTask of postGitTasks) {
3840
- await postGitTask(latestCommit);
3841
- }
3842
- return;
3843
- }
3844
- async function generateChangelogForWorkspace({
3845
- tree,
3846
- args,
3847
- nxReleaseConfig,
3848
- workspaceChangelogVersion,
3849
- changes
3850
- }) {
3851
- const workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
3852
- if (!workspaceConfig) {
3853
- throw new Error(
3854
- `Unable to determine the Storm workspace config. Please ensure that your storm-workspace.json file is present and valid.`
3855
- );
3856
- }
3857
- const config5 = nxReleaseConfig.changelog?.workspaceChangelog;
3858
- if (config5 === false) {
3859
- return;
3860
- }
3861
- if (workspaceChangelogVersion === null) {
3862
- return;
3863
- }
3864
- if (!config5) {
3865
- throw new Error(
3866
- `Workspace changelog is enabled but no configuration was provided. Please provide a workspaceChangelog object in your nx.json`
3867
- );
3868
- }
3869
- if (Object.entries(nxReleaseConfig.groups ?? {}).length > 1) {
3870
- output.output.warn({
3871
- title: `Workspace changelog is enabled, but you have multiple release groups configured. This is not supported, so workspace changelog will be disabled.`,
3872
- bodyLines: [
3873
- `A single workspace version cannot be determined when defining multiple release groups because versions can differ between each group.`,
3874
- `Project level changelogs can be enabled with the "release.changelog.projectChangelogs" property.`
3875
- ]
3876
- });
3877
- return;
3878
- }
3879
- if (Object.values(nxReleaseConfig.groups ?? {})[0]?.projectsRelationship === "independent") {
3880
- output.output.warn({
3881
- title: `Workspace changelog is enabled, but you have configured an independent projects relationship. This is not supported, so workspace changelog will be disabled.`,
3882
- bodyLines: [
3883
- `A single workspace version cannot be determined when using independent projects because versions can differ between each project.`,
3884
- `Project level changelogs can be enabled with the "release.changelog.projectChangelogs" property.`
3885
- ]
3886
- });
3887
- return;
3888
- }
3889
- const interactive = args.interactive === "all" || args.interactive === "workspace";
3890
- const dryRun = !!args.dryRun;
3891
- const gitRemote = args.gitRemote;
3892
- let interpolatedTreePath = config5.file || "";
3893
- if (interpolatedTreePath) {
3894
- interpolatedTreePath = utils.interpolate(interpolatedTreePath, {
3895
- projectName: "",
3896
- // n/a for the workspace changelog
3897
- projectRoot: "",
3898
- // n/a for the workspace changelog
3899
- workspaceRoot: ""
3900
- // within the tree, workspaceRoot is the root
3901
- });
3902
- }
3903
- const releaseVersion = new shared.ReleaseVersion({
3904
- version: workspaceChangelogVersion,
3905
- releaseTagPattern: nxReleaseConfig.releaseTagPattern
3906
- });
3907
- if (interpolatedTreePath) {
3908
- const prefix = dryRun ? "Previewing" : "Generating";
3909
- output.output.log({
3910
- title: `${prefix} an entry in ${interpolatedTreePath} for ${releaseVersion.gitTag}`
3911
- });
3912
- }
3913
- const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
3914
- const changelogRenderer = new StormChangelogRenderer({
3915
- changes,
3916
- changelogEntryVersion: releaseVersion.rawVersion,
3917
- project: null,
3918
- isVersionPlans: false,
3919
- entryWhenNoChanges: config5.entryWhenNoChanges,
3920
- changelogRenderOptions: config5.renderOptions,
3921
- conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
3922
- remoteReleaseClient
3923
- });
3924
- let contents = await changelogRenderer.render();
3925
- if (interactive) {
3926
- const tmpDir = tmp.dirSync().name;
3927
- const changelogPath = path.joinPathFragments(
3928
- tmpDir,
3929
- // Include the tree path in the name so that it is easier to identify which changelog file is being edited
3930
- `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
3931
- );
3932
- fs$1.writeFileSync(changelogPath, contents);
3933
- await launchEditor.launchEditor(changelogPath);
3934
- contents = fs$1.readFileSync(changelogPath, "utf8");
3935
- }
3936
- if (interpolatedTreePath) {
3937
- tree.write(
3938
- interpolatedTreePath,
3939
- await generateChangelogContent(
3940
- releaseVersion,
3941
- interpolatedTreePath,
3942
- contents,
3943
- tree.exists(interpolatedTreePath) ? tree.read(interpolatedTreePath)?.toString() : "",
3944
- null,
3945
- workspaceConfig
3946
- )
3947
- );
3948
- printChanges.printAndFlushChanges(tree, !!dryRun, 3, false, shared.noDiffInChangelogMessage);
3949
- }
3950
- return {
3951
- releaseVersion,
3952
- contents
3953
- };
3954
- }
3955
- async function generateChangelogForProjects({
3956
- tree,
3957
- args,
3958
- changes,
3959
- projectsVersionData,
3960
- releaseGroup,
3961
- projects,
3962
- nxReleaseConfig,
3963
- projectToAdditionalDependencyBumps
3964
- }) {
3965
- const workspaceConfig = await chunkG3JMIIRF_cjs.getWorkspaceConfig();
3966
- if (!workspaceConfig) {
3967
- throw new Error(
3968
- `Unable to determine the Storm workspace config. Please ensure that your storm-workspace.json file is present and valid.`
3969
- );
3970
- }
3971
- const config5 = releaseGroup.changelog;
3972
- if (config5 === false) {
3973
- return;
3974
- }
3975
- const interactive = args.interactive === "all" || args.interactive === "projects";
3976
- const dryRun = !!args.dryRun;
3977
- const gitRemote = args.gitRemote;
3978
- const projectChangelogs = {};
3979
- for (const project of projects) {
3980
- let interpolatedTreePath = config5.file || "";
3981
- if (interpolatedTreePath) {
3982
- interpolatedTreePath = utils.interpolate(interpolatedTreePath, {
3983
- projectName: project.name,
3984
- projectRoot: project.data.root,
3985
- workspaceRoot: ""
3986
- });
3987
- }
3988
- const newVersion = projectsVersionData[project.name]?.newVersion;
3989
- if (!newVersion) {
3990
- continue;
3991
- }
3992
- const releaseVersion = new shared.ReleaseVersion({
3993
- version: newVersion,
3994
- releaseTagPattern: releaseGroup.releaseTagPattern,
3995
- projectName: project.name
3996
- });
3997
- if (interpolatedTreePath) {
3998
- const prefix = dryRun ? "Previewing" : "Generating";
3999
- output.output.log({
4000
- title: `${prefix} an entry in ${interpolatedTreePath} for ${releaseVersion.gitTag}`
4001
- });
4002
- const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
4003
- const changelogRenderer = new StormChangelogRenderer({
4004
- changes,
4005
- changelogEntryVersion: releaseVersion.rawVersion,
4006
- project: project.name,
4007
- entryWhenNoChanges: typeof config5.entryWhenNoChanges === "string" ? utils.interpolate(config5.entryWhenNoChanges, {
4008
- projectName: project.name,
4009
- projectRoot: project.data.root,
4010
- workspaceRoot: ""
4011
- }) : false,
4012
- changelogRenderOptions: config5.renderOptions,
4013
- isVersionPlans: !!releaseGroup.versionPlans,
4014
- conventionalCommitsConfig: releaseGroup.versionPlans ? null : nxReleaseConfig.conventionalCommits,
4015
- dependencyBumps: projectToAdditionalDependencyBumps.get(project.name),
4016
- remoteReleaseClient
4017
- });
4018
- let contents = await changelogRenderer.render();
4019
- output.output.log({
4020
- title: `Changelog renderer for ${project.name} rendered the following content:
4021
-
4022
- ${contents}`.trim()
3336
+ if (options.gitPush ?? this.config.changelog?.git?.push) {
3337
+ devkit.output.logSingleLine(
3338
+ `Pushing to git remote "${options.gitRemote ?? "origin"}"`
3339
+ );
3340
+ await git.gitPush({
3341
+ gitRemote: options.gitRemote,
3342
+ dryRun: options.dryRun,
3343
+ verbose: options.verbose,
3344
+ additionalArgs: options.gitPushArgs || this.config.changelog?.git?.pushArgs
4023
3345
  });
4024
- if (interactive) {
4025
- const tmpDir = tmp.dirSync().name;
4026
- const changelogPath = path.joinPathFragments(
4027
- tmpDir,
4028
- // Include the tree path in the name so that it is easier to identify which changelog file is being edited
4029
- `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
4030
- );
4031
- fs$1.writeFileSync(changelogPath, contents);
4032
- await launchEditor.launchEditor(changelogPath);
4033
- contents = fs$1.readFileSync(changelogPath, "utf8");
4034
- }
4035
- if (interpolatedTreePath) {
4036
- tree.write(
4037
- interpolatedTreePath,
4038
- await generateChangelogContent(
4039
- releaseVersion,
4040
- interpolatedTreePath,
4041
- contents,
4042
- tree.exists(interpolatedTreePath) ? tree.read(interpolatedTreePath)?.toString() : "",
4043
- project.name,
4044
- workspaceConfig
4045
- )
4046
- );
4047
- printChanges.printAndFlushChanges(
4048
- tree,
4049
- !!dryRun,
4050
- 3,
4051
- false,
4052
- shared.noDiffInChangelogMessage,
4053
- // Only print the change for the current changelog file at this point
4054
- (f) => f.path === interpolatedTreePath
4055
- );
4056
- }
4057
- projectChangelogs[project.name] = {
4058
- releaseVersion,
4059
- contents
4060
- };
4061
- }
4062
- }
4063
- return projectChangelogs;
4064
- }
4065
- function checkChangelogFilesEnabled(nxReleaseConfig) {
4066
- if (nxReleaseConfig.changelog?.workspaceChangelog && nxReleaseConfig.changelog?.workspaceChangelog.file) {
4067
- return true;
4068
- }
4069
- return Object.values(nxReleaseConfig.groups ?? {}).some(
4070
- (releaseGroup) => typeof releaseGroup?.changelog === "boolean" && releaseGroup.changelog || releaseGroup?.changelog?.file
4071
- );
4072
- }
4073
- async function getCommits(fromSHA, toSHA) {
4074
- const rawCommits = await git.getGitDiff(fromSHA, toSHA);
4075
- return git.parseCommits(rawCommits);
4076
- }
4077
- function filterHiddenChanges(changes, conventionalCommitsConfig) {
4078
- return changes.filter((change) => {
4079
- const type = change.type;
4080
- const typeConfig = conventionalCommitsConfig.types[type];
4081
- if (!typeConfig) {
4082
- return false;
4083
- }
4084
- return !typeConfig.changelog.hidden;
4085
- });
4086
- }
4087
- function filterHiddenCommits(commits, conventionalCommitsConfig) {
4088
- if (!commits) {
4089
- return [];
4090
- }
4091
- return commits.filter((commit) => {
4092
- const type = commit.type;
4093
- const typeConfig = conventionalCommitsConfig.types[type];
4094
- if (!typeConfig) {
4095
- return false;
4096
- }
4097
- return !typeConfig.changelog.hidden;
4098
- });
4099
- }
4100
- function shouldCreateGitHubRelease(changelogConfig, createReleaseArg = void 0) {
4101
- if (createReleaseArg !== void 0) {
4102
- return createReleaseArg === "github";
4103
- }
4104
- if (changelogConfig === false) {
4105
- return false;
4106
- }
4107
- return changelogConfig.createRelease !== false;
4108
- }
4109
- async function promptForGitHubRelease() {
4110
- try {
4111
- const result = await enquirer.prompt([
4112
- {
4113
- name: "confirmation",
4114
- message: "Do you want to create a GitHub release anyway?",
4115
- type: "confirm"
4116
- }
4117
- ]);
4118
- return result.confirmation;
4119
- } catch (e) {
4120
- return false;
4121
- }
4122
- }
4123
- function getProjectsAffectedByCommit(commit, fileToProjectMap) {
4124
- const affectedProjects = /* @__PURE__ */ new Set();
4125
- for (const file of commit.affectedFiles) {
4126
- affectedProjects.add(fileToProjectMap[file]);
4127
- }
4128
- return Array.from(affectedProjects);
4129
- }
4130
- function commitChangesNonProjectFiles(commit, nonProjectFiles) {
4131
- return nonProjectFiles.some(
4132
- (fileData) => commit.affectedFiles.includes(fileData.file)
4133
- );
4134
- }
4135
- function createFileToProjectMap(projectFileMap) {
4136
- const fileToProjectMap = {};
4137
- for (const [projectName, projectFiles] of Object.entries(projectFileMap)) {
4138
- for (const file of projectFiles) {
4139
- fileToProjectMap[file.file] = projectName;
4140
3346
  }
4141
- }
4142
- return fileToProjectMap;
4143
- }
4144
- function versionPlanSemverReleaseTypeToChangelogType(bump) {
4145
- switch (bump) {
4146
- case "premajor":
4147
- case "major":
4148
- return { type: "feat", isBreaking: true };
4149
- case "preminor":
4150
- case "minor":
4151
- return { type: "feat", isBreaking: false };
4152
- case "prerelease":
4153
- case "prepatch":
4154
- case "patch":
4155
- return { type: "fix", isBreaking: false };
4156
- default:
4157
- throw new Error(`Invalid semver bump type: ${bump}`);
4158
- }
4159
- }
4160
- function formatGithubReleaseNotes(releaseVersion, content, projectName, workspaceConfig) {
4161
- if (!workspaceConfig) {
4162
- return content;
4163
- }
4164
- return `![${(typeof workspaceConfig.release.banner === "string" ? workspaceConfig.organization ? titleCase(
4165
- typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization.name
4166
- ) : void 0 : workspaceConfig.release.banner.alt) || "Release banner header"}](${typeof workspaceConfig.release.banner === "string" ? workspaceConfig.release.banner : workspaceConfig.release.banner?.url})
4167
- ${workspaceConfig.release.header || ""}
4168
-
4169
- # ${projectName ? `${titleCase(projectName)} ` : ""}v${releaseVersion.rawVersion}
4170
-
4171
- We at [${workspaceConfig.organization ? titleCase(
4172
- typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization.name
4173
- ) : ""}](${workspaceConfig.homepage}) are very excited to announce the v${releaseVersion.rawVersion} release of the ${projectName ? workspaceConfig.name ? `${titleCase(workspaceConfig.name)} - ${titleCase(projectName)}` : titleCase(projectName) : workspaceConfig.name ? titleCase(workspaceConfig.name) : "Storm Software"} project! \u{1F680}
4174
-
4175
- These changes are released under the ${workspaceConfig.license.includes("license") ? workspaceConfig.license : `${workspaceConfig.license} license`}. You can find more details on [our licensing page](${workspaceConfig.licensing}). You can find guides, API references, and other documentation around this release (and much more) on [our documentation site](${workspaceConfig.docs}).
4176
-
4177
- If you have any questions or comments, feel free to reach out to the team on [Discord](${workspaceConfig.socials.discord}) or [our contact page](${workspaceConfig.contact}). Please help us spread the word by giving [this repository](https://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}) a star \u2B50 on GitHub or [posting on X (Twitter)](https://x.com/intent/tweet?text=Check%20out%20the%20latest%20@${workspaceConfig.socials.twitter}%20release%20${projectName ? `${titleCase(projectName)?.replaceAll(" ", "%20")}%20` : ""}v${releaseVersion.rawVersion}%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/${typeof workspaceConfig.organization === "string" ? workspaceConfig.organization : workspaceConfig.organization?.name}/${workspaceConfig.name}/releases/tag/${releaseVersion.gitTag}) about this release!
4178
-
4179
- ## Release Notes
4180
-
4181
- ${content.replaceAll(
4182
- `## ${generateChangelogTitle(
4183
- releaseVersion.rawVersion,
4184
- projectName,
4185
- workspaceConfig
4186
- )}`,
4187
- ""
4188
- ).replaceAll(
4189
- `# ${generateChangelogTitle(releaseVersion.rawVersion, projectName, workspaceConfig)}`,
4190
- ""
4191
- )}
4192
-
4193
- ---
4194
-
4195
- ${workspaceConfig.release.footer}
4196
- `;
4197
- }
4198
-
4199
- // src/release/config.ts
4200
- var DEFAULT_CONVENTIONAL_COMMITS_CONFIG2 = {
4201
- questions: DEFAULT_MONOREPO_COMMIT_QUESTIONS,
4202
- types: DEFAULT_COMMIT_TYPES
4203
- };
4204
- var DEFAULT_RELEASE_GROUP_CONFIG = {
4205
- projectsRelationship: "independent",
4206
- releaseTagPattern: "{projectName}@{version}",
4207
- changelog: {
4208
- git: {
4209
- tag: true
4210
- },
4211
- createRelease: "github",
4212
- entryWhenNoChanges: false,
4213
- file: "{projectRoot}/CHANGELOG.md",
4214
- renderOptions: {
4215
- authors: false,
4216
- commitReferences: true,
4217
- versionTitleDate: true
4218
- }
4219
- },
4220
- version: {
4221
- groupPreVersionCommand: "pnpm build",
4222
- useLegacyVersioning: true,
4223
- currentVersionResolver: "git-tag",
4224
- specifierSource: "conventional-commits",
4225
- generator: "@storm-software/workspace-tools:release-version",
4226
- generatorOptions: {
4227
- currentVersionResolver: "git-tag",
4228
- specifierSource: "conventional-commits"
4229
- }
4230
- }
4231
- };
4232
- var DEFAULT_RELEASE_CONFIG = {
4233
- conventionalCommits: DEFAULT_CONVENTIONAL_COMMITS_CONFIG2,
4234
- changelog: {
4235
- git: {
4236
- tag: true
4237
- },
4238
- automaticFromRef: true,
4239
- workspaceChangelog: false,
4240
- projectChangelogs: {
4241
- createRelease: "github",
4242
- entryWhenNoChanges: false,
4243
- file: "{projectRoot}/CHANGELOG.md",
4244
- renderOptions: {
4245
- authors: false,
4246
- commitReferences: true,
4247
- versionTitleDate: true
4248
- }
4249
- }
4250
- },
4251
- version: {
4252
- preVersionCommand: "pnpm build",
4253
- useLegacyVersioning: true,
4254
- currentVersionResolver: "git-tag",
4255
- specifierSource: "conventional-commits",
4256
- generator: "@storm-software/workspace-tools:release-version",
4257
- generatorOptions: {
4258
- currentVersionResolver: "git-tag",
4259
- specifierSource: "conventional-commits"
3347
+ for (const postGitTask of postGitTasks) {
3348
+ await postGitTask(latestCommit);
4260
3349
  }
4261
- }
3350
+ return;
3351
+ };
4262
3352
  };
4263
3353
 
4264
3354
  // src/release/run.ts
4265
- var runRelease = async (config5, options) => {
3355
+ var runRelease = async (config5, {
3356
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3357
+ project,
3358
+ head,
3359
+ base,
3360
+ dryRun = false,
3361
+ skipPublish = false,
3362
+ ignoreNxJsonConfig = false,
3363
+ ...releaseConfig
3364
+ }) => {
4266
3365
  if (!process.env.GITHUB_ACTOR) {
4267
3366
  throw new Error("The `GITHUB_ACTOR` environment variable is not set.");
4268
3367
  }
4269
3368
  if (!await isUserAnOrganizationMember(process.env.GITHUB_ACTOR, config5)) {
4270
- chunkG3JMIIRF_cjs.writeFatal(
3369
+ chunkEHPPIARR_cjs.writeFatal(
4271
3370
  "You must be a member of the Storm Software organization to run the release process.",
4272
3371
  config5
4273
3372
  );
@@ -4284,63 +3383,42 @@ var runRelease = async (config5, options) => {
4284
3383
  process.env.NODE_AUTH_TOKEN = process.env.NPM_TOKEN;
4285
3384
  process.env.NPM_AUTH_TOKEN = process.env.NPM_TOKEN;
4286
3385
  process.env.NPM_CONFIG_PROVENANCE = "true";
4287
- chunkG3JMIIRF_cjs.writeDebug("Creating workspace Project Graph data...", config5);
4288
- const nxJson = nxJson_js.readNxJson();
4289
- chunkG3JMIIRF_cjs.writeDebug("Reading in the workspaces release configuration", config5);
4290
- const to = options.head || process.env.NX_HEAD;
4291
- const from = options.base || process.env.NX_BASE;
4292
- chunkG3JMIIRF_cjs.writeDebug(
3386
+ chunkEHPPIARR_cjs.writeDebug("Creating Storm release client...", config5);
3387
+ const releaseClient = await StormReleaseClient.create(
3388
+ releaseConfig,
3389
+ ignoreNxJsonConfig,
3390
+ config5
3391
+ );
3392
+ chunkEHPPIARR_cjs.writeDebug("Reading in the workspaces release configuration", config5);
3393
+ const to = head || process.env.NX_HEAD;
3394
+ const from = base || process.env.NX_BASE;
3395
+ chunkEHPPIARR_cjs.writeDebug(
4293
3396
  `Using the following Git SHAs to determine the release content:
4294
3397
  - From: ${from}
4295
3398
  - To: ${to}
4296
3399
  `,
4297
3400
  config5
4298
3401
  );
4299
- if (nxJson.release?.groups) {
4300
- nxJson.release.groups = Object.keys(nxJson.release.groups).reduce(
4301
- (ret, groupName) => {
4302
- const groupConfig = nxJson.release?.groups?.[groupName];
4303
- ret[groupName] = chunkG3JMIIRF_cjs.defu(groupConfig, DEFAULT_RELEASE_GROUP_CONFIG);
4304
- return ret;
4305
- },
4306
- {}
4307
- );
4308
- }
4309
- const nxReleaseConfig = chunkG3JMIIRF_cjs.defu(
4310
- nxJson.release,
4311
- DEFAULT_RELEASE_CONFIG
4312
- );
4313
- chunkG3JMIIRF_cjs.writeInfo(
4314
- "Using the following `nx.json` release configuration values",
4315
- config5
4316
- );
4317
- chunkG3JMIIRF_cjs.writeInfo(nxReleaseConfig, config5);
4318
- const releaseVersion = version_js.createAPI(nxReleaseConfig);
4319
- const releaseChangelog = createAPI(nxReleaseConfig);
4320
- const releasePublish = publish_js.createAPI(nxReleaseConfig);
4321
- chunkG3JMIIRF_cjs.writeDebug("Determining the current release versions...", config5);
4322
- const { workspaceVersion, projectsVersionData } = await releaseVersion({
4323
- dryRun: false,
4324
- verbose: chunkG3JMIIRF_cjs.isVerbose(config5.logLevel),
3402
+ chunkEHPPIARR_cjs.writeDebug("Determining the current release versions...", config5);
3403
+ const { workspaceVersion, projectsVersionData, releaseGraph } = await releaseClient.releaseVersion({
3404
+ dryRun,
3405
+ verbose: chunkEHPPIARR_cjs.isVerbose(config5.logLevel),
4325
3406
  preid: config5.preid,
4326
- deleteVersionPlans: false,
4327
3407
  stageChanges: true,
4328
3408
  gitCommit: false
4329
3409
  });
4330
- await releaseChangelog({
4331
- ...options,
4332
- version: nxReleaseConfig?.projectsRelationship !== "fixed" ? void 0 : workspaceVersion,
3410
+ await releaseClient.releaseChangelog({
3411
+ version: releaseConfig?.projectsRelationship === "fixed" ? workspaceVersion : void 0,
4333
3412
  versionData: projectsVersionData,
4334
- dryRun: false,
4335
- verbose: chunkG3JMIIRF_cjs.isVerbose(config5.logLevel),
3413
+ dryRun,
3414
+ verbose: chunkEHPPIARR_cjs.isVerbose(config5.logLevel),
4336
3415
  to,
4337
3416
  from,
4338
- gitCommit: true,
4339
- gitCommitMessage: "release(monorepo): Publish workspace release updates"
3417
+ releaseGraph
4340
3418
  });
4341
- chunkG3JMIIRF_cjs.writeDebug("Tagging commit with git", config5);
4342
- if (options.skipPublish) {
4343
- chunkG3JMIIRF_cjs.writeWarning(
3419
+ chunkEHPPIARR_cjs.writeDebug("Tagging commit with git", config5);
3420
+ if (skipPublish) {
3421
+ chunkEHPPIARR_cjs.writeWarning(
4344
3422
  "Skipping publishing packages since `skipPublish` was provided as `true` in the release options.",
4345
3423
  config5
4346
3424
  );
@@ -4349,17 +3427,16 @@ var runRelease = async (config5, options) => {
4349
3427
  (key) => projectsVersionData[key]?.newVersion
4350
3428
  );
4351
3429
  if (changedProjects.length > 0) {
4352
- chunkG3JMIIRF_cjs.writeInfo(
3430
+ chunkEHPPIARR_cjs.writeInfo(
4353
3431
  `Publishing release for ${changedProjects.length} ${changedProjects.length === 1 ? "project" : "projects"}:
4354
3432
  ${changedProjects.map((changedProject) => ` - ${changedProject}`).join("\n")}
4355
3433
  `,
4356
3434
  config5
4357
3435
  );
4358
3436
  await updatePackageManifests(projectsVersionData, config5);
4359
- const result = await releasePublish({
4360
- ...options,
4361
- dryRun: !!options.dryRun,
4362
- verbose: chunkG3JMIIRF_cjs.isVerbose(config5.logLevel)
3437
+ const result = await releaseClient.releasePublish({
3438
+ dryRun,
3439
+ verbose: chunkEHPPIARR_cjs.isVerbose(config5.logLevel)
4363
3440
  });
4364
3441
  const failedProjects = Object.keys(result).filter(
4365
3442
  (key) => result[key]?.code && result[key]?.code > 0
@@ -4374,10 +3451,10 @@ ${failedProjects.map((failedProject) => ` - ${failedProject} (Error Code: ${res
4374
3451
  );
4375
3452
  }
4376
3453
  } else {
4377
- chunkG3JMIIRF_cjs.writeWarning("Skipped publishing packages.", config5);
3454
+ chunkEHPPIARR_cjs.writeWarning("Skipped publishing packages.", config5);
4378
3455
  }
4379
3456
  }
4380
- chunkG3JMIIRF_cjs.writeSuccess("Completed the Storm workspace release process!", config5);
3457
+ chunkEHPPIARR_cjs.writeSuccess("Completed the Storm workspace release process!", config5);
4381
3458
  };
4382
3459
  async function updatePackageManifests(projectsVersionData, config5) {
4383
3460
  let projectGraph;
@@ -4392,7 +3469,7 @@ async function updatePackageManifests(projectsVersionData, config5) {
4392
3469
  Object.keys(projectsVersionData).map(async (node) => {
4393
3470
  const projectNode = projectGraph.nodes[node];
4394
3471
  if (!projectNode?.data.root) {
4395
- chunkG3JMIIRF_cjs.writeWarning(
3472
+ chunkEHPPIARR_cjs.writeWarning(
4396
3473
  `Project node ${node} not found in the project graph. Skipping manifest update.`,
4397
3474
  config5
4398
3475
  );
@@ -4400,17 +3477,17 @@ async function updatePackageManifests(projectsVersionData, config5) {
4400
3477
  }
4401
3478
  const versionData = projectsVersionData[node];
4402
3479
  if (projectNode?.data.root && versionData && versionData.newVersion !== null) {
4403
- chunkG3JMIIRF_cjs.writeTrace(
3480
+ chunkEHPPIARR_cjs.writeTrace(
4404
3481
  `Writing version ${versionData.newVersion} update to manifest file for ${node}
4405
3482
  `,
4406
3483
  config5
4407
3484
  );
4408
- const projectRoot = chunkG3JMIIRF_cjs.joinPaths(
3485
+ const projectRoot = chunkEHPPIARR_cjs.joinPaths(
4409
3486
  config5.workspaceRoot,
4410
3487
  projectNode.data.root
4411
3488
  );
4412
- const packageJsonPath = chunkG3JMIIRF_cjs.joinPaths(projectRoot, "package.json");
4413
- const cargoTomlPath = chunkG3JMIIRF_cjs.joinPaths(projectRoot, "Cargo.toml");
3489
+ const packageJsonPath = chunkEHPPIARR_cjs.joinPaths(projectRoot, "package.json");
3490
+ const cargoTomlPath = chunkEHPPIARR_cjs.joinPaths(projectRoot, "Cargo.toml");
4414
3491
  if (fs$1.existsSync(packageJsonPath)) {
4415
3492
  const packageJsonContent = await fs.readFile(packageJsonPath, "utf8");
4416
3493
  const packageJson = JSON.parse(packageJsonContent);
@@ -4428,7 +3505,7 @@ async function updatePackageManifests(projectsVersionData, config5) {
4428
3505
  })
4429
3506
  );
4430
3507
  } else {
4431
- chunkG3JMIIRF_cjs.writeWarning("No project nodes found. Skipping manifest updates.", config5);
3508
+ chunkEHPPIARR_cjs.writeWarning("No project nodes found. Skipping manifest updates.", config5);
4432
3509
  }
4433
3510
  }
4434
3511
 
@@ -4436,8 +3513,8 @@ async function updatePackageManifests(projectsVersionData, config5) {
4436
3513
  var _config = {};
4437
3514
  function createProgram(config5) {
4438
3515
  _config = config5;
4439
- chunkG3JMIIRF_cjs.writeInfo("\u26A1 Running Storm Git Tools", config5);
4440
- const root = chunkG3JMIIRF_cjs.findWorkspaceRootSafe(process.cwd());
3516
+ chunkEHPPIARR_cjs.writeInfo("\u26A1 Running Storm Git Tools", config5);
3517
+ const root = chunkEHPPIARR_cjs.findWorkspaceRootSafe(process.cwd());
4441
3518
  process.env.STORM_WORKSPACE_ROOT ??= root;
4442
3519
  process.env.NX_WORKSPACE_ROOT_PATH ??= root;
4443
3520
  if (root) {
@@ -4477,12 +3554,12 @@ async function commitAction({
4477
3554
  dryRun = false
4478
3555
  }) {
4479
3556
  try {
4480
- chunkG3JMIIRF_cjs.writeInfo(
3557
+ chunkEHPPIARR_cjs.writeInfo(
4481
3558
  `\u26A1 Preparing to commit your changes. Please provide the requested details below...`,
4482
3559
  _config
4483
3560
  );
4484
3561
  await runCommit(config5, dryRun);
4485
- chunkG3JMIIRF_cjs.writeSuccess(
3562
+ chunkEHPPIARR_cjs.writeSuccess(
4486
3563
  `\u{1F389} Storm Commit processing completed successfully!
4487
3564
 
4488
3565
  Note: Please run "pnpm push" to upload these changes to the remote ${_config.name ? _config.name : _config.namespace ? _config.namespace : _config.organization ? _config.organization : "Storm-Software"} Git repository at ${_config.repository}
@@ -4490,7 +3567,7 @@ Note: Please run "pnpm push" to upload these changes to the remote ${_config.nam
4490
3567
  _config
4491
3568
  );
4492
3569
  } catch (error) {
4493
- chunkG3JMIIRF_cjs.writeFatal(
3570
+ chunkEHPPIARR_cjs.writeFatal(
4494
3571
  `A fatal error occurred while running commit action:
4495
3572
 
4496
3573
  ${error.message}${error.stack ? `
@@ -4505,14 +3582,14 @@ Please fix any errors and try committing again.`,
4505
3582
  }
4506
3583
  async function readmeAction(options) {
4507
3584
  try {
4508
- chunkG3JMIIRF_cjs.writeInfo("\u26A1 Formatting the workspace's README.md files", _config);
3585
+ chunkEHPPIARR_cjs.writeInfo("\u26A1 Formatting the workspace's README.md files", _config);
4509
3586
  await runReadme(options);
4510
- chunkG3JMIIRF_cjs.writeSuccess(
3587
+ chunkEHPPIARR_cjs.writeSuccess(
4511
3588
  "Formatting of the workspace's README.md files is complete\n",
4512
3589
  _config
4513
3590
  );
4514
3591
  } catch (error) {
4515
- chunkG3JMIIRF_cjs.writeFatal(
3592
+ chunkEHPPIARR_cjs.writeFatal(
4516
3593
  `A fatal error occurred while running README format action:
4517
3594
 
4518
3595
  ${error.message}`
@@ -4527,7 +3604,7 @@ async function releaseAction({
4527
3604
  dryRun
4528
3605
  }) {
4529
3606
  try {
4530
- chunkG3JMIIRF_cjs.writeInfo(
3607
+ chunkEHPPIARR_cjs.writeInfo(
4531
3608
  "\u26A1 Running the Storm Release and Publish process on the workspace",
4532
3609
  _config
4533
3610
  );
@@ -4537,9 +3614,9 @@ async function releaseAction({
4537
3614
  base,
4538
3615
  head
4539
3616
  });
4540
- chunkG3JMIIRF_cjs.writeSuccess("Release completed successfully!\n", _config);
3617
+ chunkEHPPIARR_cjs.writeSuccess("Release completed successfully!\n", _config);
4541
3618
  } catch (error) {
4542
- chunkG3JMIIRF_cjs.writeFatal(
3619
+ chunkEHPPIARR_cjs.writeFatal(
4543
3620
  `A fatal error occurred while running release action:
4544
3621
 
4545
3622
  ${error.message} ${error.stack ? `
@@ -4553,17 +3630,17 @@ Stacktrace: ${error.stack}` : ""}`,
4553
3630
  }
4554
3631
  async function commitLintAction(options) {
4555
3632
  try {
4556
- chunkG3JMIIRF_cjs.writeInfo(
3633
+ chunkEHPPIARR_cjs.writeInfo(
4557
3634
  `\u26A1 Linting the ${_config.repository ? _config.repository : _config.namespace ? _config.namespace : _config.name ? _config.name : typeof _config.organization === "string" ? _config.organization : _config.organization?.name ? _config.organization?.name : "Storm-Software"} repository's commit messages.`,
4558
3635
  _config
4559
3636
  );
4560
3637
  await runCommitLint(_config, options);
4561
- chunkG3JMIIRF_cjs.writeSuccess(
3638
+ chunkEHPPIARR_cjs.writeSuccess(
4562
3639
  "Linting the commit messages completed successfully!\n",
4563
3640
  _config
4564
3641
  );
4565
3642
  } catch (error) {
4566
- chunkG3JMIIRF_cjs.writeFatal(
3643
+ chunkEHPPIARR_cjs.writeFatal(
4567
3644
  `A fatal error occurred while linting the commit messages:
4568
3645
 
4569
3646
  ${error.message}`,
@@ -4575,18 +3652,20 @@ ${error.message}`,
4575
3652
 
4576
3653
  // bin/git.ts
4577
3654
  void (async () => {
4578
- const config5 = await chunkG3JMIIRF_cjs.getConfig();
3655
+ const config5 = await chunkEHPPIARR_cjs.getConfig();
4579
3656
  try {
4580
- chunkG3JMIIRF_cjs.handleProcess(config5);
3657
+ chunkEHPPIARR_cjs.handleProcess(config5);
4581
3658
  const program = createProgram(config5);
4582
3659
  await program.parseAsync(process.argv);
4583
- chunkG3JMIIRF_cjs.writeSuccess(
3660
+ chunkEHPPIARR_cjs.writeSuccess(
4584
3661
  `\u{1F389} Git ${process.argv && process.argv.length >= 3 && process.argv[2] ? process.argv[2] : "tool"} processing completed successfully!`,
4585
3662
  config5
4586
3663
  );
4587
- chunkG3JMIIRF_cjs.exitWithSuccess(config5);
3664
+ chunkEHPPIARR_cjs.exitWithSuccess(config5);
4588
3665
  } catch (error) {
4589
- chunkG3JMIIRF_cjs.exitWithError(config5);
3666
+ chunkEHPPIARR_cjs.exitWithError(config5);
4590
3667
  process.exit(1);
4591
3668
  }
4592
3669
  })();
3670
+ //# sourceMappingURL=git.cjs.map
3671
+ //# sourceMappingURL=git.cjs.map