@solvro/config 2.2.0 → 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 +354 -154
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +355 -155
- package/dist/cli/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 +7 -4
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.
|
|
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",
|
|
@@ -154,22 +154,54 @@ var package_default = {
|
|
|
154
154
|
"@next/eslint-plugin-next": ">=12.3.0",
|
|
155
155
|
eslint: ">=9.0.0 <10.0.0"
|
|
156
156
|
},
|
|
157
|
-
packageManager: "npm@11.11.
|
|
157
|
+
packageManager: "npm@11.11.1",
|
|
158
158
|
engines: {
|
|
159
|
-
node: "^20.19.0 || >=22.12.0"
|
|
159
|
+
node: "^20.19.0 || >=22.12.0",
|
|
160
|
+
npm: "^11.11.1"
|
|
160
161
|
},
|
|
161
162
|
volta: {
|
|
162
|
-
node: "22.
|
|
163
|
+
node: "22.22.1",
|
|
164
|
+
npm: "11.11.1"
|
|
163
165
|
},
|
|
164
166
|
publishConfig: {
|
|
165
167
|
access: "public"
|
|
166
168
|
}
|
|
167
169
|
};
|
|
168
170
|
|
|
169
|
-
// src/constants/
|
|
171
|
+
// src/constants/github.ts
|
|
170
172
|
var REPO_URL = "https://github.com/Solvro/lib-web-solvro-config";
|
|
171
173
|
var BUG_TRACKER_URL = `${REPO_URL}/issues/new`;
|
|
172
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
|
+
|
|
173
205
|
// src/utils/confirm-project-type.ts
|
|
174
206
|
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
175
207
|
|
|
@@ -216,12 +248,13 @@ function isGitClean() {
|
|
|
216
248
|
}
|
|
217
249
|
|
|
218
250
|
// src/utils/package-json.ts
|
|
219
|
-
var
|
|
251
|
+
var p7 = __toESM(require("@clack/prompts"), 1);
|
|
220
252
|
var import_local_pkg = require("local-pkg");
|
|
221
253
|
var import_node_assert = __toESM(require("assert"), 1);
|
|
222
254
|
var import_promises = require("fs/promises");
|
|
223
255
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
224
|
-
var
|
|
256
|
+
var import_detect = require("package-manager-detector/detect");
|
|
257
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
225
258
|
var import_semver = __toESM(require("semver"), 1);
|
|
226
259
|
|
|
227
260
|
// src/utils/git-root.ts
|
|
@@ -258,6 +291,9 @@ var $$ = (async (...arguments_) => {
|
|
|
258
291
|
return cachedExeca(...arguments_);
|
|
259
292
|
});
|
|
260
293
|
|
|
294
|
+
// src/utils/is-supported-package-manager.ts
|
|
295
|
+
var isSupportedPackageManager = (userAgent) => userAgent != null && SUPPORTED_PACKAGE_MANAGERS.includes(userAgent);
|
|
296
|
+
|
|
261
297
|
// src/utils/run-with-spinner.ts
|
|
262
298
|
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
263
299
|
|
|
@@ -289,14 +325,128 @@ var runWithSpinner = async (options2) => {
|
|
|
289
325
|
});
|
|
290
326
|
};
|
|
291
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
|
+
|
|
292
404
|
// src/utils/package-json.ts
|
|
293
405
|
var PackageJson = class {
|
|
294
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
|
+
}
|
|
295
445
|
async load() {
|
|
296
446
|
const json = await (0, import_local_pkg.loadPackageJSON)(projectRoot());
|
|
297
447
|
if (json === null) {
|
|
298
|
-
|
|
299
|
-
`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.`
|
|
300
450
|
);
|
|
301
451
|
process.exit(1);
|
|
302
452
|
}
|
|
@@ -338,8 +488,8 @@ var PackageJson = class {
|
|
|
338
488
|
const isReact = await (0, import_local_pkg.isPackageListed)("react");
|
|
339
489
|
const isNestJs = await (0, import_local_pkg.isPackageListed)("@nestjs/core");
|
|
340
490
|
if (isReact && isAdonis) {
|
|
341
|
-
|
|
342
|
-
`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.`
|
|
343
493
|
);
|
|
344
494
|
process.exit(1);
|
|
345
495
|
}
|
|
@@ -374,13 +524,20 @@ var PackageJson = class {
|
|
|
374
524
|
async install(package_, options2 = {}) {
|
|
375
525
|
const isInstalled = await this.hasPackage(package_);
|
|
376
526
|
const installVersion = options2.version ?? "latest";
|
|
527
|
+
const [installCommand, ...commandOptions] = this.manager.installPackage.split(" ");
|
|
528
|
+
if (options2.dev === true) {
|
|
529
|
+
commandOptions.push("-D");
|
|
530
|
+
}
|
|
377
531
|
if (!isInstalled) {
|
|
378
532
|
await runWithSpinner({
|
|
379
533
|
start: `Instalowanie pakietu ${package_}`,
|
|
380
534
|
stop: `${package_} zainstalowany \u{1F60D}`,
|
|
381
535
|
error: `Instalacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
382
536
|
callback: async () => {
|
|
383
|
-
await
|
|
537
|
+
await $$(installCommand, [
|
|
538
|
+
...commandOptions,
|
|
539
|
+
`${package_}@${installVersion}`
|
|
540
|
+
]);
|
|
384
541
|
}
|
|
385
542
|
});
|
|
386
543
|
await this.load();
|
|
@@ -392,14 +549,46 @@ var PackageJson = class {
|
|
|
392
549
|
stop: `${package_} zaktualizowany \u{1F60D}`,
|
|
393
550
|
error: `Aktualizacja pakietu ${package_} nie powiod\u0142a si\u0119 \u{1F976}`,
|
|
394
551
|
callback: async () => {
|
|
395
|
-
await
|
|
552
|
+
await $$(installCommand, [
|
|
553
|
+
...commandOptions,
|
|
554
|
+
`${package_}@${installVersion}`
|
|
555
|
+
]);
|
|
396
556
|
}
|
|
397
557
|
});
|
|
398
558
|
await this.load();
|
|
399
559
|
}
|
|
400
560
|
}
|
|
561
|
+
async localExecute(...commandArguments) {
|
|
562
|
+
const [command, ...commandOptions] = this.manager.localExecute.split(" ");
|
|
563
|
+
const options2 = [...commandOptions, ...commandArguments];
|
|
564
|
+
await $$(command, options2);
|
|
565
|
+
}
|
|
401
566
|
async clearInstall() {
|
|
402
|
-
|
|
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";
|
|
403
592
|
}
|
|
404
593
|
};
|
|
405
594
|
|
|
@@ -413,7 +602,7 @@ var packageJson = new PackageJson();
|
|
|
413
602
|
var installHusky = async () => {
|
|
414
603
|
if (!await packageJson.hasPackage("husky")) {
|
|
415
604
|
await packageJson.install("husky", { dev: true });
|
|
416
|
-
await
|
|
605
|
+
await packageJson.localExecute("husky", "init");
|
|
417
606
|
}
|
|
418
607
|
await packageJson.load();
|
|
419
608
|
import_node_assert2.default.ok(packageJson.json !== null);
|
|
@@ -436,13 +625,14 @@ var installCommitLint = async () => {
|
|
|
436
625
|
await packageJson2.install("@commitlint/cli", { dev: true });
|
|
437
626
|
await (0, import_promises2.writeFile)(
|
|
438
627
|
import_node_path3.default.join(root, ".husky/commit-msg"),
|
|
439
|
-
|
|
628
|
+
`${packageJson2.manager.localExecute} commitlint --edit "$1"
|
|
629
|
+
`
|
|
440
630
|
);
|
|
441
631
|
await (0, import_promises2.writeFile)(import_node_path3.default.join(root, ".commitlintrc.js"), commitlint());
|
|
442
632
|
};
|
|
443
633
|
|
|
444
634
|
// src/cli/install-eslint.ts
|
|
445
|
-
var
|
|
635
|
+
var p8 = __toESM(require("@clack/prompts"), 1);
|
|
446
636
|
var import_node_fs = require("fs");
|
|
447
637
|
var fs = __toESM(require("fs/promises"), 1);
|
|
448
638
|
var import_node_path4 = __toESM(require("path"), 1);
|
|
@@ -472,7 +662,7 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
472
662
|
if (type === "react" && await packageJson3.isNextJs()) {
|
|
473
663
|
const is15 = await packageJson3.doesSatisfy("next", ">=15");
|
|
474
664
|
if (!is15) {
|
|
475
|
-
|
|
665
|
+
p8.cancel(
|
|
476
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"
|
|
477
667
|
);
|
|
478
668
|
process.exit(1);
|
|
@@ -488,7 +678,7 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
488
678
|
"utf8"
|
|
489
679
|
);
|
|
490
680
|
if (eslintContent.includes("export default solvro(")) {
|
|
491
|
-
|
|
681
|
+
p8.note("Eslint jest ju\u017C skonfigurowany. Pomijam.");
|
|
492
682
|
return;
|
|
493
683
|
} else {
|
|
494
684
|
if (isNonInteractive2) {
|
|
@@ -497,8 +687,8 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
497
687
|
const isConfirmed = await polishConfirm({
|
|
498
688
|
message: `Znaleziono plik konfiguracyjny Eslint. Czy chcesz go nadpisa\u0107?`
|
|
499
689
|
});
|
|
500
|
-
if (
|
|
501
|
-
|
|
690
|
+
if (p8.isCancel(isConfirmed) || !isConfirmed) {
|
|
691
|
+
p8.cancel("Nadpisz plik konfiguracyjny Eslint i spr\xF3buj ponownie.");
|
|
502
692
|
process.exit(1);
|
|
503
693
|
}
|
|
504
694
|
await fs.rm(import_node_path4.default.join(root2, eslintConfig));
|
|
@@ -514,26 +704,56 @@ var installEslint = async (isNonInteractive2 = false) => {
|
|
|
514
704
|
export default solvro();
|
|
515
705
|
`
|
|
516
706
|
);
|
|
517
|
-
|
|
707
|
+
p8.note("Plik konfiguracyjny Eslint zosta\u0142 utworzony.");
|
|
518
708
|
};
|
|
519
709
|
|
|
520
710
|
// src/cli/install-ga.ts
|
|
521
|
-
var
|
|
711
|
+
var p9 = __toESM(require("@clack/prompts"), 1);
|
|
522
712
|
var import_node_fs2 = require("fs");
|
|
523
713
|
var fs2 = __toESM(require("fs/promises"), 1);
|
|
524
714
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
525
715
|
|
|
526
716
|
// src/cli/templates/commit-lint-ci.ts
|
|
527
|
-
var commitLintCi = (
|
|
717
|
+
var commitLintCi = ({
|
|
718
|
+
manager
|
|
719
|
+
}) => `
|
|
528
720
|
- name: Check commit name
|
|
529
721
|
if: github.event_name == 'pull_request'
|
|
530
|
-
run:
|
|
722
|
+
run: ${manager.localExecute} commitlint --from \${{ github.event.pull_request.base.sha }} --to \${{ github.event.pull_request.head.sha }} --verbose
|
|
531
723
|
`;
|
|
532
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
|
+
|
|
533
751
|
// src/cli/templates/adonis-ci.ts
|
|
534
752
|
var adonisCi = ({
|
|
535
753
|
nodeVersion,
|
|
536
|
-
withCommitlint
|
|
754
|
+
withCommitlint,
|
|
755
|
+
manager,
|
|
756
|
+
pnpmVersion
|
|
537
757
|
}) => `name: CI
|
|
538
758
|
|
|
539
759
|
on:
|
|
@@ -545,48 +765,43 @@ jobs:
|
|
|
545
765
|
lint:
|
|
546
766
|
runs-on: ubuntu-latest
|
|
547
767
|
steps:
|
|
548
|
-
|
|
549
|
-
uses: actions/checkout@v4
|
|
550
|
-
with:
|
|
551
|
-
fetch-depth: 0
|
|
552
|
-
|
|
553
|
-
- name: Setup node
|
|
554
|
-
uses: actions/setup-node@v4
|
|
555
|
-
with:
|
|
556
|
-
node-version: ${nodeVersion}
|
|
557
|
-
cache: "npm"
|
|
768
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
558
769
|
|
|
559
770
|
- name: Install dependencies
|
|
560
|
-
run:
|
|
771
|
+
run: ${manager.cleanInstall}
|
|
561
772
|
|
|
562
773
|
- name: Set up AdonisJS environment
|
|
563
774
|
run: |
|
|
564
775
|
cp .env.example .env
|
|
565
776
|
node ace generate:key
|
|
566
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
777
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
567
778
|
- name: Check formatting
|
|
568
|
-
run:
|
|
779
|
+
run: ${manager.runScript} format:check
|
|
569
780
|
if: always()
|
|
570
781
|
|
|
571
782
|
- name: Lint code
|
|
572
|
-
run:
|
|
783
|
+
run: ${manager.runScript} lint
|
|
573
784
|
if: always()
|
|
574
785
|
|
|
575
786
|
- name: Check types
|
|
576
|
-
run:
|
|
787
|
+
run: ${manager.runScript} types:check
|
|
577
788
|
if: always()
|
|
578
789
|
|
|
579
790
|
- name: Run tests
|
|
580
|
-
run:
|
|
791
|
+
run: ${manager.name} test
|
|
581
792
|
if: always()
|
|
582
793
|
|
|
583
794
|
- name: Build
|
|
584
|
-
run:
|
|
795
|
+
run: ${manager.runScript} build
|
|
585
796
|
if: always()
|
|
586
797
|
`;
|
|
587
798
|
|
|
588
799
|
// src/cli/templates/adonis-ci-migrations.ts
|
|
589
|
-
var adonisMigrationsCi = (
|
|
800
|
+
var adonisMigrationsCi = ({
|
|
801
|
+
nodeVersion,
|
|
802
|
+
manager,
|
|
803
|
+
pnpmVersion
|
|
804
|
+
}) => `name: Migration check
|
|
590
805
|
|
|
591
806
|
on:
|
|
592
807
|
pull_request:
|
|
@@ -618,11 +833,10 @@ jobs:
|
|
|
618
833
|
- 5432:5432
|
|
619
834
|
|
|
620
835
|
steps:
|
|
621
|
-
|
|
622
|
-
uses: actions/checkout@v4
|
|
836
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
623
837
|
|
|
624
838
|
- name: Install dependencies
|
|
625
|
-
run:
|
|
839
|
+
run: ${manager.cleanInstall}
|
|
626
840
|
|
|
627
841
|
- name: Set up AdonisJS environment
|
|
628
842
|
run: |
|
|
@@ -650,7 +864,9 @@ updates:
|
|
|
650
864
|
// src/cli/templates/nestjs-ci.ts
|
|
651
865
|
var nestjsCi = ({
|
|
652
866
|
nodeVersion,
|
|
653
|
-
withCommitlint
|
|
867
|
+
withCommitlint,
|
|
868
|
+
manager,
|
|
869
|
+
pnpmVersion
|
|
654
870
|
}) => `name: CI
|
|
655
871
|
|
|
656
872
|
on:
|
|
@@ -662,61 +878,54 @@ jobs:
|
|
|
662
878
|
lint:
|
|
663
879
|
runs-on: ubuntu-latest
|
|
664
880
|
steps:
|
|
665
|
-
|
|
666
|
-
uses: actions/checkout@v4
|
|
667
|
-
with:
|
|
668
|
-
fetch-depth: 0
|
|
669
|
-
|
|
670
|
-
- name: Setup node
|
|
671
|
-
uses: actions/setup-node@v4
|
|
672
|
-
with:
|
|
673
|
-
node-version: ${nodeVersion}
|
|
674
|
-
cache: "npm"
|
|
881
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
675
882
|
|
|
676
883
|
- name: Install dependencies
|
|
677
|
-
run:
|
|
678
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
884
|
+
run: ${manager.cleanInstall}
|
|
885
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
679
886
|
- name: Check formatting
|
|
680
|
-
run:
|
|
887
|
+
run: ${manager.runScript} format:check
|
|
681
888
|
if: always()
|
|
682
889
|
|
|
683
890
|
- name: Lint code
|
|
684
|
-
run:
|
|
891
|
+
run: ${manager.runScript} lint
|
|
685
892
|
if: always()
|
|
686
893
|
|
|
687
894
|
- name: Check types
|
|
688
|
-
run:
|
|
895
|
+
run: ${manager.runScript} types:check
|
|
689
896
|
if: always()
|
|
690
897
|
|
|
691
898
|
- name: Run tests
|
|
692
|
-
run:
|
|
899
|
+
run: ${manager.name} test
|
|
693
900
|
if: always()
|
|
694
901
|
|
|
695
902
|
- name: Run e2e tests
|
|
696
|
-
run:
|
|
903
|
+
run: ${manager.runScript} test:e2e
|
|
697
904
|
if: always()
|
|
698
905
|
|
|
699
906
|
- name: Build
|
|
700
|
-
run:
|
|
907
|
+
run: ${manager.runScript} build
|
|
701
908
|
if: always()
|
|
702
909
|
`;
|
|
703
910
|
|
|
704
911
|
// src/cli/templates/nextjs-ci.ts
|
|
705
|
-
var nextJsCi = () => `
|
|
912
|
+
var nextJsCi = ({ manager }) => `
|
|
706
913
|
- name: Setup build cache
|
|
707
|
-
uses: actions/cache@
|
|
914
|
+
uses: actions/cache@v5
|
|
708
915
|
with:
|
|
709
916
|
path: \${{ github.workspace }}/.next/cache
|
|
710
|
-
key: \${{ runner.os }}-nextjs-\${{ hashFiles('
|
|
917
|
+
key: \${{ runner.os }}-nextjs-\${{ hashFiles('**/${manager.lockfile}') }}-\${{ hashFiles('**/*.ts', '**/*.tsx') }}
|
|
711
918
|
restore-keys: |
|
|
712
|
-
\${{ runner.os }}-nextjs-\${{ hashFiles('
|
|
919
|
+
\${{ runner.os }}-nextjs-\${{ hashFiles('**/${manager.lockfile}') }}-
|
|
713
920
|
`;
|
|
714
921
|
|
|
715
922
|
// src/cli/templates/react-ci.ts
|
|
716
923
|
var reactCi = ({
|
|
717
924
|
nodeVersion,
|
|
718
925
|
withCommitlint,
|
|
719
|
-
|
|
926
|
+
manager,
|
|
927
|
+
usingNextJs,
|
|
928
|
+
pnpmVersion
|
|
720
929
|
}) => `name: CI
|
|
721
930
|
|
|
722
931
|
on:
|
|
@@ -728,34 +937,25 @@ jobs:
|
|
|
728
937
|
lint:
|
|
729
938
|
runs-on: ubuntu-latest
|
|
730
939
|
steps:
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
with:
|
|
734
|
-
fetch-depth: 0
|
|
735
|
-
|
|
736
|
-
- name: Setup node
|
|
737
|
-
uses: actions/setup-node@v4
|
|
738
|
-
with:
|
|
739
|
-
node-version: ${nodeVersion}
|
|
740
|
-
cache: "npm"
|
|
741
|
-
${usingNextJs ? nextJsCi() : ""}
|
|
940
|
+
${nodeSetupCi({ nodeVersion, manager, pnpmVersion })}
|
|
941
|
+
${usingNextJs ? nextJsCi({ manager }) : ""}
|
|
742
942
|
- name: Install dependencies
|
|
743
|
-
run:
|
|
744
|
-
${withCommitlint ? commitLintCi() : ""}
|
|
943
|
+
run: ${manager.cleanInstall}
|
|
944
|
+
${withCommitlint ? commitLintCi({ manager }) : ""}
|
|
745
945
|
- name: Check formatting
|
|
746
|
-
run:
|
|
946
|
+
run: ${manager.runScript} format:check
|
|
747
947
|
if: always()
|
|
748
948
|
|
|
749
949
|
- name: Lint code
|
|
750
|
-
run:
|
|
950
|
+
run: ${manager.runScript} lint
|
|
751
951
|
if: always()
|
|
752
952
|
|
|
753
953
|
- name: Check types
|
|
754
|
-
run:
|
|
954
|
+
run: ${manager.runScript} types:check
|
|
755
955
|
if: always()
|
|
756
956
|
|
|
757
957
|
- name: Build
|
|
758
|
-
run:
|
|
958
|
+
run: ${manager.runScript} build
|
|
759
959
|
if: always()
|
|
760
960
|
`;
|
|
761
961
|
|
|
@@ -768,10 +968,12 @@ var installGithubActions = async () => {
|
|
|
768
968
|
const ghWorkflowsDirectory = import_node_path5.default.join(gitDirectory, ".github/workflows");
|
|
769
969
|
await fs2.mkdir(ghWorkflowsDirectory, { recursive: true });
|
|
770
970
|
const type = await packageJson4.getProjectType();
|
|
971
|
+
const manager = packageJson4.manager;
|
|
972
|
+
const pnpmVersion = manager.name === "pnpm" ? await packageJson4.getPnpmVersion() : void 0;
|
|
771
973
|
const withCommitlint = await packageJson4.hasPackage("@commitlint/cli");
|
|
772
974
|
if (type === "adonis") {
|
|
773
975
|
if (!(0, import_node_fs2.existsSync)(import_node_path5.default.join(projectDirectory, ".env.example"))) {
|
|
774
|
-
|
|
976
|
+
p9.cancel(
|
|
775
977
|
"Nie znaleziono pliku .env.example. Upewnij si\u0119, \u017Ce jeste\u015B w katalogu projektu Adonisa."
|
|
776
978
|
);
|
|
777
979
|
process.exit(1);
|
|
@@ -780,12 +982,14 @@ var installGithubActions = async () => {
|
|
|
780
982
|
import_node_path5.default.join(ghWorkflowsDirectory, "ci.yml"),
|
|
781
983
|
adonisCi({
|
|
782
984
|
nodeVersion: "22",
|
|
783
|
-
withCommitlint
|
|
985
|
+
withCommitlint,
|
|
986
|
+
manager,
|
|
987
|
+
pnpmVersion
|
|
784
988
|
})
|
|
785
989
|
);
|
|
786
990
|
await fs2.writeFile(
|
|
787
991
|
import_node_path5.default.join(ghWorkflowsDirectory, "db.yml"),
|
|
788
|
-
adonisMigrationsCi()
|
|
992
|
+
adonisMigrationsCi({ nodeVersion: "22", manager, pnpmVersion })
|
|
789
993
|
);
|
|
790
994
|
}
|
|
791
995
|
if (type === "react") {
|
|
@@ -795,7 +999,9 @@ var installGithubActions = async () => {
|
|
|
795
999
|
reactCi({
|
|
796
1000
|
nodeVersion: "22",
|
|
797
1001
|
withCommitlint,
|
|
798
|
-
usingNextJs
|
|
1002
|
+
usingNextJs,
|
|
1003
|
+
manager,
|
|
1004
|
+
pnpmVersion
|
|
799
1005
|
})
|
|
800
1006
|
);
|
|
801
1007
|
if (usingNextJs) {
|
|
@@ -807,7 +1013,9 @@ var installGithubActions = async () => {
|
|
|
807
1013
|
import_node_path5.default.join(ghWorkflowsDirectory, "ci.yml"),
|
|
808
1014
|
nestjsCi({
|
|
809
1015
|
nodeVersion: "22",
|
|
810
|
-
withCommitlint
|
|
1016
|
+
withCommitlint,
|
|
1017
|
+
manager,
|
|
1018
|
+
pnpmVersion
|
|
811
1019
|
})
|
|
812
1020
|
);
|
|
813
1021
|
}
|
|
@@ -821,19 +1029,24 @@ var installGithubActions = async () => {
|
|
|
821
1029
|
await packageJson4.addScriptIfNotExists("lint", "eslint . --max-warnings=0");
|
|
822
1030
|
await packageJson4.addScriptIfNotExists("format", "prettier --write .");
|
|
823
1031
|
await packageJson4.addScriptIfNotExists("types:check", "tsc --noEmit");
|
|
824
|
-
|
|
1032
|
+
p9.note("Dodano konfiguracj\u0119 CI i skrypty.");
|
|
825
1033
|
};
|
|
826
1034
|
|
|
827
1035
|
// src/cli/install-lint-staged.ts
|
|
828
1036
|
var import_node_assert3 = __toESM(require("assert"), 1);
|
|
829
1037
|
var import_promises3 = require("fs/promises");
|
|
1038
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
830
1039
|
var packageJson5 = new PackageJson();
|
|
831
1040
|
var installLintStaged = async () => {
|
|
832
1041
|
await packageJson5.load();
|
|
833
1042
|
import_node_assert3.default.ok(packageJson5.json !== null);
|
|
834
1043
|
await installHusky();
|
|
835
1044
|
await packageJson5.install("lint-staged", { dev: true });
|
|
836
|
-
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
|
+
);
|
|
837
1050
|
packageJson5.json["lint-staged"] = {
|
|
838
1051
|
"*": "prettier -w --ignore-unknown"
|
|
839
1052
|
};
|
|
@@ -841,11 +1054,11 @@ var installLintStaged = async () => {
|
|
|
841
1054
|
};
|
|
842
1055
|
|
|
843
1056
|
// src/cli/install-prettier.ts
|
|
844
|
-
var
|
|
1057
|
+
var p10 = __toESM(require("@clack/prompts"), 1);
|
|
845
1058
|
var import_node_assert4 = __toESM(require("assert"), 1);
|
|
846
1059
|
var import_node_fs3 = require("fs");
|
|
847
1060
|
var fs3 = __toESM(require("fs/promises"), 1);
|
|
848
|
-
var
|
|
1061
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
849
1062
|
var prettierConfigNames = [
|
|
850
1063
|
".prettierrc.js",
|
|
851
1064
|
".prettierrc.cjs",
|
|
@@ -870,34 +1083,34 @@ var installPrettier = async (isNonInteractive2 = false) => {
|
|
|
870
1083
|
version: ">=3"
|
|
871
1084
|
});
|
|
872
1085
|
const prettierConfig = prettierConfigNames.find(
|
|
873
|
-
(configName) => (0, import_node_fs3.existsSync)(
|
|
1086
|
+
(configName) => (0, import_node_fs3.existsSync)(import_node_path7.default.join(root2, configName))
|
|
874
1087
|
);
|
|
875
1088
|
const solvroPrettierPath = "@solvro/config/prettier";
|
|
876
1089
|
if (prettierConfig !== void 0 || packageJson6.json.prettier !== void 0) {
|
|
877
1090
|
if (packageJson6.json.prettier === solvroPrettierPath) {
|
|
878
|
-
|
|
1091
|
+
p10.note("Konfiguracja Prettiera jest ju\u017C ustawiona. Pomijam.");
|
|
879
1092
|
return;
|
|
880
1093
|
}
|
|
881
1094
|
if (isNonInteractive2) {
|
|
882
1095
|
for (const configName of prettierConfigNames) {
|
|
883
|
-
await fs3.rm(
|
|
1096
|
+
await fs3.rm(import_node_path7.default.join(root2, configName)).catch(() => null);
|
|
884
1097
|
}
|
|
885
1098
|
} else {
|
|
886
1099
|
const isConfirmed = await polishConfirm({
|
|
887
1100
|
message: `Znaleziono konfiguracj\u0119 Prettiera. Czy chcesz j\u0105 nadpisa\u0107?`
|
|
888
1101
|
});
|
|
889
|
-
if (
|
|
890
|
-
|
|
1102
|
+
if (p10.isCancel(isConfirmed) || !isConfirmed) {
|
|
1103
|
+
p10.cancel("Usu\u0144 konfiguracje Prettiera i spr\xF3buj ponownie.");
|
|
891
1104
|
process.exit(1);
|
|
892
1105
|
}
|
|
893
1106
|
for (const configName of prettierConfigNames) {
|
|
894
|
-
await fs3.rm(
|
|
1107
|
+
await fs3.rm(import_node_path7.default.join(root2, configName)).catch(() => null);
|
|
895
1108
|
}
|
|
896
1109
|
}
|
|
897
1110
|
}
|
|
898
1111
|
packageJson6.json.prettier = solvroPrettierPath;
|
|
899
1112
|
await packageJson6.save();
|
|
900
|
-
|
|
1113
|
+
p10.note("Konfiguracja Prettiera zosta\u0142a dodana.");
|
|
901
1114
|
};
|
|
902
1115
|
|
|
903
1116
|
// src/cli/index.ts
|
|
@@ -905,31 +1118,15 @@ var program = new import_commander.Command();
|
|
|
905
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);
|
|
906
1119
|
program.parse();
|
|
907
1120
|
var options = program.opts();
|
|
908
|
-
var isNonInteractive =
|
|
1121
|
+
var isNonInteractive = checkIsNonInteractive();
|
|
909
1122
|
async function main() {
|
|
910
1123
|
if (!isNonInteractive) {
|
|
911
|
-
|
|
912
|
-
}
|
|
913
|
-
const userAgent = (0, import_detect.getUserAgent)();
|
|
914
|
-
if (userAgent !== "npm") {
|
|
915
|
-
const packageManager = userAgent ?? "unknown";
|
|
916
|
-
const warningMessage = `${import_picocolors2.default.red(import_picocolors2.default.bold(`\u26A0\uFE0F OSTRZE\u017BENIE: ${packageManager} nie jest obs\u0142ugiwany \u26A0\uFE0F`))}
|
|
917
|
-
|
|
918
|
-
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.
|
|
919
|
-
|
|
920
|
-
${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")}!`)}
|
|
921
|
-
|
|
922
|
-
${import_picocolors2.default.white(`W mi\u0119dzyczasie u\u017Cyj ${import_picocolors2.default.green("npm")}'a:`)}
|
|
923
|
-
${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
924
|
-
if (isNonInteractive) {
|
|
925
|
-
console.error(warningMessage);
|
|
926
|
-
} else {
|
|
927
|
-
p8.cancel(warningMessage);
|
|
928
|
-
}
|
|
929
|
-
process.exit(1);
|
|
1124
|
+
p11.intro(import_picocolors5.default.bold(import_picocolors5.default.bgBlue(" @solvro/config ")));
|
|
930
1125
|
}
|
|
931
1126
|
const packageJson7 = new PackageJson();
|
|
1127
|
+
packageJson7.verifyPackageManager();
|
|
932
1128
|
await packageJson7.load();
|
|
1129
|
+
await packageJson7.validateUserAgentConsistency();
|
|
933
1130
|
if (options.force !== true && !isGitClean()) {
|
|
934
1131
|
if (isNonInteractive) {
|
|
935
1132
|
console.error(
|
|
@@ -940,15 +1137,15 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
940
1137
|
const isConfirmed = await polishConfirm({
|
|
941
1138
|
message: `Masz niezapisane zmiany w Git. Czy chcesz kontynuowa\u0107?`
|
|
942
1139
|
});
|
|
943
|
-
if (
|
|
944
|
-
|
|
1140
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1141
|
+
p11.cancel("Zapisz zmiany w Git i spr\xF3buj ponownie.");
|
|
945
1142
|
process.exit(1);
|
|
946
1143
|
}
|
|
947
1144
|
}
|
|
948
1145
|
if (await packageJson7.hasPackage("eslint") && !await packageJson7.doesSatisfy("eslint", "<10")) {
|
|
949
1146
|
const eslint = await packageJson7.getPackageInfo("eslint");
|
|
950
|
-
const versionInfo = eslint?.version == null ? "" : ` Obecnie zainstalowana jest wersja ${
|
|
951
|
-
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}`;
|
|
952
1149
|
const errorRetry = "Prosz\u0119 zainstalowa\u0107 wersj\u0119 9 i spr\xF3bowa\u0107 ponownie.";
|
|
953
1150
|
if (isNonInteractive) {
|
|
954
1151
|
console.error(errorMessage);
|
|
@@ -956,10 +1153,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
956
1153
|
process.exit(1);
|
|
957
1154
|
}
|
|
958
1155
|
const isConfirmed = await polishConfirm({
|
|
959
|
-
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)`
|
|
960
1157
|
});
|
|
961
|
-
if (
|
|
962
|
-
|
|
1158
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1159
|
+
p11.cancel(errorRetry);
|
|
963
1160
|
process.exit(1);
|
|
964
1161
|
}
|
|
965
1162
|
await packageJson7.install("eslint", { dev: true, version: "^9" });
|
|
@@ -967,17 +1164,17 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
967
1164
|
const projectType = await packageJson7.getProjectType();
|
|
968
1165
|
if (!isNonInteractive) {
|
|
969
1166
|
if (projectType === "adonis") {
|
|
970
|
-
await confirmProjectType(
|
|
1167
|
+
await confirmProjectType(import_picocolors5.default.magenta("Adonis"));
|
|
971
1168
|
}
|
|
972
1169
|
if (projectType === "react") {
|
|
973
|
-
await confirmProjectType(
|
|
1170
|
+
await confirmProjectType(import_picocolors5.default.cyan("React"));
|
|
974
1171
|
}
|
|
975
1172
|
if (projectType === "nestjs") {
|
|
976
|
-
await confirmProjectType(
|
|
1173
|
+
await confirmProjectType(import_picocolors5.default.red("NestJS"));
|
|
977
1174
|
}
|
|
978
1175
|
if (projectType === "node") {
|
|
979
|
-
|
|
980
|
-
`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.`
|
|
981
1178
|
);
|
|
982
1179
|
process.exit(1);
|
|
983
1180
|
}
|
|
@@ -988,10 +1185,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
988
1185
|
} else {
|
|
989
1186
|
if (!await packageJson7.isESM()) {
|
|
990
1187
|
const isConfirmed = await polishConfirm({
|
|
991
|
-
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)`
|
|
992
1189
|
});
|
|
993
|
-
if (
|
|
994
|
-
|
|
1190
|
+
if (p11.isCancel(isConfirmed) || !isConfirmed) {
|
|
1191
|
+
p11.cancel("Zmie\u0144 projekt na ESM i spr\xF3buj ponownie.");
|
|
995
1192
|
process.exit(1);
|
|
996
1193
|
}
|
|
997
1194
|
await packageJson7.ensureESM();
|
|
@@ -1021,35 +1218,35 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
1021
1218
|
process.exit(1);
|
|
1022
1219
|
}
|
|
1023
1220
|
} else {
|
|
1024
|
-
const additionalTools = await
|
|
1025
|
-
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")}`,
|
|
1026
1223
|
initialValues: ["eslint", "prettier", "gh-action", "commitlint"],
|
|
1027
1224
|
options: [
|
|
1028
1225
|
{
|
|
1029
1226
|
value: "eslint",
|
|
1030
|
-
label:
|
|
1227
|
+
label: import_picocolors5.default.bold(import_picocolors5.default.blueBright("ESLint")),
|
|
1031
1228
|
hint: "sprawdzanie jako\u015Bci kodu"
|
|
1032
1229
|
},
|
|
1033
1230
|
{
|
|
1034
1231
|
value: "prettier",
|
|
1035
|
-
label:
|
|
1232
|
+
label: import_picocolors5.default.bold(import_picocolors5.default.yellowBright("Prettier")),
|
|
1036
1233
|
hint: "formatowanie"
|
|
1037
1234
|
},
|
|
1038
1235
|
{
|
|
1039
1236
|
value: "gh-action",
|
|
1040
|
-
label:
|
|
1041
|
-
hint: "automatyczne testy na
|
|
1237
|
+
label: import_picocolors5.default.bold("GitHub Actions"),
|
|
1238
|
+
hint: "automatyczne testy na GitHubie"
|
|
1042
1239
|
},
|
|
1043
1240
|
{
|
|
1044
1241
|
value: "commitlint",
|
|
1045
|
-
label:
|
|
1242
|
+
label: import_picocolors5.default.bold("Commitlint"),
|
|
1046
1243
|
hint: "walidacja tre\u015Bci commit\xF3w"
|
|
1047
1244
|
}
|
|
1048
1245
|
],
|
|
1049
1246
|
required: false
|
|
1050
1247
|
});
|
|
1051
|
-
if (
|
|
1052
|
-
|
|
1248
|
+
if (p11.isCancel(additionalTools) || additionalTools.length === 0) {
|
|
1249
|
+
p11.cancel("Nie wybrano \u017Cadnych narz\u0119dzi.");
|
|
1053
1250
|
process.exit(1);
|
|
1054
1251
|
}
|
|
1055
1252
|
toolsToInstall = additionalTools;
|
|
@@ -1072,7 +1269,10 @@ ${import_picocolors2.default.cyan("npx @solvro/config")}`;
|
|
|
1072
1269
|
await installGithubActions();
|
|
1073
1270
|
}
|
|
1074
1271
|
await packageJson7.clearInstall();
|
|
1075
|
-
|
|
1272
|
+
if (toolsToInstall.includes("prettier")) {
|
|
1273
|
+
await packageJson7.localExecute("prettier", "--write", "package.json");
|
|
1274
|
+
}
|
|
1275
|
+
const printSuccess = isNonInteractive ? console.info : p11.outro;
|
|
1076
1276
|
printSuccess("\u2705 Konfiguracja zako\u0144czona pomy\u015Blnie!");
|
|
1077
1277
|
}
|
|
1078
1278
|
async function mainWrapper() {
|
|
@@ -1081,7 +1281,7 @@ async function mainWrapper() {
|
|
|
1081
1281
|
} catch (error) {
|
|
1082
1282
|
if (process.env.NODE_ENV === "development") {
|
|
1083
1283
|
console.error(
|
|
1084
|
-
|
|
1284
|
+
import_picocolors5.default.red("Unhandled error in main:"),
|
|
1085
1285
|
error instanceof Error ? error.message : error
|
|
1086
1286
|
);
|
|
1087
1287
|
} else {
|
|
@@ -1090,7 +1290,7 @@ async function mainWrapper() {
|
|
|
1090
1290
|
console.error(errorMessage);
|
|
1091
1291
|
console.error(BUG_TRACKER_URL);
|
|
1092
1292
|
} else {
|
|
1093
|
-
|
|
1293
|
+
p11.cancel(`${errorMessage} ${BUG_TRACKER_URL}`);
|
|
1094
1294
|
}
|
|
1095
1295
|
}
|
|
1096
1296
|
process.exit(1);
|