@storm-software/git-tools 2.111.24 → 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.
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) {
@@ -87909,6 +87906,7 @@ var chalk3 = __toESM(require_source(), 1);
87909
87906
  var import_enquirer2 = __toESM(require_enquirer(), 1);
87910
87907
  var import_semver2 = __toESM(require_semver4(), 1);
87911
87908
  var import_tmp = __toESM(require_tmp2(), 1);
87909
+ import { titleCase as titleCase2 } from "@stryke/string-format/title-case";
87912
87910
  import { readFileSync as readFileSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
87913
87911
  import {
87914
87912
  createNxReleaseConfig,
@@ -87927,7 +87925,7 @@ import {
87927
87925
  getFirstGitCommit,
87928
87926
  getGitDiff,
87929
87927
  getLatestGitTagForPattern,
87930
- gitAdd,
87928
+ gitAdd as gitAdd2,
87931
87929
  gitPush,
87932
87930
  parseCommits,
87933
87931
  parseGitCommit
@@ -87939,7 +87937,6 @@ import { defaultCreateReleaseProvider as defaultCreateReleaseProvider2 } from "n
87939
87937
  import { resolveNxJsonConfigErrorMessage } from "nx/src/command-line/release/utils/resolve-nx-json-error-message";
87940
87938
  import {
87941
87939
  ReleaseVersion as ReleaseVersion2,
87942
- commitChanges,
87943
87940
  createCommitMessageValues,
87944
87941
  createGitTagValues,
87945
87942
  handleDuplicateGitTags,
@@ -87957,11 +87954,12 @@ import { createProjectGraphAsync as createProjectGraphAsync4 } from "nx/src/proj
87957
87954
  import { interpolate } from "nx/src/tasks-runner/utils";
87958
87955
  import { isCI } from "nx/src/utils/is-ci";
87959
87956
  import { output as output2 } from "nx/src/utils/output";
87960
- import { joinPathFragments } from "nx/src/utils/path";
87957
+ import { joinPathFragments as joinPathFragments2 } from "nx/src/utils/path";
87961
87958
  import { workspaceRoot } from "nx/src/utils/workspace-root";
87962
87959
 
87963
87960
  // src/utilities/changelog-utils.ts
87964
87961
  init_esm_shims();
87962
+ import { titleCase } from "@stryke/string-format/title-case";
87965
87963
  import { format, resolveConfig } from "prettier";
87966
87964
  async function generateChangelogContent(releaseVersion, filepath, newContent, currentContent, project, workspaceConfig) {
87967
87965
  const formatOptions = await resolveConfig(filepath) ?? {};
@@ -88004,14 +88002,6 @@ ${changelogContents}`,
88004
88002
  }
88005
88003
  );
88006
88004
  }
88007
- var titleCase = (input) => {
88008
- if (!input) {
88009
- return "";
88010
- }
88011
- return input.split(/(?=[A-Z])|[\.\-\s_]/).map((s) => s.trim()).filter((s) => !!s).map(
88012
- (s) => s ? s.toLowerCase().charAt(0).toUpperCase() + s.toLowerCase().slice(1) : s
88013
- ).join(" ");
88014
- };
88015
88005
  function generateChangelogTitle(version3, project, workspaceConfig) {
88016
88006
  if (!workspaceConfig?.name || !project) {
88017
88007
  return version3;
@@ -88049,6 +88039,7 @@ function parseChangelogMarkdown(contents) {
88049
88039
  // src/utilities/git-utils.ts
88050
88040
  init_esm_shims();
88051
88041
  import { execCommand } from "nx/src/command-line/release/utils/exec-command.js";
88042
+ import { gitAdd } from "nx/src/command-line/release/utils/git";
88052
88043
  async function gitTag({
88053
88044
  tag,
88054
88045
  message: message2,
@@ -88091,6 +88082,76 @@ async function gitTag({
88091
88082
  ${err}`);
88092
88083
  }
88093
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
+ }
88094
88155
 
88095
88156
  // src/release/changelog-renderer.ts
88096
88157
  init_esm_shims();
@@ -91494,6 +91555,195 @@ var {
91494
91555
  var import_semver = __toESM(require_semver4(), 1);
91495
91556
  import DefaultChangelogRenderer from "nx/release/changelog-renderer";
91496
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
+ };
91497
91747
 
91498
91748
  // src/release/github.ts
91499
91749
  init_esm_shims();
@@ -91504,7 +91754,10 @@ import { execSync as execSync2 } from "node:child_process";
91504
91754
  import { existsSync as existsSync5, promises as fsp } from "node:fs";
91505
91755
  import { homedir } from "node:os";
91506
91756
  import { printDiff } from "nx/src/command-line/release/utils/print-changes";
91507
- 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";
91508
91761
  import {
91509
91762
  noDiffInChangelogMessage
91510
91763
  } from "nx/src/command-line/release/utils/shared";
@@ -91537,7 +91790,11 @@ function getGitHubRepoData(remoteName = "origin", createReleaseConfig) {
91537
91790
  );
91538
91791
  }
91539
91792
  } catch (error) {
91540
- return null;
91793
+ import_devkit.output.error({
91794
+ title: `Failed to get GitHub repo data`,
91795
+ bodyLines: [error.message]
91796
+ });
91797
+ return void 0;
91541
91798
  }
91542
91799
  }
