diff --git a/README.md b/README.md index 53e1267..e9bc288 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ composer require stephenjude/filament-jetstream Install Jetstream with team, api and email verification. ```php -php artisan filament:jetstream:install --team --api --verification +php artisan filament:jetstream:install --teams --api --verification ``` You can publish the config file with: diff --git a/src/Commands/FilamentJetstreamCommand.php b/src/Commands/FilamentJetstreamCommand.php index 8a300b8..d53b57a 100644 --- a/src/Commands/FilamentJetstreamCommand.php +++ b/src/Commands/FilamentJetstreamCommand.php @@ -6,33 +6,34 @@ class FilamentJetstreamCommand extends Command { - public $signature = 'filament:jetstream:install {--dark : Indicate that dark mode support should be installed} - {--teams : Indicates if team support should be installed} - {--api : Indicates if API support should be installed}'; + public $signature = 'filament:jetstream:install {--teams : Indicates if team support should be installed} + {--api : Indicates if API support should be installed} + {--verification : Indicates if email verification support should be installed} + {--dark : Indicate that dark mode support should be installed}'; public $description = 'Install the Jetstream component and it\'s filament component'; public function handle(): int { - $this->callSilently( - sprintf( - 'jetstream:install livewire %s %s %s %s', - $this->option('team') ? '--team' : '', - $this->option('api') ? '--api' : '', - $this->option('verification') ? '--verification' : '', - $this->option('dark') ? '--dark' : '' - ) - ); + $this->callSilently('jetstream:install', [ + 'stack' => 'livewire', + '--teams' => $this->option('teams'), + '--api' => $this->option('api'), + '--verification' => $this->option('verification'), + '--dark' => $this->option('dark'), + ]); $this->configureUser(); - if ($this->option('team')) { + if ($this->option('teams')) { $this->configureTeam(); } $this->configureAssets(); - $this->comment('All done'); + $this->line(''); + + $this->info('Jetstream scaffolding installed successfully.'); return self::SUCCESS; } @@ -41,9 +42,9 @@ public function configureUser(): void { $this->replaceInFile( search: 'use Laravel\Sanctum\HasApiTokens;', - replace: 'use Filament\Panel;' . PHP_EOL . - 'use Filament\Models\Contracts\FilamentUser;' . PHP_EOL . - 'use Laravel\Sanctum\HasApiTokens;' . PHP_EOL, + replace: 'use Filament\Panel;'.PHP_EOL. + 'use Filament\Models\Contracts\FilamentUser;'.PHP_EOL. + 'use Laravel\Sanctum\HasApiTokens;'.PHP_EOL, path: app_path('Models/User.php'), ); @@ -54,9 +55,9 @@ public function configureUser(): void ); $this->replaceInFile( - search: '}' . PHP_EOL, - replace: 'public function canAccessPanel(Panel $panel): bool' . PHP_EOL . '{' . PHP_EOL . - ' return;' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL, + search: '}'.PHP_EOL, + replace: 'public function canAccessPanel(Panel $panel): bool'.PHP_EOL.'{'.PHP_EOL. + ' return;'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL, path: app_path('Models/User.php'), ); @@ -73,10 +74,10 @@ public function configureTeam(): void { $this->replaceInFile( search: 'use Laravel\Sanctum\HasApiTokens;', - replace: 'use Illuminate\Support\Collection;' . PHP_EOL . - 'use Illuminate\Database\Eloquent\Model;' . PHP_EOL . - 'use Filament\Models\Contracts\HasTenants;' . PHP_EOL . - 'use Laravel\Sanctum\HasApiTokens;' . PHP_EOL, + replace: 'use Illuminate\Support\Collection;'.PHP_EOL. + 'use Illuminate\Database\Eloquent\Model;'.PHP_EOL. + 'use Filament\Models\Contracts\HasTenants;'.PHP_EOL. + 'use Laravel\Sanctum\HasApiTokens;'.PHP_EOL, path: app_path('Models/User.php'), ); @@ -87,16 +88,16 @@ public function configureTeam(): void ); $this->replaceInFile( - search: '}' . PHP_EOL . '}' . PHP_EOL, - replace: 'public function canAccessTenant(Model $tenant): bool' . PHP_EOL . '{' . PHP_EOL . - ' return $this->belongsToTeam($tenant);' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL, + search: '}'.PHP_EOL.'}'.PHP_EOL, + replace: 'public function canAccessTenant(Model $tenant): bool'.PHP_EOL.'{'.PHP_EOL. + ' return $this->belongsToTeam($tenant);'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL, path: app_path('Models/User.php'), ); $this->replaceInFile( - search: '}' . PHP_EOL . '}' . PHP_EOL, - replace: 'public function getTenants(Panel $panel): Collection' . PHP_EOL . '{' . PHP_EOL . - ' return $this->allTeams();' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL, + search: '}'.PHP_EOL.'}'.PHP_EOL, + replace: 'public function getTenants(Panel $panel): Collection'.PHP_EOL.'{'.PHP_EOL. + ' return $this->allTeams();'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL, path: app_path('Models/User.php'), ); } @@ -104,11 +105,11 @@ public function configureTeam(): void public function configureAssets(): void { $this->replaceInFile( - search: 'content: [' . PHP_EOL, - replace: 'content: [' . PHP_EOL . - './app/Filament/**/*.php' . PHP_EOL . - './resources/views/filament/**/*.blade.php' . PHP_EOL . - './vendor/filament/**/*.blade.php' . PHP_EOL, + search: 'content: ['.PHP_EOL, + replace: 'content: ['.PHP_EOL. + './app/Filament/**/*.php'.PHP_EOL. + './resources/views/filament/**/*.blade.php'.PHP_EOL. + './vendor/filament/**/*.blade.php'.PHP_EOL, path: base_path('Models/User.php'), ); @@ -119,16 +120,16 @@ public function configureAssets(): void ); $this->replaceInFile( - search: '}' . PHP_EOL . '}' . PHP_EOL, - replace: 'public function canAccessTenant(Model $tenant): bool' . PHP_EOL . '{' . PHP_EOL . - ' return $this->belongsToTeam($tenant);' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL, + search: '}'.PHP_EOL.'}'.PHP_EOL, + replace: 'public function canAccessTenant(Model $tenant): bool'.PHP_EOL.'{'.PHP_EOL. + ' return $this->belongsToTeam($tenant);'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL, path: app_path('Models/User.php'), ); $this->replaceInFile( - search: '}' . PHP_EOL . '}' . PHP_EOL, - replace: 'public function getTenants(Panel $panel): Collection' . PHP_EOL . '{' . PHP_EOL . - ' return $this->allTeams();' . PHP_EOL . '}' . PHP_EOL . '}' . PHP_EOL, + search: '}'.PHP_EOL.'}'.PHP_EOL, + replace: 'public function getTenants(Panel $panel): Collection'.PHP_EOL.'{'.PHP_EOL. + ' return $this->allTeams();'.PHP_EOL.'}'.PHP_EOL.'}'.PHP_EOL, path: app_path('tailwind.config.js'), ); } diff --git a/src/FilamentJetstreamServiceProvider.php b/src/FilamentJetstreamServiceProvider.php index 062879b..a630903 100644 --- a/src/FilamentJetstreamServiceProvider.php +++ b/src/FilamentJetstreamServiceProvider.php @@ -3,17 +3,11 @@ namespace FilamentJetstream\FilamentJetstream; use Filament\Events\Auth\Registered; -use Filament\Support\Assets\Asset; -use Filament\Support\Assets\Css; -use Filament\Support\Assets\Js; -use Filament\Support\Facades\FilamentAsset; -use Filament\Support\Facades\FilamentIcon; use FilamentJetstream\FilamentJetstream\Commands\FilamentJetstreamCommand; use FilamentJetstream\FilamentJetstream\Listeners\CreatePersonalTeam; use FilamentJetstream\FilamentJetstream\Testing\TestsFilamentJetstream; use Illuminate\Support\Facades\Event; use Livewire\Features\SupportTesting\Testable; -use Spatie\LaravelPackageTools\Commands\InstallCommand; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; @@ -31,12 +25,7 @@ public function configurePackage(Package $package): void * More info: https://github.com/spatie/laravel-package-tools */ $package->name(static::$name) - ->hasCommands($this->getCommands()) - ->hasInstallCommand(function (InstallCommand $command) { - $command - ->publishConfigFile() - ->askToStarRepoOnGitHub('stephenjude/filament-jetstream'); - }); + ->hasCommands($this->getCommands()); $configFileName = $package->shortName(); @@ -64,40 +53,10 @@ public function packageBooted(): void CreatePersonalTeam::class, ); - // Asset Registration - FilamentAsset::register( - $this->getAssets(), - $this->getAssetPackageName() - ); - - FilamentAsset::registerScriptData( - $this->getScriptData(), - $this->getAssetPackageName() - ); - - // Icon Registration - FilamentIcon::register($this->getIcons()); - // Testing Testable::mixin(new TestsFilamentJetstream()); } - protected function getAssetPackageName(): ?string - { - return 'stephenjude/filament-jetstream'; - } - - /** - * @return array - */ - protected function getAssets(): array - { - return [ - // AlpineComponent::make('filament-jetstream', __DIR__ . '/../resources/dist/components/filament-jetstream.js'), - Css::make('filament-jetstream-styles', __DIR__ . '/../resources/dist/filament-jetstream.css'), - Js::make('filament-jetstream-scripts', __DIR__ . '/../resources/dist/filament-jetstream.js'), - ]; - } /** * @return array @@ -109,13 +68,6 @@ protected function getCommands(): array ]; } - /** - * @return array - */ - protected function getIcons(): array - { - return []; - } /** * @return array @@ -124,22 +76,4 @@ protected function getRoutes(): array { return []; } - - /** - * @return array - */ - protected function getScriptData(): array - { - return []; - } - - /** - * @return array - */ - protected function getMigrations(): array - { - return [ - 'create_filament-jetstream_table', - ]; - } }