Desktop: adapt to 0.5.0 (app.platforms, subscriptions, catalog diff), Dependencies polish, ~ for the home folder
- inspect reports platforms, subscription ids and the catalog each store should sell; app identity and parity follow app.platforms and per-item platforms; catalog.diff joins the JSON methods - Portfolio: one Platforms column, compact catalog, paths truncated and shown with ~; the confirm dialog and run logs show ~ instead of the home folder
This commit is contained in:
parent
7fab0a5b03
commit
9320d64f46
12 changed files with 60 additions and 24 deletions
|
|
@ -9,7 +9,7 @@ import { appleCurrent, pages, playProduct } from './prices';
|
|||
import { ascClient, type J } from './apple/asc';
|
||||
import { type CatalogRow, catalogDiff, fromApplePeriod, fromAppleType, regionOf, type StoreItem, wantedCatalog } from './lib/catalog';
|
||||
import type { Ctx } from './lib/ctx';
|
||||
import { done, log } from './lib/log';
|
||||
import { done, log, printJson } from './lib/log';
|
||||
import { fromMoney } from './lib/money';
|
||||
import { listOneTimeProducts } from './play/products';
|
||||
import { playClient } from './play/client';
|
||||
|
|
@ -94,7 +94,7 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const play = (!store || store === 'play') && config.play ? await playItems(ctx) : null;
|
||||
const { rows, parity } = catalogDiff(want, { apple, play }, { threshold: a.num('threshold', 10) / 100 });
|
||||
const errors = rows.filter(r => r.level === 'error').length;
|
||||
if (a.has('json')) console.log(JSON.stringify({ errors, rows, parity }, null, 2));
|
||||
if (a.has('json')) printJson({ errors, rows, parity });
|
||||
else {
|
||||
console.log(formatRows(rows));
|
||||
if (parity.length) console.log(`\nprice differences between the stores (same currency, over ${a.num('threshold', 10)} %):\n` +
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
// Offline summary of the project config: app name, store ids, languages, products, shots. No network, no credentials.
|
||||
// storebound inspect [--json]
|
||||
import { platformsOf, sellsOn } from './lib/config';
|
||||
import type { Ctx } from './lib/ctx';
|
||||
import type { ProjectSummary } from './lib/desktop-protocol';
|
||||
import { log, printJson } from './lib/log';
|
||||
|
||||
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,
|
||||
|
|
@ -13,10 +15,16 @@ export function summarize(ctx: Ctx): ProjectSummary {
|
|||
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 arrive in the config schema separately; counted when present
|
||||
subscriptions: ((config as { subscriptions?: unknown[] }).subscriptions ?? []).length,
|
||||
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,
|
||||
};
|
||||
|
|
@ -25,7 +33,7 @@ export function summarize(ctx: Ctx): ProjectSummary {
|
|||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const s = summarize(ctx);
|
||||
if (ctx.args.has('json')) { printJson(s); return; }
|
||||
log('inspect', `${s.name} · ${s.languages.length} languages · ${s.products} products`);
|
||||
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}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,11 +78,16 @@ export interface ProjectSummary {
|
|||
languages: string[];
|
||||
play: { packageName: string } | null;
|
||||
apple: { bundleId: string; appId: string | null } | null;
|
||||
/** One-time in-app products in the config (shared by both stores). */
|
||||
/** app.platforms (default: from the apple / play sections). */
|
||||
platforms: ('ios' | 'android')[];
|
||||
/** One-time in-app products in the config (one shared catalog). */
|
||||
products: number;
|
||||
productIds: string[];
|
||||
/** Subscriptions in the config (0 until the config defines them). */
|
||||
/** Auto-renewable subscriptions in the config (all groups). */
|
||||
subscriptions: number;
|
||||
subscriptionIds: string[];
|
||||
/** Product and subscription ids each store should sell (items may be limited to one platform). */
|
||||
catalog: { ios: string[]; android: string[] };
|
||||
shots: boolean;
|
||||
testflightGroups: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ export function appIdentity(s: ProjectSummary): AppIdentity {
|
|||
id: s.dir,
|
||||
name: s.name,
|
||||
platforms: {
|
||||
ios: s.apple ? { bundleId: s.apple.bundleId, ascAppId: s.apple.appId } : null,
|
||||
android: s.play ? { packageName: s.play.packageName } : null,
|
||||
ios: s.apple && s.platforms.includes('ios') ? { bundleId: s.apple.bundleId, ascAppId: s.apple.appId } : null,
|
||||
android: s.play && s.platforms.includes('android') ? { packageName: s.play.packageName } : null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
@ -86,12 +86,13 @@ export const playProductIds = (data: unknown): string[] => (((data as J)?.produc
|
|||
* and config ids missing from a store the app is on.
|
||||
*/
|
||||
export function catalogParity(s: ProjectSummary, apple?: string[], play?: string[]): CatalogParity {
|
||||
const ids = s.productIds;
|
||||
const live = apple !== undefined || play !== undefined;
|
||||
const onlyIos = apple && play ? apple.filter(x => !play.includes(x)) : [];
|
||||
const onlyAndroid = apple && play ? play.filter(x => !apple.includes(x)) : [];
|
||||
const missingIos = s.apple && apple ? ids.filter(x => !apple.includes(x)) : [];
|
||||
const missingAndroid = s.play && play ? ids.filter(x => !play.includes(x)) : [];
|
||||
// the status reads list one-time products; subscriptions are compared by `catalog diff` (catalog.diff method)
|
||||
const sold = (ids: string[]) => ids.filter(x => s.productIds.includes(x));
|
||||
const missingIos = apple ? sold(s.catalog.ios).filter(x => !apple.includes(x)) : [];
|
||||
const missingAndroid = play ? sold(s.catalog.android).filter(x => !play.includes(x)) : [];
|
||||
return {
|
||||
checked: live ? 'live' : 'config', products: s.products, subscriptions: s.subscriptions,
|
||||
onlyIos, onlyAndroid, missingIos, missingAndroid,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export const FORBIDDEN_METHOD_WORDS = /submit|release|publish|rollout|resume|com
|
|||
|
||||
/** Read tools whose command prints a structured result with --json. */
|
||||
export const JSON_TOOLS = new Set(['check', 'check_aso', 'validate', 'health', 'reviews_list', 'prices_diff', 'analytics_compare', 'apple_status',
|
||||
'apple_next_build', 'play_status', 'play_next_version_code', 'shots_check', 'apple_testflight_status', 'apple_ppo_status']);
|
||||
'apple_next_build', 'play_status', 'play_next_version_code', 'shots_check', 'apple_testflight_status', 'apple_ppo_status', 'catalog_diff']);
|
||||
|
||||
/** `apple_testflight_status` -> `apple.testflight_status`: first underscore becomes the namespace dot. */
|
||||
export const methodName = (tool: string): string => tool.replace('_', '.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue