@aklinker1/zero-changelog 0.1.9 → 0.1.10

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.
@@ -1,5 +1,6 @@
1
1
  //#region src/conventional-commit.d.ts
2
2
  type ConventionalCommit = {
3
+ hash: string;
3
4
  type: string;
4
5
  scope?: string;
5
6
  description: string;
@@ -1,6 +1,7 @@
1
1
  import types from "./semver-types/aklinker1.mjs";
2
2
  import { n as sentenceCase } from "./utils-BLItnE1t.mjs";
3
3
  //#region src/get-release-notes.ts
4
+ const REF_SUFFIX_REGEX = /\(#[0-9]+\)$/;
4
5
  function getReleaseNotes(conventionalCommits, since, tag, repo) {
5
6
  const commitsByType = conventionalCommits.reduce((acc, commit) => {
6
7
  acc[commit.type] ??= [];
@@ -8,6 +9,7 @@ function getReleaseNotes(conventionalCommits, since, tag, repo) {
8
9
  return acc;
9
10
  }, {});
10
11
  const lines = [];
12
+ const breakingChanges = [];
11
13
  if (since) lines.push(`[compare changes](https://github.com/${repo}/compare/${since}...${tag})`, "");
12
14
  for (const [type, details] of Object.entries(types)) {
13
15
  const commits = commitsByType[type];
@@ -16,10 +18,20 @@ function getReleaseNotes(conventionalCommits, since, tag, repo) {
16
18
  for (const commit of commits) {
17
19
  const scope = commit.scope ? `**${commit.scope}**: ` : "";
18
20
  const breaking = commit.isBreaking ? "⚠️ " : "";
19
- lines.push(`- ${breaking}${scope}${sentenceCase(commit.description)}`);
21
+ const hashLink = `[\`${commit.hash.slice(0, 7)}\`](https://github.com/${repo}/commit/${commit.hash})`;
22
+ lines.push(`- ${breaking}${scope}${sentenceCase(commit.description)}${REF_SUFFIX_REGEX.test(commit.description) ? "" : ` (${hashLink})`}`);
23
+ if (commit.isBreaking) {
24
+ const footer = commit.footers.find((footer) => footer.key === "breaking change");
25
+ if (footer) breakingChanges.push(`- ${hashLink}: ${footer.value} `);
26
+ }
20
27
  }
21
28
  lines.push("");
22
29
  }
30
+ if (breakingChanges.length > 0) {
31
+ lines.push("### ⚠️ Breaking Changes", "");
32
+ lines.push(...breakingChanges);
33
+ lines.push("");
34
+ }
23
35
  const authors = conventionalCommits.flatMap((commit) => commit.authors);
24
36
  if (authors.length) {
25
37
  const emailNameMap = authors.reduce((acc, author) => {
@@ -18,6 +18,7 @@ function parseCommit(commit) {
18
18
  });
19
19
  }
20
20
  return {
21
+ hash: commit.hash,
21
22
  type,
22
23
  scope,
23
24
  description,
@@ -109,6 +109,7 @@ type ReleaseOptions = {
109
109
  * Template vars:
110
110
  *
111
111
  * - `{{version}}`: The version after being bumped.
112
+ * - `{{tag}}`: The tag that will be used for the release.
112
113
  * - `{{path}}`: The {@link ReleaseOptions#path} relative to the current working directory.
113
114
  * - `{{dirname}}`: The path's base name.
114
115
  *
@@ -130,7 +131,7 @@ type ReleaseOptions = {
130
131
  * commitTemplate: "chore(release): My Package v{{version}}"
131
132
  * ```
132
133
  *
133
- * @default "chore(release): v{{version}}"
134
+ * @default "chore(release): {{tag}}"
134
135
  */
135
136
  commitTemplate?: string;
136
137
  /**
package/dist/release.mjs CHANGED
@@ -38,7 +38,7 @@ async function run(options) {
38
38
  //#endregion
39
39
  //#region src/release.ts
40
40
  async function release(options) {
41
- const { additionalDirs = [], commitTemplate = "chore(release): v{{version}}", dryRun = false, dryRunPublishCommands, publishCommands, releaseNameTemplate = "{{tag}}", versionFiles = [
41
+ const { additionalDirs = [], commitTemplate = "chore(release): {{tag}}", dryRun = false, dryRunPublishCommands, publishCommands, releaseNameTemplate = "{{tag}}", versionFiles = [
42
42
  "package.json",
43
43
  "jsr.json",
44
44
  "deno.json",
@@ -86,7 +86,8 @@ async function release(options) {
86
86
  const commit = template(commitTemplate, {
87
87
  version,
88
88
  path,
89
- dirname
89
+ dirname,
90
+ tag
90
91
  });
91
92
  await run({
92
93
  dryRun,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aklinker1/zero-changelog",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Zero-dependency, conventional commit release and changelog generator with monorepo support",
5
5
  "keywords": [
6
6
  "changelog",