@storm-software/git-tools 2.111.25 → 2.111.26

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 (4) hide show
  1. package/README.md +1 -1
  2. package/bin/git.cjs +354 -286
  3. package/bin/git.js +316 -248
  4. package/package.json +1 -1
package/bin/git.js CHANGED
@@ -82112,10 +82112,7 @@ var runCommit = async (commitizenFile = "@storm-software/git-tools/commit/config
82112
82112
 
82113
82113
  `);
82114
82114
  await runCommitLint(config, { message: message2 });
82115
- const commandItems = ["git", "commit"];
82116
- if (!process.env.CI && !process.env.STORM_CI) {
82117
- commandItems.push("-S");
82118
- }
82115
+ const commandItems = ["git", "commit", "-S"];
82119
82116
  commandItems.push(...["--file", commitMsgFile]);
82120
82117
  const command = (0, import_any_shell_escape.default)(commandItems);
82121
82118
  if (dryRun) {
@@ -87928,7 +87925,7 @@ import {
87928
87925
  getFirstGitCommit,
87929
87926
  getGitDiff,
87930
87927
  getLatestGitTagForPattern,
87931
- gitAdd,
87928
+ gitAdd as gitAdd2,
87932
87929
  gitPush,
87933
87930
  parseCommits,
87934
87931
  parseGitCommit
@@ -87937,11 +87934,9 @@ import { launchEditor } from "nx/src/command-line/release/utils/launch-editor";
87937
87934
  import { printAndFlushChanges } from "nx/src/command-line/release/utils/print-changes";
87938
87935
  import { printConfigAndExit } from "nx/src/command-line/release/utils/print-config";
87939
87936
  import { defaultCreateReleaseProvider as defaultCreateReleaseProvider2 } from "nx/src/command-line/release/utils/remote-release-clients/github";
87940
- import { createRemoteReleaseClient } from "nx/src/command-line/release/utils/remote-release-clients/remote-release-client";
87941
87937
  import { resolveNxJsonConfigErrorMessage } from "nx/src/command-line/release/utils/resolve-nx-json-error-message";
87942
87938
  import {
87943
87939
  ReleaseVersion as ReleaseVersion2,
87944
- commitChanges,
87945
87940
  createCommitMessageValues,
87946
87941
  createGitTagValues,
87947
87942
  handleDuplicateGitTags,
@@ -87959,7 +87954,7 @@ import { createProjectGraphAsync as createProjectGraphAsync4 } from "nx/src/proj
87959
87954
  import { interpolate } from "nx/src/tasks-runner/utils";
87960
87955
  import { isCI } from "nx/src/utils/is-ci";
87961
87956
  import { output as output2 } from "nx/src/utils/output";
87962
- import { joinPathFragments } from "nx/src/utils/path";
87957
+ import { joinPathFragments as joinPathFragments2 } from "nx/src/utils/path";
87963
87958
  import { workspaceRoot } from "nx/src/utils/workspace-root";
87964
87959
 
87965
87960
  // src/utilities/changelog-utils.ts
@@ -88044,6 +88039,7 @@ function parseChangelogMarkdown(contents) {
88044
88039
  // src/utilities/git-utils.ts
88045
88040
  init_esm_shims();
88046
88041
  import { execCommand } from "nx/src/command-line/release/utils/exec-command.js";
88042
+ import { gitAdd } from "nx/src/command-line/release/utils/git";
88047
88043
  async function gitTag({
88048
88044
  tag,
88049
88045
  message: message2,
@@ -88086,6 +88082,76 @@ async function gitTag({
88086
88082
  ${err}`);
88087
88083
  }
88088
88084
  }
