storebound aab <file> --json (offline packageName / versionCode / versionName / SDKs / sha256, no config) and play release --json result for CI scripts that replace their own Play API calls

This commit is contained in:
CRTkafa 2026-10-22 03:28:46 +08:00
parent ee35b11341
commit 256e8e33ad
9 changed files with 47 additions and 3 deletions

18
cli/aab.ts Normal file
View file

@ -0,0 +1,18 @@
// Offline: what an Android App Bundle says about itself, without a config or credentials (CI reads the version code
// before it uploads, instead of unzipping the AAB or asking the Play API).
// storebound aab <file.aab> [--json]
import { createHash } from 'node:crypto';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import type { Args } from './lib/args';
import { aabInfo } from './lib/gradle';
import { log, printJson } from './lib/log';
export async function run(args: Args): Promise<void> {
const file = args._.find(x => x.endsWith('.aab'));
if (!file) throw new Error('usage: storebound aab <file.aab> [--json]');
const data = readFileSync(resolve(file));
const info = { ...aabInfo(data), sha256: createHash('sha256').update(data).digest('hex'), bytes: data.length };
if (args.has('json')) { printJson(info); return; }
log('aab', `${info.packageName} ${info.versionName ?? '?'} (${info.versionCode}) · minSdk ${info.minSdk ?? '?'} · targetSdk ${info.targetSdk ?? '?'} · ${(info.bytes / 1e6).toFixed(1)} MB`);
}