spec-up-t 1.0.55 → 1.0.56

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/gulpfile.js CHANGED
@@ -15,7 +15,7 @@ const assets = fs.readJsonSync('./src/asset-map.json');
15
15
 
16
16
  let compileLocation = 'assets/compiled';
17
17
 
18
- async function fetchSpecRefs(){
18
+ async function fetchSpecRefs() {
19
19
  return Promise.all([
20
20
  axios.get('https://raw.githubusercontent.com/tobie/specref/master/refs/ietf.json'),
21
21
  axios.get('https://raw.githubusercontent.com/tobie/specref/master/refs/w3c.json'),
@@ -26,7 +26,7 @@ async function fetchSpecRefs(){
26
26
  }).catch(e => console.log(e));
27
27
  }
28
28
 
29
- async function compileAssets(){
29
+ async function compileAssets() {
30
30
  await fs.ensureDir(compileLocation);
31
31
  return new Promise(resolve => {
32
32
  mergeStreams(
@@ -42,23 +42,23 @@ async function compileAssets(){
42
42
  .pipe(terser())
43
43
  .pipe(concat('body.js'))
44
44
  .pipe(gulp.dest(compileLocation))
45
- ).on('finish', function() {
45
+ ).on('finish', function () {
46
46
  resolve();
47
47
  })
48
48
  });
49
49
  }
50
50
 
51
- function runCommand(cmd){
51
+ function runCommand(cmd) {
52
52
  return new Promise((resolve, reject) => {
53
53
  exec(cmd, {}, error => error ? reject() : resolve());
54
54
  });
55
55
  }
56
56
 
57
- async function bumpVersion(){
58
- return runCommand(`npm version --no-git-tag-version ${ argv.v || 'patch' }`);
57
+ async function bumpVersion() {
58
+ return runCommand(`npm version --no-git-tag-version ${argv.v || 'patch'}`);
59
59
  }
60
60
 
61
- async function renderSpecs(){
61
+ async function renderSpecs() {
62
62
  return runCommand('npm run render');
63
63
  }
64
64
 
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- module.exports = function(options = {}) {
2
+ module.exports = function (options = {}) {
3
3
  const fs = require('fs-extra');
4
4
  const path = require('path');
5
5
 
@@ -11,18 +11,21 @@ module.exports = function(options = {}) {
11
11
 
12
12
  const { runJsonKeyValidatorSync } = require('./src/json-key-validator.js');
13
13
  runJsonKeyValidatorSync();
14
-
14
+
15
15
  const { createTermRelations } = require('./src/create-term-relations.js');
16
16
  createTermRelations();
17
+
18
+ const { createTermIndex } = require('./src/create-term-index.js');
19
+ createTermIndex();
17
20
 
18
21
  const { insertTermIndex } = require('./src/insert-term-index.js');
19
22
  insertTermIndex();
20
-
23
+
21
24
  const gulp = require('gulp');
22
25
  const findPkgDir = require('find-pkg-dir');
23
26
  const modulePath = findPkgDir(__dirname);
24
27
  let config = fs.readJsonSync('./output/specs-generated.json');
25
-
28
+
26
29
  const createVersionsIndex = require('./src/create-versions-index.js');
27
30
  createVersionsIndex(config.specs[0].output_path);
28
31
 
@@ -38,7 +41,7 @@ module.exports = function(options = {}) {
38
41
  const replacers = [
39
42
  {
40
43
  test: 'insert',
41
- transform: function(path){
44
+ transform: function (path) {
42
45
  if (!path) return '';
43
46
  return fs.readFileSync(path, 'utf8');
44
47
  }
@@ -46,7 +49,7 @@ module.exports = function(options = {}) {
46
49
  ];
47
50
 
48
51
  const { processMarkdownFiles } = require('./src/fix-markdown-files.js');
49
-
52
+
50
53
  // Synchonously process markdown files
51
54
  processMarkdownFiles(path.join(config.specs[0].spec_directory, config.specs[0].spec_terms_directory));
52
55
 
@@ -64,11 +67,11 @@ module.exports = function(options = {}) {
64
67
  });
65
68
  }
66
69
 
67
- function normalizePath(path){
70
+ function normalizePath(path) {
68
71
  return path.trim().replace(/\/$/g, '') + '/';
69
72
  }
70
73
 
71
- function renderRefGroup(type){
74
+ function renderRefGroup(type) {
72
75
  let group = specGroups[type];
73
76
  if (!group) return '';
74
77
  let html = Object.keys(group).sort().reduce((html, name) => {
@@ -84,14 +87,14 @@ module.exports = function(options = {}) {
84
87
  return `\n${html}\n</dl>\n`;
85
88
  }
86
89
 
87
- function findKatexDist(){
90
+ function findKatexDist() {
88
91
  const relpath = "node_modules/katex/dist";
89
92
  const paths = [
90
93
  path.join(process.cwd(), relpath),
91
94
  path.join(__dirname, relpath),
92
95
  ];
93
- for(const abspath of paths) {
94
- if(fs.existsSync(abspath)) {
96
+ for (const abspath of paths) {
97
+ if (fs.existsSync(abspath)) {
95
98
  return abspath
96
99
  }
97
100
  }
@@ -115,16 +118,16 @@ module.exports = function(options = {}) {
115
118
  const specCorpus = fs.readJsonSync(modulePath + '/assets/compiled/refs.json');
116
119
  const containers = require('markdown-it-container');
117
120
  const md = require('markdown-it')({
118
- html: true,
119
- linkify: true,
120
- typographer: true
121
- })
121
+ html: true,
122
+ linkify: true,
123
+ typographer: true
124
+ })
122
125
  .use(require('./src/markdown-it-extensions.js'), [
123
126
  {
124
127
  filter: type => type.match(terminologyRegex),
125
- parse(token, type, primary){
128
+ parse(token, type, primary) {
126
129
  if (!primary) return;
127
- if (type === 'def'){
130
+ if (type === 'def') {
128
131
  definitions.push(token.info.args);
129
132
  return token.info.args.reduce((acc, syn) => {
130
133
  return `<span id="term:${syn.replace(spaceRegex, '-').toLowerCase()}">${acc}</span>`;
@@ -144,13 +147,13 @@ module.exports = function(options = {}) {
144
147
  },
145
148
  {
146
149
  filter: type => type.match(specNameRegex),
147
- parse(token, type, name){
150
+ parse(token, type, name) {
148
151
  if (name) {
149
152
  let _name = name.replace(spaceRegex, '-').toUpperCase();
150
153
  let spec = specCorpus[_name] ||
151
- specCorpus[_name.toLowerCase()] ||
152
- specCorpus[name.toLowerCase()] ||
153
- specCorpus[name];
154
+ specCorpus[_name.toLowerCase()] ||
155
+ specCorpus[name.toLowerCase()] ||
156
+ specCorpus[name];
154
157
  if (spec) {
155
158
  spec._name = _name;
156
159
  let group = specGroups[type] = specGroups[type] || {};
@@ -158,8 +161,8 @@ module.exports = function(options = {}) {
158
161
  }
159
162
  }
160
163
  },
161
- render(token, type, name){
162
- if (name){
164
+ render(token, type, name) {
165
+ if (name) {
163
166
  let spec = token.info.spec;
164
167
  if (spec) return `[<a class="spec-reference" href="#ref:${spec._name}">${spec._name}</a>]`;
165
168
  }
@@ -179,12 +182,12 @@ module.exports = function(options = {}) {
179
182
  .use(require('markdown-it-sup'))
180
183
  .use(require('markdown-it-task-lists'))
181
184
  .use(require('markdown-it-multimd-table'), {
182
- multiline: true,
183
- rowspan: true,
185
+ multiline: true,
186
+ rowspan: true,
184
187
  headerless: true
185
188
  })
186
189
  .use(containers, 'notice', {
187
- validate: function(params) {
190
+ validate: function (params) {
188
191
  let matches = params.match(/(\w+)\s?(.*)?/);
189
192
  return matches && noticeTypes[matches[1]];
190
193
  },
@@ -194,7 +197,7 @@ module.exports = function(options = {}) {
194
197
  let id;
195
198
  let type = matches[1];
196
199
  if (matches[2]) {
197
- id = matches[2].trim().replace(/\s+/g , '-').toLowerCase();
200
+ id = matches[2].trim().replace(/\s+/g, '-').toLowerCase();
198
201
  if (noticeTitles[id]) id += '-' + noticeTitles[id]++;
199
202
  else noticeTitles[id] = 1;
200
203
  }
@@ -214,7 +217,7 @@ module.exports = function(options = {}) {
214
217
  anchorClassName: 'toc-anchor'
215
218
  })
216
219
  .use(require('@traptitech/markdown-it-katex'))
217
-
220
+
218
221
  // Custom plugin to add class to <dl> and the last <dd> in each series after a <dt>
219
222
  function addClassToDefinitionList(md) {
220
223
  const originalRender = md.renderer.rules.dl_open || function (tokens, idx, options, env, self) {
@@ -272,11 +275,11 @@ module.exports = function(options = {}) {
272
275
  noticeTitles = {};
273
276
  specGroups = {};
274
277
  console.log('\n SPEC-UP-T: Rendering: ' + spec.title + "\n");
275
-
278
+
276
279
  function interpolate(template, variables) {
277
280
  return template.replace(/\${(.*?)}/g, (match, p1) => variables[p1.trim()]);
278
281
  }
279
-
282
+
280
283
  return new Promise(async (resolve, reject) => {
281
284
  Promise.all((spec.markdown_paths || ['spec.md']).map(_path => {
282
285
  return fs.readFile(spec.spec_directory + _path, 'utf8').catch(e => reject(e))
@@ -304,31 +307,31 @@ module.exports = function(options = {}) {
304
307
  specLogoLink: spec.logo_link,
305
308
  spec: JSON.stringify(spec)
306
309
  });
307
-
310
+
308
311
  fs.writeFile(path.join(spec.destination, 'index.html'),
309
312
  templateInterpolated, 'utf8'
310
313
 
311
- , function (err, data) {
312
- if (err) {
313
- reject(err);
314
- }
315
- else {
316
- resolve();
317
- }
318
- });
314
+ , function (err, data) {
315
+ if (err) {
316
+ reject(err);
317
+ }
318
+ else {
319
+ resolve();
320
+ }
321
+ });
319
322
  validateReferences(references, definitions, render);
320
323
  references = [];
321
324
  definitions = [];
322
325
  });
323
326
  });
324
327
  }
325
- catch(e) {
328
+ catch (e) {
326
329
  console.error("\n SPEC-UP-T: " + e + "\n");
327
330
  }
328
331
  }
329
332
 
330
333
  config.specs.forEach(spec => {
331
- spec.spec_directory = normalizePath(spec.spec_directory);
334
+ spec.spec_directory = normalizePath(spec.spec_directory);
332
335
  spec.destination = normalizePath(spec.output_path || spec.spec_directory);
333
336
 
334
337
  fs.ensureDirSync(spec.destination);
@@ -343,40 +346,40 @@ module.exports = function(options = {}) {
343
346
  assets.css += `<link href="${asset.path}" rel="stylesheet"/>`;
344
347
  }
345
348
  if (ext === 'js') {
346
- assets.js[asset.inject || 'body'] += `<script src="${asset.path}" ${ asset.module ? 'type="module"' : '' } ></script>`;
349
+ assets.js[asset.inject || 'body'] += `<script src="${asset.path}" ${asset.module ? 'type="module"' : ''} ></script>`;
347
350
  }
348
351
  return assets;
349
352
  }, {
350
353
  css: '',
351
354
  js: { head: '', body: '' }
352
- });
355
+ });
353
356
 
354
357
  if (options.dev) {
355
- assetTags.head = assets.head.css.map(_path => `<link href="${_path}" rel="stylesheet"/>`).join('') +
356
- customAssets.css +
357
- assets.head.js.map(_path => `<script src="${_path}"></script>`).join('') +
358
- customAssets.js.head;
359
- assetTags.body = assets.body.js.map(_path => `<script src="${_path}" data-manual></script>`).join('') +
360
- customAssets.js.body;
358
+ assetTags.head = assets.head.css.map(_path => `<link href="${_path}" rel="stylesheet"/>`).join('') +
359
+ customAssets.css +
360
+ assets.head.js.map(_path => `<script src="${_path}"></script>`).join('') +
361
+ customAssets.js.head;
362
+ assetTags.body = assets.body.js.map(_path => `<script src="${_path}" data-manual></script>`).join('') +
363
+ customAssets.js.body;
361
364
  }
362
365
  else {
363
366
  assetTags.head = `
364
367
  <style>${fs.readFileSync(modulePath + '/assets/compiled/head.css', 'utf8')}</style>
365
- ${ customAssets.css }
368
+ ${customAssets.css}
366
369
  <script>${fs.readFileSync(modulePath + '/assets/compiled/head.js', 'utf8')}</script>
367
- ${ customAssets.js.head }
370
+ ${customAssets.js.head}
368
371
  `;
369
372
  assetTags.body = `<script>${fs.readFileSync(modulePath + '/assets/compiled/body.js', 'utf8')}</script>
370
- ${ customAssets.js.body }`;
373
+ ${customAssets.js.body}`;
371
374
  }
372
375
 
373
376
  if (spec.katex) {
374
377
  const katexDist = findKatexDist();
375
378
  assetTags.body += `<script>/* katex */${fs.readFileSync(path.join(katexDist, 'katex.min.js'),
376
- 'utf8')}</script>`;
379
+ 'utf8')}</script>`;
377
380
  assetTags.body += `<style>/* katex */${fs.readFileSync(path.join(katexDist, 'katex.min.css'),
378
- 'utf8')}</style>`;
379
-
381
+ 'utf8')}</style>`;
382
+
380
383
  fs.copySync(path.join(katexDist, 'fonts'), path.join(spec.destination, 'fonts'));
381
384
  }
382
385
 
@@ -394,7 +397,7 @@ module.exports = function(options = {}) {
394
397
  });
395
398
 
396
399
  }
397
- catch(e) {
400
+ catch (e) {
398
401
  console.error("\n SPEC-UP-T: " + e + "\n");
399
402
  }
400
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
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": {
@@ -28,29 +28,29 @@
28
28
  "diff": "^7.0.0",
29
29
  "find-pkg-dir": "^2.0.0",
30
30
  "fs-extra": "^11.2.0",
31
- "gulp": "^5.0.0",
32
- "gulp-clean-css": "^4.3.0",
33
- "gulp-concat": "^2.6.1",
34
- "gulp-terser": "^2.1.0",
31
+ "gulp": "4.0.2",
32
+ "gulp-clean-css": "4.3.0",
33
+ "gulp-concat": "2.6.1",
34
+ "gulp-terser": "1.2.0",
35
35
  "jsdom": "^25.0.0",
36
36
  "markdown-it": "^13.0.1",
37
- "markdown-it-anchor": "5.2.5",
38
- "markdown-it-attrs": "4.1.4",
37
+ "markdown-it-anchor": "^9.2.0",
38
+ "markdown-it-attrs": "^4.1.4",
39
39
  "markdown-it-chart": "^0.2.0",
40
40
  "markdown-it-container": "^2.0.0",
41
41
  "markdown-it-deflist": "^2.1.0",
42
42
  "markdown-it-icons": "^0.4.1",
43
43
  "markdown-it-ins": "^2.0.0",
44
44
  "markdown-it-mark": "^2.0.0",
45
- "markdown-it-modify-token": "1.0.2",
45
+ "markdown-it-modify-token": "^1.0.2",
46
46
  "markdown-it-multimd-table": "^4.1.3",
47
47
  "markdown-it-prism": "^2.2.0",
48
48
  "markdown-it-references": "1.0.0-alpha.10",
49
49
  "markdown-it-sub": "^1.0.0",
50
50
  "markdown-it-sup": "^1.0.0",
51
- "markdown-it-task-lists": "2.1.1",
52
- "markdown-it-textual-uml": "0.1.3",
53
- "markdown-it-toc-and-anchor": "4.2.0",
51
+ "markdown-it-task-lists": "^2.1.1",
52
+ "markdown-it-textual-uml": "^0.1.3",
53
+ "markdown-it-toc-and-anchor": "^4.2.0",
54
54
  "merge-stream": "^2.0.0",
55
55
  "pdf-lib": "^1.17.1",
56
56
  "pkg-dir": "^8.0.0",
@@ -1,7 +1,4 @@
1
1
  /**
2
- * Creates a term index by reading specifications from a JSON file and generating a list of file paths.
3
- * The list of file paths is then written to a JSON file in the project root directory.
4
- *
5
2
  * Steps:
6
3
  * 1. Reads the configuration from 'specs.json'.
7
4
  * 2. Extracts the directories containing the specifications and terms.
@@ -25,7 +22,8 @@ function createTermIndex() {
25
22
  const specDirectories = config.specs.map(spec => spec.spec_directory);
26
23
  const specTermDirectoryName = config.specs.map(spec => spec.spec_terms_directory);
27
24
  const outputPathJSON = './term-index.json';
28
- const files = fs.readdirSync(path.join(specDirectories[0], specTermDirectoryName[0]));
25
+ const files = fs.readdirSync(path.join(specDirectories[0], specTermDirectoryName[0]))
26
+ .filter(file => !file.startsWith('_'));
29
27
 
30
28
  const filePaths = files.map(file => specTermDirectoryName[0] + '/' + file);
31
29
 
package/assets/test.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "foo": {
3
- "bar": 1
4
- }
5
- }
package/assets/test.text DELETED
@@ -1 +0,0 @@
1
- Beam me in, Scotty!
@@ -1,5 +0,0 @@
1
- import {test } from './module-test.js';
2
-
3
- console.log('Custom javascript in body')
4
-
5
- test();
@@ -1 +0,0 @@
1
- console.log('Custom javascript in head')
@@ -1,6 +0,0 @@
1
-
2
- body:after {
3
- content: "Custom CSS in body";
4
- opacity: 0;
5
- pointer-events: none;
6
- }
@@ -1,8 +0,0 @@
1
-
2
- function test(){
3
- console.log('module option for custom assets')
4
- }
5
-
6
- export {
7
- test
8
- }
package/term-index.json DELETED
@@ -1,6 +0,0 @@
1
- [
2
- "terms-definitions/term-1.md",
3
- "terms-definitions/term-2.md",
4
- "terms-definitions/term-3.md",
5
- "terms-definitions/term-4.md"
6
- ]