53 lines
2.8 KiB
TypeScript
53 lines
2.8 KiB
TypeScript
// Offline summary of the project config: app name, store ids, languages, products, shots. No network, no credentials.
|
|
// 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)
|
|
import { platformsOf, profileOf, sellsOn } from './lib/config';
|
|
import type { Ctx } from './lib/ctx';
|
|
import type { ProjectSummary } from './lib/desktop-protocol';
|
|
import { log, printJson } from './lib/log';
|
|
import { findIcon, iconDataUrl, listingCompleteness } from './lib/project-files';
|
|
|
|
export function summarize(ctx: Ctx): ProjectSummary {
|
|
const { config, root, path } = ctx.loaded;
|
|
const subs = (config.subscriptions ?? []).flatMap(g => g.subscriptions);
|
|
return {
|
|
dir: root,
|
|
config: path,
|
|
name: config.app.name,
|
|
languages: config.languages.map(l => l.id),
|
|
play: config.play ? { packageName: config.play.packageName } : null,
|
|
apple: config.apple ? { bundleId: config.apple.bundleId, appId: config.apple.appId ?? null } : null,
|
|
platforms: platformsOf(config),
|
|
products: config.products?.length ?? 0,
|
|
productIds: (config.products ?? []).map(p => p.id),
|
|
subscriptions: subs.length,
|
|
subscriptionIds: subs.map(s => s.id),
|
|
// the catalog each store should sell (items can be limited to one platform)
|
|
catalog: {
|
|
ios: config.apple ? [...(config.products ?? []), ...subs].filter(x => sellsOn(config, x, 'apple')).map(x => x.id) : [],
|
|
android: config.play ? [...(config.products ?? []), ...subs].filter(x => sellsOn(config, x, 'play')).map(x => x.id) : [],
|
|
},
|
|
shots: !!config.shots,
|
|
testflightGroups: config.apple?.testflight?.groups?.length ?? 0,
|
|
profile: profileOf(config),
|
|
icon: findIcon(config, root),
|
|
};
|
|
}
|
|
|
|
export async function run(ctx: Ctx): Promise<void> {
|
|
const { config, root } = ctx.loaded;
|
|
if (ctx.args.has('icon')) { printJson(iconDataUrl(findIcon(config, root))); return; }
|
|
if (ctx.args.has('listings')) {
|
|
const l = listingCompleteness(config, root);
|
|
if (ctx.args.has('json')) { printJson(l); return; }
|
|
for (const p of l.problems) log('inspect', p);
|
|
for (const x of l.locales) log('inspect', `${x.lang.padEnd(6)} ${Math.round(x.complete * 100)} % complete${x.screenshots === null ? '' : ` · ${x.screenshots} screenshots`}`);
|
|
return;
|
|
}
|
|
const s = summarize(ctx);
|
|
if (ctx.args.has('json')) { printJson(s); return; }
|
|
log('inspect', `${s.name} · ${s.platforms.join(' + ')} · ${s.languages.length} languages · ${s.products} products · ${s.subscriptions} subscriptions`);
|
|
log('inspect', `play ${s.play?.packageName ?? '-'} · apple ${s.apple?.bundleId ?? '-'}${s.apple?.appId ? ` (${s.apple.appId})` : ''}`);
|
|
log('inspect', `config ${s.config}`);
|
|
}
|