spec-up-t 0.11.29 → 0.11.31

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.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @file This file contains a function that adds a blank line at the end of all markdown files in a directory and its subdirectories, only if the blank line is missing.
3
+ * @author Kor Dwarshuis
4
+ * @version 1.0.0
5
+ * @since 2024-08-20
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ // Function to process markdown files in a directory recursively
12
+ function processMarkdownFiles(directory) {
13
+ // Helper function to process a directory
14
+ function processDirectory(directory) {
15
+ // Read the contents of the directory
16
+ fs.readdir(directory, { withFileTypes: true }, (err, items) => {
17
+ if (err) {
18
+ console.error(`Error reading directory: ${err}`);
19
+ return;
20
+ }
21
+
22
+ // Loop through each item in the directory
23
+ items.forEach(item => {
24
+ const itemPath = path.join(directory, item.name);
25
+ if (item.isDirectory()) {
26
+ // If the item is a directory, call processDirectory recursively
27
+ processDirectory(itemPath);
28
+ } else if (item.isFile() && path.extname(item.name) === '.md') {
29
+ // If the item is a markdown file, process it
30
+ fs.readFile(itemPath, 'utf8', (err, data) => {
31
+ if (err) {
32
+ console.error(`Error reading file ${item.name}: ${err}`);
33
+ return;
34
+ }
35
+
36
+ // Check if the file ends with a blank line
37
+ if (!data.endsWith('\n')) {
38
+ // If not, add a blank line at the end
39
+ data += '\n';
40
+ // Write the modified content back to the file
41
+ fs.writeFile(itemPath, data, 'utf8', err => {
42
+ if (err) {
43
+ console.error(`Error writing file ${item.name}: ${err}`);
44
+ } else {
45
+ console.log(`Added blank line to ${item.name}`);
46
+ }
47
+ });
48
+ }
49
+ });
50
+ }
51
+ });
52
+ });
53
+ }
54
+
55
+ // Start processing from the given directory
56
+ processDirectory(directory);
57
+ }
58
+
59
+ const directoryPath = './spec';
60
+ processMarkdownFiles(directoryPath);
61
+
62
+ module.exports = {
63
+ processMarkdownFiles
64
+ }
@@ -5,25 +5,26 @@
5
5
  * @since 2024-06-09
6
6
  */
7
7
 
8
- // Get the current working directory
9
-
10
8
  const fs = require('fs-extra');
11
9
  const config = fs.readJsonSync('specs.json');
12
- const specDirectories = config.specs.map(spec => spec.spec_directory + '/' + spec.spec_terms_directory);
10
+
11
+ // Collect all directories that contain files with a term and definition
12
+ const specTermsDirectories = config.specs.map(spec => spec.spec_directory + '/' + spec.spec_terms_directory);
13
13
 
14
14
  // Create directory named “output” in the project root if it does not yet exist
15
15
  if (!fs.existsSync('output')) {
16
16
  fs.mkdirSync('output');
17
17
  }
18
18
 
19
- // Create directory named “output/xrefs” in the project root if it does not yet exist
19
+ // Create directory named “output/xrefs-history” in the project root if it does not yet exist
20
20
  if (!fs.existsSync('output/xrefs-history')) {
21
21
  fs.mkdirSync('output/xrefs-history');
22
22
  }
23
23
 
24
24
  // Create a path for the output file in the project root
25
- const outputPath = 'output/xrefs-data.js';
26
- const outputPathTimeStamped = 'output/xrefs-history/xrefs-data-' + Date.now() + '.js';
25
+ const outputPathJSON = 'output/xrefs-data.json';
26
+ const outputPathJS = 'output/xrefs-data.js';
27
+ const outputPathJSTimeStamped = 'output/xrefs-history/xrefs-data-' + Date.now() + '.js';
27
28
 
