Skip to content

Commit

Permalink
Diff out defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 12, 2024
1 parent b94145f commit 53a989f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions monorepo/DevTools/src/RefactorConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use function is_array;
use function is_string;
use function file_exists;
use function array_udiff;
use function str_starts_with;
use function file_put_contents;

Expand Down Expand Up @@ -72,12 +73,16 @@ protected function migrateToYaml(): void

try {
$config = config('hyde');

$default = require Hyde::vendorPath('config/hyde.php');

// Todo: Add argument to not diff out defaults
$config = array_udiff($config, $default, fn ($a, $b) => $a === $b ? 0 : 1);

$config = $this->serializePhpData($config);

$yaml = Yaml::dump($config, 16, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK | Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);

// Todo: Diff out defaults? (unless with argument)

file_put_contents(Hyde::path('hyde.yml'), $yaml);
} catch (Throwable $exception) {
$this->error('Failed to migrate configuration: '.$exception->getMessage());
Expand Down

0 comments on commit 53a989f

Please sign in to comment.