From b7cce135553a6e3be9148b783d4a9deaba5eeff3 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 9 May 2024 18:31:23 +0800 Subject: [PATCH] Only run migration after selecting the database Signed-off-by: Mior Muhammad Zaki --- src/NewCommand.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/NewCommand.php b/src/NewCommand.php index 032b0ee..83b6beb 100644 --- a/src/NewCommand.php +++ b/src/NewCommand.php @@ -158,9 +158,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $composer = $this->findComposer(); + $phpBinary = $this->phpBinary(); $commands = [ - $composer." create-project laravel/laravel \"$directory\" $version --remove-vcs --prefer-dist", + $composer." create-project laravel/laravel \"$directory\" $version --remove-vcs --prefer-dist --no-scripts", + $composer." run post-root-package-install -d \"$directory\"", + $phpBinary." \"$directory/artisan\" key:generate --ansi", ]; if ($directory != '.' && $input->getOption('force')) { @@ -464,12 +467,12 @@ protected function promptForDatabaseOptions(string $directory, InputInterface $i default: $defaultDatabase, )); - if ($input->getOption('database') !== 'sqlite') { - $migrate = confirm( - label: 'Default database updated. Would you like to run the default database migrations?', - default: true - ); - } + $migrate = confirm( + label: $input->getOption('database') !== 'sqlite' + ? 'Default database updated. Would you like to run the default database migrations?' + : 'Would you like to run the default database migrations?', + default: true + ); } return [$input->getOption('database') ?? $defaultDatabase, $migrate ?? false];