| @@ 14-81 (lines=68) @@ | ||
| 11 | * |
|
| 12 | * @author Mahmoud Zalt <[email protected]> |
|
| 13 | */ |
|
| 14 | class CloneContainersCommand extends ConsoleCommand |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The name and signature of the console command. |
|
| 19 | * |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | protected $signature = "containers:add {repository-names*}"; // {--skip-update=false} |
|
| 23 | ||
| 24 | /** |
|
| 25 | * The console command description. |
|
| 26 | * |
|
| 27 | * @var string |
|
| 28 | */ |
|
| 29 | protected $description = "select existing container to download"; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Create a new command instance. |
|
| 33 | * |
|
| 34 | * @return void |
|
| 35 | */ |
|
| 36 | public function __construct() |
|
| 37 | { |
|
| 38 | parent::__construct(); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Execute the console command. |
|
| 43 | * |
|
| 44 | * @return mixed |
|
| 45 | */ |
|
| 46 | public function handle() |
|
| 47 | { |
|
| 48 | $ContainersPath = "app/Containers"; |
|
| 49 | ||
| 50 | foreach ($this->argument("repository-names") as $repoName) { |
|
| 51 | $repoName = ucfirst(strtolower($repoName)); |
|
| 52 | ||
| 53 | // TODO: find a way to validate the repo! |
|
| 54 | $process = new Process("git clone --depth 1 [email protected]:Porto-SAP/" . $repoName . ".git " . $ContainersPath . "/" . $repoName); |
|
| 55 | $process->run(); |
|
| 56 | ||
| 57 | if (!$process->isSuccessful()) { |
|
| 58 | throw new ProcessFailedException($process); |
|
| 59 | } |
|
| 60 | ||
| 61 | echo "Downloading " . $repoName . " completed successfully.\n"; |
|
| 62 | } |
|
| 63 | ||
| 64 | // TODO: add skip update option |
|
| 65 | ||
| 66 | // if (!$this->option('skip-update')) { |
|
| 67 | ||
| 68 | echo "Running 'Composer Update'..\n"; |
|
| 69 | $process = new Process("composer update"); |
|
| 70 | $process->run(); |
|
| 71 | ||
| 72 | if (!$process->isSuccessful()) { |
|
| 73 | throw new ProcessFailedException($process); |
|
| 74 | } |
|
| 75 | ||
| 76 | echo $process->getOutput(); |
|
| 77 | // } |
|
| 78 | ||
| 79 | echo "Congratulation :)\n"; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| @@ 14-81 (lines=68) @@ | ||
| 11 | * |
|
| 12 | * @author Mahmoud Zalt <[email protected]> |
|
| 13 | */ |
|
| 14 | class DeleteContainersCommand extends ConsoleCommand |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The name and signature of the console command. |
|
| 19 | * |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | protected $signature = "containers:remove {container-names*}"; // {--skip-update=false} |
|
| 23 | ||
| 24 | /** |
|
| 25 | * The console command description. |
|
| 26 | * |
|
| 27 | * @var string |
|
| 28 | */ |
|
| 29 | protected $description = "select existing container to download"; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * Create a new command instance. |
|
| 33 | * |
|
| 34 | * @return void |
|
| 35 | */ |
|
| 36 | public function __construct() |
|
| 37 | { |
|
| 38 | parent::__construct(); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Execute the console command. |
|
| 43 | * |
|
| 44 | * @return mixed |
|
| 45 | */ |
|
| 46 | public function handle() |
|
| 47 | { |
|
| 48 | $ContainersPath = "app/Containers"; |
|
| 49 | ||
| 50 | foreach ($this->argument("container-names") as $repoName) { |
|
| 51 | $repoName = ucfirst(strtolower($repoName)); |
|
| 52 | ||
| 53 | // TODO: find a way to validate the repo! |
|
| 54 | $process = new Process("rm -rf " . $ContainersPath . '/' .$repoName); |
|
| 55 | $process->run(); |
|
| 56 | ||
| 57 | if (!$process->isSuccessful()) { |
|
| 58 | throw new ProcessFailedException($process); |
|
| 59 | } |
|
| 60 | ||
| 61 | echo "Container " . $repoName . " deleted successfully.\n"; |
|
| 62 | } |
|
| 63 | ||
| 64 | // TODO: add skip update option |
|
| 65 | ||
| 66 | // if (!$this->option('skip-update')) { |
|
| 67 | ||
| 68 | echo "Running 'Composer Update'..\n"; |
|
| 69 | $process = new Process("composer update"); |
|
| 70 | $process->run(); |
|
| 71 | ||
| 72 | if (!$process->isSuccessful()) { |
|
| 73 | throw new ProcessFailedException($process); |
|
| 74 | } |
|
| 75 | ||
| 76 | echo $process->getOutput(); |
|
| 77 | // } |
|
| 78 | ||
| 79 | echo "Congratulation :)\n"; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||