From 28b5e9b46077b0452e8f373a5d9608ef716253aa Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Thu, 10 Aug 2023 13:57:05 -0700 Subject: [PATCH 1/3] Enable publishing any tag name --- src/Commands/InstallCommand.php | 60 +++++++++------------------------ 1 file changed, 15 insertions(+), 45 deletions(-) diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 35d0f5c..2efd419 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -13,13 +13,7 @@ class InstallCommand extends Command public ?Closure $startWith = null; - protected bool $shouldPublishConfigFile = false; - - protected bool $shouldPublishAssets = false; - - protected bool $shouldPublishInertiaComponents = false; - - protected bool $shouldPublishMigrations = false; + protected array $publishes = []; protected bool $askToRunMigrations = false; @@ -48,35 +42,12 @@ public function handle() ($this->startWith)($this); } - if ($this->shouldPublishConfigFile) { - $this->comment('Publishing config file...'); - - $this->callSilently("vendor:publish", [ - '--tag' => "{$this->package->shortName()}-config", - ]); - } - - if ($this->shouldPublishAssets) { - $this->comment('Publishing assets...'); + foreach ($this->publishes as $tag) { + $name = str_replace('-', ' ', $tag); + $this->comment("Publishing $name..."); $this->callSilently("vendor:publish", [ - '--tag' => "{$this->package->shortName()}-assets", - ]); - } - - if ($this->shouldPublishInertiaComponents) { - $this->comment('Publishing inertia components...'); - - $this->callSilently("vendor:publish", [ - '--tag' => "{$this->package->shortName()}-inertia-components", - ]); - } - - if ($this->shouldPublishMigrations) { - $this->comment('Publishing migration...'); - - $this->callSilently("vendor:publish", [ - '--tag' => "{$this->package->shortName()}-migrations", + '--tag' => "{$this->package->shortName()}-{$tag}", ]); } @@ -117,32 +88,31 @@ public function handle() } } - public function publishConfigFile(): self + public function publish(string $tag): self { - $this->shouldPublishConfigFile = true; + $this->publishes[] = $tag; return $this; } - public function publishAssets(): self + public function publishConfigFile(): self { - $this->shouldPublishAssets = true; + return $this->publish('config'); + } - return $this; + public function publishAssets(): self + { + return $this->publish('assets'); } public function publishInertiaComponents(): self { - $this->shouldPublishInertiaComponents = true; - - return $this; + return $this->publish('inertia-components'); } public function publishMigrations(): self { - $this->shouldPublishMigrations = true; - - return $this; + return $this->publish('migrations'); } public function askToRunMigrations(): self From 65bc4f4c5c6ee6ab6ce46f69d6bbf23886df0bce Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 11 Aug 2023 09:41:42 +0200 Subject: [PATCH 2/3] Update InstallCommand.php --- src/Commands/InstallCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 2efd419..daf93e1 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -44,7 +44,7 @@ public function handle() foreach ($this->publishes as $tag) { $name = str_replace('-', ' ', $tag); - $this->comment("Publishing $name..."); + $this->comment("Publishing {$name}..."); $this->callSilently("vendor:publish", [ '--tag' => "{$this->package->shortName()}-{$tag}", From aa2ea563a8478c108ade9c8f7911cd8ded37211a Mon Sep 17 00:00:00 2001 From: Matt Isenhower Date: Tue, 22 Aug 2023 11:01:57 -0700 Subject: [PATCH 3/3] Make publish variadic --- src/Commands/InstallCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index daf93e1..1453bdb 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -88,9 +88,9 @@ public function handle() } } - public function publish(string $tag): self + public function publish(string ...$tag): self { - $this->publishes[] = $tag; + $this->publishes = array_merge($this->publishes, $tag); return $this; }