@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/program.js +13 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docubook/cli",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "DocuBook CLI tool that helps you initialize, update, and deploy documentation directly from your terminal.",
5
5
  "type": "module",
6
6
  "files": [
@@ -32,21 +32,18 @@ function _writeChangelogStore(obj) {
32
32
  }
33
33
  }
34
34
 
35
- async function _fetchChangelogFromGitHub(tag) {
36
- // Try to fetch CHANGELOG.md from the repo tag. Support several tag-name variants
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 bare = tag.replace(/^v/, "");
41
- const variants = [tag, bare, `cli-${tag}`, `cli-${bare}`].filter(Boolean);
42
-
43
- const candidates = [];
44
- for (const v of variants) {
45
- candidates.push(`https://raw.githubusercontent.com/${repo}/${v}/CHANGELOG.md`);
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
- if (/^#{1,3}\s*/.test(lines[j])) {
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 tag = version.startsWith("v") ? version : `v${version}`;
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);