/** * Execute the console command. * * @return mixed */ public function handle() { $deployments = $this->fetchDeployments(); $deploymentName = $this->argument('deployment'); $time = time(); $this->info("Started at " . date('[Y-m-d H:i:s]')); $this->info("Config file is " . $this->argument('config')); $logger = new OutputLogger($this->output); foreach ($deployments as $section => $config) { if ($deploymentName != null && $deploymentName != $section) { continue; } $this->info("Getting the status of {$section}"); try { $server = new HttpServer($logger); $server->initialize($config); $data = $server->status(); $this->info("Current version: " . $data['currentVersion']); $this->info("Old versions: " . implode(', ', $data['oldVersions'])); } catch (ServerException $e) { $this->error("Server error: " . $e->getMessage()); } } $time = time() - $time; $this->info("Finished at " . date('[Y-m-d H:i:s]') . " (in {$time} seconds)"); }
public function testStatus() { $body = m::mock(\Psr\Http\Message\StreamInterface::class); $body->shouldReceive('getContents')->once()->andReturn('{"success": "Rolled back"}'); $response = m::mock(\Psr\Http\Message\ResponseInterface::class); $response->shouldReceive('getBody')->once()->andReturn($body); $client = m::mock(\GuzzleHttp\Client::class); $client->shouldReceive('request')->with(m::mustBe('POST'), m::mustBe($this->config['remote_endpoint'] . '?cmd=status'), new PayloadMatcher(['headers', 'form_params']))->once()->andReturn($response); $this->httpServer->setClient($client); $this->httpServer->status(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $deployments = $this->fetchDeployments(); $deploymentName = $this->argument('deployment'); $packageOnly = $this->option('package-only'); $time = time(); $this->info("Started at " . date('[Y-m-d H:i:s]')); $this->info("Config file is " . $this->argument('config')); $logger = new OutputLogger($this->output); foreach ($deployments as $section => $config) { if ($deploymentName != null && $deploymentName != $section) { continue; } $this->info("Deploying {$section}"); try { $server = new HttpServer($logger); $server->initialize($config); $deployer = new LaravelHttpDeployer($server, $config->get('local.path', '.'), $logger); $deployer->ignoreMasks = $config->get('ignore', []); $deployer->extraFiles = $config->get('extra_files', []); $deployer->tempDir = $config->get('local.temp_dir', '/tmp'); $deployer->versionFileName = $config->get('version_filename', 'version'); $deployer->beforeScripts = $config->get('before_scripts', []); $deployer->packageName = $section; if ($packageOnly) { $packagePath = $deployer->packageOnly(); $this->info("Package created at '{$packagePath}'."); } else { $response = $deployer->deploy(); $this->info($response['success']); } } catch (ServerException $e) { $this->error("Server error: " . $e->getMessage()); } catch (HttpDeployerException $e) { $this->error("Deployer error: " . $e->getMessage()); } } $time = time() - $time; $this->info("Finished at " . date('[Y-m-d H:i:s]') . " (in {$time} seconds)"); }
/** * Execute the console command. * * @return mixed */ public function handle() { $deployments = $this->fetchDeployments(); $deploymentName = $this->argument('deployment'); $this->onStartCommand(); foreach ($deployments as $section => $config) { if ($deploymentName != null && $deploymentName != $section) { continue; } $this->info("Getting the status of {$section}"); try { $server = new HttpServer($this->getLogger()); $server->initialize($config); $data = $server->status(); $this->info("Current version: " . $data['currentVersion']); $this->info("Old versions: " . implode(', ', $data['oldVersions'])); } catch (ServerException $e) { $this->error("Server error: " . $e->getMessage()); } } $this->onEndCommand(); }
/** * Execute the console command. * * @return mixed */ public function handle() { $deployments = $this->fetchDeployments(); $version = $this->argument('version'); $deploymentName = $this->argument('deployment'); $this->onStartCommand(); foreach ($deployments as $section => $config) { if ($deploymentName != null && $deploymentName != $section) { continue; } $this->info("Rolling back {$section}"); try { $server = new HttpServer($this->getLogger()); $server->initialize($config); $response = $server->rollback($version); $this->info($response['success']); } catch (ServerException $e) { $this->error("Server error: " . $e->getMessage()); } } $this->onEndCommand(); }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ protected function setUp() { $logger = new \Mayconbordin\LaravelHttpDeployer\Loggers\ConsoleLogger(); $this->httpServer = new HttpServer($logger); $this->httpServer->initialize(new \Illuminate\Config\Repository($this->config)); }