91543
91800
  async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion, changelogContents, latestCommit, { dryRun }) {
@@ -91551,12 +91808,12 @@ async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion,
91551
91808
  });
91552
91809
  process.exit(1);
91553
91810
  }
91554
- const token = await resolveGithubToken(githubRepoData.hostname);
91811
+ const tokenData = await resolveTokenData(githubRepoData.hostname);
91555
91812
  const githubRequestConfig = {
91556
91813
  repo: githubRepoData.slug,
91557
91814
  hostname: githubRepoData.hostname,
91558
91815
  apiBaseUrl: githubRepoData.apiBaseUrl,
91559
- token
91816
+ token: tokenData?.token || null
91560
91817
  };
91561
91818
  let existingGithubReleaseForVersion;
91562
91819
  try {
@@ -91657,13 +91914,10 @@ Follow up in the browser to manually create the release:
91657
91914
  ` + chalk2.underline(chalk2.cyan(result2.url)) + "\n"
91658
91915
  );
91659
91916
  });
91660
- }
91661
- if (result2.status === "manual") {
91662
91917
  if (result2.error) {
91663
91918
  console.error(result2.error);
91664
91919
  process.exitCode = 1;
91665
91920
  }
91666
- const open2 = (init_open(), __toCommonJS(open_exports));
91667
91921
  await open2(result2.url).then(() => {
91668
91922
  console.info(
91669
91923
  `Follow up in the browser to manually create the release.`
@@ -91733,13 +91987,13 @@ async function syncGithubRelease(githubRequestConfig, release, existingGithubRel
91733
91987
  };
91734
91988
  }
91735
91989
  }
91736
- async function resolveGithubToken(hostname) {
91737
- 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;
91738
91992
  if (tokenFromEnv) {
91739
- return tokenFromEnv;
91993
+ return { token: tokenFromEnv, headerName: "Authorization" };
91740
91994
  }
91741
- const ghCLIPath = joinPaths(
91742
- 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"),
91743
91997
  "gh",
91744
91998
  "hosts.yml"
91745
91999
  );
@@ -91752,11 +92006,12 @@ async function resolveGithubToken(hostname) {
91752
92006
  return ghCLIConfig[hostname].oauth_token;
91753
92007
  }
91754
92008
  if (ghCLIConfig[hostname].user && ghCLIConfig[hostname].git_protocol === "ssh") {
91755
- return execSync2(`gh auth token`, {
92009
+ const token = execSync2(`gh auth token`, {
91756
92010
  encoding: "utf8",
91757
92011
  stdio: "pipe",
91758
92012
  windowsHide: false
91759
92013
  }).trim();
92014
+ return { token, headerName: "Authorization" };
91760
92015
  }
91761
92016
  }
91762
92017
  }
@@ -91765,7 +92020,9 @@ async function resolveGithubToken(hostname) {
91765
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.`
91766
92021
  );
91767
92022
  }
91768
- 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
+ );
91769
92026
  }
91770
92027
  async function getGithubReleaseByTag(config, tag) {
91771
92028
  return await makeGithubRequest(
@@ -91807,206 +92064,24 @@ function githubNewReleaseURL(config, release) {
91807
92064
  }
91808
92065
  return url2;
91809
92066
  }
91810
- var providerToRefSpec = {
91811
- github: { "pull-request": "pull", hash: "commit", issue: "issues" }
91812
- };
91813
- function formatReference(ref, repoData) {
91814
- const refSpec = providerToRefSpec["github"];
91815
- return `[${ref.value}](https://${repoData.hostname}/${repoData.slug}/${refSpec[ref.type]}/${ref.value.replace(/^#/, "")})`;
91816
- }
91817
- function formatReferences(references, repoData) {
91818
- const pr2 = references.filter((ref) => ref.type === "pull-request");
91819
- const issue = references.filter((ref) => ref.type === "issue");
91820
- if (pr2.length > 0 || issue.length > 0) {
91821
- return " (" + [...pr2, ...issue].map((ref) => formatReference(ref, repoData)).join(", ") + ")";
91822
- }
91823
- if (references.length > 0) {
91824
- 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
+ );
91825
92073
  }
91826
- 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
+ );
91827
92083
  }
91828
92084
 
