@solvro/config 1.9.0 → 1.10.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.
package/dist/cli/index.js CHANGED
@@ -1,46 +1,34 @@
1
1
  // src/cli/index.ts
2
2
  import * as p6 from "@clack/prompts";
3
- import { $ as $4 } from "execa";
4
- import { isPackageListed as isPackageListed2 } from "local-pkg";
5
3
  import c from "picocolors";
6
4
 
7
- // src/utils/get-project-type.ts
8
- import { isPackageExists } from "local-pkg";
9
- var getProjectType = () => {
10
- const isAdonis = isPackageExists("@adonisjs/core");
11
- const isNext = isPackageExists("next");
12
- if (isNext && isAdonis) {
13
- throw new Error(
14
- "You can't use both Adonis and Next.js in the same project"
15
- );
16
- }
17
- if (isAdonis) {
18
- return "adonis";
19
- }
20
- if (isNext) {
21
- return "next";
22
- }
23
- return "node";
24
- };
25
-
26
- // src/utils/git-root.ts
27
- import { execSync } from "node:child_process";
28
- var gitRoot = () => {
29
- const root = execSync("git rev-parse --show-toplevel").toString().trim();
30
- return root;
31
- };
32
-
33
5
  // src/utils/is-git-clean.ts
34
- import { execSync as execSync2 } from "node:child_process";
6
+ import { execSync } from "node:child_process";
35
7
  function isGitClean() {
36
8
  try {
37
- execSync2("git diff-index --quiet HEAD --");
9
+ execSync("git diff-index --quiet HEAD --");
38
10
  return true;
39
11
  } catch {
40
12
  return false;
41
13
  }
42
14
  }
43
15
 
16
+ // src/utils/package-json.ts
17
+ import * as p2 from "@clack/prompts";
18
+ import { $ } from "execa";
19
+ import { getPackageInfo, isPackageListed, loadPackageJSON } from "local-pkg";
20
+ import assert from "node:assert";
21
+ import { writeFile } from "node:fs/promises";
22
+ import path from "node:path";
23
+ import semver from "semver";
24
+
25
+ // src/utils/git-root.ts
26
+ import { execSync as execSync2 } from "node:child_process";
27
+ var gitRoot = () => {
28
+ const root2 = execSync2("git rev-parse --show-toplevel").toString().trim();
29
+ return root2;
30
+ };
31
+
44
32
  // src/utils/polish-confirm.ts
45
33
  import * as p from "@clack/prompts";
46
34
  var polishConfirm = async (props) => {
@@ -51,17 +39,144 @@ var polishConfirm = async (props) => {
51
39
  });
52
40
  };
53
41
 
54
- // src/cli/install-eslint.ts
55
- import * as p2 from "@clack/prompts";
56
- import { $ } from "execa";
57
- import { getPackageInfo } from "local-pkg";
58
- import { existsSync } from "node:fs";
59
- import * as fs from "node:fs/promises";
60
- import path from "node:path";
61
- import semver from "semver";
42
+ // src/utils/package-json.ts
62
43
  var $$ = $({
63
44
  cwd: gitRoot()
64
45
  });
46
+ var PackageJson = class {
47
+ json = null;
48
+ async load() {
49
+ const json = await loadPackageJSON(gitRoot());
50
+ if (json === null) {
51
+ p2.cancel(
52
+ "Nie znaleziono package.json. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu."
53
+ );
54
+ process.exit(1);
55
+ }
56
+ this.json = json;
57
+ }
58
+ hasPackage(pkg) {
59
+ return isPackageListed(pkg);
60
+ }
61
+ async doesSatisfies(pkg, version) {
62
+ await this.load();
63
+ assert(this.json !== null);
64
+ if (this.json.dependencies?.[pkg] === void 0) {
65
+ return false;
66
+ }
67
+ return semver.satisfies(this.json.dependencies[pkg], version);
68
+ }
69
+ async ensureESM() {
70
+ await this.load();
71
+ assert(this.json !== null);
72
+ if (this.json.type === "module") {
73
+ return;
74
+ }
75
+ const isConfirmed = await polishConfirm({
76
+ message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak type: "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
77
+ });
78
+ if (p2.isCancel(isConfirmed) || !isConfirmed) {
79
+ p2.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
80
+ process.exit(1);
81
+ }
82
+ this.json.type = "module";
83
+ await this.save();
84
+ }
85
+ async getProjectType() {
86
+ const isAdonis = await isPackageListed("@adonisjs/core");
87
+ const isNext = await isPackageListed("next");
88
+ if (isNext && isAdonis) {
89
+ throw new Error(
90
+ "You can't use both Adonis and Next.js in the same project"
91
+ );
92
+ }
93
+ if (isAdonis) {
94
+ return "adonis";
95
+ }
96
+ if (isNext) {
97
+ return "next";
98
+ }
99
+ return "node";
100
+ }
101
+ async save() {
102
+ await writeFile(
103
+ path.join(gitRoot(), "package.json"),
104
+ JSON.stringify(this.json, null, 2)
105
+ );
106
+ }
107
+ async addScriptIfNotExists(name, script) {
108
+ await this.load();
109
+ assert(this.json !== null);
110
+ if (this.json.scripts?.[name] !== void 0) {
111
+ return;
112
+ }
113
+ this.json.scripts = this.json.scripts ?? {};
114
+ this.json.scripts[name] = script;
115
+ await this.save();
116
+ }
117
+ async install(pkg, options) {
118
+ const info = await getPackageInfo(pkg);
119
+ if (info?.version !== void 0 && options?.minVersion !== void 0) {
120
+ if (!semver.satisfies(info.version, options.minVersion)) {
121
+ const spinner3 = p2.spinner();
122
+ spinner3.start(`Aktualizowanie ${pkg}`);
123
+ await $$`npm i ${options.dev === true ? "-D" : ""}@latest ${pkg}`;
124
+ spinner3.stop(`${pkg} zaktualizowany \u{1F60D}`);
125
+ await this.load();
126
+ return;
127
+ } else {
128
+ return;
129
+ }
130
+ }
131
+ if (info !== void 0) {
132
+ return;
133
+ }
134
+ const spinner2 = p2.spinner();
135
+ spinner2.start(`Instalowanie ${pkg}`);
136
+ await $$`npm i ${options?.dev === true ? "-D" : ""}@latest ${pkg}`;
137
+ spinner2.stop(`${pkg} zainstalowany \u{1F60D}`);
138
+ await this.load();
139
+ }
140
+ };
141
+
142
+ // src/cli/install-commitlint.ts
143
+ import { writeFile as writeFile2 } from "fs/promises";
144
+ import path2 from "path";
145
+
146
+ // src/utils/$$.ts
147
+ import { $ as $2 } from "execa";
148
+ var $$2 = $2({
149
+ cwd: gitRoot()
150
+ });
151
+
152
+ // src/cli/templates/commitlint.ts
153
+ var commitlint = () => `export default {
154
+ extends: ["@solvro/config/commitlint"],
155
+ };
156
+ `;
157
+
158
+ // src/cli/install-commitlint.ts
159
+ var root = gitRoot();
160
+ var packageJson = new PackageJson();
161
+ var installCommitLint = async () => {
162
+ if (!await packageJson.hasPackage("husky")) {
163
+ await packageJson.install("husky", { dev: true });
164
+ await $$2`npx husky init`;
165
+ }
166
+ await packageJson.install("@commitlint/cli", { dev: true });
167
+ await packageJson.install("@commitlint/config-conventional", { dev: true });
168
+ await writeFile2(
169
+ path2.join(root, ".husky/commit-msg"),
170
+ 'npx commitlint --edit "$1"\n'
171
+ );
172
+ await writeFile2(path2.join(root, ".commitlintrc.js"), commitlint());
173
+ };
174
+
175
+ // src/cli/install-eslint.ts
176
+ import * as p3 from "@clack/prompts";
177
+ import { existsSync } from "node:fs";
178
+ import * as fs from "node:fs/promises";
179
+ import path3 from "node:path";
65
180
  var eslintConfigNames = [
66
181
  ".eslintrc.js",
67
182
  ".eslintrc.cjs",
@@ -76,75 +191,70 @@ var eslintConfigNames = [
76
191
  "eslint.config.mts",
77
192
  "eslint.config.cts"
78
193
  ];
194
+ var packageJson2 = new PackageJson();
79
195
  var installEslint = async () => {
80
- const root = gitRoot();
81
- const eslint = await getPackageInfo("eslint");
82
- if (typeof eslint?.version !== "string") {
83
- const isConfirmed = await polishConfirm({
84
- message: `Eslint nie jest zainstalowany. Czy chcesz go zainstalowa\u0107?`
85
- });
86
- if (p2.isCancel(isConfirmed) || !isConfirmed) {
87
- p2.cancel("Zainstaluj Eslint i spr\xF3buj ponownie.");
88
- process.exit(1);
89
- }
90
- const spinner4 = p2.spinner();
91
- spinner4.start("Instalowanie Eslint");
92
- await $$`npm i -D eslint`;
93
- spinner4.stop("Eslint zainstalowany");
94
- } else if (!semver.satisfies(eslint.version, ">=9")) {
95
- const isConfirmed = await polishConfirm({
96
- message: `Eslint jest zainstalowany, ale trzeba go zaktualizowa\u0107. Czy chcesz zaktualizowa\u0107?`
97
- });
98
- if (p2.isCancel(isConfirmed) || !isConfirmed) {
99
- p2.cancel("Zaktualizuj Eslint i spr\xF3buj ponownie.");
196
+ const root2 = gitRoot();
197
+ await packageJson2.load();
198
+ await packageJson2.install("eslint", { dev: true, minVersion: ">=9" });
199
+ const type = await packageJson2.getProjectType();
200
+ if (type === "next") {
201
+ const is15 = await packageJson2.doesSatisfies("next", ">=15");
202
+ if (!is15) {
203
+ p3.cancel(
204
+ "Next.js musi by\u0107 w conajmniej wersji 15. Zaktualizuj Next.js i spr\xF3buj ponownie.\nWi\u0119cej informacji tutaj: https://nextjs.org/docs/app/building-your-application/upgrading/version-15"
205
+ );
100
206
  process.exit(1);
101
207
  }
102
- const spinner4 = p2.spinner();
103
- spinner4.start("Aktualizowanie Eslinta");
104
- await $$`npm i -D eslint@latest`;
105
- spinner4.stop("Eslint zaktualizowany");
208
+ await packageJson2.install("@next/eslint-plugin-next", { dev: true });
106
209
  }
107
210
  const eslintConfig = eslintConfigNames.find(
108
- (configName) => existsSync(path.join(root, configName))
211
+ (configName) => existsSync(path3.join(root2, configName))
109
212
  );
110
213
  if (eslintConfig !== void 0) {
111
214
  const eslintContent = await fs.readFile(
112
- path.join(root, eslintConfig),
215
+ path3.join(root2, eslintConfig),
113
216
  "utf-8"
114
217
  );
115
218
  if (eslintContent.includes("export default solvro(")) {
116
- p2.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
219
+ p3.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
117
220
  return;
118
221
  } else {
119
222
  const isConfirmed = await polishConfirm({
120
223
  message: `Znaleziono plik konfiguracyjny Eslint. Czy chcesz go nadpisa\u0107?`
121
224
  });
122
- if (p2.isCancel(isConfirmed) || !isConfirmed) {
123
- p2.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
225
+ if (p3.isCancel(isConfirmed) || !isConfirmed) {
226
+ p3.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
124
227
  process.exit(1);
125
228
  }
126
- await fs.rm(path.join(root, eslintConfig));
229
+ await fs.rm(path3.join(root2, eslintConfig));
127
230
  }
128
231
  }
129
232
  await fs.writeFile(
130
- path.join(gitRoot(), "eslint.config.js"),
233
+ path3.join(gitRoot(), "eslint.config.js"),
131
234
  `import { solvro } from "@solvro/config/eslint";
132
235
 
133
236
  export default solvro();
134
237
  `
135
238
  );
136
- p2.note("Plik konfiguracyjny Eslint zosta\u0142 utworzony.");
239
+ p3.note("Plik konfiguracyjny Eslint zosta\u0142 utworzony.");
137
240
  };
138
241
 
139
242
  // src/cli/install-ga.ts
140
- import * as p3 from "@clack/prompts";
141
- import { loadPackageJSON } from "local-pkg";
243
+ import * as p4 from "@clack/prompts";
142
244
  import { existsSync as existsSync2 } from "node:fs";
143
245
  import * as fs2 from "node:fs/promises";
144
- import path2 from "node:path";
246
+ import path4 from "node:path";
247
+
248
+ // src/cli/templates/commit-lint-ci.ts
249
+ var commitLintCi = () => ` - name: Run commitlint check
250
+ run: npx commitlint -f \${{ github.event.pull_request.base.sha }}
251
+ `;
145
252
 
146
253
  // src/cli/templates/adonis-ci.ts
147
- var adonisCi = ({ nodeVersion }) => `name: CI
254
+ var adonisCi = ({
255
+ nodeVersion,
256
+ withCommitlint
257
+ }) => `name: CI
148
258
 
149
259
  on:
150
260
  push:
@@ -171,7 +281,7 @@ jobs:
171
281
  run: |
172
282
  cp .env.example .env
173
283
  node ace generate:key
174
-
284
+ ${withCommitlint ? commitLintCi() : ""}
175
285
  - name: Run prettier
176
286
  run: npm run format:check
177
287
  if: always()
@@ -204,7 +314,10 @@ updates:
204
314
  `;
205
315
 
206
316
  // src/cli/templates/next-ci.ts
207
- var nextCi = ({ nodeVersion }) => `name: CI
317
+ var nextCi = ({
318
+ nodeVersion,
319
+ withCommitlint
320
+ }) => `name: CI
208
321
 
209
322
  on:
210
323
  push:
@@ -226,7 +339,7 @@ jobs:
226
339
 
227
340
  - name: Install dependencies
228
341
  run: npm ci
229
-
342
+ ${withCommitlint ? commitLintCi() : ""}
230
343
  - name: Format check
231
344
  run: npm run format:check
232
345
  if: always()
@@ -236,116 +349,72 @@ jobs:
236
349
  if: always()`;
237
350
 
238
351
  // src/cli/install-ga.ts
352
+ var packageJson3 = new PackageJson();
239
353
  var installGithubActions = async () => {
240
- const root = gitRoot();
241
- const ghWorkflowsDir = path2.join(root, ".github/workflows");
354
+ const root2 = gitRoot();
355
+ await packageJson3.load();
356
+ const ghWorkflowsDir = path4.join(root2, ".github/workflows");
242
357
  await fs2.mkdir(ghWorkflowsDir, { recursive: true });
243
- const type = getProjectType();
358
+ const type = await packageJson3.getProjectType();
359
+ const withCommitlint = await packageJson3.hasPackage("@commitlint/cli");
244
360
  if (type === "adonis") {
245
- if (!existsSync2(path2.join(root, ".env.example"))) {
246
- p3.cancel(
361
+ if (!existsSync2(path4.join(root2, ".env.example"))) {
362
+ p4.cancel(
247
363
  "Nie znaleziono pliku .env.example. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu Adonisa."
248
364
  );
249
365
  process.exit(1);
250
366
  }
251
367
  await fs2.writeFile(
252
- path2.join(ghWorkflowsDir, "ci.yml"),
368
+ path4.join(ghWorkflowsDir, "ci.yml"),
253
369
  adonisCi({
254
- nodeVersion: "22"
370
+ nodeVersion: "22",
371
+ withCommitlint
255
372
  })
256
373
  );
257
374
  }
258
375
  if (type === "next") {
259
376
  await fs2.writeFile(
260
- path2.join(ghWorkflowsDir, "ci.yml"),
377
+ path4.join(ghWorkflowsDir, "ci.yml"),
261
378
  nextCi({
262
- nodeVersion: "22"
379
+ nodeVersion: "22",
380
+ withCommitlint
263
381
  })
264
382
  );
265
383
  }
266
- if (!existsSync2(path2.join(root, ".github/dependabot.yml"))) {
267
- await fs2.writeFile(path2.join(root, ".github/dependabot.yml"), dependabot());
384
+ if (!existsSync2(path4.join(root2, ".github/dependabot.yml"))) {
385
+ await fs2.writeFile(path4.join(root2, ".github/dependabot.yml"), dependabot());
268
386
  }
269
- const packageJson = await loadPackageJSON(root);
270
- if (packageJson === null) {
271
- p3.cancel(
272
- "Nie znaleziono package.json. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu."
273
- );
274
- process.exit(1);
275
- }
276
- packageJson.scripts = packageJson.scripts ?? {};
277
- if (!packageJson.scripts["format:check"]) {
278
- packageJson.scripts["format:check"] = "prettier --check .";
279
- }
280
- if (!packageJson.scripts.lint) {
281
- packageJson.scripts.lint = "eslint .";
282
- }
283
- if (!packageJson.scripts.format) {
284
- packageJson.scripts.format = "prettier --write .";
285
- }
286
- if (!packageJson.scripts.typecheck) {
287
- packageJson.scripts.typecheck = "tsc --noEmit";
288
- }
289
- await fs2.writeFile(
290
- path2.join(root, "package.json"),
291
- JSON.stringify(packageJson, null, 2)
292
- );
293
- p3.note("Dodano konfiguracj\u0119 CI i skrypty.");
387
+ await packageJson3.addScriptIfNotExists("format:check", "prettier --check .");
388
+ await packageJson3.addScriptIfNotExists("lint", "eslint . --max-warnings=0");
389
+ await packageJson3.addScriptIfNotExists("format", "prettier --write .");
390
+ await packageJson3.addScriptIfNotExists("typecheck", "tsc --noEmit");
391
+ p4.note("Dodano konfiguracj\u0119 CI i skrypty.");
294
392
  };
295
393
 
296
394
  // src/cli/install-lint-staged.ts
297
- import * as p4 from "@clack/prompts";
298
- import { $ as $2 } from "execa";
299
- import { writeFile as writeFile3 } from "fs/promises";
300
- import { isPackageListed, loadPackageJSON as loadPackageJSON2 } from "local-pkg";
301
- import path3 from "path";
302
- var $$2 = $2({
303
- cwd: gitRoot()
304
- });
395
+ import assert2 from "assert";
396
+ import { writeFile as writeFile5 } from "fs/promises";
397
+ var packageJson4 = new PackageJson();
305
398
  var installLintStaged = async () => {
306
- const lintStaged = await isPackageListed("lint-staged");
307
- const husky = await isPackageListed("husky");
308
- if (!lintStaged) {
309
- const spinner4 = p4.spinner();
310
- spinner4.start("Instalowanie lint-staged");
311
- await $$2`npm i -D lint-staged`;
312
- spinner4.stop("lint-staged zainstalowany");
313
- }
314
- if (!husky) {
315
- const spinner4 = p4.spinner();
316
- spinner4.start("Instalowanie husky");
317
- await $$2`npm i -D husky`;
318
- await $2`npx husky init`;
319
- spinner4.stop("husky zainstalowany");
320
- }
321
- await writeFile3(".husky/pre-commit", "npx lint-staged\n");
322
- const packageJson = await loadPackageJSON2(gitRoot());
323
- if (packageJson === null) {
324
- p4.cancel(
325
- "Nie znaleziono package.json. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu."
326
- );
327
- process.exit(1);
399
+ await packageJson4.load();
400
+ assert2(packageJson4.json !== null);
401
+ if (!await packageJson4.hasPackage("husky")) {
402
+ await packageJson4.install("husky");
403
+ await $$2`npx husky init`;
328
404
  }
329
- packageJson["lint-staged"] = {
405
+ await writeFile5(".husky/pre-commit", "npx lint-staged\n");
406
+ packageJson4.json["lint-staged"] = {
330
407
  "*": "prettier -w --ignore-unknown"
331
408
  };
332
- await writeFile3(
333
- path3.join(gitRoot(), "package.json"),
334
- JSON.stringify(packageJson, null, 2)
335
- );
409
+ await packageJson4.save();
336
410
  };
337
411
 
338
412
  // src/cli/install-prettier.ts
339
413
  import * as p5 from "@clack/prompts";
340
- import { $ as $3 } from "execa";
341
- import { getPackageInfo as getPackageInfo2, loadPackageJSON as loadPackageJSON3 } from "local-pkg";
414
+ import assert3 from "node:assert";
342
415
  import { existsSync as existsSync3 } from "node:fs";
343
416
  import * as fs3 from "node:fs/promises";
344
- import path4 from "node:path";
345
- import semver2 from "semver";
346
- var $$3 = $3({
347
- cwd: gitRoot()
348
- });
417
+ import path5 from "node:path";
349
418
  var prettierConfigNames = [
350
419
  ".prettierrc.js",
351
420
  ".prettierrc.cjs",
@@ -360,46 +429,17 @@ var prettierConfigNames = [
360
429
  "prettier.config.mts",
361
430
  "prettier.config.cts"
362
431
  ];
432
+ var packageJson5 = new PackageJson();
363
433
  var installPrettier = async () => {
364
- const root = gitRoot();
365
- const packageJsonPath = path4.join(root, "package.json");
366
- const prettier = await getPackageInfo2("prettier");
367
- if (typeof prettier?.version !== "string") {
368
- const isConfirmed = await polishConfirm({
369
- message: `Prettier nie jest zainstalowany. Czy chcesz go zainstalowa\u0107?`
370
- });
371
- if (p5.isCancel(isConfirmed) || !isConfirmed) {
372
- p5.cancel("Zainstaluj Prettiera i spr\xF3buj ponownie.");
373
- process.exit(1);
374
- }
375
- const spinner4 = p5.spinner();
376
- spinner4.start("Instalowanie Prettiera");
377
- await $$3`npm i -D prettier`;
378
- spinner4.stop("Prettiera zainstalowany");
379
- } else if (!semver2.satisfies(prettier.version, ">=3")) {
380
- const isConfirmed = await polishConfirm({
381
- message: `Prettier jest zainstalowany, ale trzeba go zaktualizowa\u0107. Czy chcesz zaktualizowa\u0107?`
382
- });
383
- if (p5.isCancel(isConfirmed) || !isConfirmed) {
384
- p5.cancel("Zaktualizuj Prettiera i spr\xF3buj ponownie.");
385
- process.exit(1);
386
- }
387
- const spinner4 = p5.spinner();
388
- spinner4.start("Aktualizowanie Prettiera");
389
- await $$3`npm i -D eslint@latest`;
390
- spinner4.stop("Prettier zaktualizowany");
391
- }
434
+ const root2 = gitRoot();
435
+ await packageJson5.load();
436
+ assert3(packageJson5.json !== null);
392
437
  const prettierConfig = prettierConfigNames.find(
393
- (configName) => existsSync3(path4.join(root, configName))
438
+ (configName) => existsSync3(path5.join(root2, configName))
394
439
  );
395
- const packageJson = await loadPackageJSON3();
396
- if (packageJson === null) {
397
- p5.cancel("Nie znaleziono pliku package.json.");
398
- process.exit(1);
399
- }
400
440
  const solvroPrettierPath = "@solvro/config/prettier";
401
- if (prettierConfig !== void 0 || packageJson.prettier !== void 0) {
402
- if (packageJson.prettier === solvroPrettierPath) {
441
+ if (prettierConfig !== void 0 || packageJson5.json.prettier !== void 0) {
442
+ if (packageJson5.json.prettier === solvroPrettierPath) {
403
443
  p5.note("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
404
444
  return;
405
445
  }
@@ -411,22 +451,16 @@ var installPrettier = async () => {
411
451
  process.exit(1);
412
452
  }
413
453
  for (const configName of prettierConfigNames) {
414
- await fs3.rm(path4.join(root, configName)).catch(() => null);
454
+ await fs3.rm(path5.join(root2, configName)).catch(() => null);
415
455
  }
416
456
  }
417
- const newPackageJson = await loadPackageJSON3();
418
- if (newPackageJson === null) {
419
- p5.cancel("Nie znaleziono pliku package.json.");
420
- process.exit(1);
421
- }
422
- newPackageJson.prettier = solvroPrettierPath;
423
- await fs3.writeFile(packageJsonPath, JSON.stringify(newPackageJson, null, 2));
457
+ packageJson5.json.prettier = solvroPrettierPath;
458
+ await packageJson5.save();
424
459
  p5.note("Konfiguracja Prettiera zosta\u0142a dodana.");
425
460
  };
426
461
 
427
462
  // src/cli/index.ts
428
463
  p6.intro(c.bold(c.bgBlue(" @solvro/config ")));
429
- var projectType = getProjectType();
430
464
  if (!isGitClean()) {
431
465
  const isConfirmed = await polishConfirm({
432
466
  message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
@@ -436,6 +470,9 @@ if (!isGitClean()) {
436
470
  process.exit(1);
437
471
  }
438
472
  }
473
+ var packageJson6 = new PackageJson();
474
+ await packageJson6.ensureESM();
475
+ var projectType = await packageJson6.getProjectType();
439
476
  if (projectType === "adonis") {
440
477
  const isConfirmed = await polishConfirm({
441
478
  message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 Adonisa. Czy to si\u0119 zgadza?`
@@ -466,7 +503,7 @@ if (projectType === "node") {
466
503
  }
467
504
  var additionalTools = await p6.multiselect({
468
505
  message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${c.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
469
- initialValues: ["eslint", "prettier", "gh-action"],
506
+ initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
470
507
  options: [
471
508
  {
472
509
  value: "eslint",
@@ -482,26 +519,20 @@ var additionalTools = await p6.multiselect({
482
519
  value: "gh-action",
483
520
  label: c.bold("GitHub Actions"),
484
521
  hint: "automatyczne testy na Githubie"
522
+ },
523
+ {
524
+ value: "commitlint",
525
+ label: c.bold("Commitlint"),
526
+ hint: "walidacja tre\u015Bci commit\xF3w"
485
527
  }
486
528
  ],
487
529
  required: false
488
530
  });
489
- var $$4 = $4({
490
- cwd: gitRoot()
491
- });
492
- if (p6.isCancel(additionalTools)) {
531
+ if (p6.isCancel(additionalTools) || additionalTools.length === 0) {
493
532
  p6.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
494
533
  process.exit(1);
495
534
  }
496
- await p6.tasks([
497
- {
498
- title: "Instalowanie @solvro/config",
499
- enabled: !await isPackageListed2("@solvro/config"),
500
- task: async () => {
501
- await $$4`npm i -D @solvro/config`;
502
- }
503
- }
504
- ]);
535
+ await packageJson6.install("@solvro/config", { dev: true });
505
536
  if (additionalTools.includes("eslint")) {
506
537
  await installEslint();
507
538
  }
@@ -509,6 +540,10 @@ if (additionalTools.includes("prettier")) {
509
540
  await installPrettier();
510
541
  await installLintStaged();
511
542
  }
543
+ if (additionalTools.includes("commitlint")) {
544
+ await installCommitLint();
545
+ }
512
546
  if (additionalTools.includes("gh-action")) {
513
547
  await installGithubActions();
514
548
  }
549
+ //# sourceMappingURL=index.js.map