Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Framework update #8

Merged
merged 2 commits into from Apr 19, 2020
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/vendor
.phpunit.result.cache
/.docker
/.idea
/.vscode
/.vagrant
/.docker
/.vscode
/vendor
containers
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 7.4

before_script:
- composer self-update
Expand Down
66 changes: 17 additions & 49 deletions app/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Compose;
use App\Satchel;
use App\Laradock;
use App\Support\Concerns\CommandResponsable;
use Illuminate\Support\Facades\Storage;
use App\Support\Artifacts\DockerComposeFile;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -14,6 +15,8 @@

abstract class Command extends BaseCommand
{
use CommandResponsable;

/**
* Laradock instance.
*
Expand Down Expand Up @@ -54,9 +57,9 @@ abstract class Command extends BaseCommand
/**
* Command constructor.
*
* @param Laradock $laradock
* @param Satchel $satchel
* @param Compose $compose
* @param Laradock $laradock
* @param Satchel $satchel
* @param Compose $compose
*/
public function __construct(Laradock $laradock, Satchel $satchel, Compose $compose)
{
Expand All @@ -71,8 +74,8 @@ public function __construct(Laradock $laradock, Satchel $satchel, Compose $compo
* Initializes the command after the input has been bound and before the input
* is validated.
*
* @param InputInterface $input
* @param OutputInterface $output
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
Expand All @@ -91,54 +94,19 @@ protected function initialize(InputInterface $input, OutputInterface $output)
/**
* Execute the console command.
*
* @return bool
* @return void
*/
public function handle()
{
try {
// Run the Command and if it's success full
// call the success method.
if ($this->fire()) {
return $this->sendSuccessResponse();
}

return $this->sendErrorResponse();
$this->fire() ?
$this->sendSuccessResponse($this->successMessage) :
$this->sendErrorResponse($this->errorMessage);
} catch (\Exception $e) {
$this->sendFailedResponse($e);
return false;
}
}

/**
* Show a sucess message and the exit the
* program.
*
* @return bool
*/
protected function sendSuccessResponse(): bool
{
$message = $this->successMessage ?? 'Command successfully ran!';

$this->info($message);

return true;
}

/**
* Show an error message and then exits the
* program.
*
* @return bool
*/
protected function sendErrorResponse(): bool
{
$message = $this->errorMessage ?? 'Command failed !';

$this->error($message);

return false;
}

/**
* Perform any validation before the command is run.
*
Expand Down Expand Up @@ -188,7 +156,7 @@ protected function shouldFetchLaradock(): bool
/**
* Validate that the service is available in Laradock folder.
*
* @param string $service
* @param string $service
*
* @throws \InvalidArgumentException
*/
Expand All @@ -203,7 +171,7 @@ protected function serviceIsAvailableInLaradock(string $service)
/**
* Validate that the service is available in Docker folder.
*
* @param string $service
* @param string $service
*
* @throws \InvalidArgumentException
*/
Expand All @@ -218,7 +186,7 @@ protected function serviceExistsInDockerFolder(string $service)
/**
* Validate that the service is not available in Docker folder.
*
* @param string $service
* @param string $service
*
* @throws \InvalidArgumentException
*/
Expand All @@ -233,7 +201,7 @@ protected function serviceShouldNotExistInDockerFolder(string $service)
/**
* Validate that the service is available in docker-compose.yml file.
*
* @param string $service
* @param string $service
*
* @throws \InvalidArgumentException|FileNotFoundException
*/
Expand All @@ -248,7 +216,7 @@ protected function serviceExistsInDockerComposeFile(string $service)
/**
* Output an error message.
*
* @param \Exception $e
* @param \Exception $e
*
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/GenerateCommandLineTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class GenerateCommandLineTools extends Command
/**
* Execute the console command.
*
* @return mixed
* @return void
*/
public function handle()
{
return Containers::make()->save() ?
Containers::make()->save() ?
$this->sendSuccessResponse('containers script generated!') :
$this->sendErrorResponse('Could generate containers script!');
}
Expand Down
13 changes: 7 additions & 6 deletions app/Laradock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ZipArchive;
use GuzzleHttp\Client;
use Illuminate\Support\Arr;
use Symfony\Component\Yaml\Yaml;
use Illuminate\Support\Collection;
use App\Support\Artifacts\EnvFile;
Expand Down Expand Up @@ -34,9 +35,9 @@ class Laradock
/**
* Laradock constructor.
*
* @param Client $gitHubClient
* @param string $laradockZip
* @param Satchel $satchel
* @param Client $gitHubClient
* @param string $laradockZip
* @param Satchel $satchel
*/
public function __construct(Client $gitHubClient, string $laradockZip, Satchel $satchel)
{
Expand Down Expand Up @@ -68,7 +69,7 @@ public function availableServices(): Collection
/**
* Checks if service is avalable in laradock.
*
* @param string $service
* @param string $service
*
* @return bool
*/
Expand Down Expand Up @@ -108,7 +109,7 @@ public function envData()
/**
* Get the full path of the service.
*
* @param string $service
* @param string $service
*
* @return string
*/
Expand Down Expand Up @@ -142,7 +143,7 @@ protected function unzip(): Laradock

// Rename extracted folder so we may access it later.
$this->satchel->move(
array_first($this->satchel->directories('laradock')),
Arr::first($this->satchel->directories('laradock')),
'laradock/data'
);
return $this;
Expand Down
2 changes: 1 addition & 1 deletion app/Support/Artifacts/AbstractArtifact.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abstract class AbstractArtifact implements Artifact
/**
* Create a new instance of the Artifact.
*
* @param array $args
* @param array $args
*
* @return Artifact
*/
Expand Down
18 changes: 7 additions & 11 deletions app/Support/Concerns/CommandResponsable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,30 @@
trait CommandResponsable
{
/**
* Show a sucess message and the exit the program.
* Show a success message and the exit the program.
*
* @param string $message
* @param string $message
*
* @return bool
* @return void
*/
protected function sendSuccessResponse(string $message = null): bool
protected function sendSuccessResponse(string $message = null): void
{
$message = $message ?? 'Command successfully ran!';

$this->info($message);

return true;
}

/**
* Show an error message and then exits the program.
*
* @param string $message
* @param string $message
*
* @return bool
* @return void
*/
protected function sendErrorResponse(string $message = null): bool
protected function sendErrorResponse(string $message = null): void
{
$message = $message ?? 'Command failed !';

$this->error($message);

return false;
}
}
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
}
],
"require": {
"php": "^7.1.3",
"php": "^7.2",
"ext-zip": "*",
"guzzlehttp/guzzle": "~6.0",
"laravel-zero/framework": "5.7.*",
"symfony/finder": "^4.2",
"symfony/yaml": "^4.2",
"zendframework/zend-text": "^2.7"
"laravel-zero/framework": "^7.0",
"symfony/finder": "^5.0",
"symfony/yaml": "^5.0",
"laminas/laminas-text": "^2.7"
},
"require-dev": {
"kint-php/kint": "^3.1",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.3"
"kint-php/kint": "^3.3",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
Expand Down
Loading