From ee427553bb59fbc08c86789fbb8c38718b8151ca Mon Sep 17 00:00:00 2001 From: CRT Date: Sun, 11 Oct 2026 21:23:37 +0000 Subject: [PATCH] shots check: ligatures no longer read as system-font glyphs (probe spans shaped as one run); --help on every command and group, unknown flags rejected before anything runs Root cause: the per-character font probes were inline spans side by side, so Chrome shaped f + i into the fi ligature across them and the lone i probe reported no glyph of ours. Each probe is now its own block. The Google Fonts text= subsets keep the GSUB ligatures; regression test with a real Montserrat text= subset. --help / -h prints the command's usage and exits 0 before any config, render or network; unknown flags exit 2 with the usage (cli/data/flags.json from tools/gen-flags.ts). Command tables moved to cli/commands.ts; ads apple reachable again; shots render --scenes rejects unknown ids at once. --- CHANGELOG.md | 12 + CONTRIBUTING.md | 4 + cli/commands.ts | 92 ++ cli/data/flags.json | 1101 +++++++++++++++++ cli/index.ts | 147 +-- cli/shots/glyphs.ts | 4 +- cli/shots/render.ts | 6 +- tests/cli-help.test.ts | 111 ++ tests/fixtures/fonts/Montserrat-OFL.txt | 93 ++ .../fonts/montserrat-text-subset.woff2 | Bin 0 -> 4728 bytes tests/glyph-ligatures.test.ts | 49 + tools/gen-flags.ts | 105 ++ 12 files changed, 1625 insertions(+), 99 deletions(-) create mode 100644 cli/commands.ts create mode 100644 cli/data/flags.json create mode 100644 tests/cli-help.test.ts create mode 100644 tests/fixtures/fonts/Montserrat-OFL.txt create mode 100644 tests/fixtures/fonts/montserrat-text-subset.woff2 create mode 100644 tests/glyph-ligatures.test.ts create mode 100644 tools/gen-flags.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b9b4fd0..5a7ab19a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## Unreleased +- `shots check` no longer reports `i drawn with a system font` for captions with ligatures ("Outfits" in en / de / nl + with Montserrat). The font usage probes (one span per character, read with CDP `CSS.getPlatformFontsForNode`) sat + side by side in one line, so Chrome shaped "f" + "i" into the fi ligature across them and the lone "i" probe reported + no glyph of ours. Each probe is now its own block. The Google Fonts `text=` subsets were fine (they keep the GSUB + ligatures); regression test with a real Montserrat `text=` subset (`tests/glyph-ligatures.test.ts`). +- `--help` / `-h` on every command, subcommand and group (`storebound shots render --help`, `storebound apple --help`) + prints the usage (the module's usage lines, the description and the options it accepts) and exits 0 before anything + loads; it used to start the command (a full render). An unknown flag (`--dyr`) exits 2 with the usage before anything + runs (`cli/data/flags.json`, `bun tools/gen-flags.ts`). `storebound shots` alone lists the shots commands. + `storebound ads apple ...` is reachable again (the plain `ads` command used to swallow it). +- `shots render --scenes` takes scene ids (the usage said numbers); an unknown id fails at once with the list of ids + instead of a 30 s page timeout. - Local font files in `shots.fonts`: `title`, `body` and `fallback[]` take, besides a Google Fonts family, a path (relative to the config) or `{ family, file, weight?, style?, license? }` (TTF / OTF / WOFF / WOFF2, validated by extension and signature; the family comes from the name table when not given). `shots fonts` checks the file's cmap diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 46059864..d662330a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,6 +27,10 @@ Try the screenshot and video pipeline on the demo game without any store account - **Skills are the single source.** Edit `skills/*/SKILL.md` or `docs/agents-core.md`, then run `bun tools/gen-adapters.ts`; never edit `AGENTS.md`, `GEMINI.md`, the plugin manifests or the Cursor / Copilot files by hand. Frontmatter is `name` + `description` only. +- **New or renamed flags: run `bun tools/gen-flags.ts`.** The CLI rejects a flag a command does not read + (`cli/data/flags.json`, generated from the commands and their imports in `cli/commands.ts`); a flag read with a + computed name goes into `DYNAMIC` in that tool. `tests/cli-help.test.ts` fails on a stale table, on a command whose + `--help` does anything but print its usage, and on an MCP / desktop tool that passes a flag its command does not take. - **No secrets, no real ids, no personal data** in code, tests, fixtures or examples: use `com.example.*`, `example.com` and obviously fake values. `bun run ci` runs the scrub. - **No hand-written SVG.** Charts come from visx, icons from Phosphor (`@phosphor-icons/react` in the desktop app, one diff --git a/cli/commands.ts b/cli/commands.ts new file mode 100644 index 00000000..6971c337 --- /dev/null +++ b/cli/commands.ts @@ -0,0 +1,92 @@ +// The command tables: name -> (lazy module, one-line description). index.ts dispatches from here; tools/gen-flags.ts +// reads this file to find each command's module and writes the flags it accepts to cli/data/flags.json. +import type { parseArgs } from './lib/args'; +import type { Ctx } from './lib/ctx'; + +export type Mod = { run(ctx: Ctx): Promise }; +export type Plain = { run(args: ReturnType): Promise }; +/** Commands that work without a storebound.config.ts. */ +export const PLAIN: Record Promise, string]> = { + 'init': [() => import('./init'), 'copy the templates (config, listing, copy, declarations, privacy policy) into this project; --profile app|game|subscription-app (default app)'], + 'import': [() => import('./import'), 'fastlane [--dir fastlane] [--profile app|game|subscription-app] [--dry]: Appfile, deliver + supply metadata and screenshots -> config, store/*.md, shots frames (read-only on fastlane, never overwrites)'], + 'install': [() => import('./install'), 'skills + MCP server for --agent claude|codex|cursor|copilot|windsurf|gemini|opencode'], + 'mcp': [async () => ({ run: async () => (await import('./mcp')).serve() }), 'stdio MCP server wrapping these commands (for any MCP-capable AI tool)'], + 'serve': [() => import('./serve'), '--stdio: JSON-RPC session for the storebound desktop app (dry runs; writes need a host confirm token)'], + 'apps': [() => import('./apps'), 'list (every app the store keys can see: App Store Connect team, Play developer accounts; --icons) | check (key works / permission missing / revoked, with the fix); --store apple|play, --json; read-only'], + 'desktop': [() => import('./desktop'), 'open the storebound desktop app (in an app folder: add or select it there); not installed: the download for this system, --download saves it to ~/Downloads after checking its signature (never installs)'], + 'doctor': [() => import('./doctor'), 'local tools for screenshots, previews, icons and captures (ffmpeg, Chrome, playwright, Xcode, adb, git) and how to install what is missing; --json'], + 'scan': [() => import('./scan'), 'offline, read-only rejection-risk scan of the project itself (stack, SDKs, Info.plist, manifest, listings) with guideline, evidence file:line, fix and skill, plus the Data safety / App Privacy / ATT / privacy manifest proposal; --write puts the detected answers into the config; --json; exit 1 on blockers'], + 'api': [() => import('./api'), 'every App Store Connect / Google Play API operation: list | coverage | apple|play [--param k=v] [--body f.json] [--all-pages] (GET runs; writes dry unless --yes in a terminal; owner-only ones need the id typed)'], + 'privacy-manifest': [() => import('./privacy-manifest'), 'iOS PrivacyInfo.xcprivacy + required-reason API + SDK manifest scan (--ios )'], + 'ws': [() => import('./workspace'), 'many apps and studios (storebound.workspace.json): init | list | status (apps x stores, parallel) | check | validate | run --apps a,b|--all (writes dry unless --apply) | apps import --account | desktop export|import'], + 'release': [() => import('./release'), 'status [--app a,b] [--versions]: both stores on one train per version (build > testing > review > live > rollout %) | plan : what is left on each store, in fix order; read-only, --json'], + 'flow': [() => import('./flow'), 'repo-local workflows (store/workflows/*.yml, storebound.workflows.*): list | validate | run [NAME=value] [--dry plan only | --apply] [--from | --resume]; writes run as dry runs unless --apply, owner steps (submit, release, rollout) are never run'], + 'ads': [() => import('./ads'), 'scan --ios : AdAttributionKit / SKAdNetwork checks of Info.plist (network ids, postback copy endpoints, attribution windows, cooldown) and sources; --json'], +}; +export const COMMANDS: Record Promise, string]> = { + 'inspect': [() => import('./inspect'), 'offline summary of the config (name, store ids, languages, products, subscriptions); --json'], + 'check': [() => import('./check'), 'validate config, copy files, data safety answers, products, subscriptions and the app profile (offline); --aso keyword audit'], + 'validate': [() => import('./validate'), 'read-only store readiness report with ordered blockers (--apple / --play), plus local renders checks (--no-local skips); exit 1 on blockers'], + 'analytics': [() => import('./analytics'), 'setup (App Store report request) | snapshot (impressions, page views, installs, conversion -> .storebound/analytics) | compare (vs listing changes in git)'], + 'health': [() => import('./health'), 'crash / ANR vitals (Play) and diagnostics (App Store), read-only; --weekly writes a markdown report; exit 1 over a threshold'], + 'catalog': [() => import('./catalog'), 'diff: cross-store parity of products + subscriptions (missing / extra / mismatched, prices per region, offers); read-only, exit 1 on mismatches | pull [--write]: store texts of IAPs + subscriptions as a config proposal'], + 'reports': [() => import('./reports'), 'apple-sales | apple-finance --month | play-earnings --month | play-sales --month: download to .storebound/reports/, summary table + CSV; read-only'], + 'triage': [() => import('./triage'), 'TestFlight crash / screenshot feedback and Play error reports grouped by signature, device, OS version, build; read-only, --json'], + 'aso': [() => import('./aso'), 'rank [--storefronts us,de] [--keywords a,b]: App Store rank per keyword and storefront + competitors from the public iTunes Search API (rate limited) -> .storebound/aso/'], + 'prices': [() => import('./prices'), 'export | import a CSV of product x store x region prices (diff first, asks before writing; Apple future-dated changes) | ppp --base (purchasing power price sheet, snapped to store price points)'], + 'ads apple': [() => import('./ads/apple'), 'Apple Ads (Search Ads): status | campaigns | report (spend, taps, installs, CPA per campaign / keyword, --csv); bid | budget | pause (dry run, asks first; never via MCP)'], + 'web': [() => import('./web'), 'init (apple-app-site-association, assetlinks.json, Smart App Banner tag, optional landing page) | check (live files: content type, no redirects, ids match)'], + 'revenuecat': [() => import('./revenuecat'), 'diff (catalog vs RevenueCat products, entitlements, default offering) | sync (dry run, asks first; never via MCP)'], + 'console fill': [() => import('./console/fill'), '
[--store apple|play]: AI-assisted autofill of console forms without an API in a visible Chromium you sign in to yourself; stops before Save / Submit'], + 'reviews': [() => import('./reviews'), 'list | draft (local reply drafts in .storebound/replies) | send (approved drafts only, asks first)'], + 'originality': [() => import('./originality'), 'Guideline 4.3 check vs your other apps (--against ): listing text, name, icon and screenshot perceptual hashes, project structure; scores, flags, suggestions; offline, exit 1 on a near-duplicate'], + 'listing': [() => import('./listing'), 'translate --to de-DE,ja [--from en-US] [--translate ""]: listing translation drafts per language (App Store name, subtitle, promo text, keywords, description; Play title, short, full) with store limits and keyword rules, marked until reviewed | check | reviewed --lang ; local files only'], + 'whats-new': [() => import('./whats-new'), 'draft user-facing release notes from git log into the listing files (--since ); --languages a,b: one file per language to translate | check | apply'], + 'play products': [() => import('./play/products'), 'one-time products: create / update, regional prices, activate'], + 'play subscriptions': [() => import('./play/subscriptions'), 'auto-renewable subscriptions: listings, base plan, regional prices, intro offer, activate (--csv prices sheet; asks first)'], + 'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language; pull [--write]: live listings back into the listing file (diff first)'], + 'play images': [() => import('./play/images'), 'icon, feature graphic, phone / 7" / 10" screenshots per language; --variant '], + 'play data-safety': [() => import('./play/data-safety'), 'Data safety form (CSV import through the API)'], + 'play release': [() => import('./play/release'), 'upload an AAB and put it on tracks with release notes'], + 'play build': [() => import('./play/build'), 'gradle bundleRelease (Flutter: flutter build appbundle) with the next free versionCode and the upload key from env / .storebound; --dry'], + 'play upload': [() => import('./play/upload'), 'upload an AAB to a testing track (--track internal|alpha|beta), versionCode checked first; --dry read-only, asks first'], + 'play status': [() => import('./play/status'), 'tracks, listings, products (read-only)'], + 'play rollout': [() => import('./play/rollout'), 'staged rollout: --fraction x | --halt | --resume | --complete (asks first)'], + 'play share': [() => import('./play/share'), 'internal app sharing: upload an AAB / APK, print the share link (asks first; --dry)'], + 'play next-version-code': [() => import('./play/next-version-code'), 'next free versionCode (prints the number)'], + 'apple bundle': [() => import('./apple/bundle'), 'register the bundle id; finds the app record'], + 'apple iap': [() => import('./apple/iap'), 'in-app purchases, localizations, price schedules, availability'], + 'apple subscriptions': [() => import('./apple/subscriptions'), 'subscription groups, subscriptions, localizations, prices (equalized + overrides + --csv), intro offers, availability, review screenshot (asks first)'], + 'apple iap-review': [() => import('./apple/iap-review'), 'IAP review screenshots + product states'], + 'apple iap-submit': [() => import('./apple/iap-submit'), 'IAP + subscription versions into a review submission (first of a type: --with-version), then submit (asks first; --no-submit keeps a draft)'], + 'apple offer-codes': [() => import('./apple/offer-codes'), 'offer codes for one-time purchases (campaigns; custom and one-time-use codes with --codes, asks first)'], + 'apple win-back': [() => import('./apple/win-back'), 'win-back offers for lapsed subscribers (asks first: they go live on their start date)'], + 'apple promoted': [() => import('./apple/promoted'), 'promoted in-app purchases on the product page: create, order, --enable (asks first)'], + 'apple preorder': [() => import('./apple/preorder'), 'status | enable --release-date | end: App Store pre-orders per territory (asks first)'], + 'apple cpp': [() => import('./apple/cpp'), 'custom product pages: list | create | upload --name | submit --name | visible --name (submit / visible ask first)'], + 'apple events': [() => import('./apple/events'), 'in-app events: list | create | upload --name | submit --name (submit asks first)'], + 'apple listing': [() => import('./apple/listing'), 'version, build, name / subtitle / description / keywords per locale; pull [--write]: live texts back into the listing file (diff first)'], + 'apple screenshots': [() => import('./apple/screenshots'), '6.9" + 6.5" (+ 13" iPad) screenshots per locale; --variant '], + 'apple appinfo': [() => import('./apple/appinfo'), 'categories, age rating, content rights, Free price, territories'], + 'apple review-details': [() => import('./apple/review-details'), 'App Review contact, demo account (from .storebound/, masked) + notes'], + 'apple status': [() => import('./apple/status'), 'versions, builds, IAPs, review submissions (--wait-review, --cancel-submission )'], + 'apple previews': [() => import('./apple/previews'), 'app preview videos per locale (MD5-idempotent, poster frame time code); --dry'], + 'apple release': [() => import('./apple/release'), 'phased release on|pause|resume|complete, --manual-release (asks first)'], + 'apple signing': [() => import('./apple/signing'), 'status | ensure: bundle id capabilities, distribution certificate (key kept in .storebound/signing), App Store profiles installed for Xcode; --dry, asks first'], + 'apple build': [() => import('./apple/build'), 'xcodebuild archive + exportArchive (ExportOptions.plist generated, next build number, API key signing); Capacitor, React Native, Flutter, Unity; --dry'], + 'apple upload': [() => import('./apple/upload'), 'upload an IPA (App Store Connect API build upload, or --via altool), build number checked, waits for processing; --dry, asks first'], + 'apple adhoc': [() => import('./apple/adhoc'), 'ad-hoc / release-testing: devices (list) | register (dry run, asks first) | options (ExportOptions.plist) | export --archive '], + 'apple next-build': [() => import('./apple/next-build'), 'next safe build number (prints the number)'], + 'apple encryption': [() => import('./apple/encryption'), 'export compliance answer for builds, from the config'], + 'apple ppo': [() => import('./apple/ppo'), 'Product Page Optimization: status | create --variant b | upload --variant b | start | stop (asks first)'], + 'apple testflight': [() => import('./apple/testflight'), 'TestFlight: status | groups | testers (CSV in .storebound/) | what-to-test --build N | info | distribute --build N --group g [--submit-review] | wait --build N | expire --keep N|--older-than D (asks)'], + 'icons': [() => import('./icons'), 'App Store / Play / web / adaptive / legacy launcher icons from one artwork'], + 'shots capture': [() => import('./shots/capture'), 'raw frames: --source web (playwright) | ios-sim (simctl) | android-emu (adb) | folder; --dry'], + 'shots fonts': [() => import('./shots/fonts'), 'download font subsets for the copy (CJK / Arabic / Cyrillic ...)'], + 'shots render': [() => import('./shots/render'), 'store screenshots + feature graphic in every size and language'], + 'shots jpeg': [() => import('./shots/jpeg'), 'JPEG q92 copies of the Play renders (4x faster uploads)'], + 'shots check': [() => import('./shots/check'), 'local store checks of the renders (size, alpha, counts, overflow) and folder frames; --variants, --json'], + 'shots record': [() => import('./shots/record'), 'app or gameplay clips for app previews: --source web (playwright video) | ios-sim (simctl recordVideo) | android-emu (screenrecord) | folder; --dry'], + 'shots video': [() => import('./shots/video'), 'App Store app previews (886x1920, 1200x1600) + YouTube promo video from the clips, captions, poster, store checks; --dry'], + 'shots gallery': [() => import('./shots/gallery'), 'review page /index.html: every language, size, scene and variant, issues highlighted'], +}; diff --git a/cli/data/flags.json b/cli/data/flags.json new file mode 100644 index 00000000..fd2bede2 --- /dev/null +++ b/cli/data/flags.json @@ -0,0 +1,1101 @@ +{ + "global": [ + "account", + "config", + "dry", + "force-unlock", + "help", + "json", + "only", + "verbose", + "yes" + ], + "commands": { + "ads": [ + "ios", + "plist" + ], + "ads apple": [ + "adgroup", + "all", + "bid", + "by", + "campaign", + "csv", + "daily", + "days", + "end", + "keyword", + "start" + ], + "analytics": [ + "days", + "dir", + "md", + "paths", + "store" + ], + "api": [ + "all-pages", + "body", + "out", + "param", + "search", + "store", + "upload" + ], + "apple adhoc": [ + "archive", + "csv", + "method", + "name", + "out", + "platform", + "plist", + "udid" + ], + "apple appinfo": [], + "apple build": [ + "build-number", + "configuration", + "keychain", + "no-install", + "out", + "project", + "scheme", + "version", + "workspace" + ], + "apple bundle": [ + "name" + ], + "apple cpp": [ + "include-drafts", + "jobs", + "name", + "off", + "src", + "variant", + "write" + ], + "apple encryption": [ + "build" + ], + "apple events": [ + "name" + ], + "apple iap": [], + "apple iap-review": [], + "apple iap-submit": [ + "new-version", + "no-submit", + "with-version" + ], + "apple listing": [ + "build", + "include-drafts", + "version", + "write" + ], + "apple next-build": [], + "apple offer-codes": [ + "all", + "base", + "ceiling", + "codes", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "update-bigmac", + "with-automatic" + ], + "apple ppo": [ + "experiment", + "include-drafts", + "jobs", + "name", + "src", + "traffic", + "variant", + "write" + ], + "apple preorder": [ + "release-date", + "territories" + ], + "apple previews": [ + "lang", + "no-captions", + "port", + "poster", + "seconds", + "src", + "target" + ], + "apple promoted": [ + "enable" + ], + "apple release": [ + "manual-release", + "phased", + "version" + ], + "apple review-details": [ + "contact-from" + ], + "apple screenshots": [ + "include-drafts", + "jobs", + "src", + "variant", + "write" + ], + "apple signing": [ + "keychain", + "no-install" + ], + "apple status": [ + "cancel-submission", + "timeout", + "version", + "wait-review" + ], + "apple subscriptions": [ + "all", + "base", + "ceiling", + "codes", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "update-bigmac", + "with-automatic" + ], + "apple testflight": [ + "build", + "csv", + "group", + "internal-only", + "invite", + "keep", + "locale", + "older-than", + "remove", + "submit-review", + "text", + "timeout", + "version" + ], + "apple upload": [ + "build", + "csv", + "group", + "internal-only", + "invite", + "keep", + "locale", + "no-wait", + "older-than", + "remove", + "submit-review", + "text", + "timeout", + "version", + "via" + ], + "apple win-back": [ + "all", + "base", + "ceiling", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "update-bigmac", + "with-automatic" + ], + "apps": [ + "icons", + "store" + ], + "aso": [ + "competitors", + "delay", + "keywords", + "limit", + "only-keywords", + "storefronts" + ], + "catalog": [ + "all", + "base", + "ceiling", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "threshold", + "update-bigmac", + "with-automatic", + "write" + ], + "check": [ + "aso", + "storefront" + ], + "console fill": [ + "cdp", + "chrome-profile", + "fresh-profile", + "profile", + "start-url", + "store" + ], + "desktop": [ + "channel", + "dir", + "download", + "format", + "no-folder" + ], + "doctor": [ + "dir" + ], + "flow": [ + "apply", + "from", + "resume" + ], + "health": [ + "apple", + "days", + "out", + "play", + "weekly" + ], + "icons": [], + "import": [ + "dir", + "out", + "profile" + ], + "init": [ + "dir", + "profile" + ], + "inspect": [ + "declarations", + "icon", + "listing-text", + "listings", + "render" + ], + "install": [ + "agent", + "command", + "dir", + "home", + "no-mcp", + "no-skills" + ], + "listing": [ + "all", + "force", + "from", + "lang", + "store", + "to", + "translate" + ], + "mcp": [], + "originality": [ + "against", + "threshold" + ], + "play build": [ + "dir", + "flavor", + "module", + "out", + "version-code", + "version-name" + ], + "play data-safety": [ + "csv" + ], + "play images": [ + "include-drafts", + "src", + "variant", + "write" + ], + "play listing": [ + "include-drafts", + "write" + ], + "play next-version-code": [], + "play products": [], + "play release": [ + "alpha", + "beta", + "fraction", + "include-drafts", + "internal", + "name", + "production", + "version-code", + "write" + ], + "play rollout": [ + "complete", + "fraction", + "halt", + "resume", + "track" + ], + "play share": [ + "aab", + "apk" + ], + "play status": [], + "play subscriptions": [ + "all", + "base", + "ceiling", + "codes", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "update-bigmac", + "with-automatic" + ], + "play upload": [ + "include-drafts", + "name", + "status", + "track", + "write" + ], + "prices": [ + "all", + "base", + "ceiling", + "csv", + "file", + "floor", + "no-subscriptions", + "offline", + "out", + "reconvert", + "source", + "store", + "update-bigmac", + "with-automatic" + ], + "privacy-manifest": [ + "ios", + "sdk-dirs" + ], + "release": [ + "all", + "app", + "apple", + "apply", + "apps", + "concurrency", + "force", + "merge", + "no-health", + "no-validate", + "offline", + "out", + "play", + "state", + "stdio", + "versions", + "workspace" + ], + "reports": [ + "csv", + "date", + "detail", + "frequency", + "month", + "out", + "region", + "type", + "vendor" + ], + "revenuecat": [ + "current" + ], + "reviews": [ + "all", + "days", + "dir", + "file", + "rating", + "store", + "text", + "unanswered", + "undo" + ], + "scan": [ + "against", + "capacitor", + "cordova", + "cordova-android", + "cordova-ios", + "dir", + "expo", + "flutter", + "godot", + "no-declarations", + "originality", + "react-native", + "store", + "threshold", + "unity", + "write" + ], + "serve": [ + "stdio" + ], + "shots capture": [ + "concurrency", + "device", + "force", + "keep-booted", + "lang", + "only-missing", + "source", + "src", + "variants" + ], + "shots check": [ + "lang", + "src", + "variants" + ], + "shots fonts": [], + "shots gallery": [ + "lang", + "no-variants", + "out", + "src" + ], + "shots jpeg": [ + "lang", + "q", + "src", + "variant", + "variants" + ], + "shots record": [ + "concurrency", + "device", + "force", + "keep-booted", + "lang", + "no-captions", + "only-missing", + "port", + "seconds", + "source", + "src", + "target", + "variants" + ], + "shots render": [ + "concurrency", + "lang", + "no-sheet", + "port", + "scenes", + "size", + "variant", + "variants" + ], + "shots video": [ + "lang", + "no-captions", + "port", + "seconds", + "target" + ], + "triage": [ + "apple", + "build", + "comments", + "days", + "issues", + "play" + ], + "validate": [ + "apple", + "capacitor", + "cordova", + "cordova-android", + "cordova-ios", + "days", + "expo", + "flutter", + "godot", + "include-drafts", + "jobs", + "lang", + "no-health", + "no-local", + "no-scan", + "out", + "play", + "react-native", + "src", + "unity", + "variant", + "variants", + "weekly", + "write" + ], + "web": [ + "base-url", + "landing", + "out", + "version-code" + ], + "whats-new": [ + "all", + "dir", + "force", + "hook", + "lang", + "languages", + "since", + "translate" + ], + "ws": [ + "aab", + "adgroup", + "against", + "agent", + "all", + "all-pages", + "alpha", + "apk", + "app", + "apple", + "apply", + "apps", + "archive", + "aso", + "base", + "base-url", + "beta", + "bid", + "body", + "build", + "build-number", + "by", + "campaign", + "cancel-submission", + "capacitor", + "cdp", + "ceiling", + "channel", + "chrome-profile", + "codes", + "command", + "comments", + "competitors", + "complete", + "concurrency", + "configuration", + "contact-from", + "cordova", + "cordova-android", + "cordova-ios", + "csv", + "current", + "daily", + "date", + "days", + "declarations", + "delay", + "detail", + "device", + "dir", + "download", + "enable", + "end", + "experiment", + "expo", + "file", + "flavor", + "floor", + "flutter", + "force", + "format", + "fraction", + "frequency", + "fresh-profile", + "from", + "godot", + "group", + "halt", + "home", + "hook", + "icon", + "icons", + "include-drafts", + "internal", + "internal-only", + "invite", + "ios", + "issues", + "jobs", + "keep", + "keep-booted", + "keychain", + "keyword", + "keywords", + "landing", + "lang", + "languages", + "limit", + "listing-text", + "listings", + "locale", + "manual-release", + "md", + "merge", + "method", + "module", + "month", + "name", + "new-version", + "no-captions", + "no-declarations", + "no-folder", + "no-health", + "no-install", + "no-local", + "no-mcp", + "no-scan", + "no-sheet", + "no-skills", + "no-submit", + "no-subscriptions", + "no-validate", + "no-variants", + "no-wait", + "off", + "offline", + "older-than", + "only-keywords", + "only-missing", + "originality", + "out", + "param", + "paths", + "phased", + "platform", + "play", + "plist", + "port", + "poster", + "production", + "profile", + "project", + "q", + "rating", + "react-native", + "reconvert", + "region", + "release-date", + "remove", + "render", + "resume", + "scenes", + "scheme", + "sdk-dirs", + "search", + "seconds", + "since", + "size", + "source", + "src", + "start", + "start-url", + "state", + "status", + "stdio", + "store", + "storefront", + "storefronts", + "submit-review", + "target", + "territories", + "text", + "threshold", + "timeout", + "to", + "track", + "traffic", + "translate", + "type", + "udid", + "unanswered", + "undo", + "unity", + "update-bigmac", + "upload", + "variant", + "variants", + "vendor", + "version", + "version-code", + "version-name", + "versions", + "via", + "wait-review", + "weekly", + "with-automatic", + "with-version", + "workspace", + "write" + ] + }, + "usage": { + "ads": [ + "storebound ads scan --ios ios/App [--plist path/to/Info.plist] [--dry] [--json]" + ], + "ads apple": [ + "storebound ads apple status [--json] token works?, ad accounts and roles (GET /v1/acls), the one used", + "storebound ads apple campaigns [--all] [--json] App Store campaigns: status, daily budget, countries, adamId", + "storebound ads apple report [--days 7 | --start YYYY-MM-DD --end YYYY-MM-DD] [--by campaign|keyword] [--campaign ]", + "storebound ads apple bid --keyword --bid [--campaign ] [--adgroup ] [--dry] [--yes]", + "storebound ads apple budget --campaign --daily [--dry] [--yes]", + "storebound ads apple pause --campaign [--adgroup ] [--dry] [--yes]" + ], + "analytics": [ + "storebound analytics setup [--dry] App Store: create the ONGOING analytics report request (Admin key; once)", + "storebound analytics snapshot [--days 28] [--store apple|play] [--dry] -> .storebound/analytics/.json", + "storebound analytics compare [--days 7] [--paths store,storebound.config.ts] [--md]" + ], + "api": [ + "storebound api list [--store apple|play] [--search text] [--json]", + "storebound api coverage [--store apple|play] [--json]", + "storebound api apple|play [--param k=v ...] [--body file.json] [--upload file]", + "storebound api get apple|play ... GET only (what the MCP tool api_get runs)" + ], + "apple adhoc": [ + "storebound apple adhoc devices [--platform IOS|MAC_OS] [--json] registered devices, UDIDs masked", + "storebound apple adhoc register [--csv .storebound/devices.csv] [--name n --udid u --platform IOS] [--dry] [--yes]", + "storebound apple adhoc profile [--name \"\"] [--dry] [--yes] IOS_APP_ADHOC profile with every enabled iOS device", + "storebound apple adhoc options [--method release-testing|ad-hoc] [--out build/ExportOptions.plist] [--dry]", + "storebound apple adhoc export --archive [--plist build/ExportOptions.plist] [--out build/adhoc] [--dry]" + ], + "apple appinfo": [ + "storebound apple appinfo [--dry] [--json]" + ], + "apple build": [ + "storebound apple build [--version 1.2.0] [--build-number N] [--scheme S] [--workspace W | --project P]" + ], + "apple bundle": [ + "storebound apple bundle [--name \"My App\"] [--dry]" + ], + "apple cpp": [ + "storebound apple cpp list [--json]", + "storebound apple cpp create [--name \"...\"] [--dry] [--json] pages missing on App Store Connect + localizations", + "storebound apple cpp upload --name \"...\" [--only en-US,tr] [--src store/renders] [--dry] screenshots (the page's variant)", + "storebound apple cpp submit --name \"...\" [--dry] [--yes] into a review submission (the owner's step; asks)", + "storebound apple cpp visible --name \"...\" [--off] [--dry] [--yes] show / hide an approved page (asks)" + ], + "apple encryption": [ + "storebound apple encryption [--build 42] [--dry]" + ], + "apple events": [ + "storebound apple events list [--json]", + "storebound apple events create [--name \"\"] [--dry] [--json] missing events + localizations", + "storebound apple events upload --name \"...\" [--dry] event card (16:9) + details page (9:16) images per locale", + "storebound apple events submit --name \"...\" [--dry] [--yes] into a review submission (the owner's step; asks)" + ], + "apple iap": [ + "storebound apple iap [--dry] [--only id1,id2]" + ], + "apple iap-review": [ + "storebound apple iap-review [--dry]" + ], + "apple iap-submit": [ + "storebound apple iap-submit [--only id1,id2] [--with-version] [--new-version] [--no-submit] [--dry] [--yes] [--json]" + ], + "apple listing": [ + "storebound apple listing --version 1.0.0 [--build 3] [--include-drafts] [--dry] [--json]", + "storebound apple listing pull [--version x.y.z] [--write] [--json]" + ], + "apple next-build": [ + "storebound apple next-build -> 42" + ], + "apple offer-codes": [ + "storebound apple offer-codes [--only id1,id2] [--codes] [--dry] [--yes] [--json]" + ], + "apple ppo": [ + "storebound apple ppo status [--json]", + "storebound apple ppo create --variant b[,c] [--name \"...\"] [--traffic 30] [--dry]", + "storebound apple ppo upload --variant b [--experiment \"...\"] [--only en-US,tr] [--src store/renders] [--dry]", + "storebound apple ppo start | stop [--experiment \"...\"] [--dry] [--yes]" + ], + "apple preorder": [ + "storebound apple preorder status [--json]", + "storebound apple preorder enable --release-date YYYY-MM-DD [--territories USA,DEU] [--dry] [--yes] [--json]", + "storebound apple preorder end [--territories USA,DEU] [--dry] [--yes] [--json]" + ], + "apple previews": [ + "storebound apple previews [--src store/renders] [--only en-US,tr] [--poster 5] [--dry]" + ], + "apple promoted": [ + "storebound apple promoted [--enable] [--dry] [--yes] [--json]" + ], + "apple release": [ + "storebound apple release --phased on|pause|resume|complete [--version 1.2.0] [--dry] [--yes]", + "storebound apple release --manual-release [--version 1.2.0] [--yes]" + ], + "apple review-details": [ + "storebound apple review-details [--contact-from ] [--dry]" + ], + "apple screenshots": [ + "storebound apple screenshots [--src store/renders] [--only en-US,tr] [--jobs 4] [--variant b] [--dry]" + ], + "apple signing": [ + "storebound apple signing status [--json] read-only: capabilities, certificates (with / without a", + "storebound apple signing ensure [--dry] [--yes] [--keychain [path]] [--no-install] [--json]" + ], + "apple status": [ + "storebound apple status [--json]", + "storebound apple status --cancel-submission [--yes]", + "storebound apple status --wait-review [--version 1.2.0] [--timeout 48h]" + ], + "apple subscriptions": [ + "storebound apple subscriptions [--dry] [--only id1,id2] [--csv store/prices.csv] [--codes] [--yes]" + ], + "apple testflight": [ + "storebound apple testflight status [--json] groups, testers per group, recent builds + beta states", + "storebound apple testflight groups [--dry] create the groups of apple.testflight.groups that are missing", + "storebound apple testflight testers [--csv f] [--group a,b] [--remove] [--invite] [--dry] [--yes]", + "storebound apple testflight what-to-test --build N [--version x.y.z] [--locale en-US,tr] [--text \"...\"] [--dry]", + "storebound apple testflight info [--dry] Test Information + Beta App Review contact / notes", + "storebound apple testflight distribute --build N --group a,b [--version x.y.z] [--internal-only] [--submit-review] [--dry] [--yes]", + "storebound apple testflight wait --build N [--version x.y.z] [--timeout 60m] [--dry] [--json] until processing ends", + "storebound apple testflight expire (--keep N | --older-than D) [--version x.y.z] [--dry] [--yes] [--json]" + ], + "apple upload": [ + "storebound apple upload [] [--via api|altool] [--no-wait] [--timeout 60m] [--dry] [--yes] [--json]" + ], + "apple win-back": [ + "storebound apple win-back [--only sub1,sub2] [--dry] [--yes] [--json]" + ], + "apps": [ + "storebound apps list [--store apple|play] [--icons] [--json] every app the key can see (App Store Connect team /", + "storebound apps check [--store apple|play] [--json] auth OK / permission missing / key revoked, with the fix" + ], + "aso": [ + "storebound aso rank [--storefronts us,de=de-DE] [--keywords \"a,b\"] [--only-keywords] [--competitors 3] [--limit 200]" + ], + "catalog": [ + "storebound catalog diff [--store apple|play] [--threshold 10] [--json]", + "storebound catalog pull [--store apple|play] [--write] [--json]" + ], + "check": [ + "storebound check everything above", + "storebound check --aso keyword audit of both listing files (App Store keyword field, Play stuffing); exit 1 on errors" + ], + "console fill": [ + "storebound console fill lists the forms", + "storebound console fill --dry [--json] the answers and the step-by-step guidance; opens no browser", + "storebound console fill [--store apple|play] [--json] [--profile ]" + ], + "desktop": [ + "storebound desktop open the app; in an app folder (storebound.config.*) it adds or selects that", + "storebound desktop --dir the same for another folder; --no-folder: just open the app", + "storebound desktop --download not installed: download the installer for this system into ~/Downloads," + ], + "doctor": [ + "storebound doctor [--dir .] [--json]" + ], + "flow": [ + "storebound flow list [--json] the flows of this project and their steps", + "storebound flow validate [--json] definitions, sub-flow cycles, commands, variables; exit 1 on a problem", + "storebound flow run [NAME=value ...] [--dry | --apply] [--from | --resume] [--json]" + ], + "health": [ + "storebound health [--apple] [--play] [--days 7] [--json]", + "storebound health --weekly [--out .storebound/health] [--dry] also writes .md (+ .json for the next" + ], + "icons": [ + "storebound icons [--dry]" + ], + "import": [ + "storebound import fastlane [--dir [,]] [--out ] [--profile app|game|subscription-app] [--dry]" + ], + "init": [ + "storebound init [--dir .] [--profile app|game|subscription-app] [--dry]" + ], + "inspect": [ + "storebound inspect [--json]", + "storebound inspect --icon --json the app icon as a data: URL (for the desktop app)", + "storebound inspect --listings [--json] listing completeness per language on both stores (+ rendered screenshots)", + "storebound inspect --listing-text --json the listing files as they are (desktop export)", + "storebound inspect --declarations [--json] Data safety, App Privacy, app info, export compliance and App Review", + "storebound inspect --render --json one render (relative to the renders folder) as a data: URL" + ], + "install": [ + "storebound install --agent claude|codex|cursor|copilot|windsurf|gemini|opencode[,...] [--dir .] [--dry]" + ], + "listing": [ + "storebound listing translate --to de-DE,ja [--from en-US] [--store apple|play] [--translate \"\"] [--force] [--dry] [--json]", + "storebound listing check [--json] limits, keyword rules, untranslated and draft sections; exit 1 on a problem", + "storebound listing reviewed --lang de-DE[,ja] | --all [--dry] a human read the draft: remove its marker" + ], + "originality": [ + "storebound originality [--against [,]] [--threshold 0.7] [--json]" + ], + "play build": [ + "storebound play build [--version-code N] [--version-name 1.2.0] [--flavor prod] [--dir android] [--module app]" + ], + "play data-safety": [ + "storebound play data-safety [--csv out.csv] [--dry]" + ], + "play images": [ + "storebound play images [--dry] [--only en-US,de-DE] [--src store/renders] [--variant b]" + ], + "play listing": [ + "storebound play listing [--dry] [--json] [--only en-US,de-DE] [--include-drafts]", + "storebound play listing pull [--write] [--json] live listings -> diff -> (with --write) the Play listing file" + ], + "play next-version-code": [ + "storebound play next-version-code -> 43" + ], + "play products": [ + "storebound play products [--dry] [--only id1,id2]" + ], + "play release": [ + "storebound play release app-release.aab [--internal completed] [--production draft] [--name \"1.0.0 (3)\"] [--dry]", + "storebound play release --version-code 3 --production draft" + ], + "play rollout": [ + "storebound play rollout --fraction 0.2 | --halt | --resume [--fraction 0.1] | --complete [--track production] [--dry] [--yes]" + ], + "play share": [ + "storebound play share --aab app.aab | --apk app.apk [--dry] [--yes] [--json]" + ], + "play status": [ + "storebound play status [--json]" + ], + "play subscriptions": [ + "storebound play subscriptions [--dry] [--only id1,id2] [--csv store/prices.csv] [--yes]" + ], + "play upload": [ + "storebound play upload [] [--track internal|alpha|beta] [--status completed|draft] [--name text] [--dry] [--yes] [--json]" + ], + "prices": [ + "storebound prices export [--out store/prices.csv] [--store apple|play] [--only ids] [--with-automatic] [--no-subscriptions] [--dry] [--json]", + "storebound prices import [--csv store/prices.csv] [--store apple|play] [--only ids] [--reconvert] [--all] [--dry] [--yes]", + "storebound prices ppp [--base ] [...] purchasing power price sheet (prices-ppp.ts)" + ], + "privacy-manifest": [ + "storebound privacy-manifest --ios ios/App [--sdk-dirs node_modules/@capacitor,node_modules/some-plugin] [--json]" + ], + "reports": [ + "storebound reports apple-sales [--type SALES] [--frequency DAILY|WEEKLY|MONTHLY|YEARLY] [--date ...] [--vendor N]", + "storebound reports apple-finance --month YYYY-MM [--detail] [--region ZZ] [--vendor N]", + "storebound reports play-earnings --month YYYY-MM", + "storebound reports play-sales --month YYYY-MM" + ], + "revenuecat": [ + "storebound revenuecat diff [--json] read-only parity report; exit 1 when out of sync", + "storebound revenuecat sync [--dry] [--yes] [--current] [--json]" + ], + "reviews": [ + "storebound reviews list [--store apple|play] [--days 14] [--unanswered] [--rating 1,2] [--json]", + "storebound reviews draft [--store apple|play] [--days 14] [--rating 1,2,3] [--all] [--dir .storebound/replies] [--dry]", + "storebound reviews send [--dir .storebound/replies] [--dry] [--yes]", + "storebound reviews drafts [--json] the local drafts with the checks `send` applies (offline)", + "storebound reviews approve [--undo] [--dry] sets approved: true (false) in one draft (local file)", + "storebound reviews reply --text \"...\" [--dry] writes the reply of one draft (local file; approval reset)", + "storebound reviews send --file ... sends that one approved draft only" + ], + "scan": [ + "storebound scan [--dir ] [--config ] [--store apple|play] [--json] [--no-declarations]", + "storebound scan --write also write the detected dataSafety / appPrivacy answers into the config", + "storebound scan --originality [--against ] [--threshold 0.7] also the 4.3 / Play repetitive content" + ], + "shots capture": [ + "storebound shots capture [--lang en,tr] [--only hero,shop] [--device phone|tablet] [--source web|ios-sim|android-emu|folder]" + ], + "shots check": [ + "storebound shots check [--lang en,tr] [--variants] [--json]" + ], + "shots fonts": [ + "storebound shots fonts [--json] (re-run after editing the copy or the fonts)" + ], + "shots gallery": [ + "storebound shots gallery [--lang en,tr] [--src store/renders] [--out ] [--no-variants] [--json]" + ], + "shots jpeg": [ + "storebound shots jpeg [--q 92] [--lang en,tr] [--variant b | --variants]" + ], + "shots record": [ + "storebound shots record [--lang en,tr] [--only intro,combo] [--source web|ios-sim|android-emu|folder] [--dry] [--keep-booted]" + ], + "shots render": [ + "storebound shots render [--lang en,tr] [--size ios69,play,feature] [--scenes hero,battle] [--variant b | --variants]" + ], + "shots video": [ + "storebound shots video [--lang en,tr] [--target iphone,ipad,youtube] [--seconds 25] [--no-captions] [--dry]" + ], + "triage": [ + "storebound triage [--apple] [--play] [--days 14] [--build N] [--issues 10] [--comments 3] [--dry] [--json]" + ], + "validate": [ + "storebound validate [--apple] [--play] [--json] [--src store/renders] [--no-local] [--no-health] [--no-scan]" + ], + "web": [ + "storebound web init [--out web] [--landing] [--version-code N] [--dry] [--json]", + "storebound web check [] [--json] read-only, no credentials: the live files on https://" + ], + "whats-new": [ + "storebound whats-new [--since v1.1.0] [--lang en-US] [--all] [--hook \"text\"] [--dry]", + "storebound whats-new --languages en-US,de-DE,tr [--dir store/whats-new] [--translate \"\"] [--force] [--dry] [--json]", + "storebound whats-new check [--dir store/whats-new] [--json] limits per store (Play 500, App Store 4000), untranslated files", + "storebound whats-new apply [--dir store/whats-new] [--dry] [--json] checked files -> both listing files" + ] + } +} diff --git a/cli/index.ts b/cli/index.ts index 68c01311..b67b4678 100755 --- a/cli/index.ts +++ b/cli/index.ts @@ -1,114 +1,50 @@ #!/usr/bin/env bun // storebound: ship a mobile app or game to Google Play and the App Store from the terminal. // Run `storebound help` for the command list. Config: storebound.config.ts; credentials: env or .storebound/. +// `--help` / `-h` anywhere prints the usage of the command (or of a group like `storebound shots`) and exits 0 before +// anything loads; an unknown --flag (cli/data/flags.json, tools/gen-flags.ts) exits 2 with the usage, also before. import { parseArgs } from './lib/args'; import { toolPath } from './lib/tools'; -import { loadConfig } from './lib/config'; -import type { Ctx } from './lib/ctx'; +import { COMMANDS, PLAIN } from './commands'; +import FLAGS from './data/flags.json'; -type Mod = { run(ctx: Ctx): Promise }; -type Plain = { run(args: ReturnType): Promise }; -/** Commands that work without a storebound.config.ts. */ -const PLAIN: Record Promise, string]> = { - 'init': [() => import('./init'), 'copy the templates (config, listing, copy, declarations, privacy policy) into this project; --profile app|game|subscription-app (default app)'], - 'import': [() => import('./import'), 'fastlane [--dir fastlane] [--profile app|game|subscription-app] [--dry]: Appfile, deliver + supply metadata and screenshots -> config, store/*.md, shots frames (read-only on fastlane, never overwrites)'], - 'install': [() => import('./install'), 'skills + MCP server for --agent claude|codex|cursor|copilot|windsurf|gemini|opencode'], - 'mcp': [async () => ({ run: async () => (await import('./mcp')).serve() }), 'stdio MCP server wrapping these commands (for any MCP-capable AI tool)'], - 'serve': [() => import('./serve'), '--stdio: JSON-RPC session for the storebound desktop app (dry runs; writes need a host confirm token)'], - 'apps': [() => import('./apps'), 'list (every app the store keys can see: App Store Connect team, Play developer accounts; --icons) | check (key works / permission missing / revoked, with the fix); --store apple|play, --json; read-only'], - 'desktop': [() => import('./desktop'), 'open the storebound desktop app (in an app folder: add or select it there); not installed: the download for this system, --download saves it to ~/Downloads after checking its signature (never installs)'], - 'doctor': [() => import('./doctor'), 'local tools for screenshots, previews, icons and captures (ffmpeg, Chrome, playwright, Xcode, adb, git) and how to install what is missing; --json'], - 'scan': [() => import('./scan'), 'offline, read-only rejection-risk scan of the project itself (stack, SDKs, Info.plist, manifest, listings) with guideline, evidence file:line, fix and skill, plus the Data safety / App Privacy / ATT / privacy manifest proposal; --write puts the detected answers into the config; --json; exit 1 on blockers'], - 'api': [() => import('./api'), 'every App Store Connect / Google Play API operation: list | coverage | apple|play [--param k=v] [--body f.json] [--all-pages] (GET runs; writes dry unless --yes in a terminal; owner-only ones need the id typed)'], - 'privacy-manifest': [() => import('./privacy-manifest'), 'iOS PrivacyInfo.xcprivacy + required-reason API + SDK manifest scan (--ios )'], - 'ws': [() => import('./workspace'), 'many apps and studios (storebound.workspace.json): init | list | status (apps x stores, parallel) | check | validate | run --apps a,b|--all (writes dry unless --apply) | apps import --account | desktop export|import'], - 'release': [() => import('./release'), 'status [--app a,b] [--versions]: both stores on one train per version (build > testing > review > live > rollout %) | plan : what is left on each store, in fix order; read-only, --json'], - 'flow': [() => import('./flow'), 'repo-local workflows (store/workflows/*.yml, storebound.workflows.*): list | validate | run [NAME=value] [--dry plan only | --apply] [--from | --resume]; writes run as dry runs unless --apply, owner steps (submit, release, rollout) are never run'], - 'ads': [() => import('./ads'), 'scan --ios : AdAttributionKit / SKAdNetwork checks of Info.plist (network ids, postback copy endpoints, attribution windows, cooldown) and sources; --json'], -}; -const COMMANDS: Record Promise, string]> = { - 'inspect': [() => import('./inspect'), 'offline summary of the config (name, store ids, languages, products, subscriptions); --json'], - 'check': [() => import('./check'), 'validate config, copy files, data safety answers, products, subscriptions and the app profile (offline); --aso keyword audit'], - 'validate': [() => import('./validate'), 'read-only store readiness report with ordered blockers (--apple / --play), plus local renders checks (--no-local skips); exit 1 on blockers'], - 'analytics': [() => import('./analytics'), 'setup (App Store report request) | snapshot (impressions, page views, installs, conversion -> .storebound/analytics) | compare (vs listing changes in git)'], - 'health': [() => import('./health'), 'crash / ANR vitals (Play) and diagnostics (App Store), read-only; --weekly writes a markdown report; exit 1 over a threshold'], - 'catalog': [() => import('./catalog'), 'diff: cross-store parity of products + subscriptions (missing / extra / mismatched, prices per region, offers); read-only, exit 1 on mismatches | pull [--write]: store texts of IAPs + subscriptions as a config proposal'], - 'reports': [() => import('./reports'), 'apple-sales | apple-finance --month | play-earnings --month | play-sales --month: download to .storebound/reports/, summary table + CSV; read-only'], - 'triage': [() => import('./triage'), 'TestFlight crash / screenshot feedback and Play error reports grouped by signature, device, OS version, build; read-only, --json'], - 'aso': [() => import('./aso'), 'rank [--storefronts us,de] [--keywords a,b]: App Store rank per keyword and storefront + competitors from the public iTunes Search API (rate limited) -> .storebound/aso/'], - 'prices': [() => import('./prices'), 'export | import a CSV of product x store x region prices (diff first, asks before writing; Apple future-dated changes) | ppp --base (purchasing power price sheet, snapped to store price points)'], - 'ads apple': [() => import('./ads/apple'), 'Apple Ads (Search Ads): status | campaigns | report (spend, taps, installs, CPA per campaign / keyword, --csv); bid | budget | pause (dry run, asks first; never via MCP)'], - 'web': [() => import('./web'), 'init (apple-app-site-association, assetlinks.json, Smart App Banner tag, optional landing page) | check (live files: content type, no redirects, ids match)'], - 'revenuecat': [() => import('./revenuecat'), 'diff (catalog vs RevenueCat products, entitlements, default offering) | sync (dry run, asks first; never via MCP)'], - 'console fill': [() => import('./console/fill'), ' [--store apple|play]: AI-assisted autofill of console forms without an API in a visible Chromium you sign in to yourself; stops before Save / Submit'], - 'reviews': [() => import('./reviews'), 'list | draft (local reply drafts in .storebound/replies) | send (approved drafts only, asks first)'], - 'originality': [() => import('./originality'), 'Guideline 4.3 check vs your other apps (--against ): listing text, name, icon and screenshot perceptual hashes, project structure; scores, flags, suggestions; offline, exit 1 on a near-duplicate'], - 'listing': [() => import('./listing'), 'translate --to de-DE,ja [--from en-US] [--translate ""]: listing translation drafts per language (App Store name, subtitle, promo text, keywords, description; Play title, short, full) with store limits and keyword rules, marked until reviewed | check | reviewed --lang ; local files only'], - 'whats-new': [() => import('./whats-new'), 'draft user-facing release notes from git log into the listing files (--since ); --languages a,b: one file per language to translate | check | apply'], - 'play products': [() => import('./play/products'), 'one-time products: create / update, regional prices, activate'], - 'play subscriptions': [() => import('./play/subscriptions'), 'auto-renewable subscriptions: listings, base plan, regional prices, intro offer, activate (--csv prices sheet; asks first)'], - 'play listing': [() => import('./play/listing'), 'app details + title / short / full description per language; pull [--write]: live listings back into the listing file (diff first)'], - 'play images': [() => import('./play/images'), 'icon, feature graphic, phone / 7" / 10" screenshots per language; --variant '], - 'play data-safety': [() => import('./play/data-safety'), 'Data safety form (CSV import through the API)'], - 'play release': [() => import('./play/release'), 'upload an AAB and put it on tracks with release notes'], - 'play build': [() => import('./play/build'), 'gradle bundleRelease (Flutter: flutter build appbundle) with the next free versionCode and the upload key from env / .storebound; --dry'], - 'play upload': [() => import('./play/upload'), 'upload an AAB to a testing track (--track internal|alpha|beta), versionCode checked first; --dry read-only, asks first'], - 'play status': [() => import('./play/status'), 'tracks, listings, products (read-only)'], - 'play rollout': [() => import('./play/rollout'), 'staged rollout: --fraction x | --halt | --resume | --complete (asks first)'], - 'play share': [() => import('./play/share'), 'internal app sharing: upload an AAB / APK, print the share link (asks first; --dry)'], - 'play next-version-code': [() => import('./play/next-version-code'), 'next free versionCode (prints the number)'], - 'apple bundle': [() => import('./apple/bundle'), 'register the bundle id; finds the app record'], - 'apple iap': [() => import('./apple/iap'), 'in-app purchases, localizations, price schedules, availability'], - 'apple subscriptions': [() => import('./apple/subscriptions'), 'subscription groups, subscriptions, localizations, prices (equalized + overrides + --csv), intro offers, availability, review screenshot (asks first)'], - 'apple iap-review': [() => import('./apple/iap-review'), 'IAP review screenshots + product states'], - 'apple iap-submit': [() => import('./apple/iap-submit'), 'IAP + subscription versions into a review submission (first of a type: --with-version), then submit (asks first; --no-submit keeps a draft)'], - 'apple offer-codes': [() => import('./apple/offer-codes'), 'offer codes for one-time purchases (campaigns; custom and one-time-use codes with --codes, asks first)'], - 'apple win-back': [() => import('./apple/win-back'), 'win-back offers for lapsed subscribers (asks first: they go live on their start date)'], - 'apple promoted': [() => import('./apple/promoted'), 'promoted in-app purchases on the product page: create, order, --enable (asks first)'], - 'apple preorder': [() => import('./apple/preorder'), 'status | enable --release-date | end: App Store pre-orders per territory (asks first)'], - 'apple cpp': [() => import('./apple/cpp'), 'custom product pages: list | create | upload --name | submit --name | visible --name (submit / visible ask first)'], - 'apple events': [() => import('./apple/events'), 'in-app events: list | create | upload --name | submit --name (submit asks first)'], - 'apple listing': [() => import('./apple/listing'), 'version, build, name / subtitle / description / keywords per locale; pull [--write]: live texts back into the listing file (diff first)'], - 'apple screenshots': [() => import('./apple/screenshots'), '6.9" + 6.5" (+ 13" iPad) screenshots per locale; --variant '], - 'apple appinfo': [() => import('./apple/appinfo'), 'categories, age rating, content rights, Free price, territories'], - 'apple review-details': [() => import('./apple/review-details'), 'App Review contact, demo account (from .storebound/, masked) + notes'], - 'apple status': [() => import('./apple/status'), 'versions, builds, IAPs, review submissions (--wait-review, --cancel-submission )'], - 'apple previews': [() => import('./apple/previews'), 'app preview videos per locale (MD5-idempotent, poster frame time code); --dry'], - 'apple release': [() => import('./apple/release'), 'phased release on|pause|resume|complete, --manual-release (asks first)'], - 'apple signing': [() => import('./apple/signing'), 'status | ensure: bundle id capabilities, distribution certificate (key kept in .storebound/signing), App Store profiles installed for Xcode; --dry, asks first'], - 'apple build': [() => import('./apple/build'), 'xcodebuild archive + exportArchive (ExportOptions.plist generated, next build number, API key signing); Capacitor, React Native, Flutter, Unity; --dry'], - 'apple upload': [() => import('./apple/upload'), 'upload an IPA (App Store Connect API build upload, or --via altool), build number checked, waits for processing; --dry, asks first'], - 'apple adhoc': [() => import('./apple/adhoc'), 'ad-hoc / release-testing: devices (list) | register (dry run, asks first) | options (ExportOptions.plist) | export --archive '], - 'apple next-build': [() => import('./apple/next-build'), 'next safe build number (prints the number)'], - 'apple encryption': [() => import('./apple/encryption'), 'export compliance answer for builds, from the config'], - 'apple ppo': [() => import('./apple/ppo'), 'Product Page Optimization: status | create --variant b | upload --variant b | start | stop (asks first)'], - 'apple testflight': [() => import('./apple/testflight'), 'TestFlight: status | groups | testers (CSV in .storebound/) | what-to-test --build N | info | distribute --build N --group g [--submit-review] | wait --build N | expire --keep N|--older-than D (asks)'], - 'icons': [() => import('./icons'), 'App Store / Play / web / adaptive / legacy launcher icons from one artwork'], - 'shots capture': [() => import('./shots/capture'), 'raw frames: --source web (playwright) | ios-sim (simctl) | android-emu (adb) | folder; --dry'], - 'shots fonts': [() => import('./shots/fonts'), 'download font subsets for the copy (CJK / Arabic / Cyrillic ...)'], - 'shots render': [() => import('./shots/render'), 'store screenshots + feature graphic in every size and language'], - 'shots jpeg': [() => import('./shots/jpeg'), 'JPEG q92 copies of the Play renders (4x faster uploads)'], - 'shots check': [() => import('./shots/check'), 'local store checks of the renders (size, alpha, counts, overflow) and folder frames; --variants, --json'], - 'shots record': [() => import('./shots/record'), 'app or gameplay clips for app previews: --source web (playwright video) | ios-sim (simctl recordVideo) | android-emu (screenrecord) | folder; --dry'], - 'shots video': [() => import('./shots/video'), 'App Store app previews (886x1920, 1200x1600) + YouTube promo video from the clips, captions, poster, store checks; --dry'], - 'shots gallery': [() => import('./shots/gallery'), 'review page /index.html: every language, size, scene and variant, issues highlighted'], -}; +const COMMON = 'common options: --config --dry (no writes) --only --yes (skip confirmations) --json --account (credential profile)'; +const line = ([k, d]: [string, string]): string => ` ${k.padEnd(25)} ${d}`; +const describe = (k: string): string => (PLAIN[k] ?? COMMANDS[k])![1]; function help(): void { console.log(`storebound · take mobile apps and games from nothing to Submit for review on Google Play and the App Store -usage: storebound [options] +usage: storebound [options] (storebound --help: its usage and options) -${Object.entries(PLAIN).map(([k, [, d]]) => ` ${k.padEnd(25)} ${d}`).join('\n')} -${Object.entries(COMMANDS).map(([k, [, d]]) => ` ${k.padEnd(25)} ${d}`).join('\n')} +${Object.entries(PLAIN).map(([k, [, d]]) => line([k, d])).join('\n')} +${Object.entries(COMMANDS).map(([k, [, d]]) => line([k, d])).join('\n')} -common options: --config --dry (no writes) --only --yes (skip confirmations) --account (credential profile) +${COMMON} credentials: PLAY_SERVICE_ACCOUNT, ASC_KEY_ID, ASC_ISSUER_ID, ASC_P8, ANDROID_KEYSTORE(_PASSWORD) / ANDROID_KEY_ALIAS / ANDROID_KEY_PASSWORD, REVIEW_DEMO_USER / REVIEW_DEMO_PASSWORD (env or .storebound/credentials.json); profiles for many accounts: ~/.storebound/credentials/.json (same names), picked with --account docs: README.md and the skills/ folder of the toolchain`); } +/** Usage of one command: its header usage lines (or the table line), description and accepted options. */ +function commandUsage(key: string): string { + const usage = (FLAGS.usage as Record)[key] ?? [`storebound ${key} [options]`]; + const flags = (FLAGS.commands as Record)[key] ?? []; + return [ + `usage: ${usage[0]}`, ...usage.slice(1).map(u => ` ${u}`), '', + ` ${describe(key)}`, '', + ...(key === 'ws' ? ['options: the options of the command it runs (ws run ...), plus --apps a,b | --all, --apply'] : flags.length ? [`options: ${flags.map(f => '--' + f).join(' ')}`] : []), + COMMON, + ].join('\n'); +} + +/** Usage of a command group (`storebound shots`): its commands. */ +const groupUsage = (g: string, keys: string[]): string => + `usage: storebound ${g} [options] (storebound ${g} --help: its usage and options)\n\n${keys.map(k => line([k, describe(k)])).join('\n')}\n\n${COMMON}`; + async function main(): Promise { + // tests (tests/cli-help.test.ts) run the CLI with STOREBOUND_NO_NETWORK=1: any request fails loudly + if (process.env.STOREBOUND_NO_NETWORK === '1') globalThis.fetch = (async (u: unknown) => { throw new Error(`network disabled (STOREBOUND_NO_NETWORK): ${String(u)}`); }) as unknown as typeof fetch; // tools (adb, emulator, ffmpeg…) are also looked up where they usually live, for apps started without a shell PATH process.env.PATH = toolPath(process.env); const argv = process.argv.slice(2); @@ -125,10 +61,27 @@ async function main(): Promise { const [a, b] = argv; if (!a || a === 'help' || a === '--help' || a === '-h') return help(); if (a === 'version' || a === '--version') return console.log((await import('../package.json')).version); - if (PLAIN[a]) return (await PLAIN[a]![0]()).run(parseArgs(argv.slice(1))); - const key = COMMANDS[`${a} ${b}`] ? `${a} ${b}` : COMMANDS[a] ? a : ''; - if (!key) { console.error(`unknown command: ${argv.slice(0, 2).join(' ')}\n`); help(); process.exit(2); } - const args = parseArgs(argv.slice(key.split(' ').length)); + const known = (k: string): boolean => !!(PLAIN[k] ?? COMMANDS[k]); + const key = known(`${a} ${b}`) ? `${a} ${b}` : known(a) ? a : ''; + const group = Object.keys({ ...PLAIN, ...COMMANDS }).filter(k => k.startsWith(a + ' ')); + if (argv.includes('--help') || argv.includes('-h')) { + if (key) return console.log(commandUsage(key)); + if (group.length) return console.log(groupUsage(a, group)); + } + if (!key) { + if (group.length) { console.error(`${b ? `unknown command: ${a} ${b}` : `storebound ${a}: which command?`}\n\n${groupUsage(a, group)}`); process.exit(2); } + console.error(`unknown command: ${argv.slice(0, 2).join(' ')}\n`); help(); process.exit(2); + } + const rest = argv.slice(key.split(' ').length); + const accepted = (FLAGS.commands as Record)[key]; + if (accepted) { + const ok = new Set([...FLAGS.global, ...accepted]); + const bad = [...new Set(rest.filter(x => /^--[^-]/.test(x)).map(x => x.slice(2).split('=')[0]!).filter(f => !ok.has(f)))]; + if (bad.length) { console.error(`unknown option${bad.length > 1 ? 's' : ''} for storebound ${key}: ${bad.map(f => '--' + f).join(', ')}\n\n${commandUsage(key)}`); process.exit(2); } + } + if (PLAIN[key]) return (await PLAIN[key]![0]()).run(parseArgs(rest)); + const args = parseArgs(rest); + const { loadConfig } = await import('./lib/config'); const loaded = await loadConfig(args.get('config')); // one writer per app and store (cli/lib/lock.ts): dry runs and reads take no lock const { acquireLock, lockKeys } = await import('./lib/lock'); diff --git a/cli/shots/glyphs.ts b/cli/shots/glyphs.ts index 63f0fb2e..ae97f537 100644 --- a/cli/shots/glyphs.ts +++ b/cli/shots/glyphs.ts @@ -252,7 +252,9 @@ export const COLLECT_TEXT = `(ours) => { box.style.cssText = 'position:absolute;left:-20000px;top:0;white-space:pre'; for (const p of probes) { const s = document.createElement('span'); - s.style.cssText = 'font-size:32px;font-family:"' + p.face.replace(/"/g, '') + '";font-weight:' + p.weight + ';font-style:' + p.style; + // display:block: one character per line box. Inline probe spans side by side are shaped as one run, so "f" + "i" + // became the fi ligature, the "i" span reported no glyph of ours and was blamed on a system font. + s.style.cssText = 'display:block;font-size:32px;font-family:"' + p.face.replace(/"/g, '') + '";font-weight:' + p.weight + ';font-style:' + p.style; s.textContent = p.ch; box.append(s); } diff --git a/cli/shots/render.ts b/cli/shots/render.ts index d7b26dbb..557bf850 100644 --- a/cli/shots/render.ts +++ b/cli/shots/render.ts @@ -1,5 +1,5 @@ // Store screenshots + Play feature graphic at exact pixel sizes, from raw app or game frames and per-language copy. -// storebound shots render [--lang en,tr] [--size ios69,play,feature] [--scenes 1,3] [--variant b | --variants] +// storebound shots render [--lang en,tr] [--size ios69,play,feature] [--scenes hero,battle] [--variant b | --variants] // [--no-sheet] [--port 8792] [--concurrency N] [--dry] // Out: ///NN.png (24-bit RGB: Play rejects alpha / palette PNGs), /feature/1024x500.png, // /sheet.png (contact sheet of every size packed into a grid, for a quick review) and /report.json (text overflow flags @@ -48,6 +48,10 @@ export async function run(ctx: Ctx): Promise { if (problems.length) throw new Error(`shots copy${v ? ` (variant ${v})` : ''}:\n ` + problems.join('\n ')); jobs.set(v ?? '', { scenes, copy }); } + for (const [v, job] of jobs) { + const bad = a.list('scenes').filter(id => !job.scenes.some(s => s.id === id)); + if (bad.length) throw new Error(`--scenes: unknown scene id${bad.length > 1 ? 's' : ''} ${bad.join(', ')}${v ? ` (variant ${v})` : ''}; scene ids: ${job.scenes.map(s => s.id).join(', ')}`); + } const framesDir = resolve(shots.frames), outDir = resolve(shots.out); if (a.has('dry')) { let n = 0; diff --git a/tests/cli-help.test.ts b/tests/cli-help.test.ts new file mode 100644 index 00000000..c2de2263 --- /dev/null +++ b/tests/cli-help.test.ts @@ -0,0 +1,111 @@ +// `--help` / `-h` on every command and command group prints the usage and exits 0 before anything runs (no config +// load, no render, no browser, no store call); an unknown --flag exits 2 with the usage, also before anything runs. +// Each command is spawned for real with an empty working folder, a temp HOME, no credentials and +// STOREBOUND_NO_NETWORK=1 (cli/index.ts makes fetch throw), and the folders must stay empty. +// Also: cli/data/flags.json is fresh (tools/gen-flags.ts --check), and every option the MCP / desktop tool lists pass +// to a command is one that command accepts (else the strict flag check would break those tools). +import { afterAll, describe, expect, test } from 'bun:test'; +import { mkdtempSync, readdirSync, rmSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { COMMANDS, PLAIN } from '../cli/commands'; +import FLAGS from '../cli/data/flags.json'; +import { TOOLS } from '../cli/mcp-tools'; +import { DESKTOP_ONLY, OWNER_TOOLS } from '../cli/serve'; + +const ROOT = join(import.meta.dir, '..'); +const CLI = join(ROOT, 'cli', 'index.ts'); +const tmp: string[] = []; +const mk = (p: string): string => { const d = mkdtempSync(join(tmpdir(), p)); tmp.push(d); return d; }; +afterAll(() => { for (const d of tmp) rmSync(d, { recursive: true, force: true }); }); + +const env = (home: string): Record => { + const e: Record = {}; + for (const [k, v] of Object.entries(process.env)) if (v !== undefined && !/^(ASC_|PLAY_|ANDROID_KEY|REVIEW_DEMO|STOREBOUND_|APPLE_ADS|REVENUECAT|GOOGLE_)/.test(k)) e[k] = v; + // no transpiler cache: Bun would write it under the temp HOME (~/Library/Caches/bun) + return { ...e, HOME: home, STOREBOUND_NO_NETWORK: '1', NO_COLOR: '1', BUN_RUNTIME_TRANSPILER_CACHE_PATH: '0' }; +}; + +async function run(args: string[]): Promise<{ code: number; out: string; err: string; ms: number; cwd: string[]; home: string[] }> { + const cwd = mk('sb-help-cwd-'), home = mk('sb-help-home-'); + const t = Date.now(); + const p = Bun.spawn([process.execPath, CLI, ...args], { cwd, env: env(home), stdin: 'ignore', stdout: 'pipe', stderr: 'pipe' }); + const kill = setTimeout(() => p.kill(), 15_000); + const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited]); + clearTimeout(kill); + return { code, out, err, ms: Date.now() - t, cwd: readdirSync(cwd), home: readdirSync(home) }; +} + +const keys = [...Object.keys(PLAIN), ...Object.keys(COMMANDS)]; +const groups = [...new Set(keys.filter(k => k.includes(' ')).map(k => k.split(' ')[0]!))]; + +describe('cli --help', () => { + test('cli/data/flags.json is fresh', () => { + const r = Bun.spawnSync([process.execPath, join(ROOT, 'tools', 'gen-flags.ts'), '--check'], { cwd: ROOT, stdout: 'pipe', stderr: 'pipe' }); + expect(r.stderr.toString()).toBe(''); + expect(r.exitCode).toBe(0); + }); + + test('every command and group: usage on stdout, exit 0, fast, nothing written, no network', async () => { + const cases = [...keys.map(k => [...k.split(' '), '--help']), ...groups.map(g => [g, '--help']), ['shots', 'render', '-h'], ['shots', 'render', '--lang', 'en', '--help'], ['help'], ['--help']]; + const bad: string[] = []; + for (let i = 0; i < cases.length; i += 8) { + const rs = await Promise.all(cases.slice(i, i + 8).map(async c => ({ c, r: await run(c) }))); + for (const { c, r } of rs) { + const why = [ + r.code !== 0 && `exit ${r.code}`, + !/^(usage: |storebound )/.test(r.out) && `stdout ${JSON.stringify(r.out.slice(0, 80))}`, + r.err.trim() && `stderr ${JSON.stringify(r.err.slice(0, 200))}`, + r.ms > 5000 && `${r.ms} ms`, + r.cwd.length && `wrote ${r.cwd.join(', ')}`, + r.home.length && `wrote ~/${r.home.join(', ~/')}`, + ].filter(Boolean); + if (why.length) bad.push(`storebound ${c.join(' ')}: ${why.join('; ')}`); + } + } + expect(bad).toEqual([]); + }, 120_000); + + test('a command --help names its options; a group lists its commands', async () => { + const r = await run(['shots', 'render', '--help']); + expect(r.out).toContain('usage: storebound shots render'); + expect(r.out).toContain('--scenes'); + const g = await run(['shots', '--help']); + for (const k of keys.filter(k => k.startsWith('shots '))) expect(g.out).toContain(k); + }, 30_000); + + test('an unknown flag: exit 2 with the usage, before anything runs', async () => { + for (const c of [['shots', 'render', '--dyr'], ['doctor', '--jsno'], ['play', 'status', '--x=1']]) { + const r = await run(c); + expect(r.code).toBe(2); + expect(r.err).toContain(`unknown option for storebound ${c.slice(0, -1).join(' ')}: ${c.at(-1)!.split('=')[0]}`); + expect(r.err).toContain('usage: storebound'); + expect(r.cwd).toEqual([]); + expect(r.home).toEqual([]); + } + const g = await run(['shots']); + expect(g.code).toBe(2); + expect(g.err).toContain('storebound shots: which command?'); + }, 30_000); +}); + +describe('flag table vs the tool lists', () => { + test('every option an MCP or desktop tool passes is one its command accepts', () => { + const table = FLAGS.commands as Record; + const bad: string[] = []; + for (const t of [...TOOLS, ...DESKTOP_ONLY, ...OWNER_TOOLS]) { + const words = t.command.filter(w => !w.startsWith('--')); + const key = table[words.slice(0, 2).join(' ')] ? words.slice(0, 2).join(' ') : words[0]!; + const ok = new Set([...FLAGS.global, ...(table[key] ?? [])]); + if (!table[key]) { bad.push(`${t.name}: no command ${key}`); continue; } + const src = t.args?.toString() ?? ''; + const used = [ + ...t.command.filter(w => w.startsWith('--')).map(w => w.slice(2)), + ...[...src.matchAll(/'--([a-z][a-z0-9-]*)'/g)].map(m => m[1]!), + ...[...src.matchAll(/\b(?:opt|flag)\('([a-z][a-z0-9-]*)'/g)].map(m => m[1]!), + ]; + for (const f of used) if (!ok.has(f)) bad.push(`${t.name}: storebound ${key} --${f}`); + } + expect(bad).toEqual([]); + }); +}); diff --git a/tests/fixtures/fonts/Montserrat-OFL.txt b/tests/fixtures/fonts/Montserrat-OFL.txt new file mode 100644 index 00000000..fe576a2e --- /dev/null +++ b/tests/fixtures/fonts/Montserrat-OFL.txt @@ -0,0 +1,93 @@ +Copyright 2024 The Montserrat.Git Project Authors (https://github.com/JulietaUla/Montserrat.git) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/tests/fixtures/fonts/montserrat-text-subset.woff2 b/tests/fixtures/fonts/montserrat-text-subset.woff2 new file mode 100644 index 0000000000000000000000000000000000000000..192b1886f3956641eb1ea328169ee8f6719268c8 GIT binary patch literal 4728 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 G=2HM3;`#mn literal 0 HcmV?d00001 diff --git a/tests/glyph-ligatures.test.ts b/tests/glyph-ligatures.test.ts new file mode 100644 index 00000000..74b57355 --- /dev/null +++ b/tests/glyph-ligatures.test.ts @@ -0,0 +1,49 @@ +// Regression: ligatures must not read as system-font glyphs. STAR DASH's "Outfits, ..." caption failed `shots check` +// with `i drawn with a system font` although Montserrat drew every glyph: the per-character probe spans sat side by +// side, Chrome shaped "f" + "i" into the fi ligature across them and the lone "i" span reported no glyph of ours. +// The fixture is a real Google Fonts css2 `text=` subset of Montserrat (as `shots fonts` downloads it; OFL, see +// fixtures/fonts/Montserrat-OFL.txt); it keeps the GSUB ligatures (ff, fi, ffi). Skips when no Chromium can launch. +import { afterAll, describe, expect, test } from 'bun:test'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { measureFonts } from '../cli/shots/glyphs'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +let browser: any = null; +let skipWhy = ''; +try { + const { chromium } = await import('playwright-core'); + try { browser = await chromium.launch({ headless: true }); } catch { browser = await chromium.launch({ headless: true, channel: 'chrome' }); } +} catch (e) { skipWhy = (e as Error).message.split('\n')[0]!; } +if (!browser) console.warn(`glyph ligature test skipped: no Chromium could launch (${skipWhy}). Run \`bunx playwright install chromium\`.`); + +afterAll(async () => { await browser?.close(); }, 30_000); + +const font = readFileSync(join(import.meta.dir, 'fixtures', 'fonts', 'montserrat-text-subset.woff2')).toString('base64'); +const TEXT = 'Outfits, fit, office, affine'; + +describe.skipIf(!browser)('shots font usage: ligatures', () => { + for (const weight of [400, 600, 800]) test(`"${TEXT}" in a Montserrat text= subset, weight ${weight}: zero system-font glyphs`, async () => { + const page = await browser.newPage(); + try { + await page.setContent(` +

${TEXT}

mounts and vehicles
`); + await page.evaluate('document.fonts.ready.then(() => 0)'); + // the subset really ligates: the line has fewer glyphs than characters, all from our font + const cdp = await page.context().newCDPSession(page); + await cdp.send('DOM.enable'); await cdp.send('CSS.enable'); + const { root } = await cdp.send('DOM.getDocument', { depth: 0 }); + const { nodeId } = await cdp.send('DOM.querySelector', { nodeId: root.nodeId, selector: 'p' }); + const { fonts } = await cdp.send('CSS.getPlatformFontsForNode', { nodeId }) as { fonts: { isCustomFont: boolean; glyphCount: number }[] }; + await cdp.detach(); + expect(fonts.every(f => f.isCustomFont)).toBe(true); + expect(fonts.reduce((n, f) => n + f.glyphCount, 0)).toBeLessThan(TEXT.length); + + const measured = await measureFonts(page, ['Montserrat']); + expect(measured.map(m => m.el)).toEqual(['p.sub', 'div small']); + for (const m of measured) expect(Object.keys(m.faces)).toEqual(['Montserrat']); + expect(await page.evaluate("document.getElementById('sb-glyph-probes')")).toBeNull(); + } finally { await page.close(); } + }, 30_000); +}); diff --git a/tools/gen-flags.ts b/tools/gen-flags.ts new file mode 100644 index 00000000..ab9d3e2c --- /dev/null +++ b/tools/gen-flags.ts @@ -0,0 +1,105 @@ +#!/usr/bin/env bun +// Writes cli/data/flags.json: the --flags every command accepts, so the dispatcher (cli/index.ts) can reject an +// unknown flag (a typo like --dyr) with the usage before anything runs, also in the compiled sidecar (no sources). +// For each command in cli/commands.ts it follows the command module and every local module it imports (static and +// dynamic), and collects the literal flag reads: .has('name'), .get, .str, .num, .list, .many. Reads with a computed +// name are listed in DYNAMIC below (the scan fails on a new one until it is added there). `ws` forwards its flags to the +// command it runs, so it accepts every flag. GLOBAL flags work on every command. The usage lines of each module's +// header comment (`// storebound ...`) go along, for `storebound --help`. +// bun tools/gen-flags.ts write cli/data/flags.json +// bun tools/gen-flags.ts --check exit 1 when the file is stale (tests/cli-help.test.ts runs it) +import { existsSync, readFileSync, writeFileSync } from 'node:fs'; +import { dirname, join, relative, resolve } from 'node:path'; + +const ROOT = resolve(import.meta.dir, '..'); +const CLI = join(ROOT, 'cli'); +const OUT = join(CLI, 'data', 'flags.json'); + +/** Flags every command accepts (read by the dispatcher, lib/ctx, lib/lock, or harmless where unused). */ +export const GLOBAL = ['account', 'config', 'dry', 'force-unlock', 'help', 'json', 'only', 'verbose', 'yes']; +/** Computed flag reads, per file (relative to cli/): the flags they can read. */ +const DYNAMIC: Record = { + 'prices.ts': ['out', 'csv'], + 'play/rollout.ts': ['halt', 'resume', 'complete'], + 'play/release.ts': ['internal', 'alpha', 'beta', 'production'], + 'ads/apple.ts': ['adgroup', 'campaign', 'keyword'], + 'apple/subscriptions.ts': [], // a wrapper of ctx.args.has(n) (confirm without --yes) + 'lib/declarations.ts': [], // a.get(k) on a Map, not the args + 'lib/catalog.ts': [], // a.get(w.id) on a Map, not the args +}; +/** Commands that pass their flags on to another command. */ +const FORWARDS = new Set(['ws']); + +// the receiver is captured so HTTP headers and URL search params (res.headers.get('content-type')) are not flags +const READ = /([\w$.)\]]*)\.(?:has|get|str|num|list|many)\(\s*(['"])([a-z][a-z0-9-]*)\2/g; +const NOT_ARGS = /(?:headers|searchParams|params|url|env)$/i; +const COMPUTED = /\b(?:args|a|ctx\.args)\.(?:has|get|str|num|list|many)\(\s*(?![\s'"])/g; +const IMPORT = /(?:\bfrom\s+|\bimport\s*\(\s*)'(\.{1,2}\/[^']+)'/g; + +function file(spec: string, from: string): string | null { + const base = resolve(dirname(from), spec); + for (const f of [base, base + '.ts', join(base, 'index.ts')]) if (f.endsWith('.ts') && existsSync(f)) return f; + return null; +} + +function scan(entry: string, errors: string[]): Set { + const flags = new Set(), seen = new Set(), todo = [entry]; + while (todo.length) { + const f = todo.pop()!; + if (seen.has(f)) continue; + seen.add(f); + const rel = relative(CLI, f); + if (rel === 'index.ts' || rel === 'commands.ts') continue; + const src = readFileSync(f, 'utf8'); + for (const m of src.matchAll(READ)) if (!NOT_ARGS.test(m[1]!)) flags.add(m[3]!); + for (const fl of DYNAMIC[rel] ?? []) flags.add(fl); + if (!(rel in DYNAMIC)) for (const m of src.matchAll(COMPUTED)) { + const line = src.slice(0, m.index).split('\n').length; + errors.push(`cli/${rel}:${line}: flag read with a computed name; list the flags it can read in DYNAMIC (tools/gen-flags.ts)`); + } + for (const m of src.matchAll(IMPORT)) { const g = file(m[1]!, f); if (g && g.startsWith(CLI)) todo.push(g); } + } + return flags; +} + +/** The usage lines of a module's header comment: `// storebound ...`. */ +function usageLines(f: string, key: string): string[] { + const out: string[] = []; + for (const line of readFileSync(f, 'utf8').split('\n')) { + if (!line.startsWith('//')) break; + const m = /^\/\/\s+(storebound .*)$/.exec(line); + if (m && (m[1]! + ' ').startsWith(`storebound ${key} `)) out.push(m[1]!.trimEnd()); + } + return out; +} + +export function build(): { table: Record; usage: Record; errors: string[] } { + const src = readFileSync(join(CLI, 'commands.ts'), 'utf8'); + const errors: string[] = []; + const per: Record = {}, usage: Record = {}; + for (const m of src.matchAll(/^ {2}'([a-z][a-z0-9 -]*)': \[.*?import\('(\.\/[^']+)'\)/gm)) { + const f = file(m[2]!, join(CLI, 'commands.ts')); + if (!f) { errors.push(`${m[1]}: module ${m[2]} not found`); continue; } + per[m[1]!] = [...scan(f, errors)].filter(x => !GLOBAL.includes(x)).sort(); + const u = usageLines(f, m[1]!); + if (u.length) usage[m[1]!] = u; + } + const all = [...new Set(Object.values(per).flat())].sort(); + for (const k of FORWARDS) if (per[k]) per[k] = all; + const table = Object.fromEntries(Object.keys(per).sort().map(k => [k, per[k]!])); + return { table, usage: Object.fromEntries(Object.keys(usage).sort().map(k => [k, usage[k]!])), errors: [...new Set(errors)] }; +} + +if (import.meta.main) { + const { table, usage, errors } = build(); + if (errors.length) { console.error(errors.join('\n')); process.exit(1); } + const text = JSON.stringify({ global: GLOBAL, commands: table, usage }, null, 1) + '\n'; + if (process.argv.includes('--check')) { + const cur = existsSync(OUT) ? readFileSync(OUT, 'utf8') : ''; + if (cur !== text) { console.error('cli/data/flags.json is stale: run bun tools/gen-flags.ts'); process.exit(1); } + console.log(`flags: ${Object.keys(table).length} commands, fresh`); + } else { + writeFileSync(OUT, text); + console.log(`flags: ${Object.keys(table).length} commands -> ${relative(ROOT, OUT)}`); + } +}