88085
+ async function gitCommit({
88086
+ messages,
88087
+ additionalArgs,
88088
+ dryRun,
88089
+ verbose,
88090
+ logFn
88091
+ }) {
88092
+ logFn = logFn || console.log;
88093
+ const commandArgs = ["commit", "-S"];
88094
+ for (const message2 of messages) {
88095
+ commandArgs.push("--message", message2);
88096
+ }
88097
+ if (additionalArgs) {
88098
+ if (Array.isArray(additionalArgs)) {
88099
+ commandArgs.push(...additionalArgs);
88100
+ } else {
88101
+ commandArgs.push(...additionalArgs.split(" "));
88102
+ }
88103
+ }
88104
+ if (verbose) {
88105
+ logFn(
88106
+ dryRun ? `Would commit all previously staged files in git with the following command, but --dry-run was set:` : `Committing files in git with the following command:`
88107
+ );
88108
+ logFn(`git ${commandArgs.join(" ")}`);
88109
+ }
88110
+ if (dryRun) {
88111
+ return;
88112
+ }
88113
+ let hasStagedFiles = false;
88114
+ try {
88115
+ await execCommand("git", ["diff-index", "--quiet", "HEAD", "--cached"]);
88116
+ } catch {
88117
+ hasStagedFiles = true;
88118
+ }
88119
+ if (!hasStagedFiles) {
88120
+ logFn("\nNo staged files found. Skipping commit.");
88121
+ return;
88122
+ }
88123
+ return execCommand("git", commandArgs);
88124
+ }
88125
+ async function commitChanges({
88126
+ changedFiles,
88127
+ deletedFiles,
88128
+ isDryRun,
88129
+ isVerbose: isVerbose2,
88130
+ gitCommitMessages,
88131
+ gitCommitArgs,
88132
+ logFn
88133
+ }) {
88134
+ logFn = logFn || console.log;
88135
+ if (!changedFiles?.length && !deletedFiles?.length) {
88136
+ throw new Error("Error: No changed files to commit");
88137
+ }
88138
+ logFn(`Committing changes with git`);
88139
+ await gitAdd({
88140
+ changedFiles,
88141
+ deletedFiles,
88142
+ dryRun: isDryRun,
88143
+ verbose: isVerbose2
88144
+ });
88145
+ if (isVerbose2) {
88146
+ console.log("");
88147
+ }
88148
+ await gitCommit({
88149
+ messages: gitCommitMessages || [],
88150
+ additionalArgs: gitCommitArgs,
88151
+ dryRun: isDryRun,
88152
+ verbose: isVerbose2
88153
+ });
88154
+ }
88089
88155
 
88090
88156
  // src/release/changelog-renderer.ts
88091
88157
  init_esm_shims();
