From 1254dbe0d8c13c39b87cf15e723f5a5a30e47d33 Mon Sep 17 00:00:00 2001 From: JesusValera Date: Sat, 4 Oct 2025 19:05:47 +0200 Subject: [PATCH 1/2] Create script to read current Phel version --- build/update-phel-version.php | 61 +++++++++++++++++++++++++++++++++++ composer.json | 8 ++++- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 build/update-phel-version.php diff --git a/build/update-phel-version.php b/build/update-phel-version.php new file mode 100644 index 0000000..47457ec --- /dev/null +++ b/build/update-phel-version.php @@ -0,0 +1,61 @@ + Date: Mon, 6 Oct 2025 18:35:01 +0200 Subject: [PATCH 2/2] Refactor update-phel-version script to use Gacela --- .../php/VersionUpdater/DependencyProvider.php | 25 ++++++++ build/src/php/VersionUpdater/Facade.php | 20 ++++++ build/src/php/VersionUpdater/Factory.php | 34 ++++++++++ .../Infrastructure/PhelVersionUpdater.php | 34 ++++++++++ .../Integration/PhelVersionUpdaterTest.php | 57 +++++++++++++++++ build/update-phel-version.php | 63 +++---------------- config.toml | 2 +- templates/footer.html | 2 +- 8 files changed, 180 insertions(+), 57 deletions(-) create mode 100644 build/src/php/VersionUpdater/DependencyProvider.php create mode 100644 build/src/php/VersionUpdater/Facade.php create mode 100644 build/src/php/VersionUpdater/Factory.php create mode 100644 build/src/php/VersionUpdater/Infrastructure/PhelVersionUpdater.php create mode 100644 build/tests/php/VersionUpdater/Integration/PhelVersionUpdaterTest.php diff --git a/build/src/php/VersionUpdater/DependencyProvider.php b/build/src/php/VersionUpdater/DependencyProvider.php new file mode 100644 index 0000000..8bcb253 --- /dev/null +++ b/build/src/php/VersionUpdater/DependencyProvider.php @@ -0,0 +1,25 @@ +set(self::FACADE_PHEL_CONSOLE, function (Container $container) { + return $container->getLocator()->get(ConsoleFacade::class); + }); + } +} diff --git a/build/src/php/VersionUpdater/Facade.php b/build/src/php/VersionUpdater/Facade.php new file mode 100644 index 0000000..e28a9b0 --- /dev/null +++ b/build/src/php/VersionUpdater/Facade.php @@ -0,0 +1,20 @@ +getFactory() + ->createPhelVersionUpdater() + ->update(); + } +} diff --git a/build/src/php/VersionUpdater/Factory.php b/build/src/php/VersionUpdater/Factory.php new file mode 100644 index 0000000..905d245 --- /dev/null +++ b/build/src/php/VersionUpdater/Factory.php @@ -0,0 +1,34 @@ +getPhelConsoleFacade(), + $this->getConfigFileLocation(), + ); + } + + private function getPhelConsoleFacade(): ConsoleFacadeInterface + { + return $this->getProvidedDependency(DependencyProvider::FACADE_PHEL_CONSOLE); + } + + private function getConfigFileLocation(): string + { + return $this->getConfig()->getAppRootDir() . '/../config.toml'; + } +} diff --git a/build/src/php/VersionUpdater/Infrastructure/PhelVersionUpdater.php b/build/src/php/VersionUpdater/Infrastructure/PhelVersionUpdater.php new file mode 100644 index 0000000..c5721b3 --- /dev/null +++ b/build/src/php/VersionUpdater/Infrastructure/PhelVersionUpdater.php @@ -0,0 +1,34 @@ +configFile); + + $phelVersion = $this->consoleFacade->getVersion(); + $updatedContent = preg_replace( + self::REGEX_PHEL_VERSION_FINDER, + 'phel_version = "' . $phelVersion . '"', + $configContent + ); + + if ($updatedContent !== $configContent) { + file_put_contents($this->configFile, $updatedContent); + } + } +} diff --git a/build/tests/php/VersionUpdater/Integration/PhelVersionUpdaterTest.php b/build/tests/php/VersionUpdater/Integration/PhelVersionUpdaterTest.php new file mode 100644 index 0000000..985a101 --- /dev/null +++ b/build/tests/php/VersionUpdater/Integration/PhelVersionUpdaterTest.php @@ -0,0 +1,57 @@ +file = tmpfile(); + fwrite($this->file, 'phel_version = "v.0.9"'); + } + + protected function tearDown(): void + { + fclose($this->file); + } + + public function test_update_phel_version(): void + { + $consoleFacade = $this->createAnonConsoleFacade(); + + $path = stream_get_meta_data($this->file)['uri']; + $phelVersionUpdater = new PhelVersionUpdater($consoleFacade, $path); + $phelVersionUpdater->update(); + + $content = file_get_contents($path); + + $expected = 'phel_version = "v1.0"'; + + self::assertSame($expected, $content); + } + + private function createAnonConsoleFacade(): ConsoleFacadeInterface + { + return new class implements ConsoleFacadeInterface { + + public function getVersion(): string + { + return 'v1.0'; + } + + public function runConsole(): void + { + // ignore + } + }; + } +} diff --git a/build/update-phel-version.php b/build/update-phel-version.php index 47457ec..39c4c50 100644 --- a/build/update-phel-version.php +++ b/build/update-phel-version.php @@ -1,61 +1,14 @@ updateTomlFile(); diff --git a/config.toml b/config.toml index bbff8d2..1aa9504 100644 --- a/config.toml +++ b/config.toml @@ -28,5 +28,5 @@ extra_syntaxes_and_themes = ["syntaxes"] # Put all your custom variables here repo_content_url = "https://github.com/phel-lang/phel-lang.org/blob/master/content/" -phel_version = "0.23.1" +phel_version = "v0.23.1" diff --git a/templates/footer.html b/templates/footer.html index 998528f..a40d962 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -52,7 +52,7 @@

Community