spec-up-t 1.6.15 → 1.6.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.16",
|
|
4
4
|
"description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
|
|
5
5
|
"main": "./index",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,34 @@ const fs = require('fs-extra');
|
|
|
18
18
|
const path = require('path');
|
|
19
19
|
const Logger = require('../utils/logger');
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Extracts snapshot labels from a hand-edited docs/versions/index.html.
|
|
23
|
+
* Parses every anchor whose href points to a version directory (e.g. "v1/")
|
|
24
|
+
* and maps the directory name to the visible link text.
|
|
25
|
+
*
|
|
26
|
+
* Example input: <a href="v1/">KERI Release 1.0</a>
|
|
27
|
+
* Example output: { "v1": "KERI Release 1.0" }
|
|
28
|
+
*
|
|
29
|
+
* The "Latest version" link (href="../") is intentionally ignored.
|
|
30
|
+
*
|
|
31
|
+
* @param {string} indexHtmlPath - Absolute path to docs/versions/index.html.
|
|
32
|
+
* @returns {Object} Map of version directory names to label strings.
|
|
33
|
+
*/
|
|
34
|
+
function extractLabelsFromIndexHtml(indexHtmlPath) {
|
|
35
|
+
const labels = {};
|
|
36
|
+
const html = fs.readFileSync(indexHtmlPath, 'utf8');
|
|
37
|
+
// Match: href="v1/" or href="v1" (with or without trailing slash)
|
|
38
|
+
const linkPattern = /href="(v\d+)\/?">([^<]+)<\/a>/g;
|
|
39
|
+
let match = linkPattern.exec(html);
|
|
40
|
+
while (match !== null) {
|
|
41
|
+
const dirName = match[1];
|
|
42
|
+
const linkText = match[2].trim();
|
|
43
|
+
labels[dirName] = linkText;
|
|
44
|
+
match = linkPattern.exec(html);
|
|
45
|
+
}
|
|
46
|
+
return labels;
|
|
47
|
+
}
|
|
48
|
+
|
|
21
49
|
/**
|
|
22
50
|
* Migrates frozen snapshots from docs/versions/ to snapshots/.
|
|
23
51
|
* @param {string} outputPath - The output directory defined in specs.json (e.g. './docs').
|
|
@@ -57,21 +85,29 @@ function migrateVersionsToSnapshots(outputPath) {
|
|
|
57
85
|
});
|
|
58
86
|
|
|
59
87
|
// Always keep labels.json up to date in snapshots/.
|
|
88
|
+
// Priority order (highest wins):
|
|
89
|
+
// 1. Labels already in snapshots/labels.json (from previous migrations or freezes)
|
|
90
|
+
// 2. Labels extracted from hand-edited docs/versions/index.html
|
|
91
|
+
// 3. Labels from docs/versions/labels.json (auto-generated source)
|
|
60
92
|
const srcLabels = path.join(src, 'labels.json');
|
|
93
|
+
const srcIndexHtml = path.join(src, 'index.html');
|
|
61
94
|
const destLabels = path.join(dest, 'labels.json');
|
|
62
95
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
96
|
+
// Start from labels.json if it exists
|
|
97
|
+
const legacyLabels = fs.existsSync(srcLabels) ? fs.readJsonSync(srcLabels) : {};
|
|
98
|
+
|
|
99
|
+
// Overlay with labels parsed from index.html — these may be hand-edited
|
|
100
|
+
const htmlLabels = fs.existsSync(srcIndexHtml)
|
|
101
|
+
? extractLabelsFromIndexHtml(srcIndexHtml)
|
|
102
|
+
: {};
|
|
103
|
+
|
|
104
|
+
// Existing snapshots/labels.json wins on any conflict
|
|
105
|
+
const existingDestLabels = fs.existsSync(destLabels) ? fs.readJsonSync(destLabels) : {};
|
|
106
|
+
|
|
107
|
+
const merged = { ...legacyLabels, ...htmlLabels, ...existingDestLabels };
|
|
108
|
+
|
|
109
|
+
if (Object.keys(merged).length > 0) {
|
|
110
|
+
fs.writeJsonSync(destLabels, merged, { spaces: 2 });
|
|
75
111
|
}
|
|
76
112
|
|
|
77
113
|
if (migratedCount > 0) {
|