@@ -91489,6 +91555,195 @@ var {
91489
91555
  var import_semver = __toESM(require_semver4(), 1);
91490
91556
  import DefaultChangelogRenderer from "nx/release/changelog-renderer";
91491
91557
  import { DEFAULT_CONVENTIONAL_COMMITS_CONFIG } from "nx/src/command-line/release/config/conventional-commits";
91558
+ var StormChangelogRenderer = class extends DefaultChangelogRenderer {
91559
+ /**
91560
+ * The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
91561
+ */
91562
+ workspaceConfig = null;
91563
+ /**
91564
+ * The configuration object for the ChangelogRenderer, which includes the changes, version, project, and other options.
91565
+ */
91566
+ config;
91567
+ /**
91568
+ * 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).
91569
+ *
91570
+ * @param config - The configuration object for the ChangelogRenderer
91571
+ */
91572
+ constructor(config) {
91573
+ super(config);
91574
+ this.config = {
91575
+ ...config,
91576
+ repoData: config.remoteReleaseClient.getRemoteRepoData()
91577
+ };
91578
+ }
91579
+ async render() {
91580
+ this.workspaceConfig = await getWorkspaceConfig();
91581
+ return await super.render();
91582
+ }
91583
+ preprocessChanges() {
91584
+ this.relevantChanges = [...this.changes];
91585
+ this.breakingChanges = [];
91586
+ this.additionalChangesForAuthorsSection = [];
91587
+ for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91588
+ const change = this.relevantChanges[i];
91589
+ if (change && change.type === "revert" && change.revertedHashes) {
91590
+ for (const revertedHash of change.revertedHashes) {
91591
+ const revertedCommitIndex = this.relevantChanges.findIndex(
91592
+ (c) => c.shortHash && revertedHash.startsWith(c.shortHash)
91593
+ );
91594
+ if (revertedCommitIndex !== -1) {
91595
+ this.relevantChanges.splice(revertedCommitIndex, 1);
91596
+ this.relevantChanges.splice(i, 1);
91597
+ i--;
91598
+ break;
91599
+ }
91600
+ }
91601
+ }
91602
+ }
91603
+ if (this.isVersionPlans) {
91604
+ this.conventionalCommitsConfig = {
91605
+ types: {
91606
+ feat: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.feat,
91607
+ fix: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.fix
91608
+ }
91609
+ };
91610
+ for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91611
+ if (this.relevantChanges[i]?.isBreaking) {
91612
+ const change = this.relevantChanges[i];
91613
+ if (change) {
91614
+ this.additionalChangesForAuthorsSection.push(change);
91615
+ const line = this.formatChange(change);
91616
+ this.breakingChanges.push(line);
91617
+ this.relevantChanges.splice(i, 1);
91618
+ }
91619
+ }
91620
+ }
91621
+ } else {
91622
+ for (const change of this.relevantChanges) {
91623
+ if (change.isBreaking) {
91624
+ const breakingChangeExplanation = change.body ? this.extractBreakingChangeExplanation(change.body) : "";
91625
+ this.breakingChanges.push(
91626
+ breakingChangeExplanation ? `- ${change.scope ? `**${change.scope.trim()}:** ` : ""}${breakingChangeExplanation}` : this.formatChange(change)
91627
+ );
91628
+ }
91629
+ }
91630
+ }
91631
+ }
91632
+ /**
91633
+ * Determines if the changelog entry should be rendered as empty. This is the case when there are no relevant changes, breaking changes, or dependency bumps.
91634
+ */
91635
+ // protected override shouldRenderEmptyEntry(): boolean {
91636
+ // return true;
91637
+ // }
91638
+ renderVersionTitle() {
91639
+ const isMajorVersion = `${(0, import_semver.major)(this.changelogEntryVersion)}.0.0` === this.changelogEntryVersion.replace(/^v/, "");
91640
+ return isMajorVersion ? `# ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}` : `## ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}`;
91641
+ }
91642
+ renderBreakingChanges() {
91643
+ return [
91644
+ "### Breaking Changes",
91645
+ "",
91646
+ ...Array.from(new Set(this.breakingChanges))
91647
+ ];
91648
+ }
91649
+ renderDependencyBumps() {
91650
+ const markdownLines = ["", "### Updated Dependencies", ""];
91651
+ this.dependencyBumps?.forEach(({ dependencyName, newVersion }) => {
91652
+ markdownLines.push(`- Updated ${dependencyName} to ${newVersion}`);
91653
+ });
91654
+ return markdownLines;
91655
+ }
91656
+ async renderAuthors() {
91657
+ const markdownLines = [];
91658
+ const _authors = /* @__PURE__ */ new Map();
91659
+ for (const change of [
91660
+ ...this.relevantChanges,
91661
+ ...this.additionalChangesForAuthorsSection
91662
+ ]) {
91663
+ if (!change.authors) {
91664
+ continue;
91665
+ }
91666
+ for (const author of change.authors) {
91667
+ const name = this.formatName(author.name);
91668
+ if (!name || name.includes("[bot]") || name === this.workspaceConfig?.bot.name) {
91669
+ continue;
91670
+ }
91671
+ if (_authors.has(name)) {
91672
+ const entry = _authors.get(name);
91673
+ entry?.email.add(author.email);
91674
+ } else {
91675
+ _authors.set(name, { email: /* @__PURE__ */ new Set([author.email]) });
91676
+ }
91677
+ }
91678
+ }
91679
+ if (this.config.repoData && this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
91680
+ await Promise.all(
91681
+ [..._authors.keys()].map(async (authorName) => {
91682
+ const meta = _authors.get(authorName);
91683
+ if (!meta) {
91684
+ return;
91685
+ }
91686
+ for (const email of meta.email) {
91687
+ if (email.endsWith("@users.noreply.github.com")) {
91688
+ const match = email.match(
91689
+ /^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
91690
+ );
91691
+ if (match && match[2]) {
91692
+ meta.github = match[2];
91693
+ break;
91694
+ }
91695
+ }
91696
+ const { data } = await axios_default.get(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
91697
+ if (data?.user) {
91698
+ meta.github = data.user.username;
91699
+ break;
91700
+ }
91701
+ }
91702
+ })
91703
+ );
91704
+ }
91705
+ const authors = [..._authors.entries()].map((e) => ({
91706
+ name: e[0],
91707
+ ...e[1]
91708
+ }));
91709
+ if (authors.length > 0) {
91710
+ markdownLines.push(
91711
+ "",
91712
+ "### \u2764\uFE0F Thank You",
91713
+ "",
91714
+ ...authors.sort((a, b) => a.name.localeCompare(b.name)).map((i) => {
91715
+ const github = i.github ? ` @${i.github}` : "";
91716
+ return `- ${i.name}${github}`;
91717
+ })
91718
+ );
91719
+ }
91720
+ return markdownLines;
91721
+ }
91722
+ formatChange(change) {
91723
+ let description = change.description || "";
91724
+ let extraLines = [];
91725
+ let extraLinesStr = "";
91726
+ if (description.includes("\n")) {
91727
+ const lines2 = description.split("\n");
91728
+ if (lines2.length > 1) {
91729
+ description = lines2[0];
91730
+ extraLines = lines2.slice(1);
91731
+ }
91732
+ const indentation = " ";
91733
+ extraLinesStr = extraLines.filter((l2) => l2.trim().length > 0).map((l2) => `${indentation}${l2}`).join("\n");
91734
+ }
91735
+ let changeLine = "- " + (!this.isVersionPlans && change.scope ? `**${change.scope.trim()}:** ` : "") + description;
91736
+ if (this.config.repoData && change.githubReferences) {
91737
+ changeLine += this.remoteReleaseClient.formatReferences(
91738
+ change.githubReferences
91739
+ );
91740
+ }
91741
+ if (extraLinesStr) {
91742
+ changeLine += "\n\n" + extraLinesStr;
91743
+ }
91744
+ return changeLine;
91745
+ }
91746
+ };
91492
91747
 
