11import * as p from "@clack/prompts" ;
22import { Command } from "commander" ;
3- import { getUserAgent } from "package-manager-detector/detect" ;
43import c from "picocolors" ;
54
65import packageJsonData from "../../package.json" ;
76import { BUG_TRACKER_URL } from "../constants" ;
7+ import { checkIsNonInteractive } from "../utils/check-is-non-interactive" ;
88import { confirmProjectType } from "../utils/confirm-project-type" ;
99import { isGitClean } from "../utils/is-git-clean" ;
1010import { PackageJson } from "../utils/package-json" ;
@@ -41,39 +41,17 @@ program
4141program . parse ( ) ;
4242const options : CliOptions = program . opts ( ) ;
4343
44- // Check if running in non-interactive mode (any CLI flags provided)
45- const isNonInteractive = process . argv . length > 2 ;
44+ const isNonInteractive = checkIsNonInteractive ( ) ;
4645
4746async function main ( ) {
4847 if ( ! isNonInteractive ) {
4948 p . intro ( c . bold ( c . bgBlue ( " @solvro/config " ) ) ) ;
5049 }
5150
52- const userAgent = getUserAgent ( ) ;
53-
54- if ( userAgent !== "npm" ) {
55- const packageManager = userAgent ?? "unknown" ;
56- const warningMessage = `\
57- ${ c . red ( c . bold ( `⚠️ OSTRZEŻENIE: ${ packageManager } nie jest obsługiwany ⚠️` ) ) }
58-
59- Próbujesz uruchomić ten skrypt ${ c . yellow ( packageManager ) } 'em, ale @solvro/config obecnie działa tylko z ${ c . green ( "npm" ) } 'em.
60-
61- ${ c . white ( `Support dla innych menedżerów pakietów jest planowany w nadchodzących wersjach - ${ c . yellow ( "zagwiazdkuj i spróbuj ponownie wkrótce" ) } !` ) }
62-
63- ${ c . white ( `W międzyczasie użyj ${ c . green ( "npm" ) } 'a:` ) }
64- ${ c . cyan ( "npx @solvro/config" ) } `;
65-
66- if ( isNonInteractive ) {
67- console . error ( warningMessage ) ;
68- } else {
69- p . cancel ( warningMessage ) ;
70- }
71- process . exit ( 1 ) ;
72- }
73-
7451 const packageJson = new PackageJson ( ) ;
75- // Project directory check
76- await packageJson . load ( ) ;
52+ packageJson . verifyPackageManager ( ) ;
53+ await packageJson . load ( ) ; // Project directory check
54+ await packageJson . validateUserAgentConsistency ( ) ;
7755
7856 // Git clean check
7957 if ( options . force !== true && ! isGitClean ( ) ) {
@@ -140,7 +118,7 @@ ${c.cyan("npx @solvro/config")}`;
140118
141119 if ( projectType === "node" ) {
142120 p . cancel (
143- `Nie znaleziono ani ${ c . magenta ( "Adonis" ) } ' a, ${ c . cyan ( "React" ) } ' a, ani ${ c . white ( "NestJS" ) } ' a. Musisz ręcznie konfigurować projekt.` ,
121+ `Nie znaleziono ani ${ c . magenta ( "Adonis" ) } - a, ${ c . cyan ( "React" ) } - a, ani ${ c . white ( "NestJS" ) } - a. Musisz ręcznie konfigurować projekt.` ,
144122 ) ;
145123 process . exit ( 1 ) ;
146124 }
@@ -151,7 +129,7 @@ ${c.cyan("npx @solvro/config")}`;
151129 } else {
152130 if ( ! ( await packageJson . isESM ( ) ) ) {
153131 const isConfirmed = await polishConfirm ( {
154- message : `Twój projekt nie używa ESM (brak type: "module" w package.json). Czy chcesz to dodać? (Wymagane by kontynuować)` ,
132+ message : `Twój projekt nie używa ESM (brak " type" : "module" w package.json). Czy chcesz to dodać? (Wymagane by kontynuować)` ,
155133 } ) ;
156134
157135 if ( p . isCancel ( isConfirmed ) || ! isConfirmed ) {
@@ -209,7 +187,7 @@ ${c.cyan("npx @solvro/config")}`;
209187 {
210188 value : "gh-action" ,
211189 label : c . bold ( "GitHub Actions" ) ,
212- hint : "automatyczne testy na Githubie " ,
190+ hint : "automatyczne testy na GitHubie " ,
213191 } ,
214192 {
215193 value : "commitlint" ,
@@ -253,6 +231,9 @@ ${c.cyan("npx @solvro/config")}`;
253231 }
254232
255233 await packageJson . clearInstall ( ) ;
234+ if ( toolsToInstall . includes ( "prettier" ) ) {
235+ await packageJson . localExecute ( "prettier" , "--write" , "package.json" ) ;
236+ }
256237
257238 const printSuccess = isNonInteractive ? console . info : p . outro ;
258239 printSuccess ( "✅ Konfiguracja zakończona pomyślnie!" ) ;
0 commit comments