Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected function configure()
->addOption('vue', null, InputOption::VALUE_NONE, 'Install the Vue Starter Kit')
->addOption('livewire', null, InputOption::VALUE_NONE, 'Install the Livewire Starter Kit')
->addOption('livewire-class-components', null, InputOption::VALUE_NONE, 'Generate stand-alone Livewire class components')
->addOption('api', null, InputOption::VALUE_NONE, 'Install Laravel API with Sanctum')
->addOption('withPassport', null, InputOption::VALUE_NONE, 'Use Passport for authentication')
->addOption('workos', null, InputOption::VALUE_NONE, 'Use WorkOS for authentication')
->addOption('pest', null, InputOption::VALUE_NONE, 'Install the Pest testing framework')
->addOption('phpunit', null, InputOption::VALUE_NONE, 'Install the PHPUnit testing framework')
Expand Down Expand Up @@ -126,6 +128,36 @@ protected function interact(InputInterface $input, OutputInterface $output)
default => null,
};

if(! $this->usingLaravelStarterKit($input) || $this->usingLaravelStarterKit($input)) {
match(select(
label: 'Would you like to install API?',
options: [
'no' => 'No',
'yes' => 'Yes'
],
default: 'no',
)) {
'no' => $input->setOption('api', false),
'yes' => $input->setOption('api', true),
default => false,
};
}

if($input->getOption('api')) {
match(select(
label: 'Would you like to use Passport?',
options: [
'no' =>'No',
'yes' => 'Yes',
],
default: 'no',
)) {
'no' => $input->setOption('withPassport', false),
'yes'=> $input->setOption('withPassport', true),
default => false,
};
}

if ($this->usingLaravelStarterKit($input)) {
match (select(
label: 'Which authentication provider do you prefer?',
Expand Down Expand Up @@ -291,6 +323,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->createRepository($directory, $input, $output);
}

if($input->getOption('api')) {
$this->installAPI($directory, $input, $output);
}

if ($input->getOption('pest')) {
$this->installPest($directory, $input, $output);
}
Expand Down Expand Up @@ -569,6 +605,27 @@ protected function validateDatabaseOption(InputInterface $input)
}
}

/**
* Install API routes to the application
*
* @param \Symfony\Component\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return void
*/
protected function installAPI(string $directory, InputInterface $input, OutputInterface $output) {
if($input->getOption('withPassport')) {
$commands = [
'php artisan install:api --passport',
];
} else {
$commands = [
'php artisan install:api',
];
}

$this->runCommands($commands, $input, $output, workingPath: $directory);
}

/**
* Install Pest into the application.
*
Expand Down