91493
91748
  // src/release/github.ts
91494
91749
  init_esm_shims();
@@ -91499,7 +91754,10 @@ import { execSync as execSync2 } from "node:child_process";
91499
91754
  import { existsSync as existsSync5, promises as fsp } from "node:fs";
91500
91755
  import { homedir } from "node:os";
91501
91756
  import { printDiff } from "nx/src/command-line/release/utils/print-changes";
91502
- import { defaultCreateReleaseProvider } from "nx/src/command-line/release/utils/remote-release-clients/github";
91757
+ import {
91758
+ defaultCreateReleaseProvider,
91759
+ GithubRemoteReleaseClient
91760
+ } from "nx/src/command-line/release/utils/remote-release-clients/github";
91503
91761
  import {
91504
91762
  noDiffInChangelogMessage
91505
91763
  } from "nx/src/command-line/release/utils/shared";
@@ -91532,7 +91790,11 @@ function getGitHubRepoData(remoteName = "origin", createReleaseConfig) {
91532
91790
  );
91533
91791
  }
91534
91792
  } catch (error) {
91535
- return null;
91793
+ import_devkit.output.error({
91794
+ title: `Failed to get GitHub repo data`,
91795
+ bodyLines: [error.message]
91796
+ });
91797
+ return void 0;
91536
91798
  }
91537
91799
  }
91538
91800
  async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion, changelogContents, latestCommit, { dryRun }) {
@@ -91546,12 +91808,12 @@ async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion,
91546
91808
  });
91547
91809
  process.exit(1);
91548
91810
  }
91549
- const token = await resolveGithubToken(githubRepoData.hostname);
91811
+ const tokenData = await resolveTokenData(githubRepoData.hostname);
91550
91812
  const githubRequestConfig = {
91551
91813
  repo: githubRepoData.slug,
91552
91814
  hostname: githubRepoData.hostname,
91553
91815
  apiBaseUrl: githubRepoData.apiBaseUrl,
91554
- token
91816
+ token: tokenData?.token || null
91555
91817
  };
91556
91818
  let existingGithubReleaseForVersion;
91557
91819
  try {
@@ -91725,13 +91987,13 @@ async function syncGithubRelease(githubRequestConfig, release, existingGithubRel
91725
91987
  };
91726
91988
  }
91727
91989
  }
