@soybeanjs/changelog 0.0.3 → 0.0.5
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/index.cjs +15 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +15 -9
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ function join(array, glue = ", ", finalGlue = " and ") {
|
|
|
58
58
|
|
|
59
59
|
const VERSION_REG = /v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
60
60
|
const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
|
|
61
|
+
const VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
61
62
|
|
|
62
63
|
async function getTotalGitTags() {
|
|
63
64
|
const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
|
|
@@ -130,13 +131,13 @@ async function getGitDiff(from, to = "HEAD") {
|
|
|
130
131
|
const gitCommits = rwaGitLines.map((line) => {
|
|
131
132
|
const [firstLine, ...body] = line.split("\n");
|
|
132
133
|
const [message, shortHash, authorName, authorEmail] = firstLine.split("|");
|
|
133
|
-
const
|
|
134
|
+
const gitCommit = {
|
|
134
135
|
message,
|
|
135
136
|
shortHash,
|
|
136
137
|
author: { name: authorName, email: authorEmail },
|
|
137
138
|
body: body.join("\n")
|
|
138
139
|
};
|
|
139
|
-
return
|
|
140
|
+
return gitCommit;
|
|
140
141
|
});
|
|
141
142
|
return gitCommits;
|
|
142
143
|
}
|
|
@@ -165,8 +166,8 @@ function parseGitCommit(commit) {
|
|
|
165
166
|
references.push({ value: commit.shortHash, type: "hash" });
|
|
166
167
|
description = description.replace(PullRequestRE, "").trim();
|
|
167
168
|
const authors = [commit.author];
|
|
168
|
-
const
|
|
169
|
-
for (const $match of
|
|
169
|
+
const matches = commit.body.matchAll(CoAuthoredByRegex);
|
|
170
|
+
for (const $match of matches) {
|
|
170
171
|
const { name = "", email = "" } = $match.groups || {};
|
|
171
172
|
const author = {
|
|
172
173
|
name: name.trim(),
|
|
@@ -201,7 +202,8 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
201
202
|
try {
|
|
202
203
|
const data = await ofetch.ofetch(`https://ungh.cc/users/find/${email}`);
|
|
203
204
|
login = data?.user?.username || "";
|
|
204
|
-
} catch {
|
|
205
|
+
} catch (e) {
|
|
206
|
+
console.log("e: ", e);
|
|
205
207
|
}
|
|
206
208
|
if (login) {
|
|
207
209
|
return login;
|
|
@@ -217,6 +219,7 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
217
219
|
});
|
|
218
220
|
login = data?.author?.login || "";
|
|
219
221
|
} catch (e) {
|
|
222
|
+
console.log("e: ", e);
|
|
220
223
|
}
|
|
221
224
|
}
|
|
222
225
|
if (login) {
|
|
@@ -228,6 +231,7 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
228
231
|
});
|
|
229
232
|
login = data.items[0].login;
|
|
230
233
|
} catch (e) {
|
|
234
|
+
console.log("e: ", e);
|
|
231
235
|
}
|
|
232
236
|
return login;
|
|
233
237
|
}
|
|
@@ -413,7 +417,7 @@ function getGitUserAvatar(userName) {
|
|
|
413
417
|
}
|
|
414
418
|
function createContributorLine(contributors) {
|
|
415
419
|
let loginLine = "";
|
|
416
|
-
let
|
|
420
|
+
let unLoginLine = "";
|
|
417
421
|
contributors.forEach((contributor, index) => {
|
|
418
422
|
const { name, email, login } = contributor;
|
|
419
423
|
if (!login) {
|
|
@@ -421,7 +425,7 @@ function createContributorLine(contributors) {
|
|
|
421
425
|
if (index < contributors.length - 1) {
|
|
422
426
|
line += ", ";
|
|
423
427
|
}
|
|
424
|
-
|
|
428
|
+
unLoginLine += line;
|
|
425
429
|
} else {
|
|
426
430
|
const githubUrl = getUserGithub(login);
|
|
427
431
|
const avatar = getGitUserAvatar(login);
|
|
@@ -429,10 +433,11 @@ function createContributorLine(contributors) {
|
|
|
429
433
|
}
|
|
430
434
|
});
|
|
431
435
|
return `${loginLine}
|
|
432
|
-
${
|
|
436
|
+
${unLoginLine}`;
|
|
433
437
|
}
|
|
434
438
|
function generateMarkdown(params) {
|
|
435
|
-
const {
|
|
439
|
+
const { options, showTitle, contributors } = params;
|
|
440
|
+
const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
|
|
436
441
|
const lines = [];
|
|
437
442
|
const isNewVersion = !VERSION_REG.test(options.to);
|
|
438
443
|
const version = isNewVersion ? options.newVersion : options.to;
|
|
@@ -556,6 +561,7 @@ async function generateTotalChangelog(options, showProgress = true) {
|
|
|
556
561
|
const markdown = await getTotalChangelogMarkdown(opts, showProgress);
|
|
557
562
|
await writeMarkdown(markdown, opts.output, true);
|
|
558
563
|
}
|
|
564
|
+
getChangelogMarkdown();
|
|
559
565
|
|
|
560
566
|
exports.generateChangelog = generateChangelog;
|
|
561
567
|
exports.generateTotalChangelog = generateTotalChangelog;
|
package/dist/index.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ interface ChangelogOption {
|
|
|
70
70
|
*/
|
|
71
71
|
regenerate: boolean;
|
|
72
72
|
/**
|
|
73
|
-
* version from package.json, with
|
|
73
|
+
* version from package.json, with prefix "v"
|
|
74
74
|
* @description if the options "to" is not specified, the version will be used
|
|
75
75
|
*/
|
|
76
76
|
newVersion: string;
|
package/dist/index.mjs
CHANGED
|
@@ -51,6 +51,7 @@ function join(array, glue = ", ", finalGlue = " and ") {
|
|
|
51
51
|
|
|
52
52
|
const VERSION_REG = /v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
53
53
|
const VERSION_REG_OF_MARKDOWN = /## \[v\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?]/g;
|
|
54
|
+
const VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
54
55
|
|
|
55
56
|
async function getTotalGitTags() {
|
|
56
57
|
const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
|
|
@@ -123,13 +124,13 @@ async function getGitDiff(from, to = "HEAD") {
|
|
|
123
124
|
const gitCommits = rwaGitLines.map((line) => {
|
|
124
125
|
const [firstLine, ...body] = line.split("\n");
|
|
125
126
|
const [message, shortHash, authorName, authorEmail] = firstLine.split("|");
|
|
126
|
-
const
|
|
127
|
+
const gitCommit = {
|
|
127
128
|
message,
|
|
128
129
|
shortHash,
|
|
129
130
|
author: { name: authorName, email: authorEmail },
|
|
130
131
|
body: body.join("\n")
|
|
131
132
|
};
|
|
132
|
-
return
|
|
133
|
+
return gitCommit;
|
|
133
134
|
});
|
|
134
135
|
return gitCommits;
|
|
135
136
|
}
|
|
@@ -158,8 +159,8 @@ function parseGitCommit(commit) {
|
|
|
158
159
|
references.push({ value: commit.shortHash, type: "hash" });
|
|
159
160
|
description = description.replace(PullRequestRE, "").trim();
|
|
160
161
|
const authors = [commit.author];
|
|
161
|
-
const
|
|
162
|
-
for (const $match of
|
|
162
|
+
const matches = commit.body.matchAll(CoAuthoredByRegex);
|
|
163
|
+
for (const $match of matches) {
|
|
163
164
|
const { name = "", email = "" } = $match.groups || {};
|
|
164
165
|
const author = {
|
|
165
166
|
name: name.trim(),
|
|
@@ -194,7 +195,8 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
194
195
|
try {
|
|
195
196
|
const data = await ofetch(`https://ungh.cc/users/find/${email}`);
|
|
196
197
|
login = data?.user?.username || "";
|
|
197
|
-
} catch {
|
|
198
|
+
} catch (e) {
|
|
199
|
+
console.log("e: ", e);
|
|
198
200
|
}
|
|
199
201
|
if (login) {
|
|
200
202
|
return login;
|
|
@@ -210,6 +212,7 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
210
212
|
});
|
|
211
213
|
login = data?.author?.login || "";
|
|
212
214
|
} catch (e) {
|
|
215
|
+
console.log("e: ", e);
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
if (login) {
|
|
@@ -221,6 +224,7 @@ async function getResolvedAuthorLogin(github, commitHashes, email) {
|
|
|
221
224
|
});
|
|
222
225
|
login = data.items[0].login;
|
|
223
226
|
} catch (e) {
|
|
227
|
+
console.log("e: ", e);
|
|
224
228
|
}
|
|
225
229
|
return login;
|
|
226
230
|
}
|
|
@@ -406,7 +410,7 @@ function getGitUserAvatar(userName) {
|
|
|
406
410
|
}
|
|
407
411
|
function createContributorLine(contributors) {
|
|
408
412
|
let loginLine = "";
|
|
409
|
-
let
|
|
413
|
+
let unLoginLine = "";
|
|
410
414
|
contributors.forEach((contributor, index) => {
|
|
411
415
|
const { name, email, login } = contributor;
|
|
412
416
|
if (!login) {
|
|
@@ -414,7 +418,7 @@ function createContributorLine(contributors) {
|
|
|
414
418
|
if (index < contributors.length - 1) {
|
|
415
419
|
line += ", ";
|
|
416
420
|
}
|
|
417
|
-
|
|
421
|
+
unLoginLine += line;
|
|
418
422
|
} else {
|
|
419
423
|
const githubUrl = getUserGithub(login);
|
|
420
424
|
const avatar = getGitUserAvatar(login);
|
|
@@ -422,10 +426,11 @@ function createContributorLine(contributors) {
|
|
|
422
426
|
}
|
|
423
427
|
});
|
|
424
428
|
return `${loginLine}
|
|
425
|
-
${
|
|
429
|
+
${unLoginLine}`;
|
|
426
430
|
}
|
|
427
431
|
function generateMarkdown(params) {
|
|
428
|
-
const {
|
|
432
|
+
const { options, showTitle, contributors } = params;
|
|
433
|
+
const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
|
|
429
434
|
const lines = [];
|
|
430
435
|
const isNewVersion = !VERSION_REG.test(options.to);
|
|
431
436
|
const version = isNewVersion ? options.newVersion : options.to;
|
|
@@ -549,5 +554,6 @@ async function generateTotalChangelog(options, showProgress = true) {
|
|
|
549
554
|
const markdown = await getTotalChangelogMarkdown(opts, showProgress);
|
|
550
555
|
await writeMarkdown(markdown, opts.output, true);
|
|
551
556
|
}
|
|
557
|
+
getChangelogMarkdown();
|
|
552
558
|
|
|
553
559
|
export { generateChangelog, generateTotalChangelog, getChangelogMarkdown, getTotalChangelogMarkdown };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/changelog",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "generate changelog form git tags and commits for github",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Soybean",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"cli-progress": "3.12.0",
|
|
36
36
|
"convert-gitmoji": "0.1.3",
|
|
37
|
-
"dayjs": "1.11.
|
|
37
|
+
"dayjs": "1.11.9",
|
|
38
38
|
"execa": "7.1.1",
|
|
39
|
-
"ofetch": "1.1.
|
|
39
|
+
"ofetch": "1.1.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@soybeanjs/cli": "0.6.
|
|
42
|
+
"@soybeanjs/cli": "0.6.2",
|
|
43
43
|
"@types/cli-progress": "3.11.0",
|
|
44
|
-
"@types/node": "20.
|
|
45
|
-
"eslint": "8.
|
|
46
|
-
"eslint-config-soybeanjs": "0.
|
|
47
|
-
"simple-git-hooks": "2.
|
|
44
|
+
"@types/node": "20.4.5",
|
|
45
|
+
"eslint": "8.45.0",
|
|
46
|
+
"eslint-config-soybeanjs": "0.5.3",
|
|
47
|
+
"simple-git-hooks": "2.9.0",
|
|
48
48
|
"tsx": "3.12.7",
|
|
49
|
-
"typescript": "5.1.
|
|
49
|
+
"typescript": "5.1.6",
|
|
50
50
|
"unbuild": "1.2.1"
|
|
51
51
|
},
|
|
52
52
|
"simple-git-hooks": {
|