Makelore 2.0 initial clean snapshot
This commit is contained in:
46
scripts/verify-bundled-python.mjs
Normal file
46
scripts/verify-bundled-python.mjs
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { getPythonTarget, PYTHON_VERSION } from './bundled-python-manifest.mjs';
|
||||
|
||||
const SCRIPT_DIR = path.dirname(fileURLToPath(import.meta.url));
|
||||
const PROJECT_ROOT = path.resolve(SCRIPT_DIR, '..');
|
||||
|
||||
function readOption(name) {
|
||||
const prefix = `--${name}=`;
|
||||
const inline = process.argv.find((value) => value.startsWith(prefix));
|
||||
if (inline) return inline.slice(prefix.length);
|
||||
const index = process.argv.indexOf(`--${name}`);
|
||||
return index >= 0 ? process.argv[index + 1] : undefined;
|
||||
}
|
||||
|
||||
function runProbe(executable, label, args) {
|
||||
const result = spawnSync(executable, args, { encoding: 'utf8', windowsHide: true });
|
||||
if (result.status !== 0) {
|
||||
const detail = String(result.stderr || result.stdout || result.error?.message || 'unknown error').trim();
|
||||
throw new Error(`${label} failed: ${detail}`);
|
||||
}
|
||||
process.stdout.write(`[python] ${label}: ${String(result.stdout || result.stderr).trim()}\n`);
|
||||
}
|
||||
|
||||
const targetId = readOption('target');
|
||||
const root = readOption('root');
|
||||
if (!targetId || !root) {
|
||||
process.stderr.write('Usage: verify-bundled-python.mjs --root <target-root> --target <target-id>\n');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
try {
|
||||
const target = getPythonTarget(targetId);
|
||||
const executable = path.resolve(root, target.executable);
|
||||
const meowaCli = path.join(PROJECT_ROOT, '.opencode', 'skills', 'game-assets', 'meowart_api.py');
|
||||
runProbe(executable, 'version', ['--version']);
|
||||
runProbe(executable, 'stdlib', ['-c', "import json, pathlib, urllib.request; print('stdlib-ok')"]);
|
||||
runProbe(executable, 'meowa-help', [meowaCli, '--help']);
|
||||
process.stdout.write(`[python] ${targetId} verified for Python ${PYTHON_VERSION}\n`);
|
||||
} catch (error) {
|
||||
process.stderr.write(`[python] ${targetId} verification failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user