diff --git a/cli/joomla_build.php b/cli/joomla_build.php index 17cbd88..36e0c4a 100644 --- a/cli/joomla_build.php +++ b/cli/joomla_build.php @@ -155,6 +155,14 @@ function parseManifest(string $file): array $element = (string) ($xml->element ?? ''); $group = (string) ($xml->attributes()->group ?? ''); + // For packages, prefer as the clean element (avoids pkg_pkg_ duplication) + if ($type === 'package' && $element === '') { + $packageName = (string) ($xml->packagename ?? ''); + if ($packageName !== '') { + $element = $packageName; + } + } + // Fallback element detection if ($element === '') { $element = (string) ($xml->attributes()->plugin ?? ''); } if ($element === '') { $element = (string) ($xml->attributes()->module ?? ''); } @@ -164,6 +172,10 @@ function parseManifest(string $file): array $element = strtolower(basename(dirname($file))); } } + + // Strip existing type prefix to prevent duplication (e.g. pkg_mokowaas → mokowaas) + $element = preg_replace('/^(pkg_|com_|mod_|plg_\w+_|tpl_|lib_)/', '', $element); + if ($name === '') { $name = $element; } return compact('name', 'type', 'element', 'group');