spec-up-t 1.1.11 → 1.1.13
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/assets/js/show-commit-hashes.js +4 -4
- package/index.js +2 -2
- package/package.json +1 -1
- package/src/add-remove-xref-source.js +1 -1
- package/src/collect-external-references.js +15 -14
- package/src/collectExternalReferences/checkRateLimit.js +3 -3
- package/src/collectExternalReferences/processXTrefsData.js +2 -2
- package/src/collectExternalReferences/setupFetchHeaders.js +1 -1
- package/src/create-pdf.js +2 -2
- package/src/create-term-index.js +1 -1
- package/src/create-versions-index.js +2 -2
- package/src/fix-markdown-files.js +2 -2
- package/src/freeze.js +1 -1
- package/src/install-from-boilerplate/menu.sh +1 -1
- package/src/json-key-validator.js +3 -3
- package/src/prepare-tref.js +2 -2
- package/src/references.js +3 -3
|
@@ -100,13 +100,13 @@ function fetchCommitHashes() {
|
|
|
100
100
|
.then(response => {
|
|
101
101
|
if (response.status === 403 && response.headers.get('X-RateLimit-Remaining') === '0') {
|
|
102
102
|
const resetTime = new Date(response.headers.get('X-RateLimit-Reset') * 1000);
|
|
103
|
-
console.error(
|
|
103
|
+
console.error(`❌ Github API rate limit exceeded. Try again after ${resetTime}. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
104
104
|
|
|
105
105
|
// Call the debounced error function
|
|
106
106
|
debouncedError();
|
|
107
107
|
return true;
|
|
108
108
|
} else {
|
|
109
|
-
console.log(
|
|
109
|
+
console.log(`ℹ️ Github API rate limit: ${response.headers.get('X-RateLimit-Remaining')} requests remaining. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
return response.json();
|
|
@@ -174,12 +174,12 @@ function fetchCommitHashes() {
|
|
|
174
174
|
|
|
175
175
|
if (response.status === 403 && response.headers.get('X-RateLimit-Remaining') === '0') {
|
|
176
176
|
const resetTime = new Date(response.headers.get('X-RateLimit-Reset') * 1000);
|
|
177
|
-
console.error(
|
|
177
|
+
console.error(`❌ Github API rate limit exceeded. Try again after ${resetTime}. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
178
178
|
|
|
179
179
|
debouncedError();
|
|
180
180
|
return true;
|
|
181
181
|
} else {
|
|
182
|
-
console.log(
|
|
182
|
+
console.log(`ℹ️ Github API rate limit: ${response.headers.get('X-RateLimit-Remaining')} requests remaining. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
const data = await response.json();
|
package/index.js
CHANGED
|
@@ -246,7 +246,7 @@ module.exports = async function (options = {}) {
|
|
|
246
246
|
try {
|
|
247
247
|
noticeTitles = {};
|
|
248
248
|
specGroups = {};
|
|
249
|
-
console.log('
|
|
249
|
+
console.log('ℹ️ Rendering: ' + spec.title);
|
|
250
250
|
|
|
251
251
|
function interpolate(template, variables) {
|
|
252
252
|
return template.replace(/\${(.*?)}/g, (match, p1) => variables[p1.trim()]);
|
|
@@ -314,7 +314,7 @@ module.exports = async function (options = {}) {
|
|
|
314
314
|
});
|
|
315
315
|
}
|
|
316
316
|
catch (e) {
|
|
317
|
-
console.error("
|
|
317
|
+
console.error("❌ " + e);
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
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": {
|
|
@@ -84,7 +84,7 @@ function askRemoveEntry() {
|
|
|
84
84
|
// Function to show current external references
|
|
85
85
|
function showReferences() {
|
|
86
86
|
const data = JSON.parse(fs.readFileSync(JSON_FILE, 'utf8'));
|
|
87
|
-
console.log('
|
|
87
|
+
console.log('Current external references (xref):');
|
|
88
88
|
|
|
89
89
|
data.specs[0].external_specs.forEach(spec => {
|
|
90
90
|
console.log('--- External Reference: ---');
|
|
@@ -20,22 +20,22 @@ function collectExternalReferences(options = {}) {
|
|
|
20
20
|
const GITHUB_API_TOKEN = process.env.GITHUB_API_TOKEN;
|
|
21
21
|
|
|
22
22
|
const explanationPAT =
|
|
23
|
-
|
|
23
|
+
`❌ No GitHub Personal Access Token (PAT) was found.
|
|
24
24
|
|
|
25
|
-
GitHub requires you to set up a PAT to retrieve external references.
|
|
25
|
+
GitHub requires you to set up a PAT to retrieve external references.
|
|
26
26
|
|
|
27
|
-
There is no point in continuing without a PAT, so we stop here.
|
|
27
|
+
There is no point in continuing without a PAT, so we stop here.
|
|
28
28
|
|
|
29
|
-
Find instructions on how to get a PAT at https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token
|
|
29
|
+
Find instructions on how to get a PAT at https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token
|
|
30
30
|
|
|
31
31
|
`;
|
|
32
32
|
|
|
33
33
|
const explanationNoExternalReferences =
|
|
34
|
-
`\n
|
|
34
|
+
`\n❌ No external references were found in the specs.json file.
|
|
35
35
|
|
|
36
|
-
There is no point in continuing without external references, so we stop here.
|
|
36
|
+
There is no point in continuing without external references, so we stop here.
|
|
37
37
|
|
|
38
|
-
Please add external references to the specs.json file that you will find at the root of your project.
|
|
38
|
+
Please add external references to the specs.json file that you will find at the root of your project.
|
|
39
39
|
|
|
40
40
|
`;
|
|
41
41
|
|
|
@@ -45,11 +45,11 @@ Please add external references to the specs.json file that you will find at the
|
|
|
45
45
|
// Do not run the script if the GitHub API token is not set
|
|
46
46
|
if (!GITHUB_API_TOKEN) {
|
|
47
47
|
console.log(explanationPAT);
|
|
48
|
-
const userInput = readlineSync.question('Press any key');
|
|
48
|
+
const userInput = readlineSync.question('ℹ️ Press any key');
|
|
49
49
|
|
|
50
50
|
// React to user pressing any key
|
|
51
51
|
if (userInput.trim() !== '') {
|
|
52
|
-
console.log('Stopping...');
|
|
52
|
+
console.log('ℹ️ Stopping...');
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -61,7 +61,7 @@ Please add external references to the specs.json file that you will find at the
|
|
|
61
61
|
|
|
62
62
|
// React to user pressing any key
|
|
63
63
|
if (userInput.trim() !== '') {
|
|
64
|
-
console.log('Stopping...');
|
|
64
|
+
console.log('ℹ️ Stopping...');
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
} else {
|
|
@@ -77,7 +77,8 @@ Please add external references to the specs.json file that you will find at the
|
|
|
77
77
|
doesUrlExist(repo.url).then(exists => {
|
|
78
78
|
if (!exists) {
|
|
79
79
|
const userInput = readlineSync.question(
|
|
80
|
-
|
|
80
|
+
`❌ This external reference is not a valid URL:
|
|
81
|
+
|
|
81
82
|
Repository: ${repo.url},
|
|
82
83
|
|
|
83
84
|
Terms directory: ${repo.terms_dir}
|
|
@@ -86,12 +87,12 @@ Please add external references to the specs.json file that you will find at the
|
|
|
86
87
|
|
|
87
88
|
Do you want to stop? (yes/no): `);
|
|
88
89
|
if (userInput.toLowerCase() === 'yes' || userInput.toLowerCase() === 'y') {
|
|
89
|
-
console.log('Stopping...');
|
|
90
|
+
console.log('ℹ️ Stopping...');
|
|
90
91
|
process.exit(1);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
}).catch(error => {
|
|
94
|
-
console.error('
|
|
95
|
+
console.error('❌ Error checking URL existence:', error);
|
|
95
96
|
});
|
|
96
97
|
});
|
|
97
98
|
|
|
@@ -118,7 +119,7 @@ Please add external references to the specs.json file that you will find at the
|
|
|
118
119
|
// Function to extend xtref objects with additional information, such as repository URL and directory information.
|
|
119
120
|
function extendXTrefs(config, xtrefs) {
|
|
120
121
|
if (config.specs[0].external_specs_repos) {
|
|
121
|
-
console.log("
|
|
122
|
+
console.log("ℹ️ PLEASE NOTE: Your specs.json file is outdated (not your fault, we changed something). Use this one: https://github.com/trustoverip/spec-up-t-starter-pack/blob/main/spec-up-t-boilerplate/specs.json or e-mail kor@dwarshuis.com for help.");
|
|
122
123
|
return;
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -5,12 +5,12 @@ function checkRateLimit(response) {
|
|
|
5
5
|
|
|
6
6
|
if (response.status === 403 && remaining === '0') {
|
|
7
7
|
const resetTime = new Date(reset * 1000);
|
|
8
|
-
console.error(
|
|
8
|
+
console.error(`❌ Github API rate limit exceeded. Try again after ${resetTime}. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
9
9
|
return true;
|
|
10
10
|
} else if (remaining !== null) {
|
|
11
|
-
console.log(
|
|
11
|
+
console.log(`ℹ️ Github API rate limit: ${remaining} requests remaining. See https://trustoverip.github.io/spec-up-t-website/docs/getting-started/github-token for more info.`);
|
|
12
12
|
} else {
|
|
13
|
-
console.warn(
|
|
13
|
+
console.warn(`ℹ️ Unable to determine rate limit status. Check your GitHub API token and network connection.`);
|
|
14
14
|
}
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -30,11 +30,11 @@ async function processXTrefsData(allXTrefs, GITHUB_API_TOKEN, outputPathJSON, ou
|
|
|
30
30
|
xtref.commitHash = item.sha;
|
|
31
31
|
xtref.content = item.content;
|
|
32
32
|
xtref.avatarUrl = item.repository.owner.avatar_url;
|
|
33
|
-
console.log(
|
|
33
|
+
console.log(`✅ Match found for term: ${xtref.term} in ${xtref.externalSpec};`);
|
|
34
34
|
} else {
|
|
35
35
|
xtref.commitHash = "not found";
|
|
36
36
|
xtref.content = "This term was not found in the external repository.";
|
|
37
|
-
console.log(
|
|
37
|
+
console.log(`ℹ️ No match found for term: ${xtref.term} in ${xtref.externalSpec};`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -6,7 +6,7 @@ function setupFetchHeaders(GITHUB_API_TOKEN) {
|
|
|
6
6
|
if (GITHUB_API_TOKEN) {
|
|
7
7
|
fetchHeaders['Authorization'] = `token ${GITHUB_API_TOKEN}`;
|
|
8
8
|
} else {
|
|
9
|
-
console.log('
|
|
9
|
+
console.log('ℹ️ There is no GitHub token set up. Therefore, you are more likely to be at your limit of GitHub API requests. If you run into the limit, create a token and search the documentation on this topic.');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
return fetchHeaders;
|
package/src/create-pdf.js
CHANGED
|
@@ -197,8 +197,8 @@ const pdfLib = require('pdf-lib');
|
|
|
197
197
|
const optimizedPdfBytes = await pdfDoc.save();
|
|
198
198
|
fs.writeFileSync('docs/index.pdf', optimizedPdfBytes);
|
|
199
199
|
|
|
200
|
-
console.log('
|
|
200
|
+
console.log('✅ PDF generated successfully! Find the PDF in the same directory as the index.html file.');
|
|
201
201
|
} catch (error) {
|
|
202
|
-
console.error('
|
|
202
|
+
console.error('❌ Error generating PDF:', error);
|
|
203
203
|
}
|
|
204
204
|
})();
|
package/src/create-term-index.js
CHANGED
|
@@ -33,7 +33,7 @@ function createTermIndex() {
|
|
|
33
33
|
|
|
34
34
|
fs.writeJsonSync(outputPathJSON, filePaths, { spaces: 2 });
|
|
35
35
|
|
|
36
|
-
console.log(
|
|
36
|
+
console.log(`✅ The new terms were added. All done.`);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
module.exports = {
|
|
@@ -71,9 +71,9 @@ function createVersionsIndex(outputPath) {
|
|
|
71
71
|
const indexPath = path.join(versionsDir, 'index.html');
|
|
72
72
|
fs.writeFile(indexPath, htmlContent, (err) => {
|
|
73
73
|
if (err) {
|
|
74
|
-
console.error(
|
|
74
|
+
console.error(`❌ Error writing index file: ${err}`);
|
|
75
75
|
} else {
|
|
76
|
-
console.log(
|
|
76
|
+
console.log(`✅ Index file created at ${indexPath}`);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -77,12 +77,12 @@ function fixMarkdownFiles(directory) {
|
|
|
77
77
|
fs.writeFileSync(itemPath, data, 'utf8');
|
|
78
78
|
}
|
|
79
79
|
} catch (err) {
|
|
80
|
-
console.error(
|
|
80
|
+
console.error(`❌ Error while trying to fix the markdown in file ${item.name}: ${err}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
} catch (err) {
|
|
85
|
-
console.error(
|
|
85
|
+
console.error(`❌ Error reading directory: ${err}`);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
package/src/freeze.js
CHANGED
|
@@ -87,4 +87,4 @@ const destFile = path.join(newVersionDir, 'index.html');
|
|
|
87
87
|
fs.copyFileSync(sourceFile, destFile);
|
|
88
88
|
|
|
89
89
|
// Log a message indicating the file has been copied
|
|
90
|
-
console.log(
|
|
90
|
+
console.log(`✅ Created a freezed specification version in ${destFile}`);
|
|
@@ -27,7 +27,7 @@ function handle_choice() {
|
|
|
27
27
|
echo " Goodbye! You chose to exit."
|
|
28
28
|
echo -e " ************************************\n\n"
|
|
29
29
|
fi
|
|
30
|
-
echo -e "\n\n\n
|
|
30
|
+
echo -e "\n\n\nℹ️ Type 'npm run menu' to return to the main menu.\n"
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
# Function to display the introduction text
|
|
@@ -34,7 +34,7 @@ function checkKeysSync(object, expectedKeys, parentKey = '') {
|
|
|
34
34
|
} else if (typeof object === 'object') {
|
|
35
35
|
// If the key is missing from the object, log an error
|
|
36
36
|
if (!(key in object)) {
|
|
37
|
-
console.error(
|
|
37
|
+
console.error(`❌ Error: Missing key '${key}' in ${parentKey}\n We cannot guarantee that Spec-Up-T will work properly.\n Here is an example specs.json file:\n https://github.com/trustoverip/spec-up-t-starter-pack/blob/main/spec-up-t-boilerplate/specs.json`);
|
|
38
38
|
errorFound = true;
|
|
39
39
|
pauseForEnterSync(); // Pause synchronously to allow user to acknowledge the error
|
|
40
40
|
}
|
|
@@ -85,7 +85,7 @@ function runJsonKeyValidatorSync() {
|
|
|
85
85
|
|
|
86
86
|
// Iterate over each spec entry in the specs array from the JSON file
|
|
87
87
|
for (let [index, spec] of data.specs.entries()) {
|
|
88
|
-
console.log(
|
|
88
|
+
console.log(`ℹ️ Checking spec #${index + 1}`);
|
|
89
89
|
|
|
90
90
|
// Check for keys defined in expectedKeys.specs
|
|
91
91
|
checkKeysSync(spec, expectedKeys.specs, `specs[${index}]`);
|
|
@@ -108,7 +108,7 @@ function runJsonKeyValidatorSync() {
|
|
|
108
108
|
|
|
109
109
|
// If no errors were found, print a success message
|
|
110
110
|
if (!errorFound) {
|
|
111
|
-
console.log('
|
|
111
|
+
console.log('✅ All keys are present. No errors found. Continuing…');
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
package/src/prepare-tref.js
CHANGED
|
@@ -111,12 +111,12 @@ ${localXTrefContent.content}
|
|
|
111
111
|
}
|
|
112
112
|
} catch (err) {
|
|
113
113
|
fs.writeFileSync(itemPath, match[0] + '\n\n' + '<!-- This is a copy of the saved remote text. Remove it if you like. It is automatically (re)generated -->\n\nNothing found, so nothing to show.', 'utf8');
|
|
114
|
-
// console.error(
|
|
114
|
+
// console.error(`❌ Error reading or writing file ${item.name}: ${err}`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
} catch (err) {
|
|
119
|
-
console.error(
|
|
119
|
+
console.error(`❌ Error reading directory: ${err}`);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
package/src/references.js
CHANGED
|
@@ -16,7 +16,7 @@ function validateReferences(references, definitions, render) {
|
|
|
16
16
|
}
|
|
17
17
|
);
|
|
18
18
|
if (unresolvedRefs.length > 0 ) {
|
|
19
|
-
console.log('
|
|
19
|
+
console.log('ℹ️ Unresolved References: ', unresolvedRefs)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const danglingDefs = [];
|
|
@@ -27,7 +27,7 @@ function validateReferences(references, definitions, render) {
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
if(danglingDefs.length > 0) {
|
|
30
|
-
console.log('
|
|
30
|
+
console.log('ℹ️ Dangling Definitions: ', danglingDefs)
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -65,7 +65,7 @@ async function fetchExternalSpecs(spec) {
|
|
|
65
65
|
createNewDLWithTerms(Object.keys(r)[0], Object.values(r)[0])
|
|
66
66
|
);
|
|
67
67
|
} catch (e) {
|
|
68
|
-
console.log("
|
|
68
|
+
console.log("❌ " + e);
|
|
69
69
|
return []; // Return an empty array in case of errors
|
|
70
70
|
}
|
|
71
71
|
}
|