chore: cascade main → dev (a5cd566) [skip ci]
#170
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+42
-102
@@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
@@ -10,7 +9,7 @@
|
||||
* INGROUP: moko-platform
|
||||
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||
* 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);
|
||||
@@ -18,15 +17,9 @@ declare(strict_types=1);
|
||||
$path = '.';
|
||||
$type = 'patch'; // patch | minor | major
|
||||
foreach ($argv as $i => $arg) {
|
||||
if ($arg === '--path' && isset($argv[$i + 1])) {
|
||||
$path = $argv[$i + 1];
|
||||
}
|
||||
if ($arg === '--minor') {
|
||||
$type = 'minor';
|
||||
}
|
||||
if ($arg === '--major') {
|
||||
$type = 'major';
|
||||
}
|
||||
if ($arg === '--path' && isset($argv[$i + 1])) $path = $argv[$i + 1];
|
||||
if ($arg === '--minor') $type = 'minor';
|
||||
if ($arg === '--major') $type = 'major';
|
||||
}
|
||||
|
||||
$root = realpath($path) ?: $path;
|
||||
@@ -102,25 +95,12 @@ $patch = (int)$parts[3];
|
||||
$old = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
||||
|
||||
switch ($type) {
|
||||
case 'major':
|
||||
$major++;
|
||||
$minor = 0;
|
||||
$patch = 0;
|
||||
break;
|
||||
case 'minor':
|
||||
$minor++;
|
||||
$patch = 0;
|
||||
break;
|
||||
case 'major': $major++; $minor = 0; $patch = 0; break;
|
||||
case 'minor': $minor++; $patch = 0; break;
|
||||
default:
|
||||
$patch++;
|
||||
if ($patch > 99) {
|
||||
$minor++;
|
||||
$patch = 0;
|
||||
}
|
||||
if ($minor > 99) {
|
||||
$major++;
|
||||
$minor = 0;
|
||||
}
|
||||
if ($patch > 99) { $minor++; $patch = 0; }
|
||||
if ($minor > 99) { $major++; $minor = 0; }
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -128,34 +108,12 @@ $new = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
||||
|
||||
// -- Update .mokogitea/manifest.xml (canonical target) --
|
||||
if (file_exists($mokoManifest) && !empty($mokoContent)) {
|
||||
if (preg_match('|<version>\d{2}\.\d{2}\.\d{2}</version>|', $mokoContent)) {
|
||||
// Replace existing version tag
|
||||
$updated = preg_replace(
|
||||
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
|
||||
"<version>{$new}</version>",
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$updated = preg_replace(
|
||||
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
|
||||
"<version>{$new}</version>",
|
||||
$mokoContent,
|
||||
1
|
||||
);
|
||||
file_put_contents($mokoManifest, $updated);
|
||||
}
|
||||
|
||||
@@ -170,55 +128,37 @@ if (file_exists($readme) && !empty($readmeContent)) {
|
||||
file_put_contents($readme, $updated);
|
||||
}
|
||||
|
||||
// ── Update manifest XML files ────────────────────────────────────────────────
|
||||
foreach ($manifestFiles as $xmlFile) {
|
||||
$xmlContent = file_get_contents($xmlFile);
|
||||
if (strpos($xmlContent, '<extension') === false && strpos($xmlContent, '<version>') === false) {
|
||||
continue;
|
||||
}
|
||||
$updatedXml = preg_replace(
|
||||
'|<version>\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?</version>|',
|
||||
"<version>{$new}</version>",
|
||||
$xmlContent
|
||||
);
|
||||
if ($updatedXml !== $xmlContent) {
|
||||
file_put_contents($xmlFile, $updatedXml);
|
||||
// -- Cascade to ALL Joomla extension XML manifests --
|
||||
$xmlPatterns = [
|
||||
"{$root}/src/pkg_*.xml",
|
||||
"{$root}/src/*.xml",
|
||||
"{$root}/src/packages/*/*.xml",
|
||||
"{$root}/*.xml",
|
||||
];
|
||||
|
||||
$updatedFiles = [];
|
||||
foreach ($xmlPatterns as $pattern) {
|
||||
foreach (glob($pattern) ?: [] as $xmlFile) {
|
||||
$content = file_get_contents($xmlFile);
|
||||
// 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 ───────────────────────────────────────────
|
||||
$modFiles = array_merge(
|
||||
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);
|
||||
}
|
||||
if (!empty($updatedFiles)) {
|
||||
fwrite(STDERR, "Updated " . count($updatedFiles) . " Joomla manifest(s): " . implode(', ', $updatedFiles) . "\n");
|
||||
}
|
||||
|
||||
// ── Update composer.json ─────────────────────────────────────────────────────
|
||||
$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";
|
||||
echo "{$old} -> {$new}\n";
|
||||
exit(0);
|
||||
|
||||
Reference in New Issue
Block a user