@docubook/cli 0.2.5 → 0.2.6
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/package.json +1 -1
- package/src/cli/program.js +13 -16
package/package.json
CHANGED
package/src/cli/program.js
CHANGED
|
@@ -32,21 +32,18 @@ function _writeChangelogStore(obj) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async function _fetchChangelogFromGitHub(
|
|
36
|
-
//
|
|
37
|
-
// (e.g. v1.2.3, 1.2.3, cli-v1.2.3, cli-1.2.3) and common filename variants.
|
|
35
|
+
async function _fetchChangelogFromGitHub(version) {
|
|
36
|
+
// Fetch CHANGELOG.md from the CLI release tag format: cli-v0.2.5
|
|
38
37
|
const repo = "DocuBook/docubook";
|
|
38
|
+
const bare = version.replace(/^v/, "");
|
|
39
|
+
const tag = `cli-v${bare}`;
|
|
39
40
|
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
candidates.push(`https://raw.githubusercontent.com/${repo}/${v}/CHANGELOG.MD`);
|
|
47
|
-
}
|
|
48
|
-
// final fallback to main branch
|
|
49
|
-
candidates.push(`https://raw.githubusercontent.com/${repo}/main/CHANGELOG.md`);
|
|
41
|
+
const candidates = [
|
|
42
|
+
`https://raw.githubusercontent.com/${repo}/${tag}/CHANGELOG.md`,
|
|
43
|
+
`https://raw.githubusercontent.com/${repo}/${tag}/CHANGELOG.MD`,
|
|
44
|
+
// Fallback to main branch
|
|
45
|
+
`https://raw.githubusercontent.com/${repo}/main/CHANGELOG.md`,
|
|
46
|
+
];
|
|
50
47
|
|
|
51
48
|
for (const url of candidates) {
|
|
52
49
|
try {
|
|
@@ -75,7 +72,8 @@ function _extractVersionSection(changelogText, version) {
|
|
|
75
72
|
|
|
76
73
|
let end = lines.length;
|
|
77
74
|
for (let j = start + 1; j < lines.length; j++) {
|
|
78
|
-
|
|
75
|
+
// Match the next version heading (level 2, ## but not ###)
|
|
76
|
+
if (/^##\s*(?!#)/.test(lines[j])) {
|
|
79
77
|
end = j;
|
|
80
78
|
break;
|
|
81
79
|
}
|
|
@@ -89,8 +87,7 @@ async function showChangelogOnce(pkgName, version) {
|
|
|
89
87
|
const seen = Array.isArray(store[pkgName]) ? store[pkgName] : [];
|
|
90
88
|
if (seen.includes(version)) return;
|
|
91
89
|
|
|
92
|
-
const
|
|
93
|
-
const changelog = await _fetchChangelogFromGitHub(tag);
|
|
90
|
+
const changelog = await _fetchChangelogFromGitHub(version);
|
|
94
91
|
if (!changelog) return;
|
|
95
92
|
|
|
96
93
|
const section = _extractVersionSection(changelog, version);
|