Skip to content

Commit

Permalink
Remove validate config
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Sep 10, 2022
1 parent 88cb11a commit 9bd7b48
Showing 1 changed file with 0 additions and 41 deletions.
41 changes: 0 additions & 41 deletions src/Command/MainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ protected function execute(Input $input, Output $output): int

if (!$plan) {
$this->checkUpdates();
$this->validateConfig();
$this->deployer->server->start();

if (!empty($skippedTasks)) {
Expand Down Expand Up @@ -183,46 +182,6 @@ private function showBanner()
}
}

private function validateConfig(): void
{
if (!defined('DEPLOYER_DEPLOY_FILE')) {
return;
}
$validate = function (Configuration $configA, Configuration $configB): void {
$keysA = array_keys($configA->ownValues());
$keysB = array_keys($configB->ownValues());
for ($i = 0; $i < count($keysA); $i++) {
for ($j = $i + 1; $j < count($keysB); $j++) {
$a = $keysA[$i];
$b = $keysB[$j];
if (levenshtein($a, $b) == 1) {
$source = file_get_contents(DEPLOYER_DEPLOY_FILE);
$code = '';
foreach (find_config_line($source, $a) as list($n, $line)) {
$code .= " $n: " . str_replace($a, "<fg=red>$a</fg=red>", $line) . "\n";
}
foreach (find_config_line($source, $b) as list($n, $line)) {
$code .= " $n: " . str_replace($b, "<fg=red>$b</fg=red>", $line) . "\n";
}
if (!empty($code)) {
warning(<<<AAA
Did you mean "<fg=green>$a</fg=green>" or "<fg=green>$b</fg=green>"?</>
$code
AAA
);
}
}
}
}
};

$validate($this->deployer->config, $this->deployer->config);
foreach ($this->deployer->hosts as $host) {
$validate($host->config(), $this->deployer->config);
}
}

public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
parent::complete($input, $suggestions);
Expand Down

0 comments on commit 9bd7b48

Please sign in to comment.