Skip to content

Commit 0f69005

Browse files
committed
💡 docs-code(repo_management_files/extractfilescopes.js): renamed and documented extracfilescopes.js
rename functions and edited the document blocks to reflect the changes
1 parent 0a0653f commit 0f69005

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

Diff for: package.json

+27-27
Original file line numberDiff line numberDiff line change
@@ -146,63 +146,63 @@
146146
"package.json",
147147
"release.config.ts",
148148
"renovate.json",
149-
"typedoc.json",
150149
"tsconfig.json",
151-
"public/.gitkeep",
150+
"typedoc.json",
152151
".vscode/settings.json",
152+
"public/.gitkeep",
153153
"repo_management_files/cz-emoji-type-extract.js",
154154
"repo_management_files/cz-type-extract.js",
155155
"repo_management_files/directorystructuredocument.md",
156156
"repo_management_files/extractfilescopes.js",
157157
"repo_management_files/genericcommitmessages.md",
158158
"repo_management_files/gitmojisemver-extract.js",
159159
"repo_management_files/issues.sh",
160-
"repo_management_files/packagejsondocument.md",
161160
"repo_management_files/labels.sh",
162-
".github/dependabot.yml",
163-
".github/workflows/build.yml",
164-
".github/workflows/lint.yml",
165-
".github/workflows/docs.yml",
166-
".github/workflows/pr.yml",
167-
".github/workflows/test.yml",
168-
".github/workflows/release.yml",
161+
"repo_management_files/packagejsondocument.md",
169162
".husky/commit-msg",
170163
".husky/prepare-commit-msg",
171164
".husky/_/.gitignore",
172165
".husky/_/applypatch-msg",
173-
".husky/_/h",
174166
".husky/_/commit-msg",
175-
".husky/_/post-checkout",
176167
".husky/_/post-applypatch",
168+
".husky/_/post-checkout",
177169
".husky/_/post-commit",
170+
".husky/_/h",
178171
".husky/_/post-rewrite",
179172
".husky/_/pre-applypatch",
180173
".husky/_/pre-auto-gc",
174+
".husky/_/post-merge",
181175
".husky/_/pre-commit",
182176
".husky/_/pre-rebase",
183-
".husky/_/pre-push",
184177
".husky/_/prepare-commit-msg",
185-
".husky/_/post-merge",
178+
".husky/_/pre-push",
179+
".github/dependabot.yml",
180+
".github/workflows/build.yml",
181+
".github/workflows/docs.yml",
182+
".github/workflows/pr.yml",
183+
".github/workflows/lint.yml",
184+
".github/workflows/release.yml",
185+
".github/workflows/test.yml",
186+
"src/app.ts",
187+
"src/bin/.gitkeep",
188+
"src/controllers/.gitkeep",
189+
"src/middleware/.gitkeep",
190+
"src/configs/.gitkeep",
191+
"src/models/.gitkeep",
192+
"src/plugins/.gitkeep",
193+
"src/routes/.gitkeep",
194+
"src/utils/.gitkeep",
195+
"src/views/.gitkeep",
186196
"test/.gitkeep",
187197
"test/bin/.gitkeep",
188198
"test/configs/.gitkeep",
189199
"test/controllers/.gitkeep",
190200
"test/plugins/.gitkeep",
191-
"test/views/.gitkeep",
192-
"test/utils/.gitkeep",
193201
"test/models/.gitkeep",
202+
"test/views/.gitkeep",
194203
"test/routes/.gitkeep",
195204
"test/middleware/.gitkeep",
196-
"src/app.ts",
197-
"src/controllers/.gitkeep",
198-
"src/bin/.gitkeep",
199-
"src/configs/.gitkeep",
200-
"src/middleware/.gitkeep",
201-
"src/models/.gitkeep",
202-
"src/utils/.gitkeep",
203-
"src/routes/.gitkeep",
204-
"src/views/.gitkeep",
205-
"src/plugins/.gitkeep"
205+
"test/utils/.gitkeep"
206206
],
207207
"questions": {
208208
"scope": "Specify a scope: "
@@ -271,4 +271,4 @@
271271
}
272272
}
273273
}
274-
}
274+
}

Diff for: repo_management_files/extractFileScopes.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { fileURLToPath } from 'url';
66
const __filename = fileURLToPath(import.meta.url);
77
const __dirname = dirname(__filename);
88

9+
// TODO First extract the current scopes and keep any scopes that were manually added in without completely overwriting them with the new file list scope array.
10+
911
// Project root directory, back one directory from repo_management_files.
1012
// normalize the 'directoryPath' string to go from the form `/absolute_path/template-nodes-project/repo_management_files/../`
1113
// to `/absolute_path/template-nodes-project/` to subtract from the beginning of the filePath
@@ -15,15 +17,14 @@ const directoryPath = path.normalize(__dirname + '/../');
1517
const exclude = ['.dccache', '.git', 'node_modules', 'dist', 'coverage', 'CHANGELOG.md', 'bun.lockb', 'docs'];
1618

1719
/**
18-
* Subtracts all occurrences of a sub-string from a main string.
20+
* Removes absolute path sub-string from a main string.
1921
*
20-
* This function takes two strings as input: a main string and a sub-string.
21-
* It removes all occurrences of the sub-string from the main string.
22+
* This function removes all occurrences of the absolute path to the project directory from the main string.
2223
*
23-
* @param {string} mainString - The main string from which sub-string will be removed.
24-
* @return {string} The resulting string after removing all occurrences of the sub-string.
24+
* @param {string} mainString - The main string from which absolute path sub-string will be removed.
25+
* @return {string} The resulting lower case string after removing all occurrences of the absolute path sub-string.
2526
*/
26-
function subtractStrings(mainString) {
27+
function removeAbsolutePathToLowerCase(mainString) {
2728
// Create a regular expression to match all occurrences of the subString
2829
const regex = new RegExp(directoryPath, 'g');
2930

@@ -32,7 +33,6 @@ function subtractStrings(mainString) {
3233
return mainString.replace(regex, '').toLowerCase();
3334
}
3435

35-
3636
/**
3737
* Lists all files and directories in a directory excluding specified items.
3838
* @param {string} dirPath - The directory path to list items from.
@@ -83,7 +83,6 @@ function listFilesAndDirectories(dirPath, excludeList) {
8383
});
8484
}
8585

86-
8786
/**
8887
* Updates the scopes array in the package.json file.
8988
*
@@ -129,9 +128,10 @@ function updateScopesInPackageJson(packageJsonPath, newScopes) {
129128
});
130129
}
131130

131+
// scan all the files not in the exlude list and then update the package.json scopes array
132132
listFilesAndDirectories(directoryPath, exclude)
133133
.then(fileScopes => {
134-
updateScopesInPackageJson(directoryPath + 'package.json', fileScopes.map(subtractStrings));
134+
updateScopesInPackageJson(directoryPath + 'package.json', fileScopes.map(removeAbsolutePathToLowerCase));
135135
})
136136
.catch(err => {
137137
console.error('Error:', err);

0 commit comments

Comments
 (0)