28
29
  function getXrefsData() {
29
30
  let allXrefs = {};
@@ -62,7 +63,7 @@ function getXrefsData() {
62
63
 
63
64
  console.log(`Github API request for the term “${match.term}” was successful`);
64
65
 
65
- // Extract JSON data from the response
66
+ // Extract JSON data from the response, see https://blockchainbird.github.io/spec-up-t-website/docs/various-roles/developers-guide/#example-of-api-response for example response
66
67
  const data = await response.json();
67
68
 
68
69
  // Check if there are any commits
@@ -85,9 +86,15 @@ function getXrefsData() {
85
86
  }
86
87
  }
87
88
 
89
+ async function fetchLatestCommitHashes() {
90
+ for (const xref of allXrefs.xrefs) {
91
+ xref.commitHash = await fetchLatestCommitHash(xref);
92
+ }
93
+ }
94
+
88
95
  // Go through all directories that contain files with a term and definition
89
- console.log('All “spec_directory” found in specs.json: ', specDirectories);
90
- specDirectories.forEach(specDirectory => {
96
+ console.log("All “spec_directory”'s found in specs.json: ", specTermsDirectories);
97
+ specTermsDirectories.forEach(specDirectory => {
91
98
  console.log(`Current spec_directory: `, specDirectory);
92
99
  // read directory
93
100
  fs.readdirSync(specDirectory).forEach(file => {
@@ -101,7 +108,7 @@ function getXrefsData() {
101
108
  const xrefs = markdown.match(regex);
102
109
  xrefs.forEach(xref => {
103
110
  console.log(`Xref found in ${file}: `, xref);
104
- // example of xref: [[xref: PE, Holder]]
111
+ // example of xref: [xref: test-1, Aal]
105
112
  allXrefs.xrefs.add(xref);
106
113
  });
107
114
  }
@@ -113,26 +120,28 @@ function getXrefsData() {
113
120
 
114
121
  // Example output:
115
122
  // allXrefs.xrefs: [
116
- // '[[xref: PE, Holder]]',
117
123
  // '[[xref: test-1, Aal]]',
118
124
  // '[[xref: test-2, Abac]]'
119
125
  // ]
120
126
 
121
- // remove[[xref:” from the beginning of every value in allMatches
127
+ // The following steps create an array of objects with the keys externalSpec” and “term” for each xref by splitting the xref string on the comma and removing the “[[xref:” and “]]” parts
128
+
129
+ // Step 1: remove “[[xref:” from the beginning of every value in allMatches
122
130
  allXrefs.xrefs = allXrefs.xrefs.map(xref => {
123
131
  return xref.replace(/\[\[xref:/, '');
124
132
  });
125
- // remove “]]” from the end of every value in allMatches
133
+
134
+ // Step 2: remove “]]” from the end of every value in allMatches
126
135
  allXrefs.xrefs = allXrefs.xrefs.map(xref => {
127
136
  return xref.replace(/\]\]/, '');
128
137
  });
129
138
 
130
- // trim every entry of allMatches
131
- allXrefs.xrefs = allXrefs.xrefs.map(match => {
132
- return match.trim();
139
+ // Step 3: trim every entry of allMatches
140
+ allXrefs.xrefs = allXrefs.xrefs.map(xref => {
141
+ return xref.trim();
133
142
  });
134
143
 
135
- // split every entry of allMatches on the first comma, replace the entry with an object that has two keys: one that contains everything before the comma and one that contains everything after the comma
144
+ // Step 4: split every entry of allMatches on the first comma, replace the entry with an object that has two keys: one that contains everything before the comma and one that contains everything after the comma
136
145
  allXrefs.xrefs = allXrefs.xrefs.map(xref => {
137
146
  let [externalSpec, term] = xref.split(/,/, 2);
138
147
  return {
@@ -143,12 +152,11 @@ function getXrefsData() {
143
152
 
144
153
  // Example output:
145
154
  // allXrefs.xrefs: [
146
- // { externalSpec: 'PE', term: 'Holder' },
147
155
  // { externalSpec: 'test-1', term: 'Aal' },
148
156
  // { externalSpec: 'test-2', term: 'Abac' }
149
157
  // ]
150
158
 
151
-
159
+ // Step 5: add the url and the dir where the terms are, to the xref object
152
160
  allXrefs.xrefs.forEach(xref => {
153
161
  config.specs.forEach(spec => {
154
162
  spec.external_specs_repos.forEach(repo => {
@@ -156,8 +164,8 @@ function getXrefsData() {
156
164
  // Example external_specs_repos:
157
165
  // "external_specs_repos": [
158
166
  // {
159
- // "external_spec": "PE",
160
- // "url": "https://github.com/decentralized-identity/presentation-exchange",
167
+ // "external_spec": "test-1",
168
+ // "url": "https://github.com/blockchainbird/spec-up-xref-test-1",
161
169
  // "terms_dir": "spec"
162
170
  // },
163
171
  // …
@@ -170,6 +178,7 @@ function getXrefsData() {
170
178
  });
171
179
  });
172
180
 
181
+ // Step 6: add the owner and repo to the xref object
173
182
  allXrefs.xrefs.forEach(xref => {
174
183
  if (xref.repoUrl === undefined) {
175
184
  console.log('match.repoUrl is undefined');
@@ -181,44 +190,58 @@ function getXrefsData() {
181
190
  xref.repo = urlParts[2];
182
191
  });
183
192
 
184
- allXrefs.xrefs.forEach(match => {
193
+ // Step 7: add the site to the xref object
194
+ allXrefs.xrefs.forEach(xref => {
185
195
  // loop through array of specs in config
186
196
  config.specs.forEach(spec => {
187
197
  if (spec.external_specs) {
188
198
  // Example external_specs:
189
199
  // "external_specs": [
190
- // {
191
- // "PE": "https://identity.foundation/presentation-exchange"
192
- // },
200
+ // {
201
+ // "test-1": "https://blockchainbird.github.io/spec-up-xref-test-1/"
202
+ // }
193
203
  // …
194
204
  // ]
195
205
  spec.external_specs.forEach(externalSpec => {
196
206
  const key = Object.keys(externalSpec)[0];
197
- if (key === match.externalSpec) {
198
- match.site = externalSpec[key];
207
+ if (key === xref.externalSpec) {
208
+ xref.site = externalSpec[key];
199
209
  }
200
210
  });
201
211
  }
202
212
  });
203
213
  });
204
214
 
205
- async function fetchLatestCommitHashes() {
206
- for (const match of allXrefs.xrefs) {
207
- match.commitHash = await fetchLatestCommitHash(match);
215
+ // Loop through all xrefs and fetch the latest commit hash for each term and add it to the xref object
216
+ /* Example of xref after adding commitHash:
217
+ xref: {
218
+ "externalSpec": "test-1",
219
+ "term": "Aal",
220
+ "repoUrl": "https://github.com/blockchainbird/spec-up-xref-test-1",
221
+ "terms_dir": "spec/term-definitions",
222
+ "owner": "blockchainbird",
223
+ "repo": "spec-up-xref-test-1",
224
+ "site": "https://blockchainbird.github.io/spec-up-xref-test-1/",
225
+ "commitHash": [
226
+ "f66951f1d378490289caab9c51141b44a0438365"
227
+ ]
208
228
  }
209
- }
229
+ */
210
230
 
211
231
  // Call the function and wait for it to complete before writing to the file
212
232
  fetchLatestCommitHashes().then(() => {
213
233
  // Convert allXrefsStr to a JSON string with indentation
214
234
  const allXrefsStr = JSON.stringify(allXrefs, null, 2);
215
235
 
236
+ // // Write the JSON code to a .json file
237
+ fs.writeFileSync(outputPathJSON, allXrefsStr, 'utf8');
238
+
216
239
  // Create the JS code for the assignment
217
240
  const stringReadyForFileWrite = `const allXrefs = ${allXrefsStr};`;
218
241
 
219
242
  // Write the JS code to a .js file
220
- fs.writeFileSync(outputPath, stringReadyForFileWrite, 'utf8');
221
- fs.writeFileSync(outputPathTimeStamped, stringReadyForFileWrite, 'utf8');
243
+ fs.writeFileSync(outputPathJS, stringReadyForFileWrite, 'utf8');
244
+ fs.writeFileSync(outputPathJSTimeStamped, stringReadyForFileWrite, 'utf8');
222
245
  });
223
246
  }
224
247
 
@@ -0,0 +1,94 @@
1
+ const fs = require('fs');
2
+ const readlineSync = require('readline-sync');
3
+
4
+ let errorFound = false;
5
+
6
+ // Function to pause the script and wait for the ENTER key synchronously
7
+ function pauseForEnterSync() {
8
+ readlineSync.question('Press ENTER to continue...');
9
+ }
10
+
11
+ function loadData() {
12
+ return JSON.parse(fs.readFileSync('./specs.json', 'utf8'));
13
+ }
14
+
15
+ function checkKeysSync(object, expectedKeys, parentKey = '') {
16
+ for (let key of expectedKeys) {
17
+ if (Array.isArray(object)) {
18
+ for (let [index, item] of object.entries()) {
19
+ checkKeysSync(item, expectedKeys, `${parentKey}[${index}]`);
20
+ }
21
+ } else if (typeof object === 'object') {
22
+ if (!(key in object)) {
23
+ 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/blockchainbird/spec-up-t-starter-pack/blob/main/spec-up-t-starterpack/specs.json`);
24
+ errorFound = true;
25
+ pauseForEnterSync(); // Pause synchronously
26
+ }
27
+ if (typeof expectedKeys[key] === 'object' && object[key]) {
28
+ checkKeysSync(object[key], expectedKeys[key], `${parentKey}.${key}`);
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ function runJsonKeyValidatorSync() {
35
+ const data = loadData();
36
+ const expectedKeys = {
37
+ specs: [
38
+ "title",
39
+ "spec_directory",
40
+ "spec_terms_directory",
41
+ "output_path",
42
+ "markdown_paths",
43
+ "logo",
44
+ "logo_link",
45
+ "source",
46
+ "external_specs",
47
+ "external_specs_repos",
48
+ "assets",
49
+ "katex",
50
+ "searchHighlightStyle"
51
+ ],
52
+ source: [
53
+ "host",
54
+ "account",
55
+ "repo"
56
+ ],
57
+ external_specs_repos: [
58
+ "external_spec",
59
+ "url",
60
+ "terms_dir"
61
+ ],
62
+ assets: [
63
+ "path",
64
+ "inject",
65
+ "module"
66
+ ]
67
+ };
68
+
69
+ for (let [index, spec] of data.specs.entries()) {
70
+ console.log(` Checking spec #${index + 1}`);
71
+ checkKeysSync(spec, expectedKeys.specs, `specs[${index}]`);
72
+
73
+ if (spec.source) {
74
+ checkKeysSync(spec.source, expectedKeys.source, `specs[${index}].source`);
75
+ }
76
+
77
+ if (spec.external_specs_repos) {
78
+ checkKeysSync(spec.external_specs_repos, expectedKeys.external_specs_repos, `specs[${index}].external_specs_repos`);
79
+ }
80
+
81
+ // if (spec.assets) {
82
+ // checkKeysSync(spec.assets, expectedKeys.assets, `specs[${index}].assets`);
83
+ // }
84
+ }
85
+
86
+ if (!errorFound) {
87
+ console.log(' All keys are present. No errors found. Continue…');
88
+ }
89
+ }
90
+
91
+ // Export the function to be used in other scripts
92
+ module.exports = {
93
+ runJsonKeyValidatorSync
94
+ };
package/logo.png DELETED
Binary file
package/spec/header.md DELETED
@@ -1,20 +0,0 @@
1
- ## Status
2
-
3
- This is the first public review draft of the ToIP Glossary. It is also the first version published using the [Spec-Up specification editing utility](https://identity.foundation/spec-up/) developed by the [Decentralized Identity Foundation](http://identity.foundation/).
4
-
5
- ## Copyright Notice
6
-
7
- This specification is subject to the **OWF Contributor License Agreement 1.0 - Copyright**
8
- available at
9
- [https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owf-contributor-license-agreement-1-0-copyright](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owf-contributor-license-agreement-1-0-copyright).
10
-
11
- These terms are inherited from the [Technical Stack Working Group](https://wiki.trustoverip.org/display/HOME/Technology+Stack+Working+Group) at the Trust over IP (ToIP) Foundation. [Working Group Charter](https://trustoverip.org/wp-content/uploads/TSWG-2-Charter-Revision.pdf)
12
-
13
-
14
- ## Terms of Use
15
-
16
- These materials are made available under and are subject to the [OWF CLA 1.0 - Copyright & Patent license](https://www.openwebfoundation.org/the-agreements/the-owf-1-0-agreements-granted-claims/owf-contributor-license-agreement-1-0-copyright-and-patent). Any source code is made available under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0.txt).
17
-
18
- THESE MATERIALS ARE PROVIDED “AS IS.” The Trust Over IP Foundation, established as the Joint Development Foundation Projects, LLC, Trust Over IP Foundation Series ("ToIP"), and its members and contributors (each of ToIP, its members and contributors, a "ToIP Party") expressly disclaim any warranties (express, implied, or otherwise), including implied warranties of merchantability, non-infringement, fitness for a particular purpose, or title, related to the materials. The entire risk as to implementing or otherwise using the materials is assumed by the implementer and user.
19
-
20
- IN NO EVENT WILL ANY ToIP PARTY BE LIABLE TO ANY OTHER PARTY FOR LOST PROFITS OR ANY FORM OF INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER FROM ANY CAUSES OF ACTION OF ANY KIND WITH RESPECT TO THESE MATERIALS, ANY DELIVERABLE OR THE ToIP GOVERNING AGREEMENT, WHETHER BASED ON BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE, AND WHETHER OR NOT THE OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,32 +0,0 @@
1
-
2
- [//]: # (Pandoc Formatting Macros)
3
-
4
- [//]: # (::: introtitle)
5
-
6
- [//]: # (Introduction)
7
-
8
- [//]: # (:::)
9
-
10
- ## Introduction
11
-
12
- The ToIP Glossary is a deliverable of the ToIP Concepts and Terminology Working Group. Its purpose is to promote shared understanding of terms and concepts across the many different working groups, communities, enterprises, and ecosystems who are collaborating to develop and deploy decentralized digital trust infrastructure.
13
-
14
- Contributions and feedback are encouraged from any stakeholder in this area of terminology.
15
-
16
- ## Linking to this Glossary
17
-
18
- This glossary is designed to be both human and machine readable. All terms are listed alphabetically; acronyms are listed separately and linked to the fully expanded terms. Document authors can link directly to any term using standard web links and anchors following this syntax:
19
-
20
- `https://trustoverip.org/ctwg-main-glossary#term:xxxxx`
21
-
22
- Where `xxxxx` is the term as it appears in the glossary, with any spaces are replaced by en-dashes (hyphens). For example, a link to the term `self-certifying identifer` would be:
23
-
24
- `https://trustoverip.github.io/ctwg-main-glossary#self-certifiying-identifier`
25
-
26
- A specification document written using the [Decentralized Identity Foundation](http://identity.foundation/)'s open source [Spec-Up editor](https://identity.foundation/spec-up/) may create special external references to terms in this glossary using the Spec-Up `xref` tag following this syntax:
27
-
28
- `[[xref: glossary, xxxxx]]`
29
-
30
- Where `glossary` is the text label the document author assigns to the URL of a Web-accessible glossary, and `xxxxx` is the term as it appears in that glossary, with any spaces are replaced by en-dashes (hyphens). For example, a Spec-Up external reference to the term `self-certifying identifer` using the label `toip` for this glossary would look like this:
31
-
32
- `[[xref: toip, self-certifying-identifier]]`
@@ -1,24 +0,0 @@
1
- ## Referenced Glossaries
2
-
3
- [//]: # (Pandoc Formatting Macros)
4
-
5
- [//]: # (# Normative references)
6
-
7
- [//]: # (::: { #nrm:pdf2 .normref label="ISO 32000-2" })
8
-
9
- [//]: # (ISO 32000-2, *Document management --- Portable Document Format --- Part 2: PDF 2.0*)
10
-
11
- [//]: # (:::)
12
-
13
- The following glossaries were used as sources for some of the definitions in the ToIP Glossary. All source glossaries are cited in the definitions of each term.
14
-
15
- | Short Name | Source Glossary | URL |
16
- |------------|-----------------|-----|
17
- | Wikipedia | Wikipedia | https://www.wikipedia.org/ |
18
- | eSSIF-Lab | eSSIF-Lab Glossary | https://essif-lab.github.io/framework/docs/essifLab-glossary |
19
- | NIST-CSRC | NIST Computer Security Resource Center Glossary | https://csrc.nist.gov/glossary/ |
20
- | PEMC IGR | Kantara Privacy Enhancing Mobile Credentials Implementors Guidance Report | https://kantarainitiative.org/download/pemc-implementors-guidance-report/ |
21
- | W3C DID | W3C Decentralized Identifiers (DIDs) 1.0 | https://www.w3.org/TR/did-core/#terminology |
22
- | W3C VC | W3C VC Data Model 1.1 | https://www.w3.org/TR/vc-data-model/#terminology |
23
- | Ethereum | Ethereum.org Glossary | https://ethereum.org/ |
24
- | Merriam-Webster | Merriam-Webster Dictionary | https://www.merriam-webster.com/dictionary/ |
@@ -1,10 +0,0 @@
1
-
2
- [//]: # (Pandoc Formatting Macros)
3
-
4
- [//]: # (Portable Document Format)
5
-
6
- [//]: # (blank)
7
-
8
- [//]: # (: file format defined by ISO 32000-2)
9
-
10
- ## Terms & Definitions
package/spec/title.md DELETED
@@ -1,38 +0,0 @@
1
- ToIP Glossary
2
- ==================
3
-
4
- **Specification Status**: Public Review Draft 01 (PR1)
5
-
6
- **Latest Draft:**
7
-
8
- * [Github Repository](https://github.com/trustoverip/ctwg-main-glossary)
9
- * [Submit/View Issues](https://github.com/trustoverip/ctwg-main-glossary/issues)
10
- * [Discussions](https://github.com/trustoverip/ctwg-main-glossary/discussions)
11
-
12
- **Editors:**
13
-
14
- - [Drummond Reed](https://github.com/talltree), [Gen](https://www.gendigital.com)
15
- - [Henk van Caan](https://github.com/henkvancann)
16
-
17
- **Contributors:**
18
-
19
- - [Darrell O'Donnell](https://github.com/darrellodonnell), [Continuum Loop Inc.](https://www.continuumloop.com/)
20
- - [Kevin Griffin](https://github.com/m00sey), [GLEIF](https://gleif.org)
21
- - [Kor Dwarshuis](https://github.com/kordwarshuis/)
22
- - [Neil Thomson] TODO
23
- - [Nicky Hickman] TODO
24
- - [Rieks Joosten] TODO
25
- - TODO
26
-
27
- **Participate:**
28
-
29
- ~ [GitHub repo](https://github.com/trustoverip/ctwg-main-glossary)
30
- ~ [Commit history](https://github.com/trustoverip/ctwg-main-glossary/commits/main)
31
-
32
- ------------------------------------
33
-
34
- [//]: # (Pandoc Formatting Macros)
35
-
36
- [//]: # (\maketitle)
37
-
38
- [//]: # (\newpage)
package/spec/toc.md DELETED
@@ -1,4 +0,0 @@
1
-
2
- [//]: # (Pandoc Formatting Macros)
3
-
4
- [//]: # (\toc)