Skip to content

Commit

Permalink
Emoji support
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalduzzi committed May 23, 2023
1 parent 41c051c commit 6294854
Show file tree
Hide file tree
Showing 21 changed files with 94 additions and 51 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": [ "laravel", "docker", "cli" ],
"type": "library",
"license": "MIT",
"version": "0.1.0",
"version": "0.1.1",
"bin": [
"bin/skipper"
],
Expand Down
7 changes: 5 additions & 2 deletions src/Commands/InitCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ protected function handle(): int

$this->io->success("$name has been created successfully.");

$this->io->writeln('Use command <info>sail</info> to start the project containers');
$this->io->writeln('Use command <info>check</info> to validate your project compose file');
$this->io->writeln('⛵️ Use command <info>skipper sail</info> to start the project containers');
$this->io->writeln('Use command <info>skipper check</info> to validate your project compose file');

return Command::SUCCESS;
}
Expand Down Expand Up @@ -185,6 +185,9 @@ private function preparePath(): void

if ($dockerBase) {
DockerBase::install(getcwd(), 'docker');

$this->io->writeln('<info>Resuming the skipper init operation</info>');
$this->io->newLine();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ListCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ListCmd extends BaseCommand
{
protected function handle(): int
{
$data = array_map(fn ($p) => [$p->isRunning() ? 'Yes' : 'No', $p->name, $p->host, $p->path], $this->configRepo->config->projects);
$data = array_map(fn ($p) => [$p->isRunning() ? '🟢' : '🔴', $p->name, $p->host, $p->path], $this->configRepo->config->projects);

$this->io->table(['Running', 'Name', 'Host', 'Path'], $data);

Expand Down
15 changes: 6 additions & 9 deletions src/Commands/ManCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ protected function handle(): int
{
$app = $this->getApplication();

$all = $app->all();

$this->io->writeln("{$app->getName()} <info>{$app->getVersion()}</info>");
$this->io->writeln("{$app->getName()}<info>{$app->getVersion()}</info>");
$this->io->newLine();

$this->io->writeln('<comment>Usage</comment>');
Expand All @@ -25,8 +23,7 @@ protected function handle(): int

$this->io->newLine();

$this->io->writeln('<comment>Default options</comment>');
$this->io->writeln('Available for all commands');
$this->io->writeln('<comment>Default options</comment> Available for all commands');
$this->io->definitionList(
['-h, --help' => 'Display help for the given command'],
['-q, --quiet' => 'Do not output any message'],
Expand All @@ -38,13 +35,13 @@ protected function handle(): int

$this->io->writeln(' <comment>Proxy</comment>');
$this->io->definitionList(
['proxy:certs' => ' Install proxy local root certificate'],
['proxy:certs' => 'Install proxy local root certificate'],
['proxy:up' => 'Launch the proxy docker compose instance'],
['proxy:down' => 'Stop the proxy docker compose instance'],
['proxy:restart' => 'Restart the proxy container instance'],
['proxy:show' => 'Print the current Caddyfile configuration'],
['proxy:config' => 'Regenerate the proxy configuration file'],
['proxy:update' => ' Update the proxy deployment after a skipper upgrade'],
['proxy:update' => 'Update the proxy deployment after a skipper upgrade'],
);

$this->io->writeln(' <comment>Helpers</comment>');
Expand Down Expand Up @@ -78,8 +75,8 @@ protected function handle(): int
['restore' => 'Restore a MySQL backup'],
);

$this->io->writeln('Refer to https://github.com/tiknil/skipper for additional documentation');
$this->io->writeln('Use <info>skipper help [command]</info> or <info>skipper [command] --help</info> for details about a specific command');
$this->io->writeln('📖 Refer to <comment>https://github.com/tiknil/skipper</comment> for additional documentation');
$this->io->writeln('Use <info>skipper help [command]</info> or <info>skipper [command] --help</info> for details about a specific command');

return Command::SUCCESS;
}
Expand Down
9 changes: 7 additions & 2 deletions src/Commands/ProjectCmds/BackupCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,18 @@ protected function handle(): int
fclose($fileStream);

if ($dumpResult === Command::SUCCESS) {
$this->io->success("Backup $outputFile created successfully");
$this->io->writeln('✅ <info>Backup created successfully</info>');
$this->io->writeln("📦 $outputFile");
}

$uncompressedFile = rtrim($outputFile, '.gz');

$this->io->newLine();
$this->io->writeln(['You can uncompress it using']);
$this->io->writeln("<fg=green>gunzip < $outputFile > $uncompressedFile</>");
$this->io->writeln("<comment>gunzip < $outputFile > $uncompressedFile</comment>");

$this->io->newLine();
$this->io->writeln("Use <info>skipper restore --file $outputFile</info> to restore");

return $dumpResult;

Expand Down
4 changes: 2 additions & 2 deletions src/Commands/ProjectCmds/DockCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected function handle(): int
$result = Execute::onShell($cmd);

if ($result === Command::SUCCESS) {
$this->io->writeln('Use command <info>caddy stop</info> to stop the reverse proxy');
$this->io->writeln('Use command <info>shutdown</info> to stop all running projects and the reverse proxy');
$this->io->writeln('⏹️ Use command <info>skipper caddy stop</info> to stop the reverse proxy');
$this->io->writeln('🔌 Use command <info>skipper shutdown</info> to stop all running projects and the reverse proxy');
}

return $result;
Expand Down
9 changes: 5 additions & 4 deletions src/Commands/ProjectCmds/RestoreCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ protected function handle(): int
mkdir(dirname($file), 0777, true);
}

$this->io->warning('Restoring the DB is a risky operation. You may lose your data');
$this->io->text('Input file: '.$file);
$this->io->writeln('<comment>⚠️ Restoring the DB is a risky operation. You may lose your data ⚠️</comment>');
$this->io->newLine();
$this->io->writeln("Input file: <comment>$file</comment>");

$confirm = $this->io->confirm('Proceed anyway?');

Expand Down Expand Up @@ -144,15 +145,15 @@ protected function handle(): int
$sqlStream->close();

$result = $process->wait();
} catch (Exception $e) {
} catch (\Exception $e) {
$this->io->error($e->getMessage());

$gunResult = Command::FAILURE;
$result = Command::FAILURE;
}

if ($gunResult === Command::SUCCESS && $result === Command::SUCCESS) {
$this->io->success("Backup $file restored successfully");
$this->io->success("Backup $file restored successfully");
} else {
$this->io->error('An error occurred');

Expand Down
5 changes: 0 additions & 5 deletions src/Commands/ProjectCmds/RmCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ class RmCmd extends BaseCommand
{
use WithProject;

protected function prepare()
{
$this->io->infoText('Removing the skipper project');
}

protected function handle(): int
{
Execute::onShell($this->project->composeCommand('down'));
Expand Down
7 changes: 5 additions & 2 deletions src/Commands/ProjectCmds/SailCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected function handle(): int
...$this->project->definitionList()
);

$this->io->writeln('<comment>Performing docker compose validity checks</comment>');
$result = $this->checkComposeFile();

if (!$result) {
Expand All @@ -45,6 +46,8 @@ protected function handle(): int
if (!$confirm) {
return Command::SUCCESS;
}
} else {
$this->io->newLine();
}

$shouldBuild = $this->input->getOption('build');
Expand All @@ -67,15 +70,15 @@ protected function handle(): int

if (!HostFile::for($this->project->host)->check()) {
$this->io->writeln([
"Host {$this->project->host} is not registered inside your /etc/hosts file.",
"Host {$this->project->host} is not registered inside your /etc/hosts file.",
"Use command <info>skipper host {$this->project->host}</info>",
]);

$this->io->newLine();
}

$this->io->writeln([
"<comment>{$this->project->name}</comment> is up and running at <info>https://{$this->project->host}</info>",
"🚀 <comment>{$this->project->name}</comment> is up and running at <info>https://{$this->project->host}</info> 🚀",
]);

return Command::SUCCESS;
Expand Down
10 changes: 10 additions & 0 deletions src/Commands/ProjectCmds/SyncCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ class SyncCmd extends BaseCommand

protected function handle(): int
{
$this->io->writeln('<fg=bright-blue>Install composer dependencies</>');
Execute::onShell($this->project->composeCommand([
'exec',
$this->project->phpContainer,
'composer',
'install',
]));

$this->io->writeln('-------------------');
$this->io->writeln('<fg=bright-blue>Migrate database</>');

Execute::onShell($this->project->composeCommand([
'exec',
$this->project->phpContainer,
Expand All @@ -32,8 +36,14 @@ protected function handle(): int

Execute::hideOutput(['cd', $this->project->path], false);

$this->io->writeln('-------------------');
$this->io->writeln('<fg=bright-blue>Install js dependencies</>');

Execute::onShell(['yarn', 'install']);

$this->io->writeln('-------------------');
$this->io->writeln('<fg=bright-blue>Build frontend files</>');

Execute::onShell(['yarn', 'build']);

return Command::SUCCESS;
Expand Down
12 changes: 7 additions & 5 deletions src/Commands/ProxyCmd/CertsCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ protected function handle(): int
{
$caddy = $this->configRepo->caddy;

$this->io->writeln('The proxy (Caddy) creates a local root certificate to sign its https certificates');
$this->io->writeln('📝 The proxy (Caddy) creates a local root certificate to sign its https certificates');
$this->io->writeln("The OS normally doesn't trust this root certificate, but we can install it on our system");

$this->io->newLine();

$uid = posix_getuid();

$this->io->writeln('Looking for root certificate in <info>'.$caddy->certPath().'</info>');
$this->io->writeln('🧐 Looking for root certificate in <info>'.$caddy->certPath().'</info>');

if (!file_exists($caddy->certPath())) {
$this->io->note([
Expand All @@ -35,7 +37,7 @@ protected function handle(): int

$cmd = [];

$this->io->writeln('<info>Mac OS X will prompt for your Touch ID or password</info>');
$this->io->writeln('🔐 <info>Mac OS X will prompt for your Touch ID or password</info>');

if ($uid !== 0) {
$cmd[] = 'sudo';
Expand All @@ -51,10 +53,10 @@ protected function handle(): int
$result = Execute::onShell($cmd);

if ($result === Command::SUCCESS) {
$this->io->success('Cert installed correctly');
$this->io->success('Cert installed correctly');

$this->io->writeln([
'The browser may need some time to refresh its cache and recognize the certificate as valid',
'The browser may need some time to refresh its cache and recognize the certificate as valid',
]);
}

Expand Down
6 changes: 3 additions & 3 deletions src/Commands/ProxyCmd/ConfigCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ protected function handle(): int

$caddy->writeCaddyfile($this->configRepo->config);

$this->io->success('Configuration updated');
$this->io->success('Configuration updated');

$this->io->writeln('Use <info>skipper proxy:show</info> to see the updated file');
$this->io->writeln('Use <info>skipper proxy:restart</info> to see the new configuration in action');
$this->io->writeln('📄 Use <info>skipper proxy:show</info> to see the updated file');
$this->io->writeln('▶️ Use <info>skipper proxy:restart</info> to see the new configuration in action');

return Command::SUCCESS;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/ProxyCmd/DownCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class DownCmd extends BaseCommand
protected function handle(): int
{

$this->io->info(['If you have at least one project running, docker will not be able to dismiss the skipper network']);
$this->io->writeln(['❕ <info>If you have at least one project running, docker will not be able to dismiss the skipper network</info>']);
$this->io->newLine();

$caddy = $this->configRepo->caddy;

return $caddy->stop();
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ProxyCmd/ShowCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ protected function handle(): int
{
$caddy = $this->configRepo->caddy;

return Execute::onOutput(['cat', $caddy->caddyfilePath()]);
return Execute::onShell(['less', $caddy->caddyfilePath()]);
}
}
6 changes: 4 additions & 2 deletions src/Commands/ShutdownCmd.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ protected function handle(): int

foreach ($this->configRepo->config->projects as $project) {
if (!$project->isRunning()) {
$this->io->writeln("<fg=gray>Skipping <info>{$project->name}</info>, not currently running</>");
$this->io->writeln("<fg=gray>⏭️ Skipping <info>{$project->name}</info>, not currently running</>");

continue;
}

$this->io->writeln("<fg=gray>Stopping <info>{$project->name}</info></>");
$this->io->writeln("<fg=gray>⏹️ Stopping <info>{$project->name}</info></>");

Execute::onShell($project->composeCommand('down'));
}

$this->io->newLine();
$this->io->writeln('<fg=gray>⏹️ Stopping the reverse proxy</>');
$this->configRepo->caddy->stop();

return Command::SUCCESS;
Expand Down
Loading

0 comments on commit 6294854

Please sign in to comment.