@aklinker1/zero-changelog 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -27,9 +27,9 @@ bun add @aklinker1/zero-changelog
27
27
 
28
28
  Refer to the API reference:
29
29
 
30
- - [Release](https://jsr.io/@aklinker1/zero-ioc/doc/release/~/ReleaseOptions)
31
- - [Sync Releases](https://jsr.io/@aklinker1/zero-ioc/doc/sync-releases/~/SyncReleasesOptions)
32
- - [Summarize Unreleased Commits](https://jsr.io/@aklinker1/zero-ioc/doc/summarize-unreleased-commits/~/SummarizeUnreleasedCommitsOptions)
30
+ - [Release](https://jsr.io/@aklinker1/zero-changelog/doc/release/~/ReleaseOptions)
31
+ - [Sync Releases](https://jsr.io/@aklinker1/zero-changelog/doc/sync-releases/~/SyncReleasesOptions)
32
+ - [Summarize Unreleased Commits](https://jsr.io/@aklinker1/zero-changelog/doc/summarize-unreleased-commits/~/SummarizeUnreleasedCommitsOptions)
33
33
 
34
34
  ## Usage
35
35
 
@@ -1,4 +1,4 @@
1
- import { t as getVersionRegexFor } from "./version-regex-C82OGsTC.mjs";
1
+ import { t as getVersionRegexFor } from "./version-regex-qeo3bsOW.mjs";
2
2
  import { styleText } from "node:util";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { join, relative } from "node:path";
@@ -11,7 +11,7 @@ async function getCurrentVersion(path, versionFiles) {
11
11
  const regex = getVersionRegexFor(file);
12
12
  const version = text.match(regex)?.groups?.version;
13
13
  if (version) {
14
- console.log(`Found current version (${version})) in ${styleText("cyan", relative(process.cwd(), file))}`);
14
+ console.log(`Found current version (${version}) in ${styleText("cyan", relative(process.cwd(), file))}`);
15
15
  return version;
16
16
  }
17
17
  console.log(` -> Not found in ${styleText("cyan", relative(process.cwd(), file))}`);
@@ -1,7 +1,11 @@
1
1
  import { t as waitForChildProcess } from "./wait-for-child-process-lyAoE4WE.mjs";
2
2
  import { spawn } from "node:child_process";
3
3
  //#region src/get-github-repo.ts
4
- const REMOTE_REGEX = [/^git@github\.com:(?<owner>\S+)\/(?<repo>\S+)\.git$/, /^https:\/\/github\.com\/(?<owner>\S+)\/(?<repo>\S+)\.git$/];
4
+ const REMOTE_REGEX = [
5
+ /^git@github\.com:(?<owner>\S+)\/(?<repo>\S+)\.git$/,
6
+ /^https:\/\/github\.com\/(?<owner>\S+)\/(?<repo>\S+)\.git$/,
7
+ /^https:\/\/github\.com\/(?<owner>\S+)\/(?<repo>\S+)$/
8
+ ];
5
9
  async function getGithubRepo() {
6
10
  console.log("Getting current github repo...");
7
11
  const { stdout } = await waitForChildProcess(spawn("git", [
@@ -1,4 +1,5 @@
1
1
  import types from "./semver-types/aklinker1.mjs";
2
+ import { n as sentenceCase } from "./utils-BLItnE1t.mjs";
2
3
  //#region src/get-release-notes.ts
3
4
  function getReleaseNotes(conventionalCommits, since, tag, repo) {
4
5
  const commitsByType = conventionalCommits.reduce((acc, commit) => {
@@ -15,7 +16,7 @@ function getReleaseNotes(conventionalCommits, since, tag, repo) {
15
16
  for (const commit of commits) {
16
17
  const scope = commit.scope ? `**${commit.scope}**: ` : "";
17
18
  const breaking = commit.isBreaking ? "⚠️ " : "";
18
- lines.push(`- ${breaking}${scope}${commit.description}`);
19
+ lines.push(`- ${breaking}${scope}${sentenceCase(commit.description)}`);
19
20
  }
20
21
  lines.push("");
21
22
  }
@@ -1,2 +1,2 @@
1
- import { n as parseGitLog, t as listCommitsSince } from "./list-commits-since-DycWgHTi.mjs";
1
+ import { n as parseGitLog, t as listCommitsSince } from "./list-commits-since-CpENJIqP.mjs";
2
2
  export { listCommitsSince, parseGitLog };
package/dist/release.mjs CHANGED
@@ -3,11 +3,11 @@ import { detectVersionBump } from "./detect-version-bump.mjs";
3
3
  import { t as findPreviousTag } from "./find-previous-tag-Cj2oZAty.mjs";
4
4
  import { getCurrentVersion } from "./get-current-version.mjs";
5
5
  import { getGithubRepo } from "./get-github-repo.mjs";
6
+ import { r as template } from "./utils-BLItnE1t.mjs";
6
7
  import { getReleaseNotes } from "./get-release-notes.mjs";
7
- import { t as listCommitsSince } from "./list-commits-since-DycWgHTi.mjs";
8
+ import { t as listCommitsSince } from "./list-commits-since-CpENJIqP.mjs";
8
9
  import { parseChangelog } from "./parse-changelog.mjs";
9
10
  import { parseCommits } from "./parse-commits.mjs";
10
- import { n as template } from "./utils-BO6byvK5.mjs";
11
11
  import { isPrerelease, parseSemver } from "./semver.mjs";
12
12
  import { serializeChangelog } from "./serialize-changelog.mjs";
13
13
  import { updateVersionFiles } from "./update-version-files.mjs";
@@ -52,23 +52,36 @@ async function release(options) {
52
52
  if (!githubRepo) throw Error("No github repo provided");
53
53
  const currentVersion = parseSemver(await getCurrentVersion(path, versionFiles));
54
54
  const since = options.since ?? await findPreviousTag(tagPrefix);
55
- const changes = parseCommits(await listCommitsSince({
55
+ console.log("Since:", since);
56
+ const commits = await listCommitsSince({
56
57
  since,
57
58
  dirs: [path, ...additionalDirs]
58
- }));
59
- const bump = (options.bump?.trim() || void 0) ?? detectVersionBump(changes, throwOnNoChanges);
59
+ });
60
+ console.log("Commits:", commits.length);
61
+ const conventionalCommits = parseCommits(commits);
62
+ console.log("Conventional commits:", conventionalCommits.length, conventionalCommits[0]);
63
+ const bump = (options.bump?.trim() || void 0) ?? detectVersionBump(conventionalCommits, throwOnNoChanges);
64
+ console.log("Bump:", bump);
60
65
  const version = currentVersion.bump(bump);
66
+ console.log("Version:", version);
61
67
  const tag = tagPrefix + version;
62
- console.log("Bumping version to:", version);
63
68
  console.log("Tag:", tag);
64
69
  await updateVersionFiles(path, versionFiles, version);
65
- const releaseNotes = getReleaseNotes(changes, since, tag, githubRepo);
66
- const changelog = parseChangelog(await readFile("CHANGELOG.md", "utf8"));
70
+ const releaseNotes = getReleaseNotes(conventionalCommits, since, tag, githubRepo);
71
+ console.log("Release notes:");
72
+ console.log("---");
73
+ console.log(releaseNotes);
74
+ console.log("---");
75
+ const changelog = parseChangelog(await readFile("CHANGELOG.md", "utf8").catch((err) => {
76
+ if (err.code === "ENOENT") return "";
77
+ throw err;
78
+ }));
67
79
  changelog.unshift({
68
80
  header: `v${version}`,
69
81
  body: releaseNotes
70
82
  });
71
83
  await writeFile("CHANGELOG.md", serializeChangelog(changelog), "utf8");
84
+ console.log("CHANGELOG.md updated");
72
85
  if (dryRun && dryRunPublishCommands?.length) for (const cmd of dryRunPublishCommands) await run({
73
86
  dryRun: false,
74
87
  cwd: path,
@@ -103,6 +116,7 @@ async function release(options) {
103
116
  cwd: path,
104
117
  cmd: "git push --tags"
105
118
  });
119
+ console.log("Changes pushed");
106
120
  await createGithubRelease({
107
121
  repo: githubRepo,
108
122
  token: githubToken,
@@ -119,7 +133,12 @@ async function release(options) {
119
133
  latest: latestRelease,
120
134
  prerelease: isPrerelease(parseSemver(version))
121
135
  });
122
- throw Error("Not implemented");
136
+ console.log("Release created");
137
+ return {
138
+ version,
139
+ tag,
140
+ releaseNotes
141
+ };
123
142
  }
124
143
  //#endregion
125
144
  export { release };
@@ -1,7 +1,7 @@
1
1
  import { t as findPreviousTag } from "./find-previous-tag-Cj2oZAty.mjs";
2
- import { t as listCommitsSince } from "./list-commits-since-DycWgHTi.mjs";
2
+ import { r as template } from "./utils-BLItnE1t.mjs";
3
+ import { t as listCommitsSince } from "./list-commits-since-CpENJIqP.mjs";
3
4
  import { parseCommits } from "./parse-commits.mjs";
4
- import { n as template } from "./utils-BO6byvK5.mjs";
5
5
  import { basename, relative, resolve } from "node:path";
6
6
  //#region src/summarize-unreleased-commits.ts
7
7
  async function summarizeUnreleasedCommits(options) {
@@ -1,5 +1,5 @@
1
- import { t as getVersionRegexFor } from "./version-regex-C82OGsTC.mjs";
2
- import { t as replaceRegexGroup } from "./utils-BO6byvK5.mjs";
1
+ import { t as getVersionRegexFor } from "./version-regex-qeo3bsOW.mjs";
2
+ import { t as replaceRegexGroup } from "./utils-BLItnE1t.mjs";
3
3
  import { styleText } from "node:util";
4
4
  import { readFile, writeFile } from "node:fs/promises";
5
5
  import { join, relative } from "node:path";
@@ -18,5 +18,9 @@ function replaceRegexGroup(text, regexp, group, replacement) {
18
18
  function template(template, vars) {
19
19
  return Object.entries(vars).reduce((acc, [key, value]) => acc.replace(new RegExp(`\\{\\{\\s*?${key}\\s*?\\}\\}`, "g"), String(value)), template);
20
20
  }
21
+ function sentenceCase(str) {
22
+ if (str.length === 0) return str;
23
+ return str[0].toUpperCase() + str.slice(1);
24
+ }
21
25
  //#endregion
22
- export { template as n, replaceRegexGroup as t };
26
+ export { sentenceCase as n, template as r, replaceRegexGroup as t };
@@ -1,8 +1,8 @@
1
1
  import { basename } from "node:path";
2
2
  //#region src/internal/version-regex.ts
3
- const PACKAGE_JSON_VERSION_REGEX = /"version":\s*?"(?<version>)"/;
4
- const PACKAGE_YAML_VERSION_REGEX = /["']?version["']?:\s+?["']?(?<version>)["']?/;
5
- const CARGO_TOML_VERSION_REGEX = /^version\s*=\s*"(?<version>\w*?)"/;
3
+ const PACKAGE_JSON_VERSION_REGEX = /"version":\s*?"(?<version>\S*?)"/;
4
+ const PACKAGE_YAML_VERSION_REGEX = /["']?version["']?:\s+?["']?(?<version>\S*?)["']?/;
5
+ const CARGO_TOML_VERSION_REGEX = /^version\s*=\s*"(?<version>\S*?)"/;
6
6
  function getVersionRegexFor(versionFile) {
7
7
  const filename = basename(versionFile);
8
8
  switch (filename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aklinker1/zero-changelog",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Zero-dependency, conventional commit release and changelog generator with monorepo support",
5
5
  "keywords": [
6
6
  "changelog",
@@ -9,102 +9,105 @@
9
9
  "release notes"
10
10
  ],
11
11
  "license": "MIT",
12
+ "repository": {
13
+ "url": "https://github.com/aklinker1/zero-changelog"
14
+ },
12
15
  "files": [
13
16
  "dist/"
14
17
  ],
15
18
  "type": "module",
16
19
  "exports": {
20
+ "./changelog-section": {
21
+ "types": "./dist/changelog-section.d.mts",
22
+ "default": "./dist/changelog-section.mjs"
23
+ },
17
24
  "./conventional-commit": {
18
25
  "types": "./dist/conventional-commit.d.mts",
19
26
  "default": "./dist/conventional-commit.mjs"
20
27
  },
28
+ "./create-github-release": {
29
+ "types": "./dist/create-github-release.d.mts",
30
+ "default": "./dist/create-github-release.mjs"
31
+ },
32
+ "./detect-version-bump": {
33
+ "types": "./dist/detect-version-bump.d.mts",
34
+ "default": "./dist/detect-version-bump.mjs"
35
+ },
36
+ "./find-previous-tag": {
37
+ "types": "./dist/find-previous-tag.d.mts",
38
+ "default": "./dist/find-previous-tag.mjs"
39
+ },
40
+ "./get-current-version": {
41
+ "types": "./dist/get-current-version.d.mts",
42
+ "default": "./dist/get-current-version.mjs"
43
+ },
21
44
  "./get-github-release": {
22
45
  "types": "./dist/get-github-release.d.mts",
23
46
  "default": "./dist/get-github-release.mjs"
24
47
  },
48
+ "./get-github-repo": {
49
+ "types": "./dist/get-github-repo.d.mts",
50
+ "default": "./dist/get-github-repo.mjs"
51
+ },
25
52
  "./get-release-notes": {
26
53
  "types": "./dist/get-release-notes.d.mts",
27
54
  "default": "./dist/get-release-notes.mjs"
28
55
  },
29
- "./summarize-unreleased-commits": {
30
- "types": "./dist/summarize-unreleased-commits.d.mts",
31
- "default": "./dist/summarize-unreleased-commits.mjs"
56
+ "./git-commit": {
57
+ "types": "./dist/git-commit.d.mts",
58
+ "default": "./dist/git-commit.mjs"
32
59
  },
33
60
  "./list-commits-since": {
34
61
  "types": "./dist/list-commits-since.d.mts",
35
62
  "default": "./dist/list-commits-since.mjs"
36
63
  },
37
- "./find-previous-tag": {
38
- "types": "./dist/find-previous-tag.d.mts",
39
- "default": "./dist/find-previous-tag.mjs"
40
- },
41
- "./get-github-repo": {
42
- "types": "./dist/get-github-repo.d.mts",
43
- "default": "./dist/get-github-repo.mjs"
44
- },
45
- "./detect-version-bump": {
46
- "types": "./dist/detect-version-bump.d.mts",
47
- "default": "./dist/detect-version-bump.mjs"
48
- },
49
64
  "./parse-changelog": {
50
65
  "types": "./dist/parse-changelog.d.mts",
51
66
  "default": "./dist/parse-changelog.mjs"
52
67
  },
53
- "./sync-releases": {
54
- "types": "./dist/sync-releases.d.mts",
55
- "default": "./dist/sync-releases.mjs"
56
- },
57
68
  "./parse-commit": {
58
69
  "types": "./dist/parse-commit.d.mts",
59
70
  "default": "./dist/parse-commit.mjs"
60
71
  },
61
- "./semver-type-map": {
62
- "types": "./dist/semver-type-map.d.mts",
63
- "default": "./dist/semver-type-map.mjs"
64
- },
65
- "./changelog-section": {
66
- "types": "./dist/changelog-section.d.mts",
67
- "default": "./dist/changelog-section.mjs"
68
- },
69
- "./release": {
70
- "types": "./dist/release.d.mts",
71
- "default": "./dist/release.mjs"
72
- },
73
- "./git-commit": {
74
- "types": "./dist/git-commit.d.mts",
75
- "default": "./dist/git-commit.mjs"
76
- },
77
72
  "./parse-commits": {
78
73
  "types": "./dist/parse-commits.d.mts",
79
74
  "default": "./dist/parse-commits.mjs"
80
75
  },
81
- "./update-version-files": {
82
- "types": "./dist/update-version-files.d.mts",
83
- "default": "./dist/update-version-files.mjs"
76
+ "./release": {
77
+ "types": "./dist/release.d.mts",
78
+ "default": "./dist/release.mjs"
84
79
  },
85
- "./get-current-version": {
86
- "types": "./dist/get-current-version.d.mts",
87
- "default": "./dist/get-current-version.mjs"
80
+ "./semver": {
81
+ "types": "./dist/semver.d.mts",
82
+ "default": "./dist/semver.mjs"
88
83
  },
89
84
  "./semver-type": {
90
85
  "types": "./dist/semver-type.d.mts",
91
86
  "default": "./dist/semver-type.mjs"
92
87
  },
93
- "./semver": {
94
- "types": "./dist/semver.d.mts",
95
- "default": "./dist/semver.mjs"
96
- },
97
- "./create-github-release": {
98
- "types": "./dist/create-github-release.d.mts",
99
- "default": "./dist/create-github-release.mjs"
88
+ "./semver-type-map": {
89
+ "types": "./dist/semver-type-map.d.mts",
90
+ "default": "./dist/semver-type-map.mjs"
100
91
  },
101
92
  "./serialize-changelog": {
102
93
  "types": "./dist/serialize-changelog.d.mts",
103
94
  "default": "./dist/serialize-changelog.mjs"
104
95
  },
96
+ "./summarize-unreleased-commits": {
97
+ "types": "./dist/summarize-unreleased-commits.d.mts",
98
+ "default": "./dist/summarize-unreleased-commits.mjs"
99
+ },
105
100
  "./sync-release": {
106
101
  "types": "./dist/sync-release.d.mts",
107
102
  "default": "./dist/sync-release.mjs"
103
+ },
104
+ "./sync-releases": {
105
+ "types": "./dist/sync-releases.d.mts",
106
+ "default": "./dist/sync-releases.mjs"
107
+ },
108
+ "./update-version-files": {
109
+ "types": "./dist/update-version-files.d.mts",
110
+ "default": "./dist/update-version-files.mjs"
108
111
  }
109
112
  },
110
113
  "scripts": {