Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RamonSmit committed Jul 18, 2017
2 parents bab2bb0 + ffc9cd0 commit 3cfd452
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/Helpers/SSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function instance()
*/
public static function home($stage)
{
return config('laravel-deploy-helper.stages.' . $stage . '.remote.root');
return config('laravel-deploy-helper.stages.'.$stage.'.remote.root');
}

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ public static function checkAppVersion(Connection $connection, $app, $requestedV
if ($requestedVersion === true) {
$connection->run(Command::builder($app, []), function ($response) use ($app) {
if (stripos($response, 'command not found') !== false) {
throw new \Exception('ERROR: ' . $app . ' is not installed on the server.');
throw new \Exception('ERROR: '.$app.' is not installed on the server.');
}
});
verbose("\t => Checking $app is available");
Expand All @@ -99,7 +99,7 @@ public static function checkAppVersion(Connection $connection, $app, $requestedV
*/
$connection->run(Command::builder($app, []), function ($response) use ($app) {
if (stripos($response, 'command not found') !== false) {
throw new \Exception('ERROR: ' . $app . ' is not installed on the server.');
throw new \Exception('ERROR: '.$app.' is not installed on the server.');
}
});

Expand Down Expand Up @@ -140,9 +140,9 @@ public static function preFlight($instance, $stage, $branch = false)
if ($stage === null) {
throw new \Exception('The argument "--stage=" is required!', 128);
} else {
if (!is_array(config('laravel-deploy-helper.stages.' . $stage))) {
throw new \Exception('The stage "' . $stage
. '" does not exist!', 128);
if (!is_array(config('laravel-deploy-helper.stages.'.$stage))) {
throw new \Exception('The stage "'.$stage
.'" does not exist!', 128);
}
}

Expand All @@ -152,13 +152,13 @@ public static function preFlight($instance, $stage, $branch = false)
}

if (in_array($branch, Git::getBranches()) == false) {
throw new \Exception('The branch "' . $branch
. '" does not exists locally? Please `git pull`!', 128);
throw new \Exception('The branch "'.$branch
.'" does not exists locally? Please `git pull`!', 128);
}
}

// Connecting to remote server
verbose('[' . $stage . '] Trying to login into remote SSH');
verbose('['.$stage.'] Trying to login into remote SSH');
$ssh = self::instance()->into($stage);

// Check for lockfile
Expand All @@ -168,22 +168,22 @@ public static function preFlight($instance, $stage, $branch = false)
}

// Trying to read file
verbose('[' . $stage . '] Reading config file from remote server');
$config = $ssh->exists(self::home($stage) . '/ldh.json');
verbose('['.$stage.'] Reading config file from remote server');
$config = $ssh->exists(self::home($stage).'/ldh.json');

// Check if config exists
if ($config == false) {
error('[' . $stage . '] ldh.json does not exists.');
error('['.$stage.'] ldh.json does not exists.');
if ($instance->confirm('Do you want to initialize LDH here?')) {
Deployer::freshInit($ssh, $stage);
} else {
return false;
}
} else {
verbose('[' . $stage . '] Found config. Checking directories.');
$config = $ssh->getString(self::home($stage) . '/ldh.json');
verbose('['.$stage.'] Found config. Checking directories.');
$config = $ssh->getString(self::home($stage).'/ldh.json');
if ($config == false) {
error('[' . $stage . '] Config file is empty... Something is wrong.');
error('['.$stage.'] Config file is empty... Something is wrong.');

return false;
}
Expand All @@ -201,6 +201,6 @@ public static function performLanding($stage)
{
$ssh = self::instance()->into($stage);
Locker::unlock($ssh, $stage);
verbose('[' . $stage . '] Changes are successfull!');
verbose('['.$stage.'] Changes are successfull!');
}
}
4 changes: 2 additions & 2 deletions src/Helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function verbose($message)
{
$console = new ConsoleOutput();
$console->getFormatter()->setStyle('info', new OutputFormatterStyle('blue', null));
$console->writeln('<info>' . $message . '</info>');
$console->writeln('<info>'.$message.'</info>');
}
}

Expand All @@ -31,7 +31,7 @@ function error($message)
{
$console = new ConsoleOutput();
$console->getFormatter()->setStyle('error', new OutputFormatterStyle('white', 'red'));
$console->writeln('<error>' . $message . '</error>');
$console->writeln('<error>'.$message.'</error>');
}
}

Expand Down

0 comments on commit 3cfd452

Please sign in to comment.