Skip to content

Commit

Permalink
Merge pull request #105 from misenhower/publish-anything
Browse files Browse the repository at this point in the history
Enable publishing any tag name with the install command
  • Loading branch information
freekmurze authored Aug 23, 2023
2 parents f534427 + aa2ea56 commit cc7c991
Showing 1 changed file with 15 additions and 45 deletions.
60 changes: 15 additions & 45 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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}",
]);
}

Expand Down Expand Up @@ -117,32 +88,31 @@ public function handle()
}
}

public function publishConfigFile(): self
public function publish(string ...$tag): self
{
$this->shouldPublishConfigFile = true;
$this->publishes = array_merge($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
Expand Down

0 comments on commit cc7c991

Please sign in to comment.