diff --git a/package.json b/package.json index c05b130..66c32ed 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "verify:local-release": "pnpm run verify:battle-save && pnpm run verify:campaign-save && tsc --noEmit && pnpm run build && pnpm run verify:release", "verify:public-deploy": "node scripts/verify-public-deploy.mjs", "qa:representative": "node scripts/qa-representative-battles.mjs", + "qa:smoke": "node scripts/qa-representative-battles.mjs --set=smoke", "deploy:nas": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/deploy-nas.ps1 -Build", "ship:release": "node scripts/ship-release.mjs" }, diff --git a/scripts/qa-representative-battles.mjs b/scripts/qa-representative-battles.mjs index 994f986..56b6ddb 100644 --- a/scripts/qa-representative-battles.mjs +++ b/scripts/qa-representative-battles.mjs @@ -3,6 +3,7 @@ import { existsSync } from 'node:fs'; import { readFile, writeFile } from 'node:fs/promises'; import { chromium } from 'playwright'; +const cliOptions = parseCliOptions(process.argv.slice(2)); const defaultQaPort = process.env.QA_PORT ?? '41737'; const targetUrl = process.env.QA_URL ?? `http://127.0.0.1:${defaultQaPort}/`; const headless = process.env.QA_HEADLESS !== '0'; @@ -619,7 +620,10 @@ const allRepresentativeBattles = [ } ]; +const smokeBattles = allRepresentativeBattles.filter((battle) => [1, 7, 27].includes(battle.no)); + const qaBattleSets = { + smoke: smokeBattles, representative: allRepresentativeBattles, campaign: allCampaignBattles, early: earlyCampaignBattles, @@ -630,14 +634,14 @@ const qaBattleSets = { nanzhongFinal: nanzhongFinalCampaignBattles, northern: northernCampaignBattles }; -const qaSetName = process.env.QA_SET ?? 'representative'; +const qaSetName = cliOptions.set ?? process.env.QA_SET ?? 'representative'; const qaBattleSet = qaBattleSets[qaSetName]; if (!qaBattleSet) { throw new Error(`Unknown QA_SET "${qaSetName}". Use one of: ${Object.keys(qaBattleSets).join(', ')}`); } const requestedBattles = new Set( - (process.env.QA_BATTLES ?? '') + (cliOptions.battles ?? process.env.QA_BATTLES ?? '') .split(',') .map((entry) => entry.trim()) .filter(Boolean) @@ -1534,3 +1538,35 @@ async function isServerReachable(url) { function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } + +function parseCliOptions(args) { + const options = {}; + + for (let index = 0; index < args.length; index += 1) { + const arg = args[index]; + if (!arg.startsWith('--')) { + continue; + } + + const [rawKey, rawValue] = arg.slice(2).split('=', 2); + const key = rawKey.trim(); + if (!key) { + continue; + } + + if (rawValue !== undefined) { + options[key] = rawValue; + continue; + } + + const next = args[index + 1]; + if (next && !next.startsWith('--')) { + options[key] = next; + index += 1; + } else { + options[key] = '1'; + } + } + + return options; +}