spec-up-t 1.0.10 → 1.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spec-up-t",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
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": {
package/src/create-pdf.js CHANGED
@@ -1,3 +1,4 @@
1
+ const fs = require('fs-extra');
1
2
  const puppeteer = require('puppeteer');
2
3
  const path = require('path');
3
4
 
@@ -7,8 +8,15 @@ const path = require('path');
7
8
  const browser = await puppeteer.launch();
8
9
  const page = await browser.newPage();
9
10
 
11
+ // Read and parse the specs.json file
12
+ const config = fs.readJsonSync('specs.json');
13
+
14
+ // Extract the output_path from the specs.json file
15
+ const outputPath = config.specs[0].output_path;
16
+
10
17
  // Define the path to the HTML file based on the directory where the script is called from
11
- const filePath = path.resolve(process.cwd(), 'docs/index.html');
18
+ //TODO: replace `docs/index.html` with the path in specs.json
19
+ const filePath = path.resolve(process.cwd(), outputPath, 'index.html');
12
20
  const fileUrl = `file://${filePath}`;
13
21
 
14
22
  // Navigate to the HTML file
package/src/freeze.js ADDED
@@ -0,0 +1,54 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ // Read and parse the specs.json file
5
+ const config = fs.readJsonSync('specs.json');
6
+
7
+ // Extract the output_path from the specs.json file
8
+ const outputPath = config.specs[0].output_path;
9
+
10
+ // Define the source file path
11
+ const sourceFile = path.join(outputPath, 'index.html');
12
+
13
+ // Define the destination directory path
14
+ const destDir = path.join(outputPath, 'versions');
15
+
16
+ // Ensure the destination directory exists, create it if it doesn't
17
+ if (!fs.existsSync(destDir)) {
18
+ fs.mkdirSync(destDir, { recursive: true });
19
+ }
20
+
21
+ // Get all files in the destination directory
22
+ const files = fs.readdirSync(destDir);
23
+
24
+ // Initialize the highest version number to 0
25
+ let highestVersion = 0;
26
+
27
+ // Define the pattern to match versioned filenames
28
+ const versionPattern = /^index-v(\d+)\.html$/;
29
+
30
+ // Iterate over each file in the destination directory
31
+ files.forEach(file => {
32
+ // Check if the file matches the version pattern
33
+ const match = file.match(versionPattern);
34
+ if (match) {
35
+ // Extract the version number from the filename
36
+ const version = parseInt(match[1], 10);
37
+ // Update the highest version number if the current version is higher
38
+ if (version > highestVersion) {
39
+ highestVersion = version;
40
+ }
41
+ }
42
+ });
43
+
44
+ // Calculate the new version number
45
+ const newVersion = highestVersion + 1;
46
+
47
+ // Define the destination file path with the new version number
48
+ const destFile = path.join(destDir, `index-v${newVersion}.html`);
49
+
50
+ // Copy the source file to the destination file
51
+ fs.copyFileSync(sourceFile, destFile);
52
+
53
+ // Log a message indicating the file has been copied
54
+ console.log(`\n SPEC-UP-T: Created a freezed specification version in ${destFile}\n`);