@sprid/release 1.2.1 → 1.3.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 CHANGED
@@ -3,6 +3,20 @@
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.3.0 - 2026-10-30
7
+
8
+ - `creative` (`asc-creative`) pushes the App Store's product page header, search
9
+ results asset and app previews through Asset Library, from `ascCreative` in the
10
+ config. The dry run checks every file against the store's sizes, lengths and
11
+ frame rates, and refuses an alpha channel or a preview with no audio track.
12
+ - `storeCopy.playVideo` sets the Play preview video (a YouTube URL) with the rest
13
+ of the listing.
14
+
15
+ ## 1.2.2 - 2026-10-30
16
+
17
+ - Android releases run on Windows: `npx` and Gradle's wrapper start through cmd.exe
18
+ (`gradlew.bat`), with each argument quoted for it.
19
+
6
20
  ## 1.2.1 - 2026-10-08
7
21
 
8
22
  - Republished for the coordinated CLI and screenshot capture update; mobile release behavior remains unchanged.
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,30 @@ 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
+
58
83
  Play shows each tablet slot only on tablets of that size, so one tablet capture goes to both
59
84
  slots by default. Every screenshot file is resolved before any slot is emptied.
60
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprid/release",
3
- "version": "1.2.1",
3
+ "version": "1.3.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/asc/client.ts CHANGED
@@ -45,9 +45,9 @@ export function createAscClient(config: AppReleaseConfig): AscClient {
45
45
 
46
46
  async function api(path: string, init: RequestInit = {}): Promise<any> {
47
47
  const method = init.method ?? 'GET';
48
- // Reads and screenshot completion PATCHes are safe to repeat. Never retry
48
+ // Reads and upload completion PATCHes are safe to repeat. Never retry
49
49
  // resource creation or review submission automatically after an ambiguous 5xx.
50
- const repeatable = method === 'GET' || (method === 'PATCH' && /^\/appScreenshots\/[^/]+$/.test(path));
50
+ const repeatable = method === 'GET' || (method === 'PATCH' && /^\/(appScreenshots|appAssetLibraryImages|appAssetLibraryVideos)\/[^/]+$/.test(path));
51
51
  for (let attempt = 0; ; attempt++) {
52
52
  const res = await fetch(`${ASC_BASE}${path}`, {
53
53
  ...init,
@@ -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,5 @@ 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';
@@ -4,7 +4,7 @@ import { resolve } from 'node:path';
4
4
  import { releasePath } from '../config.ts';
5
5
  import type { AppReleaseConfig } from '../config.ts';
6
6
  import type { AndroidSigning } from './credentials.ts';
7
- import { run, runLogged } from './exec.ts';
7
+ import { GRADLEW, run, runLogged } from './exec.ts';
8
8
  import { stage, stageLogPath } from '../progress.ts';
9
9
 
10
10
 
@@ -98,13 +98,13 @@ export async function buildAndroid(
98
98
  // with "Timeout waiting to lock journal cache". Cheap; a fresh daemon also
99
99
  // guarantees the jvmargs patched above actually apply.
100
100
  try {
101
- await run('./gradlew', ['--stop'], { cwd: resolve(appDir, 'android'), env });
101
+ await run(GRADLEW, ['--stop'], { cwd: resolve(appDir, 'android'), env });
102
102
  } catch {
103
103
  /* no daemon registry yet — nothing to stop */
104
104
  }
105
105
 
106
106
  await stage('android-build', 'Building Android AAB', () =>
107
- runLogged('./gradlew', ['bundleRelease'], {
107
+ runLogged(GRADLEW, ['bundleRelease'], {
108
108
  cwd: resolve(appDir, 'android'),
109
109
  env,
110
110
  logFile: stageLogPath('android-build', releasePath(config, '.')),
package/src/build/exec.ts CHANGED
@@ -10,6 +10,28 @@ export interface RunOptions {
10
10
  }
11
11
 
12
12
 
13
+ /**
14
+ * Windows starts npm shims and Gradle's wrapper (`npx.cmd`, `gradlew.bat`) only
15
+ * through cmd.exe: Node refuses to spawn a .cmd or .bat file directly. cmd.exe
16
+ * splits the line itself, so each argument is quoted here, and one it cannot
17
+ * carry intact (a double quote, a line break) is refused rather than mangled.
18
+ */
19
+ export function spawnTarget(cmd: string, args: string[], platform: NodeJS.Platform = process.platform): { file: string; args: string[]; shell: boolean } {
20
+ if (platform !== 'win32') return { file: cmd, args, shell: false };
21
+ return { file: [cmd, ...args].map(windowsArg).join(' '), args: [], shell: true };
22
+ }
23
+
24
+ export function windowsArg(arg: string): string {
25
+ if (/^[\w@+=:,./\\-]+$/.test(arg)) return arg;
26
+ if (/["\r\n]/.test(arg)) throw new Error(`Cannot pass ${JSON.stringify(arg)} through cmd.exe on Windows.`);
27
+ // A backslash before the closing quote would escape it: double the run.
28
+ return `"${arg.replace(/(\\+)$/, '$1$1')}"`;
29
+ }
30
+
31
+ /** `./gradlew` on macOS and Linux, the wrapper's batch file on Windows. */
32
+ export const GRADLEW = process.platform === 'win32' ? 'gradlew.bat' : './gradlew';
33
+
34
+
13
35
  const SECRET_FLAGS = new Set(['-P', '-p', '--password', '--apiKey']);
14
36
 
15
37
  const SECRET_KEY = /(password|secret|token|apikey|api_key)/i;
@@ -30,7 +52,8 @@ function redactArgs(args: string[]): string {
30
52
 
31
53
  export function run(cmd: string, args: string[], opts: RunOptions = {}): Promise<void> {
32
54
  return new Promise((resolve, reject) => {
33
- const child = spawn(cmd, args, { stdio: 'inherit', cwd: opts.cwd, env: opts.env ?? process.env });
55
+ const target = spawnTarget(cmd, args);
56
+ const child = spawn(target.file, target.args, { stdio: 'inherit', cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
34
57
  child.on('error', reject);
35
58
  child.on('close', (code) => {
36
59
  if (code === 0) resolve();
@@ -56,7 +79,8 @@ export function runLogged(cmd: string, args: string[], opts: RunLoggedOptions):
56
79
  return new Promise((resolve, reject) => {
57
80
  mkdirSync(dirname(opts.logFile), { recursive: true });
58
81
  const log = createWriteStream(opts.logFile);
59
- const child = spawn(cmd, args, { stdio: ['inherit', 'pipe', 'pipe'], cwd: opts.cwd, env: opts.env ?? process.env });
82
+ const target = spawnTarget(cmd, args);
83
+ const child = spawn(target.file, target.args, { stdio: ['inherit', 'pipe', 'pipe'], cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
60
84
 
61
85
  let pending = '';
62
86
  const consume = (chunk: Buffer) => {
@@ -127,7 +151,8 @@ export function tee(commandLine: string, opts: RunOptions = {}): Promise<{ code:
127
151
 
128
152
  export function capture(cmd: string, args: string[], opts: CaptureOptions = {}): Promise<string> {
129
153
  return new Promise((resolve, reject) => {
130
- const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'inherit'], cwd: opts.cwd, env: opts.env ?? process.env });
154
+ const target = spawnTarget(cmd, args);
155
+ const child = spawn(target.file, target.args, { stdio: ['pipe', 'pipe', 'inherit'], cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
131
156
  let out = '';
132
157
  child.stdout.on('data', (d) => (out += d.toString()));
133
158
  child.on('error', reject);
package/src/cli.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  import { loadReleaseConfig, listingLocaleMap, releasePath, type AppReleaseConfig } from './config.ts';
5
5
  import { pushAscMetadata } from './asc/metadata.ts';
6
6
  import { pushAscScreenshots } from './asc/screenshots.ts';
7
+ import { pushAscCreative } from './asc/creative.ts';
7
8
  import { pushPlayMetadata } from './play/metadata.ts';
8
9
  import { pushPlayScreenshots } from './play/screenshots.ts';
9
10
  import { pushPlayGraphics } from './play/graphics.ts';
@@ -36,9 +37,11 @@ const COMMANDS: Record<string, { usage: string; bool: string[]; values?: string[
36
37
  metadata: { usage: 'metadata [--execute] [--asc|--play]', bool: ['execute', 'asc', 'play'] },
37
38
  screenshots: { usage: 'screenshots [--execute] [--asc|--play]', bool: ['execute', 'asc', 'play'] },
38
39
  graphics: { usage: 'graphics [--execute]', bool: ['execute'] },
40
+ creative: { usage: 'creative [--execute]', bool: ['execute'] },
39
41
  'asc-metadata': { usage: 'asc-metadata [--execute]', bool: ['execute'] },
40
42
  'play-metadata': { usage: 'play-metadata [--execute]', bool: ['execute'] },
41
43
  'asc-screenshots': { usage: 'asc-screenshots [--execute]', bool: ['execute'] },
44
+ 'asc-creative': { usage: 'asc-creative [--execute]', bool: ['execute'] },
42
45
  'play-screenshots': { usage: 'play-screenshots [--execute]', bool: ['execute'] },
43
46
  'play-graphics': { usage: 'play-graphics [--execute]', bool: ['execute'] },
44
47
  };
@@ -51,9 +54,9 @@ function printUsage(command?: string): void {
51
54
  }
52
55
  console.log('Usage: sprid release <command> [flags]\n');
53
56
  console.log('Commands:');
54
- for (const name of ['ship', 'bump', 'credentials-pull', 'credentials-push', 'asc-upload', 'play-upload', 'asc-submit', 'metadata', 'screenshots', 'graphics']) console.log(` ${COMMANDS[name].usage}`);
57
+ for (const name of ['ship', 'bump', 'credentials-pull', 'credentials-push', 'asc-upload', 'play-upload', 'asc-submit', 'metadata', 'screenshots', 'graphics', 'creative']) console.log(` ${COMMANDS[name].usage}`);
55
58
  console.log('\nWithout --execute every command is a dry run: it prints what it would send.');
56
- console.log('Per-store names also work: asc-metadata, play-metadata, asc-screenshots, play-screenshots, play-graphics.');
59
+ console.log('Per-store names also work: asc-metadata, play-metadata, asc-screenshots, play-screenshots, play-graphics, asc-creative.');
57
60
  console.log('\n--config <file> accepts TS, JS, MJS or JSON. Paths resolve beside that file.');
58
61
  console.log('--locale <locale,...> selects store locale codes. --annotate records executed changes in Sprid (opt-in).');
59
62
  console.log('\nCredentials (never read into an agent conversation):');
@@ -151,6 +154,7 @@ async function main() {
151
154
  const asc = {
152
155
  metadata: (send = execute) => pushAscMetadata({ config, copy: needCopy(), localeMap: localeMap('apple'), execute: send }),
153
156
  screenshots: (send = execute) => pushAscScreenshots({ config, execute: send, localeMap: localeMap('apple') }),
157
+ creative: (send = execute) => pushAscCreative({ config, execute: send, localeMap: localeMap('apple') }),
154
158
  };
155
159
  const play = {
156
160
  metadata: (send = execute) => pushPlayMetadata({ config, copy: needCopy(), contact: config.contact, localeMap: localeMap('play'), execute: send }),
@@ -161,7 +165,7 @@ async function main() {
161
165
  // What was pushed, for the annotation after a real push.
162
166
  const touched: string[] = [];
163
167
  const s = stores(config);
164
- const appleSelected = command.startsWith('asc-') || (['metadata', 'screenshots'].includes(command) && s.asc);
168
+ const appleSelected = command.startsWith('asc-') || command === 'creative' || (['metadata', 'screenshots'].includes(command) && s.asc);
165
169
  const playSelected = command.startsWith('play-') || command === 'graphics' || (['metadata', 'screenshots'].includes(command) && s.play);
166
170
  if (!appleSelected && !playSelected) throw new Error('Configure appId/ascAppId or play.packageName.');
167
171
  if (appleSelected && !config.appId && !config.ascAppId) throw new Error('Set appId or ascAppId for App Store commands.');
@@ -196,6 +200,10 @@ async function main() {
196
200
  case 'asc-screenshots':
197
201
  await asc.screenshots(); touched.push('App Store screenshots');
198
202
  break;
203
+ case 'creative':
204
+ case 'asc-creative':
205
+ await asc.creative(); touched.push('App Store header and search assets');
206
+ break;
199
207
  case 'play-screenshots':
200
208
  await play.screenshots(); touched.push('Play screenshots');
201
209
  break;
@@ -204,7 +212,7 @@ async function main() {
204
212
  // Annotate the push in Sprid (best effort, only when logged in), so the
205
213
  // Monday mail shows "App Store listing changed (Thu)" next to the numbers.
206
214
  if (execute && has('annotate') && touched.length > 0) {
207
- const kind = /screenshots|graphics/.test(touched.join(' ')) ? 'screenshots' : 'listing';
215
+ const kind = /screenshots|graphics|assets/.test(touched.join(' ')) ? 'screenshots' : 'listing';
208
216
  const ok = await annotate({ kind, label: `${touched.join(' + ')} changed`, app: appSlugFromRepo(releasePath(config, '.')), meta: { command } });
209
217
  if (ok) console.log('\nAnnotated in Sprid: the Monday mail will show this change next to the numbers.');
210
218
  }
package/src/config.ts CHANGED
@@ -263,6 +263,20 @@ export interface AscScreenshotsConfig {
263
263
  deprecatedTypes?: string[];
264
264
  }
265
265
 
266
+ /** App Store creative assets (for the `asc-creative` command). Paths may contain `{lang}`. */
267
+ export interface AscCreativeConfig {
268
+ /** Product page header: 3840×1646 PNG or video (21:9), or a 5244×2950 universal PNG (16:9). */
269
+ header?: string;
270
+ /** Search results: 3:2 image or video, 1920×1280 to 3840×2560, or the universal PNG. */
271
+ search?: string;
272
+ /** App previews in display order, at most three: 886×1920 portrait or 1920×886 landscape, 15-30 s, with an audio track. */
273
+ previews?: string[];
274
+ /** Device profile the previews fill. Default `IPHONE_DYNAMIC_ISLAND_LARGE_PROFILE` (6.9", scaled for smaller iPhones). */
275
+ previewProfile?: string;
276
+ /** Poster frame of every video, `HH:MM:SS:FF`. App Store Connect defaults to 5 s. */
277
+ posterFrame?: string;
278
+ }
279
+
266
280
  /** Play feature-graphic + icon source (for the `play-graphics` command). */
267
281
  export interface PlayGraphicsConfig {
268
282
  /** Feature graphic PNG (1024×500); may contain `{lang}`. */
@@ -334,6 +348,8 @@ export interface AppReleaseConfig {
334
348
  ascScreenshots?: AscScreenshotsConfig;
335
349
  /** Source for `play-graphics` (feature graphic + icon upload). */
336
350
  playGraphics?: PlayGraphicsConfig;
351
+ /** Source for `asc-creative` (product page header, search results asset, app previews). */
352
+ ascCreative?: AscCreativeConfig;
337
353
  /**
338
354
  * Listing-locale maps for the metadata pushes (which locales the *listings*
339
355
  * ship in — may be narrower than `locales`, which also drives release notes).
package/src/copy.ts CHANGED
@@ -27,6 +27,12 @@ export interface StoreCopy {
27
27
  supportUrl?: string;
28
28
  /** Marketing URL (Apple). */
29
29
  marketingUrl?: string;
30
+ /**
31
+ * Play preview video: a public or unlisted YouTube URL with ads off and no age
32
+ * restriction. Shown before the screenshots, autoplays muted where Play allows,
33
+ * full screen when portrait. An empty string removes it. (Play only)
34
+ */
35
+ playVideo?: string;
30
36
  }
31
37
 
32
38
  /** Contact / default-language details for a Play listing. */
@@ -46,6 +52,8 @@ export const LIMITS = {
46
52
  description: 4000,
47
53
  } as const;
48
54
 
55
+ const YOUTUBE_VIDEO = /^https:\/\/(www\.youtube\.com\/watch\?v=|youtu\.be\/)[\w-]{11}([?&#].*)?$/;
56
+
49
57
  /**
50
58
  * Fail loudly on anything a store would reject: over-limit fields, keyword
51
59
  * or empty required strings. Only selected store fields are validated when a store is provided.
@@ -74,6 +82,9 @@ export function validateStoreCopy(copy: Record<string, StoreCopy>, store?: 'appl
74
82
  errors.push(`[${locale}] ${field} is ${value.length}/${LIMITS[field]} chars (over by ${value.length - LIMITS[field]})`);
75
83
  }
76
84
  }
85
+ if (store !== 'apple' && c.playVideo && !YOUTUBE_VIDEO.test(c.playVideo)) {
86
+ errors.push(`[${locale}] playVideo must be a YouTube video URL (youtube.com/watch?v=… or youtu.be/…)`);
87
+ }
77
88
 
78
89
  }
79
90
  if (errors.length) {
@@ -14,7 +14,8 @@ export interface PushPlayMetadataOptions {
14
14
  export async function pushPlayMetadata({ config, copy, contact, localeMap, execute = false }: PushPlayMetadataOptions): Promise<void> {
15
15
  const listings = selectedCopy(copy, listingLocaleMap(config, 'play', localeMap), 'play');
16
16
  const plan = listings.map(([language, c]) => ({ language, title: c.name,
17
- shortDescription: c.shortDescription, fullDescription: c.description }));
17
+ shortDescription: c.shortDescription, fullDescription: c.description,
18
+ ...(c.playVideo === undefined ? {} : { video: c.playVideo }) }));
18
19
  console.log(JSON.stringify({ store: 'play', packageName: config.play?.packageName, listings: plan, contact }, null, 2));
19
20
  if (!execute) return;
20
21
  const client = createPlayClient(config);