fix: auto-add folder=\"packages\" to package manifest during build

When building Joomla packages, sub-package ZIPs are placed in a
packages/ subdirectory. The manifest <files> element must have
folder="packages" for Joomla to find them. This fix ensures the
attribute is always present, even if version bump tools overwrote it.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-28 15:31:50 -05:00
parent 20293f5f5c
commit 28a9e05cb7
+12
View File
@@ -402,6 +402,18 @@ if ($isJoomlaPackage) {
echo " Sub-package: {$subName}.zip\n";
}
// Ensure package manifest has folder="packages" on <files> element
// since sub-packages are stored in a packages/ subdirectory
$pkgManifests = glob("{$sourceDir}/pkg_*.xml") ?: [];
foreach ($pkgManifests as $pkgXml) {
$pkgContent = file_get_contents($pkgXml);
if (strpos($pkgContent, '<files>') !== false && strpos($pkgContent, 'folder="packages"') === false) {
$pkgContent = str_replace('<files>', '<files folder="packages">', $pkgContent);
file_put_contents($pkgXml, $pkgContent);
echo " Fixed: added folder=\"packages\" to " . basename($pkgXml) . "\n";
}
}
// Copy top-level XML and PHP files into the package root
$topLevelFiles = array_merge(
glob("{$sourceDir}/*.xml") ?: [],