Skip to content

Commit

Permalink
Installation Issue Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jiten14 committed Sep 9, 2024
1 parent a6f106b commit 5e32a52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 42 deletions.
14 changes: 0 additions & 14 deletions src/Commands/JitoneAiCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
35 changes: 7 additions & 28 deletions src/JitoneAiServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down

0 comments on commit 5e32a52

Please sign in to comment.