From 53a989fd8187d9efbac87d0f016ec84e98248b56 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 12 Jul 2024 11:54:59 +0200 Subject: [PATCH] Diff out defaults --- monorepo/DevTools/src/RefactorConfigCommand.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/monorepo/DevTools/src/RefactorConfigCommand.php b/monorepo/DevTools/src/RefactorConfigCommand.php index b83ab5345a7..44644297a8e 100644 --- a/monorepo/DevTools/src/RefactorConfigCommand.php +++ b/monorepo/DevTools/src/RefactorConfigCommand.php @@ -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; @@ -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());