Skip to content

Commit

Permalink
Add prompt to ask if user wants kit updatable, and adjust stubbed f…
Browse files Browse the repository at this point in the history
…ile.
  • Loading branch information
jesseleite committed Dec 4, 2024
1 parent ecf0442 commit 9e33094
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Console/Commands/StarterKitInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,21 @@ protected function createConfig(): self

$targetPath = base_path('package/starter-kit.yaml');

if (File::exists($targetPath) && $this->input->isInteractive() && ! $this->option('force')) {
if ($this->input->isInteractive() && File::exists($targetPath) && ! $this->option('force')) {
if (! confirm('A [starter-kit.yaml] config already exists. Would you like to overwrite it?', false)) {
return $this;
}
}

// TODO: Ask if updatable, and if so prepend `updatable: true` to yaml and create service provider too?
if ($this->input->isInteractive()) {
if (confirm(
label: 'Would you like to make this starter-kit updatable?',
default: false,
hint: 'Read more: https://statamic.dev/starter-kits/creating-a-starter-kit#making-starter-kits-updatable',
)) {
$contents = "updatable: true\n".$contents;
}
}

File::put($targetPath, $contents);

Expand All @@ -143,7 +151,7 @@ protected function createComposerJson(?string $package, ?string $name, ?string $

$targetPath = base_path('package/composer.json');

if (File::exists($targetPath) && $this->input->isInteractive() && ! $this->option('force')) {
if ($this->input->isInteractive() && File::exists($targetPath) && ! $this->option('force')) {
if (! confirm('A [composer.json] config already exists. Would you like to overwrite it?', false)) {
return $this;
}
Expand Down

0 comments on commit 9e33094

Please sign in to comment.