diff --git a/src/Console/Install.php b/src/Console/Install.php new file mode 100644 index 0000000..27a2c57 --- /dev/null +++ b/src/Console/Install.php @@ -0,0 +1,37 @@ +error("🐳 To install packages, please run 'php artisan bag:install' outside Sail."); + return 0; + } + + $this->syncPackages(); + } + + protected function proxyHandle() + { + //ignored + } +} diff --git a/src/Console/ProxyCommand.php b/src/Console/ProxyCommand.php index d855194..b7b156b 100644 --- a/src/Console/ProxyCommand.php +++ b/src/Console/ProxyCommand.php @@ -7,16 +7,29 @@ use Illuminate\Support\Facades\Process; abstract class ProxyCommand extends Command { + const PACKAGES = [ + 'stack-laravel', + ]; + protected $base_path; - abstract protected function proxyHandle(); + public function __construct() + { + parent::__construct(); + + $this->base_path = realpath(__DIR__ . '/../..'); + } public function handle() { - $this->base_path = realpath(__DIR__ . '/../..'); + foreach (self::PACKAGES as $package) { + if (! is_dir("{$this->base_path}/packages/$package")) { + $this->error("🚨 Missing package bag/$package. Please run 'php artisan bag:install' first."); + return 1; + } + } try { - $this->syncPackages(); return $this->proxyHandle(); } catch (\Exception $exception) { @@ -25,9 +38,13 @@ abstract class ProxyCommand extends Command } } + abstract protected function proxyHandle(); + protected function syncPackages(): void { - $this->syncPackage('stack-laravel'); + foreach (self::PACKAGES as $package) { + $this->syncPackage($package); + } } protected function syncPackage($package): void diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index af04a05..480a2bf 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -28,6 +28,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider implements Def } $this->commands([ + Console\Install::class, Console\MakeMigrations::class, //... ]); @@ -41,6 +42,7 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider implements Def public function provides() { return [ + Console\Install::class, Console\MakeMigrations::class, ]; }