@solvro/config 2.0.0-beta.2 → 2.0.0-beta.4
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 +63 -0
- package/dist/adonis-HMBH6E55.js +56 -0
- package/dist/adonis-HMBH6E55.js.map +1 -0
- package/dist/chunk-AQ5RXFKK.js +34 -0
- package/dist/chunk-AQ5RXFKK.js.map +1 -0
- package/dist/chunk-DHQ2VVRM.js +86 -0
- package/dist/chunk-DHQ2VVRM.js.map +1 -0
- package/dist/chunk-HM3MY7J3.js +22 -0
- package/dist/chunk-HM3MY7J3.js.map +1 -0
- package/dist/chunk-J5OUMHDO.js +44 -0
- package/dist/chunk-J5OUMHDO.js.map +1 -0
- package/dist/chunk-OEFF22F3.js +189 -0
- package/dist/chunk-OEFF22F3.js.map +1 -0
- package/dist/cli/index.js +416 -145
- package/dist/cli/index.js.map +1 -1
- package/dist/commitlint/index.js +5 -0
- package/dist/commitlint/index.js.map +1 -1
- package/dist/eslint/index.js +64 -510
- package/dist/eslint/index.js.map +1 -1
- package/dist/nestjs-JMOHWBQG.js +57 -0
- package/dist/nestjs-JMOHWBQG.js.map +1 -0
- package/dist/node-S7MI3CIK.js +27 -0
- package/dist/node-S7MI3CIK.js.map +1 -0
- package/dist/prettier/index.js +5 -0
- package/dist/prettier/index.js.map +1 -1
- package/dist/react-4BBIFFXI.js +2133 -0
- package/dist/react-4BBIFFXI.js.map +1 -0
- package/package.json +54 -47
package/dist/cli/index.js
CHANGED
@@ -1,8 +1,146 @@
|
|
1
|
+
import {
|
2
|
+
init_esm_shims
|
3
|
+
} from "../chunk-J5OUMHDO.js";
|
4
|
+
|
1
5
|
// src/cli/index.ts
|
6
|
+
init_esm_shims();
|
2
7
|
import * as p6 from "@clack/prompts";
|
8
|
+
import { Command } from "commander";
|
3
9
|
import c from "picocolors";
|
4
10
|
|
11
|
+
// package.json
|
12
|
+
var package_default = {
|
13
|
+
name: "@solvro/config",
|
14
|
+
version: "2.0.0-beta.1",
|
15
|
+
description: "Solvro's engineering style guide",
|
16
|
+
keywords: [
|
17
|
+
"eslint",
|
18
|
+
"prettier",
|
19
|
+
"solvro"
|
20
|
+
],
|
21
|
+
homepage: "https://github.com/Solvro/lib-web-solvro-config#readme",
|
22
|
+
bugs: {
|
23
|
+
url: "https://github.com/Solvro/lib-web-solvro-config/issues"
|
24
|
+
},
|
25
|
+
repository: {
|
26
|
+
type: "git",
|
27
|
+
url: "git+https://github.com/Solvro/lib-web-solvro-config.git"
|
28
|
+
},
|
29
|
+
license: "MPL-2.0",
|
30
|
+
type: "module",
|
31
|
+
exports: {
|
32
|
+
"./eslint": {
|
33
|
+
types: "./dist/eslint/index.d.ts",
|
34
|
+
import: "./dist/eslint/index.js",
|
35
|
+
require: "./dist/eslint/index.cjs"
|
36
|
+
},
|
37
|
+
"./prettier": {
|
38
|
+
types: "./dist/prettier/index.d.ts",
|
39
|
+
import: "./dist/prettier/index.js",
|
40
|
+
require: "./dist/prettier/index.cjs"
|
41
|
+
},
|
42
|
+
"./commitlint": {
|
43
|
+
types: "./dist/commitlint/index.d.ts",
|
44
|
+
import: "./dist/commitlint/index.js",
|
45
|
+
require: "./dist/commitlint/index.cjs"
|
46
|
+
}
|
47
|
+
},
|
48
|
+
bin: "./bin/index.js",
|
49
|
+
files: [
|
50
|
+
"dist"
|
51
|
+
],
|
52
|
+
scripts: {
|
53
|
+
build: "tsup",
|
54
|
+
"build:watch": "tsup --watch",
|
55
|
+
cli: "tsx ./src/cli/index.ts",
|
56
|
+
dev: "npx @eslint/config-inspector",
|
57
|
+
format: "prettier --check .",
|
58
|
+
knip: "knip",
|
59
|
+
lint: "eslint .",
|
60
|
+
prepare: "husky || true",
|
61
|
+
prepublish: "npm run build",
|
62
|
+
release: "semantic-release",
|
63
|
+
test: "vitest run",
|
64
|
+
"test:ui": "vitest --ui",
|
65
|
+
"test:watch": "vitest",
|
66
|
+
typecheck: "tsc --noEmit"
|
67
|
+
},
|
68
|
+
"lint-staged": {
|
69
|
+
"*": "prettier -w --ignore-unknown"
|
70
|
+
},
|
71
|
+
prettier: "./dist/prettier/index.js",
|
72
|
+
dependencies: {
|
73
|
+
"@adonisjs/eslint-config": "^2.1.0",
|
74
|
+
"@clack/prompts": "^0.11.0",
|
75
|
+
"@commitlint/config-conventional": "^19.8.1",
|
76
|
+
"@darraghor/eslint-plugin-nestjs-typed": "^6.7.0",
|
77
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
78
|
+
"@eslint/js": "^9.30.1",
|
79
|
+
"@tanstack/eslint-plugin-query": "^5.81.2",
|
80
|
+
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
81
|
+
"@typescript-eslint/eslint-plugin": "^8.35.1",
|
82
|
+
commander: "^14.0.0",
|
83
|
+
"eslint-config-prettier": "^10.1.5",
|
84
|
+
"eslint-plugin-antfu": "^3.1.1",
|
85
|
+
"eslint-plugin-import": "^2.32.0",
|
86
|
+
"eslint-plugin-jsdoc": "^51.3.3",
|
87
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
88
|
+
"eslint-plugin-n": "^17.21.0",
|
89
|
+
"eslint-plugin-react": "^7.37.5",
|
90
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
91
|
+
"eslint-plugin-unicorn": "^59.0.1",
|
92
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
93
|
+
execa: "^9.6.0",
|
94
|
+
"find-up-simple": "^1.0.1",
|
95
|
+
globals: "^16.3.0",
|
96
|
+
"is-interactive": "^2.0.0",
|
97
|
+
"local-pkg": "^1.1.1",
|
98
|
+
picocolors: "^1.1.1",
|
99
|
+
"prettier-plugin-packagejson": "^2.5.18",
|
100
|
+
"prettier-plugin-tailwindcss": "^0.6.13",
|
101
|
+
semver: "^7.7.2",
|
102
|
+
"typescript-eslint": "^8.35.1"
|
103
|
+
},
|
104
|
+
devDependencies: {
|
105
|
+
"@commitlint/cli": "^19.8.1",
|
106
|
+
"@eslint/config-inspector": "^1.1.0",
|
107
|
+
"@next/eslint-plugin-next": "^15.3.5",
|
108
|
+
"@semantic-release/git": "^10.0.1",
|
109
|
+
"@types/node": "^24.0.10",
|
110
|
+
"@types/semver": "^7.7.0",
|
111
|
+
"@vitest/coverage-v8": "^3.2.4",
|
112
|
+
"@vitest/ui": "^3.2.4",
|
113
|
+
eslint: "^9.30.1",
|
114
|
+
"eslint-config-flat-gitignore": "^2.1.0",
|
115
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "^0.3.0",
|
116
|
+
husky: "^9.1.7",
|
117
|
+
jiti: "^2.4.2",
|
118
|
+
knip: "^5.61.3",
|
119
|
+
"lint-staged": "^16.1.2",
|
120
|
+
prettier: "^3.6.2",
|
121
|
+
"semantic-release": "^24.2.6",
|
122
|
+
tsup: "^8.5.0",
|
123
|
+
tsx: "^4.20.3",
|
124
|
+
typescript: "^5.8.3",
|
125
|
+
vitest: "^3.2.4"
|
126
|
+
},
|
127
|
+
peerDependencies: {
|
128
|
+
"@next/eslint-plugin-next": ">=12.3.0 <16.0.0-0"
|
129
|
+
},
|
130
|
+
packageManager: "npm@11.4.2",
|
131
|
+
engines: {
|
132
|
+
node: "^20.19.0 || >=22.12.0"
|
133
|
+
},
|
134
|
+
volta: {
|
135
|
+
node: "22.17.0"
|
136
|
+
},
|
137
|
+
publishConfig: {
|
138
|
+
access: "public"
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
5
142
|
// src/utils/is-git-clean.ts
|
143
|
+
init_esm_shims();
|
6
144
|
import { execSync } from "child_process";
|
7
145
|
function isGitClean() {
|
8
146
|
try {
|
@@ -14,7 +152,8 @@ function isGitClean() {
|
|
14
152
|
}
|
15
153
|
|
16
154
|
// src/utils/package-json.ts
|
17
|
-
|
155
|
+
init_esm_shims();
|
156
|
+
import * as p from "@clack/prompts";
|
18
157
|
import { getPackageInfo, isPackageListed, loadPackageJSON } from "local-pkg";
|
19
158
|
import assert from "assert";
|
20
159
|
import { writeFile } from "fs/promises";
|
@@ -22,28 +161,45 @@ import path from "path";
|
|
22
161
|
import semver from "semver";
|
23
162
|
|
24
163
|
// src/utils/$$.ts
|
25
|
-
|
164
|
+
init_esm_shims();
|
26
165
|
|
27
166
|
// src/utils/git-root.ts
|
167
|
+
init_esm_shims();
|
168
|
+
import { findUpSync } from "find-up-simple";
|
28
169
|
import { execSync as execSync2 } from "child_process";
|
29
170
|
var gitRoot = () => {
|
30
|
-
|
31
|
-
|
171
|
+
try {
|
172
|
+
const root2 = execSync2("git rev-parse --show-toplevel").toString().trim();
|
173
|
+
return root2;
|
174
|
+
} catch {
|
175
|
+
const packageLockPath = findUpSync("package-lock.json");
|
176
|
+
if (packageLockPath !== void 0) {
|
177
|
+
return packageLockPath.replace("/package-lock.json", "");
|
178
|
+
}
|
179
|
+
return process.cwd();
|
180
|
+
}
|
32
181
|
};
|
33
182
|
|
34
183
|
// src/utils/$$.ts
|
35
|
-
var
|
36
|
-
|
37
|
-
|
184
|
+
var cachedExeca = null;
|
185
|
+
var $$ = async (...arguments_) => {
|
186
|
+
if (cachedExeca === null) {
|
187
|
+
const { $ } = await import("execa");
|
188
|
+
cachedExeca = $({
|
189
|
+
cwd: gitRoot()
|
190
|
+
});
|
191
|
+
}
|
192
|
+
return cachedExeca(...arguments_);
|
193
|
+
};
|
38
194
|
|
39
|
-
// src/utils/
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
195
|
+
// src/utils/run-if-interactive.ts
|
196
|
+
init_esm_shims();
|
197
|
+
import isInteractive from "is-interactive";
|
198
|
+
var runIfInteractive = (function_) => {
|
199
|
+
if (isInteractive()) {
|
200
|
+
return function_();
|
201
|
+
}
|
202
|
+
return void 0;
|
47
203
|
};
|
48
204
|
|
49
205
|
// src/utils/package-json.ts
|
@@ -52,7 +208,7 @@ var PackageJson = class {
|
|
52
208
|
async load() {
|
53
209
|
const json = await loadPackageJSON(gitRoot());
|
54
210
|
if (json === null) {
|
55
|
-
|
211
|
+
p.cancel(
|
56
212
|
"Nie znaleziono package.json. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu."
|
57
213
|
);
|
58
214
|
process.exit(1);
|
@@ -64,7 +220,7 @@ var PackageJson = class {
|
|
64
220
|
}
|
65
221
|
async doesSatisfies(package_, version) {
|
66
222
|
await this.load();
|
67
|
-
assert(this.json !== null);
|
223
|
+
assert.ok(this.json !== null);
|
68
224
|
const packageInfo = await getPackageInfo(package_);
|
69
225
|
if (packageInfo?.version === void 0) {
|
70
226
|
return false;
|
@@ -73,21 +229,14 @@ var PackageJson = class {
|
|
73
229
|
}
|
74
230
|
async isESM() {
|
75
231
|
await this.load();
|
76
|
-
assert(this.json !== null);
|
232
|
+
assert.ok(this.json !== null);
|
77
233
|
return this.json.type === "module";
|
78
234
|
}
|
79
235
|
async ensureESM() {
|
80
236
|
if (await this.isESM()) {
|
81
237
|
return;
|
82
238
|
}
|
83
|
-
assert(this.json !== null);
|
84
|
-
const isConfirmed = await polishConfirm({
|
85
|
-
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak type: "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
86
|
-
});
|
87
|
-
if (p2.isCancel(isConfirmed) || !isConfirmed) {
|
88
|
-
p2.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
89
|
-
process.exit(1);
|
90
|
-
}
|
239
|
+
assert.ok(this.json !== null);
|
91
240
|
this.json.type = "module";
|
92
241
|
await this.save();
|
93
242
|
}
|
@@ -119,7 +268,7 @@ var PackageJson = class {
|
|
119
268
|
}
|
120
269
|
async addScriptIfNotExists(name, script) {
|
121
270
|
await this.load();
|
122
|
-
assert(this.json !== null);
|
271
|
+
assert.ok(this.json !== null);
|
123
272
|
if (this.json.scripts?.[name] !== void 0) {
|
124
273
|
return;
|
125
274
|
}
|
@@ -127,32 +276,60 @@ var PackageJson = class {
|
|
127
276
|
this.json.scripts[name] = script;
|
128
277
|
await this.save();
|
129
278
|
}
|
130
|
-
async install(package_,
|
279
|
+
async install(package_, options2) {
|
131
280
|
const isInstalled = await this.hasPackage(package_);
|
132
281
|
if (!isInstalled) {
|
133
|
-
const spinner2 =
|
134
|
-
|
135
|
-
|
136
|
-
|
282
|
+
const spinner2 = p.spinner();
|
283
|
+
runIfInteractive(() => {
|
284
|
+
spinner2.start(`Instalowanie ${package_}`);
|
285
|
+
});
|
286
|
+
await $$`npm i ${options2?.dev === true ? "-D" : ""} ${package_}@latest`;
|
287
|
+
runIfInteractive(() => {
|
288
|
+
spinner2.stop(`${package_} zainstalowany \u{1F60D}`);
|
289
|
+
});
|
137
290
|
await this.load();
|
138
291
|
return;
|
139
292
|
}
|
140
293
|
const info = await getPackageInfo(package_);
|
141
|
-
if (info?.version !== void 0 &&
|
142
|
-
const spinner2 =
|
143
|
-
|
144
|
-
|
145
|
-
|
294
|
+
if (info?.version !== void 0 && options2?.minVersion !== void 0 && !semver.satisfies(info.version, options2.minVersion) || options2?.alwaysUpdate === true) {
|
295
|
+
const spinner2 = p.spinner();
|
296
|
+
runIfInteractive(() => {
|
297
|
+
spinner2.start(`Aktualizowanie ${package_}`);
|
298
|
+
});
|
299
|
+
await $$`npm i ${options2.dev === true ? "-D" : ""} ${package_}@latest`;
|
300
|
+
runIfInteractive(() => {
|
301
|
+
spinner2.stop(`${package_} zaktualizowany \u{1F60D}`);
|
302
|
+
});
|
146
303
|
await this.load();
|
147
304
|
}
|
148
305
|
}
|
306
|
+
async clearInstall() {
|
307
|
+
await $$`npm ci`;
|
308
|
+
}
|
309
|
+
};
|
310
|
+
|
311
|
+
// src/utils/polish-confirm.ts
|
312
|
+
init_esm_shims();
|
313
|
+
import * as p2 from "@clack/prompts";
|
314
|
+
import isInteractive2 from "is-interactive";
|
315
|
+
var polishConfirm = async (props) => {
|
316
|
+
if (!isInteractive2()) {
|
317
|
+
return true;
|
318
|
+
}
|
319
|
+
return p2.confirm({
|
320
|
+
active: "Tak",
|
321
|
+
inactive: "Nie",
|
322
|
+
...props
|
323
|
+
});
|
149
324
|
};
|
150
325
|
|
151
326
|
// src/cli/install-commitlint.ts
|
327
|
+
init_esm_shims();
|
152
328
|
import { writeFile as writeFile2 } from "fs/promises";
|
153
329
|
import path2 from "path";
|
154
330
|
|
155
331
|
// src/cli/install-husky.ts
|
332
|
+
init_esm_shims();
|
156
333
|
import assert2 from "assert";
|
157
334
|
var packageJson = new PackageJson();
|
158
335
|
var installHusky = async () => {
|
@@ -161,13 +338,14 @@ var installHusky = async () => {
|
|
161
338
|
await $$`npx husky init`;
|
162
339
|
}
|
163
340
|
await packageJson.load();
|
164
|
-
assert2(packageJson.json !== null);
|
341
|
+
assert2.ok(packageJson.json !== null);
|
165
342
|
packageJson.json.scripts = packageJson.json.scripts ?? {};
|
166
343
|
packageJson.json.scripts.prepare = `husky || true`;
|
167
344
|
await packageJson.save();
|
168
345
|
};
|
169
346
|
|
170
347
|
// src/cli/templates/commitlint.ts
|
348
|
+
init_esm_shims();
|
171
349
|
var commitlint = () => `export default {
|
172
350
|
extends: ["@solvro/config/commitlint"],
|
173
351
|
};
|
@@ -187,6 +365,7 @@ var installCommitLint = async () => {
|
|
187
365
|
};
|
188
366
|
|
189
367
|
// src/cli/install-eslint.ts
|
368
|
+
init_esm_shims();
|
190
369
|
import * as p3 from "@clack/prompts";
|
191
370
|
import { existsSync } from "fs";
|
192
371
|
import * as fs from "fs/promises";
|
@@ -206,7 +385,7 @@ var eslintConfigNames = [
|
|
206
385
|
"eslint.config.cts"
|
207
386
|
];
|
208
387
|
var packageJson3 = new PackageJson();
|
209
|
-
var installEslint = async () => {
|
388
|
+
var installEslint = async (isNonInteractive2 = false) => {
|
210
389
|
const root2 = gitRoot();
|
211
390
|
await packageJson3.load();
|
212
391
|
await packageJson3.install("eslint", { dev: true, minVersion: ">=9" });
|
@@ -233,14 +412,18 @@ var installEslint = async () => {
|
|
233
412
|
p3.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
|
234
413
|
return;
|
235
414
|
} else {
|
236
|
-
|
237
|
-
|
238
|
-
}
|
239
|
-
|
240
|
-
|
241
|
-
|
415
|
+
if (isNonInteractive2) {
|
416
|
+
await fs.rm(path3.join(root2, eslintConfig));
|
417
|
+
} else {
|
418
|
+
const isConfirmed = await polishConfirm({
|
419
|
+
message: `Znaleziono plik konfiguracyjny Eslint. Czy chcesz go nadpisa\u0107?`
|
420
|
+
});
|
421
|
+
if (p3.isCancel(isConfirmed) || !isConfirmed) {
|
422
|
+
p3.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
|
423
|
+
process.exit(1);
|
424
|
+
}
|
425
|
+
await fs.rm(path3.join(root2, eslintConfig));
|
242
426
|
}
|
243
|
-
await fs.rm(path3.join(root2, eslintConfig));
|
244
427
|
}
|
245
428
|
}
|
246
429
|
const isESM = await packageJson3.isESM();
|
@@ -256,12 +439,17 @@ export default solvro();
|
|
256
439
|
};
|
257
440
|
|
258
441
|
// src/cli/install-ga.ts
|
442
|
+
init_esm_shims();
|
259
443
|
import * as p4 from "@clack/prompts";
|
260
444
|
import { existsSync as existsSync2 } from "fs";
|
261
445
|
import * as fs2 from "fs/promises";
|
262
446
|
import path4 from "path";
|
263
447
|
|
448
|
+
// src/cli/templates/adonis-ci.ts
|
449
|
+
init_esm_shims();
|
450
|
+
|
264
451
|
// src/cli/templates/commit-lint-ci.ts
|
452
|
+
init_esm_shims();
|
265
453
|
var commitLintCi = () => `
|
266
454
|
- name: Check commit name
|
267
455
|
if: github.event_name == 'pull_request'
|
@@ -323,6 +511,7 @@ ${withCommitlint ? commitLintCi() : ""}
|
|
323
511
|
if: always()`;
|
324
512
|
|
325
513
|
// src/cli/templates/adonis-ci-migrations.ts
|
514
|
+
init_esm_shims();
|
326
515
|
var adonisMigrationsCi = () => `name: Migration check
|
327
516
|
|
328
517
|
on:
|
@@ -374,6 +563,7 @@ jobs:
|
|
374
563
|
`;
|
375
564
|
|
376
565
|
// src/cli/templates/dependabot.ts
|
566
|
+
init_esm_shims();
|
377
567
|
var dependabot = () => `version: 2
|
378
568
|
updates:
|
379
569
|
- package-ecosystem: "npm"
|
@@ -385,6 +575,7 @@ updates:
|
|
385
575
|
`;
|
386
576
|
|
387
577
|
// src/cli/templates/nestjs-ci.ts
|
578
|
+
init_esm_shims();
|
388
579
|
var nestjsCi = ({
|
389
580
|
nodeVersion,
|
390
581
|
withCommitlint
|
@@ -438,6 +629,7 @@ ${withCommitlint ? commitLintCi() : ""}
|
|
438
629
|
if: always()`;
|
439
630
|
|
440
631
|
// src/cli/templates/react-ci.ts
|
632
|
+
init_esm_shims();
|
441
633
|
var reactCi = ({
|
442
634
|
nodeVersion,
|
443
635
|
withCommitlint
|
@@ -531,12 +723,13 @@ var installGithubActions = async () => {
|
|
531
723
|
};
|
532
724
|
|
533
725
|
// src/cli/install-lint-staged.ts
|
726
|
+
init_esm_shims();
|
534
727
|
import assert3 from "assert";
|
535
728
|
import { writeFile as writeFile5 } from "fs/promises";
|
536
729
|
var packageJson5 = new PackageJson();
|
537
730
|
var installLintStaged = async () => {
|
538
731
|
await packageJson5.load();
|
539
|
-
assert3(packageJson5.json !== null);
|
732
|
+
assert3.ok(packageJson5.json !== null);
|
540
733
|
await installHusky();
|
541
734
|
await packageJson5.install("lint-staged", { dev: true });
|
542
735
|
await writeFile5(".husky/pre-commit", "npx lint-staged\n");
|
@@ -547,6 +740,7 @@ var installLintStaged = async () => {
|
|
547
740
|
};
|
548
741
|
|
549
742
|
// src/cli/install-prettier.ts
|
743
|
+
init_esm_shims();
|
550
744
|
import * as p5 from "@clack/prompts";
|
551
745
|
import assert4 from "assert";
|
552
746
|
import { existsSync as existsSync3 } from "fs";
|
@@ -567,10 +761,10 @@ var prettierConfigNames = [
|
|
567
761
|
"prettier.config.cts"
|
568
762
|
];
|
569
763
|
var packageJson6 = new PackageJson();
|
570
|
-
var installPrettier = async () => {
|
764
|
+
var installPrettier = async (isNonInteractive2 = false) => {
|
571
765
|
const root2 = gitRoot();
|
572
766
|
await packageJson6.load();
|
573
|
-
assert4(packageJson6.json !== null);
|
767
|
+
assert4.ok(packageJson6.json !== null);
|
574
768
|
await packageJson6.install("prettier", { dev: true, minVersion: ">=3" });
|
575
769
|
const prettierConfig = prettierConfigNames.find(
|
576
770
|
(configName) => existsSync3(path5.join(root2, configName))
|
@@ -581,15 +775,21 @@ var installPrettier = async () => {
|
|
581
775
|
p5.note("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
|
582
776
|
return;
|
583
777
|
}
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
778
|
+
if (isNonInteractive2) {
|
779
|
+
for (const configName of prettierConfigNames) {
|
780
|
+
await fs3.rm(path5.join(root2, configName)).catch(() => null);
|
781
|
+
}
|
782
|
+
} else {
|
783
|
+
const isConfirmed = await polishConfirm({
|
784
|
+
message: `Znaleziono konfiguracj\u0119 Prettiera. Czy chcesz j\u0105 nadpisa\u0107?`
|
785
|
+
});
|
786
|
+
if (p5.isCancel(isConfirmed) || !isConfirmed) {
|
787
|
+
p5.cancel("Usu\u0144 konfiguracje Prettiera i spr\xF3buj ponownie.");
|
788
|
+
process.exit(1);
|
789
|
+
}
|
790
|
+
for (const configName of prettierConfigNames) {
|
791
|
+
await fs3.rm(path5.join(root2, configName)).catch(() => null);
|
792
|
+
}
|
593
793
|
}
|
594
794
|
}
|
595
795
|
packageJson6.json.prettier = solvroPrettierPath;
|
@@ -598,100 +798,171 @@ var installPrettier = async () => {
|
|
598
798
|
};
|
599
799
|
|
600
800
|
// src/cli/index.ts
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
801
|
+
var program = new Command();
|
802
|
+
program.name("@solvro/config").description("Solvro's engineering style guide setup").version(package_default.version).option("-f, --force", "Skip git clean check", false).option("--eslint", "Install ESLint configuration", false).option("--prettier", "Install Prettier configuration", false).option("--gh-action", "Install GitHub Actions", false).option("--commitlint", "Install Commitlint configuration", false).option("-a, --all", "Install all tools", false);
|
803
|
+
program.parse();
|
804
|
+
var options = program.opts();
|
805
|
+
var isNonInteractive = process.argv.length > 2;
|
806
|
+
async function main() {
|
807
|
+
if (!isNonInteractive) {
|
808
|
+
p6.intro(c.bold(c.bgBlue(" @solvro/config ")));
|
609
809
|
}
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
810
|
+
if (options.force !== true && !isGitClean()) {
|
811
|
+
if (isNonInteractive) {
|
812
|
+
console.error(
|
813
|
+
"Git repository has uncommitted changes. Use --force to bypass this check."
|
814
|
+
);
|
815
|
+
process.exit(1);
|
816
|
+
}
|
817
|
+
const isConfirmed = await polishConfirm({
|
818
|
+
message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
|
819
|
+
});
|
820
|
+
if (p6.isCancel(isConfirmed) || !isConfirmed) {
|
821
|
+
p6.cancel("Zapisz zmiany w Git i spr\xF3buj ponownie.");
|
822
|
+
process.exit(1);
|
823
|
+
}
|
620
824
|
}
|
621
|
-
|
622
|
-
|
623
|
-
if (
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
825
|
+
const packageJson7 = new PackageJson();
|
826
|
+
const projectType = await packageJson7.getProjectType();
|
827
|
+
if (!isNonInteractive) {
|
828
|
+
if (projectType === "adonis") {
|
829
|
+
const isConfirmed = await polishConfirm({
|
830
|
+
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 Adonisa. Czy to si\u0119 zgadza?`
|
831
|
+
});
|
832
|
+
if (p6.isCancel(isConfirmed) || !isConfirmed) {
|
833
|
+
p6.cancel("Zg\u0142o\u015B b\u0142\u0105d na GitHubie :(, a my spr\xF3bujemy pom\xF3c.");
|
834
|
+
process.exit(1);
|
835
|
+
}
|
836
|
+
}
|
837
|
+
if (projectType === "react") {
|
838
|
+
const isConfirmed = await polishConfirm({
|
839
|
+
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 Reacta. Czy to si\u0119 zgadza?`
|
840
|
+
});
|
841
|
+
if (p6.isCancel(isConfirmed)) {
|
842
|
+
p6.cancel("\u{1F621}");
|
843
|
+
process.exit(1);
|
844
|
+
}
|
845
|
+
if (!isConfirmed) {
|
846
|
+
p6.cancel("Zg\u0142o\u015B b\u0142\u0105d na GitHubie :(, a my spr\xF3bujemy pom\xF3c.");
|
847
|
+
process.exit(1);
|
848
|
+
}
|
849
|
+
}
|
850
|
+
if (projectType === "nestjs") {
|
851
|
+
const isConfirmed = await polishConfirm({
|
852
|
+
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 NestJsa. Czy to si\u0119 zgadza?`
|
853
|
+
});
|
854
|
+
if (p6.isCancel(isConfirmed)) {
|
855
|
+
p6.cancel("\u{1F621}");
|
856
|
+
process.exit(1);
|
857
|
+
}
|
858
|
+
}
|
859
|
+
if (projectType === "node") {
|
860
|
+
p6.cancel(
|
861
|
+
"Nie znaleziono ani Adonisa, Reacta, ani NestJsa. Musisz r\u0119cznie konfigurowa\u0107 projekt."
|
862
|
+
);
|
863
|
+
process.exit(1);
|
864
|
+
}
|
630
865
|
}
|
631
|
-
if (
|
632
|
-
|
633
|
-
|
866
|
+
if (projectType === "adonis" || projectType === "react") {
|
867
|
+
if (isNonInteractive) {
|
868
|
+
await packageJson7.ensureESM();
|
869
|
+
} else {
|
870
|
+
if (!await packageJson7.isESM()) {
|
871
|
+
const isConfirmed = await polishConfirm({
|
872
|
+
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak type: "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
873
|
+
});
|
874
|
+
if (p6.isCancel(isConfirmed) || !isConfirmed) {
|
875
|
+
p6.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
876
|
+
process.exit(1);
|
877
|
+
}
|
878
|
+
await packageJson7.ensureESM();
|
879
|
+
}
|
880
|
+
}
|
634
881
|
}
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
882
|
+
let toolsToInstall = [];
|
883
|
+
if (options.all === true) {
|
884
|
+
toolsToInstall = ["eslint", "prettier", "gh-action", "commitlint"];
|
885
|
+
} else if (isNonInteractive) {
|
886
|
+
if (options.eslint === true) {
|
887
|
+
toolsToInstall.push("eslint");
|
888
|
+
}
|
889
|
+
if (options.prettier === true) {
|
890
|
+
toolsToInstall.push("prettier");
|
891
|
+
}
|
892
|
+
if (options.ghAction === true) {
|
893
|
+
toolsToInstall.push("gh-action");
|
894
|
+
}
|
895
|
+
if (options.commitlint === true) {
|
896
|
+
toolsToInstall.push("commitlint");
|
897
|
+
}
|
898
|
+
if (toolsToInstall.length === 0) {
|
899
|
+
console.error(
|
900
|
+
"No tools specified. Use --eslint, --prettier, --gh-action, --commitlint, or --all"
|
901
|
+
);
|
902
|
+
process.exit(1);
|
903
|
+
}
|
904
|
+
} else {
|
905
|
+
const additionalTools = await p6.multiselect({
|
906
|
+
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${c.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
|
907
|
+
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
908
|
+
options: [
|
909
|
+
{
|
910
|
+
value: "eslint",
|
911
|
+
label: c.bold(c.blueBright("ESLint")),
|
912
|
+
hint: "sprawdzanie jako\u015Bci kodu"
|
913
|
+
},
|
914
|
+
{
|
915
|
+
value: "prettier",
|
916
|
+
label: c.bold(c.yellowBright("Prettier")),
|
917
|
+
hint: "formatowanie"
|
918
|
+
},
|
919
|
+
{
|
920
|
+
value: "gh-action",
|
921
|
+
label: c.bold("GitHub Actions"),
|
922
|
+
hint: "automatyczne testy na Githubie"
|
923
|
+
},
|
924
|
+
{
|
925
|
+
value: "commitlint",
|
926
|
+
label: c.bold("Commitlint"),
|
927
|
+
hint: "walidacja tre\u015Bci commit\xF3w"
|
928
|
+
}
|
929
|
+
],
|
930
|
+
required: false
|
931
|
+
});
|
932
|
+
if (p6.isCancel(additionalTools) || additionalTools.length === 0) {
|
933
|
+
p6.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
934
|
+
process.exit(1);
|
935
|
+
}
|
936
|
+
toolsToInstall = additionalTools;
|
937
|
+
}
|
938
|
+
await packageJson7.install("@solvro/config", {
|
939
|
+
dev: true,
|
940
|
+
alwaysUpdate: !isNonInteractive
|
640
941
|
});
|
641
|
-
if (
|
642
|
-
|
643
|
-
|
942
|
+
if (toolsToInstall.includes("eslint")) {
|
943
|
+
await installEslint(isNonInteractive);
|
944
|
+
}
|
945
|
+
if (toolsToInstall.includes("prettier")) {
|
946
|
+
await installPrettier(isNonInteractive);
|
947
|
+
await installLintStaged();
|
948
|
+
}
|
949
|
+
if (toolsToInstall.includes("commitlint")) {
|
950
|
+
await installCommitLint();
|
951
|
+
}
|
952
|
+
if (toolsToInstall.includes("gh-action")) {
|
953
|
+
await installGithubActions();
|
954
|
+
}
|
955
|
+
await packageJson7.clearInstall();
|
956
|
+
if (isNonInteractive) {
|
957
|
+
console.log("\u2705 Configuration completed successfully!");
|
958
|
+
} else {
|
959
|
+
p6.outro("\u2705 Configuration completed successfully!");
|
644
960
|
}
|
645
961
|
}
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
);
|
650
|
-
process.exit(1);
|
651
|
-
}
|
652
|
-
var additionalTools = await p6.multiselect({
|
653
|
-
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${c.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
|
654
|
-
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
655
|
-
options: [
|
656
|
-
{
|
657
|
-
value: "eslint",
|
658
|
-
label: c.bold(c.blueBright("ESLint")),
|
659
|
-
hint: "sprawdzanie jako\u015Bci kodu"
|
660
|
-
},
|
661
|
-
{
|
662
|
-
value: "prettier",
|
663
|
-
label: c.bold(c.yellowBright("Prettier")),
|
664
|
-
hint: "formatowanie"
|
665
|
-
},
|
666
|
-
{
|
667
|
-
value: "gh-action",
|
668
|
-
label: c.bold("GitHub Actions"),
|
669
|
-
hint: "automatyczne testy na Githubie"
|
670
|
-
},
|
671
|
-
{
|
672
|
-
value: "commitlint",
|
673
|
-
label: c.bold("Commitlint"),
|
674
|
-
hint: "walidacja tre\u015Bci commit\xF3w"
|
675
|
-
}
|
676
|
-
],
|
677
|
-
required: false
|
678
|
-
});
|
679
|
-
if (p6.isCancel(additionalTools) || additionalTools.length === 0) {
|
680
|
-
p6.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
962
|
+
try {
|
963
|
+
await main();
|
964
|
+
} catch (error) {
|
965
|
+
console.error("An error occurred:", error);
|
681
966
|
process.exit(1);
|
682
967
|
}
|
683
|
-
await packageJson7.install("@solvro/config", { dev: true, alwaysUpdate: true });
|
684
|
-
if (additionalTools.includes("eslint")) {
|
685
|
-
await installEslint();
|
686
|
-
}
|
687
|
-
if (additionalTools.includes("prettier")) {
|
688
|
-
await installPrettier();
|
689
|
-
await installLintStaged();
|
690
|
-
}
|
691
|
-
if (additionalTools.includes("commitlint")) {
|
692
|
-
await installCommitLint();
|
693
|
-
}
|
694
|
-
if (additionalTools.includes("gh-action")) {
|
695
|
-
await installGithubActions();
|
696
|
-
}
|
697
968
|
//# sourceMappingURL=index.js.map
|