fix: version_bump.php cascades version to all Joomla XML manifests
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Universal: Cascade Main → Dev / Cascade main → branches (push) Successful in 3s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 51s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Universal: Cascade Main → Dev / Cascade main → branches (push) Successful in 3s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 51s
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Authored-by: Moko Consulting
This commit is contained in:
+42
-102
@@ -1,6 +1,5 @@
|
|||||||
#!/usr/bin/env php
|
#!/usr/bin/env php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
@@ -10,7 +9,7 @@
|
|||||||
* INGROUP: moko-platform
|
* INGROUP: moko-platform
|
||||||
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
* PATH: /cli/version_bump.php
|
* PATH: /cli/version_bump.php
|
||||||
* BRIEF: Auto-increment version — manifest.xml is canonical, also updates README.md and Joomla XML
|
* BRIEF: Auto-increment version — manifest.xml is canonical, cascades to all XML and MD files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
@@ -18,15 +17,9 @@ declare(strict_types=1);
|
|||||||
$path = '.';
|
$path = '.';
|
||||||
$type = 'patch'; // patch | minor | major
|
$type = 'patch'; // patch | minor | major
|
||||||
foreach ($argv as $i => $arg) {
|
foreach ($argv as $i => $arg) {
|
||||||
if ($arg === '--path' && isset($argv[$i + 1])) {
|
if ($arg === '--path' && isset($argv[$i + 1])) $path = $argv[$i + 1];
|
||||||
$path = $argv[$i + 1];
|
if ($arg === '--minor') $type = 'minor';
|
||||||
}
|
if ($arg === '--major') $type = 'major';
|
||||||
if ($arg === '--minor') {
|
|
||||||
$type = 'minor';
|
|
||||||
}
|
|
||||||
if ($arg === '--major') {
|
|
||||||
$type = 'major';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$root = realpath($path) ?: $path;
|
$root = realpath($path) ?: $path;
|
||||||
@@ -102,25 +95,12 @@ $patch = (int)$parts[3];
|
|||||||
$old = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
$old = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'major':
|
case 'major': $major++; $minor = 0; $patch = 0; break;
|
||||||
$major++;
|
case 'minor': $minor++; $patch = 0; break;
|
||||||
$minor = 0;
|
|
||||||
$patch = 0;
|
|
||||||
break;
|
|
||||||
case 'minor':
|
|
||||||
$minor++;
|
|
||||||
$patch = 0;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$patch++;
|
$patch++;
|
||||||
if ($patch > 99) {
|
if ($patch > 99) { $minor++; $patch = 0; }
|
||||||
$minor++;
|
if ($minor > 99) { $major++; $minor = 0; }
|
||||||
$patch = 0;
|
|
||||||
}
|
|
||||||
if ($minor > 99) {
|
|
||||||
$major++;
|
|
||||||
$minor = 0;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,34 +108,12 @@ $new = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
|||||||
|
|
||||||
// -- Update .mokogitea/manifest.xml (canonical target) --
|
// -- Update .mokogitea/manifest.xml (canonical target) --
|
||||||
if (file_exists($mokoManifest) && !empty($mokoContent)) {
|
if (file_exists($mokoManifest) && !empty($mokoContent)) {
|
||||||
if (preg_match('|<version>\d{2}\.\d{2}\.\d{2}</version>|', $mokoContent)) {
|
$updated = preg_replace(
|
||||||
// Replace existing version tag
|
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
|
||||||
$updated = preg_replace(
|
"<version>{$new}</version>",
|
||||||
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
|
$mokoContent,
|
||||||
"<version>{$new}</version>",
|
1
|
||||||
$mokoContent,
|
);
|
||||||
1
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Insert <version> before <license> (per schema order) or as last child of <identity>
|
|
||||||
if (strpos($mokoContent, '<license') !== false) {
|
|
||||||
$updated = preg_replace(
|
|
||||||
'|(\s*<license)|',
|
|
||||||
"\n <version>{$new}</version>\$1",
|
|
||||||
$mokoContent,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
} elseif (strpos($mokoContent, '</identity>') !== false) {
|
|
||||||
$updated = preg_replace(
|
|
||||||
'|(</identity>)|',
|
|
||||||
" <version>{$new}</version>\n \$1",
|
|
||||||
$mokoContent,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$updated = $mokoContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_put_contents($mokoManifest, $updated);
|
file_put_contents($mokoManifest, $updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,55 +128,37 @@ if (file_exists($readme) && !empty($readmeContent)) {
|
|||||||
file_put_contents($readme, $updated);
|
file_put_contents($readme, $updated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Update manifest XML files ────────────────────────────────────────────────
|
// -- Cascade to ALL Joomla extension XML manifests --
|
||||||
foreach ($manifestFiles as $xmlFile) {
|
$xmlPatterns = [
|
||||||
$xmlContent = file_get_contents($xmlFile);
|
"{$root}/src/pkg_*.xml",
|
||||||
if (strpos($xmlContent, '<extension') === false && strpos($xmlContent, '<version>') === false) {
|
"{$root}/src/*.xml",
|
||||||
continue;
|
"{$root}/src/packages/*/*.xml",
|
||||||
}
|
"{$root}/*.xml",
|
||||||
$updatedXml = preg_replace(
|
];
|
||||||
'|<version>\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?</version>|',
|
|
||||||
"<version>{$new}</version>",
|
$updatedFiles = [];
|
||||||
$xmlContent
|
foreach ($xmlPatterns as $pattern) {
|
||||||
);
|
foreach (glob($pattern) ?: [] as $xmlFile) {
|
||||||
if ($updatedXml !== $xmlContent) {
|
$content = file_get_contents($xmlFile);
|
||||||
file_put_contents($xmlFile, $updatedXml);
|
// Only update files that have an <extension> tag (Joomla manifests)
|
||||||
|
if (strpos($content, '<extension') === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$newContent = preg_replace(
|
||||||
|
'|<version>\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?</version>|',
|
||||||
|
"<version>{$new}</version>",
|
||||||
|
$content
|
||||||
|
);
|
||||||
|
if ($newContent !== $content) {
|
||||||
|
file_put_contents($xmlFile, $newContent);
|
||||||
|
$updatedFiles[] = substr($xmlFile, strlen($root) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Update Dolibarr mod*.class.php ───────────────────────────────────────────
|
if (!empty($updatedFiles)) {
|
||||||
$modFiles = array_merge(
|
fwrite(STDERR, "Updated " . count($updatedFiles) . " Joomla manifest(s): " . implode(', ', $updatedFiles) . "\n");
|
||||||
glob("{$root}/src/core/modules/mod*.class.php") ?: [],
|
|
||||||
glob("{$root}/htdocs/core/modules/mod*.class.php") ?: []
|
|
||||||
);
|
|
||||||
foreach ($modFiles as $modFile) {
|
|
||||||
$modContent = file_get_contents($modFile);
|
|
||||||
if (strpos($modContent, 'extends DolibarrModules') === false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$updatedMod = preg_replace(
|
|
||||||
'/(\$this->version\s*=\s*)[\'"][^\'"]*[\'"]/',
|
|
||||||
"\${1}'{$new}'",
|
|
||||||
$modContent
|
|
||||||
);
|
|
||||||
if ($updatedMod !== $modContent) {
|
|
||||||
file_put_contents($modFile, $updatedMod);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Update composer.json ─────────────────────────────────────────────────────
|
echo "{$old} -> {$new}\n";
|
||||||
$composerFile = "{$root}/composer.json";
|
|
||||||
if (file_exists($composerFile)) {
|
|
||||||
$composerContent = file_get_contents($composerFile);
|
|
||||||
$updatedComposer = preg_replace(
|
|
||||||
'/("version"\s*:\s*")\d{2}\.\d{2}\.\d{2}(")/m',
|
|
||||||
'${1}' . $new . '${2}',
|
|
||||||
$composerContent
|
|
||||||
);
|
|
||||||
if ($updatedComposer !== $composerContent) {
|
|
||||||
file_put_contents($composerFile, $updatedComposer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "{$old} → {$new}\n";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user