Skip to content

Commit

Permalink
Improves sail console output
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 29, 2024
1 parent 9f8314a commit 1c21e92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
],
"require": {
"php": "^8.0",
"illuminate/console": "^9.0|^10.0|^11.0",
"illuminate/contracts": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"illuminate/console": "^9.52.16|^10.0|^11.0",
"illuminate/contracts": "^9.52.16|^10.0|^11.0",
"illuminate/support": "^9.52.16|^10.0|^11.0",
"symfony/yaml": "^6.0|^7.0"
},
"bin": [
Expand Down
7 changes: 4 additions & 3 deletions src/Console/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function handle()
}

if ($invalidServices = array_diff($services, $this->services)) {
$this->error('Invalid services ['.implode(',', $invalidServices).'].');
$this->components->error('Invalid services ['.implode(',', $invalidServices).'].');

return 1;
}
Expand All @@ -50,8 +50,9 @@ public function handle()
$this->replaceEnvVariables($services);
$this->configurePhpUnit();

$this->info('Additional Sail services installed successfully.');

$this->prepareInstallation($services);

$this->output->writeln('');
$this->components->info('Additional Sail services installed successfully.');
}
}
12 changes: 2 additions & 10 deletions src/Console/Concerns/InteractsWithDockerComposeServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,14 @@ protected function prepareInstallation($services)
}

if (count($services) > 0) {
$status = $this->runCommands([
$this->runCommands([
'./vendor/bin/sail pull '.implode(' ', $services),
]);

if ($status === 0) {
$this->info('Sail images installed successfully.');
}
}

$status = $this->runCommands([
$this->runCommands([
'./vendor/bin/sail build',
]);

if ($status === 0) {
$this->info('Sail build successful.');
}
}

/**
Expand Down
19 changes: 16 additions & 3 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function handle()
}

if ($invalidServices = array_diff($services, $this->services)) {
$this->error('Invalid services ['.implode(',', $invalidServices).'].');
$this->components->error('Invalid services ['.implode(',', $invalidServices).'].');

return 1;
}
Expand All @@ -55,8 +55,21 @@ public function handle()
$this->installDevContainer();
}

$this->info('Sail scaffolding installed successfully.');

$this->prepareInstallation($services);

$this->output->writeln('');
$this->components->info('Sail scaffolding installed successfully. Initiate Docker containers using Sail\'s "up" command.');

$this->output->writeln('<fg=gray>➜</> <options=bold>./vendor/bin/sail up</>');

if (in_array('mysql', $services) ||
in_array('mariadb', $services) ||
in_array('pgsql', $services)) {
$this->components->warn('A database service was installed. Run "artisan migrate" to prepare your database:');

$this->output->writeln('<fg=gray>➜</> <options=bold>./vendor/bin/sail artisan migrate</>');
}

$this->output->writeln('');
}
}

0 comments on commit 1c21e92

Please sign in to comment.