mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 16:54:08 +01:00
Add facts
This commit is contained in:
parent
54fe1eab26
commit
81ba8e3034
@ -7,7 +7,7 @@
|
||||
|
||||
namespace Deployer;
|
||||
|
||||
require __DIR__ . '/deploy/config.php';
|
||||
require __DIR__ . '/config/dump.php';
|
||||
require __DIR__ . '/deploy/prepare.php';
|
||||
require __DIR__ . '/deploy/lock.php';
|
||||
require __DIR__ . '/deploy/release.php';
|
||||
@ -21,9 +21,19 @@ require __DIR__ . '/deploy/cleanup.php';
|
||||
require __DIR__ . '/deploy/copy_dirs.php';
|
||||
require __DIR__ . '/deploy/rollback.php';
|
||||
|
||||
use Deployer\Task\Context;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
/**
|
||||
* Facts
|
||||
*/
|
||||
|
||||
set('hostname', function () {
|
||||
return Context::get()->getHost()->getHostname();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*/
|
||||
@ -111,6 +121,7 @@ set('bin/symlink', function () {
|
||||
return get('use_relative_symlink') ? 'ln -nfs --relative' : 'ln -nfs';
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Default arguments and options.
|
||||
*/
|
||||
|
@ -11,24 +11,24 @@ use Deployer\Task\Context;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
desc('Print server configuration');
|
||||
desc('Print host configuration');
|
||||
task('config:dump', function () {
|
||||
$server = Context::get()->getHost();
|
||||
$config = Deployer::get()->config;
|
||||
$env = Context::get()->getConfiguration();
|
||||
$host = Context::get()->getHost();
|
||||
$common = Deployer::get()->config;
|
||||
$config = Context::get()->getConfiguration();
|
||||
$dump = [];
|
||||
|
||||
foreach ($config as $name => $value) {
|
||||
foreach ($common as $name => $value) {
|
||||
try {
|
||||
$env->get($name);
|
||||
$config->get($name);
|
||||
} catch (\RuntimeException $exception) {
|
||||
// Ignore fails.
|
||||
$message = 'Failed to dump';
|
||||
$env->set($name, output()->isDecorated() ? "\033[1;30m$message\033[0m" : $message);
|
||||
$config->set($name, output()->isDecorated() ? "\033[1;30m$message\033[0m" : $message);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($env->getValues() as $name => $value) {
|
||||
foreach ($config->getValues() as $name => $value) {
|
||||
if (is_array($value)) {
|
||||
$value = json_encode($value, JSON_PRETTY_PRINT);
|
||||
} elseif (is_bool($value)) {
|
||||
@ -39,7 +39,7 @@ task('config:dump', function () {
|
||||
}
|
||||
|
||||
$io = new SymfonyStyle(input(), output());
|
||||
$io->section("[{$server->getConfiguration()->getName()}] {$server->getConfiguration()->getHost()}");
|
||||
$io->section("[{$host->getHostname()}]");
|
||||
|
||||
$table = new Table(output());
|
||||
$table
|
Loading…
x
Reference in New Issue
Block a user