66e728b078
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 4: Governance (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (pull_request) Blocked by required conditions
Platform: moko-platform CI / Gate 5: Template Integrity (push) Blocked by required conditions
Platform: moko-platform CI / CI Summary (push) Blocked by required conditions
Generic: Repo Health / Release configuration (push) Blocked by required conditions
Generic: Repo Health / Scripts governance (push) Blocked by required conditions
Generic: Repo Health / Repository health (push) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Generic: Repo Health / Release configuration (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Access control (push) Successful in 18s
Generic: Repo Health / Site Health (push) Has been skipped
Universal: PR Check / Branch Policy (pull_request) Successful in 3s
Universal: Auto Version Bump / Version Bump (push) Failing after 27s
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Successful in 28s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Repo Health / Access control (pull_request) Successful in 3s
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) Failing after 1m7s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 1m7s
Auto-fixed 5006 tab-indent and line-ending errors via phpcbf, then manually broke 100 lines exceeding 150-char limit. All 74 files in cli/, automation/, maintenance/, deploy/ now pass PHPCS PSR-12 clean. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
171 lines
6.7 KiB
PHP
171 lines
6.7 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_read.php
|
|
* VERSION: 09.22.00
|
|
* BRIEF: Parse .manifest.xml and output requested field(s) for CI consumption
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../lib/Enterprise/CliFramework.php';
|
|
|
|
use MokoEnterprise\CliFramework;
|
|
|
|
class ManifestReadCli extends CliFramework
|
|
{
|
|
protected function configure(): void
|
|
{
|
|
$this->setDescription('Parse manifest.xml and output requested field(s) for CI consumption');
|
|
$this->addArgument('--path', 'Repository root path', '.');
|
|
$this->addArgument('--field', 'Single field name to output', '');
|
|
$this->addArgument('--all', 'Print all fields as KEY=VALUE lines', false);
|
|
$this->addArgument('--github-output', 'Append all fields to $GITHUB_OUTPUT', false);
|
|
$this->addArgument('--json', 'Output all fields as JSON', false);
|
|
}
|
|
|
|
protected function run(): int
|
|
{
|
|
$path = $this->getArgument('--path');
|
|
$field = $this->getArgument('--field');
|
|
$showAll = $this->getArgument('--all');
|
|
$ghOutput = $this->getArgument('--github-output');
|
|
$jsonMode = $this->getArgument('--json');
|
|
|
|
// Determine mode
|
|
if ($ghOutput) {
|
|
$mode = 'github-output';
|
|
} elseif ($showAll) {
|
|
$mode = 'all';
|
|
} elseif ($jsonMode) {
|
|
$mode = 'json';
|
|
} else {
|
|
$mode = 'field';
|
|
}
|
|
|
|
// -- Locate manifest --
|
|
$root = realpath($path) ?: $path;
|
|
$manifestFile = null;
|
|
|
|
// Priority: manifest.xml (current standard)
|
|
$candidates = [
|
|
"{$root}/.mokogitea/manifest.xml",
|
|
"{$root}/.mokogitea/.manifest.xml", // legacy (dot-prefixed)
|
|
"{$root}/.mokogitea/.moko-platform", // legacy v4
|
|
];
|
|
|
|
foreach ($candidates as $candidate) {
|
|
if (file_exists($candidate)) {
|
|
$manifestFile = $candidate;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ($manifestFile === null) {
|
|
$this->log('ERROR', "No manifest found in {$root}");
|
|
return 1;
|
|
}
|
|
|
|
// -- Parse XML --
|
|
$xml = @simplexml_load_file($manifestFile);
|
|
|
|
if ($xml === false) {
|
|
// Fallback: try YAML format (.mokostandards legacy)
|
|
$content = file_get_contents($manifestFile);
|
|
$fields = [];
|
|
if (preg_match('/^platform:\s*(.+)/m', $content, $m)) {
|
|
$fields['platform'] = trim($m[1], " \t\n\r\"'");
|
|
}
|
|
if (preg_match('/^standards_version:\s*(.+)/m', $content, $m)) {
|
|
$fields['standards-version'] = trim($m[1], " \t\n\r\"'");
|
|
}
|
|
if (preg_match('/^governed_repo:\s*(.+)/m', $content, $m)) {
|
|
$fields['name'] = trim($m[1], " \t\n\r\"'");
|
|
}
|
|
} else {
|
|
// Register namespace for XPath (optional, simple path works without)
|
|
$fields = [
|
|
'name' => (string)($xml->identity->name ?? ''),
|
|
'display-name' => (string)($xml->identity->{"display-name"} ?? ''),
|
|
'org' => (string)($xml->identity->org ?? ''),
|
|
'description' => (string)($xml->identity->description ?? ''),
|
|
'license' => (string)($xml->identity->license ?? ''),
|
|
'license-spdx' => (string)($xml->identity->license['spdx'] ?? ''),
|
|
'platform' => (string)($xml->governance->platform ?? ''),
|
|
'standards-version' => (string)($xml->governance->{"standards-version"} ?? ''),
|
|
'standards-source' => (string)($xml->governance->{"standards-source"} ?? ''),
|
|
'language' => (string)($xml->build->language ?? ''),
|
|
'package-type' => (string)($xml->build->{"package-type"} ?? ''),
|
|
'entry-point' => (string)($xml->build->{"entry-point"} ?? ''),
|
|
'version' => (string)($xml->identity->version ?? ''),
|
|
'source-dir' => (string)($xml->deploy->{"source-dir"} ?? ''),
|
|
'remote-subdir' => (string)($xml->deploy->{"remote-subdir"} ?? ''),
|
|
'excludes' => (string)($xml->deploy->excludes ?? ''),
|
|
'dev-host' => (string)($xml->deploy->{"dev-host"} ?? ''),
|
|
'demo-host' => (string)($xml->deploy->{"demo-host"} ?? ''),
|
|
'manifest-file' => $manifestFile,
|
|
];
|
|
}
|
|
|
|
// Strip empty values for cleaner output
|
|
$fields = array_filter($fields, fn($v) => $v !== '');
|
|
|
|
// -- Output --
|
|
switch ($mode) {
|
|
case 'field':
|
|
if ($field === '') {
|
|
$this->log('ERROR', "Usage: manifest_read.php --path <dir> --field <name>");
|
|
$this->log('ERROR', " manifest_read.php --path <dir> --all");
|
|
$this->log('ERROR', " manifest_read.php --path <dir> --json");
|
|
$this->log('ERROR', " manifest_read.php --path <dir> --github-output");
|
|
return 2;
|
|
}
|
|
echo ($fields[$field] ?? '') . "\n";
|
|
break;
|
|
|
|
case 'all':
|
|
foreach ($fields as $k => $v) {
|
|
echo "{$k}={$v}\n";
|
|
}
|
|
break;
|
|
|
|
case 'json':
|
|
echo json_encode($fields, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\n";
|
|
break;
|
|
|
|
case 'github-output':
|
|
$outputFile = getenv('GITHUB_OUTPUT');
|
|
if ($outputFile === false || $outputFile === '') {
|
|
$this->log('ERROR', 'GITHUB_OUTPUT not set — printing to stdout instead');
|
|
foreach ($fields as $k => $v) {
|
|
// Convert field-name to FIELD_NAME for env var style
|
|
$envKey = str_replace('-', '_', $k);
|
|
echo "{$envKey}={$v}\n";
|
|
}
|
|
} else {
|
|
$fh = fopen($outputFile, 'a');
|
|
foreach ($fields as $k => $v) {
|
|
$envKey = str_replace('-', '_', $k);
|
|
fwrite($fh, "{$envKey}={$v}\n");
|
|
}
|
|
fclose($fh);
|
|
$this->log('INFO', "Wrote " . count($fields) . " fields to GITHUB_OUTPUT");
|
|
}
|
|
break;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
$app = new ManifestReadCli();
|
|
exit($app->execute());
|