spec-up-t 1.1.3 → 1.1.5

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",
3
+ "version": "1.1.5",
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": {
@@ -0,0 +1,51 @@
1
+ const fs = require('fs').promises;
2
+
3
+ /**
4
+ * Reads the content of a file or returns an empty string if the file does not exist.
5
+ * @param {string} filePath - The path to the file.
6
+ * @returns {Promise<string>} - The content of the file or an empty string.
7
+ */
8
+ async function readFileOrCreateEmpty(filePath) {
9
+ try {
10
+ return await fs.readFile(filePath, 'utf8');
11
+ } catch (error) {
12
+ if (error.code === 'ENOENT') {
13
+ return '';
14
+ }
15
+ throw error;
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Updates the .gitignore file with the specified files.
21
+ * @param {string} gitignorePath - The path to the .gitignore file.
22
+ * @param {string[]} filesToAdd - The list of files to add to .gitignore.
23
+ */
24
+ async function updateGitignore(gitignorePath, filesToAdd) {
25
+ try {
26
+ // Read the .gitignore file or create an empty one if it doesn't exist
27
+ let gitignoreContent = await readFileOrCreateEmpty(gitignorePath);
28
+
29
+ // Split the content into lines and remove empty lines
30
+ const gitignoreLines = gitignoreContent.split('\n').filter(line => line.trim() !== '');
31
+
32
+ // Add files to .gitignore if they are not already present
33
+ filesToAdd.forEach(file => {
34
+ if (!gitignoreLines.some(line => line.trim() === file.trim())) {
35
+ gitignoreLines.push(file.trim());
36
+ }
37
+ });
38
+
39
+ // Join the lines back into a single string
40
+ const updatedGitignoreContent = gitignoreLines.join('\n') + '\n';
41
+
42
+ // Write the updated content back to the .gitignore file
43
+ await fs.writeFile(gitignorePath, updatedGitignoreContent, 'utf8');
44
+
45
+ console.log('Updated .gitignore file');
46
+ } catch (error) {
47
+ console.error('Error updating .gitignore:', error.message);
48
+ }
49
+ }
50
+
51
+ module.exports = { updateGitignore};
@@ -0,0 +1,17 @@
1
+ // Configuration
2
+ const gitIgnoreEntries = {
3
+ gitignorePath: path.join(__dirname, '../../../../', '.gitignore'),
4
+ filesToAdd: ['node_modules',
5
+ '*.log',
6
+ 'dist',
7
+ '*.bak',
8
+ '*.tmp',
9
+ '.DS_Store',
10
+ '.env',
11
+ 'coverage',
12
+ 'build',
13
+ '.history'
14
+ ],
15
+ };
16
+
17
+ module.exports = { gitIgnoreEntries };
@@ -1,3 +1,3 @@
1
- const systemFiles = ['main.sh','README.md','help.txt'];
1
+ const systemFiles = ['README.md','.env.example'];
2
2
 
3
3
  module.exports = { systemFiles };
@@ -1,9 +1,11 @@
1
1
  const { configScriptsKeys } = require('./config-scripts-keys');
2
2
  const addScriptsKeys = require('./add-scripts-keys');
3
3
  const copySystemFiles = require('./copy-system-files');
4
+ const { gitIgnoreEntries } = require('./config-gitignore-entries');
5
+ const {updateGitignore} = require('./add-gitignore-entries');
4
6
 
5
7
  addScriptsKeys(configScriptsKeys);
6
-
7
8
  copySystemFiles();
9
+ updateGitignore(gitIgnoreEntries.gitignorePath, gitIgnoreEntries.filesToAdd);
8
10
 
9
11
  console.log("✅ custom update done");