comment-variables 0.12.4 → 0.13.0
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/README.md +12 -6
- package/comments.config.js +7 -0
- package/comments.example.js +1 -0
- package/comments.template.js +1 -0
- package/library/index.js +30 -19
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -44,26 +44,27 @@ Creates Comment Variables placeholders right next to the single sources of truth
|
|
|
44
44
|
comment-variables --config <your-config.js>
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
Passes a different file as your config instead of the default `comments.config.js` (like `comment-variables --config your-config.js`), through a path relative to the root of your project.
|
|
48
48
|
|
|
49
49
|
```
|
|
50
|
-
|
|
50
|
+
--lint-config-imports now part of the config at the `lintConfigImports` key
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
By default, `comment-variables` excludes your config file and all the (JavaScript/TypeScript) files it recursively imports. This flag cancels this mechanism, linting config imports. (The config file however still remains excluded from linting.)
|
|
54
54
|
|
|
55
55
|
```
|
|
56
|
-
|
|
56
|
+
--my-ignores-only now part of the config at the `myIgnoresOnly` key
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
By default, `comment-variables` includes a preset list of ignored folders (`"node_modules"`, `".next"`, `".react-router"`...). This flag cancels this mechanism so that you can have full control over your ignored files and folders.
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
_The --config flag can be composed with any of the commands:_
|
|
62
62
|
|
|
63
63
|
```
|
|
64
64
|
comment-variables --config your-config.js
|
|
65
|
-
comment-variables compress --config your-config.js
|
|
66
|
-
comment-variables resolve --config your-config.js
|
|
65
|
+
comment-variables compress --config your-config.js
|
|
66
|
+
comment-variables resolve --config your-config.js
|
|
67
|
+
comment-variables placeholders --config your-config.js
|
|
67
68
|
```
|
|
68
69
|
|
|
69
70
|
## **`comments.config.js`**
|
|
@@ -128,9 +129,14 @@ const data = {
|
|
|
128
129
|
|
|
129
130
|
const ignores = ["README.md"];
|
|
130
131
|
|
|
132
|
+
const lintConfigImports = false; // can be ommitted
|
|
133
|
+
const myIgnoresOnly = false; // can be ommitted
|
|
134
|
+
|
|
131
135
|
const config = {
|
|
132
136
|
data,
|
|
133
137
|
ignores,
|
|
138
|
+
lintConfigImports,
|
|
139
|
+
myIgnoresOnly,
|
|
134
140
|
};
|
|
135
141
|
|
|
136
142
|
export default config;
|
package/comments.config.js
CHANGED
|
@@ -106,9 +106,16 @@ const data = {
|
|
|
106
106
|
|
|
107
107
|
const ignores = ["README.md"];
|
|
108
108
|
|
|
109
|
+
// FORMER CLI FLAGS NOW TO BE INCLUDED INSIDE THE CONFIG ITSELF
|
|
110
|
+
|
|
111
|
+
const lintConfigImports = false; // can be ommitted
|
|
112
|
+
const myIgnoresOnly = false; // can be ommitted
|
|
113
|
+
|
|
109
114
|
const config = {
|
|
110
115
|
data,
|
|
111
116
|
ignores,
|
|
117
|
+
lintConfigImports,
|
|
118
|
+
myIgnoresOnly,
|
|
112
119
|
};
|
|
113
120
|
|
|
114
121
|
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// A JavaScript file that acts as an example file for the generated Comment Variables template config. Use the `comment-variables compress` and `comment-variables resolve` commands to see how the following comments go back and forth from Comment Variables placeholders to actual comments reversibly.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// A Comment Variables config template generated upon approval in case no config file has been found. Feel free to use it as a steping stone to learn how to use Comment Variables.
|
package/library/index.js
CHANGED
|
@@ -7,8 +7,6 @@ import fs from "fs";
|
|
|
7
7
|
import resolveConfig, {
|
|
8
8
|
defaultConfigFileName,
|
|
9
9
|
configFlag,
|
|
10
|
-
lintConfigImportsFlag,
|
|
11
|
-
myIgnoresOnlyFlag,
|
|
12
10
|
knownIgnores,
|
|
13
11
|
makeResolvedConfigData,
|
|
14
12
|
} from "comment-variables-resolve-config";
|
|
@@ -29,6 +27,16 @@ import {
|
|
|
29
27
|
placeholdersCommentsFlow,
|
|
30
28
|
} from "./_commons/utilities/flows.js";
|
|
31
29
|
|
|
30
|
+
// GATHERS COMMANDS.
|
|
31
|
+
|
|
32
|
+
const commands = process.argv;
|
|
33
|
+
const coreCommand = commands[2];
|
|
34
|
+
|
|
35
|
+
const skipDetails =
|
|
36
|
+
coreCommand === resolveRuleName ||
|
|
37
|
+
coreCommand === compressRuleName ||
|
|
38
|
+
coreCommand === placeholdersRuleName;
|
|
39
|
+
|
|
32
40
|
// ENSURES THE CLI TOOL ONLY RUNS IN FOLDERS THAT POSSESS A package.json FILE AND A .git FOLDER.
|
|
33
41
|
|
|
34
42
|
if (!hasPackageJson) {
|
|
@@ -37,22 +45,15 @@ if (!hasPackageJson) {
|
|
|
37
45
|
);
|
|
38
46
|
exitDueToFailure();
|
|
39
47
|
}
|
|
48
|
+
skipDetails || console.log("package.json file noticed. Allowed to proceed.");
|
|
49
|
+
|
|
40
50
|
if (!hasGitFolder) {
|
|
41
51
|
console.error(
|
|
42
52
|
"ERROR. No git folder found in this directory. Aborting to prevent irreversible changes."
|
|
43
53
|
);
|
|
44
54
|
exitDueToFailure();
|
|
45
55
|
}
|
|
46
|
-
|
|
47
|
-
// GATHERS COMMANDS.
|
|
48
|
-
|
|
49
|
-
const commands = process.argv;
|
|
50
|
-
const coreCommand = commands[2];
|
|
51
|
-
|
|
52
|
-
const skipDetails =
|
|
53
|
-
coreCommand === resolveRuleName ||
|
|
54
|
-
coreCommand === compressRuleName ||
|
|
55
|
-
coreCommand === placeholdersRuleName;
|
|
56
|
+
skipDetails || console.log("git folder noticed. Allowed to proceed.");
|
|
56
57
|
|
|
57
58
|
// OBTAINS THE VALIDATED FLATTENED CONFIG, REVERSE FLATTENED CONFIG, CONFIG PATH, AND PASSED IGNORES.
|
|
58
59
|
|
|
@@ -87,6 +88,9 @@ const {
|
|
|
87
88
|
configPath,
|
|
88
89
|
passedIgnores,
|
|
89
90
|
rawConfigAndImportPaths,
|
|
91
|
+
// NEW
|
|
92
|
+
lintConfigImports,
|
|
93
|
+
myIgnoresOnly,
|
|
90
94
|
} = resolveConfigResults;
|
|
91
95
|
|
|
92
96
|
skipDetails || console.log("Running with config:", config);
|
|
@@ -99,10 +103,19 @@ skipDetails ||
|
|
|
99
103
|
skipDetails || console.log("Aliases are:", aliases_flattenedKeys);
|
|
100
104
|
skipDetails || console.log("Config path is:", configPath);
|
|
101
105
|
skipDetails || console.log("Passed ignores are:", passedIgnores);
|
|
106
|
+
// NEW
|
|
107
|
+
skipDetails || console.log("lintConfigImports is:", lintConfigImports);
|
|
108
|
+
skipDetails || console.log("myIgnoresOnly are:", myIgnoresOnly);
|
|
109
|
+
|
|
110
|
+
/* IMPORTANT
|
|
111
|
+
Aside from the config flag, all other flags (`--lint-config-imports`, `--my-ignores-only`) should be included in the config so that they can be shared across the CLI and the extension within a single source of truth, invalidating the need to scream " (And DON'T FORGET YOUR FLAGS!)".
|
|
112
|
+
This didn't come to mind originally because the idea of these flags came into play before I reliably made the VS Code extension.
|
|
113
|
+
The goal therefore becomes that ONLY the config path remains the SOLE available flag for the CLI and config option for the extension that users will have to manage manually across both solutions.
|
|
114
|
+
And then I can start working on the template for Comment Variables to unleash upon asking if no config file is found. comments.template.js */
|
|
102
115
|
|
|
103
|
-
// ADDRESSES THE --lint-config-imports FLAG, GIVEN THAT THE FILES IMPORTED BY THE CONFIG ARE IGNORED BY DEFAULT.
|
|
116
|
+
// ADDRESSES THE --lint-config-imports FLAG (lintConfigImports, no longer a flag), GIVEN THAT THE FILES IMPORTED BY THE CONFIG ARE IGNORED BY DEFAULT.
|
|
104
117
|
|
|
105
|
-
const lintConfigImports = commands.indexOf(lintConfigImportsFlag) >= 2;
|
|
118
|
+
// const lintConfigImports = commands.indexOf(lintConfigImportsFlag) >= 2; // NOW FROM CONFIG
|
|
106
119
|
const rawConfigPathIgnores = lintConfigImports
|
|
107
120
|
? [configPath]
|
|
108
121
|
: rawConfigAndImportPaths;
|
|
@@ -118,9 +131,9 @@ skipDetails ||
|
|
|
118
131
|
configPathIgnores
|
|
119
132
|
);
|
|
120
133
|
|
|
121
|
-
// ADDRESSES THE --my-ignores-only FLAG, GIVEN THAT KNOWN IGNORES ARE IGNORED BY DEFAULT
|
|
134
|
+
// ADDRESSES THE --my-ignores-only FLAG (myIgnoresOnly, no longer a flag, GIVEN THAT KNOWN IGNORES ARE IGNORED BY DEFAULT
|
|
122
135
|
|
|
123
|
-
const myIgnoresOnly = commands.indexOf(myIgnoresOnlyFlag) >= 2;
|
|
136
|
+
// const myIgnoresOnly = commands.indexOf(myIgnoresOnlyFlag) >= 2; // NOW FROM CONFIG
|
|
124
137
|
const rawIgnores = [...configPathIgnores, ...passedIgnores];
|
|
125
138
|
const ignores = myIgnoresOnly ? rawIgnores : [...rawIgnores, ...knownIgnores];
|
|
126
139
|
|
|
@@ -176,9 +189,7 @@ switch (coreCommand) {
|
|
|
176
189
|
else
|
|
177
190
|
console.log(
|
|
178
191
|
`If these settings are correct with you, feel free to initiate the command "${resolveRuleName}" to resolve comments, or "${compressRuleName}" to compress them back to their $COMMENT forms. You can also generate the placeholders at their definitions locations with the command "${placeholdersRuleName}".${
|
|
179
|
-
passedConfigPath
|
|
180
|
-
? " (And DON'T FORGET YOUR FLAGS!)"
|
|
181
|
-
: ""
|
|
192
|
+
passedConfigPath ? " (And DON'T FORGET YOUR --config FLAG!)" : ""
|
|
182
193
|
}`
|
|
183
194
|
);
|
|
184
195
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-variables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "A CLI tool for configuring, managing and maintaining JavaScript comments as JavaScript variables.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"jscomments": "./library/index.js",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"library",
|
|
12
12
|
"comments.config.js",
|
|
13
|
-
"comments.config.json"
|
|
13
|
+
"comments.config.json",
|
|
14
|
+
"comments.template.js",
|
|
15
|
+
"comments.example.js"
|
|
14
16
|
],
|
|
15
17
|
"repository": {
|
|
16
18
|
"type": "git",
|
|
@@ -27,7 +29,7 @@
|
|
|
27
29
|
"type": "module",
|
|
28
30
|
"dependencies": {
|
|
29
31
|
"@eslint/markdown": "^6.5.0",
|
|
30
|
-
"comment-variables-resolve-config": "^1.
|
|
32
|
+
"comment-variables-resolve-config": "^1.12.0",
|
|
31
33
|
"eslint": "^9.29.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|