Consolidate engine docs and naming

This commit is contained in:
2026-05-19 11:09:37 +02:00
parent 121b174f2c
commit dbcb8f4284
47 changed files with 826 additions and 1992 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env node
const { spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');
function loadDotEnv(filePath) {
if (!fs.existsSync(filePath)) return;
const lines = fs.readFileSync(filePath, 'utf8').split(/\r?\n/);
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const match = trimmed.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
if (!match) continue;
const [, key, rawValue] = match;
if (process.env[key] != null) continue;
process.env[key] = rawValue.replace(/^["']|["']$/g, '');
}
}
const projectRoot = path.resolve(__dirname, '..');
loadDotEnv(path.join(projectRoot, '.env'));
const mode = process.argv[2] || 'dev';
const engine = String(process.env.DEFAULT_GAME_ENGINE || process.env.GAME_ENGINE || 'ink')
.trim()
.toLowerCase();
const allowedModes = new Set(['dev', 'start']);
const allowedEngines = new Set(['ink', 'yaml', 'zcode']);
if (!allowedModes.has(mode)) {
console.error(`Unsupported run mode "${mode}". Use "dev" or "start".`);
process.exit(1);
}
if (!allowedEngines.has(engine)) {
console.error(`Unsupported DEFAULT_GAME_ENGINE "${engine}". Use "ink", "yaml", or "zcode".`);
process.exit(1);
}
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const script = `${mode}:${engine}`;
console.log(`[run-engine] DEFAULT_GAME_ENGINE=${engine}; running npm run ${script}`);
const result = spawnSync(npmCommand, ['run', script], {
cwd: projectRoot,
env: process.env,
stdio: 'inherit',
});
process.exit(result.status == null ? 1 : result.status);