spec-up-t 1.6.3-beta.1 → 1.6.4
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/.github/copilot-instructions.md +2 -0
- package/assets/compiled/body.js +9 -7
- package/assets/compiled/head.css +6 -6
- package/assets/css/adjust-font-size.css +0 -4
- package/assets/css/download-pdf-docx.css +19 -20
- package/assets/css/header-navbar.css +0 -4
- package/assets/css/index.css +36 -0
- package/assets/css/terms-and-definitions.css +0 -1
- package/assets/css/validate-external-refs.css +198 -3
- package/assets/js/add-href-to-snapshot-link.js +11 -5
- package/assets/js/download-pdf-docx.js +20 -9
- package/assets/js/edit-term-buttons.js +71 -68
- package/assets/js/github-issues.js +27 -27
- package/assets/js/insert-irefs.js +1 -1
- package/assets/js/validate-external-refs.js +356 -7
- package/package.json +3 -3
- package/src/add-remove-xref-source.js +0 -5
- package/src/collect-external-references.test.js +98 -0
- package/src/install-from-boilerplate/boilerplate/gitignore +2 -2
- package/src/install-from-boilerplate/boilerplate/menu-wrapper.sh +19 -0
- package/src/install-from-boilerplate/boilerplate/specs.json +3 -6
- package/src/install-from-boilerplate/config-scripts-keys.js +1 -1
- package/src/install-from-boilerplate/config-system-files.js +1 -0
- package/src/install-from-boilerplate/custom-update.js +6 -3
- package/src/install-from-boilerplate/update-dependencies.js +105 -0
- package/src/pipeline/references/collect-external-references.js +12 -0
- package/src/pipeline/references/external-references-service.js +1 -1
- package/src/pipeline/rendering/render-spec-document.js +5 -1
- package/templates/template.html +43 -10
- package/src/health-check/destination-gitignore-checker.js +0 -414
- package/src/health-check/external-specs-checker.js +0 -287
- package/src/health-check/specs-configuration-checker.js +0 -387
- package/src/health-check/term-references-checker.js +0 -270
- package/src/health-check/terms-intro-checker.js +0 -82
- package/src/health-check/tref-term-checker.js +0 -549
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const Logger = require('../utils/logger');
|
|
4
|
-
const { externalReferences } = require('../utils/regex-patterns');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Extracts the spec name from a tref tag at the beginning of a markdown file
|
|
8
|
-
* @param {string} firstLine - The first line of a markdown file
|
|
9
|
-
* @returns {string|null} - The extracted spec name or null if not found
|
|
10
|
-
*/
|
|
11
|
-
function extractSpecNameFromTref(firstLine) {
|
|
12
|
-
if (!firstLine.includes('[[tref:')) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
// Extract content between [[tref: and the next comma
|
|
18
|
-
const match = firstLine.match(externalReferences.trefSpecExtractor);
|
|
19
|
-
if (match && match[1]) {
|
|
20
|
-
// Trim whitespace
|
|
21
|
-
return match[1].trim();
|
|
22
|
-
}
|
|
23
|
-
} catch (error) {
|
|
24
|
-
Logger.error('Error extracting spec name from tref:', error);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Validates the existence of specs.json and returns its parsed content
|
|
32
|
-
* @param {string} projectRoot - Root directory of the project
|
|
33
|
-
* @param {Array} results - Results array to populate
|
|
34
|
-
* @returns {Object|null} - Parsed specs.json or null if not found
|
|
35
|
-
*/
|
|
36
|
-
function getSpecsConfig(projectRoot, results) {
|
|
37
|
-
const specsPath = path.join(projectRoot, 'specs.json');
|
|
38
|
-
|
|
39
|
-
if (!fs.existsSync(specsPath)) {
|
|
40
|
-
results.push({
|
|
41
|
-
name: 'Find specs.json file',
|
|
42
|
-
success: false,
|
|
43
|
-
details: 'specs.json file not found in project root'
|
|
44
|
-
});
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const specsContent = fs.readFileSync(specsPath, 'utf8');
|
|
50
|
-
return JSON.parse(specsContent);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
results.push({
|
|
53
|
-
name: 'Parse specs.json file',
|
|
54
|
-
success: false,
|
|
55
|
-
details: `Error parsing specs.json: ${error.message}`
|
|
56
|
-
});
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Extracts external specs and term directories from specs configuration
|
|
63
|
-
* @param {Object} specs - Specs configuration object
|
|
64
|
-
* @param {string} projectRoot - Root directory of the project
|
|
65
|
-
* @returns {Object} - Object containing external specs and term directories
|
|
66
|
-
*/
|
|
67
|
-
function extractSpecsInfo(specs, projectRoot) {
|
|
68
|
-
const externalSpecs = [];
|
|
69
|
-
const allSpecDirectories = [];
|
|
70
|
-
|
|
71
|
-
if (!specs.specs || !Array.isArray(specs.specs)) {
|
|
72
|
-
return { externalSpecs, allSpecDirectories };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
specs.specs.forEach(spec => {
|
|
76
|
-
// Collect external specs
|
|
77
|
-
if (spec.external_specs && Array.isArray(spec.external_specs)) {
|
|
78
|
-
spec.external_specs.forEach(extSpec => {
|
|
79
|
-
if (extSpec.external_spec) {
|
|
80
|
-
externalSpecs.push(extSpec.external_spec);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Collect term directories
|
|
86
|
-
if (spec.spec_directory && spec.spec_terms_directory) {
|
|
87
|
-
const termsDir = path.join(
|
|
88
|
-
projectRoot,
|
|
89
|
-
spec.spec_directory,
|
|
90
|
-
spec.spec_terms_directory
|
|
91
|
-
);
|
|
92
|
-
allSpecDirectories.push(termsDir);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
return { externalSpecs, allSpecDirectories };
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Reports status of found external specs
|
|
101
|
-
* @param {Array} externalSpecs - List of external specs
|
|
102
|
-
* @param {Array} results - Results array to populate
|
|
103
|
-
*/
|
|
104
|
-
function reportExternalSpecs(externalSpecs, results) {
|
|
105
|
-
if (externalSpecs.length === 0) {
|
|
106
|
-
results.push({
|
|
107
|
-
name: 'Find external specs',
|
|
108
|
-
success: false,
|
|
109
|
-
details: 'No external_spec entries found in specs.json'
|
|
110
|
-
});
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
results.push({
|
|
115
|
-
name: 'Find external specs',
|
|
116
|
-
success: true,
|
|
117
|
-
details: `Found ${externalSpecs.length} external specs: ${externalSpecs.join(', ')}`
|
|
118
|
-
});
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Reports status of found spec term directories
|
|
124
|
-
* @param {Array} allSpecDirectories - List of spec term directories
|
|
125
|
-
* @param {Array} results - Results array to populate
|
|
126
|
-
* @returns {boolean} - Whether any directories were found
|
|
127
|
-
*/
|
|
128
|
-
function reportSpecDirectories(allSpecDirectories, results) {
|
|
129
|
-
if (allSpecDirectories.length === 0) {
|
|
130
|
-
results.push({
|
|
131
|
-
name: 'Find spec terms directories',
|
|
132
|
-
success: false,
|
|
133
|
-
details: 'No spec_directory/spec_terms_directory entries found in specs.json'
|
|
134
|
-
});
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
results.push({
|
|
139
|
-
name: 'Find spec terms directories',
|
|
140
|
-
success: true,
|
|
141
|
-
details: `Found ${allSpecDirectories.length} spec terms directories`
|
|
142
|
-
});
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Gets markdown files from a terms directory
|
|
148
|
-
* @param {string} termsDir - Path to terms directory
|
|
149
|
-
* @param {Array} results - Results array to populate
|
|
150
|
-
* @returns {Array} - List of markdown file paths or empty array if none found
|
|
151
|
-
*/
|
|
152
|
-
function getMarkdownFiles(termsDir, results) {
|
|
153
|
-
if (!fs.existsSync(termsDir)) {
|
|
154
|
-
results.push({
|
|
155
|
-
name: `Check terms directory: ${termsDir}`,
|
|
156
|
-
success: false,
|
|
157
|
-
details: `Terms directory does not exist: ${termsDir}`
|
|
158
|
-
});
|
|
159
|
-
return [];
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const markdownFiles = fs.readdirSync(termsDir)
|
|
163
|
-
.filter(file => path.extname(file) === '.md')
|
|
164
|
-
.map(file => path.join(termsDir, file));
|
|
165
|
-
|
|
166
|
-
if (markdownFiles.length === 0) {
|
|
167
|
-
results.push({
|
|
168
|
-
name: `Find markdown files in <code>${termsDir}</code>`,
|
|
169
|
-
success: false,
|
|
170
|
-
details: `No markdown files found in terms directory: ${termsDir}`
|
|
171
|
-
});
|
|
172
|
-
return [];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
results.push({
|
|
176
|
-
name: `Find markdown files in <code>${termsDir}</code>`,
|
|
177
|
-
success: true,
|
|
178
|
-
details: `Found ${markdownFiles.length} markdown files`
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
return markdownFiles;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Validates a markdown file's tref references
|
|
186
|
-
* @param {string} mdFile - Path to markdown file
|
|
187
|
-
* @param {Array} externalSpecs - List of external specs
|
|
188
|
-
* @param {Array} results - Results array to populate
|
|
189
|
-
*/
|
|
190
|
-
function validateMarkdownFile(mdFile, externalSpecs, results) {
|
|
191
|
-
try {
|
|
192
|
-
const content = fs.readFileSync(mdFile, 'utf8');
|
|
193
|
-
const firstLine = content.split('\n')[0];
|
|
194
|
-
|
|
195
|
-
if (!firstLine.includes('[[tref:')) {
|
|
196
|
-
return; // Skip this file
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const specName = extractSpecNameFromTref(firstLine);
|
|
200
|
-
if (!specName) {
|
|
201
|
-
results.push({
|
|
202
|
-
name: `Check tref in ${path.basename(mdFile)}`,
|
|
203
|
-
success: false,
|
|
204
|
-
details: `Could not extract spec name from tref tag in first line: "${firstLine}"`
|
|
205
|
-
});
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const isValid = externalSpecs.includes(specName);
|
|
210
|
-
results.push({
|
|
211
|
-
name: `Check tref spec "${specName}" in <code>${path.basename(mdFile)}</code>`,
|
|
212
|
-
success: isValid,
|
|
213
|
-
details: isValid
|
|
214
|
-
? `Valid external spec reference: ${specName}`
|
|
215
|
-
: `Invalid external spec reference: "${specName}" is not defined in external_specs`
|
|
216
|
-
});
|
|
217
|
-
} catch (error) {
|
|
218
|
-
results.push({
|
|
219
|
-
name: `Check file ${path.basename(mdFile)}`,
|
|
220
|
-
success: false,
|
|
221
|
-
details: `Error reading or processing file: ${error.message}`
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Check if all markdown files in spec terms directories have valid tref references
|
|
228
|
-
* @param {string} projectRoot - Root directory of the project
|
|
229
|
-
* @returns {Promise<Array>} - Array of check results
|
|
230
|
-
*/
|
|
231
|
-
async function checkTermReferences(projectRoot) {
|
|
232
|
-
const results = [];
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
const specs = getSpecsConfig(projectRoot, results);
|
|
236
|
-
if (!specs) {
|
|
237
|
-
return results;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const { externalSpecs, allSpecDirectories } = extractSpecsInfo(specs, projectRoot);
|
|
241
|
-
|
|
242
|
-
const hasDirectories = reportSpecDirectories(allSpecDirectories, results);
|
|
243
|
-
|
|
244
|
-
if (!hasDirectories) {
|
|
245
|
-
return results;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Process all markdown files in all terms directories
|
|
249
|
-
for (const termsDir of allSpecDirectories) {
|
|
250
|
-
const markdownFiles = getMarkdownFiles(termsDir, results);
|
|
251
|
-
|
|
252
|
-
for (const mdFile of markdownFiles) {
|
|
253
|
-
validateMarkdownFile(mdFile, externalSpecs, results);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return results;
|
|
258
|
-
} catch (error) {
|
|
259
|
-
Logger.error('Error checking term references:', error);
|
|
260
|
-
return [{
|
|
261
|
-
name: 'Term references check',
|
|
262
|
-
success: false,
|
|
263
|
-
details: `Error: ${error.message}`
|
|
264
|
-
}];
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
module.exports = {
|
|
269
|
-
checkTermReferences
|
|
270
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const Logger = require('../utils/logger');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Check if the terms-and-definitions-intro.md file exists in the spec directory
|
|
7
|
-
* @param {string} projectRoot - Root directory of the project
|
|
8
|
-
* @returns {Promise<Array>} - Array of check results
|
|
9
|
-
*/
|
|
10
|
-
async function checkTermsIntroFile(projectRoot) {
|
|
11
|
-
const results = [];
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
// Path to the project's specs.json
|
|
15
|
-
const specsPath = path.join(projectRoot, 'specs.json');
|
|
16
|
-
|
|
17
|
-
// Check if specs.json exists
|
|
18
|
-
if (!fs.existsSync(specsPath)) {
|
|
19
|
-
return [{
|
|
20
|
-
name: 'Find specs.json file',
|
|
21
|
-
success: false,
|
|
22
|
-
details: 'specs.json file not found in project root'
|
|
23
|
-
}];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
results.push({
|
|
27
|
-
name: 'Find specs.json file',
|
|
28
|
-
success: true,
|
|
29
|
-
details: 'specs.json file found'
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Read specs.json to get the spec directory
|
|
33
|
-
const specsContent = fs.readFileSync(specsPath, 'utf8');
|
|
34
|
-
const specs = JSON.parse(specsContent);
|
|
35
|
-
|
|
36
|
-
// Get the spec_directory value
|
|
37
|
-
const specDir = specs.specs?.[0]?.spec_directory;
|
|
38
|
-
|
|
39
|
-
if (!specDir) {
|
|
40
|
-
results.push({
|
|
41
|
-
name: 'Find spec_directory field',
|
|
42
|
-
success: false,
|
|
43
|
-
details: 'spec_directory field not found in specs.json'
|
|
44
|
-
});
|
|
45
|
-
return results;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
results.push({
|
|
49
|
-
name: 'Find spec_directory field',
|
|
50
|
-
success: true,
|
|
51
|
-
details: `spec_directory field found: "${specDir}"`
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Build the path to the terms-and-definitions-intro.md file
|
|
55
|
-
const specDirPath = path.resolve(projectRoot, specDir);
|
|
56
|
-
const termsIntroPath = path.join(specDirPath, 'terms-and-definitions-intro.md');
|
|
57
|
-
|
|
58
|
-
// Check if the terms-and-definitions-intro.md file exists
|
|
59
|
-
const termsIntroExists = fs.existsSync(termsIntroPath);
|
|
60
|
-
|
|
61
|
-
results.push({
|
|
62
|
-
name: 'Find terms-and-definitions-intro.md file',
|
|
63
|
-
success: termsIntroExists,
|
|
64
|
-
details: termsIntroExists
|
|
65
|
-
? 'terms-and-definitions-intro.md file found in spec directory'
|
|
66
|
-
: `terms-and-definitions-intro.md file not found in ${specDirPath}`
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
return results;
|
|
70
|
-
} catch (error) {
|
|
71
|
-
Logger.error('Error checking terms-and-definitions-intro.md file:', error);
|
|
72
|
-
return [{
|
|
73
|
-
name: 'Terms intro file check',
|
|
74
|
-
success: false,
|
|
75
|
-
details: `Error: ${error.message}`
|
|
76
|
-
}];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
module.exports = {
|
|
81
|
-
checkTermsIntroFile
|
|
82
|
-
};
|