2026-04-15 02:35:30 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
2026-05-31 13:36:05 -05:00
|
|
|
|
2026-04-15 02:35:30 +00:00
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*
|
|
|
|
|
* FILE INFORMATION
|
2026-05-21 21:33:52 -05:00
|
|
|
* DEFGROUP: moko-platform.CLI
|
|
|
|
|
* INGROUP: moko-platform
|
2026-05-11 17:01:17 -05:00
|
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
2026-04-15 02:35:30 +00:00
|
|
|
* PATH: /cli/platform_detect.php
|
2026-05-31 14:18:26 -05:00
|
|
|
* BRIEF: Detect platform from manifest.xml file — outputs platform string
|
2026-04-15 02:35:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-31 11:39:10 -05:00
|
|
|
require_once __DIR__ . '/../lib/Enterprise/CliFramework.php';
|
2026-04-15 02:35:30 +00:00
|
|
|
|
2026-05-31 11:39:10 -05:00
|
|
|
use MokoEnterprise\CliFramework;
|
|
|
|
|
|
|
|
|
|
class PlatformDetectCli extends CliFramework
|
|
|
|
|
{
|
|
|
|
|
protected function configure(): void
|
|
|
|
|
{
|
2026-05-31 14:18:26 -05:00
|
|
|
$this->setDescription('Detect platform from manifest.xml file');
|
2026-05-31 11:39:10 -05:00
|
|
|
$this->addArgument('--path', 'Repository root path', '.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function run(): int
|
|
|
|
|
{
|
|
|
|
|
$path = $this->getArgument('--path');
|
|
|
|
|
$root = realpath($path) ?: $path;
|
|
|
|
|
|
2026-05-31 14:18:26 -05:00
|
|
|
// Check .mokogitea/manifest.xml first, fallback to root
|
|
|
|
|
$file = "{$root}/.mokogitea/manifest.xml";
|
2026-05-31 11:39:10 -05:00
|
|
|
if (!file_exists($file)) {
|
|
|
|
|
$file = "{$root}/.mokostandards";
|
|
|
|
|
}
|
|
|
|
|
if (!file_exists($file)) {
|
|
|
|
|
echo "unknown\n";
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content = file_get_contents($file);
|
|
|
|
|
if (preg_match('/^platform:\s*(.+)/m', $content, $m)) {
|
|
|
|
|
echo trim($m[1], " \t\n\r\"'") . "\n";
|
|
|
|
|
} else {
|
|
|
|
|
echo "unknown\n";
|
|
|
|
|
}
|
2026-04-15 02:35:30 +00:00
|
|
|
|
2026-05-31 11:39:10 -05:00
|
|
|
return 0;
|
|
|
|
|
}
|
2026-04-15 02:35:30 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-31 11:39:10 -05:00
|
|
|
$app = new PlatformDetectCli();
|
|
|
|
|
exit($app->execute());
|