@solvro/config 2.2.1 → 2.3.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 +14 -2
- package/dist/cli/index.cjs +349 -151
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +350 -152
- package/dist/cli/index.js.map +1 -1
- package/package.json +2 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -23,15 +23,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
|
|
25
25
|
// src/cli/index.ts
|
|
26
|
-
var
|
|
26
|
+
var p11 = __toESM(require("@clack/prompts"), 1);
|
|
27
27
|
var import_commander = require("commander");
|
|
28
|
-
var
|
|
29
|
-
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
28
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
30
29
|
|
|
31
30
|
// package.json
|
|
32
31
|
var package_default = {
|
|
33
32
|
name: "@solvro/config",
|
|
34
|
-
version: "2.2.
|
|
33
|
+
version: "2.2.1",
|
|
35
34
|
description: "Solvro's engineering style guide",
|
|
36
35
|
keywords: [
|
|
37
36
|
"eslint",
|
|
@@ -97,6 +96,7 @@ var package_default = {
|
|
|
97
96
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
98
97
|
"@eslint/config-helpers": "^0.4.2",
|
|
99
98
|
"@eslint/js": "^9.37.0",
|
|
99
|
+
"@solvro/utils": "^1.5.0",
|
|
100
100
|
"@tanstack/eslint-plugin-query": "^5.91.4",
|
|
101
101
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
102
102
|
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
|
@@ -168,10 +168,40 @@ var package_default = {
|
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
// src/constants/
|
|
171
|
+
// src/constants/github.ts
|
|
172
172
|
var REPO_URL = "https://github.com/Solvro/lib-web-solvro-config";
|
|
173
173
|
var BUG_TRACKER_URL = `${REPO_URL}/issues/new`;
|
|
174
174
|
|
|
175
|
+
// src/constants/package-managers.ts
|
|
176
|
+
var PACKAGE_MANAGER_CONFIGS = {
|
|
177
|
+
npm: {
|
|
178
|
+
name: "npm",
|
|
179
|
+
lockfile: "package-lock.json",
|
|
180
|
+
installPackage: "npm install",
|
|
181
|
+
installDependencies: "npm install",
|
|
182
|
+
cleanInstall: "npm ci",
|
|
183
|
+
downloadExecute: "npx",
|
|
184
|
+
localExecute: "npx",
|
|
185
|
+
runScript: "npm run",
|
|
186
|
+
create: "npm create"
|
|
187
|
+
},
|
|
188
|
+
pnpm: {
|
|
189
|
+
name: "pnpm",
|
|
190
|
+
lockfile: "pnpm-lock.yaml",
|
|
191
|
+
installPackage: "pnpm add",
|
|
192
|
+
installDependencies: "pnpm install",
|
|
193
|
+
cleanInstall: "pnpm install --frozen-lockfile",
|
|
194
|
+
downloadExecute: "pnpm dlx",
|
|
195
|
+
localExecute: "pnpm exec",
|
|
196
|
+
runScript: "pnpm run",
|
|
197
|
+
create: "pnpm create"
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var SUPPORTED_PACKAGE_MANAGERS = Object.keys(PACKAGE_MANAGER_CONFIGS);
|
|
201
|
+
|
|
202
|
+
// src/utils/check-is-non-interactive.ts
|
|
203
|
+
var checkIsNonInteractive = () => process.argv.length > 2;
|
|
204
|
+
|
|
175
205
|
// src/utils/confirm-project-type.ts
|
|
176
206
|
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
177
207
|
|
|
@@ -218,12 +248,13 @@ function isGitClean() {
|
|
|
218
248
|
}
|
|
219
249
|
|
|
220
250
|
// src/utils/package-json.ts
|
|
221
|
-
var
|
|
251
|
+
var p7 = __toESM(require("@clack/prompts"), 1);
|
|
222
252
|
var import_local_pkg = require("local-pkg");
|
|
223
253
|
var import_node_assert = __toESM(require("assert"), 1);
|
|
224
254
|
var import_promises = require("fs/promises");
|
|
225
255
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
226
|
-
var
|
|
256
|
+
var import_detect = require("package-manager-detector/detect");
|
|
257
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
227
258
|
var import_semver = __toESM(require("semver"), 1);
|
|
228
259
|
|
|
229
260
|
// src/utils/git-root.ts
|
|
@@ -260,6 +291,9 @@ var $$ = (async (...arguments_) => {
|
|
|
260
291
|
return cachedExeca(...arguments_);
|
|
261
292
|
});
|
|
262
293
|
|
|
294
|
+
// src/utils/is-supported-package-manager.ts
|
|
295
|
+
var isSupportedPackageManager = (userAgent) => userAgent != null && SUPPORTED_PACKAGE_MANAGERS.includes(userAgent);
|
|
296
|
+
|
|
263
297
|
// src/utils/run-with-spinner.ts
|
|
264
298
|
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
265
299
|
|
|
@@ -291,14 +325,128 @@ var runWithSpinner = async (options2) => {
|
|
|
291
325
|
});
|
|
292
326
|
};
|
|
293
327
|
|
|
328
|
+
// src/utils/warn-inconsistent-user-agent.ts
|
|
329
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
330
|
+
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
331
|
+
var hintInstallWithDetected = (manager) => `
|
|
332
|
+
${import_picocolors.default.white(`Upewnij si\u0119, \u017Ce u\u017Cywasz w\u0142a\u015Bciwej komendy. Spr\xF3buj jeszcze raz za pomoc\u0105 ${import_picocolors.default.yellow(manager.name)}-a:`)}
|
|
333
|
+
|
|
334
|
+
${import_picocolors.default.cyan(`${manager.downloadExecute} @solvro/config@latest`)}`;
|
|
335
|
+
var warnUnsupported = (manager) => `
|
|
336
|
+
${import_picocolors.default.white("@solvro/config obecnie dzia\u0142a tylko z nast\u0119puj\u0105cymi mened\u017Cerami pakiet\xF3w:")}
|
|
337
|
+
|
|
338
|
+
${SUPPORTED_PACKAGE_MANAGERS.map((supportedManager) => import_picocolors.default.white(`- ${import_picocolors.default.cyan(supportedManager)}`)).join("\n")}
|
|
339
|
+
|
|
340
|
+
Niestety, ${import_picocolors.default.yellow(manager)} nie jest wspierany.`;
|
|
341
|
+
var warnInconsistentUserAgent = ({
|
|
342
|
+
userAgent,
|
|
343
|
+
detectedPackageManager
|
|
344
|
+
}) => {
|
|
345
|
+
const warningMessage = `${import_picocolors.default.red(import_picocolors.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: niesp\xF3jny mened\u017Cer pakiet\xF3w \u26A0\uFE0F`))}
|
|
346
|
+
|
|
347
|
+
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${import_picocolors.default.yellow(userAgent.name)}-em, ale w tym projekcie wykryto mened\u017Cer pakiet\xF3w ${import_picocolors.default.yellow(detectedPackageManager)}.
|
|
348
|
+
${isSupportedPackageManager(detectedPackageManager) ? hintInstallWithDetected(PACKAGE_MANAGER_CONFIGS[detectedPackageManager]) : warnUnsupported(detectedPackageManager)}`;
|
|
349
|
+
if (checkIsNonInteractive()) {
|
|
350
|
+
console.error(warningMessage);
|
|
351
|
+
} else {
|
|
352
|
+
p4.cancel(warningMessage);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// src/utils/warn-missing-lockfile.ts
|
|
357
|
+
var p5 = __toESM(require("@clack/prompts"), 1);
|
|
358
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
359
|
+
var warnMissingLockfile = ({
|
|
360
|
+
manager
|
|
361
|
+
}) => {
|
|
362
|
+
const warningMessage = `${import_picocolors2.default.red(import_picocolors2.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: brak pliku blokady \u26A0\uFE0F`))}
|
|
363
|
+
|
|
364
|
+
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${import_picocolors2.default.yellow(manager.name)}-em, ale nie wykryto pliku ${import_picocolors2.default.yellow(manager.lockfile)}.
|
|
365
|
+
|
|
366
|
+
${import_picocolors2.default.white(`Sprawd\u017A, czy ten projekt na pewno korzysta z mened\u017Cera pakiet\xF3w ${import_picocolors2.default.yellow(manager.name)}.`)}
|
|
367
|
+
${import_picocolors2.default.white("Je\u015Bli to si\u0119 zgadza, zainstaluj najpierw zale\u017Cno\u015Bci projektu i spr\xF3buj ponownie:")}
|
|
368
|
+
|
|
369
|
+
${import_picocolors2.default.cyan(manager.installDependencies)}
|
|
370
|
+
${import_picocolors2.default.cyan(`${manager.downloadExecute} @solvro/config@latest`)}`;
|
|
371
|
+
if (checkIsNonInteractive()) {
|
|
372
|
+
console.error(warningMessage);
|
|
373
|
+
} else {
|
|
374
|
+
p5.cancel(warningMessage);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/utils/warn-unsupported-package-manager.ts
|
|
379
|
+
var p6 = __toESM(require("@clack/prompts"), 1);
|
|
380
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
381
|
+
var warnUnsupportedPackageManager = ({
|
|
382
|
+
userAgent
|
|
383
|
+
}) => {
|
|
384
|
+
const packageManager = userAgent ?? "<nieznany>";
|
|
385
|
+
const warningMessage = `${import_picocolors3.default.red(import_picocolors3.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
386
|
+
|
|
387
|
+
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${import_picocolors3.default.yellow(packageManager)}-em, ale @solvro/config obecnie dzia\u0142a tylko z nast\u0119puj\u0105cymi mened\u017Cerami pakiet\xF3w:
|
|
388
|
+
|
|
389
|
+
${SUPPORTED_PACKAGE_MANAGERS.map((manager) => import_picocolors3.default.white(`- ${import_picocolors3.default.cyan(manager)}`)).join("\n")}
|
|
390
|
+
|
|
391
|
+
${import_picocolors3.default.white(`Chcesz, aby dodano wsparcie dla ${import_picocolors3.default.yellow(packageManager)}-a? Daj nam zna\u0107!`)}
|
|
392
|
+
${import_picocolors3.default.white(import_picocolors3.default.underline(BUG_TRACKER_URL))}
|
|
393
|
+
|
|
394
|
+
${import_picocolors3.default.white(`W mi\u0119dzyczasie u\u017Cyj innego mened\u017Cera:`)}
|
|
395
|
+
|
|
396
|
+
${Object.values(PACKAGE_MANAGER_CONFIGS).map((config) => import_picocolors3.default.cyan(`${config.downloadExecute} @solvro/config`)).join(import_picocolors3.default.white("\nlub\n"))}`;
|
|
397
|
+
if (checkIsNonInteractive()) {
|
|
398
|
+
console.error(warningMessage);
|
|
399
|
+
} else {
|
|
400
|
+
p6.cancel(warningMessage);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
294
404
|
// src/utils/package-json.ts
|
|
295
405
|
var PackageJson = class {
|
|
296
406
|
json = null;
|
|
407
|
+
_manager = null;
|
|
408
|
+
/** Checks if the process is run from a supported package manager */
|
|
409
|
+
verifyPackageManager() {
|
|
410
|
+
const userAgent = (0, import_detect.getUserAgent)();
|
|
411
|
+
if (!isSupportedPackageManager(userAgent)) {
|
|
412
|
+
warnUnsupportedPackageManager({ userAgent });
|
|
413
|
+
process.exit(1);
|
|
414
|
+
}
|
|
415
|
+
return userAgent;
|
|
416
|
+
}
|
|
417
|
+
/** Checks if the user agent is consistent with the project's package manager */
|
|
418
|
+
async validateUserAgentConsistency() {
|
|
419
|
+
if (this.json?.packageManager != null) {
|
|
420
|
+
const [detectedPackageManager] = this.json.packageManager.split("@");
|
|
421
|
+
if (detectedPackageManager !== this.manager.name) {
|
|
422
|
+
warnInconsistentUserAgent({
|
|
423
|
+
userAgent: this.manager,
|
|
424
|
+
detectedPackageManager
|
|
425
|
+
});
|
|
426
|
+
process.exit(1);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const lockfilePath = import_node_path2.default.join(projectRoot(), this.manager.lockfile);
|
|
430
|
+
try {
|
|
431
|
+
await (0, import_promises.stat)(lockfilePath);
|
|
432
|
+
} catch {
|
|
433
|
+
warnMissingLockfile({ manager: this.manager });
|
|
434
|
+
process.exit(1);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// use a cached getter to avoid premature exits on importing a file with a toplevel construction
|
|
438
|
+
get manager() {
|
|
439
|
+
if (this._manager == null) {
|
|
440
|
+
const userAgent = this.verifyPackageManager();
|
|
441
|
+
this._manager = PACKAGE_MANAGER_CONFIGS[userAgent];
|
|
442
|
+
}
|
|
443
|
+
return this._manager;
|
|
444
|
+
}
|
|
297
445
|
async load() {
|
|
298
446
|
const json = await (0, import_local_pkg.loadPackageJSON)(projectRoot());
|
|
299
447
|
if (json === null) {
|
|
300
|
-
|
|
301
|
-
`Nie znaleziono pliku ${
|
|
448
|
+
p7.cancel(
|
|
449
|
+
`Nie znaleziono pliku ${import_picocolors4.default.cyan("package.json")}. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu.`
|
|
302
450
|
);
|
|
303
451
|
process.exit(1);
|
|
304
452
|
}
|
|
@@ -340,8 +488,8 @@ var PackageJson = class {
|
|
|
340
488
|
const isReact = await (0, import_local_pkg.isPackageListed)("react");
|
|
341
489
|
const isNestJs = await (0, import_local_pkg.isPackageListed)("@nestjs/core");
|
|
342
490
|
if (isReact && isAdonis) {
|
|
343
|
-
|
|
344
|
-
`Projekty korzystaj\u0105ce zar\xF3wno z ${
|
|
491
|
+
p7.cancel(
|
|
492
|
+
`Projekty korzystaj\u0105ce zar\xF3wno z ${import_picocolors4.default.magenta("Adonis")}a jak i ${import_picocolors4.default.cyan("React")}a nie s\u0105 wspierane.`
|
|
345
493
|
);
|
|
346
494
|
process.exit(1);
|
|
347
495
|
}
|
|
@@ -376,13 +524,20 @@ var PackageJson = class {
|
|
|
376
524
|
async install(package_, options2 = {}) {
|
|
377
525
|
const isInstalled = await this.hasPackage(package_);
|
|
378
526
|
const installVersion = options2.version ?? "latest";
|
|
527
|
+
const [installCommand, ...commandOptions] = this.manager.installPackage.split(" ");
|
|
528
|
+
if (options2.dev === true) {
|
|
529
|
+
commandOptions.push("-D");
|
|
530
|
+
}
|
|
379
531
|
if (!isInstalled) {
|
|
380
532
|
await runWithSpinner({
|
|
381
533
|
start: `Instalowanie pakietu ${package_}`,
|
|
382
534
|
stop: `${package_} zainstalowany \u{1F60D}`,
|
|
383
535
|
error: `Instalacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
384
536
|
callback: async () => {
|
|
385
|
-
await
|
|
537
|
+
await $$(installCommand, [
|
|
538
|
+
...commandOptions,
|
|
539
|
+
`${package_}@${installVersion}`
|
|
540
|
+
]);
|
|
386
541
|
}
|
|
387
542
|
});
|
|
388
543
|
await this.load();
|
|
@@ -394,14 +549,46 @@ var PackageJson = class {
|
|
|
394
549
|
stop: `${package_} zaktualizowany \u{1F60D}`,
|
|
395
550
|
error: `Aktualizacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
396
551
|
callback: async () => {
|
|
397
|
-
await
|
|
552
|
+
await $$(installCommand, [
|
|
553
|
+
...commandOptions,
|
|
554
|
+
`${package_}@${installVersion}`
|
|
555
|
+
]);
|
|
398
556
|
}
|
|
399
557
|
});
|
|
400
558
|
await this.load();
|
|
401
559
|
}
|
|
402
560
|
}
|
|
561
|
+
async localExecute(...commandArguments) {
|
|
562
|
+
const [command, ...commandOptions] = this.manager.localExecute.split(" ");
|
|
563
|
+
const options2 = [...commandOptions, ...commandArguments];
|
|
564
|
+
await $$(command, options2);
|
|
565
|
+
}
|
|
403
566
|
async clearInstall() {
|
|
404
|
-
|
|
567
|
+
const [command, ...options2] = this.manager.cleanInstall.split(" ");
|
|
568
|
+
await $$(command, options2);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Gets the pnpm major version from package.json packageManager field or user agent.
|
|
572
|
+
* Falls back to version "10" if neither source is available.
|
|
573
|
+
* Returns only the major version for CI stability.
|
|
574
|
+
*/
|
|
575
|
+
async getPnpmVersion() {
|
|
576
|
+
await this.load();
|
|
577
|
+
if (this.json?.packageManager?.startsWith("pnpm@") === true) {
|
|
578
|
+
const version = this.json.packageManager.split("@")[1];
|
|
579
|
+
const majorVersion = version.split(".")[0];
|
|
580
|
+
if (/^\d+$/.test(majorVersion)) {
|
|
581
|
+
return majorVersion;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
585
|
+
if (userAgent != null) {
|
|
586
|
+
const match = /pnpm\/(\d+)(?:\.\d+)*/.exec(userAgent);
|
|
587
|
+
if (match?.[1] != null) {
|
|
588
|
+
return match[1];
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return "10";
|
|
405
592
|
}
|
|
406
593
|
};
|
|
407
594
|
|
|
@@ -415,7 +602,7 @@ var packageJson = new PackageJson();
|
|
|
415
602
|
var installHusky = async () => {
|
|
416
603
|
if (!await packageJson.hasPackage("husky")) {
|
|
417
604
|
await packageJson.install("husky", { dev: true });
|
|
418
|
-
await
|
|
605
|
+
await packageJson.localExecute("husky", "init");
|
|
419
606
|
}
|
|
420
607
|
await packageJson.load();
|
|
421
608
|
import_node_assert2.default.ok(packageJson.json !== null);
|
|
@@ -438,13 +625,14 @@ var installCommitLint = async () => {
|
|
|
438
625
|
await packageJson2.install("@commitlint/cli", { dev: true });
|
|
439
626
|
await (0, import_promises2.writeFile)(
|
|
440
627
|
import_node_path3.default.join(root, ".husky/commit-msg"),
|
|
441
|
-
|
|
628
|
+
`${packageJson2.manager.localExecute} commitlint --edit "$1"
|
|
629
|
+
`
|
|
442
630
|
);
|
|
443
631
|
await (0, import_promises2.writeFile)(import_node_path3.default.join(root, ".commitlintrc.js"), commitlint());
|
|
444
632
|
};
|
|
445
633
|
|
|
446
634
|
// src/cli/install-eslint.ts
|
|
447
|
-
var
|
|
635
|
+
var p8 = __toESM(require("@clack/prompts"), 1);
|
|
448
636
|
var import_node_fs = require("fs");
|
|
449
637
|
var fs = __toESM(require("fs/promises"), 1);
|
|
450
638
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
@@ -474,7 +662,7 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
474
662
|
if (type === "react" && await packageJson3.isNextJs()) {
|
|
475
663
|
const is15 = await packageJson3.doesSatisfy("next", ">=15");
|
|
476
664
|
if (!is15) {
|
|
477
|
-
|
|
665
|
+
p8.cancel(
|
|
478
666
|
"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"
|
|
479
667
|
);
|
|
480
668
|
process.exit(1);
|
|
@@ -490,7 +678,7 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
490
678
|
"utf8"
|
|
491
679
|
);
|
|
492
680
|
if (eslintContent.includes("export default solvro(")) {
|
|
493
|
-
|
|
681
|
+
p8.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
|
|
494
682
|
return;
|
|
495
683
|
} else {
|
|
496
684
|
if (isNonInteractive2) {
|
|
@@ -499,8 +687,8 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
499
687
|
const isConfirmed = await polishConfirm({
|
|
500
688
|
message: `Znaleziono plik konfiguracyjny Eslint. Czy chcesz go nadpisa\u0107?`
|
|
501
689
|
});
|
|
502
|
-
if (
|
|
503
|
-
|
|
690
|
+
if (p8.isCancel(isConfirmed) || !isConfirmed) {
|
|
691
|
+
p8.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
|
|
504
692
|
process.exit(1);
|
|
505
693
|
}
|
|
506
694
|
await fs.rm(import_node_path4.default.join(root2, eslintConfig));
|
|
@@ -516,26 +704,56 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
516
704
|
export default solvro();
|
|
517
705
|
`
|
|
518
706
|
);
|
|
519
|
-
|
|
707
|
+
p8.note("Plik konfiguracyjny Eslint zosta\u0142 utworzony.");
|
|
520
708
|
};
|
|
521
709
|
|
|
522
710
|
// src/cli/install-ga.ts
|
|
523
|
-
var
|
|
711
|
+
var p9 = __toESM(require("@clack/prompts"), 1);
|
|
524
712
|
var import_node_fs2 = require("fs");
|
|
525
713
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
526
714
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
527
715
|
|
|
528
716
|
// src/cli/templates/commit-lint-ci.ts
|
|
529
|
-
var commitLintCi = (
|
|
717
|
+
var commitLintCi = ({
|
|
718
|
+
manager
|
|
719
|
+
}) => `
|
|
530
720
|
- name: Check commit name
|
|
531
721
|
if: github.event_name == 'pull_request'
|
|
532
|
-
run:
|
|
722
|
+
run: ${manager.localExecute} commitlint --from \${{ github.event.pull_request.base.sha }} --to \${{ github.event.pull_request.head.sha }} --verbose
|
|
533
723
|
`;
|
|
534
724
|
|
|
725
|
+
// src/cli/templates/pnpm-setup-ci.ts
|
|
726
|
+
var pnpmSetupCi = ({
|
|
727
|
+
pnpmVersion = "10"
|
|
728
|
+
} = {}) => `
|
|
729
|
+
|
|
730
|
+
- name: Setup pnpm
|
|
731
|
+
uses: pnpm/action-setup@v4
|
|
732
|
+
with:
|
|
733
|
+
version: ${pnpmVersion}`;
|
|
734
|
+
|
|
735
|
+
// src/cli/templates/node-setup-ci.ts
|
|
736
|
+
var nodeSetupCi = ({
|
|
737
|
+
nodeVersion,
|
|
738
|
+
manager,
|
|
739
|
+
pnpmVersion
|
|
740
|
+
}) => ` - name: Checkout
|
|
741
|
+
uses: actions/checkout@v6
|
|
742
|
+
with:
|
|
743
|
+
fetch-depth: 0
|
|
744
|
+
|
|
745
|
+
- name: Setup node
|
|
746
|
+
uses: actions/setup-node@v6
|
|
747
|
+
with:
|
|
748
|
+
node-version: ${nodeVersion}
|
|
749
|
+
cache: "${manager.name}"${manager.name === "pnpm" ? pnpmSetupCi({ pnpmVersion }) : ""}`;
|
|
750
|
+
|
|
535
751
|
// src/cli/templates/adonis-ci.ts
|
|
536
752
|
var adonisCi = ({
|
|
537
753
|
nodeVersion,
|
|
538
|
-
withCommitlint
|
|
754
|
+
withCommitlint,
|
|
755
|
+
manager,
|
|
756
|
+
pnpmVersion
|
|
539
757
|
}) => `name: CI
|
|
540
758
|
|
|
541
759
|
on:
|
|
@@ -547,48 +765,43 @@ jobs:
|
|
|
547
765
|
lint:
|
|
548
766
|
runs-on: ubuntu-latest
|
|
549
767
|
steps:
|
|
550
|
-
|
|
551
|
-
uses: actions/checkout@v4
|
|
552
|
-
with:
|
|
553
|
-
fetch-depth: 0
|
|
554
|
-
|
|
555
|
-
- name: Setup node
|
|
556
|
-
uses: actions/setup-node@v4
|
|
557
|
-
with:
|
|
558
|
-
node-version: ${nodeVersion}
|
|
559
|
-
cache: "npm"
|
|
768
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
560
769
|
|
|
561
770
|
- name: Install dependencies
|
|
562
|
-
run:
|
|
771
|
+
run: ${manager.cleanInstall}
|
|
563
772
|
|
|
564
773
|
- name: Set up AdonisJS environment
|
|
565
774
|
run: |
|
|
566
775
|
cp .env.example .env
|
|
567
776
|
node ace generate:key
|
|
568
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
777
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
569
778
|
- name: Check formatting
|
|
570
|
-
run:
|
|
779
|
+
run: ${manager.runScript} format:check
|
|
571
780
|
if: always()
|
|
572
781
|
|
|
573
782
|
- name: Lint code
|
|
574
|
-
run:
|
|
783
|
+
run: ${manager.runScript} lint
|
|
575
784
|
if: always()
|
|
576
785
|
|
|
577
786
|
- name: Check types
|
|
578
|
-
run:
|
|
787
|
+
run: ${manager.runScript} types:check
|
|
579
788
|
if: always()
|
|
580
789
|
|
|
581
790
|
- name: Run tests
|
|
582
|
-
run:
|
|
791
|
+
run: ${manager.name} test
|
|
583
792
|
if: always()
|
|
584
793
|
|
|
585
794
|
- name: Build
|
|
586
|
-
run:
|
|
795
|
+
run: ${manager.runScript} build
|
|
587
796
|
if: always()
|
|
588
797
|
`;
|
|
589
798
|
|
|
590
799
|
// src/cli/templates/adonis-ci-migrations.ts
|
|
591
|
-
var adonisMigrationsCi = (
|
|
800
|
+
var adonisMigrationsCi = ({
|
|
801
|
+
nodeVersion,
|
|
802
|
+
manager,
|
|
803
|
+
pnpmVersion
|
|
804
|
+
}) => `name: Migration check
|
|
592
805
|
|
|
593
806
|
on:
|
|
594
807
|
pull_request:
|
|
@@ -620,11 +833,10 @@ jobs:
|
|
|
620
833
|
- 5432:5432
|
|
621
834
|
|
|
622
835
|
steps:
|
|
623
|
-
|
|
624
|
-
uses: actions/checkout@v4
|
|
836
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
625
837
|
|
|
626
838
|
- name: Install dependencies
|
|
627
|
-
run:
|
|
839
|
+
run: ${manager.cleanInstall}
|
|
628
840
|
|
|
629
841
|
- name: Set up AdonisJS environment
|
|
630
842
|
run: |
|
|
@@ -652,7 +864,9 @@ updates:
|
|
|
652
864
|
// src/cli/templates/nestjs-ci.ts
|
|
653
865
|
var nestjsCi = ({
|
|
654
866
|
nodeVersion,
|
|
655
|
-
withCommitlint
|
|
867
|
+
withCommitlint,
|
|
868
|
+
manager,
|
|
869
|
+
pnpmVersion
|
|
656
870
|
}) => `name: CI
|
|
657
871
|
|
|
658
872
|
on:
|
|
@@ -664,61 +878,54 @@ jobs:
|
|
|
664
878
|
lint:
|
|
665
879
|
runs-on: ubuntu-latest
|
|
666
880
|
steps:
|
|
667
|
-
|
|
668
|
-
uses: actions/checkout@v4
|
|
669
|
-
with:
|
|
670
|
-
fetch-depth: 0
|
|
671
|
-
|
|
672
|
-
- name: Setup node
|
|
673
|
-
uses: actions/setup-node@v4
|
|
674
|
-
with:
|
|
675
|
-
node-version: ${nodeVersion}
|
|
676
|
-
cache: "npm"
|
|
881
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
677
882
|
|
|
678
883
|
- name: Install dependencies
|
|
679
|
-
run:
|
|
680
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
884
|
+
run: ${manager.cleanInstall}
|
|
885
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
681
886
|
- name: Check formatting
|
|
682
|
-
run:
|
|
887
|
+
run: ${manager.runScript} format:check
|
|
683
888
|
if: always()
|
|
684
889
|
|
|
685
890
|
- name: Lint code
|
|
686
|
-
run:
|
|
891
|
+
run: ${manager.runScript} lint
|
|
687
892
|
if: always()
|
|
688
893
|
|
|
689
894
|
- name: Check types
|
|
690
|
-
run:
|
|
895
|
+
run: ${manager.runScript} types:check
|
|
691
896
|
if: always()
|
|
692
897
|
|
|
693
898
|
- name: Run tests
|
|
694
|
-
run:
|
|
899
|
+
run: ${manager.name} test
|
|
695
900
|
if: always()
|
|
696
901
|
|
|
697
902
|
- name: Run e2e tests
|
|
698
|
-
run:
|
|
903
|
+
run: ${manager.runScript} test:e2e
|
|
699
904
|
if: always()
|
|
700
905
|
|
|
701
906
|
- name: Build
|
|
702
|
-
run:
|
|
907
|
+
run: ${manager.runScript} build
|
|
703
908
|
if: always()
|
|
704
909
|
`;
|
|
705
910
|
|
|
706
911
|
// src/cli/templates/nextjs-ci.ts
|
|
707
|
-
var nextJsCi = () => `
|
|
912
|
+
var nextJsCi = ({ manager }) => `
|
|
708
913
|
- name: Setup build cache
|
|
709
|
-
uses: actions/cache@
|
|
914
|
+
uses: actions/cache@v5
|
|
710
915
|
with:
|
|
711
916
|
path: \${{ github.workspace }}/.next/cache
|
|
712
|
-
key: \${{ runner.os }}-nextjs-\${{ hashFiles('
|
|
917
|
+
key: \${{ runner.os }}-nextjs-\${{ hashFiles('**/${manager.lockfile}') }}-\${{ hashFiles('**/*.ts', '**/*.tsx') }}
|
|
713
918
|
restore-keys: |
|
|
714
|
-
\${{ runner.os }}-nextjs-\${{ hashFiles('
|
|
919
|
+
\${{ runner.os }}-nextjs-\${{ hashFiles('**/${manager.lockfile}') }}-
|
|
715
920
|
`;
|
|
716
921
|
|
|
717
922
|
// src/cli/templates/react-ci.ts
|
|
718
923
|
var reactCi = ({
|
|
719
924
|
nodeVersion,
|
|
720
925
|
withCommitlint,
|
|
721
|
-
|
|
926
|
+
manager,
|
|
927
|
+
usingNextJs,
|
|
928
|
+
pnpmVersion
|
|
722
929
|
}) => `name: CI
|
|
723
930
|
|
|
724
931
|
on:
|
|
@@ -730,34 +937,25 @@ jobs:
|
|
|
730
937
|
lint:
|
|
731
938
|
runs-on: ubuntu-latest
|
|
732
939
|
steps:
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
with:
|
|
736
|
-
fetch-depth: 0
|
|
737
|
-
|
|
738
|
-
- name: Setup node
|
|
739
|
-
uses: actions/setup-node@v4
|
|
740
|
-
with:
|
|
741
|
-
node-version: ${nodeVersion}
|
|
742
|
-
cache: "npm"
|
|
743
|
-
${usingNextJs ? nextJsCi() : ""}
|
|
940
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
941
|
+
${usingNextJs ? nextJsCi({ manager }) : ""}
|
|
744
942
|
- name: Install dependencies
|
|
745
|
-
run:
|
|
746
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
943
|
+
run: ${manager.cleanInstall}
|
|
944
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
747
945
|
- name: Check formatting
|
|
748
|
-
run:
|
|
946
|
+
run: ${manager.runScript} format:check
|
|
749
947
|
if: always()
|
|
750
948
|
|
|
751
949
|
- name: Lint code
|
|
752
|
-
run:
|
|
950
|
+
run: ${manager.runScript} lint
|
|
753
951
|
if: always()
|
|
754
952
|
|
|
755
953
|
- name: Check types
|
|
756
|
-
run:
|
|
954
|
+
run: ${manager.runScript} types:check
|
|
757
955
|
if: always()
|
|
758
956
|
|
|
759
957
|
- name: Build
|
|
760
|
-
run:
|
|
958
|
+
run: ${manager.runScript} build
|
|
761
959
|
if: always()
|
|
762
960
|
`;
|
|
763
961
|
|
|
@@ -770,10 +968,12 @@ var installGithubActions = async () => {
|
|
|
770
968
|
const ghWorkflowsDirectory = import_node_path5.default.join(gitDirectory, ".github/workflows");
|
|
771
969
|
await fs2.mkdir(ghWorkflowsDirectory, { recursive: true });
|
|
772
970
|
const type = await packageJson4.getProjectType();
|
|
971
|
+
const manager = packageJson4.manager;
|
|
972
|
+
const pnpmVersion = manager.name === "pnpm" ? await packageJson4.getPnpmVersion() : void 0;
|
|
773
973
|
const withCommitlint = await packageJson4.hasPackage("@commitlint/cli");
|
|
774
974
|
if (type === "adonis") {
|
|
775
975
|
if (!(0, import_node_fs2.existsSync)(import_node_path5.default.join(projectDirectory, ".env.example"))) {
|
|
776
|
-
|
|
976
|
+
p9.cancel(
|
|
777
977
|
"Nie znaleziono pliku .env.example. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu Adonisa."
|
|
778
978
|
);
|
|
779
979
|
process.exit(1);
|
|
@@ -782,12 +982,14 @@ var installGithubActions = async () => {
|
|
|
782
982
|
import_node_path5.default.join(ghWorkflowsDirectory, "ci.yml"),
|
|
783
983
|
adonisCi({
|
|
784
984
|
nodeVersion: "22",
|
|
785
|
-
withCommitlint
|
|
985
|
+
withCommitlint,
|
|
986
|
+
manager,
|
|
987
|
+
pnpmVersion
|
|
786
988
|
})
|
|
787
989
|
);
|
|
788
990
|
await fs2.writeFile(
|
|
789
991
|
import_node_path5.default.join(ghWorkflowsDirectory, "db.yml"),
|
|
790
|
-
adonisMigrationsCi()
|
|
992
|
+
adonisMigrationsCi({ nodeVersion: "22", manager, pnpmVersion })
|
|
791
993
|
);
|
|
792
994
|
}
|
|
793
995
|
if (type === "react") {
|
|
@@ -797,7 +999,9 @@ var installGithubActions = async () => {
|
|
|
797
999
|
reactCi({
|
|
798
1000
|
nodeVersion: "22",
|
|
799
1001
|
withCommitlint,
|
|
800
|
-
usingNextJs
|
|
1002
|
+
usingNextJs,
|
|
1003
|
+
manager,
|
|
1004
|
+
pnpmVersion
|
|
801
1005
|
})
|
|
802
1006
|
);
|
|
803
1007
|
if (usingNextJs) {
|
|
@@ -809,7 +1013,9 @@ var installGithubActions = async () => {
|
|
|
809
1013
|
import_node_path5.default.join(ghWorkflowsDirectory, "ci.yml"),
|
|
810
1014
|
nestjsCi({
|
|
811
1015
|
nodeVersion: "22",
|
|
812
|
-
withCommitlint
|
|
1016
|
+
withCommitlint,
|
|
1017
|
+
manager,
|
|
1018
|
+
pnpmVersion
|
|
813
1019
|
})
|
|
814
1020
|
);
|
|
815
1021
|
}
|
|
@@ -823,19 +1029,24 @@ var installGithubActions = async () => {
|
|
|
823
1029
|
await packageJson4.addScriptIfNotExists("lint", "eslint . --max-warnings=0");
|
|
824
1030
|
await packageJson4.addScriptIfNotExists("format", "prettier --write .");
|
|
825
1031
|
await packageJson4.addScriptIfNotExists("types:check", "tsc --noEmit");
|
|
826
|
-
|
|
1032
|
+
p9.note("Dodano konfiguracj\u0119 CI i skrypty.");
|
|
827
1033
|
};
|
|
828
1034
|
|
|
829
1035
|
// src/cli/install-lint-staged.ts
|
|
830
1036
|
var import_node_assert3 = __toESM(require("assert"), 1);
|
|
831
1037
|
var import_promises3 = require("fs/promises");
|
|
1038
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
832
1039
|
var packageJson5 = new PackageJson();
|
|
833
1040
|
var installLintStaged = async () => {
|
|
834
1041
|
await packageJson5.load();
|
|
835
1042
|
import_node_assert3.default.ok(packageJson5.json !== null);
|
|
836
1043
|
await installHusky();
|
|
837
1044
|
await packageJson5.install("lint-staged", { dev: true });
|
|
838
|
-
await (0, import_promises3.writeFile)(
|
|
1045
|
+
await (0, import_promises3.writeFile)(
|
|
1046
|
+
import_node_path6.default.join(projectRoot(), ".husky/pre-commit"),
|
|
1047
|
+
`${packageJson5.manager.localExecute} lint-staged
|
|
1048
|
+
`
|
|
1049
|
+
);
|
|
839
1050
|
packageJson5.json["lint-staged"] = {
|
|
840
1051
|
"*": "prettier -w --ignore-unknown"
|
|
841
1052
|
};
|
|
@@ -843,11 +1054,11 @@ var installLintStaged = async () => {
|
|
|
843
1054
|
};
|
|
844
1055
|
|
|
845
1056
|
// src/cli/install-prettier.ts
|
|
846
|
-
var
|
|
1057
|
+
var p10 = __toESM(require("@clack/prompts"), 1);
|
|
847
1058
|
var import_node_assert4 = __toESM(require("assert"), 1);
|
|
848
1059
|
var import_node_fs3 = require("fs");
|
|
849
1060
|
var fs3 = __toESM(require("fs/promises"), 1);
|
|
850
|
-
var
|
|
1061
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
851
1062
|
var prettierConfigNames = [
|
|
852
1063
|
".prettierrc.js",
|
|
853
1064
|
".prettierrc.cjs",
|
|
@@ -872,34 +1083,34 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
872
1083
|
version: ">=3"
|
|
873
1084
|
});
|
|
874
1085
|
const prettierConfig = prettierConfigNames.find(
|
|
875
|
-
(configName) => (0, import_node_fs3.existsSync)(
|
|
1086
|
+
(configName) => (0, import_node_fs3.existsSync)(import_node_path7.default.join(root2, configName))
|
|
876
1087
|
);
|
|
877
1088
|
const solvroPrettierPath = "@solvro/config/prettier";
|
|
878
1089
|
if (prettierConfig !== void 0 || packageJson6.json.prettier !== void 0) {
|
|
879
1090
|
if (packageJson6.json.prettier === solvroPrettierPath) {
|
|
880
|
-
|
|
1091
|
+
p10.note("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
|
|
881
1092
|
return;
|
|
882
1093
|
}
|
|
883
1094
|
if (isNonInteractive2) {
|
|
884
1095
|
for (const configName of prettierConfigNames) {
|
|
885
|
-
await fs3.rm(
|
|
1096
|
+
await fs3.rm(import_node_path7.default.join(root2, configName)).catch(() => null);
|
|
886
1097
|
}
|
|
887
1098
|
} else {
|
|
888
1099
|
const isConfirmed = await polishConfirm({
|
|
889
1100
|
message: `Znaleziono konfiguracj\u0119 Prettiera. Czy chcesz j\u0105 nadpisa\u0107?`
|
|
890
1101
|
});
|
|
891
|
-
if (
|
|
892
|
-
|
|
1102
|
+
if (p10.isCancel(isConfirmed) || !isConfirmed) {
|
|
1103
|
+
p10.cancel("Usu\u0144 konfiguracje Prettiera i spr\xF3buj ponownie.");
|
|
893
1104
|
process.exit(1);
|
|
894
1105
|
}
|
|
895
1106
|
for (const configName of prettierConfigNames) {
|
|
896
|
-
await fs3.rm(
|
|
1107
|
+
await fs3.rm(import_node_path7.default.join(root2, configName)).catch(() => null);
|
|
897
1108
|
}
|
|
898
1109
|
}
|
|
899
1110
|
}
|
|
900
1111
|
packageJson6.json.prettier = solvroPrettierPath;
|
|
901
1112
|
await packageJson6.save();
|
|
902
|
-
|
|
1113
|
+
p10.note("Konfiguracja Prettiera zosta\u0142a dodana.");
|
|
903
1114
|
};
|
|
904
1115
|
|
|
905
1116
|
// src/cli/index.ts
|
|
@@ -907,31 +1118,15 @@ var program = new import_commander.Command();
|
|
|
907
1118
|
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);
|
|
908
1119
|
program.parse();
|
|
909
1120
|
var options = program.opts();
|
|
910
|
-
var isNonInteractive =
|
|
1121
|
+
var isNonInteractive = checkIsNonInteractive();
|
|
911
1122
|
async function main() {
|
|
912
1123
|
if (!isNonInteractive) {
|
|
913
|
-
|
|
914
|
-
}
|
|
915
|
-
const userAgent = (0, import_detect.getUserAgent)();
|
|
916
|
-
if (userAgent !== "npm") {
|
|
917
|
-
const packageManager = userAgent ?? "unknown";
|
|
918
|
-
const warningMessage = `${import_picocolors2.default.red(import_picocolors2.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
919
|
-
|
|
920
|
-
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${import_picocolors2.default.yellow(packageManager)}'em, ale @solvro/config obecnie dzia\u0142a tylko z ${import_picocolors2.default.green("npm")}'em.
|
|
921
|
-
|
|
922
|
-
${import_picocolors2.default.white(`Support dla innych mened\u017Cer\xF3w pakiet\xF3w jest planowany w nadchodz\u0105cych wersjach - ${import_picocolors2.default.yellow("zagwiazdkuj i spr\xF3buj ponownie wkr\xF3tce")}!`)}
|
|
923
|
-
|
|
924
|
-
${import_picocolors2.default.white(`W mi\u0119dzyczasie u\u017Cyj ${import_picocolors2.default.green("npm")}'a:`)}
|
|
925
|
-
${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
926
|
-
if (isNonInteractive) {
|
|
927
|
-
console.error(warningMessage);
|
|
928
|
-
} else {
|
|
929
|
-
p8.cancel(warningMessage);
|
|
930
|
-
}
|
|
931
|
-
process.exit(1);
|
|
1124
|
+
p11.intro(import_picocolors5.default.bold(import_picocolors5.default.bgBlue(" @solvro/config ")));
|
|
932
1125
|
}
|
|
933
1126
|
const packageJson7 = new PackageJson();
|
|
1127
|
+
packageJson7.verifyPackageManager();
|
|
934
1128
|
await packageJson7.load();
|
|
1129
|
+
await packageJson7.validateUserAgentConsistency();
|
|
935
1130
|
if (options.force !== true && !isGitClean()) {
|
|
936
1131
|
if (isNonInteractive) {
|
|
937
1132
|
console.error(
|
|
@@ -942,15 +1137,15 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
942
1137
|
const isConfirmed = await polishConfirm({
|
|
943
1138
|
message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
|
|
944
1139
|
});
|
|
945
|
-
if (
|
|
946
|
-
|
|
1140
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1141
|
+
p11.cancel("Zapisz zmiany w Git i spr\xF3buj ponownie.");
|
|
947
1142
|
process.exit(1);
|
|
948
1143
|
}
|
|
949
1144
|
}
|
|
950
1145
|
if (await packageJson7.hasPackage("eslint") && !await packageJson7.doesSatisfy("eslint", "<10")) {
|
|
951
1146
|
const eslint = await packageJson7.getPackageInfo("eslint");
|
|
952
|
-
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${
|
|
953
|
-
const errorMessage = `ESLint w wersji powy\u017Cej 9 ${
|
|
1147
|
+
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${import_picocolors5.default.yellow(eslint.version)}.`;
|
|
1148
|
+
const errorMessage = `ESLint w wersji powy\u017Cej 9 ${import_picocolors5.default.red("nie jest jeszcze wspierany")}.${versionInfo}`;
|
|
954
1149
|
const errorRetry = "Prosz\u0119 zainstalowa\u0107 wersj\u0119 9 i spr\xF3bowa\u0107 ponownie.";
|
|
955
1150
|
if (isNonInteractive) {
|
|
956
1151
|
console.error(errorMessage);
|
|
@@ -958,10 +1153,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
958
1153
|
process.exit(1);
|
|
959
1154
|
}
|
|
960
1155
|
const isConfirmed = await polishConfirm({
|
|
961
|
-
message: `${errorMessage} Zainstalowa\u0107 starsz\u0105 wersj\u0119 ${
|
|
1156
|
+
message: `${errorMessage} Zainstalowa\u0107 starsz\u0105 wersj\u0119 ${import_picocolors5.default.magenta("ESLint")}'a? (Wymagane by kontynuowa\u0107)`
|
|
962
1157
|
});
|
|
963
|
-
if (
|
|
964
|
-
|
|
1158
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1159
|
+
p11.cancel(errorRetry);
|
|
965
1160
|
process.exit(1);
|
|
966
1161
|
}
|
|
967
1162
|
await packageJson7.install("eslint", { dev: true, version: "^9" });
|
|
@@ -969,17 +1164,17 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
969
1164
|
const projectType = await packageJson7.getProjectType();
|
|
970
1165
|
if (!isNonInteractive) {
|
|
971
1166
|
if (projectType === "adonis") {
|
|
972
|
-
await confirmProjectType(
|
|
1167
|
+
await confirmProjectType(import_picocolors5.default.magenta("Adonis"));
|
|
973
1168
|
}
|
|
974
1169
|
if (projectType === "react") {
|
|
975
|
-
await confirmProjectType(
|
|
1170
|
+
await confirmProjectType(import_picocolors5.default.cyan("React"));
|
|
976
1171
|
}
|
|
977
1172
|
if (projectType === "nestjs") {
|
|
978
|
-
await confirmProjectType(
|
|
1173
|
+
await confirmProjectType(import_picocolors5.default.red("NestJS"));
|
|
979
1174
|
}
|
|
980
1175
|
if (projectType === "node") {
|
|
981
|
-
|
|
982
|
-
`Nie znaleziono ani ${
|
|
1176
|
+
p11.cancel(
|
|
1177
|
+
`Nie znaleziono ani ${import_picocolors5.default.magenta("Adonis")}-a, ${import_picocolors5.default.cyan("React")}-a, ani ${import_picocolors5.default.white("NestJS")}-a. Musisz r\u0119cznie konfigurowa\u0107 projekt.`
|
|
983
1178
|
);
|
|
984
1179
|
process.exit(1);
|
|
985
1180
|
}
|
|
@@ -990,10 +1185,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
990
1185
|
} else {
|
|
991
1186
|
if (!await packageJson7.isESM()) {
|
|
992
1187
|
const isConfirmed = await polishConfirm({
|
|
993
|
-
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak type: "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
|
1188
|
+
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak "type": "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
|
994
1189
|
});
|
|
995
|
-
if (
|
|
996
|
-
|
|
1190
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1191
|
+
p11.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
|
997
1192
|
process.exit(1);
|
|
998
1193
|
}
|
|
999
1194
|
await packageJson7.ensureESM();
|
|
@@ -1023,35 +1218,35 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
1023
1218
|
process.exit(1);
|
|
1024
1219
|
}
|
|
1025
1220
|
} else {
|
|
1026
|
-
const additionalTools = await
|
|
1027
|
-
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${
|
|
1221
|
+
const additionalTools = await p11.multiselect({
|
|
1222
|
+
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${import_picocolors5.default.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
|
|
1028
1223
|
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
|
1029
1224
|
options: [
|
|
1030
1225
|
{
|
|
1031
1226
|
value: "eslint",
|
|
1032
|
-
label:
|
|
1227
|
+
label: import_picocolors5.default.bold(import_picocolors5.default.blueBright("ESLint")),
|
|
1033
1228
|
hint: "sprawdzanie jako\u015Bci kodu"
|
|
1034
1229
|
},
|
|
1035
1230
|
{
|
|
1036
1231
|
value: "prettier",
|
|
1037
|
-
label:
|
|
1232
|
+
label: import_picocolors5.default.bold(import_picocolors5.default.yellowBright("Prettier")),
|
|
1038
1233
|
hint: "formatowanie"
|
|
1039
1234
|
},
|
|
1040
1235
|
{
|
|
1041
1236
|
value: "gh-action",
|
|
1042
|
-
label:
|
|
1043
|
-
hint: "automatyczne testy na
|
|
1237
|
+
label: import_picocolors5.default.bold("GitHub Actions"),
|
|
1238
|
+
hint: "automatyczne testy na GitHubie"
|
|
1044
1239
|
},
|
|
1045
1240
|
{
|
|
1046
1241
|
value: "commitlint",
|
|
1047
|
-
label:
|
|
1242
|
+
label: import_picocolors5.default.bold("Commitlint"),
|
|
1048
1243
|
hint: "walidacja tre\u015Bci commit\xF3w"
|
|
1049
1244
|
}
|
|
1050
1245
|
],
|
|
1051
1246
|
required: false
|
|
1052
1247
|
});
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1248
|
+
if (p11.isCancel(additionalTools) || additionalTools.length === 0) {
|
|
1249
|
+
p11.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
|
1055
1250
|
process.exit(1);
|
|
1056
1251
|
}
|
|
1057
1252
|
toolsToInstall = additionalTools;
|
|
@@ -1074,7 +1269,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
1074
1269
|
await installGithubActions();
|
|
1075
1270
|
}
|
|
1076
1271
|
await packageJson7.clearInstall();
|
|
1077
|
-
|
|
1272
|
+
if (toolsToInstall.includes("prettier")) {
|
|
1273
|
+
await packageJson7.localExecute("prettier", "--write", "package.json");
|
|
1274
|
+
}
|
|
1275
|
+
const printSuccess = isNonInteractive ? console.info : p11.outro;
|
|
1078
1276
|
printSuccess("\u2705 Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
1079
1277
|
}
|
|
1080
1278
|
async function mainWrapper() {
|
|
@@ -1083,7 +1281,7 @@ async function mainWrapper() {
|
|
|
1083
1281
|
} catch (error) {
|
|
1084
1282
|
if (process.env.NODE_ENV === "development") {
|
|
1085
1283
|
console.error(
|
|
1086
|
-
|
|
1284
|
+
import_picocolors5.default.red("Unhandled error in main:"),
|
|
1087
1285
|
error instanceof Error ? error.message : error
|
|
1088
1286
|
);
|
|
1089
1287
|
} else {
|
|
@@ -1092,7 +1290,7 @@ async function mainWrapper() {
|
|
|
1092
1290
|
console.error(errorMessage);
|
|
1093
1291
|
console.error(BUG_TRACKER_URL);
|
|
1094
1292
|
} else {
|
|
1095
|
-
|
|
1293
|
+
p11.cancel(`${errorMessage} ${BUG_TRACKER_URL}`);
|
|
1096
1294
|
}
|
|
1097
1295
|
}
|
|
1098
1296
|
process.exit(1);
|