@storm-software/git-tools 2.111.25 → 2.111.27

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 +601 -291
  3. package/bin/git.js +564 -254
  4. package/package.json +1 -2
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,7 +87906,6 @@ 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);
87912
- import { titleCase as titleCase2 } from "@stryke/string-format/title-case";
87913
87909
  import { readFileSync as readFileSync4, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "node:fs";
87914
87910
  import {
87915
87911
  createNxReleaseConfig,
@@ -87928,7 +87924,7 @@ import {
87928
87924
  getFirstGitCommit,
87929
87925
  getGitDiff,
87930
87926
  getLatestGitTagForPattern,
87931
- gitAdd,
87927
+ gitAdd as gitAdd2,
87932
87928
  gitPush,
87933
87929
  parseCommits,
87934
87930
  parseGitCommit
@@ -87937,11 +87933,9 @@ import { launchEditor } from "nx/src/command-line/release/utils/launch-editor";
87937
87933
  import { printAndFlushChanges } from "nx/src/command-line/release/utils/print-changes";
87938
87934
  import { printConfigAndExit } from "nx/src/command-line/release/utils/print-config";
87939
87935
  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
87936
  import { resolveNxJsonConfigErrorMessage } from "nx/src/command-line/release/utils/resolve-nx-json-error-message";
87942
87937
  import {
87943
87938
  ReleaseVersion as ReleaseVersion2,
87944
- commitChanges,
87945
87939
  createCommitMessageValues,
87946
87940
  createGitTagValues,
87947
87941
  handleDuplicateGitTags,
@@ -87959,13 +87953,256 @@ import { createProjectGraphAsync as createProjectGraphAsync4 } from "nx/src/proj
87959
87953
  import { interpolate } from "nx/src/tasks-runner/utils";
87960
87954
  import { isCI } from "nx/src/utils/is-ci";
87961
87955
  import { output as output2 } from "nx/src/utils/output";
87962
- import { joinPathFragments } from "nx/src/utils/path";
87956
+ import { joinPathFragments as joinPathFragments2 } from "nx/src/utils/path";
87963
87957
  import { workspaceRoot } from "nx/src/utils/workspace-root";
87964
87958
 
87965
87959
  // src/utilities/changelog-utils.ts
87966
87960
  init_esm_shims();
87967
- import { titleCase } from "@stryke/string-format/title-case";
87968
87961
  import { format, resolveConfig } from "prettier";
87962
+
87963
+ // src/utilities/title-case.ts
87964
+ init_esm_shims();
87965
+ var ACRONYMS = [
87966
+ "3D",
87967
+ "4D",
87968
+ "5G",
87969
+ "6G",
87970
+ "7G",
87971
+ "8G",
87972
+ "ACID",
87973
+ "AES",
87974
+ "AI",
87975
+ "AJAX",
87976
+ "API",
87977
+ "AR",
87978
+ "ASCII",
87979
+ "B2B",
87980
+ "B2C",
87981
+ "BFF",
87982
+ "BI",
87983
+ "BIOS",
87984
+ "BGP",
87985
+ "BOM",
87986
+ "BYOD",
87987
+ "C2C",
87988
+ "CAGR",
87989
+ "CAPTCHA",
87990
+ "CD",
87991
+ "CDN",
87992
+ "CDP",
87993
+ "CI",
87994
+ "CI/CD",
87995
+ "CIAM",
87996
+ "CICD",
87997
+ "CLI",
87998
+ "CMDB",
87999
+ "CORS",
88000
+ "CPU",
88001
+ "CRUD",
88002
+ "CSR",
88003
+ "CSS",
88004
+ "CX",
88005
+ "DAG",
88006
+ "DBMS",
88007
+ "DDoS",
88008
+ "DNS",
88009
+ "DNSSEC",
88010
+ "DOM",
88011
+ "DR",
88012
+ "DRM",
88013
+ "DWH",
88014
+ "E2E",
88015
+ "EAI",
88016
+ "EKS",
88017
+ "EOF",
88018
+ "EOD",
88019
+ "ETC",
88020
+ "ETL",
88021
+ "EULA",
88022
+ "FIDO",
88023
+ "FQDN",
88024
+ "FTP",
88025
+ "FaaS",
88026
+ "GDPR",
88027
+ "GCP",
88028
+ "GPU",
88029
+ "GUID",
88030
+ "GUI",
88031
+ "GZIP",
88032
+ "HCI",
88033
+ "HDD",
88034
+ "HDFS",
88035
+ "HIPAA",
88036
+ "HMAC",
88037
+ "HOTP",
88038
+ "HSM",
88039
+ "HTML",
88040
+ "HTTP",
88041
+ "HTTP/2",
88042
+ "HTTP/2.0",
88043
+ "HTTP/3",
88044
+ "HTTP/3.0",
88045
+ "HTTP2",
88046
+ "HTTPS",
88047
+ "HTTPS/2",
88048
+ "HTTPS/3",
88049
+ "HTTPS3",
88050
+ "IAM",
88051
+ "IAMM",
88052
+ "IAMT",
88053
+ "IaaS",
88054
+ "ID",
88055
+ "IMAP",
88056
+ "IP",
88057
+ "IPFS",
88058
+ "IoT",
88059
+ "JSON",
88060
+ "JSONP",
88061
+ "JWT",
88062
+ "K8s",
88063
+ "KMS",
88064
+ "KPI",
88065
+ "LAN",
88066
+ "LHS",
88067
+ "LXC",
88068
+ "MFA",
88069
+ "ML",
88070
+ "MLOps",
88071
+ "MVC",
88072
+ "MVP",
88073
+ "NAS",
88074
+ "NAT",
88075
+ "NDA",
88076
+ "NFS",
88077
+ "NIST",
88078
+ "NLP",
88079
+ "NPS",
88080
+ "OCR",
88081
+ "OEM",
88082
+ "OKR",
88083
+ "OLAP",
88084
+ "OLTP",
88085
+ "OOP",
88086
+ "ORM",
88087
+ "OS",
88088
+ "OTP",
88089
+ "P2P",
88090
+ "PDP",
88091
+ "PaaS",
88092
+ "PCI",
88093
+ "PKI",
88094
+ "PP",
88095
+ "PWA",
88096
+ "PX",
88097
+ "QA",
88098
+ "RAID",
88099
+ "RAM",
88100
+ "RDS",
88101
+ "REST",
88102
+ "RHS",
88103
+ "RPC",
88104
+ "RPA",
88105
+ "RUM",
88106
+ "RSS",
88107
+ "SAN",
88108
+ "SASE",
88109
+ "SDLC",
88110
+ "SDK",
88111
+ "SEO",
88112
+ "SFTP",
88113
+ "SIEM",
88114
+ "SLA",
88115
+ "SMB",
88116
+ "SMTP",
88117
+ "SOAP",
88118
+ "SOC",
88119
+ "SOA",
88120
+ "SPDY",
88121
+ "SPF",
88122
+ "SQL",
88123
+ "SRV",
88124
+ "SRE",
88125
+ "SSH",
88126
+ "SSDL",
88127
+ "SSO",
88128
+ "SSL",
88129
+ "SSR",
88130
+ "TDD",
88131
+ "TLD",
88132
+ "TLS",
88133
+ "TLS1.3",
88134
+ "TOTP",
88135
+ "TRPC",
88136
+ "TTL",
88137
+ "UDP",
88138
+ "UI",
88139
+ "UID",
88140
+ "URI",
88141
+ "URL",
88142
+ "UTF",
88143
+ "UUID",
88144
+ "UX",
88145
+ "VM",
88146
+ "VLAN",
88147
+ "VPN",
88148
+ "VR",
88149
+ "WAF",
88150
+ "WAN",
88151
+ "WLAN",
88152
+ "WPA",
88153
+ "XACML",
88154
+ "XML",
88155
+ "XSRF",
88156
+ "XSS",
88157
+ "XR",
88158
+ "YAML",
88159
+ "ZTA"
88160
+ ];
88161
+ var FORMAT_MAPPING = ACRONYMS.reduce(
88162
+ (ret, acronym) => {
88163
+ ret[acronym.toLowerCase()] = acronym;
88164
+ return ret;
88165
+ },
88166
+ {
88167
+ cspell: "CSpell",
88168
+ eslint: "ESLint",
88169
+ nx: "Nx"
88170
+ }
88171
+ );
88172
+ var LOWER_CASE_WHEN_NOT_FIRST = [
88173
+ "a",
88174
+ "an",
88175
+ "the",
88176
+ "is",
88177
+ "are",
88178
+ "of",
88179
+ "and",
88180
+ "to",
88181
+ "in",
88182
+ "for",
88183
+ "on",
88184
+ "with",
88185
+ "as",
88186
+ "at",
88187
+ "by"
88188
+ ];
88189
+ function titleCase(input) {
88190
+ if (!input) {
88191
+ return input;
88192
+ }
88193
+ const formatSegment = (segment) => segment.toLowerCase().split(/[\s\-_]+/).filter(Boolean).map((word, index) => {
88194
+ if (LOWER_CASE_WHEN_NOT_FIRST.includes(word.toLowerCase()) && index > 0) {
88195
+ return word.toLowerCase();
88196
+ }
88197
+ if (Object.keys(FORMAT_MAPPING).includes(word.toLowerCase())) {
88198
+ return FORMAT_MAPPING[word.toLowerCase()];
88199
+ }
88200
+ return `${word ? word.charAt(0).toUpperCase() + word.toLowerCase().slice(1) : word}`;
88201
+ }).join(" ");
88202
+ return input.split(/\s+-\s+/).map((part2) => formatSegment(part2)).join(" - ");
88203
+ }
88204
+
88205
+ // src/utilities/changelog-utils.ts
87969
88206
  async function generateChangelogContent(releaseVersion, filepath, newContent, currentContent, project, workspaceConfig) {
87970
88207
  const formatOptions = await resolveConfig(filepath) ?? {};
87971
88208
  const header = await format(
@@ -88044,6 +88281,7 @@ function parseChangelogMarkdown(contents) {
88044
88281
  // src/utilities/git-utils.ts
88045
88282
  init_esm_shims();
88046
88283
  import { execCommand } from "nx/src/command-line/release/utils/exec-command.js";
88284
+ import { gitAdd } from "nx/src/command-line/release/utils/git";
88047
88285
  async function gitTag({
88048
88286
  tag,
88049
88287
  message: message2,
@@ -88086,6 +88324,76 @@ async function gitTag({
88086
88324
  ${err}`);
88087
88325
  }
88088
88326
  }
88327
+ async function gitCommit({
88328
+ messages,
88329
+ additionalArgs,
88330
+ dryRun,
88331
+ verbose,
88332
+ logFn
88333
+ }) {
88334
+ logFn = logFn || console.log;
88335
+ const commandArgs = ["commit", "-S"];
88336
+ for (const message2 of messages) {
88337
+ commandArgs.push("--message", message2);
88338
+ }
88339
+ if (additionalArgs) {
88340
+ if (Array.isArray(additionalArgs)) {
88341
+ commandArgs.push(...additionalArgs);
88342
+ } else {
88343
+ commandArgs.push(...additionalArgs.split(" "));
88344
+ }
88345
+ }
88346
+ if (verbose) {
88347
+ logFn(
88348
+ 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:`
88349
+ );
88350
+ logFn(`git ${commandArgs.join(" ")}`);
88351
+ }
88352
+ if (dryRun) {
88353
+ return;
88354
+ }
88355
+ let hasStagedFiles = false;
88356
+ try {
88357
+ await execCommand("git", ["diff-index", "--quiet", "HEAD", "--cached"]);
88358
+ } catch {
88359
+ hasStagedFiles = true;
88360
+ }
88361
+ if (!hasStagedFiles) {
88362
+ logFn("\nNo staged files found. Skipping commit.");
88363
+ return;
88364
+ }
88365
+ return execCommand("git", commandArgs);
88366
+ }
88367
+ async function commitChanges({
88368
+ changedFiles,
88369
+ deletedFiles,
88370
+ isDryRun,
88371
+ isVerbose: isVerbose2,
88372
+ gitCommitMessages,
88373
+ gitCommitArgs,
88374
+ logFn
88375
+ }) {
88376
+ logFn = logFn || console.log;
88377
+ if (!changedFiles?.length && !deletedFiles?.length) {
88378
+ throw new Error("Error: No changed files to commit");
88379
+ }
88380
+ logFn(`Committing changes with git`);
88381
+ await gitAdd({
88382
+ changedFiles,
88383
+ deletedFiles,
88384
+ dryRun: isDryRun,
88385
+ verbose: isVerbose2
88386
+ });
88387
+ if (isVerbose2) {
88388
+ console.log("");
88389
+ }
88390
+ await gitCommit({
88391
+ messages: gitCommitMessages || [],
88392
+ additionalArgs: gitCommitArgs,
88393
+ dryRun: isDryRun,
88394
+ verbose: isVerbose2
88395
+ });
88396
+ }
88089
88397
 
88090
88398
  // src/release/changelog-renderer.ts
88091
88399
  init_esm_shims();
@@ -91489,6 +91797,195 @@ var {
91489
91797
  var import_semver = __toESM(require_semver4(), 1);
91490
91798
  import DefaultChangelogRenderer from "nx/release/changelog-renderer";
91491
91799
  import { DEFAULT_CONVENTIONAL_COMMITS_CONFIG } from "nx/src/command-line/release/config/conventional-commits";
91800
+ var StormChangelogRenderer = class extends DefaultChangelogRenderer {
91801
+ /**
91802
+ * The Storm workspace configuration object, which is loaded from the storm-workspace.json file.
91803
+ */
91804
+ workspaceConfig = null;
91805
+ /**
91806
+ * The configuration object for the ChangelogRenderer, which includes the changes, version, project, and other options.
91807
+ */
91808
+ config;
91809
+ /**
91810
+ * 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).
91811
+ *
91812
+ * @param config - The configuration object for the ChangelogRenderer
91813
+ */
91814
+ constructor(config) {
91815
+ super(config);
91816
+ this.config = {
91817
+ ...config,
91818
+ repoData: config.remoteReleaseClient.getRemoteRepoData()
91819
+ };
91820
+ }
91821
+ async render() {
91822
+ this.workspaceConfig = await getWorkspaceConfig();
91823
+ return await super.render();
91824
+ }
91825
+ preprocessChanges() {
91826
+ this.relevantChanges = [...this.changes];
91827
+ this.breakingChanges = [];
91828
+ this.additionalChangesForAuthorsSection = [];
91829
+ for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91830
+ const change = this.relevantChanges[i];
91831
+ if (change && change.type === "revert" && change.revertedHashes) {
91832
+ for (const revertedHash of change.revertedHashes) {
91833
+ const revertedCommitIndex = this.relevantChanges.findIndex(
91834
+ (c) => c.shortHash && revertedHash.startsWith(c.shortHash)
91835
+ );
91836
+ if (revertedCommitIndex !== -1) {
91837
+ this.relevantChanges.splice(revertedCommitIndex, 1);
91838
+ this.relevantChanges.splice(i, 1);
91839
+ i--;
91840
+ break;
91841
+ }
91842
+ }
91843
+ }
91844
+ }
91845
+ if (this.isVersionPlans) {
91846
+ this.conventionalCommitsConfig = {
91847
+ types: {
91848
+ feat: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.feat,
91849
+ fix: DEFAULT_CONVENTIONAL_COMMITS_CONFIG.types.fix
91850
+ }
91851
+ };
91852
+ for (let i = this.relevantChanges.length - 1; i >= 0; i--) {
91853
+ if (this.relevantChanges[i]?.isBreaking) {
91854
+ const change = this.relevantChanges[i];
91855
+ if (change) {
91856
+ this.additionalChangesForAuthorsSection.push(change);
91857
+ const line = this.formatChange(change);
91858
+ this.breakingChanges.push(line);
91859
+ this.relevantChanges.splice(i, 1);
91860
+ }
91861
+ }
91862
+ }
91863
+ } else {
91864
+ for (const change of this.relevantChanges) {
91865
+ if (change.isBreaking) {
91866
+ const breakingChangeExplanation = change.body ? this.extractBreakingChangeExplanation(change.body) : "";
91867
+ this.breakingChanges.push(
91868
+ breakingChangeExplanation ? `- ${change.scope ? `**${change.scope.trim()}:** ` : ""}${breakingChangeExplanation}` : this.formatChange(change)
91869
+ );
91870
+ }
91871
+ }
91872
+ }
91873
+ }
91874
+ /**
91875
+ * 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.
91876
+ */
91877
+ // protected override shouldRenderEmptyEntry(): boolean {
91878
+ // return true;
91879
+ // }
91880
+ renderVersionTitle() {
91881
+ const isMajorVersion = `${(0, import_semver.major)(this.changelogEntryVersion)}.0.0` === this.changelogEntryVersion.replace(/^v/, "");
91882
+ return isMajorVersion ? `# ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}` : `## ${generateChangelogTitle(this.changelogEntryVersion, this.project, this.workspaceConfig)}`;
91883
+ }
91884
+ renderBreakingChanges() {
91885
+ return [
91886
+ "### Breaking Changes",
91887
+ "",
91888
+ ...Array.from(new Set(this.breakingChanges))
91889
+ ];
91890
+ }
91891
+ renderDependencyBumps() {
91892
+ const markdownLines = ["", "### Updated Dependencies", ""];
91893
+ this.dependencyBumps?.forEach(({ dependencyName, newVersion }) => {
91894
+ markdownLines.push(`- Updated ${dependencyName} to ${newVersion}`);
91895
+ });
91896
+ return markdownLines;
91897
+ }
91898
+ async renderAuthors() {
91899
+ const markdownLines = [];
91900
+ const _authors = /* @__PURE__ */ new Map();
91901
+ for (const change of [
91902
+ ...this.relevantChanges,
91903
+ ...this.additionalChangesForAuthorsSection
91904
+ ]) {
91905
+ if (!change.authors) {
91906
+ continue;
91907
+ }
91908
+ for (const author of change.authors) {
91909
+ const name = this.formatName(author.name);
91910
+ if (!name || name.includes("[bot]") || name === this.workspaceConfig?.bot.name) {
91911
+ continue;
91912
+ }
91913
+ if (_authors.has(name)) {
91914
+ const entry = _authors.get(name);
91915
+ entry?.email.add(author.email);
91916
+ } else {
91917
+ _authors.set(name, { email: /* @__PURE__ */ new Set([author.email]) });
91918
+ }
91919
+ }
91920
+ }
91921
+ if (this.config.repoData && this.changelogRenderOptions.mapAuthorsToGitHubUsernames) {
91922
+ await Promise.all(
91923
+ [..._authors.keys()].map(async (authorName) => {
91924
+ const meta = _authors.get(authorName);
91925
+ if (!meta) {
91926
+ return;
91927
+ }
91928
+ for (const email of meta.email) {
91929
+ if (email.endsWith("@users.noreply.github.com")) {
91930
+ const match = email.match(
91931
+ /^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/
91932
+ );
91933
+ if (match && match[2]) {
91934
+ meta.github = match[2];
91935
+ break;
91936
+ }
91937
+ }
91938
+ const { data } = await axios_default.get(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
91939
+ if (data?.user) {
91940
+ meta.github = data.user.username;
91941
+ break;
91942
+ }
91943
+ }
91944
+ })
91945
+ );
91946
+ }
91947
+ const authors = [..._authors.entries()].map((e) => ({
91948
+ name: e[0],
91949
+ ...e[1]
91950
+ }));
91951
+ if (authors.length > 0) {
91952
+ markdownLines.push(
91953
+ "",
91954
+ "### \u2764\uFE0F Thank You",
91955
+ "",
91956
+ ...authors.sort((a, b) => a.name.localeCompare(b.name)).map((i) => {
91957
+ const github = i.github ? ` @${i.github}` : "";
91958
+ return `- ${i.name}${github}`;
91959
+ })
91960
+ );
91961
+ }
91962
+ return markdownLines;
91963
+ }
91964
+ formatChange(change) {
91965
+ let description = change.description || "";
91966
+ let extraLines = [];
91967
+ let extraLinesStr = "";
91968
+ if (description.includes("\n")) {
91969
+ const lines2 = description.split("\n");
91970
+ if (lines2.length > 1) {
91971
+ description = lines2[0];
91972
+ extraLines = lines2.slice(1);
91973
+ }
91974
+ const indentation = " ";
91975
+ extraLinesStr = extraLines.filter((l2) => l2.trim().length > 0).map((l2) => `${indentation}${l2}`).join("\n");
91976
+ }
91977
+ let changeLine = "- " + (!this.isVersionPlans && change.scope ? `**${change.scope.trim()}:** ` : "") + description;
91978
+ if (this.config.repoData && change.githubReferences) {
91979
+ changeLine += this.remoteReleaseClient.formatReferences(
91980
+ change.githubReferences
91981
+ );
91982
+ }
91983
+ if (extraLinesStr) {
91984
+ changeLine += "\n\n" + extraLinesStr;
91985
+ }
91986
+ return changeLine;
91987
+ }
91988
+ };
91492
91989
 
91493
91990
  // src/release/github.ts
91494
91991
  init_esm_shims();
@@ -91499,7 +91996,10 @@ import { execSync as execSync2 } from "node:child_process";
91499
91996
  import { existsSync as existsSync5, promises as fsp } from "node:fs";
91500
91997
  import { homedir } from "node:os";
91501
91998
  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";
91999
+ import {
92000
+ defaultCreateReleaseProvider,
92001
+ GithubRemoteReleaseClient
92002
+ } from "nx/src/command-line/release/utils/remote-release-clients/github";
91503
92003
  import {
91504
92004
  noDiffInChangelogMessage
91505
92005
  } from "nx/src/command-line/release/utils/shared";
@@ -91532,7 +92032,11 @@ function getGitHubRepoData(remoteName = "origin", createReleaseConfig) {
91532
92032
  );
91533
92033
  }
91534
92034
  } catch (error) {
91535
- return null;
92035
+ import_devkit.output.error({
92036
+ title: `Failed to get GitHub repo data`,
92037
+ bodyLines: [error.message]
92038
+ });
92039
+ return void 0;
91536
92040
  }
91537
92041
  }
91538
92042
  async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion, changelogContents, latestCommit, { dryRun }) {
@@ -91546,12 +92050,12 @@ async function createOrUpdateGithubRelease(createReleaseConfig, releaseVersion,
91546
92050
  });
91547
92051
  process.exit(1);
91548
92052
  }
91549
- const token = await resolveGithubToken(githubRepoData.hostname);
92053
+ const tokenData = await resolveTokenData(githubRepoData.hostname);
91550
92054
  const githubRequestConfig = {
91551
92055
  repo: githubRepoData.slug,
91552
92056
  hostname: githubRepoData.hostname,
91553
92057
  apiBaseUrl: githubRepoData.apiBaseUrl,
91554
- token
92058
+ token: tokenData?.token || null
91555
92059
  };
91556
92060
  let existingGithubReleaseForVersion;
91557
92061
  try {
@@ -91725,13 +92229,13 @@ async function syncGithubRelease(githubRequestConfig, release, existingGithubRel
91725
92229
  };
91726
92230
  }
91727
92231
  }
91728
- async function resolveGithubToken(hostname) {
91729
- const tokenFromEnv = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
92232
+ async function resolveTokenData(hostname) {
92233
+ const tokenFromEnv = process.env.STORM_BOT_GITHUB_TOKEN || process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
91730
92234
  if (tokenFromEnv) {
91731
- return tokenFromEnv;
92235
+ return { token: tokenFromEnv, headerName: "Authorization" };
91732
92236
  }
91733
- const ghCLIPath = joinPaths(
91734
- process.env.XDG_CONFIG_HOME || joinPaths(homedir(), ".config"),
92237
+ const ghCLIPath = (0, import_devkit.joinPathFragments)(
92238
+ process.env.XDG_CONFIG_HOME || (0, import_devkit.joinPathFragments)(homedir(), ".config"),
91735
92239
  "gh",
91736
92240
  "hosts.yml"
91737
92241
  );
@@ -91744,11 +92248,12 @@ async function resolveGithubToken(hostname) {
91744
92248
  return ghCLIConfig[hostname].oauth_token;
91745
92249
  }
91746
92250
  if (ghCLIConfig[hostname].user && ghCLIConfig[hostname].git_protocol === "ssh") {
91747
- return execSync2(`gh auth token`, {
92251
+ const token = execSync2(`gh auth token`, {
91748
92252
  encoding: "utf8",
91749
92253
  stdio: "pipe",
91750
92254
  windowsHide: false
91751
92255
  }).trim();
92256
+ return { token, headerName: "Authorization" };
91752
92257
  }
91753
92258
  }
91754
92259
  }
@@ -91757,7 +92262,9 @@ async function resolveGithubToken(hostname) {
91757
92262
  `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
92263
  );
91759
92264
  }
91760
- return null;
92265
+ throw new Error(
92266
+ `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).`
92267
+ );
91761
92268
  }
91762
92269
  async function getGithubReleaseByTag(config, tag) {
91763
92270
  return await makeGithubRequest(
@@ -91799,210 +92306,24 @@ function githubNewReleaseURL(config, release) {
91799
92306
  }
91800
92307
  return url2;
91801
92308
  }
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) + ")";
92309
+ async function createGithubRemoteReleaseClient(remoteName = "origin") {
92310
+ const repoData = getGitHubRepoData(remoteName, "github");
92311
+ if (!repoData) {
92312
+ throw new Error(
92313
+ `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.`
92314
+ );
91817
92315
  }
91818
- return "";
92316
+ return new GithubRemoteReleaseClient(
92317
+ repoData,
92318
+ {
92319
+ provider: "github",
92320
+ hostname: repoData.hostname,
92321
+ apiBaseUrl: repoData.apiBaseUrl
92322
+ },
92323
+ await resolveTokenData(repoData.hostname)
92324
+ );
91819
92325
  }
91820
92326
 
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
92327
  // src/release/changelog.ts
92007
92328
  function createAPI(overrideReleaseConfig) {
92008
92329
  return async function releaseChangelog(args) {
@@ -92361,7 +92682,7 @@ ${contents}`);
92361
92682
  body: c.body,
92362
92683
  isBreaking: c.isBreaking,
92363
92684
  githubReferences: c.references,
92364
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92685
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92365
92686
  authors: [c.author],
92366
92687
  shortHash: c.shortHash,
92367
92688
  revertedHashes: c.revertedHashes,
@@ -92490,7 +92811,7 @@ ${contents}`);
92490
92811
  body: c.body,
92491
92812
  isBreaking: c.isBreaking,
92492
92813
  githubReferences: c.references,
92493
- // TODO(JamesHenry): Implement support for Co-authored-by and adding multiple authors
92814
+ // TODO: Implement support for Co-authored-by and adding multiple authors
92494
92815
  authors: [c.author],
92495
92816
  shortHash: c.shortHash,
92496
92817
  revertedHashes: c.revertedHashes,
@@ -92657,12 +92978,12 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92657
92978
  isDryRun: !!args.dryRun,
92658
92979
  isVerbose: !!args.verbose,
92659
92980
  gitCommitMessages: commitMessageValues,
92660
- gitCommitArgs: args.gitCommitArgs || nxReleaseConfig.changelog?.git.commitArgs
92981
+ gitCommitArgs: args.gitCommitArgs ?? nxReleaseConfig.changelog?.git.commitArgs
92661
92982
  });
92662
92983
  latestCommit = await getCommitHash("HEAD");
92663
92984
  } else if ((args.stageChanges ?? nxReleaseConfig.changelog?.git.stageChanges) && changes.length) {
92664
92985
  output2.logSingleLine(`Staging changed files with git`);
92665
- await gitAdd({
92986
+ await gitAdd2({
92666
92987
  changedFiles,
92667
92988
  deletedFiles,
92668
92989
  dryRun: args.dryRun,
@@ -92687,7 +93008,6 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
92687
93008
  gitRemote: args.gitRemote,
92688
93009
  dryRun: args.dryRun,
92689
93010
  verbose: args.verbose
92690
- // additionalArgs: ["--signed=if-asked"]
92691
93011
  });
92692
93012
  }
92693
93013
  for (const postGitTask of postGitTasks) {
@@ -92766,17 +93086,12 @@ async function generateChangelogForWorkspace({
92766
93086
  )}`
92767
93087
  });
92768
93088
  }
92769
- const githubRepoData = getGitHubRepoData(gitRemote, config.createRelease);
92770
- const remoteReleaseClient = await createRemoteReleaseClient(
92771
- config.createRelease,
92772
- gitRemote
92773
- );
93089
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92774
93090
  const changelogRenderer = new StormChangelogRenderer({
92775
93091
  changes,
92776
93092
  changelogEntryVersion: releaseVersion.rawVersion,
92777
93093
  project: null,
92778
93094
  isVersionPlans: false,
92779
- repoData: githubRepoData,
92780
93095
  entryWhenNoChanges: config.entryWhenNoChanges,
92781
93096
  changelogRenderOptions: config.renderOptions,
92782
93097
  conventionalCommitsConfig: nxReleaseConfig.conventionalCommits,
@@ -92785,7 +93100,7 @@ async function generateChangelogForWorkspace({
92785
93100
  let contents = await changelogRenderer.render();
92786
93101
  if (interactive) {
92787
93102
  const tmpDir = (0, import_tmp.dirSync)().name;
92788
- const changelogPath = joinPathFragments(
93103
+ const changelogPath = joinPathFragments2(
92789
93104
  tmpDir,
92790
93105
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92791
93106
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -92846,11 +93161,12 @@ async function generateChangelogForProjects({
92846
93161
  workspaceRoot: ""
92847
93162
  });
92848
93163
  }
92849
- if (!projectsVersionData[project.name]?.newVersion) {
93164
+ const newVersion = projectsVersionData[project.name]?.newVersion;
93165
+ if (!newVersion) {
92850
93166
  continue;
92851
93167
  }
92852
93168
  const releaseVersion = new ReleaseVersion2({
92853
- version: projectsVersionData[project.name].newVersion,
93169
+ version: newVersion,
92854
93170
  releaseTagPattern: releaseGroup.releaseTagPattern,
92855
93171
  projectName: project.name
92856
93172
  });
@@ -92861,19 +93177,11 @@ async function generateChangelogForProjects({
92861
93177
  releaseVersion.gitTag
92862
93178
  )}`
92863
93179
  });
92864
- const githubRepoData = getGitHubRepoData(
92865
- gitRemote,
92866
- config.createRelease
92867
- );
92868
- const remoteReleaseClient = await createRemoteReleaseClient(
92869
- config.createRelease,
92870
- gitRemote
92871
- );
93180
+ const remoteReleaseClient = await createGithubRemoteReleaseClient(gitRemote);
92872
93181
  const changelogRenderer = new StormChangelogRenderer({
92873
93182
  changes,
92874
93183
  changelogEntryVersion: releaseVersion.rawVersion,
92875
93184
  project: project.name,
92876
- repoData: githubRepoData,
92877
93185
  entryWhenNoChanges: typeof config.entryWhenNoChanges === "string" ? interpolate(config.entryWhenNoChanges, {
92878
93186
  projectName: project.name,
92879
93187
  projectRoot: project.data.root,
@@ -92893,7 +93201,7 @@ ${contents}`.trim()
92893
93201
  });
92894
93202
  if (interactive) {
92895
93203
  const tmpDir = (0, import_tmp.dirSync)().name;
92896
- const changelogPath = joinPathFragments(
93204
+ const changelogPath = joinPathFragments2(
92897
93205
  tmpDir,
92898
93206
  // Include the tree path in the name so that it is easier to identify which changelog file is being edited
92899
93207
  `PREVIEW__${interpolatedTreePath.replace(/\//g, "_")}`
@@ -93031,16 +93339,16 @@ function formatGithubReleaseNotes(releaseVersion, content, projectName, workspac
93031
93339
  if (!workspaceConfig) {
93032
93340
  return content;
93033
93341
  }
93034
- return `![${titleCase2(workspaceConfig.organization)?.replaceAll(" ", "-")}](${workspaceConfig.release.banner})
93342
+ return `![${titleCase(workspaceConfig.organization)?.replaceAll(" ", "-")}](${workspaceConfig.release.banner})
93035
93343
  ${workspaceConfig.release.header || ""}
93036
93344
 
93037
- # ${projectName ? `${titleCase2(projectName)} ` : ""}v${releaseVersion.rawVersion}
93345
+ # ${projectName ? `${titleCase(projectName)} ` : ""}v${releaseVersion.rawVersion}
93038
93346
 
93039
- 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}
93347
+ 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}
93040
93348
 
93041
93349
  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}).
93042
93350
 
93043
- 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!
93351
+ 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!
93044
93352
 
93045
93353
  ## Release Notes
93046
93354
 
@@ -93121,10 +93429,12 @@ var DEFAULT_RELEASE_CONFIG = {
93121
93429
 
93122
93430
  // src/release/run.ts
93123
93431
  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";
93432
+ const name = config.bot.name;
93433
+ const email = config.bot.email ? config.bot.email : config.bot.name ? `${config.bot.name}@users.noreply.github.com` : "bot@stormsoftware.com";
93434
+ process.env.GIT_AUTHOR_NAME = name;
93435
+ process.env.GIT_AUTHOR_EMAIL = email;
93436
+ process.env.GIT_COMMITTER_NAME = name;
93437
+ process.env.GIT_COMMITTER_EMAIL = email;
93128
93438
  process.env.NODE_AUTH_TOKEN = process.env.NPM_TOKEN;
93129
93439
  process.env.NPM_AUTH_TOKEN = process.env.NPM_TOKEN;
93130
93440
  process.env.NPM_CONFIG_PROVENANCE = "true";