spec-up-t 1.1.7 → 1.1.8
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.
|
|
3
|
+
"version": "1.1.8",
|
|
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,10 +1,14 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 = {}) {
|
|
11
|
+
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
8
12
|
|
|
9
13
|
// Read the package.json file
|
|
10
14
|
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
|
|
@@ -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
|
+
*/
|
|
@@ -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
|
-
|
|
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
|
-
|
|
8
|
+
|
|
9
|
+
addScriptsKeys(configScriptsKeys, configOverwriteScriptsKeys);
|
|
8
10
|
copySystemFiles();
|
|
9
11
|
updateGitignore(gitIgnoreEntries.gitignorePath, gitIgnoreEntries.filesToAdd);
|
|
10
12
|
|