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.
This commit is contained in:
parent
e38f68fa33
commit
af08d7113a
12 changed files with 1625 additions and 99 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -2,6 +2,18 @@
|
||||||
|
|
||||||
## Unreleased
|
## 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
|
- 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
|
(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
|
extension and signature; the family comes from the name table when not given). `shots fonts` checks the file's cmap
|
||||||
|
|
|
||||||
|
|
@ -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
|
- **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
|
`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.
|
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.*`,
|
- **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.
|
`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
|
- **No hand-written SVG.** Charts come from visx, icons from Phosphor (`@phosphor-icons/react` in the desktop app, one
|
||||||
|
|
|
||||||
92
cli/commands.ts
Normal file
92
cli/commands.ts
Normal file
|
|
@ -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<void> };
|
||||||
|
export type Plain = { run(args: ReturnType<typeof parseArgs>): Promise<void> };
|
||||||
|
/** Commands that work without a storebound.config.ts. */
|
||||||
|
export const PLAIN: Record<string, [() => Promise<Plain>, 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 <operationId|METHOD path> [--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 <path>)'],
|
||||||
|
'ws': [() => import('./workspace'), 'many apps and studios (storebound.workspace.json): init | list | status (apps x stores, parallel) | check | validate | run <command> --apps a,b|--all (writes dry unless --apply) | apps import --account <profile> | desktop export|import'],
|
||||||
|
'release': [() => import('./release'), 'status [--app a,b] [--versions]: both stores on one train per version (build > testing > review > live > rollout %) | plan <version>: 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> [NAME=value] [--dry plan only | --apply] [--from <step> | --resume]; writes run as dry runs unless --apply, owner steps (submit, release, rollout) are never run'],
|
||||||
|
'ads': [() => import('./ads'), 'scan --ios <path>: AdAttributionKit / SKAdNetwork checks of Info.plist (network ids, postback copy endpoints, attribution windows, cooldown) and sources; --json'],
|
||||||
|
};
|
||||||
|
export const COMMANDS: Record<string, [() => Promise<Mod>, 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 <USD> (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 <domain> (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'), '<form> [--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 <folders>): 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 "<command>"]: 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 <ids>; local files only'],
|
||||||
|
'whats-new': [() => import('./whats-new'), 'draft user-facing release notes from git log into the listing files (--since <tag>); --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 <id>'],
|
||||||
|
'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 <id>'],
|
||||||
|
'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 <id>)'],
|
||||||
|
'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 <x.xcarchive>'],
|
||||||
|
'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 <renders>/index.html: every language, size, scene and variant, issues highlighted'],
|
||||||
|
};
|
||||||
1101
cli/data/flags.json
Normal file
1101
cli/data/flags.json
Normal file
File diff suppressed because it is too large
Load diff
147
cli/index.ts
147
cli/index.ts
|
|
@ -1,114 +1,50 @@
|
||||||
#!/usr/bin/env bun
|
#!/usr/bin/env bun
|
||||||
// storebound: ship a mobile app or game to Google Play and the App Store from the terminal.
|
// 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/.
|
// 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 { parseArgs } from './lib/args';
|
||||||
import { toolPath } from './lib/tools';
|
import { toolPath } from './lib/tools';
|
||||||
import { loadConfig } from './lib/config';
|
import { COMMANDS, PLAIN } from './commands';
|
||||||
import type { Ctx } from './lib/ctx';
|
import FLAGS from './data/flags.json';
|
||||||
|
|
||||||
type Mod = { run(ctx: Ctx): Promise<void> };
|
const COMMON = 'common options: --config <path> --dry (no writes) --only <ids> --yes (skip confirmations) --json --account <profile> (credential profile)';
|
||||||
type Plain = { run(args: ReturnType<typeof parseArgs>): Promise<void> };
|
const line = ([k, d]: [string, string]): string => ` ${k.padEnd(25)} ${d}`;
|
||||||
/** Commands that work without a storebound.config.ts. */
|
const describe = (k: string): string => (PLAIN[k] ?? COMMANDS[k])![1];
|
||||||
const PLAIN: Record<string, [() => Promise<Plain>, 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 <operationId|METHOD path> [--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 <path>)'],
|
|
||||||
'ws': [() => import('./workspace'), 'many apps and studios (storebound.workspace.json): init | list | status (apps x stores, parallel) | check | validate | run <command> --apps a,b|--all (writes dry unless --apply) | apps import --account <profile> | desktop export|import'],
|
|
||||||
'release': [() => import('./release'), 'status [--app a,b] [--versions]: both stores on one train per version (build > testing > review > live > rollout %) | plan <version>: 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> [NAME=value] [--dry plan only | --apply] [--from <step> | --resume]; writes run as dry runs unless --apply, owner steps (submit, release, rollout) are never run'],
|
|
||||||
'ads': [() => import('./ads'), 'scan --ios <path>: AdAttributionKit / SKAdNetwork checks of Info.plist (network ids, postback copy endpoints, attribution windows, cooldown) and sources; --json'],
|
|
||||||
};
|
|
||||||
const COMMANDS: Record<string, [() => Promise<Mod>, 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 <USD> (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 <domain> (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'), '<form> [--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 <folders>): 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 "<command>"]: 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 <ids>; local files only'],
|
|
||||||
'whats-new': [() => import('./whats-new'), 'draft user-facing release notes from git log into the listing files (--since <tag>); --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 <id>'],
|
|
||||||
'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 <id>'],
|
|
||||||
'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 <id>)'],
|
|
||||||
'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 <x.xcarchive>'],
|
|
||||||
'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 <renders>/index.html: every language, size, scene and variant, issues highlighted'],
|
|
||||||
};
|
|
||||||
|
|
||||||
function help(): void {
|
function help(): void {
|
||||||
console.log(`storebound · take mobile apps and games from nothing to Submit for review on Google Play and the App Store
|
console.log(`storebound · take mobile apps and games from nothing to Submit for review on Google Play and the App Store
|
||||||
|
|
||||||
usage: storebound <command> [options]
|
usage: storebound <command> [options] (storebound <command> --help: its usage and options)
|
||||||
|
|
||||||
${Object.entries(PLAIN).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]]) => ` ${k.padEnd(25)} ${d}`).join('\n')}
|
${Object.entries(COMMANDS).map(([k, [, d]]) => line([k, d])).join('\n')}
|
||||||
|
|
||||||
common options: --config <path> --dry (no writes) --only <ids> --yes (skip confirmations) --account <profile> (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);
|
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/<profile>.json (same names), picked with --account <profile>
|
profiles for many accounts: ~/.storebound/credentials/<profile>.json (same names), picked with --account <profile>
|
||||||
docs: README.md and the skills/ folder of the toolchain`);
|
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<string, string[]>)[key] ?? [`storebound ${key} [options]`];
|
||||||
|
const flags = (FLAGS.commands as Record<string, string[]>)[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 <command> ...), 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} <command> [options] (storebound ${g} <command> --help: its usage and options)\n\n${keys.map(k => line([k, describe(k)])).join('\n')}\n\n${COMMON}`;
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
|
// 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
|
// 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);
|
process.env.PATH = toolPath(process.env);
|
||||||
const argv = process.argv.slice(2);
|
const argv = process.argv.slice(2);
|
||||||
|
|
@ -125,10 +61,27 @@ async function main(): Promise<void> {
|
||||||
const [a, b] = argv;
|
const [a, b] = argv;
|
||||||
if (!a || a === 'help' || a === '--help' || a === '-h') return help();
|
if (!a || a === 'help' || a === '--help' || a === '-h') return help();
|
||||||
if (a === 'version' || a === '--version') return console.log((await import('../package.json')).version);
|
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 known = (k: string): boolean => !!(PLAIN[k] ?? COMMANDS[k]);
|
||||||
const key = COMMANDS[`${a} ${b}`] ? `${a} ${b}` : COMMANDS[a] ? a : '';
|
const key = known(`${a} ${b}`) ? `${a} ${b}` : known(a) ? a : '';
|
||||||
if (!key) { console.error(`unknown command: ${argv.slice(0, 2).join(' ')}\n`); help(); process.exit(2); }
|
const group = Object.keys({ ...PLAIN, ...COMMANDS }).filter(k => k.startsWith(a + ' '));
|
||||||
const args = parseArgs(argv.slice(key.split(' ').length));
|
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<string, string[]>)[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'));
|
const loaded = await loadConfig(args.get('config'));
|
||||||
// one writer per app and store (cli/lib/lock.ts): dry runs and reads take no lock
|
// one writer per app and store (cli/lib/lock.ts): dry runs and reads take no lock
|
||||||
const { acquireLock, lockKeys } = await import('./lib/lock');
|
const { acquireLock, lockKeys } = await import('./lib/lock');
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,9 @@ export const COLLECT_TEXT = `(ours) => {
|
||||||
box.style.cssText = 'position:absolute;left:-20000px;top:0;white-space:pre';
|
box.style.cssText = 'position:absolute;left:-20000px;top:0;white-space:pre';
|
||||||
for (const p of probes) {
|
for (const p of probes) {
|
||||||
const s = document.createElement('span');
|
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;
|
s.textContent = p.ch;
|
||||||
box.append(s);
|
box.append(s);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// Store screenshots + Play feature graphic at exact pixel sizes, from raw app or game frames and per-language copy.
|
// 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]
|
// [--no-sheet] [--port 8792] [--concurrency N] [--dry]
|
||||||
// Out: <shots.out>/<lang>/<size>/NN.png (24-bit RGB: Play rejects alpha / palette PNGs), <lang>/feature/1024x500.png,
|
// Out: <shots.out>/<lang>/<size>/NN.png (24-bit RGB: Play rejects alpha / palette PNGs), <lang>/feature/1024x500.png,
|
||||||
// <lang>/sheet.png (contact sheet of every size packed into a grid, for a quick review) and <shots.out>/report.json (text overflow flags
|
// <lang>/sheet.png (contact sheet of every size packed into a grid, for a quick review) and <shots.out>/report.json (text overflow flags
|
||||||
|
|
@ -48,6 +48,10 @@ export async function run(ctx: Ctx): Promise<void> {
|
||||||
if (problems.length) throw new Error(`shots copy${v ? ` (variant ${v})` : ''}:\n ` + problems.join('\n '));
|
if (problems.length) throw new Error(`shots copy${v ? ` (variant ${v})` : ''}:\n ` + problems.join('\n '));
|
||||||
jobs.set(v ?? '', { scenes, copy });
|
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);
|
const framesDir = resolve(shots.frames), outDir = resolve(shots.out);
|
||||||
if (a.has('dry')) {
|
if (a.has('dry')) {
|
||||||
let n = 0;
|
let n = 0;
|
||||||
|
|
|
||||||
111
tests/cli-help.test.ts
Normal file
111
tests/cli-help.test.ts
Normal file
|
|
@ -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<string, string> => {
|
||||||
|
const e: Record<string, string> = {};
|
||||||
|
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<string, string[]>;
|
||||||
|
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([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
93
tests/fixtures/fonts/Montserrat-OFL.txt
vendored
Normal file
93
tests/fixtures/fonts/Montserrat-OFL.txt
vendored
Normal file
|
|
@ -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.
|
||||||
BIN
tests/fixtures/fonts/montserrat-text-subset.woff2
vendored
Normal file
BIN
tests/fixtures/fonts/montserrat-text-subset.woff2
vendored
Normal file
Binary file not shown.
49
tests/glyph-ligatures.test.ts
Normal file
49
tests/glyph-ligatures.test.ts
Normal file
|
|
@ -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(`<style>@font-face { font-family: 'Montserrat'; font-weight: 100 900; font-synthesis: none; src: url(data:font/woff2;base64,${font}) format('woff2'); }
|
||||||
|
p { font-family: 'Montserrat'; font-weight: ${weight}; font-size: 48px; } small { font-family: 'Montserrat'; font-weight: ${weight}; }</style>
|
||||||
|
<p class="sub">${TEXT}</p><div><small>mounts and vehicles</small></div>`);
|
||||||
|
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);
|
||||||
|
});
|
||||||
105
tools/gen-flags.ts
Normal file
105
tools/gen-flags.ts
Normal file
|
|
@ -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: <x>.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 <command> ...`) go along, for `storebound <command> --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<string, string[]> = {
|
||||||
|
'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<string> {
|
||||||
|
const flags = new Set<string>(), seen = new Set<string>(), 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 <key> ...`. */
|
||||||
|
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<string, string[]>; usage: Record<string, string[]>; errors: string[] } {
|
||||||
|
const src = readFileSync(join(CLI, 'commands.ts'), 'utf8');
|
||||||
|
const errors: string[] = [];
|
||||||
|
const per: Record<string, string[]> = {}, usage: Record<string, string[]> = {};
|
||||||
|
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)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue