07ea171af9
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 43s
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
New CLI tools: - manifest_element.php — extract element/type/prefix from any platform manifest - release_create.php — create/overwrite Gitea releases with proper naming - release_package.php — build ZIP+tar.gz, SHA-256, upload assets - release_promote.php — promote releases between channels (dev→RC→stable) - version_reset_dev.php — reset platform version on dev branch after release Updated CLI tools: - version_bump.php — now writes to manifests, Dolibarr mod, composer.json (not just README) - release_cascade.php — added --version for version-aware deletion of stale releases - release_validate.php — auto-detect platform, --github-output, source dir check Workflow changes (auto-release.yml): - Draft PR to main → auto-promote highest pre-release to RC - Merged PR to main → promote RC to stable (skip rebuild when RC exists) - Removed paths filter for Go/Node/generic repo compatibility - Fixed cascade --api-base parameter bug Workflow changes (pre-release.yml): - Auto-trigger development pre-release on feature branch merge to dev - Removed paths filter Infrastructure: - RepositorySynchronizer: fixed template repo names, .mokogitea/workflows path, universal workflow cascade (Template-Generic → other templates) - bulk_sync.php: syncs universal workflows to templates before repo sync - PHPDoc added to 4 classes missing class-level docs - Version bump 09.00.00 → 09.01.00 Closes #152 #153 #154 #155 #156 #157 #158 #159 #161 #162 Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
236 lines
7.8 KiB
PHP
236 lines
7.8 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
*
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* FILE INFORMATION
|
|
* DEFGROUP: moko-platform.CLI
|
|
* INGROUP: moko-platform
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
* PATH: /cli/manifest_element.php
|
|
* BRIEF: Extract element name, type, type prefix, and ZIP name from manifest
|
|
*
|
|
* Usage:
|
|
* php manifest_element.php --path .
|
|
* php manifest_element.php --path . --version 09.01.00 --stability dev --github-output
|
|
*
|
|
* Detects platform (joomla, dolibarr, generic) and resolves:
|
|
* ext_element — canonical element name (e.g. mokojgdpc)
|
|
* ext_type — extension type (plugin, module, component, package, etc.)
|
|
* ext_folder — group/folder for plugins (e.g. system)
|
|
* ext_name — human-readable name (e.g. "Moko JGDPC")
|
|
* type_prefix — Joomla type prefix (plg_system_, com_, mod_, etc.)
|
|
* zip_name — computed ZIP filename
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
$path = '.';
|
|
$version = null;
|
|
$stability = 'stable';
|
|
$githubOutput = false;
|
|
$repoName = '';
|
|
|
|
foreach ($argv as $i => $arg) {
|
|
if ($arg === '--path' && isset($argv[$i + 1])) {
|
|
$path = $argv[$i + 1];
|
|
}
|
|
if ($arg === '--version' && isset($argv[$i + 1])) {
|
|
$version = $argv[$i + 1];
|
|
}
|
|
if ($arg === '--stability' && isset($argv[$i + 1])) {
|
|
$stability = $argv[$i + 1];
|
|
}
|
|
if ($arg === '--repo' && isset($argv[$i + 1])) {
|
|
$repoName = $argv[$i + 1];
|
|
}
|
|
if ($arg === '--github-output') {
|
|
$githubOutput = true;
|
|
}
|
|
}
|
|
|
|
$root = realpath($path) ?: $path;
|
|
|
|
// ── Detect platform from manifest.xml ────────────────────────────────────────
|
|
$platform = 'generic';
|
|
$manifestXml = "{$root}/.mokogitea/manifest.xml";
|
|
if (file_exists($manifestXml)) {
|
|
$content = file_get_contents($manifestXml);
|
|
if (preg_match('/<platform>([^<]+)<\/platform>/', $content, $pm)) {
|
|
$platform = trim($pm[1]);
|
|
}
|
|
}
|
|
|
|
// ── Find extension manifest (Joomla XML) ─────────────────────────────────────
|
|
$extManifest = null;
|
|
$manifestFiles = array_merge(
|
|
glob("{$root}/src/pkg_*.xml") ?: [],
|
|
glob("{$root}/src/*.xml") ?: [],
|
|
glob("{$root}/*.xml") ?: []
|
|
);
|
|
foreach ($manifestFiles as $file) {
|
|
$c = file_get_contents($file);
|
|
if (strpos($c, '<extension') !== false) {
|
|
$extManifest = $file;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// ── Find Dolibarr module file ────────────────────────────────────────────────
|
|
$modFile = null;
|
|
$modFiles = array_merge(
|
|
glob("{$root}/src/core/modules/mod*.class.php") ?: [],
|
|
glob("{$root}/htdocs/core/modules/mod*.class.php") ?: [],
|
|
glob("{$root}/core/modules/mod*.class.php") ?: []
|
|
);
|
|
foreach ($modFiles as $file) {
|
|
$c = file_get_contents($file);
|
|
if (strpos($c, 'extends DolibarrModules') !== false) {
|
|
$modFile = $file;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// ── Extract metadata ─────────────────────────────────────────────────────────
|
|
$extElement = '';
|
|
$extType = '';
|
|
$extFolder = '';
|
|
$extName = '';
|
|
|
|
switch (true) {
|
|
// Joomla platforms
|
|
case in_array($platform, ['joomla', 'waas-component'], true) && $extManifest !== null:
|
|
$xml = file_get_contents($extManifest);
|
|
|
|
// Extension type and folder
|
|
if (preg_match('/type="([^"]*)"/', $xml, $tm)) {
|
|
$extType = $tm[1];
|
|
}
|
|
if (preg_match('/group="([^"]*)"/', $xml, $gm)) {
|
|
$extFolder = $gm[1];
|
|
}
|
|
|
|
// Element name: <element>, plugin= attribute, <packagename>, or filename
|
|
if (preg_match('/<element>([^<]+)<\/element>/', $xml, $em)) {
|
|
$extElement = $em[1];
|
|
}
|
|
if (empty($extElement) && preg_match('/plugin="([^"]*)"/', $xml, $pm)) {
|
|
$extElement = $pm[1];
|
|
}
|
|
if ($extType === 'package' && preg_match('/<packagename>([^<]+)<\/packagename>/', $xml, $pn)) {
|
|
$extElement = $pn[1];
|
|
}
|
|
if (empty($extElement)) {
|
|
$extElement = strtolower(basename($extManifest, '.xml'));
|
|
if (in_array($extElement, ['templatedetails', 'manifest'], true)) {
|
|
$extElement = strtolower(str_replace([' ', '-'], '', $repoName ?: basename($root)));
|
|
}
|
|
}
|
|
|
|
// Human-readable name
|
|
if (preg_match('/<name>([^<]+)<\/name>/', $xml, $nm)) {
|
|
$extName = trim($nm[1]);
|
|
}
|
|
break;
|
|
|
|
// Dolibarr platforms
|
|
case in_array($platform, ['dolibarr', 'crm-module'], true) && $modFile !== null:
|
|
$extType = 'dolibarr-module';
|
|
$modBasename = basename($modFile, '.class.php');
|
|
$extElement = strtolower(preg_replace('/^mod/', '', $modBasename));
|
|
|
|
$modContent = file_get_contents($modFile);
|
|
if (preg_match('/\$this->name\s*=\s*[\'"]([^\'"]+)[\'"]/', $modContent, $nm)) {
|
|
$extName = $nm[1];
|
|
}
|
|
break;
|
|
|
|
// Generic / fallback
|
|
default:
|
|
$extElement = strtolower(str_replace([' ', '-'], '', $repoName ?: basename($root)));
|
|
$extType = 'generic';
|
|
break;
|
|
}
|
|
|
|
// ── Strip existing type prefix from element to prevent duplication ────────────
|
|
$extElement = preg_replace('/^(pkg_|com_|mod_|plg_[a-z]+_|tpl_|lib_)/', '', $extElement);
|
|
|
|
// ── Compute type prefix ──────────────────────────────────────────────────────
|
|
$typePrefix = '';
|
|
switch ($extType) {
|
|
case 'plugin':
|
|
$typePrefix = "plg_{$extFolder}_";
|
|
break;
|
|
case 'module':
|
|
$typePrefix = 'mod_';
|
|
break;
|
|
case 'component':
|
|
$typePrefix = 'com_';
|
|
break;
|
|
case 'template':
|
|
$typePrefix = 'tpl_';
|
|
break;
|
|
case 'library':
|
|
$typePrefix = 'lib_';
|
|
break;
|
|
case 'package':
|
|
$typePrefix = 'pkg_';
|
|
break;
|
|
}
|
|
|
|
// ── Compute ZIP name ─────────────────────────────────────────────────────────
|
|
$suffixMap = [
|
|
'development' => '-dev',
|
|
'dev' => '-dev',
|
|
'alpha' => '-alpha',
|
|
'beta' => '-beta',
|
|
'rc' => '-rc',
|
|
'release-candidate' => '-rc',
|
|
'stable' => '',
|
|
];
|
|
$suffix = $suffixMap[$stability] ?? '';
|
|
$zipName = '';
|
|
if ($version !== null) {
|
|
$zipName = "{$typePrefix}{$extElement}-{$version}{$suffix}.zip";
|
|
}
|
|
|
|
// Fallback name
|
|
if (empty($extName)) {
|
|
$extName = $repoName ?: basename($root);
|
|
}
|
|
|
|
// ── Output ───────────────────────────────────────────────────────────────────
|
|
$outputs = [
|
|
'platform' => $platform,
|
|
'ext_element' => $extElement,
|
|
'ext_type' => $extType,
|
|
'ext_folder' => $extFolder,
|
|
'ext_name' => $extName,
|
|
'type_prefix' => $typePrefix,
|
|
'zip_name' => $zipName,
|
|
];
|
|
|
|
if ($githubOutput) {
|
|
$ghOutput = getenv('GITHUB_OUTPUT');
|
|
$lines = [];
|
|
foreach ($outputs as $key => $value) {
|
|
$lines[] = "{$key}={$value}";
|
|
}
|
|
if ($ghOutput) {
|
|
file_put_contents($ghOutput, implode("\n", $lines) . "\n", FILE_APPEND);
|
|
} else {
|
|
// Fallback: echo ::set-output (legacy)
|
|
foreach ($outputs as $key => $value) {
|
|
echo "::set-output name={$key}::{$value}\n";
|
|
}
|
|
}
|
|
} else {
|
|
foreach ($outputs as $key => $value) {
|
|
echo "{$key}={$value}\n";
|
|
}
|
|
}
|
|
|
|
exit(0);
|