91829
- // src/release/changelog-renderer.ts
91830
- var StormChangelogRenderer = class extends DefaultChangelogRenderer {
91831
- /**
91832
- * The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
91833
- */
91834
- workspaceConfig = null;
91835
- /**
91836
- * 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).
91837
- *
91838
- * @param config - The configuration object for the ChangelogRenderer
91839
- */
91840
- constructor(config) {
91841
- super(config);
91842
- }
91843
- async render() {
91844
- this.workspaceConfig = await getWorkspaceConfig();
91845
- return await super.render();
91846
- }
91847
- preprocessChanges() {
91848
- this.relevantChanges = [...this.changes];
91849
- this.breakingChanges = [];
91850
- this.additionalChangesForAuthorsSection = [];
91851
- for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91852
- const change = this.relevantChanges[i];
91853
- if (change && change.type === "revert" && change.revertedHashes) {
91854
- for (const revertedHash of change.revertedHashes) {
91855
- const revertedCommitIndex = this.relevantChanges.findIndex(
91856
- (c) => c.shortHash && revertedHash.startsWith(c.shortHash)
91857
- );
91858
- if (revertedCommitIndex !== -1) {
91859
- this.relevantChanges.splice(revertedCommitIndex, 1);
91860
- this.relevantChanges.splice(i, 1);
91861
- i--;
91862
- break;
91863
- }
91864
- }
91865
- }
91866
- }
91867
- if (this.isVersionPlans) {
91868
- this.conventionalCommitsConfig = {
91869
- types: {
91870
- feat: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.feat,
91871
- fix: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.fix
91872
- }
91873
- };
91874
- for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91875
- if (this.relevantChanges[i]?.isBreaking) {
91876
- const change = this.relevantChanges[i];
91877
- if (change) {
91878
- this.additionalChangesForAuthorsSection.push(change);
91879
- const line = this.formatChange(change);
91880
- this.breakingChanges.push(line);
91881
- this.relevantChanges.splice(i, 1);
91882
- }
91883
- }
91884
- }
91885
- } else {
91886
- for (const change of this.relevantChanges) {
91887
- if (change.isBreaking) {
91888
- const breakingChangeExplanation = change.body ? this.extractBreakingChangeExplanation(change.body) : "";
91889
- this.breakingChanges.push(
91890
- breakingChangeExplanation ? `- ${change.scope ? `**${change.scope.trim()}:** ` : ""}${breakingChangeExplanation}` : this.formatChange(change)
91891
- );
91892
- }
91893
- }
91894
- }
91895
- }
91896
- /**
91897
- * 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.
91898
- */
91899
- // protected override shouldRenderEmptyEntry(): boolean {
91900
- // return true;
91901
- // }
91902
- renderVersionTitle() {
91903
- const isMajorVersion = `${(0, import_semver.major)(this.changelogEntryVersion)}.0.0` === this.changelogEntryVersion.replace(/^v/, "");
91904
- return isMajorVersion ? `# ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}` : `## ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}`;
91905
- }
91906
- renderBreakingChanges() {
91907
- return [
91908
- "### Breaking Changes",
91909
- "",
91910
- ...Array.from(new Set(this.breakingChanges))
91911
- ];
91912
- }
91913
- renderDependencyBumps() {
91914
- const markdownLines = ["", "### Updated Dependencies", ""];
91915
- this.dependencyBumps?.forEach(({ dependencyName, newVersion }) => {
91916
- markdownLines.push(`- Updated ${dependencyName} to ${newVersion}`);
91917
- });
91918
- return markdownLines;
91919
- }
91920
- async renderAuthors() {
91921
- const markdownLines = [];
91922
- const _authors = /* @__PURE__ */ new Map();
91923
- for (const change of [
91924
- ...this.relevantChanges,
91925
- ...this.additionalChangesForAuthorsSection
91926
- ]) {
91927
- if (!change.authors) {
91928
- continue;
91929
- }
91930
- for (const author of change.authors) {
91931
- const name = this.formatName(author.name);
91932
- if (!name || name.includes("[bot]") || name === this.workspaceConfig?.bot.name) {
91933
- continue;
91934
- }
91935
- if (_authors.has(name)) {
91936
- const entry = _authors.get(name);
91937
- entry?.email.add(author.email);
91938
- } else {
91939
- _authors.set(name, { email: /* @__PURE__ */ new Set([author.email]) });
91940
- }
91941
- }
91942
- }
91943
- if (this.repoData && this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
91944
- await Promise.all(
91945
- [..._authors.keys()].map(async (authorName) => {
91946
- const meta = _authors.get(authorName);
91947
- if (!meta) {
91948
- return;
91949
- }
91950
- for (const email of meta.email) {
91951
- if (email.endsWith("@users.noreply.github.com")) {
91952
- const match = email.match(
91953
- /^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
91954
- );
91955
- if (match && match[2]) {
91956
- meta.github = match[2];
91957
- break;
91958
- }
91959
- }
91960
- const { data } = await axios_default.get(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
91961
- if (data?.user) {
91962
- meta.github = data.user.username;
91963
- break;
91964
- }
91965
- }
91966
- })
91967
- );
91968
- }
91969
- const authors = [..._authors.entries()].map((e) => ({
91970
- name: e[0],
91971
- ...e[1]
91972
- }));
91973
- if (authors.length > 0) {
91974
- markdownLines.push(
91975
- "",
91976
- "### \u2764\uFE0F Thank You",
91977
- "",
91978
- ...authors.sort((a, b) => a.name.localeCompare(b.name)).map((i) => {
91979
- const github = i.github ? ` @${i.github}` : "";
91980
- return `- ${i.name}${github}`;
91981
- })
91982
- );
91983
- }
91984
- return markdownLines;
91985
- }
91986
- formatChange(change) {
91987
- let description = change.description || "";
91988
- let extraLines = [];
91989
- let extraLinesStr = "";
91990
- if (description.includes("\n")) {
91991
- const lines2 = description.split("\n");
91992
- if (lines2.length > 1) {
91993
- description = lines2[0];
91994
- extraLines = lines2.slice(1);
91995
- }
91996
- const indentation = " ";
91997
- extraLinesStr = extraLines.filter((l2) => l2.trim().length > 0).map((l2) => `${indentation}${l2}`).join("\n");
91998
- }
91999
- let changeLine = "- " + (!this.isVersionPlans && change.scope ? `**${change.scope.trim()}:** ` : "") + description;
92000
- if (this.repoData && this.changelogRenderOptions.commitReferences && change.githubReferences) {
92001
- changeLine += formatReferences(change.githubReferences, this.repoData);
92002
- }
92003
- if (extraLinesStr) {
92004
- changeLine += "\n\n" + extraLinesStr;
92005
- }
92006
- return changeLine;
92007
- }
92008
- };
92009
-
92010
92085
  // src/release/changelog.ts
