@cherepanov.pavel/shareable-config 2.0.3 → 2.0.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/.gitignore +12 -8
- package/.gitignore-get.js +15 -12
- package/README.md +1 -1
- package/env.json5.set.js +8 -10
- package/modules/eslint-config/configs/json.js +1 -18
- package/modules/eslint-config/rules/javascript/possible-problems.js +1 -1
- package/modules/eslint-config/rules/stylistic/jsFormatting.js +2 -34
- package/modules/shared/constants/index.js +6 -0
- package/modules/shared/utils/communication.js +36 -48
- package/modules/shared/utils/copy-with-override.js +4 -2
- package/modules/shared/utils/env.js +5 -1
- package/modules/shared/utils/file-header.js +1 -1
- package/package.json +2 -1
package/.gitignore
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
|
|
1
|
+
/node_modules/
|
|
2
|
+
/.idea/
|
|
3
3
|
*.local
|
|
4
4
|
|
|
5
5
|
# vue
|
|
6
|
-
dist
|
|
6
|
+
/dist/
|
|
7
7
|
|
|
8
8
|
# nuxt
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/.output/
|
|
10
|
+
/.nuxt/
|
|
11
11
|
|
|
12
12
|
# quasar
|
|
13
|
-
dist
|
|
14
|
-
|
|
15
|
-
quasar.config.*.temporary.compiled*
|
|
13
|
+
/dist/
|
|
14
|
+
/.quasar/
|
|
15
|
+
quasar.config.*.temporary.compiled*
|
|
16
|
+
|
|
17
|
+
# astro
|
|
18
|
+
/dist/
|
|
19
|
+
/.astro/
|
package/.gitignore-get.js
CHANGED
|
@@ -24,14 +24,13 @@ async function getGitignoreFileData(framework) {
|
|
|
24
24
|
|
|
25
25
|
const [
|
|
26
26
|
commonData,
|
|
27
|
-
|
|
27
|
+
...sections
|
|
28
|
+
] = srcFileData.split(/^# /mu);
|
|
28
29
|
|
|
29
30
|
if (!framework) {
|
|
30
|
-
return commonData
|
|
31
|
+
return commonData;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const sections = srcFileData.split(/^#\s*/mu)
|
|
34
|
-
.slice(1);
|
|
35
34
|
const matchedSection = sections.find((section) => {
|
|
36
35
|
const [
|
|
37
36
|
header,
|
|
@@ -39,7 +38,6 @@ async function getGitignoreFileData(framework) {
|
|
|
39
38
|
return (
|
|
40
39
|
header
|
|
41
40
|
.trim()
|
|
42
|
-
.toLowerCase()
|
|
43
41
|
) === framework;
|
|
44
42
|
});
|
|
45
43
|
|
|
@@ -48,14 +46,19 @@ async function getGitignoreFileData(framework) {
|
|
|
48
46
|
header,
|
|
49
47
|
...body
|
|
50
48
|
] = matchedSection.split("\n");
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
.trim()
|
|
55
|
-
|
|
49
|
+
return (
|
|
50
|
+
// eslint-disable-next-line prefer-template
|
|
51
|
+
`${commonData.trim()}\n\n`
|
|
52
|
+
+ `# ${header.trim()}\n`
|
|
53
|
+
+ (
|
|
54
|
+
body
|
|
55
|
+
.join("\n")
|
|
56
|
+
.trim()
|
|
57
|
+
)
|
|
58
|
+
);
|
|
56
59
|
}
|
|
57
|
-
// Если не
|
|
58
|
-
return commonData
|
|
60
|
+
// Если не найдено, только общий контент
|
|
61
|
+
return commonData;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
try {
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ As you'll see further down in this README, the project is flexible and supports
|
|
|
19
19
|
1. **Open the target project.**
|
|
20
20
|
2. **Install the package:**
|
|
21
21
|
```sh
|
|
22
|
-
npm i @cherepanov.pavel/shareable-config
|
|
22
|
+
npm i @cherepanov.pavel/shareable-config -D
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
3. **Copy the config files:**
|
package/env.json5.set.js
CHANGED
|
@@ -4,21 +4,19 @@ import {
|
|
|
4
4
|
askFramework, askOptionsApi, askTypescript,
|
|
5
5
|
} from "./modules/shared/utils/communication.js";
|
|
6
6
|
import {
|
|
7
|
-
getEnvs, setEnvs,
|
|
7
|
+
getEnvs, setEnvs,
|
|
8
8
|
} from "./modules/shared/utils/env.js";
|
|
9
|
-
import {
|
|
10
|
-
eslintFiles,
|
|
11
|
-
} from "./modules/shared/utils/lint.js";
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
const envs = await (
|
|
11
|
+
getEnvs()
|
|
12
|
+
.catch(() => {
|
|
13
|
+
return {
|
|
14
|
+
};
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
17
|
|
|
18
18
|
envs.isRepositoryUseTypescript = await askTypescript();
|
|
19
19
|
envs.repositoryFramework = await askFramework();
|
|
20
20
|
envs.isRepositoryUseOptionsApi = await askOptionsApi();
|
|
21
21
|
|
|
22
22
|
await setEnvs(envs);
|
|
23
|
-
|
|
24
|
-
await eslintFiles(envFileSrc);
|
|
@@ -57,24 +57,7 @@ const COMMON_RULES = {
|
|
|
57
57
|
"jsonc/no-useless-escape": suggestionRules["no-useless-escape"],
|
|
58
58
|
"jsonc/object-curly-newline": [
|
|
59
59
|
jsFormatting["@stylistic/object-curly-newline"][0],
|
|
60
|
-
|
|
61
|
-
"ObjectExpression": {
|
|
62
|
-
multiline: false,
|
|
63
|
-
minProperties: 1,
|
|
64
|
-
},
|
|
65
|
-
"ObjectPattern": {
|
|
66
|
-
multiline: false,
|
|
67
|
-
minProperties: 1,
|
|
68
|
-
},
|
|
69
|
-
"ImportDeclaration": {
|
|
70
|
-
multiline: false,
|
|
71
|
-
minProperties: 1,
|
|
72
|
-
},
|
|
73
|
-
"ExportDeclaration": {
|
|
74
|
-
multiline: false,
|
|
75
|
-
minProperties: 1,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
60
|
+
jsFormatting["@stylistic/object-curly-newline"][1],
|
|
78
61
|
// Object.fromEntries(
|
|
79
62
|
// [
|
|
80
63
|
// "ObjectExpression",
|
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
export default {
|
|
10
10
|
"@stylistic/array-bracket-newline": [
|
|
11
11
|
ERROR,
|
|
12
|
-
|
|
13
|
-
multiline: true,
|
|
14
|
-
minItems: 1,
|
|
15
|
-
},
|
|
12
|
+
"always",
|
|
16
13
|
],
|
|
17
14
|
"@stylistic/array-bracket-spacing": [
|
|
18
15
|
ERROR,
|
|
@@ -226,36 +223,7 @@ export default {
|
|
|
226
223
|
],
|
|
227
224
|
"@stylistic/object-curly-newline": [
|
|
228
225
|
ERROR,
|
|
229
|
-
|
|
230
|
-
"ObjectExpression": {
|
|
231
|
-
multiline: false,
|
|
232
|
-
minProperties: 1,
|
|
233
|
-
},
|
|
234
|
-
"ObjectPattern": {
|
|
235
|
-
multiline: false,
|
|
236
|
-
minProperties: 1,
|
|
237
|
-
},
|
|
238
|
-
"ImportDeclaration": {
|
|
239
|
-
multiline: false,
|
|
240
|
-
minProperties: 1,
|
|
241
|
-
},
|
|
242
|
-
"ExportDeclaration": {
|
|
243
|
-
multiline: false,
|
|
244
|
-
minProperties: 1,
|
|
245
|
-
},
|
|
246
|
-
"TSTypeLiteral": {
|
|
247
|
-
multiline: false,
|
|
248
|
-
minProperties: 1,
|
|
249
|
-
},
|
|
250
|
-
"TSInterfaceBody": {
|
|
251
|
-
multiline: false,
|
|
252
|
-
minProperties: 1,
|
|
253
|
-
},
|
|
254
|
-
"TSEnumBody": {
|
|
255
|
-
multiline: false,
|
|
256
|
-
minProperties: 1,
|
|
257
|
-
},
|
|
258
|
-
},
|
|
226
|
+
"always",
|
|
259
227
|
],
|
|
260
228
|
"@stylistic/object-curly-spacing": [
|
|
261
229
|
ERROR,
|
|
@@ -1,57 +1,45 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
cancel, isCancel, confirm, select,
|
|
3
|
+
} from "@clack/prompts";
|
|
4
|
+
import {
|
|
5
|
+
supportedFrameworks,
|
|
6
|
+
} from "../constants/index.js";
|
|
2
7
|
|
|
3
8
|
export async function askTypescript() {
|
|
4
|
-
return
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
rl.question(
|
|
10
|
-
"Do you use TypeScript? (Enter — no, any characters + Enter — yes):",
|
|
11
|
-
(answer) => {
|
|
12
|
-
rl.close();
|
|
13
|
-
resolve(Boolean(
|
|
14
|
-
answer,
|
|
15
|
-
));
|
|
16
|
-
},
|
|
17
|
-
);
|
|
18
|
-
});
|
|
9
|
+
return unwrapPrompt(confirm({
|
|
10
|
+
message: "Do you use TypeScript?",
|
|
11
|
+
initialValue: true,
|
|
12
|
+
}));
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
export async function askFramework() {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
.trim()
|
|
34
|
-
.toLowerCase(),
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
});
|
|
16
|
+
return unwrapPrompt(select({
|
|
17
|
+
message: "Which framework do you use?",
|
|
18
|
+
options: (
|
|
19
|
+
Object.values(supportedFrameworks)
|
|
20
|
+
.map((value) => {
|
|
21
|
+
return {
|
|
22
|
+
value,
|
|
23
|
+
};
|
|
24
|
+
})
|
|
25
|
+
),
|
|
26
|
+
}));
|
|
39
27
|
}
|
|
40
28
|
|
|
41
29
|
export async function askOptionsApi() {
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
30
|
+
return unwrapPrompt(confirm({
|
|
31
|
+
message: "Do you use the Vue options API?",
|
|
32
|
+
initialValue: false,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function unwrapPrompt(maybeCancelPromise) {
|
|
37
|
+
const result = await maybeCancelPromise;
|
|
38
|
+
|
|
39
|
+
if (isCancel(result)) {
|
|
40
|
+
cancel("✖ Operation cancelled");
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
57
45
|
}
|
|
@@ -17,7 +17,8 @@ export async function copyFile({
|
|
|
17
17
|
} catch {
|
|
18
18
|
await outputFile(destFile, `${getHeader("#")}${srcFileData}`);
|
|
19
19
|
console.info(`${fileLabel} пересоздан`);
|
|
20
|
-
return {
|
|
20
|
+
return {
|
|
21
|
+
};
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// Если файл есть — разбираем оба файла
|
|
@@ -28,7 +29,8 @@ export async function copyFile({
|
|
|
28
29
|
if (!match) {
|
|
29
30
|
await outputFile(destFile, `${getHeader("#")}${srcFileData}`);
|
|
30
31
|
console.info(`${fileLabel} пересоздан`);
|
|
31
|
-
return {
|
|
32
|
+
return {
|
|
33
|
+
};
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
return {
|
|
@@ -6,8 +6,11 @@ import JSON5 from "json5";
|
|
|
6
6
|
import {
|
|
7
7
|
outputFile,
|
|
8
8
|
} from "fs-extra";
|
|
9
|
+
import {
|
|
10
|
+
eslintFiles,
|
|
11
|
+
} from "./lint";
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
const envFileSrc = path.join(process.cwd(), "frontend-configs.env.json5");
|
|
11
14
|
|
|
12
15
|
export async function getEnvs() {
|
|
13
16
|
const srcFileData = await readFile(envFileSrc, "utf8");
|
|
@@ -17,4 +20,5 @@ export async function getEnvs() {
|
|
|
17
20
|
|
|
18
21
|
export async function setEnvs(envObj) {
|
|
19
22
|
await outputFile(envFileSrc, JSON5.stringify(envObj, null, 2));
|
|
23
|
+
await eslintFiles(envFileSrc);
|
|
20
24
|
}
|
|
@@ -9,7 +9,7 @@ const pkg = JSON.parse(await readFile(pkgJsonFileUrl, "utf8"));
|
|
|
9
9
|
export function getHeader(comment = "//") {
|
|
10
10
|
const lines = [
|
|
11
11
|
"This file is generated with",
|
|
12
|
-
|
|
12
|
+
String(pkg.repository?.url || ""),
|
|
13
13
|
`Version: ${pkg.version || ""}`,
|
|
14
14
|
"File may contain override sections, see project README for more details",
|
|
15
15
|
];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cherepanov.pavel/shareable-config",
|
|
3
3
|
"description": "setup for new repositories",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devEngines": {
|
|
7
7
|
"packageManager": {
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"lint:css:fix": "npm run lint:css -- --fix"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
+
"@clack/prompts": "^1.8.1",
|
|
58
59
|
"@eslint/compat": "2.1.0",
|
|
59
60
|
"@stylistic/eslint-plugin": "5.10.0",
|
|
60
61
|
"@stylistic/stylelint-plugin": "5.2.1",
|