@@ -140,55 +140,73 @@ public function autoRepair(string $themePath, SymfonyStyle $io, OutputInterface
140140
141141 // Check for node_modules directory
142142 if (!$ this ->fileDriver ->isDirectory ($ tailwindPath . '/node_modules ' )) {
143- if ($ isVerbose ) {
144- $ io -> warning ( ' Node modules not found in tailwind directory. Running npm ci... ' ) ;
143+ if (! $ this -> installNodeModules ( $ tailwindPath , $ io , $ isVerbose) ) {
144+ return false ;
145145 }
146+ }
146147
147- $ currentDir = getcwd ();
148- chdir ($ tailwindPath );
148+ // Check for outdated packages
149+ if ($ isVerbose ) {
150+ $ this ->checkOutdatedPackages ($ tailwindPath , $ io );
151+ }
149152
150- try {
151- if ($ this ->fileDriver ->isExists ($ tailwindPath . '/package-lock.json ' )) {
152- $ this ->shell ->execute ('npm ci --quiet ' );
153- } else {
154- if ($ isVerbose ) {
155- $ io ->warning ('No package-lock.json found, running npm install... ' );
156- }
157- $ this ->shell ->execute ('npm install --quiet ' );
158- }
159- if ($ isVerbose ) {
160- $ io ->success ('Node modules installed successfully. ' );
161- }
162- } catch (\Exception $ e ) {
153+ return true ;
154+ }
155+
156+ /**
157+ * Install Node modules in the tailwind directory
158+ */
159+ private function installNodeModules (string $ tailwindPath , SymfonyStyle $ io , bool $ isVerbose ): bool
160+ {
161+ if ($ isVerbose ) {
162+ $ io ->warning ('Node modules not found in tailwind directory. Running npm ci... ' );
163+ }
164+
165+ $ currentDir = getcwd ();
166+ chdir ($ tailwindPath );
167+
168+ try {
169+ if ($ this ->fileDriver ->isExists ($ tailwindPath . '/package-lock.json ' )) {
170+ $ this ->shell ->execute ('npm ci --quiet ' );
171+ } else {
163172 if ($ isVerbose ) {
164- $ io ->success ( ' Node modules installed successfully . ' );
173+ $ io ->warning ( ' No package-lock.json found, running npm install.. . ' );
165174 }
166- } catch (\Exception $ e ) {
167- $ io ->error ('Failed to install node modules: ' . $ e ->getMessage ());
168- chdir ($ currentDir );
169- return false ;
175+ $ this ->shell ->execute ('npm install --quiet ' );
176+ }
177+
178+ if ($ isVerbose ) {
179+ $ io ->success ('Node modules installed successfully. ' );
170180 }
171181
172182 chdir ($ currentDir );
183+ return true ;
184+ } catch (\Exception $ e ) {
185+ $ io ->error ('Failed to install node modules: ' . $ e ->getMessage ());
186+ chdir ($ currentDir );
187+ return false ;
173188 }
189+ }
174190
175- // Check for outdated packages
176- if ($ isVerbose ) {
177- $ currentDir = getcwd ();
178- chdir ($ tailwindPath );
179- try {
180- $ outdated = $ this ->shell ->execute ('npm outdated --json ' );
181- if ($ outdated ) {
182- $ io ->warning ('Outdated packages found: ' );
183- $ io ->writeln ($ outdated );
184- }
185- } catch (\Exception $ e ) {
186- // Ignore errors from npm outdated as it returns non-zero when packages are outdated
191+ /**
192+ * Check for outdated npm packages and report them
193+ */
194+ private function checkOutdatedPackages (string $ tailwindPath , SymfonyStyle $ io ): void
195+ {
196+ $ currentDir = getcwd ();
197+ chdir ($ tailwindPath );
198+
199+ try {
200+ $ outdated = $ this ->shell ->execute ('npm outdated --json ' );
201+ if ($ outdated ) {
202+ $ io ->warning ('Outdated packages found: ' );
203+ $ io ->writeln ($ outdated );
187204 }
188- chdir ($ currentDir );
205+ } catch (\Exception $ e ) {
206+ // Ignore errors from npm outdated as it returns non-zero when packages are outdated
189207 }
190208
191- return true ;
209+ chdir ( $ currentDir ) ;
192210 }
193211
194212 public function watch (string $ themePath , SymfonyStyle $ io , OutputInterface $ output , bool $ isVerbose ): bool
0 commit comments