spec-up-t 1.1.7 → 1.1.9

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.1.7",
3
+ "version": "1.1.9",
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": {
@@ -1,9 +1,13 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
- // Function to add scripts to package.json
5
- function addScriptsKeys(scriptKeys) {
6
- // Path to the package.json of the project where this script is run
4
+ /**
5
+ * Adds scripts to the package.json file.
6
+ *
7
+ * @param {Object} scriptKeys - An object containing the scripts to add.
8
+ * @param {Object} [overwriteKeys={}] - An object specifying which scripts to overwrite if they already exist.
9
+ */
10
+ function addScriptsKeys(scriptKeys, overwriteKeys = {}) {
7
11
  const packageJsonPath = path.resolve(__dirname, '../../../../', 'package.json');
8
12
 
9
13
  // Read the package.json file
@@ -22,9 +26,9 @@ function addScriptsKeys(scriptKeys) {
22
26
  packageJson.scripts = {};
23
27
  }
24
28
 
25
- // Add new scripts without overwriting existing ones
29
+ // Add new scripts without overwriting existing ones unless specified in overwriteKeys
26
30
  for (const [key, value] of Object.entries(scriptKeys)) {
27
- if (!packageJson.scripts[key]) {
31
+ if (!packageJson.scripts[key] || overwriteKeys[key]) {
28
32
  packageJson.scripts[key] = value;
29
33
  }
30
34
  }
@@ -44,4 +48,16 @@ function addScriptsKeys(scriptKeys) {
44
48
  }
45
49
 
46
50
  // Export the function
47
- module.exports = addScriptsKeys;
51
+ module.exports = addScriptsKeys;
52
+
53
+ /*
54
+
55
+ // Example usage:
56
+ const configScriptsKeys = { ... };
57
+ const overwriteConfig = { "edit": true }; // Overwrite only "edit" script
58
+
59
+ addScriptsKeys(configScriptsKeys); // Do not overwrite any existing scripts
60
+
61
+ addScriptsKeys(configScriptsKeys, overwriteConfig); // Overwrite specified existing scripts
62
+
63
+ */
@@ -2,7 +2,7 @@ const path = require('path');
2
2
 
3
3
  // Configuration
4
4
  const gitIgnoreEntries = {
5
- gitignorePath: path.join(__dirname, '../../../../', '.gitignore'),
5
+ gitignorePath: path.join(process.cwd(), '.gitignore'),
6
6
  filesToAdd: ['node_modules',
7
7
  '*.log',
8
8
  'dist',
@@ -14,4 +14,21 @@ const configScriptsKeys = {
14
14
  "custom-update": "npm update && node -e \"require('spec-up-t/src/install-from-boilerplate/custom-update.js')\""
15
15
  };
16
16
 
17
- module.exports = { configScriptsKeys };
17
+ // Defines which script keys to overwrite. If a key is not present, it will not be overwritten
18
+ const configOverwriteScriptsKeys = {
19
+ "edit": true,
20
+ "render": true,
21
+ "dev": true,
22
+ "collectExternalReferencesCache": true,
23
+ "collectExternalReferencesNoCache": true,
24
+ "topdf": true,
25
+ "freeze": true,
26
+ "references": true,
27
+ "help": true,
28
+ "menu": true,
29
+ "addremovexrefsource": true,
30
+ "configure": true,
31
+ "custom-update": true
32
+ };
33
+
34
+ module.exports = { configScriptsKeys, configOverwriteScriptsKeys };
@@ -1,10 +1,12 @@
1
1
  const { configScriptsKeys } = require('./config-scripts-keys');
2
+ const { configOverwriteScriptsKeys } = require('./config-scripts-keys');
2
3
  const addScriptsKeys = require('./add-scripts-keys');
3
4
  const copySystemFiles = require('./copy-system-files');
4
5
  const { gitIgnoreEntries } = require('./config-gitignore-entries');
5
6
  const {updateGitignore} = require('./add-gitignore-entries');
6
7
 
7
- addScriptsKeys(configScriptsKeys);
8
+
9
+ addScriptsKeys(configScriptsKeys, configOverwriteScriptsKeys);
8
10
  copySystemFiles();
9
11
  updateGitignore(gitIgnoreEntries.gitignorePath, gitIgnoreEntries.filesToAdd);
10
12