Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Badges: the game and verified counts read JSON the sync keeps current

LNPANDY4653d1bee1dc
diff --git a/README.md b/README.md
index 3223a010..c115b46e 100644
--- a/README.md
+++ b/README.md
@@ -10,8 +10,8 @@
[![Forks](https://img.shields.io/github/forks/LNPANDY/NX2Apple?style=social)](https://github.com/LNPANDY/NX2Apple/network/members)
[![Issues](https://img.shields.io/github/issues/LNPANDY/NX2Apple)](https://github.com/LNPANDY/NX2Apple/issues)
[![License](https://img.shields.io/github/license/LNPANDY/NX2Apple)](LICENSE)
-[![Games](https://img.shields.io/badge/games-58-blue)](#supported-games)
-[![Verified](https://img.shields.io/badge/verified_on_an_iPhone-3-success)](#supported-games)
+[![Games](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FLNPANDY%2FNX2Apple%2Fmain%2Fdocs%2Fbadges%2Fgames.json)](docs/badges/games.json)
+[![Verified](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FLNPANDY%2FNX2Apple%2Fmain%2Fdocs%2Fbadges%2Fverified.json)](docs/badges/verified.json)
[![English](https://img.shields.io/badge/🇺🇸_English-current-blue)](README.md)
[![简体中文](https://img.shields.io/badge/🇨🇳_简体中文-available-green)](README.zh-CN.md)
diff --git a/README.zh-CN.md b/README.zh-CN.md
index b218c8ac..a79d6e7c 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -10,8 +10,8 @@
[![Forks](https://img.shields.io/github/forks/LNPANDY/NX2Apple?style=social)](https://github.com/LNPANDY/NX2Apple/network/members)
[![Issues](https://img.shields.io/github/issues/LNPANDY/NX2Apple)](https://github.com/LNPANDY/NX2Apple/issues)
[![License](https://img.shields.io/github/license/LNPANDY/NX2Apple)](LICENSE)
-[![游戏](https://img.shields.io/badge/游戏-58-blue)](#支持的游戏)
-[![已验证](https://img.shields.io/badge/iPhone_实测通过-3-success)](#支持的游戏)
+[![游戏](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FLNPANDY%2FNX2Apple%2Fmain%2Fdocs%2Fbadges%2Fgames.json)](docs/badges/games.json)
+[![已验证](https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FLNPANDY%2FNX2Apple%2Fmain%2Fdocs%2Fbadges%2Fverified.json)](docs/badges/verified.json)
[![English](https://img.shields.io/badge/🇺🇸_English-available-green)](README.md)
[![简体中文](https://img.shields.io/badge/🇨🇳_简体中文-当前-blue)](README.zh-CN.md)
diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.py
index 3cab7e80..4494497e 100644
--- a/scripts/sync_upstream.py
+++ b/scripts/sync_upstream.py
@@ -23,7 +23,7 @@ working tree, so CI can open an issue with the log instead.
Usage: sync_upstream.py --old <upstream sha> --new <upstream sha> [--skip-build]
"""
-import argparse, os, subprocess, sys, shutil, tempfile
+import argparse, json, os, subprocess, sys, shutil, tempfile
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
@@ -593,6 +593,30 @@ def apply_changes(a, changes):
fail(f'{path}: fork patch marker missing after sync: {MARKERS[path]!r}')
+def refresh_badges():
+ """Keep docs/badges/*.json in step with the tree, so the README badges need no hand edit.
+
+ The game count is the number of title-ID profile folders (dm/games/0100…), which is what the
+ README means by "N game profiles". The verified count is the rows marked verified in the
+ README's own table, so the source of truth stays the README text rather than a second list."""
+ gdir = REPO / 'dm/games'
+ games = sum(1 for d in gdir.iterdir() if d.is_dir() and d.name.startswith('0100'))
+ readme = (REPO / 'README.md').read_text(encoding='utf-8')
+ verified = sum(1 for ln in readme.splitlines()
+ if ln.startswith('| ') and ('**Verified here**' in ln or 'Verified —' in ln))
+ for name, label, value, color in [('games', 'games', games, 'blue'),
+ ('verified', 'verified on an iPhone', verified, 'success')]:
+ p = REPO / 'docs/badges' / f'{name}.json'
+ old = p.read_text(encoding='utf-8') if p.exists() else ''
+ new = json.dumps({'schemaVersion': 1, 'label': label, 'message': str(value), 'color': color},
+ indent=2) + '\n'
+ if old != new:
+ p.parent.mkdir(parents=True, exist_ok=True)
+ p.write_text(new, encoding='utf-8')
+ say(f' badge {name}: {value}')
+ say(f'badges: {games} games, {verified} verified')
+
+
def main():
ap = argparse.ArgumentParser()
ap.add_argument('--old', required=True, help='upstream ref the fork is currently at')
@@ -606,6 +630,7 @@ def main():
try:
apply_changes(a, changes)
verify(a.skip_build)
+ refresh_badges()
except SyncProblem: pass
if problems:
say(f'\nSYNC FAILED: {len(problems)} problem(s) — nothing committed; the working tree is left as the script wrote it, `git checkout -- .` restores it')