From e15421699e3f241a4bc82d62e9efaf25c857f537 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 26 May 2026 15:03:52 -0500 Subject: [PATCH] feat: manifest.xml as canonical version source - version_bump.php: insert tag into manifest.xml if missing (placed before per schema order) - version_read.php: backfill into manifest.xml from fallback sources (README.md, Joomla XML) on first read - manifest-schema.xsd: add version="09.01.00" attribute to xs:schema - manifest.xml: add , xsi:schemaLocation pointing to schema on moko-platform main branch Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- .mokogitea/manifest.xml | 6 +++++- cli/version_bump.php | 34 +++++++++++++++++++++++++++------ cli/version_read.php | 24 +++++++++++++++++++++++ definitions/manifest-schema.xsd | 5 +++-- 4 files changed, 60 insertions(+), 9 deletions(-) diff --git a/.mokogitea/manifest.xml b/.mokogitea/manifest.xml index 21b9bd1..4a2beb4 100644 --- a/.mokogitea/manifest.xml +++ b/.mokogitea/manifest.xml @@ -4,11 +4,15 @@ Auto-generated by cleanup script. See: https://git.mokoconsulting.tech/MokoConsulting/moko-platform/wiki/Home --> - + moko-platform MokoConsulting Enterprise automation, validation, sync, and governance engine for all Moko Consulting repositories + 09.01.00 GNU General Public License v3 diff --git a/cli/version_bump.php b/cli/version_bump.php index e9f1fff..661df0c 100644 --- a/cli/version_bump.php +++ b/cli/version_bump.php @@ -128,12 +128,34 @@ $new = sprintf('%02d.%02d.%02d', $major, $minor, $patch); // -- Update .mokogitea/manifest.xml (canonical target) -- if (file_exists($mokoManifest) && !empty($mokoContent)) { - $updated = preg_replace( - '|\d{2}\.\d{2}\.\d{2}|', - "{$new}", - $mokoContent, - 1 - ); + if (preg_match('|\d{2}\.\d{2}\.\d{2}|', $mokoContent)) { + // Replace existing version tag + $updated = preg_replace( + '|\d{2}\.\d{2}\.\d{2}|', + "{$new}", + $mokoContent, + 1 + ); + } else { + // Insert before (per schema order) or as last child of + if (strpos($mokoContent, '{$new}\$1", + $mokoContent, + 1 + ); + } elseif (strpos($mokoContent, '') !== false) { + $updated = preg_replace( + '|()|', + " {$new}\n \$1", + $mokoContent, + 1 + ); + } else { + $updated = $mokoContent; + } + } file_put_contents($mokoManifest, $updated); } diff --git a/cli/version_read.php b/cli/version_read.php index 78f24c5..c31a4f8 100644 --- a/cli/version_read.php +++ b/cli/version_read.php @@ -89,5 +89,29 @@ if ($version === null) { exit(1); } +// -- Backfill: if manifest.xml exists but lacks , insert it -- +if ($mokoVersion === null && file_exists($mokoManifest)) { + $content = file_get_contents($mokoManifest); + if (!preg_match('|\d{2}\.\d{2}\.\d{2}|', $content)) { + if (strpos($content, '{$version}\$1", + $content, + 1 + ); + } elseif (strpos($content, '') !== false) { + $content = preg_replace( + '|()|', + " {$version}\n \$1", + $content, + 1 + ); + } + file_put_contents($mokoManifest, $content); + fwrite(STDERR, "Backfilled manifest.xml with version {$version}\n"); + } +} + echo $version . "\n"; exit(0); diff --git a/definitions/manifest-schema.xsd b/definitions/manifest-schema.xsd index c8ca0c2..60e3d3c 100644 --- a/definitions/manifest-schema.xsd +++ b/definitions/manifest-schema.xsd @@ -3,7 +3,7 @@ Copyright (C) 2026 Moko Consulting SPDX-License-Identifier: GPL-3.0-or-later - MokoStandards Manifest Schema v1.0 + MokoStandards Manifest Schema v09.01.00 Defines the structure of .mokogitea/manifest.xml Validate: xmllint - -schema definitions/manifest-schema.xsd .mokogitea/manifest.xml @@ -11,7 +11,8 @@ + elementFormDefault="qualified" + version="09.01.00">