diff --git a/src/Commands/JitoneAiCommand.php b/src/Commands/JitoneAiCommand.php index aeb2bcc..c9f6073 100644 --- a/src/Commands/JitoneAiCommand.php +++ b/src/Commands/JitoneAiCommand.php @@ -26,20 +26,6 @@ public function handle(): int $this->info('JitoneAi package has been set up successfully!'); $this->info('Please review the configuration file at config/jitone-ai.php'); - // Ask to star the repo - if ($this->confirm('Would you like to star our repo on GitHub?', true)) { - $repoUrl = 'https://github.com/jiten14/jitone-ai'; - $this->info("Thanks! You can star the repo here: {$repoUrl}"); - - if (PHP_OS_FAMILY === 'Darwin') { - exec("open {$repoUrl}"); - } elseif (PHP_OS_FAMILY === 'Windows') { - exec("start {$repoUrl}"); - } elseif (PHP_OS_FAMILY === 'Linux') { - exec("xdg-open {$repoUrl}"); - } - } - return self::SUCCESS; } } \ No newline at end of file diff --git a/src/JitoneAiServiceProvider.php b/src/JitoneAiServiceProvider.php index 202946f..64f6d71 100644 --- a/src/JitoneAiServiceProvider.php +++ b/src/JitoneAiServiceProvider.php @@ -12,6 +12,7 @@ use Jiten14\JitoneAi\Forms\Actions\GenerateContentAction; use Jiten14\JitoneAi\Services\OpenAIService; use Jiten14\JitoneAi\Services\ImageGenerationService; +use Spatie\LaravelPackageTools\Commands\InstallCommand; class JitoneAiServiceProvider extends PackageServiceProvider { @@ -22,34 +23,12 @@ public function configurePackage(Package $package): void $package ->name(static::$name) ->hasConfigFile() - ->hasCommand(JitoneAiCommand::class); - - // Register a post-install hook - $this->app->booted(function () { - $this->registerPostInstallHook(); - }); - } - - protected function registerPostInstallHook() - { - if ($this->app->runningInConsole()) { - $composerJson = json_decode(file_get_contents(base_path('composer.json')), true); - $scripts = $composerJson['scripts'] ?? []; - - if (!isset($scripts['post-autoload-dump'])) { - $scripts['post-autoload-dump'] = []; - } - - if (!in_array('@php artisan jitone-ai:install', $scripts['post-autoload-dump'])) { - $scripts['post-autoload-dump'][] = '@php artisan jitone-ai:install'; - $composerJson['scripts'] = $scripts; - - file_put_contents( - base_path('composer.json'), - json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) - ); - } - } + ->hasCommand(JitoneAiCommand::class) + ->hasInstallCommand(function (InstallCommand $command) { + $command + ->publishConfigFile() + ->askToStarRepoOnGitHub('jiten14/jitone-ai'); + }); } public function packageRegistered(): void