@@ -25,7 +25,8 @@ protected function configure()
2525 ->addOption ('react ' , null , InputOption::VALUE_NONE , 'Install react ' )
2626 ->addOption ('tailwind ' , null , InputOption::VALUE_NONE , 'Install tailwind ' )
2727 ->addOption ('vite ' , null , InputOption::VALUE_NONE , 'Setup vite files ' )
28- ->addOption ('vue ' , null , InputOption::VALUE_NONE , 'Install vue ' );
28+ ->addOption ('vue ' , null , InputOption::VALUE_NONE , 'Install vue ' )
29+ ->addOption ('pm ' , 'pm ' , InputOption::VALUE_OPTIONAL , 'Package manager to use ' , 'npm ' );
2930 }
3031
3132 protected function execute (InputInterface $ input , OutputInterface $ output ): int
@@ -39,23 +40,23 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3940 }
4041
4142 if ($ input ->getOption ('inerita ' )) {
42- return $ this ->installInertia ($ output );
43+ return $ this ->installInertia ($ input , $ output );
4344 }
4445
4546 if ($ input ->getOption ('react ' )) {
46- return $ this ->installReact ($ output );
47+ return $ this ->installReact ($ input , $ output );
4748 }
4849
4950 if ($ input ->getOption ('tailwind ' )) {
50- return $ this ->installTailwind ($ output );
51+ return $ this ->installTailwind ($ input , $ output );
5152 }
5253
5354 if ($ input ->getOption ('vite ' )) {
54- return $ this ->installVite ($ output );
55+ return $ this ->installVite ($ input , $ output );
5556 }
5657
5758 if ($ input ->getOption ('vue ' )) {
58- return $ this ->installVue ($ output );
59+ return $ this ->installVue ($ input , $ output );
5960 }
6061
6162 $ output ->writeln ('<error>You didn \'t select an option to install</error> ' );
@@ -157,13 +158,13 @@ protected function installBareUi($output)
157158 /**
158159 * Install inerita
159160 */
160- protected function installInertia ($ output )
161+ protected function installInertia ($ input , $ output )
161162 {
162163 $ directory = getcwd ();
163- $ npm = Utils \Core::findNpm ();
164+ $ npm = Utils \Core::findNpm ($ input -> getOption ( ' pm ' ) );
164165 $ composer = Utils \Core::findComposer ();
165166
166- $ success = Utils \Core::run ("$ npm install @leafphp/vite-plugin vite " , $ output );
167+ $ success = Utils \Core::run ("$ npm add @leafphp/vite-plugin vite " , $ output );
167168
168169 if (!$ success ) {
169170 $ output ->writeln ("❌ <error>Failed to install vite</error> " );
@@ -230,14 +231,14 @@ protected function installInertia($output)
230231 /**
231232 * Install react
232233 */
233- protected function installReact ($ output )
234+ protected function installReact ($ input , $ output )
234235 {
235236 $ output ->writeln ("📦 <info>Installing react...</info> \n" );
236237
237238 $ directory = getcwd ();
238- $ npm = Utils \Core::findNpm ();
239+ $ npm = Utils \Core::findNpm ($ input -> getOption ( ' pm ' ) );
239240 $ composer = Utils \Core::findComposer ();
240- $ success = Utils \Core::run ("$ npm install @leafphp/vite-plugin @vitejs/plugin-react @inertiajs/react react react-dom " , $ output );
241+ $ success = Utils \Core::run ("$ npm add @leafphp/vite-plugin @vitejs/plugin-react @inertiajs/react react react-dom " , $ output );
241242
242243 if (!$ success ) {
243244 $ output ->writeln ("❌ <error>Failed to install react</error> " );
@@ -321,15 +322,15 @@ protected function installReact($output)
321322 /**
322323 * Install tailwind
323324 */
324- protected function installTailwind ($ output )
325+ protected function installTailwind ($ input , $ output )
325326 {
326327 $ directory = getcwd ();
327- $ npm = Utils \Core::findNpm ();
328+ $ npm = Utils \Core::findNpm ($ input -> getOption ( ' pm ' ) );
328329 $ composer = Utils \Core::findComposer ();
329330
330331 $ output ->writeln ("📦 <info>Installing tailwind...</info> \n" );
331332
332- $ success = Utils \Core::run ("$ npm install tailwindcss postcss autoprefixer @leafphp/vite-plugin vite " , $ output );
333+ $ success = Utils \Core::run ("$ npm add tailwindcss postcss autoprefixer @leafphp/vite-plugin vite " , $ output );
333334
334335 if (!$ success ) {
335336 $ output ->writeln ("❌ <error>Failed to install tailwind</error> " );
@@ -427,13 +428,13 @@ protected function installTailwind($output)
427428 /**
428429 * Install vite
429430 */
430- protected function installVite ($ output )
431+ protected function installVite ($ input , $ output )
431432 {
432433 $ directory = getcwd ();
433- $ npm = Utils \Core::findNpm ();
434+ $ npm = Utils \Core::findNpm ($ input -> getOption ( ' pm ' ) );
434435 $ composer = Utils \Core::findComposer ();
435436
436- $ success = Utils \Core::run ("$ npm install @leafphp/vite-plugin vite " , $ output );
437+ $ success = Utils \Core::run ("$ npm add @leafphp/vite-plugin vite " , $ output );
437438
438439 if (!$ success ) {
439440 $ output ->writeln ("❌ <error>Failed to install vite</error> " );
@@ -483,14 +484,14 @@ protected function installVite($output)
483484 /**
484485 * Install vue
485486 */
486- protected function installVue ($ output )
487+ protected function installVue ($ input , $ output )
487488 {
488489 $ output ->writeln ("📦 <info>Installing Vue...</info> \n" );
489490
490491 $ directory = getcwd ();
491- $ npm = Utils \Core::findNpm ();
492+ $ npm = Utils \Core::findNpm ($ input -> getOption ( ' pm ' ) );
492493 $ composer = Utils \Core::findComposer ();
493- $ success = Utils \Core::run ("$ npm install @leafphp/vite-plugin @vitejs/plugin-vue @inertiajs/vue3 vue " , $ output );
494+ $ success = Utils \Core::run ("$ npm add @leafphp/vite-plugin @vitejs/plugin-vue @inertiajs/vue3 vue " , $ output );
494495
495496 if (!$ success ) {
496497 $ output ->writeln ("❌ <error>Failed to install Vue</error> " );
0 commit comments