@sprid/release 1.5.1 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  @sprid/release follows semver: a breaking change to a command's arguments, its
4
4
  output shape or its exit codes is a major release.
5
5
 
6
+ ## 1.5.3 - 2026-11-06
7
+
8
+ - The Google Play metadata push creates the listing for a language the app has not had yet, where it used to fail with a 404.
9
+
10
+ ## 1.5.2 - 2026-11-02
11
+
12
+ - Custom product page pushes reuse images already in the app's Asset Library
13
+ instead of uploading byte-identical copies again, so a rerun after a failure
14
+ no longer adds another set. App Store Connect writes wait up to 180 s, reads
15
+ 30 s. `SPRID_ASC_TRACE=1` logs each request with its duration.
16
+
6
17
  ## 1.5.1 - 2026-11-01
7
18
 
8
19
  - Updated dependencies: googleapis 189 and jose 6. Commands and output are
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprid/release",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Build, sign and release mobile apps locally. Store copy, screenshots, binary uploads and review submissions from one app-owned configuration. Dry run by default.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
package/src/asc/client.ts CHANGED
@@ -61,12 +61,15 @@ export function createAscClient(config: AppReleaseConfig): AscClient {
61
61
  // resource creation or review submission automatically after an ambiguous 5xx.
62
62
  const repeatable = method === 'GET' || (method === 'PATCH' && /^\/(appScreenshots|appAssetLibraryImages|appAssetLibraryVideos)\/[^/]+$/.test(path));
63
63
  for (let attempt = 0; ; attempt++) {
64
+ // Asset Library writes (reserve, commit, place, reorder) can take well over 30 s at Apple.
65
+ const started = Date.now();
64
66
  const res = await fetch(ascUrl(path), {
65
67
  ...init,
66
68
  redirect: 'error',
67
- signal: init.signal ?? AbortSignal.timeout(30000),
69
+ signal: init.signal ?? AbortSignal.timeout(method === 'GET' ? 30000 : 180000),
68
70
  headers: { Authorization: `Bearer ${await getToken()}`, 'Content-Type': 'application/json', ...(init.headers || {}) },
69
71
  });
72
+ if (process.env.SPRID_ASC_TRACE) console.log(` ASC ${method} ${path} → ${res.status} in ${Date.now() - started} ms`);
70
73
  if (res.ok) return res.status === 204 ? null : res.json();
71
74
  const body = await res.text();
72
75
  if (repeatable && attempt < 3 && [429, 500, 502, 503, 504].includes(res.status)) {
@@ -143,11 +143,48 @@ function check(items: Planned[]): void {
143
143
 
144
144
  const SETTLED = new Set(['COMPLETE', 'PREPARE_FOR_SUBMISSION', 'READY_FOR_REVIEW', 'WAITING_FOR_REVIEW', 'IN_REVIEW', 'ACCEPTED', 'APPROVED']);
145
145
 
146
- /** Upload one file into the app's Asset Library and wait until App Store Connect has processed it. */
146
+ const libraryImages = new Map<string, Promise<any[]>>();
147
+
148
+ /** Every image already in the library, read once per run. */
149
+ function listLibraryImages(client: AscClient, libraryId: string): Promise<any[]> {
150
+ let list = libraryImages.get(libraryId);
151
+ if (!list) {
152
+ list = (async () => {
153
+ const out: any[] = [];
154
+ for (let next: string | undefined = `/appAssetLibraries/${libraryId}/images?limit=200`, pages = 0; next && pages < 50; pages++) {
155
+ const res = await client.api(next);
156
+ out.push(...(res?.data ?? []));
157
+ next = res?.links?.next;
158
+ }
159
+ return out;
160
+ })();
161
+ libraryImages.set(libraryId, list);
162
+ }
163
+ return list;
164
+ }
165
+
166
+ /** A processed library image with the same byte size and pixel dimensions, preferring the same file name.
167
+ * The library has no checksum; size plus dimensions identifies a byte-identical copy of a store shot. */
168
+ export function matchLibraryImage(images: any[], file: string, bytes: Buffer): { type: string; id: string } | undefined {
169
+ let info: MediaInfo;
170
+ try { info = imageInfo(bytes); } catch { return undefined; }
171
+ const same = images.filter(i => SETTLED.has(i.attributes?.state) && i.attributes?.fileSize === bytes.length
172
+ && i.attributes?.imageAsset?.width === info.width && i.attributes?.imageAsset?.height === info.height);
173
+ const hit = same.find(i => i.attributes.fileName === basename(file)) ?? same[0];
174
+ return hit ? { type: 'appAssetLibraryImages', id: hit.id } : undefined;
175
+ }
176
+
177
+ /** Upload one file into the app's Asset Library and wait until App Store Connect has processed it.
178
+ * An image already in the library (same size and dimensions) is reused instead of uploaded again, so a
179
+ * rerun after a timeout, or a page built from the listing's own shots, adds nothing to the library. */
147
180
  export async function uploadLibraryAsset(client: AscClient, libraryId: string, file: string,
148
181
  opts: { category: 'CREATIVE_ASSETS' | 'APP_SCREENSHOTS_AND_PREVIEWS'; posterFrame?: string; timeoutMs?: number }): Promise<{ type: string; id: string }> {
149
182
  const bytes = readFileSync(file);
150
183
  const type = VIDEO_EXT.has(extname(file).toLowerCase()) ? 'appAssetLibraryVideos' : 'appAssetLibraryImages';
184
+ if (type === 'appAssetLibraryImages') {
185
+ const existing = matchLibraryImage(await listLibraryImages(client, libraryId), file, bytes);
186
+ if (existing) { console.log(` reused ${basename(file)} (already in the Asset Library)`); return existing; }
187
+ }
151
188
  const attributes: Record<string, unknown> = { category: opts.category, fileName: basename(file), fileSize: bytes.length };
152
189
  if (type === 'appAssetLibraryVideos' && opts.posterFrame) attributes.previewFrameTimeCode = opts.posterFrame;
153
190
  const reserved = await client.api(`/${type}`, { method: 'POST', body: JSON.stringify({ data: { type, attributes,
@@ -204,7 +241,7 @@ export async function pushAscCreative({ config, localeMap, execute = false }: Pu
204
241
  if (uploaded.has(item.file)) continue;
205
242
  const category = item.slot === 'preview' ? 'APP_SCREENSHOTS_AND_PREVIEWS' : 'CREATIVE_ASSETS';
206
243
  uploaded.set(item.file, await uploadLibraryAsset(client, library.id, item.file, { category, posterFrame: config.ascCreative?.posterFrame }));
207
- console.log(` uploaded ${basename(item.file)}`);
244
+ console.log(` ready ${basename(item.file)}`);
208
245
  }
209
246
 
210
247
  for (const locale of new Set(items.map(i => i.locale))) {
@@ -177,7 +177,7 @@ async function uploadAll(client: AscClient, appId: string, files: string[]): Pro
177
177
  const { data: library } = await client.api(`/apps/${appId}/assetLibrary`);
178
178
  for (const file of new Set(files)) {
179
179
  uploaded.set(file, await uploadLibraryAsset(client, library.id, file, { category: 'APP_SCREENSHOTS_AND_PREVIEWS' }));
180
- console.log(` uploaded ${basename(file)}`);
180
+ console.log(` ready ${basename(file)}`);
181
181
  }
182
182
  return uploaded;
183
183
  }
@@ -22,7 +22,11 @@ export async function pushPlayMetadata({ config, copy, contact, localeMap, execu
22
22
  const { play, packageName } = client;
23
23
  await client.withEdit(async editId => {
24
24
  for (const listing of plan) {
25
- await play.edits.listings.patch({ packageName, editId, language: listing.language, requestBody: listing });
25
+ // patch cannot create: a language new to the listing answers 404 and needs update.
26
+ await play.edits.listings.patch({ packageName, editId, language: listing.language, requestBody: listing }).catch((error: { code?: number; status?: number }) => {
27
+ if (error.code !== 404 && error.status !== 404) throw error;
28
+ return play.edits.listings.update({ packageName, editId, language: listing.language, requestBody: listing });
29
+ });
26
30
  }
27
31
  if (contact) await play.edits.details.patch({ packageName, editId, requestBody: contact });
28
32
  });