spec-up-t 1.2.3 → 1.2.5
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/.sonarlint/connectedMode.json +5 -0
- package/assets/compiled/body.js +35 -32
- package/assets/compiled/head.css +7 -5
- package/assets/compiled/head.js +3 -3
- package/assets/css/add-bootstrap-classes-to-images.css +34 -0
- package/assets/css/adjust-font-size.css +6 -11
- package/assets/css/backToTop.css +0 -1
- package/assets/css/image-full-size.css +44 -0
- package/assets/css/index.css +1 -2
- package/assets/css/pdf-styles.css +23 -27
- package/assets/css/repo-issues.css +0 -6
- package/assets/css/search.css +0 -1
- package/assets/css/sidebar-toc.css +13 -12
- package/assets/css/terms-and-definitions.css +43 -37
- package/assets/js/add-bootstrap-classes-to-images.js +98 -0
- package/assets/js/add-href-to-snapshot-link.js +2 -1
- package/assets/js/addAnchorsToTerms.js +0 -1
- package/assets/js/adjust-font-size.js +0 -9
- package/assets/js/create-alphabet-index.js +12 -3
- package/assets/js/create-term-filter.js +12 -0
- package/assets/js/custom-elements.js +13 -18
- package/assets/js/declare-markdown-it.js +1 -1
- package/assets/js/hide-show-utility-container.js +17 -0
- package/assets/js/highlightMenuItems.js +3 -3
- package/assets/js/image-full-size.js +76 -0
- package/assets/js/index.js +1 -5
- package/assets/js/insert-trefs.js +2 -2
- package/assets/js/modal.js +3 -3
- package/assets/js/search.js +15 -3
- package/assets/js/utils.js +2 -3
- package/index.js +7 -17
- package/package.json +2 -2
- package/src/README.md +3 -3
- package/src/add-remove-xref-source.js +0 -2
- package/src/asset-map.json +5 -0
- package/src/collect-external-references.js +187 -179
- package/src/collectExternalReferences/fetchTermsFromIndex.js +2 -1
- package/src/config/paths.js +2 -2
- package/src/create-external-specs-list.js +1 -1
- package/src/create-term-index.js +126 -22
- package/src/fix-markdown-files.js +152 -90
- package/src/health-check/external-specs-checker.js +173 -94
- package/src/health-check/output-gitignore-checker.js +327 -191
- package/src/health-check/specs-configuration-checker.js +288 -210
- package/src/health-check/term-references-checker.js +200 -123
- package/src/health-check/tref-term-checker.js +264 -179
- package/src/health-check.js +52 -36
- package/src/init.js +1 -4
- package/src/insert-term-index.js +5 -5
- package/src/install-from-boilerplate/add-scripts-keys.js +3 -1
- package/src/install-from-boilerplate/boilerplate/gitignore +2 -1
- package/src/install-from-boilerplate/config-system-files.js +9 -1
- package/src/install-from-boilerplate/copy-system-files.js +1 -1
- package/src/markdown-it-extensions.js +199 -106
- package/src/references.js +1 -2
- package/src/utils/doesUrlExist.js +7 -5
- package/src/utils/fetch.js +14 -14
- package/templates/template.html +1 -2
- package/assets/js/insert-xrefs.js +0 -370
- package/src/create-term-relations.js +0 -131
- package/src/prepare-tref.js +0 -174
package/src/health-check.js
CHANGED
|
@@ -15,7 +15,7 @@ const outputGitignoreChecker = require('./health-check/output-gitignore-checker'
|
|
|
15
15
|
const trefTermChecker = require('./health-check/tref-term-checker');
|
|
16
16
|
|
|
17
17
|
// Configuration
|
|
18
|
-
const OUTPUT_DIR = path.join(process.cwd(), '
|
|
18
|
+
const OUTPUT_DIR = path.join(process.cwd(), '.cache');
|
|
19
19
|
|
|
20
20
|
// Create output directory if it doesn't exist
|
|
21
21
|
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
@@ -60,18 +60,15 @@ function getRepoInfo() {
|
|
|
60
60
|
|
|
61
61
|
// Look for specs.json in the current working directory (where the command is run from)
|
|
62
62
|
const specsPath = path.join(process.cwd(), 'specs.json');
|
|
63
|
-
// console.log(`Looking for specs.json at: ${specsPath}`);
|
|
64
63
|
|
|
65
64
|
if (fs.existsSync(specsPath)) {
|
|
66
|
-
// console.log('specs.json found!');
|
|
67
65
|
const specsContent = fs.readFileSync(specsPath, 'utf8');
|
|
68
66
|
const specs = JSON.parse(specsContent);
|
|
69
67
|
|
|
70
68
|
// Check if source field exists and has required properties
|
|
71
|
-
if (specs?.specs?.[0]?.source &&
|
|
72
|
-
specs
|
|
73
|
-
specs
|
|
74
|
-
specs.specs[0].source.repo) {
|
|
69
|
+
if (specs?.specs?.[0]?.source?.host &&
|
|
70
|
+
specs?.specs?.[0]?.source?.account &&
|
|
71
|
+
specs?.specs?.[0]?.source?.repo) {
|
|
75
72
|
|
|
76
73
|
const sourceInfo = specs.specs[0].source;
|
|
77
74
|
|
|
@@ -128,7 +125,6 @@ function getRepoInfo() {
|
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
// Return default values if specs.json doesn't exist or doesn't contain the required information
|
|
131
|
-
// console.log('Using default repository values');
|
|
132
128
|
return {
|
|
133
129
|
host: 'github',
|
|
134
130
|
account: 'blockchain-bird',
|
|
@@ -158,13 +154,24 @@ function checkRepositoryExists(host, account, repo) {
|
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
156
|
|
|
157
|
+
// Helper function to get the appropriate file open command based on platform
|
|
158
|
+
function getOpenCommand() {
|
|
159
|
+
if (process.platform === 'win32') {
|
|
160
|
+
return 'start';
|
|
161
|
+
} else if (process.platform === 'darwin') {
|
|
162
|
+
return 'open';
|
|
163
|
+
} else {
|
|
164
|
+
return 'xdg-open';
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
161
168
|
// Helper function to format current time for the filename
|
|
162
169
|
function getFormattedTimestamp() {
|
|
163
170
|
const now = new Date();
|
|
164
171
|
return now.toISOString()
|
|
165
172
|
.replace(/[T:]/g, '-')
|
|
166
173
|
.replace(/\..+/, '')
|
|
167
|
-
.replace(/
|
|
174
|
+
.replace(/Z/g, 'Z');
|
|
168
175
|
}
|
|
169
176
|
|
|
170
177
|
// Helper function to generate a human-readable timestamp for display
|
|
@@ -172,6 +179,32 @@ function getHumanReadableTimestamp() {
|
|
|
172
179
|
return new Date().toLocaleString();
|
|
173
180
|
}
|
|
174
181
|
|
|
182
|
+
// Helper function to determine status display parameters based on result
|
|
183
|
+
function getStatusDisplay(result) {
|
|
184
|
+
if (result.status === 'warning' || result.success === 'partial') {
|
|
185
|
+
// Warning status
|
|
186
|
+
return {
|
|
187
|
+
statusClass: 'text-warning',
|
|
188
|
+
statusIcon: '<i class="bi bi-exclamation-triangle-fill"></i>',
|
|
189
|
+
statusText: 'Warning'
|
|
190
|
+
};
|
|
191
|
+
} else if (result.success) {
|
|
192
|
+
// Pass status
|
|
193
|
+
return {
|
|
194
|
+
statusClass: 'text-success',
|
|
195
|
+
statusIcon: '<i class="bi bi-check-circle-fill"></i>',
|
|
196
|
+
statusText: 'Pass'
|
|
197
|
+
};
|
|
198
|
+
} else {
|
|
199
|
+
// Fail status
|
|
200
|
+
return {
|
|
201
|
+
statusClass: 'text-danger',
|
|
202
|
+
statusIcon: '<i class="bi bi-x-circle-fill"></i>',
|
|
203
|
+
statusText: 'Fail'
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
175
208
|
// Main function to run all checks and generate the report
|
|
176
209
|
async function runHealthCheck() {
|
|
177
210
|
console.log('Running health checks...');
|
|
@@ -249,8 +282,7 @@ function generateReport(checkResults) {
|
|
|
249
282
|
|
|
250
283
|
// Open the report in the default browser
|
|
251
284
|
try {
|
|
252
|
-
const openCommand =
|
|
253
|
-
process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
285
|
+
const openCommand = getOpenCommand();
|
|
254
286
|
execSync(`${openCommand} "${reportPath}"`);
|
|
255
287
|
} catch (error) {
|
|
256
288
|
console.error('Failed to open the report:', error);
|
|
@@ -263,6 +295,12 @@ function generateHtmlReport(checkResults, timestamp, repoInfo) {
|
|
|
263
295
|
|
|
264
296
|
// Add repository verification check at the beginning if needed
|
|
265
297
|
if (repoInfo && repoInfo.verified === false) {
|
|
298
|
+
const failStatus = {
|
|
299
|
+
statusClass: 'text-danger',
|
|
300
|
+
statusIcon: '<i class="bi bi-x-circle-fill"></i>',
|
|
301
|
+
statusText: 'Fail'
|
|
302
|
+
};
|
|
303
|
+
|
|
266
304
|
// Create a new section at the top for repository verification
|
|
267
305
|
resultsHtml += `
|
|
268
306
|
<div class="card mb-4 results-card alert-danger" data-section="repository-verification">
|
|
@@ -280,8 +318,8 @@ function generateHtmlReport(checkResults, timestamp, repoInfo) {
|
|
|
280
318
|
</thead>
|
|
281
319
|
<tbody>
|
|
282
320
|
<tr data-status="fail" class="check-row">
|
|
283
|
-
<td class="
|
|
284
|
-
|
|
321
|
+
<td class="${failStatus.statusClass}" style="white-space: nowrap;">
|
|
322
|
+
${failStatus.statusIcon} <span style="vertical-align: middle;">${failStatus.statusText}</span>
|
|
285
323
|
</td>
|
|
286
324
|
<td>Repository existence check</td>
|
|
287
325
|
<td>The repository at https://${repoInfo.host}.com/${repoInfo.account}/${repoInfo.repo} does not exist or is not accessible. Please verify the repository information in specs.json.</td>
|
|
@@ -312,29 +350,7 @@ function generateHtmlReport(checkResults, timestamp, repoInfo) {
|
|
|
312
350
|
`;
|
|
313
351
|
|
|
314
352
|
section.results.forEach(result => {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (result.status === 'warning') {
|
|
318
|
-
// Warning status
|
|
319
|
-
statusClass = 'text-warning';
|
|
320
|
-
statusIcon = '<i class="bi bi-exclamation-triangle-fill"></i>';
|
|
321
|
-
statusText = 'Warning';
|
|
322
|
-
} else if (result.success === 'partial') {
|
|
323
|
-
// Partial success (warning) status
|
|
324
|
-
statusClass = 'text-warning';
|
|
325
|
-
statusIcon = '<i class="bi bi-exclamation-triangle-fill"></i>';
|
|
326
|
-
statusText = 'Warning';
|
|
327
|
-
} else if (result.success) {
|
|
328
|
-
// Pass status
|
|
329
|
-
statusClass = 'text-success';
|
|
330
|
-
statusIcon = '<i class="bi bi-check-circle-fill"></i>';
|
|
331
|
-
statusText = 'Pass';
|
|
332
|
-
} else {
|
|
333
|
-
// Fail status
|
|
334
|
-
statusClass = 'text-danger';
|
|
335
|
-
statusIcon = '<i class="bi bi-x-circle-fill"></i>';
|
|
336
|
-
statusText = 'Fail';
|
|
337
|
-
}
|
|
353
|
+
const { statusClass, statusIcon, statusText } = getStatusDisplay(result);
|
|
338
354
|
|
|
339
355
|
// Add data-status attribute to identify rows by status and reorder columns to put status first
|
|
340
356
|
resultsHtml += `
|
package/src/init.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const outputDir = path.join(process.cwd(), '
|
|
3
|
+
const outputDir = path.join(process.cwd(), '.cache');
|
|
4
4
|
const initFlagPath = path.join(outputDir, 'init.flag');
|
|
5
|
-
const collectExternalReferences = require('./collect-external-references.js').collectExternalReferences;
|
|
6
5
|
|
|
7
6
|
async function initialize() {
|
|
8
7
|
try {
|
|
@@ -13,8 +12,6 @@ async function initialize() {
|
|
|
13
12
|
|
|
14
13
|
// Place the init script here
|
|
15
14
|
|
|
16
|
-
// prepareTref(path.join(config.specs[0].spec_directory, config.specs[0].spec_terms_directory));
|
|
17
|
-
|
|
18
15
|
// End of the init script
|
|
19
16
|
|
|
20
17
|
// Create the init flag file
|
package/src/insert-term-index.js
CHANGED
|
@@ -19,8 +19,8 @@ function insertTermIndex() {
|
|
|
19
19
|
const fs = require('fs-extra');
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const config = fs.readJsonSync(path.join('specs.json'));
|
|
22
|
-
const terms = fs.readJsonSync(path.join('
|
|
23
|
-
const outputPathJSON = path.join('
|
|
22
|
+
const terms = fs.readJsonSync(path.join('.cache', 'term-index.json'));
|
|
23
|
+
const outputPathJSON = path.join('.cache', 'specs-generated.json');
|
|
24
24
|
let specGenerated = config;
|
|
25
25
|
let markdownPaths = specGenerated.specs[0].markdown_paths;
|
|
26
26
|
|
|
@@ -36,9 +36,9 @@ function insertTermIndex() {
|
|
|
36
36
|
// Save the updated specGenerated object back to the JSON file
|
|
37
37
|
fs.writeJsonSync(outputPathJSON, specGenerated, { spaces: 2 });
|
|
38
38
|
|
|
39
|
-
// Create directory named
|
|
40
|
-
if (!fs.existsSync('
|
|
41
|
-
fs.mkdirSync('
|
|
39
|
+
// Create directory named “.cache” in the project root if it does not yet exist
|
|
40
|
+
if (!fs.existsSync('.cache')) {
|
|
41
|
+
fs.mkdirSync('.cache');
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
fs.writeJsonSync(outputPathJSON, specGenerated, { spaces: 2 });
|
|
@@ -8,7 +8,9 @@ const path = require('path');
|
|
|
8
8
|
* @param {Object} [overwriteKeys={}] - An object specifying which scripts to overwrite if they already exist.
|
|
9
9
|
*/
|
|
10
10
|
function addScriptsKeys(scriptKeys, overwriteKeys = {}) {
|
|
11
|
-
|
|
11
|
+
// Use process.cwd() to get the current working directory where the command is run
|
|
12
|
+
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
// Read the package.json file
|
|
14
16
|
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
const systemFiles = [
|
|
1
|
+
const systemFiles = [
|
|
2
|
+
'README.md',
|
|
3
|
+
'.env.example',
|
|
4
|
+
'.github/workflows/menu.yml',
|
|
5
|
+
'.github/workflows/render-specs.yml',
|
|
6
|
+
'.github/workflows/set-gh-pages.yml',
|
|
7
|
+
'assets/test.json',
|
|
8
|
+
'assets/test.text',
|
|
9
|
+
];
|
|
2
10
|
|
|
3
11
|
module.exports = { systemFiles };
|
|
@@ -20,7 +20,7 @@ function copySystemFiles() {
|
|
|
20
20
|
fs.cpSync(srcPath, destPath, { recursive: true });
|
|
21
21
|
console.log(`✅ Copied ${item} to ${destPath}`);
|
|
22
22
|
} catch (error) {
|
|
23
|
-
console.error(`❌ Failed to copy ${item} to ${destPath}
|
|
23
|
+
console.error(`❌ Failed to copy ${item} to ${destPath}:`, error);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|