onboard reads review access from the live App Store version (READY_FOR_SALE / READY_FOR_DISTRIBUTION, newest live first; the newest version only when nothing is live): a newer draft's empty review detail no longer hides the live demo account or turns signInRequired off; reviewVersion in cli/lib/onboard.ts, tests with a live version holding a demo account and a newer draft without

This commit is contained in:
CRTkafa 2026-10-14 02:08:39 +08:00
parent 0c4689a81b
commit 21fa91afd1
3 changed files with 41 additions and 5 deletions

View file

@ -211,6 +211,17 @@ export function maskContact(c: ReviewContact): string {
return `${c.firstName ? c.firstName[0] + '.' : ''}${c.lastName ? ` ${c.lastName[0]}.` : ''} ${maskUser(c.email)}${digits ? `, phone ***${digits.slice(-2)}` : ''}`.trim();
}
/**
* The App Store version whose review detail tells the truth about review access: the LIVE one (READY_FOR_SALE /
* READY_FOR_DISTRIBUTION; the newest live one when several report it), else the newest version. A newer draft's empty
* review detail must never hide the demo account the live version was reviewed with.
*/
export function reviewVersion<T extends { attributes?: { appStoreState?: string | null; appVersionState?: string | null; createdDate?: string | null } }>(versions: T[]): T | null {
const LIVE = new Set(['READY_FOR_SALE', 'READY_FOR_DISTRIBUTION']);
const newest = [...versions].sort((a, b) => (b.attributes?.createdDate ?? '').localeCompare(a.attributes?.createdDate ?? ''));
return newest.find(v => LIVE.has(v.attributes?.appVersionState ?? '') || LIVE.has(v.attributes?.appStoreState ?? '')) ?? newest[0] ?? null;
}
// ---- sign-in for review ----
export interface SignInDecision {