91728
- async function resolveGithubToken(hostname) {
91729
- const tokenFromEnv = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
91990
+ async function resolveTokenData(hostname) {
91991
+ const tokenFromEnv = process.env.STORM_BOT_GITHUB_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
91730
91992
  if (tokenFromEnv) {
91731
- return tokenFromEnv;
91993
+ return { token: tokenFromEnv, headerName: "Authorization" };
91732
91994
  }
91733
- const ghCLIPath = joinPaths(
91734
- process.env.XDG_CONFIG_HOME || joinPaths(homedir(), ".config"),
91995
+ const ghCLIPath = (0, import_devkit.joinPathFragments)(
91996
+ process.env.XDG_CONFIG_HOME || (0, import_devkit.joinPathFragments)(homedir(), ".config"),
91735
91997
  "gh",
91736
91998
  "hosts.yml"
91737
91999
  );
@@ -91744,11 +92006,12 @@ async function resolveGithubToken(hostname) {
91744
92006
  return ghCLIConfig[hostname].oauth_token;
91745
92007
  }
91746
92008
  if (ghCLIConfig[hostname].user && ghCLIConfig[hostname].git_protocol === "ssh") {
91747
- return execSync2(`gh auth token`, {
92009
+ const token = execSync2(`gh auth token`, {
91748
92010
  encoding: "utf8",
91749
92011
  stdio: "pipe",
91750
92012
  windowsHide: false
91751
92013
  }).trim();
92014
+ return { token, headerName: "Authorization" };
91752
92015
  }
91753
92016
  }
91754
92017
  }
@@ -91757,7 +92020,9 @@ async function resolveGithubToken(hostname) {
91757
92020
  `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.`
91758
92021
  );
91759
92022
  }
91760
- return null;
92023
+ throw new Error(
92024
+ `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).`
92025
+ );
91761
92026
  }
91762
92027
  async function getGithubReleaseByTag(config, tag) {
91763
92028
  return await makeGithubRequest(
@@ -91799,210 +92064,24 @@ function githubNewReleaseURL(config, release) {
91799
92064
  }
91800
92065
  return url2;
91801
92066
  }
91802
- var providerToRefSpec = {
91803
- github: { "pull-request": "pull", hash: "commit", issue: "issues" }
91804
- };
91805
- function formatReference(ref, repoData) {
91806
- const refSpec = providerToRefSpec["github"];
91807
- return `[${ref.value}](https://${repoData.hostname}/${repoData.slug}/${refSpec[ref.type]}/${ref.value.replace(/^#/, "")})`;
91808
- }
91809
- function formatReferences(references, repoData) {
91810
- const pr2 = references.filter((ref) => ref.type === "pull-request");
91811
- const issue = references.filter((ref) => ref.type === "issue");
91812
- if (pr2.length > 0 || issue.length > 0) {
91813
- return " (" + [...pr2, ...issue].map((ref) => formatReference(ref, repoData)).join(", ") + ")";
91814
- }
91815
- if (references.length > 0) {
91816
- return " (" + formatReference(references[0], repoData) + ")";
92067
+ async function createGithubRemoteReleaseClient(remoteName = "origin") {
92068
+ const repoData = getGitHubRepoData(remoteName, "github");
92069
+ if (!repoData) {
92070
+ throw new Error(
92071
+ `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.`
92072
+ );
91817
92073
  }
91818
- return "";
92074
+ return new GithubRemoteReleaseClient(
92075
+ repoData,
92076
+ {
92077
+ provider: "github",
92078
+ hostname: repoData.hostname,
92079
+ apiBaseUrl: repoData.apiBaseUrl
92080
+ },
92081
+ await resolveTokenData(repoData.hostname)
92082
+ );
91819
92083
  }
91820
92084
 
91821
- // src/release/changelog-renderer.ts
91822
- var StormChangelogRenderer = class extends DefaultChangelogRenderer {
91823
- /**
91824
- * 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).
91825
- *
91826
- * @param config - The configuration object for the ChangelogRenderer
91827
- */
91828
- constructor(config) {
91829
- super(config);
91830
- this.config = config;
91831
- }
91832
- /**
91833
- * The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
91834
- */
91835
- workspaceConfig = null;
91836
- async render() {
91837
- this.workspaceConfig = await getWorkspaceConfig();
91838
- return await super.render();
91839
- }
91840
- preprocessChanges() {
91841
- this.relevantChanges = [...this.changes];
91842
- this.breakingChanges = [];
91843
- this.additionalChangesForAuthorsSection = [];
91844
- for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91845
- const change = this.relevantChanges[i];
91846
- if (change && change.type === "revert" && change.revertedHashes) {
91847
- for (const revertedHash of change.revertedHashes) {
91848
- const revertedCommitIndex = this.relevantChanges.findIndex(
91849
- (c) => c.shortHash && revertedHash.startsWith(c.shortHash)
91850
- );
91851
- if (revertedCommitIndex !== -1) {
91852
- this.relevantChanges.splice(revertedCommitIndex, 1);
91853
- this.relevantChanges.splice(i, 1);
91854
- i--;
91855
- break;
91856
- }
91857
- }
91858
- }
91859
- }
91860
- if (this.isVersionPlans) {
91861
- this.conventionalCommitsConfig = {
91862
- types: {
91863
- feat: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.feat,
91864
- fix: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.fix
91865
- }
91866
- };
91867
- for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91868
- if (this.relevantChanges[i]?.isBreaking) {
91869
- const change = this.relevantChanges[i];
91870
- if (change) {
91871
- this.additionalChangesForAuthorsSection.push(change);
91872
- const line = this.formatChange(change);
91873
- this.breakingChanges.push(line);
91874
- this.relevantChanges.splice(i, 1);
91875
- }
91876
- }
91877
- }
91878
- } else {
91879
- for (const change of this.relevantChanges) {
91880
- if (change.isBreaking) {
91881
- const breakingChangeExplanation = change.body ? this.extractBreakingChangeExplanation(change.body) : "";
91882
- this.breakingChanges.push(
91883
- breakingChangeExplanation ? `- ${change.scope ? `**${change.scope.trim()}:** ` : ""}${breakingChangeExplanation}` : this.formatChange(change)
91884
- );
91885
- }
91886
- }
91887
- }
91888
- }
91889
- /**
91890
- * Determines if the changelog entry should be rendered as empty. This is the case when there are no relevant changes, breaking changes, or dependency bumps.
91891
- */
91892
- // protected override shouldRenderEmptyEntry(): boolean {
91893
- // return true;
91894
- // }
91895
- renderVersionTitle() {
91896
- const isMajorVersion = `${(0, import_semver.major)(this.changelogEntryVersion)}.0.0` === this.changelogEntryVersion.replace(/^v/, "");
91897
- return isMajorVersion ? `# ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}` : `## ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}`;
91898
- }
91899
- renderBreakingChanges() {
91900
- return [
91901
- "### Breaking Changes",
91902
- "",
91903
- ...Array.from(new Set(this.breakingChanges))
91904
- ];
91905
- }
91906
- renderDependencyBumps() {
91907
- const markdownLines = ["", "### Updated Dependencies", ""];
91908
- this.dependencyBumps?.forEach(({ dependencyName, newVersion }) => {
91909
- markdownLines.push(`- Updated ${dependencyName} to ${newVersion}`);
91910
- });
91911
- return markdownLines;
91912
- }
91913
- async renderAuthors() {
91914
- const markdownLines = [];
91915
- const _authors = /* @__PURE__ */ new Map();
91916
- for (const change of [
91917
- ...this.relevantChanges,
91918
- ...this.additionalChangesForAuthorsSection
91919
- ]) {
91920
- if (!change.authors) {
91921
- continue;
91922
- }
91923
- for (const author of change.authors) {
91924
- const name = this.formatName(author.name);
91925
- if (!name || name.includes("[bot]") || name === this.workspaceConfig?.bot.name) {
91926
- continue;
91927
- }
91928
- if (_authors.has(name)) {
91929
- const entry = _authors.get(name);
91930
- entry?.email.add(author.email);
91931
- } else {
91932
- _authors.set(name, { email: /* @__PURE__ */ new Set([author.email]) });
91933
- }
91934
- }
91935
- }
91936
- if (this.config.repoData && this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
91937
- await Promise.all(
91938
- [..._authors.keys()].map(async (authorName) => {
91939
- const meta = _authors.get(authorName);
91940
- if (!meta) {
91941
- return;
91942
- }
91943
- for (const email of meta.email) {
91944
- if (email.endsWith("@users.noreply.github.com")) {
91945
- const match = email.match(
91946
- /^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
91947
- );
91948
- if (match && match[2]) {
91949
- meta.github = match[2];
91950
- break;
91951
- }
91952
- }
91953
- const { data } = await axios_default.get(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
91954
- if (data?.user) {
91955
- meta.github = data.user.username;
91956
- break;
91957
- }
91958
- }
91959
- })
91960
- );
91961
- }
91962
- const authors = [..._authors.entries()].map((e) => ({
91963
- name: e[0],
91964
- ...e[1]
91965
- }));
91966
- if (authors.length > 0) {
91967
- markdownLines.push(
91968
- "",
91969
- "### \u2764\uFE0F Thank You",
91970
- "",
91971
- ...authors.sort((a, b) => a.name.localeCompare(b.name)).map((i) => {
91972
- const github = i.github ? ` @${i.github}` : "";
91973
- return `- ${i.name}${github}`;
91974
- })
91975
- );
91976
- }
91977
- return markdownLines;
91978
- }
91979
- formatChange(change) {
91980
- let description = change.description || "";
91981
- let extraLines = [];
91982
- let extraLinesStr = "";
91983
- if (description.includes("\n")) {
91984
- const lines2 = description.split("\n");
91985
- if (lines2.length > 1) {
91986
- description = lines2[0];
91987
- extraLines = lines2.slice(1);
91988
- }
91989
- const indentation = " ";
91990
- extraLinesStr = extraLines.filter((l2) => l2.trim().length > 0).map((l2) => `${indentation}${l2}`).join("\n");
91991
- }
91992
- let changeLine = "- " + (!this.isVersionPlans && change.scope ? `**${change.scope.trim()}:** ` : "") + description;
91993
- if (this.config.repoData && this.changelogRenderOptions.commitReferences && change.githubReferences) {
91994
- changeLine += formatReferences(
91995
- change.githubReferences,
91996
- this.config.repoData
91997
- );
91998
- }
91999
- if (extraLinesStr) {
92000
- changeLine += "\n\n" + extraLinesStr;
92001
- }
92002
- return changeLine;
92003
- }
92004
- };
92005
-
92006
92085
  // src/release/changelog.ts
92007
92086
  function createAPI(overrideReleaseConfig) {
92008
92087
  return async function releaseChangelog(args) {
@@ -92361,7 +92440,7 @@ ${contents}`);
92361
92440
  body: c.body,
92362
92441
  isBreaking: c.isBreaking,
92363
92442
  githubReferences: c.references,
92364
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92443
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92365
92444
  authors: [c.author],
92366
92445
  shortHash: c.shortHash,
92367
92446
  revertedHashes: c.revertedHashes,
@@ -92490,7 +92569,7 @@ ${contents}`);
92490
92569
  body: c.body,
92491
92570
  isBreaking: c.isBreaking,
92492
92571
  githubReferences: c.references,
92493
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92572
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92494
92573
  authors: [c.author],
92495
92574
  shortHash: c.shortHash,
92496
92575
  revertedHashes: c.revertedHashes,
@@ -92657,12 +92736,12 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92657
92736
  isDryRun: !!args.dryRun,
92658
92737
  isVerbose: !!args.verbose,
92659
92738
  gitCommitMessages: commitMessageValues,
92660
- gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.changelog?.git.commitArgs
92739
+ gitCommitArgs: args.gitCommitArgs ?? nxReleaseConfig.changelog?.git.commitArgs
92661
92740
  });
92662
92741
  latestCommit = await getCommitHash("HEAD");
92663
92742
  } else if ((args.stageChanges ?? nxReleaseConfig.changelog?.git.stageChanges) && changes.length) {
92664
92743
  output2.logSingleLine(`Staging changed files with git`);
92665
- await gitAdd({
92744
+ await gitAdd2({
92666
92745
  changedFiles,
92667
92746
  deletedFiles,
92668
92747
  dryRun: args.dryRun,
@@ -92687,7 +92766,6 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92687
92766
  gitRemote: args.gitRemote,
92688
92767
  dryRun: args.dryRun,
92689
92768
  verbose: args.verbose
92690
- // additionalArgs: ["--signed=if-asked"]
92691
92769
  });
92692
92770
  }
92693
92771
  for (const postGitTask of postGitTasks) {
@@ -92766,17 +92844,12 @@ async function generateChangelogForWorkspace({
92766
92844
  )}`
92767
92845
  });
92768
92846
  }
92769
- const githubRepoData = getGitHubRepoData(gitRemote, config.createRelease);
92770
- const remoteReleaseClient = await createRemoteReleaseClient(
92771
- config.createRelease,
92772
- gitRemote
92773
- );
92847
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92774
92848
  const changelogRenderer = new StormChangelogRenderer({
92775
92849
  changes,
92776
92850
  changelogEntryVersion: releaseVersion.rawVersion,
92777
92851
  project: null,
92778
92852
  isVersionPlans: false,
92779
- repoData: githubRepoData,
92780
92853
  entryWhenNoChanges: config.entryWhenNoChanges,
92781
92854
  changelogRenderOptions: config.renderOptions,
92782
92855
  conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
@@ -92785,7 +92858,7 @@ async function generateChangelogForWorkspace({
92785
92858
  let contents = await changelogRenderer.render();
92786
92859
  if (interactive) {
92787
92860
  const tmpDir = (0, import_tmp.dirSync)().name;
92788
- const changelogPath = joinPathFragments(
92861
+ const changelogPath = joinPathFragments2(
92789
92862
  tmpDir,
92790
92863
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92791
92864
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -92846,11 +92919,12 @@ async function generateChangelogForProjects({
92846
92919
  workspaceRoot: ""
92847
92920
  });
92848
92921
  }
92849
- if (!projectsVersionData[project.name]?.newVersion) {
92922
+ const newVersion = projectsVersionData[project.name]?.newVersion;
92923
+ if (!newVersion) {
92850
92924
  continue;
92851
92925
  }
92852
92926
  const releaseVersion = new ReleaseVersion2({
92853
- version: projectsVersionData[project.name].newVersion,
92927
+ version: newVersion,
92854
92928
  releaseTagPattern: releaseGroup.releaseTagPattern,
92855
92929
  projectName: project.name
92856
92930
  });
@@ -92861,19 +92935,11 @@ async function generateChangelogForProjects({
92861
92935
  releaseVersion.gitTag
92862
92936
  )}`
92863
92937
  });
92864
- const githubRepoData = getGitHubRepoData(
92865
- gitRemote,
92866
- config.createRelease
92867
- );
92868
- const remoteReleaseClient = await createRemoteReleaseClient(
92869
- config.createRelease,
92870
- gitRemote
92871
- );
92938
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92872
92939
  const changelogRenderer = new StormChangelogRenderer({
92873
92940
  changes,
92874
92941
  changelogEntryVersion: releaseVersion.rawVersion,
92875
92942
  project: project.name,
92876
- repoData: githubRepoData,
92877
92943
  entryWhenNoChanges: typeof config.entryWhenNoChanges === "string" ? interpolate(config.entryWhenNoChanges, {
92878
92944
  projectName: project.name,
92879
92945
  projectRoot: project.data.root,
@@ -92893,7 +92959,7 @@ ${contents}`.trim()
92893
92959
  });
92894
92960
  if (interactive) {
92895
92961
  const tmpDir = (0, import_tmp.dirSync)().name;
92896
- const changelogPath = joinPathFragments(
92962
+ const changelogPath = joinPathFragments2(
92897
92963
  tmpDir,
92898
92964
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92899
92965
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -93121,10 +93187,12 @@ var DEFAULT_RELEASE_CONFIG = {
93121
93187
 
93122
93188
  // src/release/run.ts
93123
93189
  var runRelease = async (config, options) => {
93124
- process.env.GIT_AUTHOR_NAME = process.env.GITHUB_ACTOR;
93125
- process.env.GIT_AUTHOR_EMAIL = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
93126
- process.env.GIT_COMMITTER_NAME = config.bot.name;
93127
- process.env.GIT_COMMITTER_EMAIL = config.bot.email || config.bot.name ? `${config.bot.name}@users.noreply.github.com` : "bot@stormsoftware.com";
93190
+ const name = config.bot.name;
93191
+ const email = config.bot.email ? config.bot.email : config.bot.name ? `${config.bot.name}@users.noreply.github.com` : "bot@stormsoftware.com";
93192
+ process.env.GIT_AUTHOR_NAME = name;
93193
+ process.env.GIT_AUTHOR_EMAIL = email;
93194
+ process.env.GIT_COMMITTER_NAME = name;
93195
+ process.env.GIT_COMMITTER_EMAIL = email;
93128
93196
  process.env.NODE_AUTH_TOKEN = process.env.NPM_TOKEN;
93129
93197
  process.env.NPM_AUTH_TOKEN = process.env.NPM_TOKEN;
93130
93198
  process.env.NPM_CONFIG_PROVENANCE = "true";