play listing uploads the hi-res icon (and the feature graphic) for a new Play language in the same edit (403 no high resolution icon set; play images skipped it), pitfall 102; script traces skip test files
This commit is contained in:
parent
256e8e33ad
commit
600b6893e5
6 changed files with 47 additions and 1 deletions
|
|
@ -72,6 +72,18 @@ export function missingChange(type: string, remote: number, prune: boolean): Ima
|
|||
/** What one language uploads: the sets with files, the optional types without, and errors (missing required sets). */
|
||||
export interface LangImages { sets: [string, string[]][]; missing: string[]; errors: string[] }
|
||||
|
||||
/** The graphics a NEW Play language needs before its edit can commit (403 "no high resolution icon set for language"):
|
||||
* the hi-res icon and, when rendered, the feature graphic. `play listing` uploads them in the same edit as the text,
|
||||
* so listing and images never wait for each other (pitfall 102). */
|
||||
export function firstGraphics(ctx: Ctx, code: string): [string, string][] {
|
||||
const { config, resolve } = ctx.loaded;
|
||||
const icon = resolve(config.play?.icon ?? join(config.icons?.out ?? 'store/icons', 'play-512.png'));
|
||||
const l = byPlayCode(config.languages).get(code);
|
||||
const src = resolve(config.renders ?? config.shots?.out ?? 'store/renders');
|
||||
const li = langImages(code, l ? join(src, l.id) : join(src, '__none__'), icon, false);
|
||||
return li.sets.filter(([t]) => t === 'icon' || t === 'featureGraphic').map(([t, files]) => [t, files[0]!] as [string, string]);
|
||||
}
|
||||
|
||||
/** The image sets of one language folder (`tablets` = resolved play.tablets). Reads the folder only. */
|
||||
export function langImages(code: string, dir: string, icon: string, tablets: boolean): LangImages {
|
||||
const out: LangImages = { sets: [], missing: [], errors: [] };
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import type { Ctx } from '../lib/ctx';
|
|||
import { confirm, need } from '../lib/ctx';
|
||||
import { done, log, printJson, step, warn } from '../lib/log';
|
||||
import { playClient } from './client';
|
||||
import { firstGraphics } from './images';
|
||||
import { stdinIsTTY } from '../lib/tty';
|
||||
|
||||
/** Play release notes that name iOS, iPhone, App Store, ... are refused before any edit, dry runs included (pitfall 77). */
|
||||
|
|
@ -167,6 +168,15 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
for (const [i, b] of todo.entries()) {
|
||||
await play.call('PUT', `${play.API}/edits/${id}/listings/${b.language}`, b);
|
||||
log('play', step(i + 1, todo.length, b.language!));
|
||||
// a language Play does not have yet: its edit only commits with a hi-res icon (pitfall 102)
|
||||
if (!now.some(n => n.language === b.language)) {
|
||||
const graphics = firstGraphics(ctx, b.language!);
|
||||
if (!graphics.some(([t]) => t === 'icon')) throw new Error(`${b.language}: a new Play language needs the 512x512 icon in the same edit (play.icon or store/icons/play-512.png): storebound icons makes it`);
|
||||
for (const [type, f] of graphics) {
|
||||
await play.call('POST', `${play.UPLOAD}/edits/${id}/listings/${b.language}/${type}?uploadType=media`, new Uint8Array(readFileSync(f)), { 'Content-Type': /\.png$/i.test(f) ? 'image/png' : 'image/jpeg' });
|
||||
log('play', `${b.language}: ${type} uploaded with the new listing`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, { notSentForReview: ctx.args.has('not-sent-for-review'), summary: 'listing text' });
|
||||
done('play', sent ? 'listing done' : 'listing already up to date (the edit was deleted, nothing committed)');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue