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