From c5e4b41100f7fa6c7fdba6c2778e364169bb89b0 Mon Sep 17 00:00:00 2001 From: Jonathan Miller <1+jmiller@noreply.git.mokoconsulting.tech> Date: Tue, 26 May 2026 19:26:45 +0000 Subject: [PATCH] feat: version_read.php uses .mokogitea/manifest.xml as canonical version source Authored-by: Moko Consulting --- cli/version_read.php | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/cli/version_read.php b/cli/version_read.php index 2746755..78f24c5 100644 --- a/cli/version_read.php +++ b/cli/version_read.php @@ -9,7 +9,7 @@ * INGROUP: moko-platform * REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform * PATH: /cli/version_read.php - * BRIEF: Read version from README.md or manifest XML — outputs the higher of the two + * BRIEF: Read version — manifest.xml is canonical, falls back to README.md and Joomla XML */ declare(strict_types=1); @@ -23,7 +23,26 @@ foreach ($argv as $i => $arg) { $root = realpath($path) ?: $path; -// ── Read from README.md ────────────────────────────────────────────────────── +// -- 1. Read from .mokogitea/manifest.xml (canonical source) -- +$mokoVersion = null; +$mokoManifest = "{$root}/.mokogitea/manifest.xml"; +if (file_exists($mokoManifest)) { + $xml = @simplexml_load_file($mokoManifest); + if ($xml !== false) { + $v = (string)($xml->identity->version ?? ''); + if (preg_match('/^\d{2}\.\d{2}\.\d{2}$/', $v)) { + $mokoVersion = $v; + } + } +} + +// If manifest.xml has a version, that is authoritative +if ($mokoVersion !== null) { + echo $mokoVersion . "\n"; + exit(0); +} + +// -- 2. Fallback: README.md -- $readmeVersion = null; $readme = "{$root}/README.md"; if (file_exists($readme)) { @@ -33,7 +52,7 @@ if (file_exists($readme)) { } } -// ── Read from Joomla manifest XML ──────────────────────────────────────────── +// -- 3. Fallback: Joomla manifest XML -- $manifestVersion = null; $manifestFiles = array_merge( glob("{$root}/src/pkg_*.xml") ?: [], @@ -55,7 +74,7 @@ foreach ($manifestFiles as $xmlFile) { } } -// ── Output the higher version ──────────────────────────────────────────────── +// -- Output the higher version -- $version = null; if ($readmeVersion !== null && $manifestVersion !== null) { $version = version_compare($manifestVersion, $readmeVersion, '>') ? $manifestVersion : $readmeVersion; @@ -66,7 +85,7 @@ if ($readmeVersion !== null && $manifestVersion !== null) { } if ($version === null) { - fwrite(STDERR, "No version found in README.md or manifest XML\n"); + fwrite(STDERR, "No version found in manifest.xml, README.md, or Joomla XML\n"); exit(1); }