@soybeanjs/changelog 0.3.15 → 0.3.16
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 +29 -33
- package/dist/index.d.cts +0 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +27 -31
- package/package.json +9 -10
package/dist/index.cjs
CHANGED
|
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// node_modules/.pnpm/tsup@8.0.2_typescript@5.
|
|
33
|
+
// node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js
|
|
34
34
|
var init_cjs_shims = __esm({
|
|
35
|
-
"node_modules/.pnpm/tsup@8.0.2_typescript@5.
|
|
35
|
+
"node_modules/.pnpm/tsup@8.0.2_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"() {
|
|
36
36
|
"use strict";
|
|
37
37
|
}
|
|
38
38
|
});
|
|
@@ -2004,7 +2004,7 @@ var VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
|
2004
2004
|
async function getTotalGitTags() {
|
|
2005
2005
|
const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
|
|
2006
2006
|
const tags = tagStr.split("\n");
|
|
2007
|
-
return tags;
|
|
2007
|
+
return tags.filter((tag) => VERSION_REG.test(tag));
|
|
2008
2008
|
}
|
|
2009
2009
|
async function getTagDateMap() {
|
|
2010
2010
|
const tagDateStr = await execCommand("git", [
|
|
@@ -2030,25 +2030,23 @@ async function getTagDateMap() {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
function getFromToTags(tags) {
|
|
2032
2032
|
const result = [];
|
|
2033
|
-
tags.
|
|
2034
|
-
|
|
2035
|
-
|
|
2033
|
+
if (tags.length < 2) {
|
|
2034
|
+
return result;
|
|
2035
|
+
}
|
|
2036
|
+
const releaseTags = tags.filter((tag) => !isPrerelease(tag));
|
|
2037
|
+
const reversedTags = [...tags].reverse();
|
|
2038
|
+
reversedTags.forEach((tag, index) => {
|
|
2039
|
+
if (index < reversedTags.length - 1) {
|
|
2040
|
+
const to = tag;
|
|
2041
|
+
let from = reversedTags[index + 1];
|
|
2042
|
+
if (!isPrerelease(to)) {
|
|
2043
|
+
const toIndex = releaseTags.indexOf(to);
|
|
2044
|
+
from = releaseTags[toIndex - 1];
|
|
2045
|
+
}
|
|
2046
|
+
result.push({ from, to });
|
|
2036
2047
|
}
|
|
2037
2048
|
});
|
|
2038
|
-
return result;
|
|
2039
|
-
}
|
|
2040
|
-
async function getLastGitTag(delta = 0) {
|
|
2041
|
-
const tags = await getTotalGitTags();
|
|
2042
|
-
return tags[tags.length + delta - 1];
|
|
2043
|
-
}
|
|
2044
|
-
async function getGitMainBranchName() {
|
|
2045
|
-
const main = await execCommand("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
2046
|
-
return main;
|
|
2047
|
-
}
|
|
2048
|
-
async function getCurrentGitBranch() {
|
|
2049
|
-
const tag = await execCommand("git", ["tag", "--points-at", "HEAD"]);
|
|
2050
|
-
const main = getGitMainBranchName();
|
|
2051
|
-
return tag || main;
|
|
2049
|
+
return result.reverse();
|
|
2052
2050
|
}
|
|
2053
2051
|
async function getGitHubRepo() {
|
|
2054
2052
|
const url = await execCommand("git", ["config", "--get", "remote.origin.url"]);
|
|
@@ -2256,8 +2254,7 @@ function createDefaultOptions() {
|
|
|
2256
2254
|
breakingChanges: "\u{1F6A8} Breaking Changes"
|
|
2257
2255
|
},
|
|
2258
2256
|
output: "CHANGELOG.md",
|
|
2259
|
-
regenerate: false
|
|
2260
|
-
newVersion: ""
|
|
2257
|
+
regenerate: false
|
|
2261
2258
|
};
|
|
2262
2259
|
return options;
|
|
2263
2260
|
}
|
|
@@ -2279,21 +2276,20 @@ async function createOptions(options) {
|
|
|
2279
2276
|
Object.assign(opts, options);
|
|
2280
2277
|
const { newVersion } = await getVersionFromPkgJson(opts.cwd);
|
|
2281
2278
|
(_a = opts.github).repo || (_a.repo = await getGitHubRepo());
|
|
2282
|
-
|
|
2283
|
-
opts.
|
|
2284
|
-
opts.
|
|
2279
|
+
const tags = await getTotalGitTags();
|
|
2280
|
+
opts.tags = tags;
|
|
2281
|
+
opts.from || (opts.from = tags[tags.length - 1]);
|
|
2282
|
+
opts.to || (opts.to = `v${newVersion}`);
|
|
2285
2283
|
if (opts.to === opts.from) {
|
|
2286
|
-
const lastTag =
|
|
2284
|
+
const lastTag = tags[tags.length - 2];
|
|
2287
2285
|
const firstCommit = await getFirstGitCommit();
|
|
2288
2286
|
opts.from = lastTag || firstCommit;
|
|
2289
2287
|
}
|
|
2290
|
-
opts.tags = await getTotalGitTags();
|
|
2291
2288
|
opts.tagDateMap = await getTagDateMap();
|
|
2292
2289
|
opts.prerelease || (opts.prerelease = isPrerelease(opts.to));
|
|
2293
2290
|
const isFromPrerelease = isPrerelease(opts.from);
|
|
2294
2291
|
if (!isPrerelease(newVersion) && isFromPrerelease) {
|
|
2295
|
-
const
|
|
2296
|
-
const allReleaseTags = opts.tags.filter((tag) => !isPrerelease(tag) && tag !== nVersion);
|
|
2292
|
+
const allReleaseTags = opts.tags.filter((tag) => !isPrerelease(tag) && tag !== opts.to);
|
|
2297
2293
|
opts.from = allReleaseTags[allReleaseTags.length - 1];
|
|
2298
2294
|
}
|
|
2299
2295
|
return opts;
|
|
@@ -2405,10 +2401,10 @@ function generateMarkdown(params) {
|
|
|
2405
2401
|
const { options, showTitle, contributors } = params;
|
|
2406
2402
|
const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
|
|
2407
2403
|
const lines = [];
|
|
2408
|
-
const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.
|
|
2404
|
+
const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
|
|
2409
2405
|
if (showTitle) {
|
|
2410
|
-
const date = options.tagDateMap.get(options.
|
|
2411
|
-
let title = `## [${options.
|
|
2406
|
+
const date = options.tagDateMap.get(options.to) || (0, import_dayjs2.default)().format("YYYY-MM-DD");
|
|
2407
|
+
let title = `## [${options.to}](${url})`;
|
|
2412
2408
|
if (date) {
|
|
2413
2409
|
title += ` (${date})`;
|
|
2414
2410
|
}
|
|
@@ -2526,7 +2522,7 @@ ${markdown}`;
|
|
|
2526
2522
|
}
|
|
2527
2523
|
async function generateChangelog(options) {
|
|
2528
2524
|
const opts = await createOptions(options);
|
|
2529
|
-
const existContent = await isVersionInMarkdown(opts.
|
|
2525
|
+
const existContent = await isVersionInMarkdown(opts.to, opts.output);
|
|
2530
2526
|
if (!opts.regenerate && existContent)
|
|
2531
2527
|
return;
|
|
2532
2528
|
const { markdown } = await getChangelogMarkdown(opts);
|
package/dist/index.d.cts
CHANGED
|
@@ -100,12 +100,6 @@ interface ChangelogOption {
|
|
|
100
100
|
* the changelog already exists the content of v0.0.1, but you want to regenerate it
|
|
101
101
|
*/
|
|
102
102
|
regenerate: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Version from package.json, with prefix "v"
|
|
105
|
-
*
|
|
106
|
-
* If the options "to" is not specified, the version will be used
|
|
107
|
-
*/
|
|
108
|
-
newVersion: string;
|
|
109
103
|
/** Mark the release as prerelease */
|
|
110
104
|
prerelease?: boolean;
|
|
111
105
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -100,12 +100,6 @@ interface ChangelogOption {
|
|
|
100
100
|
* the changelog already exists the content of v0.0.1, but you want to regenerate it
|
|
101
101
|
*/
|
|
102
102
|
regenerate: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Version from package.json, with prefix "v"
|
|
105
|
-
*
|
|
106
|
-
* If the options "to" is not specified, the version will be used
|
|
107
|
-
*/
|
|
108
|
-
newVersion: string;
|
|
109
103
|
/** Mark the release as prerelease */
|
|
110
104
|
prerelease?: boolean;
|
|
111
105
|
}
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ var VERSION_WITH_RELEASE = /release\sv\d+\.\d+\.\d+(-(beta|alpha)\.\d+)?/;
|
|
|
68
68
|
async function getTotalGitTags() {
|
|
69
69
|
const tagStr = await execCommand("git", ["--no-pager", "tag", "-l", "--sort=creatordate"]);
|
|
70
70
|
const tags = tagStr.split("\n");
|
|
71
|
-
return tags;
|
|
71
|
+
return tags.filter((tag) => VERSION_REG.test(tag));
|
|
72
72
|
}
|
|
73
73
|
async function getTagDateMap() {
|
|
74
74
|
const tagDateStr = await execCommand("git", [
|
|
@@ -94,25 +94,23 @@ async function getTagDateMap() {
|
|
|
94
94
|
}
|
|
95
95
|
function getFromToTags(tags) {
|
|
96
96
|
const result = [];
|
|
97
|
-
tags.
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
if (tags.length < 2) {
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
const releaseTags = tags.filter((tag) => !isPrerelease(tag));
|
|
101
|
+
const reversedTags = [...tags].reverse();
|
|
102
|
+
reversedTags.forEach((tag, index) => {
|
|
103
|
+
if (index < reversedTags.length - 1) {
|
|
104
|
+
const to = tag;
|
|
105
|
+
let from = reversedTags[index + 1];
|
|
106
|
+
if (!isPrerelease(to)) {
|
|
107
|
+
const toIndex = releaseTags.indexOf(to);
|
|
108
|
+
from = releaseTags[toIndex - 1];
|
|
109
|
+
}
|
|
110
|
+
result.push({ from, to });
|
|
100
111
|
}
|
|
101
112
|
});
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
async function getLastGitTag(delta = 0) {
|
|
105
|
-
const tags = await getTotalGitTags();
|
|
106
|
-
return tags[tags.length + delta - 1];
|
|
107
|
-
}
|
|
108
|
-
async function getGitMainBranchName() {
|
|
109
|
-
const main = await execCommand("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
110
|
-
return main;
|
|
111
|
-
}
|
|
112
|
-
async function getCurrentGitBranch() {
|
|
113
|
-
const tag = await execCommand("git", ["tag", "--points-at", "HEAD"]);
|
|
114
|
-
const main = getGitMainBranchName();
|
|
115
|
-
return tag || main;
|
|
113
|
+
return result.reverse();
|
|
116
114
|
}
|
|
117
115
|
async function getGitHubRepo() {
|
|
118
116
|
const url = await execCommand("git", ["config", "--get", "remote.origin.url"]);
|
|
@@ -320,8 +318,7 @@ function createDefaultOptions() {
|
|
|
320
318
|
breakingChanges: "\u{1F6A8} Breaking Changes"
|
|
321
319
|
},
|
|
322
320
|
output: "CHANGELOG.md",
|
|
323
|
-
regenerate: false
|
|
324
|
-
newVersion: ""
|
|
321
|
+
regenerate: false
|
|
325
322
|
};
|
|
326
323
|
return options;
|
|
327
324
|
}
|
|
@@ -343,21 +340,20 @@ async function createOptions(options) {
|
|
|
343
340
|
Object.assign(opts, options);
|
|
344
341
|
const { newVersion } = await getVersionFromPkgJson(opts.cwd);
|
|
345
342
|
(_a = opts.github).repo || (_a.repo = await getGitHubRepo());
|
|
346
|
-
|
|
347
|
-
opts.
|
|
348
|
-
opts.
|
|
343
|
+
const tags = await getTotalGitTags();
|
|
344
|
+
opts.tags = tags;
|
|
345
|
+
opts.from || (opts.from = tags[tags.length - 1]);
|
|
346
|
+
opts.to || (opts.to = `v${newVersion}`);
|
|
349
347
|
if (opts.to === opts.from) {
|
|
350
|
-
const lastTag =
|
|
348
|
+
const lastTag = tags[tags.length - 2];
|
|
351
349
|
const firstCommit = await getFirstGitCommit();
|
|
352
350
|
opts.from = lastTag || firstCommit;
|
|
353
351
|
}
|
|
354
|
-
opts.tags = await getTotalGitTags();
|
|
355
352
|
opts.tagDateMap = await getTagDateMap();
|
|
356
353
|
opts.prerelease || (opts.prerelease = isPrerelease(opts.to));
|
|
357
354
|
const isFromPrerelease = isPrerelease(opts.from);
|
|
358
355
|
if (!isPrerelease(newVersion) && isFromPrerelease) {
|
|
359
|
-
const
|
|
360
|
-
const allReleaseTags = opts.tags.filter((tag) => !isPrerelease(tag) && tag !== nVersion);
|
|
356
|
+
const allReleaseTags = opts.tags.filter((tag) => !isPrerelease(tag) && tag !== opts.to);
|
|
361
357
|
opts.from = allReleaseTags[allReleaseTags.length - 1];
|
|
362
358
|
}
|
|
363
359
|
return opts;
|
|
@@ -468,10 +464,10 @@ function generateMarkdown(params) {
|
|
|
468
464
|
const { options, showTitle, contributors } = params;
|
|
469
465
|
const commits = params.commits.filter((commit) => commit.description.match(VERSION_WITH_RELEASE) === null);
|
|
470
466
|
const lines = [];
|
|
471
|
-
const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.
|
|
467
|
+
const url = `https://github.com/${options.github.repo}/compare/${options.from}...${options.to}`;
|
|
472
468
|
if (showTitle) {
|
|
473
|
-
const date = options.tagDateMap.get(options.
|
|
474
|
-
let title = `## [${options.
|
|
469
|
+
const date = options.tagDateMap.get(options.to) || dayjs2().format("YYYY-MM-DD");
|
|
470
|
+
let title = `## [${options.to}](${url})`;
|
|
475
471
|
if (date) {
|
|
476
472
|
title += ` (${date})`;
|
|
477
473
|
}
|
|
@@ -589,7 +585,7 @@ ${markdown}`;
|
|
|
589
585
|
}
|
|
590
586
|
async function generateChangelog(options) {
|
|
591
587
|
const opts = await createOptions(options);
|
|
592
|
-
const existContent = await isVersionInMarkdown(opts.
|
|
588
|
+
const existContent = await isVersionInMarkdown(opts.to, opts.output);
|
|
593
589
|
if (!opts.regenerate && existContent)
|
|
594
590
|
return;
|
|
595
591
|
const { markdown } = await getChangelogMarkdown(opts);
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/changelog",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
5
|
-
"packageManager": "pnpm@8.14.1",
|
|
4
|
+
"version": "0.3.16",
|
|
6
5
|
"description": "generate changelog form git tags and commits for github",
|
|
7
6
|
"author": {
|
|
8
7
|
"name": "Soybean",
|
|
@@ -38,23 +37,23 @@
|
|
|
38
37
|
"node": ">=14"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
41
|
-
"@soybeanjs/eslint-config": "^1.2
|
|
40
|
+
"@soybeanjs/eslint-config": "^1.3.2",
|
|
42
41
|
"cli-progress": "3.12.0",
|
|
43
42
|
"convert-gitmoji": "0.1.5",
|
|
44
43
|
"dayjs": "1.11.10",
|
|
45
44
|
"execa": "8.0.1",
|
|
46
|
-
"ofetch": "1.3.
|
|
45
|
+
"ofetch": "1.3.4"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@soybeanjs/cli": "1.0.
|
|
48
|
+
"@soybeanjs/cli": "1.0.11",
|
|
50
49
|
"@types/cli-progress": "3.11.5",
|
|
51
|
-
"@types/node": "20.
|
|
52
|
-
"eslint": "
|
|
50
|
+
"@types/node": "20.12.7",
|
|
51
|
+
"eslint": "9.1.1",
|
|
53
52
|
"lint-staged": "15.2.2",
|
|
54
|
-
"simple-git-hooks": "2.
|
|
53
|
+
"simple-git-hooks": "2.11.1",
|
|
55
54
|
"tsup": "^8.0.2",
|
|
56
|
-
"tsx": "4.7.
|
|
57
|
-
"typescript": "5.
|
|
55
|
+
"tsx": "4.7.2",
|
|
56
|
+
"typescript": "5.4.5"
|
|
58
57
|
},
|
|
59
58
|
"simple-git-hooks": {
|
|
60
59
|
"commit-msg": "pnpm soy git-commit-verify",
|