92011
92086
  function createAPI(overrideReleaseConfig) {
92012
92087
  return async function releaseChangelog(args) {
@@ -92365,7 +92440,7 @@ ${contents}`);
92365
92440
  body: c.body,
92366
92441
  isBreaking: c.isBreaking,
92367
92442
  githubReferences: c.references,
92368
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92443
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92369
92444
  authors: [c.author],
92370
92445
  shortHash: c.shortHash,
92371
92446
  revertedHashes: c.revertedHashes,
@@ -92494,7 +92569,7 @@ ${contents}`);
92494
92569
  body: c.body,
92495
92570
  isBreaking: c.isBreaking,
92496
92571
  githubReferences: c.references,
92497
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92572
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92498
92573
  authors: [c.author],
92499
92574
  shortHash: c.shortHash,
92500
92575
  revertedHashes: c.revertedHashes,
@@ -92661,12 +92736,12 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92661
92736
  isDryRun: !!args.dryRun,
92662
92737
  isVerbose: !!args.verbose,
92663
92738
  gitCommitMessages: commitMessageValues,
92664
- gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.changelog?.git.commitArgs
92739
+ gitCommitArgs: args.gitCommitArgs ?? nxReleaseConfig.changelog?.git.commitArgs
92665
92740
  });
92666
92741
  latestCommit = await getCommitHash("HEAD");
