keepchanges 0.0.0 → 0.0.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/dist/cli.mjs +14 -3
- package/package.json +4 -4
package/dist/cli.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { readFile, writeFile } from "node:fs/promises";
|
|
|
9
9
|
import { normalizeFull } from "verkit";
|
|
10
10
|
import { x } from "tinyexec";
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "0.0.
|
|
12
|
+
var version = "0.0.2";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/changelog.ts
|
|
15
15
|
function createChangelog(version, commits, repository, comparisonFrom) {
|
|
@@ -72,7 +72,12 @@ function renderSection(commits, title, repository) {
|
|
|
72
72
|
const reference = repository ? `[<samp>(${commit.hash.slice(0, 5)})</samp>](${repository.provider.commitUrl(repository, commit.hash)})` : "";
|
|
73
73
|
const authorNames = commit.authors.map((author) => author.login ? `@${author.login}` : `**${escapeHtml(author.name)}**`);
|
|
74
74
|
const authors = authorNames.length > 1 ? `${authorNames.slice(0, -1).join(", ")} and ${authorNames.at(-1)}` : authorNames[0] || "";
|
|
75
|
-
const
|
|
75
|
+
const pullRequests = commit.pullRequests.map((pullRequest) => repository ? `[${pullRequest}](${repository.provider.pullRequestUrl(repository, pullRequest)})` : pullRequest).join(", ");
|
|
76
|
+
const details = [
|
|
77
|
+
authors ? `by ${authors}` : "",
|
|
78
|
+
pullRequests ? `in ${pullRequests}` : "",
|
|
79
|
+
reference
|
|
80
|
+
].filter(Boolean).join(" ");
|
|
76
81
|
const suffix = details ? ` - ${details}` : "";
|
|
77
82
|
return `${scope}${escapeHtml(capitalize$1(commit.description))}${suffix}`;
|
|
78
83
|
}).reverse();
|
|
@@ -148,6 +153,8 @@ function parseGitLog(log) {
|
|
|
148
153
|
function parseCommit(hash, subject, body, author) {
|
|
149
154
|
const match = /^(?<type>[a-z]+)(?:\((?<scope>[^()\r\n]+)\))?(?<breaking>!)?: (?<description>.+)$/i.exec(subject);
|
|
150
155
|
if (!match?.groups) return null;
|
|
156
|
+
const pullRequestPattern = /\([ a-z]*(#\d+)\s*\)/gi;
|
|
157
|
+
const pullRequests = [...new Set([...match.groups.description.matchAll(pullRequestPattern)].map((reference) => reference[1]))];
|
|
151
158
|
const authors = [author];
|
|
152
159
|
for (const coAuthor of body.matchAll(/^Co-Authored-By:\s*(.+?)\s*<([^>]+)>$/gim)) {
|
|
153
160
|
const email = coAuthor[2].trim();
|
|
@@ -161,7 +168,8 @@ function parseCommit(hash, subject, body, author) {
|
|
|
161
168
|
authors: authors.filter((author) => !/\[bot\]|dependabot|\(bot\)/i.test(author.name)),
|
|
162
169
|
type: match.groups.type.toLowerCase(),
|
|
163
170
|
scope: match.groups.scope || "",
|
|
164
|
-
description: match.groups.description,
|
|
171
|
+
description: match.groups.description.replace(pullRequestPattern, "").trim(),
|
|
172
|
+
pullRequests,
|
|
165
173
|
isBreaking: Boolean(match.groups.breaking) || /^BREAKING(?: |-)CHANGE:/im.test(body)
|
|
166
174
|
};
|
|
167
175
|
}
|
|
@@ -184,6 +192,9 @@ const githubProvider = {
|
|
|
184
192
|
commitUrl(repository, hash) {
|
|
185
193
|
return `${repository.webUrl}/commit/${hash}`;
|
|
186
194
|
},
|
|
195
|
+
pullRequestUrl(repository, reference) {
|
|
196
|
+
return `${repository.webUrl}/pull/${reference.replace(/^#/, "")}`;
|
|
197
|
+
},
|
|
187
198
|
compareUrl(repository, from, to) {
|
|
188
199
|
return `${repository.webUrl}/compare/${from}...${to}`;
|
|
189
200
|
},
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keepchanges",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.2",
|
|
5
5
|
"description": "Generate and maintain CHANGELOG.md from Conventional Commits.",
|
|
6
6
|
"author": "edram",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/edram/
|
|
8
|
+
"homepage": "https://github.com/edram/keepchanges#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/edram/
|
|
11
|
+
"url": "git+https://github.com/edram/keepchanges.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/edram/
|
|
14
|
+
"url": "https://github.com/edram/keepchanges/issues"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
17
|
"changelog": "./dist/cli.mjs"
|