spec-up-t 1.0.90 → 1.0.92
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/compiled/body.js +1 -1
- package/assets/compiled/head.css +1 -1
- package/assets/css/index.css +202 -150
- package/assets/js/show-commit-hashes.js +2 -2
- package/index.js +0 -3
- package/package.json +2 -1
- package/src/add-remove-xref-source.js +171 -0
- package/src/collect-external-references.js +252 -0
- package/src/collectExternalReferences/fetchTermsFromGitHubRepository.js +237 -0
- package/src/{get-xtrefs-data → collectExternalReferences}/matchTerm.js +4 -3
- package/src/collectExternalReferences/processXTrefsData.js +53 -0
- package/src/config/paths.js +1 -0
- package/src/configure.js +96 -0
- package/src/init.js +2 -8
- package/src/prepare-tref.js +21 -4
- package/src/utils/doesUrlExist.js +18 -10
- package/src/utils/isLineWithDefinition.js +13 -0
- package/src/get-xtrefs-data/matchTerm.1.js +0 -23
- package/src/get-xtrefs-data/searchGitHubCode.1.js +0 -69
- package/src/get-xtrefs-data/searchGitHubCode.2.js +0 -77
- package/src/get-xtrefs-data/searchGitHubCode.3.js +0 -85
- package/src/get-xtrefs-data/searchGitHubCode.4.js +0 -92
- package/src/get-xtrefs-data/searchGitHubCode.5.js +0 -97
- package/src/get-xtrefs-data/searchGitHubCode.js +0 -97
- package/src/get-xtrefs-data.js +0 -222
- /package/src/{get-xtrefs-data → collectExternalReferences}/checkRateLimit.js +0 -0
- /package/src/{get-xtrefs-data → collectExternalReferences}/setupFetchHeaders.js +0 -0
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
async function searchGitHubCode(GITHUB_API_TOKEN, searchString, owner, repo, subdirectory) {
|
|
2
|
-
const { Octokit } = await import("octokit");
|
|
3
|
-
const { throttling } = await import("@octokit/plugin-throttling");
|
|
4
|
-
|
|
5
|
-
// Create a throttled Octokit instance
|
|
6
|
-
const ThrottledOctokit = Octokit.plugin(throttling);
|
|
7
|
-
const octokit = new ThrottledOctokit({
|
|
8
|
-
auth: GITHUB_API_TOKEN,
|
|
9
|
-
throttle: {
|
|
10
|
-
onRateLimit: (retryAfter, options) => {
|
|
11
|
-
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
|
|
12
|
-
if (options.request.retryCount <= 1) {
|
|
13
|
-
console.log(`Retrying after ${retryAfter} seconds...`);
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
onAbuseLimit: (retryAfter, options) => {
|
|
18
|
-
console.warn(`Abuse detected for request ${options.method} ${options.url}`);
|
|
19
|
-
},
|
|
20
|
-
onSecondaryRateLimit: (retryAfter, options) => {
|
|
21
|
-
console.warn(`Secondary rate limit hit for request ${options.method} ${options.url}`);
|
|
22
|
-
if (options.request.retryCount <= 1) {
|
|
23
|
-
console.log(`Retrying after ${retryAfter} seconds...`);
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
// Perform the search using Octokit with exact match
|
|
32
|
-
const searchResponse = await octokit.rest.search.code({
|
|
33
|
-
q: `"${searchString}" repo:${owner}/${repo} path:${subdirectory}`, // Exact match in subdirectory
|
|
34
|
-
headers: {
|
|
35
|
-
Accept: "application/vnd.github.v3.text-match+json", // Include text-match media type
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Log the search results
|
|
40
|
-
console.log("Total results:", searchResponse.data.total_count);
|
|
41
|
-
|
|
42
|
-
// Fetch the content of each file
|
|
43
|
-
for (const item of searchResponse.data.items) {
|
|
44
|
-
// Check if text_matches exists and is not empty
|
|
45
|
-
if (!item.text_matches || item.text_matches.length === 0) {
|
|
46
|
-
console.log(`Skipping ${item.path}: No text matches found.`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Check if the match is in the first line using text_matches
|
|
51
|
-
const isFirstLineMatch = item.text_matches.some(match => {
|
|
52
|
-
if (!match.fragment) {
|
|
53
|
-
console.log(`Skipping ${item.path}: No fragment found in text match.`);
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const firstLine = match.fragment.split("\n")[0];
|
|
58
|
-
return firstLine.includes(searchString);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
if (!isFirstLineMatch) {
|
|
62
|
-
console.log(`Skipping ${item.path}: Match not in the first line.`);
|
|
63
|
-
continue; // Skip this file
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Fetch file content
|
|
67
|
-
let content = "";
|
|
68
|
-
try {
|
|
69
|
-
const fileContentResponse = await octokit.rest.repos.getContent({
|
|
70
|
-
owner: item.repository.owner.login, // Repository owner
|
|
71
|
-
repo: item.repository.name, // Repository name
|
|
72
|
-
path: item.path, // File path
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Decode the file content (it's base64-encoded)
|
|
76
|
-
if (fileContentResponse.data.content) {
|
|
77
|
-
content = Buffer.from(fileContentResponse.data.content, "base64").toString("utf-8");
|
|
78
|
-
} else {
|
|
79
|
-
// If the file is larger than 1 MB, GitHub's API will return a download URL instead of the content.
|
|
80
|
-
console.log("File is too large. Download URL:", fileContentResponse.data.download_url);
|
|
81
|
-
}
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error(`Error fetching content for ${item.path}:`, error);
|
|
84
|
-
content = ""; // Set content to an empty string if there's an error
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Attach the content to the item
|
|
88
|
-
item.content = content;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return searchResponse;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error("Error searching GitHub or fetching file content:", error);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
exports.searchGitHubCode = searchGitHubCode;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
async function searchGitHubCode(GITHUB_API_TOKEN, searchString, owner, repo, subdirectory) {
|
|
2
|
-
const { Octokit } = await import("octokit");
|
|
3
|
-
const { throttling } = await import("@octokit/plugin-throttling");
|
|
4
|
-
|
|
5
|
-
// Create a throttled Octokit instance
|
|
6
|
-
const ThrottledOctokit = Octokit.plugin(throttling);
|
|
7
|
-
const octokit = new ThrottledOctokit({
|
|
8
|
-
auth: GITHUB_API_TOKEN,
|
|
9
|
-
throttle: {
|
|
10
|
-
onRateLimit: (retryAfter, options) => {
|
|
11
|
-
console.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
|
|
12
|
-
if (options.request.retryCount <= 1) {
|
|
13
|
-
console.log(`Retrying after ${retryAfter} seconds...`);
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
onAbuseLimit: (retryAfter, options) => {
|
|
18
|
-
console.warn(`Abuse detected for request ${options.method} ${options.url}`);
|
|
19
|
-
},
|
|
20
|
-
onSecondaryRateLimit: (retryAfter, options) => {
|
|
21
|
-
console.warn(`Secondary rate limit hit for request ${options.method} ${options.url}`);
|
|
22
|
-
if (options.request.retryCount <= 1) {
|
|
23
|
-
console.log(`Retrying after ${retryAfter} seconds...`);
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
// Perform the search using Octokit with exact match
|
|
32
|
-
const searchResponse = await octokit.rest.search.code({
|
|
33
|
-
q: `"${searchString}" repo:${owner}/${repo} path:${subdirectory}`, // Exact match in subdirectory
|
|
34
|
-
headers: {
|
|
35
|
-
Accept: "application/vnd.github.v3.text-match+json", // Include text-match media type
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Log the search results
|
|
40
|
-
console.log("Total results:", searchResponse.data.total_count);
|
|
41
|
-
|
|
42
|
-
// Fetch the content of each file
|
|
43
|
-
for (const item of searchResponse.data.items) {
|
|
44
|
-
// Check if text_matches exists and is not empty
|
|
45
|
-
if (!item.text_matches || item.text_matches.length === 0) {
|
|
46
|
-
console.log(`Skipping ${item.path}: No text matches found.`);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Check if the match is in the first line using text_matches
|
|
51
|
-
const isFirstLineMatch = item.text_matches.some(match => {
|
|
52
|
-
if (!match.fragment) {
|
|
53
|
-
console.log(`Skipping ${item.path}: No fragment found in text match.`);
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const firstLine = match.fragment.split("\n")[0];
|
|
58
|
-
return firstLine.includes(searchString);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
if (!isFirstLineMatch) {
|
|
62
|
-
console.log(`Skipping ${item.path}: Match not in the first line.`);
|
|
63
|
-
continue; // Skip this file
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Fetch file content
|
|
67
|
-
let content = "";
|
|
68
|
-
try {
|
|
69
|
-
const fileContentResponse = await octokit.rest.repos.getContent({
|
|
70
|
-
owner: item.repository.owner.login, // Repository owner
|
|
71
|
-
repo: item.repository.name, // Repository name
|
|
72
|
-
path: item.path, // File path
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Decode the file content (it's base64-encoded)
|
|
76
|
-
if (fileContentResponse.data.content) {
|
|
77
|
-
content = Buffer.from(fileContentResponse.data.content, "base64").toString("utf-8");
|
|
78
|
-
} else {
|
|
79
|
-
// If the file is larger than 1 MB, GitHub's API will return a download URL instead of the content.
|
|
80
|
-
console.log("File is too large. Download URL:", fileContentResponse.data.download_url);
|
|
81
|
-
}
|
|
82
|
-
} catch (error) {
|
|
83
|
-
console.error(`Error fetching content for ${item.path}:`, error);
|
|
84
|
-
content = ""; // Set content to an empty string if there's an error
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Attach the content to the item
|
|
88
|
-
item.content = content;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return searchResponse;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
console.error("Error searching GitHub or fetching file content:", error);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
exports.searchGitHubCode = searchGitHubCode;
|
package/src/get-xtrefs-data.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file This script is responsible for fetching the latest commit hash of term files from the GitHub API and generating both a JavaScript file and a JSON file containing the data for the cross-references (xrefs).
|
|
3
|
-
*
|
|
4
|
-
* The generated JavaScript file is included in the HTML output of the specification, serving as a data source for the JavaScript code embedded in the HTML file.
|
|
5
|
-
*
|
|
6
|
-
* Additionally, the data is written to a JSON file for further processing or usage. This ensures that the xref data is available in both JavaScript and JSON formats, providing flexibility for different use cases.
|
|
7
|
-
*
|
|
8
|
-
* @author Kor Dwarshuis
|
|
9
|
-
* @version 1.0.0
|
|
10
|
-
* @since 2024-06-09
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const fs = require('fs-extra');
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const readlineSync = require('readline-sync');
|
|
16
|
-
const { searchGitHubCode } = require('./get-xtrefs-data/searchGitHubCode.js');
|
|
17
|
-
const { matchTerm } = require('./get-xtrefs-data/matchTerm');
|
|
18
|
-
const config = fs.readJsonSync('specs.json');
|
|
19
|
-
const { doesUrlExist } = require('./utils/doesUrlExist.js');
|
|
20
|
-
const { addPath, getPath, getAllPaths } = require('./config/paths');
|
|
21
|
-
|
|
22
|
-
const externalSpecsRepos = config.specs[0].external_specs;
|
|
23
|
-
|
|
24
|
-
// Check if the URLs for the external specs repositories are valid, and prompt the user to abort if they are not.
|
|
25
|
-
externalSpecsRepos.forEach(repo => {
|
|
26
|
-
// Construct the URL for the terms directory of the repository
|
|
27
|
-
|
|
28
|
-
doesUrlExist(repo.url, repo.terms_dir).then(exists => {
|
|
29
|
-
if (!exists) {
|
|
30
|
-
const userInput = readlineSync.question(`\n SPEC-UP-T: This external reference is not a valid URL:\n Repository: ${repo.url},\n Terms directory: ${repo.terms_dir}\n Do you want to stop? (yes/no): `);
|
|
31
|
-
if (userInput.toLowerCase() === 'yes' || userInput.toLowerCase() === 'y') {
|
|
32
|
-
console.log('Stopping...');
|
|
33
|
-
process.exit(1);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}).catch(error => {
|
|
37
|
-
console.error('\n SPEC-UP-T:Error checking URL existence:', error);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Collect all directories that contain files with a term and definition
|
|
42
|
-
// This maps over the specs in the config file and constructs paths to directories
|
|
43
|
-
// where the term definition files are located.
|
|
44
|
-
const specTermsDirectories = config.specs.map(spec => spec.spec_directory + '/' + spec.spec_terms_directory);
|
|
45
|
-
|
|
46
|
-
// Ensure that the 'output' directory exists, creating it if necessary.
|
|
47
|
-
if (!fs.existsSync('output')) {
|
|
48
|
-
fs.mkdirSync('output');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Ensure that the 'output/xtrefs-history' directory exists, creating it if necessary.
|
|
52
|
-
if (!fs.existsSync('output/xtrefs-history')) {
|
|
53
|
-
fs.mkdirSync('output/xtrefs-history');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Define paths for various output files, including JSON and JS files.
|
|
57
|
-
const outputPathJSON = 'output/xtrefs-data.json';
|
|
58
|
-
const outputPathJS = 'output/xtrefs-data.js';
|
|
59
|
-
const outputPathJSTimeStamped = 'output/xtrefs-history/xtrefs-data-' + Date.now() + '.js';
|
|
60
|
-
|
|
61
|
-
function updateXTrefs(GITHUB_API_TOKEN, skipExisting) {
|
|
62
|
-
// Function to extend xtref objects with additional information, such as repository URL and directory information.
|
|
63
|
-
function extendXTrefs(config, xtrefs) {
|
|
64
|
-
if (config.specs[0].external_specs_repos) {
|
|
65
|
-
console.log("\n SPEC-UP-T: 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. \n");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
xtrefs.forEach(xtref => {
|
|
70
|
-
config.specs.forEach(spec => {
|
|
71
|
-
// Loop through "external_specs" to find the repository URL for each xtref
|
|
72
|
-
xtref.repoUrl = null;
|
|
73
|
-
xtref.terms_dir = null;
|
|
74
|
-
xtref.owner = null;
|
|
75
|
-
xtref.repo = null;
|
|
76
|
-
|
|
77
|
-
spec.external_specs.forEach(repo => {
|
|
78
|
-
if (repo.external_spec === xtref.externalSpec) {
|
|
79
|
-
xtref.repoUrl = repo.url;
|
|
80
|
-
xtref.terms_dir = repo.terms_dir;
|
|
81
|
-
const urlParts = new URL(xtref.repoUrl).pathname.split('/');
|
|
82
|
-
xtref.owner = urlParts[1];
|
|
83
|
-
xtref.repo = urlParts[2];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
// Loop through "external_specs" to find the site URL for each xtref
|
|
88
|
-
|
|
89
|
-
xtref.site = null;
|
|
90
|
-
if (spec.external_specs) {
|
|
91
|
-
spec.external_specs.forEach(externalSpec => {
|
|
92
|
-
const key = Object.keys(externalSpec)[0];
|
|
93
|
-
if (key === xtref.externalSpec) {
|
|
94
|
-
xtref.site = externalSpec[key];
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Function to check if an xtref is in the markdown content
|
|
103
|
-
function isXTrefInMarkdown(xtref, markdownContent) {
|
|
104
|
-
// const regex = new RegExp(`\\[\\[xref:${xref.term}\\]\\]`, 'g');
|
|
105
|
-
const regex = new RegExp(`\\[\\[(?:x|t)ref:${xtref.term}\\]\\]`, 'g');
|
|
106
|
-
const result = regex.test(markdownContent);
|
|
107
|
-
return result;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Function to process and clean up xref / tref strings found in the markdown file, returning an object with `externalSpec` and `term` properties.
|
|
111
|
-
function processXTref(xtref) {
|
|
112
|
-
let [externalSpec, term] = xtref.replace(/\[\[(?:xref|tref):/, '').replace(/\]\]/, '').trim().split(/,/, 2);
|
|
113
|
-
return {
|
|
114
|
-
externalSpec: externalSpec.trim(),
|
|
115
|
-
term: term.trim()
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Initialize an object to store all xtrefs.
|
|
120
|
-
let allXTrefs = { xtrefs: [] };
|
|
121
|
-
|
|
122
|
-
// If the output JSON file exists, load its data.
|
|
123
|
-
if (fs.existsSync(outputPathJSON)) {
|
|
124
|
-
const existingXTrefs = fs.readJsonSync(outputPathJSON);
|
|
125
|
-
allXTrefs = existingXTrefs && existingXTrefs.xtrefs ? existingXTrefs : { xtrefs: [] };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Collect all markdown content
|
|
129
|
-
let allMarkdownContent = '';
|
|
130
|
-
|
|
131
|
-
// Read all main repo Markdown files from a list of directories and concatenate their content into a single string.
|
|
132
|
-
specTermsDirectories.forEach(specDirectory => {
|
|
133
|
-
fs.readdirSync(specDirectory).forEach(file => {
|
|
134
|
-
if (file.endsWith('.md')) {
|
|
135
|
-
const markdown = fs.readFileSync(`${specDirectory}/${file}`, 'utf8');
|
|
136
|
-
allMarkdownContent += markdown;
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
// Remove existing entries if not in the combined markdown content
|
|
142
|
-
allXTrefs.xtrefs = allXTrefs.xtrefs.filter(existingXTref => {
|
|
143
|
-
return isXTrefInMarkdown(existingXTref, allMarkdownContent);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// Add new entries if they are in the markdown
|
|
147
|
-
const regex = /\[\[(?:xref|tref):.*?\]\]/g;
|
|
148
|
-
|
|
149
|
-
// `regex` is the regular expression object, and `allMarkdownContent` is the string being tested. The test method returns a boolean value: true if the pattern is found within the string, and false otherwise.
|
|
150
|
-
if (regex.test(allMarkdownContent)) {
|
|
151
|
-
const xtrefs = allMarkdownContent.match(regex);
|
|
152
|
-
xtrefs.forEach(xtref => {
|
|
153
|
-
const newXTrefObj = processXTref(xtref);
|
|
154
|
-
// Ensure that newXTrefObj is only added to the xtrefs array if there isn't already an object with the same term and externalSpec properties. This helps maintain the uniqueness of entries in the array based on these two properties.
|
|
155
|
-
if (!allXTrefs.xtrefs.some(existingXTref =>
|
|
156
|
-
existingXTref.term === newXTrefObj.term && existingXTref.externalSpec === newXTrefObj.externalSpec)) {
|
|
157
|
-
allXTrefs.xtrefs.push(newXTrefObj);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
// Example at this point:
|
|
163
|
-
// allXTrefs.xtrefs: [
|
|
164
|
-
// { externalSpec: 'kmg-1', term: 'authentic-chained-data-container' },
|
|
165
|
-
// ]
|
|
166
|
-
|
|
167
|
-
// Extend each xref with additional data and fetch commit information from GitHub.
|
|
168
|
-
extendXTrefs(config, allXTrefs.xtrefs);
|
|
169
|
-
|
|
170
|
-
// Example at this point:
|
|
171
|
-
// allXTrefs.xtrefs: [
|
|
172
|
-
// {
|
|
173
|
-
// externalSpec: 'kmg-1',
|
|
174
|
-
// term: 'authentic-chained-data-container',
|
|
175
|
-
// repoUrl: 'https://github.com/henkvancann/keri-main-glossary',
|
|
176
|
-
// terms_dir: 'spec/terms-definitions',
|
|
177
|
-
// owner: 'henkvancann',
|
|
178
|
-
// repo: 'keri-main-glossary',
|
|
179
|
-
// site: null
|
|
180
|
-
// }
|
|
181
|
-
// ]
|
|
182
|
-
|
|
183
|
-
(async () => {
|
|
184
|
-
try {
|
|
185
|
-
for (let xtref of allXTrefs.xtrefs) {
|
|
186
|
-
const fetchedData = await searchGitHubCode(GITHUB_API_TOKEN, xtref.term, xtref.owner, xtref.repo, xtref.terms_dir);
|
|
187
|
-
if (fetchedData.data.items.length === 0) {
|
|
188
|
-
xtref.commitHash = "not found";
|
|
189
|
-
xtref.content = "This term was not found in the external repository.";
|
|
190
|
-
} else {
|
|
191
|
-
fetchedData.data.items.forEach(item => {
|
|
192
|
-
// If the term is found according to the matchTerm function (in the first line, line should start with “[[def:), etc) add the commit hash and content to the xtref object
|
|
193
|
-
if (matchTerm(item.content, xtref.term)) {
|
|
194
|
-
xtref.commitHash = item.sha;
|
|
195
|
-
xtref.content = item.content;
|
|
196
|
-
console.log(`\n SPEC-UP-T: Match found for term: ${xtref.term} in ${xtref.externalSpec};`);
|
|
197
|
-
} else {
|
|
198
|
-
xtref.commitHash = "not found";
|
|
199
|
-
xtref.content = "This term was not found in the external repository.";
|
|
200
|
-
console.log(`\n SPEC-UP-T: No match found for term: ${xtref.term} in ${xtref.externalSpec};`);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const allXTrefsStr = JSON.stringify(allXTrefs, null, 2);
|
|
207
|
-
fs.writeFileSync(outputPathJSON, allXTrefsStr, 'utf8');
|
|
208
|
-
const stringReadyForFileWrite = `const allXTrefs = ${allXTrefsStr};`;
|
|
209
|
-
fs.writeFileSync(outputPathJS, stringReadyForFileWrite, 'utf8');
|
|
210
|
-
fs.writeFileSync(outputPathJSTimeStamped, stringReadyForFileWrite, 'utf8');
|
|
211
|
-
|
|
212
|
-
// Run the render function to update the HTML file
|
|
213
|
-
require('../index.js')({ nowatch: true });
|
|
214
|
-
} catch (error) {
|
|
215
|
-
console.error('An error occurred:', error);
|
|
216
|
-
}
|
|
217
|
-
})();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
module.exports = {
|
|
221
|
-
updateXTrefs
|
|
222
|
-
}
|
|
File without changes
|
|
File without changes
|