apple creative-assets: select Header and Search Results assets once processed (Prepare for Submission), not once approved: Apple reviews an asset only in a review submission, so 0.8.13 waited forever; upload and select in one run with a bounded processing wait; --add-for-review puts unreviewed assets into the draft review submission (never submits); --verify reads every slot back read-only (MCP apple_creative_assets_verify); a rejected file or one that failed processing twice is not re-uploaded, an archived copy is unarchived; fake commits library assets to PREPARE_FOR_SUBMISSION; pitfall 76 rewritten; apple-name check test only looks at name hints
This commit is contained in:
parent
3e4015b686
commit
183579449c
14 changed files with 378 additions and 95 deletions
|
|
@ -79,7 +79,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'apps_appPricePoints_getToManyRelated': 'apple/appinfo',
|
||||
'apps_appPriceSchedule_getToOneRelated': 'apple/appinfo validate',
|
||||
'apps_appStoreVersionExperimentsV2_getToManyRelated': 'apple/ppo',
|
||||
'apps_appStoreVersions_getToManyRelated': 'apple/asc apple/iap-submit apple/listing apple/release apple/resubmit apple/review-details apple/status art lib/store-apps listing-store onboard validate',
|
||||
'apps_appStoreVersions_getToManyRelated': 'apple/asc apple/creative-assets apple/iap-submit apple/listing apple/release apple/resubmit apple/review-details apple/status art lib/store-apps listing-store onboard validate',
|
||||
'apps_assetLibrary_getToOneRelated': 'apple/creative-assets',
|
||||
'apps_betaAppLocalizations_getToManyRelated': 'apple/testflight',
|
||||
'apps_betaAppReviewDetail_getToOneRelated': 'apple/testflight',
|
||||
|
|
|
|||
|
|
@ -1,30 +1,96 @@
|
|||
// App Store "Header and Search Results" creative assets per locale of the editable App Store version:
|
||||
// storebound apple creative-assets [--src store/renders] [--only en-US,tr] [--dry]
|
||||
// storebound apple creative-assets [--src store/renders] [--only en-US,tr] [--dry] upload + select (upsert)
|
||||
// storebound apple creative-assets --add-for-review [--dry] also put unreviewed assets into the draft submission
|
||||
// storebound apple creative-assets --verify read-only: does every slot show the local file?
|
||||
// Files (cli/shots/creative.ts): <renders>/<lang>/creative/header.{png,jpg,mov,m4v,mp4} (3840x1646, 21:9),
|
||||
// search.{...} (3:2, 1920x1280 to 3840x2560), or one universal.png (5244x2950) for both slots. apple.creativeAssets
|
||||
// can turn a placement off (header: false / search: false) or point at another universal file.
|
||||
// Flow, as App Store Connect works (Header and Search Results tab > Header / Search Results > Browse Assets): a file is
|
||||
// uploaded once into the app's Asset Library (POST appAssetLibraryImages / Videos, category CREATIVE_ASSETS, its MD5
|
||||
// in referenceName "storebound <md5>" because library assets carry no checksum), Apple reviews it, and only an
|
||||
// APPROVED asset is selected for a slot (POST appAssetLibraryPlacements with placementType PRODUCT_PAGE_HEADER_ASSET or
|
||||
// APP_STORE_SEARCH_RESULTS_ASSET and the version localization). Upsert: a slot that already shows the same MD5 is left
|
||||
// alone; a new file replaces the slot only once it is approved (the old placement is removed, then the new one is
|
||||
// created); an asset with the same MD5 already in the library is reused, never uploaded twice. Read back at the end.
|
||||
// Flow, as App Store Connect works (version page > Product Page Information > Header and Search Results > Header /
|
||||
// Search Results > Browse Assets > Save; Help "Manage your App Store assets", "App Store asset statuses",
|
||||
// "Submit assets from Asset Library", checked 19 Oct 2026):
|
||||
// 1. a file is uploaded once into the app's Asset Library (POST appAssetLibraryImages / Videos, category
|
||||
// CREATIVE_ASSETS, its MD5 in referenceName "storebound <md5>" because library assets carry no checksum);
|
||||
// 2. after processing it is "Prepare for Submission", and in that state it can already be selected for a slot
|
||||
// (POST appAssetLibraryPlacements, placementType PRODUCT_PAGE_HEADER_ASSET / APP_STORE_SEARCH_RESULTS_ASSET, the
|
||||
// version localization). Approval is NOT needed first: an asset is only reviewed once it is in a review
|
||||
// submission, so "select only approved assets" waits forever (pitfall 76);
|
||||
// 3. App Review: the asset is a review submission item of its own (reviewSubmissionItems appAssetLibraryImage /
|
||||
// appAssetLibraryVideo; console "Add for Review"). Before the app's first approved version it goes in the same
|
||||
// submission as that version; afterwards it can go alone. --add-for-review adds it to the draft submission;
|
||||
// pressing Submit for Review stays the owner's.
|
||||
// Upsert: a slot that already shows the same MD5 is left alone; an asset with the same MD5 in the library is reused
|
||||
// (an archived one is unarchived), never uploaded twice; a REJECTED file is not uploaded again (change the file); a
|
||||
// changed file replaces the slot (the old placement is removed, then the new one is created). Read back at the end.
|
||||
// Play has no such slot: the feature graphic (play images) and the promo video URL are its closest equivalents.
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { basename } from 'node:path';
|
||||
import type { Ctx } from '../lib/ctx';
|
||||
import { need } from '../lib/ctx';
|
||||
import { consoleLink } from '../lib/console-links';
|
||||
import { done, log, warn } from '../lib/log';
|
||||
import { elapsed } from '../lib/progress';
|
||||
import * as rt from '../lib/rt';
|
||||
import { ffprobe } from '../shots/report';
|
||||
import { imageInfo } from '../shots/spec';
|
||||
import { checkCreativeImage, checkCreativeVideo, type CreativeFile, creativeFiles, PLACEMENT_TYPE, type Placement } from '../shots/creative';
|
||||
import { ascClient, md5, type J } from './asc';
|
||||
import { addItem, ensureDraft, OtherSubmissionError } from './submission';
|
||||
|
||||
const TAG = 'apple';
|
||||
export const REF = (sum: string): string => `storebound ${sum}`;
|
||||
const sumOf = (a: J): string | undefined => /^storebound ([0-9a-f]{32})$/.exec(String(a?.attributes?.referenceName ?? ''))?.[1];
|
||||
|
||||
export interface Row { locale: string; placement: Placement; file: string; action: 'keep' | 'upload' | 'wait' | 'select' | 'replace'; state?: string }
|
||||
/** Asset states (AppAssetLibraryAssetState, API 4.5.1) by what storebound may do with them. */
|
||||
export const ASSET_STATES = {
|
||||
/** still uploading / processing: wait (bounded), then select */
|
||||
processing: ['AWAITING_UPLOAD', 'UPLOAD_COMPLETE'],
|
||||
/** processed and usable in a slot; not reviewed yet: goes into a review submission */
|
||||
unreviewed: ['COMPLETE', 'PREPARE_FOR_SUBMISSION'],
|
||||
/** in a submission or reviewed: usable in a slot, nothing to add */
|
||||
reviewing: ['READY_FOR_REVIEW', 'WAITING_FOR_REVIEW', 'IN_REVIEW', 'ACCEPTED', 'APPROVED'],
|
||||
} as const;
|
||||
export type AssetClass = 'processing' | 'unreviewed' | 'reviewing' | 'failed' | 'rejected' | 'archived' | 'unknown';
|
||||
|
||||
/** What a library asset's state means for storebound. Pure. */
|
||||
export function classify(state: string | undefined): AssetClass {
|
||||
const s = String(state ?? '');
|
||||
for (const [k, v] of Object.entries(ASSET_STATES)) if ((v as readonly string[]).includes(s)) return k as AssetClass;
|
||||
if (s === 'FAILED') return 'failed';
|
||||
if (s === 'REJECTED') return 'rejected';
|
||||
if (s === 'ARCHIVED') return 'archived';
|
||||
return s ? 'unknown' : 'processing';
|
||||
}
|
||||
|
||||
/** Selectable for a slot: processed and not failed / rejected / archived (Prepare for Submission is enough). */
|
||||
export const selectable = (c: AssetClass): boolean => c === 'unreviewed' || c === 'reviewing';
|
||||
|
||||
/** Stop re-uploading a file whose earlier uploads failed processing this many times. */
|
||||
export const MAX_FAILED = 2;
|
||||
|
||||
/** The library asset to use for one MD5: a live one first (newest state wins: reviewing > unreviewed > processing),
|
||||
* else an archived one (unarchive it), else none; plus why not to upload (a rejected file, repeated failures). Pure. */
|
||||
export function pickAsset(assets: J[], sum: string): { asset?: J; unarchive?: boolean; refuse?: string } {
|
||||
const mine = assets.filter(x => sumOf(x) === sum);
|
||||
const rank: Record<AssetClass, number> = { reviewing: 0, unreviewed: 1, processing: 2, unknown: 3, archived: 4, rejected: 5, failed: 6 };
|
||||
const by = (c: AssetClass) => mine.filter(x => classify(x.attributes?.state) === c);
|
||||
const live = mine.filter(x => rank[classify(x.attributes?.state)] <= 3).sort((a, b) => rank[classify(a.attributes?.state)] - rank[classify(b.attributes?.state)]);
|
||||
if (live[0]) return { asset: live[0] };
|
||||
if (by('archived')[0]) return { asset: by('archived')[0], unarchive: true };
|
||||
const rej = by('rejected')[0];
|
||||
if (rej) return { refuse: `rejected by App Review${reason(rej)}: uploading the same file again changes nothing; change the file` };
|
||||
if (by('failed').length >= MAX_FAILED) return { refuse: `${by('failed').length} earlier uploads of this file failed processing${reason(by('failed')[0]!)}: check the file (format, size) before trying again` };
|
||||
return {};
|
||||
}
|
||||
|
||||
const reason = (a: J): string => {
|
||||
const d = ((a.attributes?.stateDetails ?? []) as J[]).map(x => x?.code ?? x?.message ?? x?.description).filter(Boolean);
|
||||
return d.length ? ` (${d.join(', ')})` : '';
|
||||
};
|
||||
|
||||
/** Bounded wait for processing (every wait has a timeout and a heartbeat); tests set waitMs 0 / timeoutMs 0. */
|
||||
export const processingTiming = { pollMs: 3000, timeoutMs: 120_000, heartbeatMs: 20_000, sleep: (ms: number): Promise<void> => (ms > 0 ? rt.sleep(ms) : Promise.resolve()) };
|
||||
|
||||
export interface Row { locale: string; placement: Placement; file: string; action: 'keep' | 'upload' | 'wait' | 'select' | 'replace' | 'refuse'; state?: string; asset?: J }
|
||||
|
||||
/** Local files per App Store locale, checked; throws on any error before a network call. */
|
||||
export function localCreative(ctx: Ctx): { src: string; local: Map<string, CreativeFile[]> } {
|
||||
|
|
@ -42,7 +108,7 @@ export function localCreative(ctx: Ctx): { src: string; local: Map<string, Creat
|
|||
fs = fs.filter(f => ca[f.placement] !== false);
|
||||
for (const f of fs) {
|
||||
const issues = f.kind === 'image' ? checkCreativeImage(imageInfo(readFileSync(f.file)), f.placement, f.universal) : checkCreativeVideo(f.file, ffprobe(f.file), f.placement);
|
||||
for (const i of issues) (i.level === 'error' ? warn : log)('apple', `${l.apple} ${f.placement} ${basename(f.file)}: ${i.msg}`);
|
||||
for (const i of issues) (i.level === 'error' ? warn : log)(TAG, `${l.apple} ${f.placement} ${basename(f.file)}: ${i.msg}`);
|
||||
if (issues.some(i => i.level === 'error')) bad++;
|
||||
}
|
||||
if (fs.length) local.set(l.apple, fs);
|
||||
|
|
@ -54,30 +120,39 @@ export function localCreative(ctx: Ctx): { src: string; local: Map<string, Creat
|
|||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
const dry = ctx.args.has('dry');
|
||||
const verify = ctx.args.has('verify');
|
||||
const forReview = ctx.args.has('add-for-review');
|
||||
const bundleId = need(config.apple?.bundleId, 'apple.bundleId');
|
||||
const { src, local } = localCreative(ctx);
|
||||
if (!local.size) { warn('apple', `no creative assets in ${src}/<lang>/creative/ (header.png 3840x1646, search.png 3:2, or universal.png 5244x2950): optional; without them the App Store uses events, previews and screenshots`); return; }
|
||||
log('apple', `${[...local.values()].flat().length} creative assets for ${local.size} locales pass the checks`);
|
||||
if (!local.size) { warn(TAG, `no creative assets in ${src}/<lang>/creative/ (header.png 3840x1646, search.png 3:2, or universal.png 5244x2950): optional; without them the App Store uses events, previews and screenshots`); return; }
|
||||
log(TAG, `${[...local.values()].flat().length} creative assets for ${local.size} locales pass the checks`);
|
||||
|
||||
let c: Awaited<ReturnType<typeof ascClient>>;
|
||||
try { c = await ascClient(root, bundleId, config.apple?.appId); }
|
||||
catch (e) {
|
||||
if (!dry) throw e;
|
||||
for (const [loc, fs] of local) for (const f of fs) log('apple', `${loc} ${PLACEMENT_TYPE[f.placement]}: would upload ${basename(f.file)} to the Asset Library and select it once approved`);
|
||||
return done('apple', `creative assets planned (dry run, no App Store Connect comparison: ${(e as Error).message.split('\n')[0]})`);
|
||||
for (const [loc, fs] of local) for (const f of fs) log(TAG, `${loc} ${PLACEMENT_TYPE[f.placement]}: would upload ${basename(f.file)} to the Asset Library and select it`);
|
||||
return done(TAG, `creative assets planned (dry run, no App Store Connect comparison: ${(e as Error).message.split('\n')[0]})`);
|
||||
}
|
||||
const lib = (await c.asc('GET', `/v1/apps/${await c.app()}/assetLibrary`)).data as J;
|
||||
const version = await c.editableVersion();
|
||||
if (!version) throw new Error('no editable App Store version (run apple listing --version x.y.z first)');
|
||||
const appId = await c.app();
|
||||
const lib = (await c.asc('GET', `/v1/apps/${appId}/assetLibrary`)).data as J;
|
||||
const live = async () => (await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=50`))
|
||||
.find(v => (v.attributes.appVersionState ?? v.attributes.appStoreState) === 'READY_FOR_DISTRIBUTION' || v.attributes.appStoreState === 'READY_FOR_SALE') ?? null;
|
||||
// --verify falls back to the live version (read-only); writes need the editable one
|
||||
const version = await c.editableVersion() ?? (verify ? await live() : null);
|
||||
if (!version) throw new Error(`no editable App Store version: the header and search results slots belong to a version page (run apple listing --version x.y.z first). ${consoleLink('asc.version')}`);
|
||||
const locs = await c.all(`/v1/appStoreVersions/${version.id}/appStoreVersionLocalizations?limit=50`);
|
||||
const library = async (): Promise<J[]> => [
|
||||
...(await c.all(`/v1/appAssetLibraries/${lib.id}/images?filter[category]=CREATIVE_ASSETS&limit=200`)),
|
||||
...(await c.all(`/v1/appAssetLibraries/${lib.id}/videos?filter[category]=CREATIVE_ASSETS&limit=200`)),
|
||||
];
|
||||
let assets = await library();
|
||||
const bySum = (s: string) => assets.filter(x => sumOf(x) === s && x.attributes?.state !== 'ARCHIVED' && x.attributes?.state !== 'FAILED' && x.attributes?.state !== 'REJECTED')[0];
|
||||
const rows: Row[] = [];
|
||||
const placedIn = async (locId: string, ptype: string) => c.all(`/v1/appStoreVersionLocalizations/${locId}/placements?filter[placementType]=${ptype}&include=image,video`);
|
||||
const shownOf = (p: J) => p.relationships?.image?.data?.id ?? p.relationships?.video?.data?.id;
|
||||
|
||||
if (verify) return verifySlots();
|
||||
|
||||
const rows: Row[] = [];
|
||||
async function upload(f: CreativeFile, sum: string): Promise<J> {
|
||||
const buf = readFileSync(f.file);
|
||||
const type = f.kind === 'image' ? 'appAssetLibraryImages' : 'appAssetLibraryVideos';
|
||||
|
|
@ -86,11 +161,26 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
for (const op of (res.attributes.uploadOperations ?? []) as J[]) {
|
||||
const headers: Record<string, string> = {};
|
||||
for (const h of op.requestHeaders ?? []) headers[h.name] = h.value;
|
||||
const r = await fetch(op.url, { method: op.method, headers, body: buf.subarray(op.offset, op.offset + op.length) });
|
||||
const r = await fetch(op.url, { method: op.method, headers, body: buf.subarray(op.offset, op.offset + op.length), signal: AbortSignal.timeout(300_000) });
|
||||
if (!r.ok) throw new Error(`upload ${basename(f.file)} part ${op.offset} -> ${r.status}`);
|
||||
}
|
||||
return (await c.asc('PATCH', `/v1/${type}/${res.id}`, { data: { type, id: res.id, attributes: { uploaded: true } } })).data as J;
|
||||
}
|
||||
/** Polls one asset until it leaves processing, at most processingTiming.timeoutMs, with a heartbeat line. */
|
||||
async function processed(a: J, label: string): Promise<J> {
|
||||
const t0 = Date.now();
|
||||
let beat = t0, cur = a;
|
||||
while (classify(cur.attributes?.state) === 'processing') {
|
||||
if (Date.now() - t0 >= processingTiming.timeoutMs) {
|
||||
warn(TAG, `${label}: still ${cur.attributes?.state ?? 'processing'} after ${elapsed(Date.now() - t0)}${reason(cur)} (asset ${cur.id}); re-run later to select it`);
|
||||
return cur;
|
||||
}
|
||||
await processingTiming.sleep(processingTiming.pollMs);
|
||||
cur = ((await c.maybe(`/v1/${cur.type}/${cur.id}`))?.data as J) ?? cur;
|
||||
if (Date.now() - beat >= processingTiming.heartbeatMs) { beat = Date.now(); log(TAG, `${label}: processing (${cur.attributes?.state}, ${elapsed(Date.now() - t0)})`); }
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
|
||||
for (const loc of locs) {
|
||||
const locale: string = loc.attributes.locale;
|
||||
|
|
@ -98,37 +188,94 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const ptype = PLACEMENT_TYPE[f.placement];
|
||||
const tag = `${locale} ${ptype}`;
|
||||
const sum = md5(readFileSync(f.file));
|
||||
const placed = await c.all(`/v1/appStoreVersionLocalizations/${loc.id}/placements?filter[placementType]=${ptype}&include=image,video`);
|
||||
const shownIds = placed.map(p => p.relationships?.image?.data?.id ?? p.relationships?.video?.data?.id).filter(Boolean);
|
||||
if (placed.length === 1 && assets.some(x => shownIds.includes(x.id) && sumOf(x) === sum)) { log('apple', `${tag}: ${basename(f.file)} already selected`); rows.push({ locale, placement: f.placement, file: f.file, action: 'keep' }); continue; }
|
||||
let asset = bySum(sum);
|
||||
const row = (action: Row['action'], asset?: J) => rows.push({ locale, placement: f.placement, file: f.file, action, state: asset?.attributes?.state, asset });
|
||||
const placed = await placedIn(loc.id, ptype);
|
||||
const shownIds = placed.map(shownOf).filter(Boolean);
|
||||
const shown = assets.find(x => shownIds.includes(x.id) && sumOf(x) === sum);
|
||||
if (placed.length === 1 && shown) { log(TAG, `${tag}: ${basename(f.file)} already selected (${shown.attributes?.state})`); row('keep', shown); continue; }
|
||||
const pick = pickAsset(assets, sum);
|
||||
if (pick.refuse) { warn(TAG, `${tag}: ${basename(f.file)} ${pick.refuse}`); row('refuse'); continue; }
|
||||
let asset = pick.asset;
|
||||
if (!asset) {
|
||||
if (dry) { log('apple', `${tag}: would upload ${basename(f.file)} to the Asset Library (Apple approves it, then it is selected)`); rows.push({ locale, placement: f.placement, file: f.file, action: 'upload' }); continue; }
|
||||
log('apple', `${tag}: uploading ${basename(f.file)} to the Asset Library`);
|
||||
if (dry) { log(TAG, `${tag}: would upload ${basename(f.file)} to the Asset Library and select it once processed`); row('upload'); continue; }
|
||||
log(TAG, `${tag}: uploading ${basename(f.file)} to the Asset Library`);
|
||||
asset = await upload(f, sum);
|
||||
assets = await library();
|
||||
asset = bySum(sum) ?? asset;
|
||||
asset = pickAsset(assets, sum).asset ?? asset;
|
||||
} else if (pick.unarchive) {
|
||||
if (dry) { log(TAG, `${tag}: would unarchive ${basename(f.file)} (same file, archived) and select it`); row(placed.length ? 'replace' : 'select', asset); continue; }
|
||||
asset = (await c.asc('PATCH', `/v1/${asset.type}/${asset.id}`, { data: { type: asset.type, id: asset.id, attributes: { archived: false } } })).data as J;
|
||||
log(TAG, `${tag}: unarchived ${basename(f.file)} (asset ${asset.id})`);
|
||||
}
|
||||
if (!dry) asset = await processed(asset, `${tag} ${basename(f.file)}`);
|
||||
const cls = classify(asset.attributes?.state);
|
||||
if (!selectable(cls)) {
|
||||
if (cls === 'processing' && dry) { log(TAG, `${tag}: ${basename(f.file)} is processing in the Asset Library; would select it once processed`); row('wait', asset); continue; }
|
||||
if (cls === 'processing') { row('wait', asset); continue; }
|
||||
warn(TAG, `${tag}: ${basename(f.file)} is ${asset.attributes?.state}${reason(asset)}; not selected`); row('refuse', asset); continue;
|
||||
}
|
||||
const state = String(asset.attributes?.state ?? '');
|
||||
if (state !== 'APPROVED') { log('apple', `${tag}: ${basename(f.file)} waiting for Apple's approval (${state || 'processing'}); re-run once it is approved to select it`); rows.push({ locale, placement: f.placement, file: f.file, action: 'wait', state }); continue; }
|
||||
const action = placed.length ? 'replace' : 'select';
|
||||
if (dry) { log('apple', `${tag}: would ${action === 'replace' ? `replace ${placed.length} selected asset(s) with` : 'select'} ${basename(f.file)}`); rows.push({ locale, placement: f.placement, file: f.file, action }); continue; }
|
||||
if (dry) { log(TAG, `${tag}: would ${action === 'replace' ? `replace ${placed.length} selected asset(s) with` : 'select'} ${basename(f.file)} (${asset.attributes?.state})`); row(action, asset); continue; }
|
||||
for (const p of placed) await c.asc('DELETE', `/v1/appAssetLibraryPlacements/${p.id}`);
|
||||
const media = f.kind === 'image' ? 'image' : 'video';
|
||||
await c.asc('POST', '/v1/appAssetLibraryPlacements', { data: { type: 'appAssetLibraryPlacements', attributes: { placementType: ptype },
|
||||
relationships: { [media]: { data: { type: asset.type, id: asset.id } }, appStoreVersionLocalization: { data: { type: 'appStoreVersionLocalizations', id: loc.id } } } } });
|
||||
log('apple', `${tag}: selected ${basename(f.file)}`);
|
||||
rows.push({ locale, placement: f.placement, file: f.file, action });
|
||||
log(TAG, `${tag}: selected ${basename(f.file)} (${asset.attributes?.state})`);
|
||||
row(action, asset);
|
||||
}
|
||||
}
|
||||
if (dry) return done('apple', 'creative assets checked (dry run, nothing sent)');
|
||||
|
||||
// read back
|
||||
let off = 0;
|
||||
for (const r of rows.filter(r => r.action === 'select' || r.action === 'replace')) {
|
||||
if (!dry) for (const r of rows.filter(r => r.action === 'select' || r.action === 'replace')) {
|
||||
const loc = locs.find(l => l.attributes.locale === r.locale)!;
|
||||
const now = await c.all(`/v1/appStoreVersionLocalizations/${loc.id}/placements?filter[placementType]=${PLACEMENT_TYPE[r.placement]}`);
|
||||
if (now.length !== 1) { off++; warn('apple', `${r.locale} ${PLACEMENT_TYPE[r.placement]}: read back ${now.length} selected assets, wanted 1`); }
|
||||
if (now.length !== 1 || shownOf(now[0]!) !== r.asset?.id) { off++; warn(TAG, `${r.locale} ${PLACEMENT_TYPE[r.placement]}: read back ${now.length} selected assets, wanted ${basename(r.file)}`); }
|
||||
}
|
||||
if (off) process.exitCode = 1;
|
||||
|
||||
// review: one item per distinct unreviewed asset in a slot
|
||||
const unreviewed = new Map<string, J>();
|
||||
for (const r of rows) if (r.asset && r.action !== 'refuse' && r.action !== 'wait' && classify(r.asset.attributes?.state) === 'unreviewed') unreviewed.set(r.asset.id, r.asset);
|
||||
let added = 0;
|
||||
if (unreviewed.size && forReview) {
|
||||
const kindOf = (a: J) => (a.type === 'appAssetLibraryVideos' ? 'appAssetLibraryVideo' : 'appAssetLibraryImage');
|
||||
if (dry) for (const a of unreviewed.values()) log(TAG, `would add ${a.attributes?.fileName ?? a.id} to the draft review submission (${kindOf(a)})`);
|
||||
else {
|
||||
const { id: sid } = await ensureDraft(c, appId, root, TAG);
|
||||
for (const a of unreviewed.values()) {
|
||||
try { if (await addItem(c, sid, kindOf(a), a.id, `creative asset ${a.attributes?.fileName ?? a.id}`, TAG)) added++; }
|
||||
catch (e) { if (e instanceof OtherSubmissionError) warn(TAG, `${a.attributes?.fileName ?? a.id}: already in review submission ${e.otherId}; nothing added`); else throw e; }
|
||||
}
|
||||
log(TAG, `${added} creative asset(s) added to draft review submission ${sid}; nothing was submitted`);
|
||||
}
|
||||
}
|
||||
const n = (a: Row['action'][]) => rows.filter(r => a.includes(r.action)).length;
|
||||
const summary = `creative assets: ${n(['keep'])} up to date, ${n(['select', 'replace'])} ${dry ? 'to select' : 'selected'}, ${n(['upload'])} to upload, ${n(['wait'])} still processing, ${n(['refuse'])} refused${off ? `, ${off} did not read back` : ''}`;
|
||||
if (unreviewed.size) {
|
||||
log(TAG, forReview
|
||||
? `owner step: Submit for Review with the version (or alone once the app has an approved version): ${consoleLink('asc.app-review')}`
|
||||
: `${unreviewed.size} selected asset(s) are not reviewed yet ("Prepare for Submission"): run with --add-for-review to put them into the draft review submission (the version's, or alone once the app has an approved version); Submit for Review stays the owner's: ${consoleLink('asc.app-review')}`);
|
||||
}
|
||||
if (n(['refuse'])) process.exitCode = 1;
|
||||
return done(TAG, dry ? `${summary} (dry run, nothing sent)` : summary);
|
||||
|
||||
async function verifySlots(): Promise<void> {
|
||||
let bad = 0;
|
||||
for (const loc of locs) {
|
||||
const locale: string = loc.attributes.locale;
|
||||
for (const f of local.get(locale) ?? []) {
|
||||
const ptype = PLACEMENT_TYPE[f.placement];
|
||||
const sum = md5(readFileSync(f.file));
|
||||
const placed = await placedIn(loc.id, ptype);
|
||||
const shown = placed.map(p => assets.find(x => x.id === shownOf(p))).filter(Boolean) as J[];
|
||||
const ok = placed.length === 1 && shown[0] && sumOf(shown[0]) === sum;
|
||||
const what = shown.length ? shown.map(a => `${a.attributes?.fileName ?? a.id} (${a.attributes?.state})`).join(', ') : 'nothing';
|
||||
if (ok) log(TAG, `ok ${locale} ${ptype}: ${what}`);
|
||||
else { bad++; warn(TAG, `${locale} ${ptype}: shows ${what}, wanted ${basename(f.file)}${placed.length > 1 ? ` (${placed.length} selected)` : ''}`); }
|
||||
}
|
||||
}
|
||||
if (bad) process.exitCode = 1;
|
||||
done(TAG, `creative assets verified on version ${version!.attributes.versionString} (read-only): ${bad ? `${bad} slot(s) differ from the local files` : 'every slot shows the local file'}`);
|
||||
}
|
||||
const waiting = rows.filter(r => r.action === 'wait').length;
|
||||
done('apple', `creative assets: ${rows.filter(r => r.action === 'keep').length} up to date, ${rows.filter(r => r.action === 'select' || r.action === 'replace').length} selected, ${waiting} waiting for approval${off ? `, ${off} did not read back` : ''}`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export const COMMANDS: Record<string, [() => Promise<Mod>, string]> = {
|
|||
'apple appinfo': [() => import('./apple/appinfo'), 'categories, age rating, content rights, Free price, territories'],
|
||||
'apple review-details': [() => import('./apple/review-details'), 'App Review contact, demo account (from .storebound/, masked) + notes'],
|
||||
'apple status': [() => import('./apple/status'), 'versions, builds, IAPs, review submissions (--wait-review, --cancel-submission <id>)'],
|
||||
'apple creative-assets': [() => import('./apple/creative-assets'), 'Header and Search Results: product page header (21:9) and search results asset (3:2) per locale, or one universal 5244x2950 PNG; uploads to the Asset Library, selects once Apple approved it (MD5 upsert); --dry'],
|
||||
'apple creative-assets': [() => import('./apple/creative-assets'), 'Header and Search Results: product page header (21:9) and search results asset (3:2) per locale, or one universal 5244x2950 PNG; uploads to the Asset Library and selects it once processed (MD5 upsert); --add-for-review, --verify (read-only), --dry'],
|
||||
'apple previews': [() => import('./apple/previews'), 'app preview videos per locale (MD5-idempotent, poster frame time code); --dry'],
|
||||
'apple release': [() => import('./apple/release'), 'phased release on|pause|resume|complete, --manual-release (asks first)'],
|
||||
'apple signing': [() => import('./apple/signing'), 'status | ensure: bundle id capabilities, distribution certificate (key kept in .storebound/signing), App Store profiles installed for Xcode; --dry, asks first'],
|
||||
|
|
|
|||
|
|
@ -88,7 +88,9 @@
|
|||
"write"
|
||||
],
|
||||
"apple creative-assets": [
|
||||
"src"
|
||||
"add-for-review",
|
||||
"src",
|
||||
"verify"
|
||||
],
|
||||
"apple encryption": [
|
||||
"build"
|
||||
|
|
@ -890,6 +892,7 @@
|
|||
"ws": [
|
||||
"aab",
|
||||
"accounts",
|
||||
"add-for-review",
|
||||
"adgroup",
|
||||
"against",
|
||||
"agent",
|
||||
|
|
@ -1111,6 +1114,7 @@
|
|||
"variant",
|
||||
"variants",
|
||||
"vendor",
|
||||
"verify",
|
||||
"version",
|
||||
"version-code",
|
||||
"version-name",
|
||||
|
|
@ -1179,7 +1183,9 @@
|
|||
"storebound apple cpp visible --name \"...\" [--off] [--dry] [--yes] show / hide an approved page (asks)"
|
||||
],
|
||||
"apple creative-assets": [
|
||||
"storebound apple creative-assets [--src store/renders] [--only en-US,tr] [--dry]"
|
||||
"storebound apple creative-assets [--src store/renders] [--only en-US,tr] [--dry] upload + select (upsert)",
|
||||
"storebound apple creative-assets --add-for-review [--dry] also put unreviewed assets into the draft submission",
|
||||
"storebound apple creative-assets --verify read-only: does every slot show the local file?"
|
||||
],
|
||||
"apple encryption": [
|
||||
"storebound apple encryption [--build 42] [--dry]"
|
||||
|
|
|
|||
|
|
@ -246,7 +246,11 @@ export const TOOLS: ToolDef[] = [
|
|||
seconds: { type: 'integer', minimum: 15, maximum: 30 }, captions: { type: 'boolean', default: true } },
|
||||
args: i => [...opt('lang', i.lang), ...opt('target', i.target), ...opt('seconds', i.seconds), ...(i.captions === false ? ['--no-captions'] : [])] },
|
||||
{ name: 'apple_creative_assets', title: 'App Store header and search results assets', command: ['apple', 'creative-assets'], write: true, destructive: true, network: true, idempotent: true,
|
||||
description: 'Header and Search Results (iOS / iPadOS 27+): checks <renders>/<lang>/creative/ (header 3840x1646, search 3:2, universal 5244x2950 PNG; no alpha; videos 5-30 s, 30/60 fps), uploads new files to the App Asset Library, and selects an asset for PRODUCT_PAGE_HEADER_ASSET / APP_STORE_SEARCH_RESULTS_ASSET only once Apple approved it (MD5 upsert, same file = nothing sent). Play counterpart: feature graphic + promo video.',
|
||||
description: 'Header and Search Results (iOS / iPadOS 27+): checks <renders>/<lang>/creative/ (header 3840x1646, search 3:2, universal 5244x2950 PNG; no alpha; videos 5-30 s, 30/60 fps), uploads new files to the App Asset Library and selects them for PRODUCT_PAGE_HEADER_ASSET / APP_STORE_SEARCH_RESULTS_ASSET on the editable version once processed (Prepare for Submission is enough; MD5 upsert, same file = nothing sent, a rejected file is never re-uploaded). add_for_review puts unreviewed assets into the draft review submission (never submits). Play counterpart: feature graphic + promo video.',
|
||||
props: { only, add_for_review: { type: 'boolean', default: false, description: 'Also add the selected, unreviewed assets to the draft review submission (Submit for Review stays the owner\'s)' } },
|
||||
args: i => [...opt('only', i.only), ...(i.add_for_review === true ? ['--add-for-review'] : [])] },
|
||||
{ name: 'apple_creative_assets_verify', title: 'Verify App Store header and search results', command: ['apple', 'creative-assets', '--verify'], write: false, network: true,
|
||||
description: 'Read-only: does every Header and Search Results slot of the editable (else the live) App Store version show the local file (MD5), and in which review state? Fails on a slot that differs.',
|
||||
props: { only }, args: i => opt('only', i.only) },
|
||||
{ name: 'apple_previews', title: 'Upload App Store app previews', command: ['apple', 'previews'], write: true, destructive: true, network: true, idempotent: true,
|
||||
description: 'Sync app preview videos per locale to the editable App Store version (checked locally first; MD5-idempotent, changed sets are replaced; poster frame time code). Not public until the version is submitted and released. Slow: prefer the terminal with a log.',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue