@solvro/config 2.1.1 → 2.2.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/dist/cli/index.cjs +185 -118
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +185 -118
- package/dist/cli/index.js.map +1 -1
- package/dist/eslint/index.cjs +0 -1
- package/dist/eslint/index.cjs.map +1 -1
- package/dist/eslint/index.js +0 -1
- package/dist/eslint/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// src/cli/index.ts
|
|
2
|
-
import * as
|
|
2
|
+
import * as p8 from "@clack/prompts";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { getUserAgent } from "package-manager-detector/detect";
|
|
5
|
-
import
|
|
5
|
+
import c2 from "picocolors";
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "@solvro/config",
|
|
10
|
-
version: "2.1.
|
|
10
|
+
version: "2.1.1",
|
|
11
11
|
description: "Solvro's engineering style guide",
|
|
12
12
|
keywords: [
|
|
13
13
|
"eslint",
|
|
@@ -142,6 +142,44 @@ var package_default = {
|
|
|
142
142
|
}
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
+
// src/constants/index.ts
|
|
146
|
+
var REPO_URL = "https://github.com/Solvro/lib-web-solvro-config";
|
|
147
|
+
var BUG_TRACKER_URL = `${REPO_URL}/issues/new`;
|
|
148
|
+
|
|
149
|
+
// src/utils/confirm-project-type.ts
|
|
150
|
+
import * as p2 from "@clack/prompts";
|
|
151
|
+
|
|
152
|
+
// src/utils/polish-confirm.ts
|
|
153
|
+
import * as p from "@clack/prompts";
|
|
154
|
+
import isInteractive from "is-interactive";
|
|
155
|
+
var polishConfirm = async (props) => {
|
|
156
|
+
if (!isInteractive()) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
return p.confirm({
|
|
160
|
+
active: "Tak",
|
|
161
|
+
inactive: "Nie",
|
|
162
|
+
...props
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// src/utils/confirm-project-type.ts
|
|
167
|
+
var confirmProjectType = async (projectType) => {
|
|
168
|
+
const isConfirmed = await polishConfirm({
|
|
169
|
+
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 ${projectType}'a. Czy to si\u0119 zgadza?`
|
|
170
|
+
});
|
|
171
|
+
if (p2.isCancel(isConfirmed)) {
|
|
172
|
+
p2.cancel("\u{1F621}");
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
if (!isConfirmed) {
|
|
176
|
+
p2.cancel(
|
|
177
|
+
`:( Zg\u0142o\u015B b\u0142\u0105d na GitHubie, a my spr\xF3bujemy pom\xF3c: ${BUG_TRACKER_URL}`
|
|
178
|
+
);
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
145
183
|
// src/utils/is-git-clean.ts
|
|
146
184
|
import { execSync } from "child_process";
|
|
147
185
|
function isGitClean() {
|
|
@@ -154,11 +192,12 @@ function isGitClean() {
|
|
|
154
192
|
}
|
|
155
193
|
|
|
156
194
|
// src/utils/package-json.ts
|
|
157
|
-
import * as
|
|
195
|
+
import * as p4 from "@clack/prompts";
|
|
158
196
|
import { getPackageInfo, isPackageListed, loadPackageJSON } from "local-pkg";
|
|
159
197
|
import assert from "assert";
|
|
160
198
|
import { writeFile } from "fs/promises";
|
|
161
199
|
import path2 from "path";
|
|
200
|
+
import c from "picocolors";
|
|
162
201
|
import semver from "semver";
|
|
163
202
|
|
|
164
203
|
// src/utils/git-root.ts
|
|
@@ -195,23 +234,45 @@ var $$ = (async (...arguments_) => {
|
|
|
195
234
|
return cachedExeca(...arguments_);
|
|
196
235
|
});
|
|
197
236
|
|
|
237
|
+
// src/utils/run-with-spinner.ts
|
|
238
|
+
import * as p3 from "@clack/prompts";
|
|
239
|
+
|
|
198
240
|
// src/utils/run-if-interactive.ts
|
|
199
|
-
import
|
|
241
|
+
import isInteractive2 from "is-interactive";
|
|
200
242
|
var runIfInteractive = (function_) => {
|
|
201
|
-
if (
|
|
243
|
+
if (isInteractive2()) {
|
|
202
244
|
return function_();
|
|
203
245
|
}
|
|
204
246
|
return void 0;
|
|
205
247
|
};
|
|
206
248
|
|
|
249
|
+
// src/utils/run-with-spinner.ts
|
|
250
|
+
var runWithSpinner = async (options2) => {
|
|
251
|
+
const spinner2 = p3.spinner();
|
|
252
|
+
runIfInteractive(() => {
|
|
253
|
+
spinner2.start(options2.start);
|
|
254
|
+
});
|
|
255
|
+
try {
|
|
256
|
+
await options2.callback();
|
|
257
|
+
} catch (error) {
|
|
258
|
+
runIfInteractive(() => {
|
|
259
|
+
spinner2.error(options2.error);
|
|
260
|
+
});
|
|
261
|
+
throw error;
|
|
262
|
+
}
|
|
263
|
+
runIfInteractive(() => {
|
|
264
|
+
spinner2.stop(options2.stop);
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
|
|
207
268
|
// src/utils/package-json.ts
|
|
208
269
|
var PackageJson = class {
|
|
209
270
|
json = null;
|
|
210
271
|
async load() {
|
|
211
272
|
const json = await loadPackageJSON(projectRoot());
|
|
212
273
|
if (json === null) {
|
|
213
|
-
|
|
214
|
-
|
|
274
|
+
p4.cancel(
|
|
275
|
+
`Nie znaleziono pliku ${c.cyan("package.json")}. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu.`
|
|
215
276
|
);
|
|
216
277
|
process.exit(1);
|
|
217
278
|
}
|
|
@@ -223,10 +284,13 @@ var PackageJson = class {
|
|
|
223
284
|
async isNextJs() {
|
|
224
285
|
return this.hasPackage("next");
|
|
225
286
|
}
|
|
226
|
-
async
|
|
287
|
+
async getPackageInfo(package_) {
|
|
288
|
+
return getPackageInfo(package_);
|
|
289
|
+
}
|
|
290
|
+
async doesSatisfy(package_, version) {
|
|
227
291
|
await this.load();
|
|
228
292
|
assert.ok(this.json !== null);
|
|
229
|
-
const packageInfo = await getPackageInfo(package_);
|
|
293
|
+
const packageInfo = await this.getPackageInfo(package_);
|
|
230
294
|
if (packageInfo?.version === void 0) {
|
|
231
295
|
return false;
|
|
232
296
|
}
|
|
@@ -250,9 +314,10 @@ var PackageJson = class {
|
|
|
250
314
|
const isReact = await isPackageListed("react");
|
|
251
315
|
const isNestJs = await isPackageListed("@nestjs/core");
|
|
252
316
|
if (isReact && isAdonis) {
|
|
253
|
-
|
|
254
|
-
|
|
317
|
+
p4.cancel(
|
|
318
|
+
`Projekty korzystaj\u0105ce zar\xF3wno z ${c.magenta("Adonis")}a jak i ${c.cyan("React")}a nie s\u0105 wspierane.`
|
|
255
319
|
);
|
|
320
|
+
process.exit(1);
|
|
256
321
|
}
|
|
257
322
|
if (isNestJs) {
|
|
258
323
|
return "nestjs";
|
|
@@ -282,29 +347,29 @@ var PackageJson = class {
|
|
|
282
347
|
this.json.scripts[name] = script;
|
|
283
348
|
await this.save();
|
|
284
349
|
}
|
|
285
|
-
async install(package_, options2) {
|
|
350
|
+
async install(package_, options2 = {}) {
|
|
286
351
|
const isInstalled = await this.hasPackage(package_);
|
|
352
|
+
const installVersion = options2.version ?? "latest";
|
|
287
353
|
if (!isInstalled) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
354
|
+
await runWithSpinner({
|
|
355
|
+
start: `Instalowanie pakietu ${package_}`,
|
|
356
|
+
stop: `${package_} zainstalowany \u{1F60D}`,
|
|
357
|
+
error: `Instalacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
358
|
+
callback: async () => {
|
|
359
|
+
await $$`npm i ${options2.dev === true ? "-D" : ""} ${package_}@${installVersion}`;
|
|
360
|
+
}
|
|
295
361
|
});
|
|
296
362
|
await this.load();
|
|
297
363
|
return;
|
|
298
364
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
spinner2.stop(`${package_} zaktualizowany \u{1F60D}`);
|
|
365
|
+
if (options2.alwaysUpdate === true || options2.version != null && !await this.doesSatisfy(package_, options2.version)) {
|
|
366
|
+
await runWithSpinner({
|
|
367
|
+
start: `Aktualizowanie pakietu ${package_}`,
|
|
368
|
+
stop: `${package_} zaktualizowany \u{1F60D}`,
|
|
369
|
+
error: `Aktualizacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
370
|
+
callback: async () => {
|
|
371
|
+
await $$`npm i ${options2.dev === true ? "-D" : ""} ${package_}@${installVersion}`;
|
|
372
|
+
}
|
|
308
373
|
});
|
|
309
374
|
await this.load();
|
|
310
375
|
}
|
|
@@ -314,20 +379,6 @@ var PackageJson = class {
|
|
|
314
379
|
}
|
|
315
380
|
};
|
|
316
381
|
|
|
317
|
-
// src/utils/polish-confirm.ts
|
|
318
|
-
import * as p2 from "@clack/prompts";
|
|
319
|
-
import isInteractive2 from "is-interactive";
|
|
320
|
-
var polishConfirm = async (props) => {
|
|
321
|
-
if (!isInteractive2()) {
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
return p2.confirm({
|
|
325
|
-
active: "Tak",
|
|
326
|
-
inactive: "Nie",
|
|
327
|
-
...props
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
|
|
331
382
|
// src/cli/install-commitlint.ts
|
|
332
383
|
import { writeFile as writeFile2 } from "fs/promises";
|
|
333
384
|
import path3 from "path";
|
|
@@ -367,7 +418,7 @@ var installCommitLint = async () => {
|
|
|
367
418
|
};
|
|
368
419
|
|
|
369
420
|
// src/cli/install-eslint.ts
|
|
370
|
-
import * as
|
|
421
|
+
import * as p5 from "@clack/prompts";
|
|
371
422
|
import { existsSync } from "fs";
|
|
372
423
|
import * as fs from "fs/promises";
|
|
373
424
|
import path4 from "path";
|
|
@@ -389,12 +440,15 @@ var packageJson3 = new PackageJson();
|
|
|
389
440
|
var installEslint = async (isNonInteractive2 = false) => {
|
|
390
441
|
const root2 = projectRoot();
|
|
391
442
|
await packageJson3.load();
|
|
392
|
-
await packageJson3.install("eslint", {
|
|
443
|
+
await packageJson3.install("eslint", {
|
|
444
|
+
dev: true,
|
|
445
|
+
version: "^9"
|
|
446
|
+
});
|
|
393
447
|
const type = await packageJson3.getProjectType();
|
|
394
448
|
if (type === "react" && await packageJson3.isNextJs()) {
|
|
395
|
-
const is15 = await packageJson3.
|
|
449
|
+
const is15 = await packageJson3.doesSatisfy("next", ">=15");
|
|
396
450
|
if (!is15) {
|
|
397
|
-
|
|
451
|
+
p5.cancel(
|
|
398
452
|
"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"
|
|
399
453
|
);
|
|
400
454
|
process.exit(1);
|
|
@@ -410,7 +464,7 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
410
464
|
"utf8"
|
|
411
465
|
);
|
|
412
466
|
if (eslintContent.includes("export default solvro(")) {
|
|
413
|
-
|
|
467
|
+
p5.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
|
|
414
468
|
return;
|
|
415
469
|
} else {
|
|
416
470
|
if (isNonInteractive2) {
|
|
@@ -419,8 +473,8 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
419
473
|
const isConfirmed = await polishConfirm({
|
|
420
474
|
message: `Znaleziono plik konfiguracyjny Eslint. Czy chcesz go nadpisa\u0107?`
|
|
421
475
|
});
|
|
422
|
-
if (
|
|
423
|
-
|
|
476
|
+
if (p5.isCancel(isConfirmed) || !isConfirmed) {
|
|
477
|
+
p5.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
|
|
424
478
|
process.exit(1);
|
|
425
479
|
}
|
|
426
480
|
await fs.rm(path4.join(root2, eslintConfig));
|
|
@@ -436,11 +490,11 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
436
490
|
export default solvro();
|
|
437
491
|
`
|
|
438
492
|
);
|
|
439
|
-
|
|
493
|
+
p5.note("Plik konfiguracyjny Eslint zosta\u0142 utworzony.");
|
|
440
494
|
};
|
|
441
495
|
|
|
442
496
|
// src/cli/install-ga.ts
|
|
443
|
-
import * as
|
|
497
|
+
import * as p6 from "@clack/prompts";
|
|
444
498
|
import { existsSync as existsSync2 } from "fs";
|
|
445
499
|
import * as fs2 from "fs/promises";
|
|
446
500
|
import path5 from "path";
|
|
@@ -693,7 +747,7 @@ var installGithubActions = async () => {
|
|
|
693
747
|
const withCommitlint = await packageJson4.hasPackage("@commitlint/cli");
|
|
694
748
|
if (type === "adonis") {
|
|
695
749
|
if (!existsSync2(path5.join(projectDirectory, ".env.example"))) {
|
|
696
|
-
|
|
750
|
+
p6.cancel(
|
|
697
751
|
"Nie znaleziono pliku .env.example. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu Adonisa."
|
|
698
752
|
);
|
|
699
753
|
process.exit(1);
|
|
@@ -743,7 +797,7 @@ var installGithubActions = async () => {
|
|
|
743
797
|
await packageJson4.addScriptIfNotExists("lint", "eslint . --max-warnings=0");
|
|
744
798
|
await packageJson4.addScriptIfNotExists("format", "prettier --write .");
|
|
745
799
|
await packageJson4.addScriptIfNotExists("types:check", "tsc --noEmit");
|
|
746
|
-
|
|
800
|
+
p6.note("Dodano konfiguracj\u0119 CI i skrypty.");
|
|
747
801
|
};
|
|
748
802
|
|
|
749
803
|
// src/cli/install-lint-staged.ts
|
|
@@ -763,7 +817,7 @@ var installLintStaged = async () => {
|
|
|
763
817
|
};
|
|
764
818
|
|
|
765
819
|
// src/cli/install-prettier.ts
|
|
766
|
-
import * as
|
|
820
|
+
import * as p7 from "@clack/prompts";
|
|
767
821
|
import assert4 from "assert";
|
|
768
822
|
import { existsSync as existsSync3 } from "fs";
|
|
769
823
|
import * as fs3 from "fs/promises";
|
|
@@ -787,14 +841,17 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
787
841
|
const root2 = projectRoot();
|
|
788
842
|
await packageJson6.load();
|
|
789
843
|
assert4.ok(packageJson6.json !== null);
|
|
790
|
-
await packageJson6.install("prettier", {
|
|
844
|
+
await packageJson6.install("prettier", {
|
|
845
|
+
dev: true,
|
|
846
|
+
version: ">=3"
|
|
847
|
+
});
|
|
791
848
|
const prettierConfig = prettierConfigNames.find(
|
|
792
849
|
(configName) => existsSync3(path6.join(root2, configName))
|
|
793
850
|
);
|
|
794
851
|
const solvroPrettierPath = "@solvro/config/prettier";
|
|
795
852
|
if (prettierConfig !== void 0 || packageJson6.json.prettier !== void 0) {
|
|
796
853
|
if (packageJson6.json.prettier === solvroPrettierPath) {
|
|
797
|
-
|
|
854
|
+
p7.note("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
|
|
798
855
|
return;
|
|
799
856
|
}
|
|
800
857
|
if (isNonInteractive2) {
|
|
@@ -805,8 +862,8 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
805
862
|
const isConfirmed = await polishConfirm({
|
|
806
863
|
message: `Znaleziono konfiguracj\u0119 Prettiera. Czy chcesz j\u0105 nadpisa\u0107?`
|
|
807
864
|
});
|
|
808
|
-
if (
|
|
809
|
-
|
|
865
|
+
if (p7.isCancel(isConfirmed) || !isConfirmed) {
|
|
866
|
+
p7.cancel("Usu\u0144 konfiguracje Prettiera i spr\xF3buj ponownie.");
|
|
810
867
|
process.exit(1);
|
|
811
868
|
}
|
|
812
869
|
for (const configName of prettierConfigNames) {
|
|
@@ -816,7 +873,7 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
816
873
|
}
|
|
817
874
|
packageJson6.json.prettier = solvroPrettierPath;
|
|
818
875
|
await packageJson6.save();
|
|
819
|
-
|
|
876
|
+
p7.note("Konfiguracja Prettiera zosta\u0142a dodana.");
|
|
820
877
|
};
|
|
821
878
|
|
|
822
879
|
// src/cli/index.ts
|
|
@@ -827,27 +884,28 @@ var options = program.opts();
|
|
|
827
884
|
var isNonInteractive = process.argv.length > 2;
|
|
828
885
|
async function main() {
|
|
829
886
|
if (!isNonInteractive) {
|
|
830
|
-
|
|
887
|
+
p8.intro(c2.bold(c2.bgBlue(" @solvro/config ")));
|
|
831
888
|
}
|
|
832
889
|
const userAgent = getUserAgent();
|
|
833
890
|
if (userAgent !== "npm") {
|
|
834
891
|
const packageManager = userAgent ?? "unknown";
|
|
835
|
-
const warningMessage = `
|
|
836
|
-
${c.red(c.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
892
|
+
const warningMessage = `${c2.red(c2.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
837
893
|
|
|
838
|
-
Pr\xF3bujesz uruchomi\u0107 ten skrypt
|
|
894
|
+
Pr\xF3bujesz uruchomi\u0107 ten skrypt ${c2.yellow(packageManager)}'em, ale @solvro/config obecnie dzia\u0142a tylko z ${c2.green("npm")}'em.
|
|
839
895
|
|
|
840
|
-
Support dla innych mened\u017Cer\xF3w pakiet\xF3w
|
|
896
|
+
${c2.white(`Support dla innych mened\u017Cer\xF3w pakiet\xF3w jest planowany w nadchodz\u0105cych wersjach - ${c2.yellow("zagwiazdkuj i spr\xF3buj ponownie wkr\xF3tce")}!`)}
|
|
841
897
|
|
|
842
|
-
|
|
843
|
-
${
|
|
898
|
+
${c2.white(`W mi\u0119dzyczasie u\u017Cyj ${c2.green("npm")}'a:`)}
|
|
899
|
+
${c2.cyan("npx @solvro/config")}`;
|
|
844
900
|
if (isNonInteractive) {
|
|
845
901
|
console.error(warningMessage);
|
|
846
902
|
} else {
|
|
847
|
-
|
|
903
|
+
p8.cancel(warningMessage);
|
|
848
904
|
}
|
|
849
905
|
process.exit(1);
|
|
850
906
|
}
|
|
907
|
+
const packageJson7 = new PackageJson();
|
|
908
|
+
await packageJson7.load();
|
|
851
909
|
if (options.force !== true && !isGitClean()) {
|
|
852
910
|
if (isNonInteractive) {
|
|
853
911
|
console.error(
|
|
@@ -858,48 +916,44 @@ ${c.cyan("npx @solvro/config")}`;
|
|
|
858
916
|
const isConfirmed = await polishConfirm({
|
|
859
917
|
message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
|
|
860
918
|
});
|
|
861
|
-
if (
|
|
862
|
-
|
|
919
|
+
if (p8.isCancel(isConfirmed) || !isConfirmed) {
|
|
920
|
+
p8.cancel("Zapisz zmiany w Git i spr\xF3buj ponownie.");
|
|
863
921
|
process.exit(1);
|
|
864
922
|
}
|
|
865
923
|
}
|
|
866
|
-
|
|
924
|
+
if (await packageJson7.hasPackage("eslint") && !await packageJson7.doesSatisfy("eslint", "<10")) {
|
|
925
|
+
const eslint = await packageJson7.getPackageInfo("eslint");
|
|
926
|
+
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${c2.yellow(eslint.version)}.`;
|
|
927
|
+
const errorMessage = `ESLint w wersji powy\u017Cej 9 ${c2.red("nie jest jeszcze wspierany")}.${versionInfo}`;
|
|
928
|
+
const errorRetry = "Prosz\u0119 zainstalowa\u0107 wersj\u0119 9 i spr\xF3bowa\u0107 ponownie.";
|
|
929
|
+
if (isNonInteractive) {
|
|
930
|
+
console.error(errorMessage);
|
|
931
|
+
console.error(errorRetry);
|
|
932
|
+
process.exit(1);
|
|
933
|
+
}
|
|
934
|
+
const isConfirmed = await polishConfirm({
|
|
935
|
+
message: `${errorMessage} Zainstalowa\u0107 starsz\u0105 wersj\u0119 ${c2.magenta("ESLint")}'a? (Wymagane by kontynuowa\u0107)`
|
|
936
|
+
});
|
|
937
|
+
if (p8.isCancel(isConfirmed) || !isConfirmed) {
|
|
938
|
+
p8.cancel(errorRetry);
|
|
939
|
+
process.exit(1);
|
|
940
|
+
}
|
|
941
|
+
await packageJson7.install("eslint", { dev: true, version: "^9" });
|
|
942
|
+
}
|
|
867
943
|
const projectType = await packageJson7.getProjectType();
|
|
868
944
|
if (!isNonInteractive) {
|
|
869
945
|
if (projectType === "adonis") {
|
|
870
|
-
|
|
871
|
-
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 Adonisa. Czy to si\u0119 zgadza?`
|
|
872
|
-
});
|
|
873
|
-
if (p6.isCancel(isConfirmed) || !isConfirmed) {
|
|
874
|
-
p6.cancel("Zg\u0142o\u015B b\u0142\u0105d na GitHubie :(, a my spr\xF3bujemy pom\xF3c.");
|
|
875
|
-
process.exit(1);
|
|
876
|
-
}
|
|
946
|
+
await confirmProjectType(c2.magenta("Adonis"));
|
|
877
947
|
}
|
|
878
948
|
if (projectType === "react") {
|
|
879
|
-
|
|
880
|
-
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 Reacta. Czy to si\u0119 zgadza?`
|
|
881
|
-
});
|
|
882
|
-
if (p6.isCancel(isConfirmed)) {
|
|
883
|
-
p6.cancel("\u{1F621}");
|
|
884
|
-
process.exit(1);
|
|
885
|
-
}
|
|
886
|
-
if (!isConfirmed) {
|
|
887
|
-
p6.cancel("Zg\u0142o\u015B b\u0142\u0105d na GitHubie :(, a my spr\xF3bujemy pom\xF3c.");
|
|
888
|
-
process.exit(1);
|
|
889
|
-
}
|
|
949
|
+
await confirmProjectType(c2.cyan("React"));
|
|
890
950
|
}
|
|
891
951
|
if (projectType === "nestjs") {
|
|
892
|
-
|
|
893
|
-
message: `Wygl\u0105da jakby\u015B u\u017Cywa\u0142 NestJsa. Czy to si\u0119 zgadza?`
|
|
894
|
-
});
|
|
895
|
-
if (p6.isCancel(isConfirmed)) {
|
|
896
|
-
p6.cancel("\u{1F621}");
|
|
897
|
-
process.exit(1);
|
|
898
|
-
}
|
|
952
|
+
await confirmProjectType(c2.red("NestJS"));
|
|
899
953
|
}
|
|
900
954
|
if (projectType === "node") {
|
|
901
|
-
|
|
902
|
-
|
|
955
|
+
p8.cancel(
|
|
956
|
+
`Nie znaleziono ani ${c2.magenta("Adonis")}'a, ${c2.cyan("React")}'a, ani ${c2.white("NestJS")}'a. Musisz r\u0119cznie konfigurowa\u0107 projekt.`
|
|
903
957
|
);
|
|
904
958
|
process.exit(1);
|
|
905
959
|
}
|
|
@@ -912,8 +966,8 @@ ${c.cyan("npx @solvro/config")}`;
|
|
|
912
966
|
const isConfirmed = await polishConfirm({
|
|
913
967
|
message: `Tw\xF3j projekt nie u\u017Cywa ESM (brak type: "module" w package.json). Czy chcesz to doda\u0107? (Wymagane by kontynuowa\u0107)`
|
|
914
968
|
});
|
|
915
|
-
if (
|
|
916
|
-
|
|
969
|
+
if (p8.isCancel(isConfirmed) || !isConfirmed) {
|
|
970
|
+
p8.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
|
917
971
|
process.exit(1);
|
|
918
972
|
}
|
|
919
973
|
await packageJson7.ensureESM();
|
|
@@ -943,35 +997,35 @@ ${c.cyan("npx @solvro/config")}`;
|
|
|
943
997
|
process.exit(1);
|
|
944
998
|
}
|
|
945
999
|
} else {
|
|
946
|
-
const additionalTools = await
|
|
947
|
-
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${
|
|
1000
|
+
const additionalTools = await p8.multiselect({
|
|
1001
|
+
message: `Kt\xF3re rzeczy Ci\u0119 interesuj\u0105? ${c2.gray("zaznacz spacj\u0105, potwierd\u017A enterem")}`,
|
|
948
1002
|
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
|
949
1003
|
options: [
|
|
950
1004
|
{
|
|
951
1005
|
value: "eslint",
|
|
952
|
-
label:
|
|
1006
|
+
label: c2.bold(c2.blueBright("ESLint")),
|
|
953
1007
|
hint: "sprawdzanie jako\u015Bci kodu"
|
|
954
1008
|
},
|
|
955
1009
|
{
|
|
956
1010
|
value: "prettier",
|
|
957
|
-
label:
|
|
1011
|
+
label: c2.bold(c2.yellowBright("Prettier")),
|
|
958
1012
|
hint: "formatowanie"
|
|
959
1013
|
},
|
|
960
1014
|
{
|
|
961
1015
|
value: "gh-action",
|
|
962
|
-
label:
|
|
1016
|
+
label: c2.bold("GitHub Actions"),
|
|
963
1017
|
hint: "automatyczne testy na Githubie"
|
|
964
1018
|
},
|
|
965
1019
|
{
|
|
966
1020
|
value: "commitlint",
|
|
967
|
-
label:
|
|
1021
|
+
label: c2.bold("Commitlint"),
|
|
968
1022
|
hint: "walidacja tre\u015Bci commit\xF3w"
|
|
969
1023
|
}
|
|
970
1024
|
],
|
|
971
1025
|
required: false
|
|
972
1026
|
});
|
|
973
|
-
if (
|
|
974
|
-
|
|
1027
|
+
if (p8.isCancel(additionalTools) || additionalTools.length === 0) {
|
|
1028
|
+
p8.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
|
975
1029
|
process.exit(1);
|
|
976
1030
|
}
|
|
977
1031
|
toolsToInstall = additionalTools;
|
|
@@ -994,16 +1048,29 @@ ${c.cyan("npx @solvro/config")}`;
|
|
|
994
1048
|
await installGithubActions();
|
|
995
1049
|
}
|
|
996
1050
|
await packageJson7.clearInstall();
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
} else {
|
|
1000
|
-
p6.outro("\u2705 Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
1001
|
-
}
|
|
1051
|
+
const printSuccess = isNonInteractive ? console.info : p8.outro;
|
|
1052
|
+
printSuccess("\u2705 Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
1002
1053
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1054
|
+
async function mainWrapper() {
|
|
1055
|
+
try {
|
|
1056
|
+
await main();
|
|
1057
|
+
} catch (error) {
|
|
1058
|
+
if (process.env.NODE_ENV === "development") {
|
|
1059
|
+
console.error(
|
|
1060
|
+
c2.red("Unhandled error in main:"),
|
|
1061
|
+
error instanceof Error ? error.message : error
|
|
1062
|
+
);
|
|
1063
|
+
} else {
|
|
1064
|
+
const errorMessage = "Wyst\u0105pi\u0142 nieoczekiwany b\u0142\u0105d :( Prosz\u0119 zg\u0142osi\u0107 go tw\xF3rcom:";
|
|
1065
|
+
if (isNonInteractive) {
|
|
1066
|
+
console.error(errorMessage);
|
|
1067
|
+
console.error(BUG_TRACKER_URL);
|
|
1068
|
+
} else {
|
|
1069
|
+
p8.cancel(`${errorMessage} ${BUG_TRACKER_URL}`);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
process.exit(1);
|
|
1073
|
+
}
|
|
1008
1074
|
}
|
|
1075
|
+
void mainWrapper();
|
|
1009
1076
|
//# sourceMappingURL=index.js.map
|