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

Commit

Permalink
Fixed a bug in the install command.
Browse files Browse the repository at this point in the history
  • Loading branch information
warrickbayman committed Apr 29, 2020
1 parent a693bcc commit 1c9c2e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
16 changes: 4 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
# Changelog

## [Unreleased]
* The `Deployer::DeploymentTask` method has been renamed `Deployer::deploymentTask`.
* The `InstallCommand` constructor will now accept an instance of `Deployer`.
* The env steps and installation steps have been swapped around in `Deployer::deploymentTask`.
* A `Deployer::generateKeySteps` has been added. Will run `artisan key:generate` after the symlink steps.
* The `Initializer::discoverGitRemotes()` method will no longer be called from the constructor.
* A new `Initializer::loadGitConfig()` method will be called only if a config filename is passed to the constructor.
* The `Initializer::discoverGitRemotes()` method is now public.
* Took the SSH task execution out of the `ReleaseServer::fetch()` method and moved it to a protected `getReleaseData` method.
* The `Task` parameter on the `Ssh` constructor is now optional.
* A new `Ssh::setTask` method can be used to set a task on the `Ssh` instance.
* `Ssh::run` will now throw an exception if the task instance doesn't have a server, or if a task instance isn't set.
## [0.4.11] 29-04-2020
### Fixed
* Fixed a bug in the `InstallCommand` that was erroring out when no intallation was found.
* The `install` command will now perform its own check.

## [0.4.10] 28-04-2020
### Changed
Expand Down
2 changes: 1 addition & 1 deletion bin/attache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) {
require __DIR__.'/../../../autoload.php';
}

$app = new \Symfony\Component\Console\Application('Attaché', '0.4.10');
$app = new \Symfony\Component\Console\Application('Attaché', '0.4.11');

$app->add(new \TPG\Attache\Console\InitCommand());
$app->add(new \TPG\Attache\Console\ServersListCommand());
Expand Down
4 changes: 2 additions & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ protected function configure(): void
*/
protected function fire(): int
{
$releases = (new ReleaseService($this->server))->fetch();
$service = new ReleaseService($this->server);

if (count($releases->list()) > 0) {
if ($service->hasInstallation()) {
$this->output->writeln(
'<error>There is already an installation on '
.$this->server->name()
Expand Down
12 changes: 10 additions & 2 deletions src/ReleaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function fetch(): self
{
$outputs = $this->getReleaseData();

$this->validateOutput($outputs);

$this->releases = $this->getReleasesFromOutput(Arr::get($outputs, 0, ''));
if (count($this->releases)) {
$this->active = $this->getActiveFromOutput(Arr::get($outputs, 1, ''));
Expand All @@ -49,6 +51,14 @@ public function fetch(): self
return $this;
}

public function hasInstallation(): bool
{
$outputs = $this->getReleaseData();
$releases = $this->getReleasesFromOutput($outputs[0]);

return count($releases) > 0;
}

/**
* Get release data from the server by running a simple `ls` command.
*
Expand All @@ -65,8 +75,6 @@ protected function getReleaseData(): array
$outputs[] = $output;
});

$this->validateOutput($outputs);

return $outputs;
}

Expand Down

0 comments on commit 1c9c2e9

Please sign in to comment.