diff --git a/packages/builder/build.php b/packages/builder/build.php index 32f430a6c..d2d4884b5 100644 --- a/packages/builder/build.php +++ b/packages/builder/build.php @@ -159,13 +159,13 @@ function replaceForAllOtherOSes(): array $currentDirectory = getcwd(); $folderName = basename($currentDirectory); -if(!isValidPackageName($folderName)){ +if (! isValidPackageName($folderName)) { do { writeln('Invalid package name: "builder" is not allowed.'); $name = ask('Package name'); $packageName = $name; } while (! isValidPackageName($packageName)); -}else{ +} else { $packageName = $folderName; } diff --git a/packages/builder/src/Commands/InstallCommand.php b/packages/builder/src/Commands/InstallCommand.php index efe75d9da..0718e3f6d 100644 --- a/packages/builder/src/Commands/InstallCommand.php +++ b/packages/builder/src/Commands/InstallCommand.php @@ -100,64 +100,64 @@ public function run_migrations(): void public function register_plugins(): void { if (confirm('Do you wish to publish the configuration?', true)) { - note('Registering the Filament Resources...'); + note('Registering the Filament Resources...'); - $providerPath = app_path('Providers/Filament/AdminPanelProvider.php'); + $providerPath = app_path('Providers/Filament/AdminPanelProvider.php'); - if (File::exists($providerPath)) { + if (File::exists($providerPath)) { - $content = File::get($providerPath); + $content = File::get($providerPath); - $intend = ' '; + $intend = ' '; - $namespace = "\Moox\Builder"; + $namespace = "\Moox\Builder"; - $pluginsToAdd = multiselect( - label: 'These plugins will be installed:', - options: ['BuilderPlugin'], - default: ['BuilderPlugin'], - ); + $pluginsToAdd = multiselect( + label: 'These plugins will be installed:', + options: ['BuilderPlugin'], + default: ['BuilderPlugin'], + ); - $function = '::make(),'; + $function = '::make(),'; - $pattern = '/->plugins\(\[([\s\S]*?)\]\);/'; - $newPlugins = ''; + $pattern = '/->plugins\(\[([\s\S]*?)\]\);/'; + $newPlugins = ''; - foreach ($pluginsToAdd as $plugin) { - $searchPlugin = '/'.$plugin.'/'; - if (preg_match($searchPlugin, $content)) { - info("$plugin already registered."); - } else { - $newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n"; + foreach ($pluginsToAdd as $plugin) { + $searchPlugin = '/'.$plugin.'/'; + if (preg_match($searchPlugin, $content)) { + info("$plugin already registered."); + } else { + $newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n"; + } } - } - if ($newPlugins) { + if ($newPlugins) { - if (preg_match($pattern, $content)) { - info('Plugins section found. Adding new plugins...'); + if (preg_match($pattern, $content)) { + info('Plugins section found. Adding new plugins...'); - $replacement = "->plugins([$1\n$newPlugins\n ]);"; - $newContent = preg_replace($pattern, $replacement, $content); + $replacement = "->plugins([$1\n$newPlugins\n ]);"; + $newContent = preg_replace($pattern, $replacement, $content); - } else { - info('Plugins section created. Adding new plugins...'); + } else { + info('Plugins section created. Adding new plugins...'); - $pluginsSection = " ->plugins([\n$newPlugins\n ]);"; - $placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s'; - $replacement = "$1\n".$pluginsSection; - $newContent = preg_replace($placeholderPattern, $replacement, $content, 1); - } + $pluginsSection = " ->plugins([\n$newPlugins\n ]);"; + $placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s'; + $replacement = "$1\n".$pluginsSection; + $newContent = preg_replace($placeholderPattern, $replacement, $content, 1); + } - File::put($providerPath, $newContent); - } + File::put($providerPath, $newContent); + } - } else { + } else { - alert('AdminPanelProvider not found. You need to add the plugins manually.'); + alert('AdminPanelProvider not found. You need to add the plugins manually.'); + } } } - } public function finish(): void {