92667
92742
  } else if ((args.stageChanges ?? nxReleaseConfig.changelog?.git.stageChanges) && changes.length) {
92668
92743
  output2.logSingleLine(`Staging changed files with git`);
92669
- await gitAdd({
92744
+ await gitAdd2({
92670
92745
  changedFiles,
92671
92746
  deletedFiles,
92672
92747
  dryRun: args.dryRun,
@@ -92691,7 +92766,6 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92691
92766
  gitRemote: args.gitRemote,
92692
92767
  dryRun: args.dryRun,
92693
92768
  verbose: args.verbose
92694
- // additionalArgs: ["--signed=if-asked"]
92695
92769
  });
92696
92770
  }
92697
92771
  for (const postGitTask of postGitTasks) {
@@ -92702,11 +92776,9 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92702
92776
  async function generateChangelogForWorkspace({
92703
92777
  tree,
92704
92778
  args,
92705
- projectGraph,
92706
92779
  nxReleaseConfig,
92707
92780
  workspaceChangelogVersion,
92708
- changes,
92709
- commits
92781
+ changes
92710
92782
  }) {
92711
92783
  const workspaceConfig = await getWorkspaceConfig();
92712
92784
  if (!workspaceConfig) {
@@ -92772,21 +92844,21 @@ async function generateChangelogForWorkspace({
92772
92844
  )}`
92773
92845
  });
92774
92846
  }
92775
- const githubRepoData = getGitHubRepoData(gitRemote, config.createRelease);
92847
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92776
92848
  const changelogRenderer = new StormChangelogRenderer({
92777
92849
  changes,
92778
92850
  changelogEntryVersion: releaseVersion.rawVersion,
92779
92851
  project: null,
92780
92852
  isVersionPlans: false,
92781
- repoData: githubRepoData,
92782
92853
  entryWhenNoChanges: config.entryWhenNoChanges,
92783
92854
  changelogRenderOptions: config.renderOptions,
92784
- conventionalCommitsConfig: nxReleaseConfig.conventionalCommits
92855
+ conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
92856
+ remoteReleaseClient
92785
92857
  });
92786
92858
  let contents = await changelogRenderer.render();
92787
92859
  if (interactive) {
92788
92860
  const tmpDir = (0, import_tmp.dirSync)().name;
92789
- const changelogPath = joinPathFragments(
92861
+ const changelogPath = joinPathFragments2(
92790
92862
  tmpDir,
92791
92863
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92792
92864
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -92847,11 +92919,12 @@ async function generateChangelogForProjects({
92847
92919
  workspaceRoot: ""
92848
92920
  });
92849
92921
  }
92850
- if (!projectsVersionData[project.name]?.newVersion) {
92922
+ const newVersion = projectsVersionData[project.name]?.newVersion;
92923
+ if (!newVersion) {
92851
92924
  continue;
92852
92925
  }
92853
92926
  const releaseVersion = new ReleaseVersion2({
92854
- version: projectsVersionData[project.name].newVersion,
92927
+ version: newVersion,
92855
92928
  releaseTagPattern: releaseGroup.releaseTagPattern,
92856
92929
  projectName: project.name
92857
92930
  });
@@ -92862,15 +92935,11 @@ async function generateChangelogForProjects({
92862
92935
  releaseVersion.gitTag
92863
92936
  )}`
92864
92937
  });
92865
- const githubRepoData = getGitHubRepoData(
92866
- gitRemote,
92867
- config.createRelease
92868
- );
92938
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92869
92939
  const changelogRenderer = new StormChangelogRenderer({
92870
92940
  changes,
92871
92941
  changelogEntryVersion: releaseVersion.rawVersion,
92872
92942
  project: project.name,
92873
- repoData: githubRepoData,
92874
92943
  entryWhenNoChanges: typeof config.entryWhenNoChanges === "string" ? interpolate(config.entryWhenNoChanges, {
92875
92944
  projectName: project.name,
92876
92945
  projectRoot: project.data.root,
@@ -92879,7 +92948,8 @@ async function generateChangelogForProjects({
92879
92948
  changelogRenderOptions: config.renderOptions,
92880
92949
  isVersionPlans: !!releaseGroup.versionPlans,
92881
92950
  conventionalCommitsConfig: releaseGroup.versionPlans ? null : nxReleaseConfig.conventionalCommits,
92882
- dependencyBumps: projectToAdditionalDependencyBumps.get(project.name)
92951
+ dependencyBumps: projectToAdditionalDependencyBumps.get(project.name),
92952
+ remoteReleaseClient
92883
92953
  });
92884
92954
  let contents = await changelogRenderer.render();
92885
92955
  output2.log({
@@ -92889,7 +92959,7 @@ ${contents}`.trim()
92889
92959
  });
92890
92960
  if (interactive) {
92891
92961
  const tmpDir = (0, import_tmp.dirSync)().name;
92892
- const changelogPath = joinPathFragments(
92962
+ const changelogPath = joinPathFragments2(
92893
92963
  tmpDir,
92894
92964
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92895
92965
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -93027,16 +93097,16 @@ function formatGithubReleaseNotes(releaseVersion, content, projectName, workspac
93027
93097
  if (!workspaceConfig) {
93028
93098
  return content;
93029
93099
  }
93030
- return `![${titleCase(workspaceConfig.organization)?.replaceAll(" ", "-")}](${workspaceConfig.release.banner})
93100
+ return `![${titleCase2(workspaceConfig.organization)?.replaceAll(" ", "-")}](${workspaceConfig.release.banner})
93031
93101
  ${workspaceConfig.release.header || ""}
93032
93102
 
93033
- # ${projectName ? `${titleCase(projectName)} ` : ""}v${releaseVersion.rawVersion}
93103
+ # ${projectName ? `${titleCase2(projectName)} ` : ""}v${releaseVersion.rawVersion}
93034
93104
 
93035
- We at [${titleCase(workspaceConfig.organization)}](${workspaceConfig.homepage}) are very excited to announce the v${releaseVersion.rawVersion} release of the ${projectName ? titleCase(projectName) : workspaceConfig.name ? titleCase(workspaceConfig.name) : "Storm Software"} project! \u{1F680}
93105
+ We at [${titleCase2(workspaceConfig.organization)}](${workspaceConfig.homepage}) are very excited to announce the v${releaseVersion.rawVersion} release of the ${projectName ? titleCase2(projectName) : workspaceConfig.name ? titleCase2(workspaceConfig.name) : "Storm Software"} project! \u{1F680}
93036
93106
 
93037
93107
  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}).
93038
93108
 
93039
- If you have any questions or comments, feel free to reach out to the team on [Discord](${workspaceConfig.account.discord}) or [our contact page](${workspaceConfig.contact}). Please help us spread the word by giving [this repository](https://github.com/${workspaceConfig.organization}/${workspaceConfig.name}) a star \u2B50 on GitHub or [posting on X (Twitter)](https://x.com/intent/tweet?text=Check%20out%20the%20latest%20@${workspaceConfig.account.twitter}%20release%20${projectName ? `${titleCase(projectName)?.replaceAll(" ", "%20")}%20` : ""}v${releaseVersion.rawVersion}%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/${workspaceConfig.organization}/${workspaceConfig.name}/releases/tag/${releaseVersion.gitTag}) about this release!
93109
+ If you have any questions or comments, feel free to reach out to the team on [Discord](${workspaceConfig.account.discord}) or [our contact page](${workspaceConfig.contact}). Please help us spread the word by giving [this repository](https://github.com/${workspaceConfig.organization}/${workspaceConfig.name}) a star \u2B50 on GitHub or [posting on X (Twitter)](https://x.com/intent/tweet?text=Check%20out%20the%20latest%20@${workspaceConfig.account.twitter}%20release%20${projectName ? `${titleCase2(projectName)?.replaceAll(" ", "%20")}%20` : ""}v${releaseVersion.rawVersion}%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/${workspaceConfig.organization}/${workspaceConfig.name}/releases/tag/${releaseVersion.gitTag}) about this release!
93040
93110
 
93041
93111
  ## Release Notes
93042
93112
 
@@ -93073,6 +93143,8 @@ var DEFAULT_RELEASE_GROUP_CONFIG = {
93073
93143
  version: {
93074
93144
  groupPreVersionCommand: "pnpm build",
93075
93145
  useLegacyVersioning: true,
93146
+ currentVersionResolver: "git-tag",
93147
+ specifierSource: "conventional-commits",
93076
93148
  generator: "@storm-software/workspace-tools:release-version",
93077
93149
  generatorOptions: {
93078
93150
  currentVersionResolver: "git-tag",
@@ -93103,6 +93175,8 @@ var DEFAULT_RELEASE_CONFIG = {
93103
93175
  version: {
93104
93176
  preVersionCommand: "pnpm build",
93105
93177
  useLegacyVersioning: true,
93178
+ currentVersionResolver: "git-tag",
93179
+ specifierSource: "conventional-commits",
93106
93180
  generator: "@storm-software/workspace-tools:release-version",
93107
93181
  generatorOptions: {
93108
93182
  currentVersionResolver: "git-tag",
@@ -93113,10 +93187,12 @@ var DEFAULT_RELEASE_CONFIG = {
93113
93187
 
93114
93188
  // src/release/run.ts
93115
93189
  var runRelease = async (config, options) => {
93116
- process.env.GIT_AUTHOR_NAME = process.env.GITHUB_ACTOR;
93117
- process.env.GIT_AUTHOR_EMAIL = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
93118
- process.env.GIT_COMMITTER_NAME = config.bot.name;
93119
- 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;
93120
93196
  process.env.NODE_AUTH_TOKEN = process.env.NPM_TOKEN;
93121
93197
  process.env.NPM_AUTH_TOKEN = process.env.NPM_TOKEN;
93122
93198
  process.env.NPM_CONFIG_PROVENANCE = "true";