spec-up-t 1.2.6 → 1.2.8
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 +3 -0
- package/assets/js/collapse-definitions.js +2 -1
- package/index.js +11 -1
- package/jest.config.js +20 -0
- package/package.json +3 -2
- package/src/collect-external-references.js +10 -23
- package/src/escape-mechanism.js +57 -0
- package/src/health-check/{output-gitignore-checker.js → destination-gitignore-checker.js} +40 -25
- package/src/health-check/specs-configuration-checker.js +178 -144
- package/src/health-check.js +237 -48
- package/src/utils/README.md +35 -0
- package/src/utils/file-opener.js +89 -0
- package/branches.md +0 -17
- package/src/README.md +0 -98
- package/src/collectExternalReferences/fetchTermsFromIndex.1.js +0 -340
package/src/health-check.js
CHANGED
|
@@ -1,20 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Spec-Up-T Health Check Tool
|
|
5
|
+
*
|
|
6
|
+
* This script performs comprehensive health checks on Spec-Up-T projects,
|
|
7
|
+
* validating configuration, external references, term definitions, and more.
|
|
8
|
+
* Generates an HTML report with detailed results and actionable feedback.
|
|
9
|
+
*
|
|
10
|
+
* @author Spec-Up-T Team
|
|
11
|
+
* @version 1.0.0
|
|
12
|
+
* @since 2025-06-06
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} HealthCheckResult
|
|
17
|
+
* @property {string} name - Name of the specific check
|
|
18
|
+
* @property {boolean|string} success - Success status (true, false, or 'partial')
|
|
19
|
+
* @property {string} [status] - Status override ('warning', 'pass', 'fail')
|
|
20
|
+
* @property {string} [details] - Additional details about the check result
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {Object} HealthCheckSection
|
|
25
|
+
* @property {string} title - Title of the check section
|
|
26
|
+
* @property {HealthCheckResult[]} results - Array of individual check results
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {Object} RepositoryInfo
|
|
31
|
+
* @property {string} host - Git hosting service (e.g., 'github')
|
|
32
|
+
* @property {string} account - Account/organization name
|
|
33
|
+
* @property {string} repo - Repository name
|
|
34
|
+
* @property {string} [branch] - Branch name
|
|
35
|
+
* @property {boolean} [verified] - Whether repository existence was verified
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {Object} StatusDisplay
|
|
40
|
+
* @property {string} statusClass - CSS class for styling
|
|
41
|
+
* @property {string} statusIcon - HTML icon element
|
|
42
|
+
* @property {string} statusText - Display text for status
|
|
43
|
+
*/
|
|
44
|
+
|
|
3
45
|
const fs = require('fs');
|
|
4
46
|
const path = require('path');
|
|
5
|
-
const http = require('http');
|
|
6
47
|
const https = require('https');
|
|
7
|
-
const
|
|
48
|
+
const fileOpener = require('./utils/file-opener');
|
|
8
49
|
|
|
9
50
|
// Import modules from the health-check directory
|
|
10
51
|
const externalSpecsChecker = require('./health-check/external-specs-checker');
|
|
11
52
|
const termReferencesChecker = require('./health-check/term-references-checker');
|
|
12
53
|
const specsConfigurationChecker = require('./health-check/specs-configuration-checker');
|
|
13
54
|
const termsIntroChecker = require('./health-check/terms-intro-checker');
|
|
14
|
-
const
|
|
55
|
+
const destinationGitignoreChecker = require('./health-check/destination-gitignore-checker');
|
|
15
56
|
const trefTermChecker = require('./health-check/tref-term-checker');
|
|
16
57
|
|
|
17
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Directory where health check reports are generated
|
|
60
|
+
* @constant {string}
|
|
61
|
+
*/
|
|
18
62
|
const OUTPUT_DIR = path.join(process.cwd(), '.cache');
|
|
19
63
|
|
|
20
64
|
// Create output directory if it doesn't exist
|
|
@@ -22,8 +66,22 @@ if (!fs.existsSync(OUTPUT_DIR)) {
|
|
|
22
66
|
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
23
67
|
}
|
|
24
68
|
|
|
25
|
-
|
|
26
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves repository information from specs.json file
|
|
71
|
+
*
|
|
72
|
+
* Reads the specs.json file to extract repository configuration including
|
|
73
|
+
* host, account, repo name, and branch. Falls back to default values if
|
|
74
|
+
* the file doesn't exist or is missing required fields.
|
|
75
|
+
*
|
|
76
|
+
* @async
|
|
77
|
+
* @function getRepoInfo
|
|
78
|
+
* @returns {Promise<RepositoryInfo>} Repository information object
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const repoInfo = await getRepoInfo();
|
|
82
|
+
* console.log(repoInfo.account); // 'blockchain-bird'
|
|
83
|
+
*/
|
|
84
|
+
async function getRepoInfo() {
|
|
27
85
|
try {
|
|
28
86
|
// Path to the default boilerplate specs.json
|
|
29
87
|
const defaultSpecsPath = path.join(
|
|
@@ -90,7 +148,7 @@ function getRepoInfo() {
|
|
|
90
148
|
}
|
|
91
149
|
|
|
92
150
|
// If values have changed, verify the repository exists
|
|
93
|
-
const repoExists = checkRepositoryExists(
|
|
151
|
+
const repoExists = await checkRepositoryExists(
|
|
94
152
|
sourceInfo.host,
|
|
95
153
|
sourceInfo.account,
|
|
96
154
|
sourceInfo.repo
|
|
@@ -133,39 +191,67 @@ function getRepoInfo() {
|
|
|
133
191
|
};
|
|
134
192
|
}
|
|
135
193
|
|
|
136
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Checks if a Git repository exists and is accessible
|
|
196
|
+
*
|
|
197
|
+
* Makes an HTTP HEAD request to verify repository existence without
|
|
198
|
+
* downloading the full repository content. Handles timeouts and errors gracefully.
|
|
199
|
+
*
|
|
200
|
+
* @function checkRepositoryExists
|
|
201
|
+
* @param {string} host - Git hosting service (e.g., 'github')
|
|
202
|
+
* @param {string} account - Account or organization name
|
|
203
|
+
* @param {string} repo - Repository name
|
|
204
|
+
* @returns {Promise<boolean>} True if repository exists and is accessible
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* const exists = await checkRepositoryExists('github', 'blockchain-bird', 'spec-up-t');
|
|
208
|
+
* if (exists) {
|
|
209
|
+
* console.log('Repository is accessible');
|
|
210
|
+
* }
|
|
211
|
+
*/
|
|
137
212
|
function checkRepositoryExists(host, account, repo) {
|
|
138
|
-
|
|
139
|
-
// For synchronous checking, we'll use a simple HTTP HEAD request
|
|
213
|
+
return new Promise((resolve) => {
|
|
140
214
|
const url = `https://${host}.com/${account}/${repo}`;
|
|
141
215
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
216
|
+
try {
|
|
217
|
+
const request = https.request(url, { method: 'HEAD', timeout: 10000 }, (response) => {
|
|
218
|
+
// 200, 301, 302 status codes indicate the repo exists
|
|
219
|
+
const exists = [200, 301, 302].includes(response.statusCode);
|
|
220
|
+
resolve(exists);
|
|
221
|
+
});
|
|
146
222
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
return 'xdg-open';
|
|
165
|
-
}
|
|
223
|
+
request.on('error', (error) => {
|
|
224
|
+
console.error('Error checking repository existence:', error.message);
|
|
225
|
+
resolve(false);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
request.on('timeout', () => {
|
|
229
|
+
console.error('Timeout checking repository existence');
|
|
230
|
+
request.destroy();
|
|
231
|
+
resolve(false);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
request.end();
|
|
235
|
+
} catch (error) {
|
|
236
|
+
console.error('Error checking repository existence:', error.message);
|
|
237
|
+
resolve(false);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
166
240
|
}
|
|
167
241
|
|
|
168
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Formats current timestamp for use in filenames
|
|
244
|
+
*
|
|
245
|
+
* Generates a timestamp string that is safe to use in filenames by
|
|
246
|
+
* replacing special characters with hyphens. Format: YYYY-MM-DD-HH-mm-ssZ
|
|
247
|
+
*
|
|
248
|
+
* @function getFormattedTimestamp
|
|
249
|
+
* @returns {string} Formatted timestamp string suitable for filenames
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* const timestamp = getFormattedTimestamp();
|
|
253
|
+
* console.log(timestamp); // "2025-06-06-14-30-25Z"
|
|
254
|
+
*/
|
|
169
255
|
function getFormattedTimestamp() {
|
|
170
256
|
const now = new Date();
|
|
171
257
|
return now.toISOString()
|
|
@@ -174,12 +260,37 @@ function getFormattedTimestamp() {
|
|
|
174
260
|
.replace(/Z/g, 'Z');
|
|
175
261
|
}
|
|
176
262
|
|
|
177
|
-
|
|
263
|
+
/**
|
|
264
|
+
* Generates a human-readable timestamp for display in reports
|
|
265
|
+
*
|
|
266
|
+
* Creates a localized timestamp string for display purposes,
|
|
267
|
+
* using the system's default locale and timezone.
|
|
268
|
+
*
|
|
269
|
+
* @function getHumanReadableTimestamp
|
|
270
|
+
* @returns {string} Human-readable timestamp string
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* const readable = getHumanReadableTimestamp();
|
|
274
|
+
* console.log(readable); // "6/6/2025, 2:30:25 PM"
|
|
275
|
+
*/
|
|
178
276
|
function getHumanReadableTimestamp() {
|
|
179
277
|
return new Date().toLocaleString();
|
|
180
278
|
}
|
|
181
279
|
|
|
182
|
-
|
|
280
|
+
/**
|
|
281
|
+
* Determines status display parameters based on check result
|
|
282
|
+
*
|
|
283
|
+
* Analyzes check results to determine appropriate CSS classes,
|
|
284
|
+
* icons, and text for visual status representation in the HTML report.
|
|
285
|
+
*
|
|
286
|
+
* @function getStatusDisplay
|
|
287
|
+
* @param {HealthCheckResult} result - Check result object
|
|
288
|
+
* @returns {StatusDisplay} Status display configuration
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* const display = getStatusDisplay({ success: true });
|
|
292
|
+
* console.log(display.statusText); // "Pass"
|
|
293
|
+
*/
|
|
183
294
|
function getStatusDisplay(result) {
|
|
184
295
|
if (result.status === 'warning' || result.success === 'partial') {
|
|
185
296
|
// Warning status
|
|
@@ -205,7 +316,34 @@ function getStatusDisplay(result) {
|
|
|
205
316
|
}
|
|
206
317
|
}
|
|
207
318
|
|
|
208
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Main function to run all health checks and generate the report
|
|
321
|
+
*
|
|
322
|
+
* Orchestrates the execution of all available health check modules,
|
|
323
|
+
* collects results, and generates a comprehensive HTML report.
|
|
324
|
+
* Handles errors gracefully and ensures proper cleanup.
|
|
325
|
+
*
|
|
326
|
+
* @async
|
|
327
|
+
* @function runHealthCheck
|
|
328
|
+
* @throws {Error} When health check execution fails
|
|
329
|
+
*
|
|
330
|
+
* @description
|
|
331
|
+
* The function performs the following checks:
|
|
332
|
+
* - Term reference checks in external specs
|
|
333
|
+
* - External specs URL validation
|
|
334
|
+
* - Term references validation
|
|
335
|
+
* - specs.json configuration validation
|
|
336
|
+
* - Terms introduction file validation
|
|
337
|
+
* - .gitignore destination directory check
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* try {
|
|
341
|
+
* await runHealthCheck();
|
|
342
|
+
* console.log('Health check completed successfully');
|
|
343
|
+
* } catch (error) {
|
|
344
|
+
* console.error('Health check failed:', error);
|
|
345
|
+
* }
|
|
346
|
+
*/
|
|
209
347
|
async function runHealthCheck() {
|
|
210
348
|
console.log('Running health checks...');
|
|
211
349
|
|
|
@@ -249,28 +387,48 @@ async function runHealthCheck() {
|
|
|
249
387
|
results: termsIntroResults
|
|
250
388
|
});
|
|
251
389
|
|
|
252
|
-
// Run
|
|
253
|
-
const
|
|
390
|
+
// Run destination directory gitignore check
|
|
391
|
+
const destinationGitignoreResults = await destinationGitignoreChecker.checkDestinationGitIgnore(process.cwd());
|
|
254
392
|
results.push({
|
|
255
393
|
title: 'Check <code>.gitignore</code>',
|
|
256
|
-
results:
|
|
394
|
+
results: destinationGitignoreResults
|
|
257
395
|
});
|
|
258
396
|
|
|
259
397
|
// Add more checks here in the future
|
|
260
398
|
|
|
261
399
|
// Generate and open the report
|
|
262
|
-
generateReport(results);
|
|
400
|
+
await generateReport(results);
|
|
263
401
|
} catch (error) {
|
|
264
402
|
console.error('Error running health checks:', error);
|
|
265
403
|
process.exit(1);
|
|
266
404
|
}
|
|
267
405
|
}
|
|
268
406
|
|
|
269
|
-
|
|
270
|
-
|
|
407
|
+
/**
|
|
408
|
+
* Generates and opens an HTML health check report
|
|
409
|
+
*
|
|
410
|
+
* Creates a comprehensive HTML report with all health check results,
|
|
411
|
+
* saves it to the cache directory, and opens it in the default browser.
|
|
412
|
+
* The report includes interactive features like filtering and status indicators.
|
|
413
|
+
*
|
|
414
|
+
* @async
|
|
415
|
+
* @function generateReport
|
|
416
|
+
* @param {HealthCheckSection[]} checkResults - Array of health check result objects
|
|
417
|
+
* @throws {Error} When report generation or file operations fail
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* const results = [
|
|
421
|
+
* {
|
|
422
|
+
* title: 'Configuration Check',
|
|
423
|
+
* results: [{ name: 'specs.json', success: true, details: 'Valid' }]
|
|
424
|
+
* }
|
|
425
|
+
* ];
|
|
426
|
+
* await generateReport(results);
|
|
427
|
+
*/
|
|
428
|
+
async function generateReport(checkResults) {
|
|
271
429
|
const timestamp = getFormattedTimestamp();
|
|
272
430
|
// Get repository information from specs.json
|
|
273
|
-
const repoInfo = getRepoInfo();
|
|
431
|
+
const repoInfo = await getRepoInfo();
|
|
274
432
|
const reportFileName = `health-check-${timestamp}-${repoInfo.account}-${repoInfo.repo}.html`;
|
|
275
433
|
const reportPath = path.join(OUTPUT_DIR, reportFileName);
|
|
276
434
|
|
|
@@ -282,14 +440,35 @@ function generateReport(checkResults) {
|
|
|
282
440
|
|
|
283
441
|
// Open the report in the default browser
|
|
284
442
|
try {
|
|
285
|
-
const
|
|
286
|
-
|
|
443
|
+
const success = fileOpener.openHtmlFile(reportPath);
|
|
444
|
+
if (!success) {
|
|
445
|
+
console.error('Failed to open the report in browser');
|
|
446
|
+
}
|
|
287
447
|
} catch (error) {
|
|
288
448
|
console.error('Failed to open the report:', error);
|
|
289
449
|
}
|
|
290
450
|
}
|
|
291
451
|
|
|
292
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Generates HTML content for the health check report
|
|
454
|
+
*
|
|
455
|
+
* Creates a complete HTML document with Bootstrap styling, interactive features,
|
|
456
|
+
* and comprehensive health check results. Includes repository verification,
|
|
457
|
+
* status filtering, and detailed result tables.
|
|
458
|
+
*
|
|
459
|
+
* @function generateHtmlReport
|
|
460
|
+
* @param {HealthCheckSection[]} checkResults - Array of health check result sections
|
|
461
|
+
* @param {string} timestamp - Human-readable timestamp for the report
|
|
462
|
+
* @param {RepositoryInfo} repoInfo - Repository information object
|
|
463
|
+
* @returns {string} Complete HTML document as string
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* const html = generateHtmlReport(results, '6/6/2025, 2:30:25 PM', {
|
|
467
|
+
* host: 'github',
|
|
468
|
+
* account: 'blockchain-bird',
|
|
469
|
+
* repo: 'spec-up-t'
|
|
470
|
+
* });
|
|
471
|
+
*/
|
|
293
472
|
function generateHtmlReport(checkResults, timestamp, repoInfo) {
|
|
294
473
|
let resultsHtml = '';
|
|
295
474
|
|
|
@@ -457,5 +636,15 @@ function generateHtmlReport(checkResults, timestamp, repoInfo) {
|
|
|
457
636
|
`;
|
|
458
637
|
}
|
|
459
638
|
|
|
460
|
-
|
|
639
|
+
/**
|
|
640
|
+
* Script execution entry point
|
|
641
|
+
*
|
|
642
|
+
* Immediately executes the health check when this script is run directly.
|
|
643
|
+
* This allows the script to be used as a standalone command-line tool.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* // Run from command line:
|
|
647
|
+
* // node src/health-check.js
|
|
648
|
+
* // npm run healthCheck
|
|
649
|
+
*/
|
|
461
650
|
runHealthCheck();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Utils Module
|
|
2
|
+
|
|
3
|
+
This directory contains utility modules that provide cross-platform functionality for the Spec-Up-T health check system.
|
|
4
|
+
|
|
5
|
+
## file-opener.js
|
|
6
|
+
|
|
7
|
+
Provides secure, cross-platform file opening functionality with proper command path resolution.
|
|
8
|
+
|
|
9
|
+
### Features:
|
|
10
|
+
- **Cross-platform support**: Handles Windows (`start`), macOS (`open`), and Linux (`xdg-open`)
|
|
11
|
+
- **Secure path resolution**: Uses absolute command paths instead of relying on PATH environment variable
|
|
12
|
+
- **Error handling**: Graceful fallback when commands cannot be located
|
|
13
|
+
|
|
14
|
+
### Functions:
|
|
15
|
+
- `getCommandPath(command)` - Resolves absolute path for a given command
|
|
16
|
+
- `getOpenCommand()` - Returns the platform-specific file opening command path
|
|
17
|
+
- `openFile(filePath)` - Opens any file in its default application
|
|
18
|
+
- `openHtmlFile(htmlFilePath)` - Specifically opens HTML files in the default browser
|
|
19
|
+
|
|
20
|
+
### Security:
|
|
21
|
+
This module was created to address SonarQube security issues by:
|
|
22
|
+
1. Eliminating shell injection vulnerabilities through proper argument separation
|
|
23
|
+
2. Avoiding PATH hijacking by using absolute command paths
|
|
24
|
+
3. Providing controlled, sanitized command execution
|
|
25
|
+
|
|
26
|
+
### Usage:
|
|
27
|
+
```javascript
|
|
28
|
+
const fileOpener = require('./utils/file-opener');
|
|
29
|
+
|
|
30
|
+
// Open an HTML report
|
|
31
|
+
const success = fileOpener.openHtmlFile('/path/to/report.html');
|
|
32
|
+
|
|
33
|
+
// Get absolute path for a command
|
|
34
|
+
const gitPath = fileOpener.getCommandPath('git');
|
|
35
|
+
```
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const { spawnSync } = require('child_process');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to get the absolute path of a command
|
|
6
|
+
* @param {string} command - The command to find
|
|
7
|
+
* @returns {string} - The absolute path to the command or the command name as fallback
|
|
8
|
+
*/
|
|
9
|
+
function getCommandPath(command) {
|
|
10
|
+
// Define common system paths where commands are typically located
|
|
11
|
+
const commonPaths = [
|
|
12
|
+
`/usr/bin/${command}`,
|
|
13
|
+
`/bin/${command}`,
|
|
14
|
+
`/usr/local/bin/${command}`,
|
|
15
|
+
`/opt/homebrew/bin/${command}`, // For Homebrew on Apple Silicon Macs
|
|
16
|
+
`/opt/local/bin/${command}`, // For MacPorts
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// For Windows, add common Windows paths
|
|
20
|
+
if (process.platform === 'win32') {
|
|
21
|
+
commonPaths.unshift(
|
|
22
|
+
`C:\\Windows\\System32\\${command}.exe`,
|
|
23
|
+
`C:\\Windows\\${command}.exe`,
|
|
24
|
+
`C:\\Program Files\\Git\\bin\\${command}.exe`, // Git for Windows
|
|
25
|
+
`C:\\Program Files (x86)\\Git\\bin\\${command}.exe`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check each path to see if the command exists
|
|
30
|
+
for (const cmdPath of commonPaths) {
|
|
31
|
+
if (fs.existsSync(cmdPath)) {
|
|
32
|
+
return cmdPath;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// If we can't find the absolute path, return the command name as fallback
|
|
37
|
+
// This maintains functionality while logging the issue
|
|
38
|
+
console.warn(`Warning: Could not find absolute path for command '${command}', using relative path as fallback`);
|
|
39
|
+
return command;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get the appropriate file open command based on platform
|
|
44
|
+
* @returns {string} - The absolute path to the platform-specific open command
|
|
45
|
+
*/
|
|
46
|
+
function getOpenCommand() {
|
|
47
|
+
let command;
|
|
48
|
+
if (process.platform === 'win32') {
|
|
49
|
+
command = 'start';
|
|
50
|
+
} else if (process.platform === 'darwin') {
|
|
51
|
+
command = 'open';
|
|
52
|
+
} else {
|
|
53
|
+
command = 'xdg-open';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return getCommandPath(command);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Open a file in the default application for the current platform
|
|
61
|
+
* @param {string} filePath - The path to the file to open
|
|
62
|
+
* @returns {boolean} - True if the file was opened successfully, false otherwise
|
|
63
|
+
*/
|
|
64
|
+
function openFile(filePath) {
|
|
65
|
+
try {
|
|
66
|
+
const openCommand = getOpenCommand();
|
|
67
|
+
const result = spawnSync(openCommand, [filePath], { stdio: 'ignore' });
|
|
68
|
+
return result.status === 0;
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Failed to open file:', error);
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Open an HTML file in the default web browser
|
|
77
|
+
* @param {string} htmlFilePath - The path to the HTML file to open
|
|
78
|
+
* @returns {boolean} - True if the file was opened successfully, false otherwise
|
|
79
|
+
*/
|
|
80
|
+
function openHtmlFile(htmlFilePath) {
|
|
81
|
+
return openFile(htmlFilePath);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
module.exports = {
|
|
85
|
+
getCommandPath,
|
|
86
|
+
getOpenCommand,
|
|
87
|
+
openFile,
|
|
88
|
+
openHtmlFile
|
|
89
|
+
};
|
package/branches.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Beschrijving van de branches
|
|
2
|
-
|
|
3
|
-
## improve/compact-terms
|
|
4
|
-
|
|
5
|
-
Maak de termen weergave meer compact
|
|
6
|
-
Filters
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## various
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## test/xtrefnew
|
|
13
|
-
|
|
14
|
-
Lokaal Bewaren
|
|
15
|
-
Lijkt goed te werken.
|
|
16
|
-
Met AI gebouwde oplossing waarbij ik probeer iets aan de API limieten te doen. Ik heb twee belangrijke bestanden weggedaan en AI ze opnieuw laten bouwen op basis van een prompt en de bestanden die ik had. Het lijkt te werken, maar ik heb geen idee of het goed is. Het is een beetje een experiment.
|
|
17
|
-
|
package/src/README.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<h1>Spec-Up-T External References Collection Workflow</h1>
|
|
2
|
-
<p>This codebase implements a system for collecting and processing cross-specification references from markdown files. Here's a workflow diagram of what happens when <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#37%2C10" data-keybinding-context="1187"><span class="icon-label">collectExternalReferences()</span></a> is called:</p>
|
|
3
|
-
<h2>Workflow Overview</h2>
|
|
4
|
-
<ol>
|
|
5
|
-
<li>
|
|
6
|
-
<p><strong>Initialization & Configuration</strong></p>
|
|
7
|
-
<ul>
|
|
8
|
-
<li>Loads environment variables using dotenv</li>
|
|
9
|
-
<li>Reads <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#42%2C39" data-keybinding-context="1188"><span class="icon-label">specs.json</span></a> configuration file</li>
|
|
10
|
-
<li>Obtains GitHub Personal Access Token (PAT) from options or environment variables</li>
|
|
11
|
-
</ul>
|
|
12
|
-
</li>
|
|
13
|
-
<li>
|
|
14
|
-
<p><strong>Validation Checks</strong></p>
|
|
15
|
-
<ul>
|
|
16
|
-
<li>Verifies GitHub PAT is available, stops with instructions if missing</li>
|
|
17
|
-
<li>Confirms external repositories are configured in specs.json</li>
|
|
18
|
-
<li>Validates repository URLs using <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/utils/doesUrlExist.js#8%2C16" data-keybinding-context="1189"><span class="icon-label">doesUrlExist.js</span></a></li>
|
|
19
|
-
</ul>
|
|
20
|
-
</li>
|
|
21
|
-
<li>
|
|
22
|
-
<p><strong>Content Collection</strong></p>
|
|
23
|
-
<ul>
|
|
24
|
-
<li>Creates necessary output directories</li>
|
|
25
|
-
<li>Reads all markdown files from specified term directories</li>
|
|
26
|
-
<li>Concatenates content into a single string for processing</li>
|
|
27
|
-
</ul>
|
|
28
|
-
</li>
|
|
29
|
-
<li>
|
|
30
|
-
<p><strong>Cross-Reference Extraction</strong></p>
|
|
31
|
-
<ul>
|
|
32
|
-
<li>Uses regex to find <code>[[xref:...]]</code> and <code>[[tref:...]]</code> patterns in markdown</li>
|
|
33
|
-
<li>Processes these patterns into structured objects with <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#158%2C58" data-keybinding-context="1190"><span class="icon-label">externalSpec</span></a> and <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#186%2C64" data-keybinding-context="1191"><span class="icon-label">term</span></a> properties</li>
|
|
34
|
-
<li>Filters out duplicates and keeps only references found in current markdown content</li>
|
|
35
|
-
</ul>
|
|
36
|
-
</li>
|
|
37
|
-
<li>
|
|
38
|
-
<p><strong>Metadata Enhancement</strong></p>
|
|
39
|
-
<ul>
|
|
40
|
-
<li>Extends each reference with additional repository information:
|
|
41
|
-
<ul>
|
|
42
|
-
<li>Repository URL</li>
|
|
43
|
-
<li>Owner/repo names</li>
|
|
44
|
-
<li>Terms directory path</li>
|
|
45
|
-
<li>Avatar URL</li>
|
|
46
|
-
</ul>
|
|
47
|
-
</li>
|
|
48
|
-
</ul>
|
|
49
|
-
</li>
|
|
50
|
-
<li>
|
|
51
|
-
<p><strong>GitHub API Interaction</strong></p>
|
|
52
|
-
<ul>
|
|
53
|
-
<li>For each reference, calls <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collectExternalReferences/fetchTermsFromGitHubRepository.js#16%2C16" data-keybinding-context="1192"><span class="icon-label">fetchTermsFromGitHubRepository</span></a> which:
|
|
54
|
-
<ul>
|
|
55
|
-
<li>Uses Octokit to interface with GitHub API</li>
|
|
56
|
-
<li>Implements caching to minimize API requests</li>
|
|
57
|
-
<li>Handles rate limiting with throttling and retries</li>
|
|
58
|
-
<li>Searches for terms within specified repositories/directories</li>
|
|
59
|
-
</ul>
|
|
60
|
-
</li>
|
|
61
|
-
</ul>
|
|
62
|
-
</li>
|
|
63
|
-
<li>
|
|
64
|
-
<p><strong>Term Content Processing</strong></p>
|
|
65
|
-
<ul>
|
|
66
|
-
<li>When terms are found, retrieves:
|
|
67
|
-
<ul>
|
|
68
|
-
<li>File content</li>
|
|
69
|
-
<li>Latest commit hash</li>
|
|
70
|
-
<li>Repository metadata</li>
|
|
71
|
-
</ul>
|
|
72
|
-
</li>
|
|
73
|
-
<li>Uses <a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collectExternalReferences/matchTerm.js#3%2C10" data-keybinding-context="1193"><span class="icon-label">matchTerm.js</span></a> to validate the term within content</li>
|
|
74
|
-
</ul>
|
|
75
|
-
</li>
|
|
76
|
-
<li>
|
|
77
|
-
<p><strong>Output Generation</strong></p>
|
|
78
|
-
<ul>
|
|
79
|
-
<li>Creates three output files:
|
|
80
|
-
<ul>
|
|
81
|
-
<li><code>.cache/xtrefs-data.json</code> - JSON data file</li>
|
|
82
|
-
<li><code>.cache/xtrefs-data.js</code> - JavaScript module file</li>
|
|
83
|
-
<li><code>.cache/xtrefs-history/xtrefs-data-[timestamp].js</code> - Historical record</li>
|
|
84
|
-
</ul>
|
|
85
|
-
</li>
|
|
86
|
-
</ul>
|
|
87
|
-
</li>
|
|
88
|
-
</ol>
|
|
89
|
-
<h2>Key Functions</h2>
|
|
90
|
-
<ul>
|
|
91
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#37%2C10" data-keybinding-context="1194"><span class="icon-label">collectExternalReferences()</span></a>: Main orchestration function</li>
|
|
92
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#143%2C18" data-keybinding-context="1195"><span class="icon-label">extendXTrefs()</span></a>: Adds repository metadata to references</li>
|
|
93
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#192%2C18" data-keybinding-context="1196"><span class="icon-label">processXTref()</span></a>: Parses reference syntax into structured objects</li>
|
|
94
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collect-external-references.js#184%2C18" data-keybinding-context="1197"><span class="icon-label">isXTrefInMarkdown()</span></a>: Validates references against current content</li>
|
|
95
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collectExternalReferences/fetchTermsFromGitHubRepository.js#16%2C16" data-keybinding-context="1198"><span class="icon-label">fetchTermsFromGitHubRepository()</span></a>: Interacts with GitHub API to find terms</li>
|
|
96
|
-
<li><a class="chat-inline-anchor-widget show-file-icons" title="" draggable="true" href="vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" data-href="file:///Users/kor/webdev/Blockchain-Bird/KERI/Spec-Up/active-bcb/spec-up-t/spec-up-t/src/collectExternalReferences/processXTrefsData.js#9%2C16" data-keybinding-context="1199"><span class="icon-label">processXTrefsData()</span></a>: Processes the data and generates output files</li>
|
|
97
|
-
</ul>
|
|
98
|
-
<p>This system enables cross-specification linking by fetching and maintaining references to terms defined in external GitHub repositories, ensuring that documentation can link to canonical definitions maintained elsewhere.</p>
|