comment-variables 0.13.0 → 0.14.1
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.
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
|
+
import { cwd } from "comment-variables-resolve-config";
|
|
5
|
+
|
|
4
6
|
// rule names
|
|
5
7
|
export const resolveRuleName = "resolve";
|
|
6
8
|
export const compressRuleName = "compress";
|
|
7
9
|
export const placeholdersRuleName = "placeholders"; // rule?
|
|
8
10
|
|
|
9
|
-
// current working directory
|
|
10
|
-
export const cwd = process.cwd();
|
|
11
|
-
|
|
12
11
|
// to prevent accidental changes
|
|
13
12
|
export const hasPackageJson = fs.existsSync(path.join(cwd, "package.json"));
|
|
14
13
|
// to prevent irreversible changes
|
package/library/index.js
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
import fs from "fs";
|
|
6
|
+
import url from "url";
|
|
6
7
|
|
|
7
8
|
import resolveConfig, {
|
|
8
9
|
defaultConfigFileName,
|
|
10
|
+
templateFileName,
|
|
11
|
+
exampleFileName,
|
|
9
12
|
configFlag,
|
|
13
|
+
cwd,
|
|
10
14
|
knownIgnores,
|
|
11
15
|
makeResolvedConfigData,
|
|
12
16
|
} from "comment-variables-resolve-config";
|
|
13
17
|
|
|
14
18
|
import {
|
|
15
|
-
cwd,
|
|
16
19
|
hasPackageJson,
|
|
17
20
|
hasGitFolder,
|
|
18
21
|
resolveRuleName,
|
|
@@ -67,7 +70,38 @@ const passedConfig = commands[configFlagIndex + 1];
|
|
|
67
70
|
const passedConfigPath =
|
|
68
71
|
hasConfigFlag && passedConfig ? path.join(cwd, passedConfig) : null;
|
|
69
72
|
// defaults to comments.config.js if no --config flag is set
|
|
70
|
-
|
|
73
|
+
let rawConfigPath = passedConfigPath ?? path.join(cwd, defaultConfigFileName);
|
|
74
|
+
|
|
75
|
+
if (!fs.existsSync(rawConfigPath)) {
|
|
76
|
+
console.log(
|
|
77
|
+
`No Comment Variables config file found at ${rawConfigPath}. Switching to tutorial mode.`
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const templateFilePath = path.join(cwd, templateFileName);
|
|
81
|
+
const exampleFilePath = path.join(cwd, exampleFileName);
|
|
82
|
+
const dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
83
|
+
|
|
84
|
+
if (fs.existsSync(templateFilePath)) {
|
|
85
|
+
console.log(`Proceeding with template file found at ${templateFilePath}.`);
|
|
86
|
+
} else {
|
|
87
|
+
const sourceTemplateFilePath = path.join(
|
|
88
|
+
dirname,
|
|
89
|
+
"../generate.template.js"
|
|
90
|
+
);
|
|
91
|
+
console.log(`Generating template file at ${templateFilePath}.`);
|
|
92
|
+
fs.copyFileSync(sourceTemplateFilePath, templateFilePath);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (fs.existsSync(exampleFilePath)) {
|
|
96
|
+
console.log(`Proceeding with example file found at ${exampleFilePath}.`);
|
|
97
|
+
} else {
|
|
98
|
+
const sourceExampleFilePath = path.join(dirname, "../generate.example.js");
|
|
99
|
+
console.log(`Generating example file at ${exampleFilePath}.`);
|
|
100
|
+
fs.copyFileSync(sourceExampleFilePath, exampleFilePath);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
rawConfigPath = templateFilePath;
|
|
104
|
+
}
|
|
71
105
|
|
|
72
106
|
console.log(`Resolving config at ${rawConfigPath}...`);
|
|
73
107
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "comment-variables",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
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",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@eslint/markdown": "^6.5.0",
|
|
32
|
-
"comment-variables-resolve-config": "^1.12.
|
|
32
|
+
"comment-variables-resolve-config": "^1.12.3",
|
|
33
33
|
"eslint": "^9.29.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/comments.example.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.
|
package/comments.template.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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.
|