@sprid/release 1.2.2 → 1.4.0
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 +24 -0
- package/README.md +86 -0
- package/package.json +1 -1
- package/src/annotate.ts +4 -1
- package/src/asc/client.ts +16 -4
- package/src/asc/creative.ts +248 -0
- package/src/asc/index.ts +8 -0
- package/src/asc/page-results.ts +218 -0
- package/src/asc/product-pages.ts +513 -0
- package/src/asc/submissions.ts +64 -0
- package/src/cli.ts +75 -5
- package/src/config.ts +75 -0
- package/src/copy.ts +11 -0
- package/src/play/metadata.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
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.4.0 - 2026-10-30
|
|
7
|
+
|
|
8
|
+
- `pages` (`asc-pages`) creates and updates App Store custom product pages from
|
|
9
|
+
`ascCustomProductPages`: screenshots per device profile, promotional text, deep
|
|
10
|
+
link, search keywords and visibility. It prints each page's URL; `--submit`
|
|
11
|
+
sends the page versions to App Review.
|
|
12
|
+
- `page-test` (`asc-page-test`) creates a product page optimization test from
|
|
13
|
+
`ascProductPageTest` with up to three treatments; `--start` starts it and sends
|
|
14
|
+
it to App Review when needed, `--stop` ends it. `--result <text> --annotate`
|
|
15
|
+
records the result Apple shows, since Apple's API has none.
|
|
16
|
+
- `page-results` (`asc-page-results`) reads page views and first-time downloads
|
|
17
|
+
per page from Apple's Detailed analytics reports, each date counted once.
|
|
18
|
+
`--annotate` records the comparison in Sprid.
|
|
19
|
+
- Neither command submits a draft review submission that holds other items.
|
|
20
|
+
|
|
21
|
+
## 1.3.0 - 2026-10-30
|
|
22
|
+
|
|
23
|
+
- `creative` (`asc-creative`) pushes the App Store's product page header, search
|
|
24
|
+
results asset and app previews through Asset Library, from `ascCreative` in the
|
|
25
|
+
config. The dry run checks every file against the store's sizes, lengths and
|
|
26
|
+
frame rates, and refuses an alpha channel or a preview with no audio track.
|
|
27
|
+
- `storeCopy.playVideo` sets the Play preview video (a YouTube URL) with the rest
|
|
28
|
+
of the listing.
|
|
29
|
+
|
|
6
30
|
## 1.2.2 - 2026-10-30
|
|
7
31
|
|
|
8
32
|
- Android releases run on Windows: `npx` and Gradle's wrapper start through cmd.exe
|
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ sprid release metadata # dry run: prints every field it would send
|
|
|
16
16
|
sprid release metadata --execute # sends it
|
|
17
17
|
sprid release screenshots --asc # only App Store Connect
|
|
18
18
|
sprid release graphics --execute # Play feature graphic + icon
|
|
19
|
+
sprid release creative # App Store header, search asset, app previews
|
|
19
20
|
```
|
|
20
21
|
|
|
21
22
|
Install the commands with `npm install -g @sprid/cli`; these local tools require Bun.
|
|
@@ -55,6 +56,85 @@ export default defineReleaseConfig({
|
|
|
55
56
|
});
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
### App Store header, search results and app previews
|
|
60
|
+
|
|
61
|
+
`ascCreative` holds the creative assets iOS and iPadOS 27 show: a product page
|
|
62
|
+
header (3840×1646 PNG or video, or a 5244×2950 universal PNG), a search results
|
|
63
|
+
asset (3:2, 1920×1280 to 3840×2560) and up to three app previews (886×1920,
|
|
64
|
+
15-30 s, with an audio track). Each path may contain `{lang}`.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
ascCreative: {
|
|
68
|
+
header: './store/{lang}/header.png',
|
|
69
|
+
search: './store/{lang}/search.mp4',
|
|
70
|
+
previews: ['./store/{lang}/preview.mp4'],
|
|
71
|
+
},
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The dry run checks size, format, alpha, length and frame rate locally (video
|
|
75
|
+
through `ffprobe` when installed). `--execute` uploads each file once to the
|
|
76
|
+
app's Asset Library, waits for processing, then replaces that placement on the
|
|
77
|
+
editable version in every selected locale. The assets go to review with the
|
|
78
|
+
version; a standalone submission happens in App Store Connect.
|
|
79
|
+
|
|
80
|
+
A Play preview video is listing copy: set `playVideo` (a YouTube URL) on a
|
|
81
|
+
locale's `storeCopy` and push it with `metadata`. An empty string removes it.
|
|
82
|
+
|
|
83
|
+
### Custom product pages and product page tests
|
|
84
|
+
|
|
85
|
+
Two different experiments, measured differently:
|
|
86
|
+
|
|
87
|
+
- A **custom product page** is a second App Store page with its own screenshots,
|
|
88
|
+
promotional text, deep link and search keywords. It only shows to traffic you
|
|
89
|
+
send to its URL (`…?ppid=<page id>`) or to searches for its keywords, so the
|
|
90
|
+
URL is the tag: put it behind an ad, a link in bio or a landing page button.
|
|
91
|
+
- A **product page test** splits the default page's own visitors between the
|
|
92
|
+
original and up to three treatments (icon, screenshots). Apple assigns
|
|
93
|
+
visitors and measures it; there is nothing to tag.
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
ascCustomProductPages: [{
|
|
97
|
+
name: 'Focus', // analytics reports identify the page by this name
|
|
98
|
+
screenshots: { dir: './shots', glob: '{lang}/focus_*.png' }, // or an array, one per device profile
|
|
99
|
+
promotionalText: { en: 'Deep work, timed' },
|
|
100
|
+
deepLink: 'https://example.com/focus',
|
|
101
|
+
keywords: { en: ['focus timer'] }, // must already be keywords of the live version
|
|
102
|
+
}],
|
|
103
|
+
ascProductPageTest: {
|
|
104
|
+
name: 'Outcome-first screenshots', // a finished test cannot restart; the next one needs a new name
|
|
105
|
+
trafficProportion: 50, // percent of visitors in treatments, split evenly
|
|
106
|
+
treatments: [{ name: 'Outcome', screenshots: { dir: './shots', glob: '{lang}/outcome_*.png' } }],
|
|
107
|
+
},
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
sprid release pages # dry run: checks files, text and keywords locally
|
|
112
|
+
sprid release pages --execute --submit # create or update, upload, send to App Review; prints each URL
|
|
113
|
+
sprid release page-test --execute # create the test and its treatments, not started
|
|
114
|
+
sprid release page-test --execute --start # start it, and send it to App Review when its treatments need it
|
|
115
|
+
sprid release page-test --execute --stop # end it early; it cannot restart
|
|
116
|
+
sprid release page-results --days 28 # views and first-time downloads per page
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Screenshots go through Asset Library and replace only the configured device
|
|
120
|
+
profiles; every file is uploaded and processed before an existing one is
|
|
121
|
+
removed. An approved page changes through a new version with the same URL.
|
|
122
|
+
Neither command submits a draft review submission that already holds other
|
|
123
|
+
items (an app version being prepared): the items are added and go to review
|
|
124
|
+
with that submission.
|
|
125
|
+
|
|
126
|
+
`page-results` reads Apple's Detailed analytics reports, where custom product
|
|
127
|
+
pages appear by name: page views, first-time downloads and downloads per view
|
|
128
|
+
for each page against the default page. Apple lags two to three days, drops rows
|
|
129
|
+
under five users and adds noise. It needs an ongoing report request; the first
|
|
130
|
+
run with `--request-reports --execute` creates one (the key needs the Admin
|
|
131
|
+
role) and data arrives one to two days later.
|
|
132
|
+
|
|
133
|
+
Apple's API returns no product page test results. `page-results` shows the
|
|
134
|
+
test's state and dates; the result itself is in App Store Connect → Analytics →
|
|
135
|
+
Acquisition → Product Page Optimization. Record it with
|
|
136
|
+
`sprid release page-test --result "Outcome +14%, 92% confidence" --annotate`.
|
|
137
|
+
|
|
58
138
|
Play shows each tablet slot only on tablets of that size, so one tablet capture goes to both
|
|
59
139
|
slots by default. Every screenshot file is resolved before any slot is emptied.
|
|
60
140
|
|
|
@@ -106,6 +186,12 @@ Add `--annotate` alongside `--execute` to record the change in Sprid using your
|
|
|
106
186
|
existing login or `SPRID_PAT`. Without `--annotate`, releases do not contact Sprid.
|
|
107
187
|
Annotations are best effort. Store publishing works independently of Sprid.
|
|
108
188
|
|
|
189
|
+
Experiments land the same way, next to the store numbers they should move: a
|
|
190
|
+
page update or a test start records the page URLs or the test's treatments and
|
|
191
|
+
traffic share; `page-results --annotate` records each page's downloads per view
|
|
192
|
+
against the default page; `page-test --result "<text>" --annotate` records the
|
|
193
|
+
test result as Apple shows it, with the test's dates.
|
|
194
|
+
|
|
109
195
|
## Library use
|
|
110
196
|
|
|
111
197
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprid/release",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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/annotate.ts
CHANGED
|
@@ -29,8 +29,10 @@ function loadCreds(): Creds | null {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export async function annotate(input: {
|
|
32
|
-
kind: 'listing' | 'screenshots' | 'submission' | 'release';
|
|
32
|
+
kind: 'listing' | 'screenshots' | 'submission' | 'release' | 'note';
|
|
33
33
|
label: string;
|
|
34
|
+
/** Insight areas the change explains, e.g. `['store']`. A `note` explains none unless given. */
|
|
35
|
+
areas?: string[];
|
|
34
36
|
/** App Profile slug; the CLI's `.sprid/app.json` carries it. */
|
|
35
37
|
app?: string;
|
|
36
38
|
meta?: Record<string, unknown>;
|
|
@@ -47,6 +49,7 @@ export async function annotate(input: {
|
|
|
47
49
|
kind: input.kind,
|
|
48
50
|
label: input.label,
|
|
49
51
|
meta: input.meta ?? {},
|
|
52
|
+
...(input.areas ? { areas: input.areas } : {}),
|
|
50
53
|
source: 'cli',
|
|
51
54
|
}),
|
|
52
55
|
});
|
package/src/asc/client.ts
CHANGED
|
@@ -8,7 +8,19 @@ import { readFile } from 'node:fs/promises';
|
|
|
8
8
|
import type { AppReleaseConfig } from '../config.ts';
|
|
9
9
|
import { ascIssuer, ascKeyId, resolveAscKeyPath } from '../config.ts';
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const ASC_ORIGIN = 'https://api.appstoreconnect.apple.com';
|
|
12
|
+
export const ASC_BASE = `${ASC_ORIGIN}/v1`;
|
|
13
|
+
|
|
14
|
+
/** `/x` is a v1 path; `/v2/x` and Apple's absolute `links.next` URLs are used as given. */
|
|
15
|
+
function ascUrl(path: string): string {
|
|
16
|
+
if (path.startsWith('/v2/')) return `${ASC_ORIGIN}${path}`;
|
|
17
|
+
if (/^https?:/.test(path)) {
|
|
18
|
+
const url = new URL(path);
|
|
19
|
+
if (url.origin !== ASC_ORIGIN || url.username || url.password) throw new Error(`Refusing a non-App Store Connect URL: ${url.origin}`);
|
|
20
|
+
return url.href;
|
|
21
|
+
}
|
|
22
|
+
return `${ASC_BASE}${path}`;
|
|
23
|
+
}
|
|
12
24
|
|
|
13
25
|
export interface AscClient {
|
|
14
26
|
/** The app id this client targets (its bundle id). */
|
|
@@ -45,11 +57,11 @@ export function createAscClient(config: AppReleaseConfig): AscClient {
|
|
|
45
57
|
|
|
46
58
|
async function api(path: string, init: RequestInit = {}): Promise<any> {
|
|
47
59
|
const method = init.method ?? 'GET';
|
|
48
|
-
// Reads and
|
|
60
|
+
// Reads and upload completion PATCHes are safe to repeat. Never retry
|
|
49
61
|
// resource creation or review submission automatically after an ambiguous 5xx.
|
|
50
|
-
const repeatable = method === 'GET' || (method === 'PATCH' && /^\/appScreenshots\/[^/]+$/.test(path));
|
|
62
|
+
const repeatable = method === 'GET' || (method === 'PATCH' && /^\/(appScreenshots|appAssetLibraryImages|appAssetLibraryVideos)\/[^/]+$/.test(path));
|
|
51
63
|
for (let attempt = 0; ; attempt++) {
|
|
52
|
-
const res = await fetch(
|
|
64
|
+
const res = await fetch(ascUrl(path), {
|
|
53
65
|
...init,
|
|
54
66
|
redirect: 'error',
|
|
55
67
|
signal: init.signal ?? AbortSignal.timeout(30000),
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Push App Store creative assets through Asset Library (iOS/iPadOS 27+):
|
|
3
|
+
* the product page header, the search results asset and app previews.
|
|
4
|
+
*
|
|
5
|
+
* 1. GET /apps/:id/assetLibrary the app's library
|
|
6
|
+
* 2. POST /appAssetLibraryImages|Videos reservation + uploadOperations
|
|
7
|
+
* 3. PUT bytes to each pre-signed operation (only ASC's requestHeaders)
|
|
8
|
+
* 4. PATCH { uploaded: true }, then poll until processing settles
|
|
9
|
+
* 5. POST /appAssetLibraryPlacements links the asset to the version
|
|
10
|
+
* localization, after deleting that localization's placement of the type
|
|
11
|
+
*
|
|
12
|
+
* Header and search allow one asset per localization; previews up to three per
|
|
13
|
+
* device profile, ordered with an appAssetLibraryPlacementOrderingRequest. Specs
|
|
14
|
+
* mirror GET /appAssetLibraryRefData (2026-10): App Store Connect refuses any
|
|
15
|
+
* other size, so the dry run checks them locally first.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { spawnSync } from 'node:child_process';
|
|
19
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
20
|
+
import { basename, extname } from 'node:path';
|
|
21
|
+
import { listingLocaleMap, releasePath, type AppReleaseConfig } from '../config.ts';
|
|
22
|
+
export type { AscCreativeConfig } from '../config.ts';
|
|
23
|
+
import { createAscClient, type AscClient } from './client.ts';
|
|
24
|
+
import { EDITABLE_STATES } from './version.ts';
|
|
25
|
+
|
|
26
|
+
export interface PushAscCreativeOptions {
|
|
27
|
+
config: AppReleaseConfig;
|
|
28
|
+
/** ASC locale → copy-locale key (defaults to listingLocales.apple / locales.apple). */
|
|
29
|
+
localeMap?: Record<string, string>;
|
|
30
|
+
execute?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type Slot = 'header' | 'search' | 'preview';
|
|
34
|
+
const PLACEMENT: Record<Slot, string> = {
|
|
35
|
+
header: 'PRODUCT_PAGE_HEADER_ASSET',
|
|
36
|
+
search: 'APP_STORE_SEARCH_RESULTS_ASSET',
|
|
37
|
+
preview: 'APP_PREVIEW',
|
|
38
|
+
};
|
|
39
|
+
const IMAGE_EXT = new Set(['.png', '.jpg', '.jpeg']);
|
|
40
|
+
const VIDEO_EXT = new Set(['.mp4', '.m4v', '.mov']);
|
|
41
|
+
const PREVIEW_SIZES = ['886x1920', '1920x886', '1080x1920', '1920x1080', '750x1334', '1334x750',
|
|
42
|
+
'1200x1600', '1600x1200', '900x1200', '1200x900', '3840x2160'];
|
|
43
|
+
|
|
44
|
+
export interface MediaInfo { width: number; height: number; alpha?: boolean; seconds?: number; fps?: number; audio?: boolean }
|
|
45
|
+
|
|
46
|
+
/** Width, height and alpha from a PNG or JPEG header. */
|
|
47
|
+
export function imageInfo(bytes: Buffer): MediaInfo {
|
|
48
|
+
if (bytes.subarray(1, 4).toString('latin1') === 'PNG') {
|
|
49
|
+
const colorType = bytes[25];
|
|
50
|
+
return { width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20), alpha: colorType === 4 || colorType === 6 };
|
|
51
|
+
}
|
|
52
|
+
if (bytes[0] === 0xff && bytes[1] === 0xd8) {
|
|
53
|
+
for (let i = 2; i + 9 < bytes.length;) {
|
|
54
|
+
if (bytes[i] !== 0xff) { i++; continue; }
|
|
55
|
+
const marker = bytes[i + 1];
|
|
56
|
+
if (marker >= 0xc0 && marker <= 0xcf && ![0xc4, 0xc8, 0xcc].includes(marker)) {
|
|
57
|
+
return { width: bytes.readUInt16BE(i + 7), height: bytes.readUInt16BE(i + 5), alpha: false };
|
|
58
|
+
}
|
|
59
|
+
i += 2 + bytes.readUInt16BE(i + 2);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
throw new Error('not a PNG or JPEG');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Video facts from ffprobe; undefined when ffprobe is not installed. */
|
|
66
|
+
function videoInfo(path: string): MediaInfo | undefined {
|
|
67
|
+
const run = spawnSync('ffprobe', ['-v', 'error', '-show_entries', 'stream=codec_type,width,height,avg_frame_rate:format=duration', '-of', 'json', path], { encoding: 'utf8' });
|
|
68
|
+
if (run.error || run.status !== 0) return undefined;
|
|
69
|
+
const probe = JSON.parse(run.stdout);
|
|
70
|
+
const video = probe.streams?.find((s: any) => s.codec_type === 'video');
|
|
71
|
+
if (!video) throw new Error(`${path}: no video stream`);
|
|
72
|
+
const [n, d] = String(video.avg_frame_rate).split('/').map(Number);
|
|
73
|
+
return { width: video.width, height: video.height, seconds: Number(probe.format?.duration), fps: d ? n / d : n,
|
|
74
|
+
audio: probe.streams.some((s: any) => s.codec_type === 'audio') };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Problems with one file for one slot, as App Store Connect would report them. Empty means it fits. */
|
|
78
|
+
export function creativeProblems(slot: Slot, file: string, info: MediaInfo): string[] {
|
|
79
|
+
const ext = extname(file).toLowerCase();
|
|
80
|
+
const video = VIDEO_EXT.has(ext);
|
|
81
|
+
const size = `${info.width}x${info.height}`;
|
|
82
|
+
const problems: string[] = [];
|
|
83
|
+
if (!video && !IMAGE_EXT.has(ext)) return [`${ext || 'no extension'}: use PNG, JPEG, MP4, M4V or MOV`];
|
|
84
|
+
if (!video && info.alpha) problems.push('has an alpha channel; App Store Connect refuses transparency');
|
|
85
|
+
const universal = !video && size === '5244x2950';
|
|
86
|
+
if (universal && ext !== '.png') problems.push('the 5244×2950 universal asset must be a PNG');
|
|
87
|
+
if (slot === 'preview') {
|
|
88
|
+
if (!video) return ['app previews are videos'];
|
|
89
|
+
if (!PREVIEW_SIZES.includes(size)) problems.push(`${size} is not an app preview size (886×1920 for current iPhones)`);
|
|
90
|
+
} else if (slot === 'header' && !universal) {
|
|
91
|
+
if (size !== '3840x1646') problems.push(`${size}: the header is 3840×1646 (21:9) or a 5244×2950 universal PNG`);
|
|
92
|
+
else if (!video && ext !== '.png') problems.push('a 3840×1646 header image must be a PNG');
|
|
93
|
+
} else if (slot === 'search' && !universal) {
|
|
94
|
+
const ratio = info.width * 2 === info.height * 3;
|
|
95
|
+
if (!ratio || info.width < 1920 || info.width > 3840) problems.push(`${size}: search results take 3:2 from 1920×1280 to 3840×2560`);
|
|
96
|
+
}
|
|
97
|
+
if (video && info.seconds !== undefined) {
|
|
98
|
+
const [min, max] = slot === 'preview' ? [15, 30] : [5, 30];
|
|
99
|
+
if (info.seconds < min || info.seconds > max + 0.05) problems.push(`${info.seconds.toFixed(1)} s; ${slot} videos run ${min}-${max} s`);
|
|
100
|
+
const fps = Math.round(info.fps ?? 0);
|
|
101
|
+
if (slot === 'preview' ? fps < 23 || fps > 30 : fps !== 30 && fps !== 60) {
|
|
102
|
+
problems.push(`${fps} fps; ${slot === 'preview' ? 'previews take 23-30' : 'header and search take 30 or 60'}`);
|
|
103
|
+
}
|
|
104
|
+
if (slot === 'preview' && !info.audio) problems.push('app previews need an audio track (silence is fine)');
|
|
105
|
+
}
|
|
106
|
+
return problems;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface Planned { slot: Slot; locale: string; file: string; position: number }
|
|
110
|
+
|
|
111
|
+
function plan(config: AppReleaseConfig, map: Record<string, string>): Planned[] {
|
|
112
|
+
const creative = config.ascCreative;
|
|
113
|
+
if (!creative || (!creative.header && !creative.search && !creative.previews?.length)) {
|
|
114
|
+
throw new Error('release.config.ts needs `ascCreative {header?, search?, previews?}` for asc-creative.');
|
|
115
|
+
}
|
|
116
|
+
if ((creative.previews?.length ?? 0) > 3) throw new Error('App Store Connect takes at most three app previews per device profile.');
|
|
117
|
+
const out: Planned[] = [];
|
|
118
|
+
for (const [locale, lang] of Object.entries(map)) {
|
|
119
|
+
const add = (slot: Slot, path: string, position = 0) =>
|
|
120
|
+
out.push({ slot, locale, position, file: releasePath(config, path.replaceAll('{lang}', lang)) });
|
|
121
|
+
if (creative.header) add('header', creative.header);
|
|
122
|
+
if (creative.search) add('search', creative.search);
|
|
123
|
+
creative.previews?.forEach((path, i) => add('preview', path, i));
|
|
124
|
+
}
|
|
125
|
+
return out;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Resolve and check every file before anything is sent. Throws with all problems at once. */
|
|
129
|
+
function check(items: Planned[]): void {
|
|
130
|
+
const problems: string[] = [];
|
|
131
|
+
const unprobed = new Set<string>();
|
|
132
|
+
for (const { slot, file } of items) {
|
|
133
|
+
if (!existsSync(file)) { problems.push(`${file}: missing`); continue; }
|
|
134
|
+
const video = VIDEO_EXT.has(extname(file).toLowerCase());
|
|
135
|
+
let info: MediaInfo | undefined;
|
|
136
|
+
try { info = video ? videoInfo(file) : imageInfo(readFileSync(file)); } catch (e) { problems.push(`${file}: ${(e as Error).message}`); continue; }
|
|
137
|
+
if (!info) { unprobed.add(file); continue; }
|
|
138
|
+
for (const p of creativeProblems(slot, file, info)) problems.push(`${basename(file)} (${slot}): ${p}`);
|
|
139
|
+
}
|
|
140
|
+
for (const file of unprobed) console.log(` ${basename(file)}: ffprobe not found, size and length unchecked`);
|
|
141
|
+
if (problems.length) throw new Error(`Creative assets do not meet App Store specs:\n ${problems.join('\n ')}`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const SETTLED = new Set(['COMPLETE', 'PREPARE_FOR_SUBMISSION', 'READY_FOR_REVIEW', 'WAITING_FOR_REVIEW', 'IN_REVIEW', 'ACCEPTED', 'APPROVED']);
|
|
145
|
+
|
|
146
|
+
/** Upload one file into the app's Asset Library and wait until App Store Connect has processed it. */
|
|
147
|
+
export async function uploadLibraryAsset(client: AscClient, libraryId: string, file: string,
|
|
148
|
+
opts: { category: 'CREATIVE_ASSETS' | 'APP_SCREENSHOTS_AND_PREVIEWS'; posterFrame?: string; timeoutMs?: number }): Promise<{ type: string; id: string }> {
|
|
149
|
+
const bytes = readFileSync(file);
|
|
150
|
+
const type = VIDEO_EXT.has(extname(file).toLowerCase()) ? 'appAssetLibraryVideos' : 'appAssetLibraryImages';
|
|
151
|
+
const attributes: Record<string, unknown> = { category: opts.category, fileName: basename(file), fileSize: bytes.length };
|
|
152
|
+
if (type === 'appAssetLibraryVideos' && opts.posterFrame) attributes.previewFrameTimeCode = opts.posterFrame;
|
|
153
|
+
const reserved = await client.api(`/${type}`, { method: 'POST', body: JSON.stringify({ data: { type, attributes,
|
|
154
|
+
relationships: { assetLibrary: { data: { type: 'appAssetLibraries', id: libraryId } } } } }) });
|
|
155
|
+
const id: string = reserved.data.id;
|
|
156
|
+
// The PUT goes to Apple's storage, not the API: only the pre-signed headers, no bearer token.
|
|
157
|
+
for (const op of reserved.data.attributes.uploadOperations ?? []) {
|
|
158
|
+
const headers = Object.fromEntries((op.requestHeaders ?? []).map((h: any) => [h.name, h.value]));
|
|
159
|
+
const res = await fetch(op.url, { method: op.method, headers, body: new Uint8Array(bytes.subarray(op.offset, op.offset + op.length)) });
|
|
160
|
+
if (!res.ok) throw new Error(`${basename(file)}: chunk upload failed with ${res.status}\n${await res.text()}`);
|
|
161
|
+
}
|
|
162
|
+
await client.api(`/${type}/${id}`, { method: 'PATCH', body: JSON.stringify({ data: { type, id, attributes: { uploaded: true } } }) });
|
|
163
|
+
const deadline = Date.now() + (opts.timeoutMs ?? 10 * 60_000);
|
|
164
|
+
for (let wait = 2000; ; wait = Math.min(wait * 1.5, 15_000)) {
|
|
165
|
+
const { data } = await client.api(`/${type}/${id}`);
|
|
166
|
+
const state = data.attributes.state;
|
|
167
|
+
if (SETTLED.has(state)) return { type, id };
|
|
168
|
+
if (state === 'FAILED' || state === 'REJECTED') {
|
|
169
|
+
const details = (data.attributes.stateDetails ?? []).map((d: any) => d.description ?? d.code).join('; ');
|
|
170
|
+
throw new Error(`${basename(file)}: App Store Connect marked it ${state}${details ? `: ${details}` : ''}`);
|
|
171
|
+
}
|
|
172
|
+
if (Date.now() > deadline) throw new Error(`${basename(file)}: still ${state} after processing timeout (asset ${id})`);
|
|
173
|
+
await new Promise(r => setTimeout(r, wait));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export async function pushAscCreative({ config, localeMap, execute = false }: PushAscCreativeOptions): Promise<void> {
|
|
178
|
+
console.log(`App Store creative assets push ${execute ? '(EXECUTE)' : '(DRY RUN)'}`);
|
|
179
|
+
const map = listingLocaleMap(config, 'apple', localeMap);
|
|
180
|
+
const items = plan(config, map);
|
|
181
|
+
check(items);
|
|
182
|
+
const profile = config.ascCreative?.previewProfile ?? 'IPHONE_DYNAMIC_ISLAND_LARGE_PROFILE';
|
|
183
|
+
console.log(JSON.stringify(items.map(i => ({ locale: i.locale, placement: PLACEMENT[i.slot], file: i.file })), null, 2));
|
|
184
|
+
console.log('Shows on iOS and iPadOS 27 and later. Earlier versions keep showing screenshots and previews.');
|
|
185
|
+
if (!execute) return;
|
|
186
|
+
|
|
187
|
+
const client = createAscClient(config);
|
|
188
|
+
const app = await client.findApp();
|
|
189
|
+
const { data: library } = await client.api(`/apps/${app.id}/assetLibrary`);
|
|
190
|
+
const versions = await client.api(`/apps/${app.id}/appStoreVersions?filter[platform]=IOS&limit=5`);
|
|
191
|
+
const editable = (versions.data ?? []).find((v: any) => EDITABLE_STATES.has(v.attributes.appStoreState ?? v.attributes.appVersionState));
|
|
192
|
+
if (!editable) {
|
|
193
|
+
throw new Error('No editable iOS version. Creative assets attach to a version in Prepare for Submission; create one, or submit them standalone from Asset Library in App Store Connect.');
|
|
194
|
+
}
|
|
195
|
+
const vLocs = await client.api(`/appStoreVersions/${editable.id}/appStoreVersionLocalizations?limit=200`);
|
|
196
|
+
const localizationIds = new Map<string, string>((vLocs.data ?? []).map((l: any) => [l.attributes.locale, l.id]));
|
|
197
|
+
for (const locale of new Set(items.map(i => i.locale))) {
|
|
198
|
+
if (!localizationIds.has(locale)) throw new Error(`Version ${editable.attributes.versionString} has no ${locale} localization. Push metadata first.`);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// One upload per distinct file, however many locales place it.
|
|
202
|
+
const uploaded = new Map<string, { type: string; id: string }>();
|
|
203
|
+
for (const item of items) {
|
|
204
|
+
if (uploaded.has(item.file)) continue;
|
|
205
|
+
const category = item.slot === 'preview' ? 'APP_SCREENSHOTS_AND_PREVIEWS' : 'CREATIVE_ASSETS';
|
|
206
|
+
uploaded.set(item.file, await uploadLibraryAsset(client, library.id, item.file, { category, posterFrame: config.ascCreative?.posterFrame }));
|
|
207
|
+
console.log(` uploaded ${basename(item.file)}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
for (const locale of new Set(items.map(i => i.locale))) {
|
|
211
|
+
const localizationId = localizationIds.get(locale)!;
|
|
212
|
+
const mine = items.filter(i => i.locale === locale).sort((a, b) => a.position - b.position);
|
|
213
|
+
const slots = new Set(mine.map(i => i.slot));
|
|
214
|
+
const existing = await client.api(`/appStoreVersionLocalizations/${localizationId}/placements?limit=200`);
|
|
215
|
+
for (const p of existing.data ?? []) {
|
|
216
|
+
const slot = (Object.keys(PLACEMENT) as Slot[]).find(s => PLACEMENT[s] === p.attributes.placementType);
|
|
217
|
+
if (!slot || !slots.has(slot) || (slot === 'preview' && p.attributes.placementGroup !== profile)) continue;
|
|
218
|
+
await client.api(`/appAssetLibraryPlacements/${p.id}`, { method: 'DELETE' });
|
|
219
|
+
}
|
|
220
|
+
const previews: string[] = [];
|
|
221
|
+
for (const item of mine) {
|
|
222
|
+
const asset = uploaded.get(item.file)!;
|
|
223
|
+
const placementGroup = item.slot === 'preview' ? profile : 'DEFAULT_PROFILE';
|
|
224
|
+
const media = asset.type === 'appAssetLibraryVideos' ? 'video' : 'image';
|
|
225
|
+
const { data } = await client.api('/appAssetLibraryPlacements', { method: 'POST', body: JSON.stringify({ data: {
|
|
226
|
+
type: 'appAssetLibraryPlacements',
|
|
227
|
+
attributes: { placementType: PLACEMENT[item.slot], placementGroup },
|
|
228
|
+
relationships: {
|
|
229
|
+
[media]: { data: asset },
|
|
230
|
+
appStoreVersionLocalization: { data: { type: 'appStoreVersionLocalizations', id: localizationId } },
|
|
231
|
+
},
|
|
232
|
+
} }) });
|
|
233
|
+
if (item.slot === 'preview') previews.push(data.id);
|
|
234
|
+
console.log(` [${locale}] ${PLACEMENT[item.slot]} ← ${basename(item.file)}`);
|
|
235
|
+
}
|
|
236
|
+
if (previews.length > 1) {
|
|
237
|
+
await client.api('/appAssetLibraryPlacementOrderingRequests', { method: 'POST', body: JSON.stringify({ data: {
|
|
238
|
+
type: 'appAssetLibraryPlacementOrderingRequests',
|
|
239
|
+
attributes: { placementGroup: profile },
|
|
240
|
+
relationships: {
|
|
241
|
+
orderedPlacements: { data: previews.map(id => ({ type: 'appAssetLibraryPlacements', id })) },
|
|
242
|
+
appStoreVersionLocalization: { data: { type: 'appStoreVersionLocalizations', id: localizationId } },
|
|
243
|
+
},
|
|
244
|
+
} }) });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
console.log(`\n✓ Attached to ${editable.attributes.versionString}; they go to review with that version.`);
|
|
248
|
+
}
|
package/src/asc/index.ts
CHANGED
|
@@ -6,3 +6,11 @@ export { pushAscMetadata } from './metadata.ts';
|
|
|
6
6
|
export type { PushAscMetadataOptions } from './metadata.ts';
|
|
7
7
|
export { pushAscScreenshots } from './screenshots.ts';
|
|
8
8
|
export type { PushAscScreenshotsOptions } from './screenshots.ts';
|
|
9
|
+
export { pushAscCreative, creativeProblems, imageInfo, uploadLibraryAsset } from './creative.ts';
|
|
10
|
+
export type { PushAscCreativeOptions } from './creative.ts';
|
|
11
|
+
export { addToReview } from './submissions.ts';
|
|
12
|
+
export type { ReviewItem } from './submissions.ts';
|
|
13
|
+
export { pushCustomProductPages, pushProductPageTest, readProductPageTest, planPages, planTest, DEFAULT_SCREENSHOT_PROFILE } from './product-pages.ts';
|
|
14
|
+
export type { PushPagesOptions, PushTestOptions, PushedPage, TestStatus, PagePlan, TestPlan } from './product-pages.ts';
|
|
15
|
+
export { readPageResults, printPageResults, resultsLabel, downloadsPerView, foldPages } from './page-results.ts';
|
|
16
|
+
export type { PageResults, PageResultsOptions, PageRow } from './page-results.ts';
|