42 lines
2.6 KiB
TypeScript
42 lines
2.6 KiB
TypeScript
// Builds still active on a testing track below the production build (pitfall 129). Play reviews every active build
|
|
// with each submission: a policy issue in an old one (a media permission it asked for, "Use alternative system
|
|
// pickers") blocks "Send changes for review" for the whole app, while the API still reads production as completed.
|
|
// The Developer API cannot read a bundle's permissions, so each old build is named with the command that replaces it.
|
|
// Pure.
|
|
|
|
export interface TrackLike { track: string; releases?: { name?: string; versionCodes?: string[]; status: string }[] }
|
|
export interface OldBuild { track: string; versionCodes: number[]; name: string | null; status: string; productionCode: number }
|
|
|
|
/** Permissions Play reviews as policy-sensitive (Photo and video permissions, All files access). */
|
|
export const SENSITIVE_PERMISSIONS = ['READ_MEDIA_IMAGES', 'READ_MEDIA_VIDEO', 'READ_EXTERNAL_STORAGE', 'MANAGE_EXTERNAL_STORAGE', 'WRITE_EXTERNAL_STORAGE'];
|
|
|
|
const ACTIVE = new Set(['completed', 'inProgress', 'halted']);
|
|
const codes = (r: { versionCodes?: string[] }): number[] => (r.versionCodes ?? []).map(Number).filter(Number.isFinite);
|
|
|
|
export function oldTrackBuilds(tracks: TrackLike[]): OldBuild[] {
|
|
const prod = tracks.find(t => t.track === 'production');
|
|
const prodCodes = (prod?.releases ?? []).filter(r => ACTIVE.has(r.status)).flatMap(codes);
|
|
if (!prodCodes.length) return [];
|
|
const productionCode = Math.max(...prodCodes);
|
|
const out: OldBuild[] = [];
|
|
for (const t of tracks) {
|
|
if (t.track === 'production') continue;
|
|
for (const r of t.releases ?? []) {
|
|
const cs = codes(r);
|
|
if (!ACTIVE.has(r.status) || !cs.length || Math.max(...cs) >= productionCode) continue;
|
|
out.push({ track: t.track, versionCodes: cs, name: r.name ?? null, status: r.status, productionCode });
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
/** The track flag of `play release` for a track name (custom closed tracks go by --track). */
|
|
const trackFlag = (track: string): string => (['internal', 'alpha', 'beta'].includes(track) ? `--${track}` : `--track ${track}`);
|
|
|
|
export function oldBuildLines(old: OldBuild[]): string[] {
|
|
if (!old.length) return [];
|
|
return [
|
|
` old builds still active (${old.length}): Play reviews them with every submission; a policy issue in one (e.g. ${SENSITIVE_PERMISSIONS.slice(0, 2).join(' / ')}) blocks Send changes for review. The API cannot read their permissions:`,
|
|
...old.map(o => ` ${o.track} [${o.versionCodes.join(',')}] ${o.name ?? ''} ${o.status} -> replace: storebound play release --version-code ${o.productionCode} ${trackFlag(o.track)} completed`),
|
|
];
|
|
}
|