@solvro/config 3.0.0-beta.4 → 3.0.0-beta.6
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.cjs +144 -100
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +133 -93
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -22,15 +22,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
|
|
25
|
+
// node_modules/tsup/assets/cjs_shims.js
|
|
26
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
27
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
28
|
+
|
|
25
29
|
// src/cli/index.ts
|
|
26
|
-
var
|
|
30
|
+
var p13 = __toESM(require("@clack/prompts"), 1);
|
|
27
31
|
var import_commander = require("commander");
|
|
28
|
-
var
|
|
32
|
+
var import_picocolors8 = __toESM(require("picocolors"), 1);
|
|
29
33
|
|
|
30
34
|
// package.json
|
|
31
35
|
var package_default = {
|
|
32
36
|
name: "@solvro/config",
|
|
33
|
-
version: "3.0.0-beta.
|
|
37
|
+
version: "3.0.0-beta.5",
|
|
34
38
|
description: "Solvro's engineering style guide",
|
|
35
39
|
keywords: [
|
|
36
40
|
"eslint",
|
|
@@ -242,9 +246,9 @@ var confirmProjectType = async (projectType) => {
|
|
|
242
246
|
|
|
243
247
|
// src/utils/is-git-clean.ts
|
|
244
248
|
var import_node_child_process = require("child_process");
|
|
245
|
-
function isGitClean() {
|
|
249
|
+
function isGitClean(options2) {
|
|
246
250
|
try {
|
|
247
|
-
(0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
|
|
251
|
+
(0, import_node_child_process.execSync)("git diff-index --quiet HEAD --", { stdio: "ignore", ...options2 });
|
|
248
252
|
return true;
|
|
249
253
|
} catch {
|
|
250
254
|
return false;
|
|
@@ -258,7 +262,7 @@ var import_node_assert = __toESM(require("assert"), 1);
|
|
|
258
262
|
var import_promises = require("fs/promises");
|
|
259
263
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
260
264
|
var import_detect = require("package-manager-detector/detect");
|
|
261
|
-
var
|
|
265
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
262
266
|
var import_semver = __toESM(require("semver"), 1);
|
|
263
267
|
|
|
264
268
|
// src/utils/git-root.ts
|
|
@@ -350,11 +354,7 @@ var warnInconsistentUserAgent = ({
|
|
|
350
354
|
|
|
351
355
|
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)}.
|
|
352
356
|
${isSupportedPackageManager(detectedPackageManager) ? hintInstallWithDetected(PACKAGE_MANAGER_CONFIGS[detectedPackageManager]) : warnUnsupported(detectedPackageManager)}`;
|
|
353
|
-
|
|
354
|
-
console.error(warningMessage);
|
|
355
|
-
} else {
|
|
356
|
-
p4.cancel(warningMessage);
|
|
357
|
-
}
|
|
357
|
+
p4.cancel(warningMessage);
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
// src/utils/warn-missing-lockfile.ts
|
|
@@ -372,37 +372,35 @@ ${import_picocolors2.default.white("Je\u015Bli to si\u0119 zgadza, zainstaluj na
|
|
|
372
372
|
|
|
373
373
|
${import_picocolors2.default.cyan(manager.installDependencies)}
|
|
374
374
|
${import_picocolors2.default.cyan(`${manager.downloadExecute} @solvro/config@latest`)}`;
|
|
375
|
-
|
|
376
|
-
console.error(warningMessage);
|
|
377
|
-
} else {
|
|
378
|
-
p5.cancel(warningMessage);
|
|
379
|
-
}
|
|
375
|
+
p5.cancel(warningMessage);
|
|
380
376
|
};
|
|
381
377
|
|
|
382
378
|
// src/utils/warn-unsupported-package-manager.ts
|
|
383
379
|
var p6 = __toESM(require("@clack/prompts"), 1);
|
|
380
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
381
|
+
|
|
382
|
+
// src/utils/format-link.ts
|
|
384
383
|
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
384
|
+
var formatLink = (link) => import_picocolors3.default.white(import_picocolors3.default.underline(link));
|
|
385
|
+
|
|
386
|
+
// src/utils/warn-unsupported-package-manager.ts
|
|
385
387
|
var warnUnsupportedPackageManager = ({
|
|
386
388
|
userAgent
|
|
387
389
|
}) => {
|
|
388
390
|
const packageManager = userAgent ?? "<nieznany>";
|
|
389
|
-
const warningMessage = `${
|
|
391
|
+
const warningMessage = `${import_picocolors4.default.red(import_picocolors4.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
390
392
|
|
|
391
|
-
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${
|
|
393
|
+
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${import_picocolors4.default.yellow(packageManager)}-em, ale @solvro/config obecnie dzia\u0142a tylko z nast\u0119puj\u0105cymi mened\u017Cerami pakiet\xF3w:
|
|
392
394
|
|
|
393
|
-
${SUPPORTED_PACKAGE_MANAGERS.map((manager) =>
|
|
395
|
+
${SUPPORTED_PACKAGE_MANAGERS.map((manager) => import_picocolors4.default.white(`- ${import_picocolors4.default.cyan(manager)}`)).join("\n")}
|
|
394
396
|
|
|
395
|
-
${
|
|
396
|
-
${
|
|
397
|
+
${import_picocolors4.default.white(`Chcesz, aby dodano wsparcie dla ${import_picocolors4.default.yellow(packageManager)}-a? Daj nam zna\u0107!`)}
|
|
398
|
+
${formatLink(BUG_TRACKER_URL)}
|
|
397
399
|
|
|
398
|
-
${
|
|
400
|
+
${import_picocolors4.default.white(`W mi\u0119dzyczasie u\u017Cyj innego mened\u017Cera:`)}
|
|
399
401
|
|
|
400
|
-
${Object.values(PACKAGE_MANAGER_CONFIGS).map((config) =>
|
|
401
|
-
|
|
402
|
-
console.error(warningMessage);
|
|
403
|
-
} else {
|
|
404
|
-
p6.cancel(warningMessage);
|
|
405
|
-
}
|
|
402
|
+
${Object.values(PACKAGE_MANAGER_CONFIGS).map((config) => import_picocolors4.default.cyan(`${config.downloadExecute} @solvro/config`)).join(import_picocolors4.default.white("\nlub\n"))}`;
|
|
403
|
+
p6.cancel(warningMessage);
|
|
406
404
|
};
|
|
407
405
|
|
|
408
406
|
// src/utils/package-json.ts
|
|
@@ -450,7 +448,7 @@ var PackageJson = class {
|
|
|
450
448
|
const json = await (0, import_local_pkg.loadPackageJSON)(projectRoot());
|
|
451
449
|
if (json === null) {
|
|
452
450
|
p7.cancel(
|
|
453
|
-
`Nie znaleziono pliku ${
|
|
451
|
+
`Nie znaleziono pliku ${import_picocolors5.default.cyan("package.json")}. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu.`
|
|
454
452
|
);
|
|
455
453
|
process.exit(1);
|
|
456
454
|
}
|
|
@@ -493,7 +491,7 @@ var PackageJson = class {
|
|
|
493
491
|
const isNestJs = await (0, import_local_pkg.isPackageListed)("@nestjs/core");
|
|
494
492
|
if (isReact && isAdonis) {
|
|
495
493
|
p7.cancel(
|
|
496
|
-
`Projekty korzystaj\u0105ce zar\xF3wno z ${
|
|
494
|
+
`Projekty korzystaj\u0105ce zar\xF3wno z ${import_picocolors5.default.magenta("Adonis")}a jak i ${import_picocolors5.default.cyan("React")}a nie s\u0105 wspierane.`
|
|
497
495
|
);
|
|
498
496
|
process.exit(1);
|
|
499
497
|
}
|
|
@@ -587,7 +585,14 @@ var PackageJson = class {
|
|
|
587
585
|
}
|
|
588
586
|
async clearInstall() {
|
|
589
587
|
const [command, ...options2] = this.manager.cleanInstall.split(" ");
|
|
590
|
-
await
|
|
588
|
+
await runWithSpinner({
|
|
589
|
+
start: "Instalowanie pakiet\xF3w na \u015Bwie\u017Co",
|
|
590
|
+
stop: "Wszystkie pakiety zainstalowane \u{1F60D}",
|
|
591
|
+
error: "Instalacja pakiet\xF3w na \u015Bwie\u017Co nie powiod\u0142a si\u0119 \u{1F976}",
|
|
592
|
+
callback: async () => {
|
|
593
|
+
await $$(command, options2);
|
|
594
|
+
}
|
|
595
|
+
});
|
|
591
596
|
}
|
|
592
597
|
/**
|
|
593
598
|
* Gets the pnpm major version from package.json packageManager field or user agent.
|
|
@@ -614,6 +619,55 @@ var PackageJson = class {
|
|
|
614
619
|
}
|
|
615
620
|
};
|
|
616
621
|
|
|
622
|
+
// src/utils/print-intro.ts
|
|
623
|
+
var p8 = __toESM(require("@clack/prompts"), 1);
|
|
624
|
+
var import_node_fs = require("fs");
|
|
625
|
+
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
626
|
+
|
|
627
|
+
// src/utils/is-in-git-repo.ts
|
|
628
|
+
var import_node_child_process3 = require("child_process");
|
|
629
|
+
var isInGitRepo = (options2) => {
|
|
630
|
+
try {
|
|
631
|
+
(0, import_node_child_process3.execSync)("git rev-parse --is-inside-work-tree ", {
|
|
632
|
+
stdio: "ignore",
|
|
633
|
+
...options2
|
|
634
|
+
});
|
|
635
|
+
return true;
|
|
636
|
+
} catch {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// src/utils/print-intro.ts
|
|
642
|
+
var printIntro = () => {
|
|
643
|
+
const packageJsonUrl = new URL("../../package.json", importMetaUrl);
|
|
644
|
+
const packageJson7 = JSON.parse((0, import_node_fs.readFileSync)(packageJsonUrl, "utf8"));
|
|
645
|
+
const packageRoot = new URL("../", packageJsonUrl);
|
|
646
|
+
const execOptions = { cwd: packageRoot };
|
|
647
|
+
const clean = !isInGitRepo(execOptions) || isGitClean(execOptions);
|
|
648
|
+
const version = packageJson7.version == null || packageJson7.version.trim() === "" ? import_picocolors6.default.red("(unknown version)") : import_picocolors6.default.green(import_picocolors6.default.bold(`v${packageJson7.version}`));
|
|
649
|
+
const dirtyStatus = clean ? "" : import_picocolors6.default.white(" (dirty)");
|
|
650
|
+
p8.intro(
|
|
651
|
+
` ${import_picocolors6.default.blueBright(import_picocolors6.default.bold("@solvro/config"))} ${version}${dirtyStatus} `
|
|
652
|
+
);
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
// src/utils/print-outro.ts
|
|
656
|
+
var p9 = __toESM(require("@clack/prompts"), 1);
|
|
657
|
+
var import_picocolors7 = __toESM(require("picocolors"), 1);
|
|
658
|
+
var PROJECT_DOCS_URL = "https://docs.solvro.pl/projects/creating#konfiguracja-repozytorium";
|
|
659
|
+
var printOutro = () => {
|
|
660
|
+
p9.log.success("Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
661
|
+
p9.note(
|
|
662
|
+
`1. ${import_picocolors7.default.white(`${import_picocolors7.default.bold("Obowi\u0105zkowo")} zapoznaj si\u0119 z ${import_picocolors7.default.cyan("dokumentacj\u0105 tworzenia projekt\xF3w")}:`)}
|
|
663
|
+
${formatLink(PROJECT_DOCS_URL)}
|
|
664
|
+
2. ${import_picocolors7.default.white(`Pami\u0119taj o zostawianiu nam ${import_picocolors7.default.yellow("gwiazdek na GitHubie")}! \u2B50`)}
|
|
665
|
+
${formatLink(REPO_URL)}`,
|
|
666
|
+
"Kolejne kroki"
|
|
667
|
+
);
|
|
668
|
+
p9.outro("Mi\u0142ego dnia! \u{1F44B}");
|
|
669
|
+
};
|
|
670
|
+
|
|
617
671
|
// src/cli/install-commitlint.ts
|
|
618
672
|
var import_promises2 = require("fs/promises");
|
|
619
673
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -654,8 +708,8 @@ var installCommitLint = async () => {
|
|
|
654
708
|
};
|
|
655
709
|
|
|
656
710
|
// src/cli/install-eslint.ts
|
|
657
|
-
var
|
|
658
|
-
var
|
|
711
|
+
var p10 = __toESM(require("@clack/prompts"), 1);
|
|
712
|
+
var import_node_fs2 = require("fs");
|
|
659
713
|
var fs = __toESM(require("fs/promises"), 1);
|
|
660
714
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
661
715
|
var eslintConfigNames = [
|
|
@@ -684,15 +738,15 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
684
738
|
if (type === "react" && await packageJson3.isNextJs()) {
|
|
685
739
|
const is15 = await packageJson3.doesSatisfy("next", ">=15");
|
|
686
740
|
if (!is15) {
|
|
687
|
-
|
|
688
|
-
"Next.js musi by\u0107 w
|
|
741
|
+
p10.cancel(
|
|
742
|
+
"Next.js musi by\u0107 w co najmniej wersji 15. Zaktualizuj Next.js i spr\xF3buj ponownie.\nWi\u0119cej informacji tutaj: https://nextjs.org/docs/app/building-your-application/upgrading/version-15"
|
|
689
743
|
);
|
|
690
744
|
process.exit(1);
|
|
691
745
|
}
|
|
692
746
|
await packageJson3.install("@next/eslint-plugin-next", { dev: true });
|
|
693
747
|
}
|
|
694
748
|
const eslintConfig = eslintConfigNames.find(
|
|
695
|
-
(configName) => (0,
|
|
749
|
+
(configName) => (0, import_node_fs2.existsSync)(import_node_path4.default.join(root2, configName))
|
|
696
750
|
);
|
|
697
751
|
if (eslintConfig !== void 0) {
|
|
698
752
|
const eslintContent = await fs.readFile(
|
|
@@ -700,17 +754,17 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
700
754
|
"utf8"
|
|
701
755
|
);
|
|
702
756
|
if (eslintContent.includes("export default solvro(")) {
|
|
703
|
-
|
|
757
|
+
p10.log.warning("ESLint jest ju\u017C skonfigurowany. Pomijam.");
|
|
704
758
|
return;
|
|
705
759
|
} else {
|
|
706
760
|
if (isNonInteractive2) {
|
|
707
761
|
await fs.rm(import_node_path4.default.join(root2, eslintConfig));
|
|
708
762
|
} else {
|
|
709
763
|
const isConfirmed = await polishConfirm({
|
|
710
|
-
message: `Znaleziono plik konfiguracyjny
|
|
764
|
+
message: `Znaleziono plik konfiguracyjny ESLint. Czy chcesz go nadpisa\u0107?`
|
|
711
765
|
});
|
|
712
|
-
if (
|
|
713
|
-
|
|
766
|
+
if (p10.isCancel(isConfirmed) || !isConfirmed) {
|
|
767
|
+
p10.cancel("Nadpisz plik konfiguracyjny ESLint i spr\xF3buj ponownie.");
|
|
714
768
|
process.exit(1);
|
|
715
769
|
}
|
|
716
770
|
await fs.rm(import_node_path4.default.join(root2, eslintConfig));
|
|
@@ -726,12 +780,12 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
726
780
|
export default solvro();
|
|
727
781
|
`
|
|
728
782
|
);
|
|
729
|
-
|
|
783
|
+
p10.log.step("Plik konfiguracyjny ESLint zosta\u0142 utworzony.");
|
|
730
784
|
};
|
|
731
785
|
|
|
732
786
|
// src/cli/install-ga.ts
|
|
733
|
-
var
|
|
734
|
-
var
|
|
787
|
+
var p11 = __toESM(require("@clack/prompts"), 1);
|
|
788
|
+
var import_node_fs3 = require("fs");
|
|
735
789
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
736
790
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
737
791
|
|
|
@@ -994,8 +1048,8 @@ var installGithubActions = async () => {
|
|
|
994
1048
|
const pnpmVersion = manager.name === "pnpm" ? await packageJson4.getPnpmVersion() : void 0;
|
|
995
1049
|
const withCommitlint = await packageJson4.hasPackage("@commitlint/cli");
|
|
996
1050
|
if (type === "adonis") {
|
|
997
|
-
if (!(0,
|
|
998
|
-
|
|
1051
|
+
if (!(0, import_node_fs3.existsSync)(import_node_path5.default.join(projectDirectory, ".env.example"))) {
|
|
1052
|
+
p11.cancel(
|
|
999
1053
|
"Nie znaleziono pliku .env.example. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu Adonisa."
|
|
1000
1054
|
);
|
|
1001
1055
|
process.exit(1);
|
|
@@ -1046,12 +1100,12 @@ var installGithubActions = async () => {
|
|
|
1046
1100
|
'prettier --write "src/**/*.ts" "test/**/*.ts"'
|
|
1047
1101
|
);
|
|
1048
1102
|
if (!formatScriptUpdated) {
|
|
1049
|
-
|
|
1103
|
+
p11.log.warning(
|
|
1050
1104
|
"Aktualizacja skryptu format zosta\u0142a pomini\u0119ta, poniewa\u017C zosta\u0142 on zmieniony lub nie istnieje. R\u0119cznie zaktualizuj skrypt format w package.json, aby formatowa\u0142 wszystkie pliki projektu, a nie tylko te w katalogach src i test."
|
|
1051
1105
|
);
|
|
1052
1106
|
}
|
|
1053
1107
|
}
|
|
1054
|
-
if (!(0,
|
|
1108
|
+
if (!(0, import_node_fs3.existsSync)(import_node_path5.default.join(gitDirectory, ".github/dependabot.yml"))) {
|
|
1055
1109
|
await fs2.writeFile(
|
|
1056
1110
|
import_node_path5.default.join(gitDirectory, ".github/dependabot.yml"),
|
|
1057
1111
|
dependabot()
|
|
@@ -1061,7 +1115,7 @@ var installGithubActions = async () => {
|
|
|
1061
1115
|
await packageJson4.addScriptIfNotExists("format:check", "prettier --check .");
|
|
1062
1116
|
await packageJson4.addScriptIfNotExists("lint", "eslint . --max-warnings=0");
|
|
1063
1117
|
await packageJson4.addScriptIfNotExists("types:check", "tsc --noEmit");
|
|
1064
|
-
|
|
1118
|
+
p11.log.step("Dodano konfiguracj\u0119 CI i skrypty.");
|
|
1065
1119
|
};
|
|
1066
1120
|
|
|
1067
1121
|
// src/cli/install-lint-staged.ts
|
|
@@ -1086,9 +1140,9 @@ var installLintStaged = async () => {
|
|
|
1086
1140
|
};
|
|
1087
1141
|
|
|
1088
1142
|
// src/cli/install-prettier.ts
|
|
1089
|
-
var
|
|
1143
|
+
var p12 = __toESM(require("@clack/prompts"), 1);
|
|
1090
1144
|
var import_node_assert4 = __toESM(require("assert"), 1);
|
|
1091
|
-
var
|
|
1145
|
+
var import_node_fs4 = require("fs");
|
|
1092
1146
|
var fs3 = __toESM(require("fs/promises"), 1);
|
|
1093
1147
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
1094
1148
|
var prettierConfigNames = [
|
|
@@ -1115,12 +1169,12 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
1115
1169
|
version: ">=3"
|
|
1116
1170
|
});
|
|
1117
1171
|
const prettierConfig = prettierConfigNames.find(
|
|
1118
|
-
(configName) => (0,
|
|
1172
|
+
(configName) => (0, import_node_fs4.existsSync)(import_node_path7.default.join(root2, configName))
|
|
1119
1173
|
);
|
|
1120
1174
|
const solvroPrettierPath = "@solvro/config/prettier";
|
|
1121
1175
|
if (prettierConfig !== void 0 || packageJson6.json.prettier !== void 0) {
|
|
1122
1176
|
if (packageJson6.json.prettier === solvroPrettierPath) {
|
|
1123
|
-
|
|
1177
|
+
p12.log.warning("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
|
|
1124
1178
|
return;
|
|
1125
1179
|
}
|
|
1126
1180
|
if (isNonInteractive2) {
|
|
@@ -1131,8 +1185,8 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
1131
1185
|
const isConfirmed = await polishConfirm({
|
|
1132
1186
|
message: `Znaleziono konfiguracj\u0119 Prettiera. Czy chcesz j\u0105 nadpisa\u0107?`
|
|
1133
1187
|
});
|
|
1134
|
-
if (
|
|
1135
|
-
|
|
1188
|
+
if (p12.isCancel(isConfirmed) || !isConfirmed) {
|
|
1189
|
+
p12.cancel("Usu\u0144 konfiguracje Prettiera i spr\xF3buj ponownie.");
|
|
1136
1190
|
process.exit(1);
|
|
1137
1191
|
}
|
|
1138
1192
|
for (const configName of prettierConfigNames) {
|
|
@@ -1142,7 +1196,7 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
1142
1196
|
}
|
|
1143
1197
|
packageJson6.json.prettier = solvroPrettierPath;
|
|
1144
1198
|
await packageJson6.save();
|
|
1145
|
-
|
|
1199
|
+
p12.log.step("Konfiguracja Prettiera zosta\u0142a dodana.");
|
|
1146
1200
|
};
|
|
1147
1201
|
|
|
1148
1202
|
// src/cli/index.ts
|
|
@@ -1152,43 +1206,40 @@ program.parse();
|
|
|
1152
1206
|
var options = program.opts();
|
|
1153
1207
|
var isNonInteractive = checkIsNonInteractive();
|
|
1154
1208
|
async function main() {
|
|
1155
|
-
|
|
1156
|
-
p11.intro(import_picocolors5.default.bold(import_picocolors5.default.bgBlue(" @solvro/config ")));
|
|
1157
|
-
}
|
|
1209
|
+
printIntro();
|
|
1158
1210
|
const packageJson7 = new PackageJson();
|
|
1159
1211
|
packageJson7.verifyPackageManager();
|
|
1160
1212
|
await packageJson7.load();
|
|
1161
1213
|
await packageJson7.validateUserAgentConsistency();
|
|
1162
1214
|
if (options.force !== true && !isGitClean()) {
|
|
1163
1215
|
if (isNonInteractive) {
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
);
|
|
1216
|
+
p13.log.error("Repozytorium Git ma niezatwierdzone zmiany.");
|
|
1217
|
+
p13.cancel("U\u017Cyj --force, aby pomin\u0105\u0107 to sprawdzenie.");
|
|
1167
1218
|
process.exit(1);
|
|
1168
1219
|
}
|
|
1169
1220
|
const isConfirmed = await polishConfirm({
|
|
1170
1221
|
message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
|
|
1171
1222
|
});
|
|
1172
|
-
if (
|
|
1173
|
-
|
|
1223
|
+
if (p13.isCancel(isConfirmed) || !isConfirmed) {
|
|
1224
|
+
p13.cancel("Zapisz zmiany w Git i spr\xF3buj ponownie.");
|
|
1174
1225
|
process.exit(1);
|
|
1175
1226
|
}
|
|
1176
1227
|
}
|
|
1177
1228
|
if (await packageJson7.hasPackage("eslint") && !await packageJson7.doesSatisfy("eslint", "<10")) {
|
|
1178
1229
|
const eslint = await packageJson7.getPackageInfo("eslint");
|
|
1179
|
-
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${
|
|
1180
|
-
const errorMessage = `ESLint w wersji powy\u017Cej 9
|
|
1230
|
+
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${import_picocolors8.default.yellow(eslint.version)}.`;
|
|
1231
|
+
const errorMessage = `ESLint w wersji powy\u017Cej 9 nie jest jeszcze wspierany.${versionInfo}`;
|
|
1181
1232
|
const errorRetry = "Prosz\u0119 zainstalowa\u0107 wersj\u0119 9 i spr\xF3bowa\u0107 ponownie.";
|
|
1182
1233
|
if (isNonInteractive) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1234
|
+
p13.log.error(errorMessage);
|
|
1235
|
+
p13.cancel(errorRetry);
|
|
1185
1236
|
process.exit(1);
|
|
1186
1237
|
}
|
|
1187
1238
|
const isConfirmed = await polishConfirm({
|
|
1188
|
-
message: `${errorMessage} Zainstalowa\u0107 starsz\u0105 wersj\u0119 ${
|
|
1239
|
+
message: `${errorMessage} Zainstalowa\u0107 starsz\u0105 wersj\u0119 ${import_picocolors8.default.magenta("ESLint")}'a? (Wymagane by kontynuowa\u0107)`
|
|
1189
1240
|
});
|
|
1190
|
-
if (
|
|
1191
|
-
|
|
1241
|
+
if (p13.isCancel(isConfirmed) || !isConfirmed) {
|
|
1242
|
+
p13.cancel(errorRetry);
|
|
1192
1243
|
process.exit(1);
|
|
1193
1244
|
}
|
|
1194
1245
|
await packageJson7.install("eslint", { dev: true, version: "^9" });
|
|
@@ -1196,17 +1247,17 @@ async function main() {
|
|
|
1196
1247
|
const projectType = await packageJson7.getProjectType();
|
|
1197
1248
|
if (!isNonInteractive) {
|
|
1198
1249
|
if (projectType === "adonis") {
|
|
1199
|
-
await confirmProjectType(
|
|
1250
|
+
await confirmProjectType(import_picocolors8.default.magenta("Adonis"));
|
|
1200
1251
|
}
|
|
1201
1252
|
if (projectType === "react") {
|
|
1202
|
-
await confirmProjectType(
|
|
1253
|
+
await confirmProjectType(import_picocolors8.default.cyan("React"));
|
|
1203
1254
|
}
|
|
1204
1255
|
if (projectType === "nestjs") {
|
|
1205
|
-
await confirmProjectType(
|
|
1256
|
+
await confirmProjectType(import_picocolors8.default.red("NestJS"));
|
|
1206
1257
|
}
|
|
1207
1258
|
if (projectType === "node") {
|
|
1208
|
-
|
|
1209
|
-
`Nie znaleziono ani ${
|
|
1259
|
+
p13.cancel(
|
|
1260
|
+
`Nie znaleziono ani ${import_picocolors8.default.magenta("Adonis")}-a, ${import_picocolors8.default.cyan("React")}-a, ani ${import_picocolors8.default.white("NestJS")}-a. Musisz r\u0119cznie konfigurowa\u0107 projekt.`
|
|
1210
1261
|
);
|
|
1211
1262
|
process.exit(1);
|
|
1212
1263
|
}
|
|
@@ -1219,8 +1270,8 @@ async function main() {
|
|
|
1219
1270
|
const isConfirmed = await polishConfirm({
|
|
1220
1271
|
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak "type": "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
|
1221
1272
|
});
|
|
1222
|
-
if (
|
|
1223
|
-
|
|
1273
|
+
if (p13.isCancel(isConfirmed) || !isConfirmed) {
|
|
1274
|
+
p13.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
|
1224
1275
|
process.exit(1);
|
|
1225
1276
|
}
|
|
1226
1277
|
await packageJson7.ensureESM();
|
|
@@ -1244,41 +1295,42 @@ async function main() {
|
|
|
1244
1295
|
toolsToInstall.push("commitlint");
|
|
1245
1296
|
}
|
|
1246
1297
|
if (toolsToInstall.length === 0) {
|
|
1247
|
-
|
|
1248
|
-
|
|
1298
|
+
p13.log.error("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
|
1299
|
+
p13.cancel(
|
|
1300
|
+
"U\u017Cyj --eslint, --prettier, --gh-action, --commitlint, lub --all"
|
|
1249
1301
|
);
|
|
1250
1302
|
process.exit(1);
|
|
1251
1303
|
}
|
|
1252
1304
|
} else {
|
|
1253
|
-
const additionalTools = await
|
|
1254
|
-
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${
|
|
1305
|
+
const additionalTools = await p13.multiselect({
|
|
1306
|
+
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${import_picocolors8.default.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
|
|
1255
1307
|
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
|
1256
1308
|
options: [
|
|
1257
1309
|
{
|
|
1258
1310
|
value: "eslint",
|
|
1259
|
-
label:
|
|
1311
|
+
label: import_picocolors8.default.bold(import_picocolors8.default.blueBright("ESLint")),
|
|
1260
1312
|
hint: "sprawdzanie jako\u015Bci kodu"
|
|
1261
1313
|
},
|
|
1262
1314
|
{
|
|
1263
1315
|
value: "prettier",
|
|
1264
|
-
label:
|
|
1316
|
+
label: import_picocolors8.default.bold(import_picocolors8.default.yellowBright("Prettier")),
|
|
1265
1317
|
hint: "formatowanie"
|
|
1266
1318
|
},
|
|
1267
1319
|
{
|
|
1268
1320
|
value: "gh-action",
|
|
1269
|
-
label:
|
|
1321
|
+
label: import_picocolors8.default.bold("GitHub Actions"),
|
|
1270
1322
|
hint: "automatyczne testy na GitHubie"
|
|
1271
1323
|
},
|
|
1272
1324
|
{
|
|
1273
1325
|
value: "commitlint",
|
|
1274
|
-
label:
|
|
1326
|
+
label: import_picocolors8.default.bold("Commitlint"),
|
|
1275
1327
|
hint: "walidacja tre\u015Bci commit\xF3w"
|
|
1276
1328
|
}
|
|
1277
1329
|
],
|
|
1278
1330
|
required: false
|
|
1279
1331
|
});
|
|
1280
|
-
if (
|
|
1281
|
-
|
|
1332
|
+
if (p13.isCancel(additionalTools) || additionalTools.length === 0) {
|
|
1333
|
+
p13.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
|
1282
1334
|
process.exit(1);
|
|
1283
1335
|
}
|
|
1284
1336
|
toolsToInstall = additionalTools;
|
|
@@ -1304,26 +1356,18 @@ async function main() {
|
|
|
1304
1356
|
if (toolsToInstall.includes("prettier")) {
|
|
1305
1357
|
await packageJson7.localExecute("prettier", "--write", "package.json");
|
|
1306
1358
|
}
|
|
1307
|
-
|
|
1308
|
-
printSuccess("\u2705 Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
1359
|
+
printOutro();
|
|
1309
1360
|
}
|
|
1310
1361
|
async function mainWrapper() {
|
|
1311
1362
|
try {
|
|
1312
1363
|
await main();
|
|
1313
1364
|
} catch (error) {
|
|
1314
1365
|
if (process.env.NODE_ENV === "development") {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
error instanceof Error ? error.message : error
|
|
1318
|
-
);
|
|
1366
|
+
p13.cancel("Unhandled error in main:");
|
|
1367
|
+
console.error(error instanceof Error ? error.message : error);
|
|
1319
1368
|
} else {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
console.error(errorMessage);
|
|
1323
|
-
console.error(BUG_TRACKER_URL);
|
|
1324
|
-
} else {
|
|
1325
|
-
p11.cancel(`${errorMessage} ${BUG_TRACKER_URL}`);
|
|
1326
|
-
}
|
|
1369
|
+
p13.log.error("Wyst\u0105pi\u0142 nieoczekiwany b\u0142\u0105d :(");
|
|
1370
|
+
p13.cancel(`Prosz\u0119 zg\u0142osi\u0107 go tw\xF3rcom: ${BUG_TRACKER_URL}`);
|
|
1327
1371
|
}
|
|
1328
1372
|
process.exit(1);
|
|
1329
1373
|
}
|