Files
arcade/scripts/check-games.py
T
waozi 932014d87a Build Pushy from its own package and use the Apps package types
Arcade registers Pushy Classic and Island from the Pushy package instead
of its own tree, drops the Pushy tests and docs that moved there, and
imports node app types from the Apps package rather than Inbe. Pushy
opens straight on the newest unlocked level (Arcade 0.5.0 changelog).

Work in progress from the Pushy and Apps sessions, committed at the
owner's request: ziran.toml does not yet list the pushy package, so
scripts/check-games.py fails to resolve it.
2026-10-19 00:25:33 -03:00

52 lines
2.5 KiB
Python

#!/usr/bin/env python3
"""Check game ownership, shared interface versions, translations and update metadata."""
import json
from pathlib import Path
import re
import subprocess
ROOT = Path(__file__).resolve().parents[1]
def package_root(name):
"""Arcade's own games live here; others come from their packages."""
if name == 'self':
return ROOT
return Path(subprocess.check_output([str(ROOT / 'scripts/ziran.sh'), 'pkg', 'path', name],
cwd=ROOT, text=True).strip())
def check():
standard = json.loads((ROOT / 'standards/game-v1.json').read_text())
ledger = json.loads((ROOT / 'apps/versions.json').read_text())
for registration in json.loads((ROOT / 'games.json').read_text())['games']:
source = package_root(registration['package'])
game = json.loads((source / registration['manifest']).read_text())
for field in ['contract_version', 'module_api', 'host_api']:
assert game[field] == standard[field], f'{game["name"]}: incompatible {field}'
component = ledger['node_apps'][game['name']]
assert game['id'] == component['id'] and game['host_api'] == component['host_api']
assert game['kind'] == 'game' and 'arcade' in game['harnesses']
assert set(game['harnesses']) <= {'arcade', 'inbe'}
assert game['save_schema'] == 1
assert (source / game['source']).is_file() and (source / game['preview']).is_file()
changelog = (source / registration['manifest']).with_name('CHANGELOG.md').read_text()
version = re.search(r'^## \[(\d+\.\d+\.\d+)\] - \d{4}-\d{2}-\d{2}$', changelog, re.M)
assert version and version[1] == component['version'], 'Run ./update_version.sh'
assert component['sequence'] > 0
locales = {}
for file in (source / game['locales']).glob('*.txt'):
locales[file.stem] = {match[1] for match in re.finditer(r'^\[([^\]]+)\]$', file.read_text(), re.M)}
required = set()
for file in (source / registration['manifest']).parent.glob('*.zi'):
required.update(re.findall(r'"(' + re.escape(game['locale_prefix']) + r'[a-z0-9_]+)"', file.read_text()))
assert len(locales) >= 12
for language, keys in locales.items():
assert required <= keys, f'{language}: missing {sorted(required - keys)}'
return ledger
if __name__ == '__main__':
check()
print('Game contract, package sources, translated text and independent version ledger passed')