vydanne 0.6.0 → 0.7.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/GETTING_STARTED.md +69 -40
- package/README.md +91 -16
- package/SKILL.md +129 -24
- package/bin/vydanne.mjs +24 -1
- package/package.json +3 -2
- package/src/client.mjs +42 -6
- package/src/commands/accessibility.mjs +13 -0
- package/src/commands/ageRating.mjs +94 -21
- package/src/commands/bridge.mjs +328 -0
- package/src/commands/compliance.mjs +78 -9
- package/src/commands/diff.mjs +63 -19
- package/src/commands/fill.mjs +74 -13
- package/src/commands/inspect.mjs +4 -2
- package/src/commands/preflight.mjs +59 -6
- package/src/commands/prepare.mjs +220 -0
- package/src/commands/prerelease.mjs +17 -5
- package/src/commands/previews.mjs +33 -2
- package/src/commands/privacy.mjs +75 -5
- package/src/commands/push.mjs +118 -0
- package/src/commands/reviewContact.mjs +63 -13
- package/src/config.mjs +53 -4
- package/src/index.mjs +60 -3
- package/src/locales.mjs +27 -5
- package/src/play/aab.mjs +133 -0
- package/src/play/commands/diff.mjs +40 -0
- package/src/play/commands/fill.mjs +20 -19
- package/src/play/commands/prerelease.mjs +94 -20
- package/src/play/images.mjs +67 -0
- package/src/registry.mjs +11 -0
- package/src/screenshots.mjs +112 -0
- package/src/upload.mjs +3 -1
- package/types/index.d.ts +225 -10
- package/vydanne.config.example.mjs +54 -1
package/src/commands/fill.mjs
CHANGED
|
@@ -4,12 +4,11 @@ import { green, yellow, red } from "../util.mjs";
|
|
|
4
4
|
import { VALID } from "../locales.mjs";
|
|
5
5
|
import { uploadAsset } from "../upload.mjs";
|
|
6
6
|
import { reportCrossStore } from "../crossStore.mjs";
|
|
7
|
+
import { deviceMap, screenshotBase, IMAGE_FILE } from "../screenshots.mjs";
|
|
7
8
|
|
|
8
9
|
// Version-localization fields (attr -> metadata filename) and AppInfo fields (name/subtitle, shared).
|
|
9
10
|
const VERSION_TXT = { description: "description", keywords: "keywords", promotionalText: "promotional_text", whatsNew: "release_notes", marketingUrl: "marketing_url", supportUrl: "support_url" };
|
|
10
11
|
const INFO_TXT = { name: "name", subtitle: "subtitle" };
|
|
11
|
-
const IOS_DEVICE = { iphone69: "APP_IPHONE_67", iphone65: "APP_IPHONE_65", ipad13: "APP_IPAD_PRO_3GEN_129", watch: "APP_WATCH_ULTRA" };
|
|
12
|
-
const MAC_DEVICE = { macos: "APP_DESKTOP" };
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* PATCH a localization, surviving attributes Apple refuses to edit RIGHT NOW.
|
|
@@ -61,25 +60,64 @@ export async function run(config, client) {
|
|
|
61
60
|
console.error(red("fill: refusing to upload — fix the listing text, or set VYDANNE_ALLOW_CROSS_STORE=1."));
|
|
62
61
|
return false;
|
|
63
62
|
}
|
|
63
|
+
// No allowLive: name/subtitle live on the app-info record, and the live one must never take a PATCH
|
|
64
|
+
// (Apple would refuse each with INVALID_STATE, failing the whole locale — release notes included).
|
|
64
65
|
const info = await client.appInfo();
|
|
66
|
+
// Said out loud, because the `if (info)` guard below otherwise skips name/subtitle for every locale
|
|
67
|
+
// in perfect silence — twenty locales of "written" with two fields quietly missing from each.
|
|
68
|
+
if (!info) console.log(yellow(" no editable app info — name/subtitle will be skipped (the live record is not writable)"));
|
|
65
69
|
const infoLocs = info ? (await client.get(`/v1/appInfos/${info.id}/appInfoLocalizations?limit=200`)).json.data || [] : [];
|
|
66
70
|
|
|
67
71
|
for (const platform of config.platforms) {
|
|
72
|
+
// No allowLive, deliberately: this is the command whose PATCHes would otherwise land on the listing
|
|
73
|
+
// customers are reading. Refusing is the whole point — an unwritten release note is recoverable, a
|
|
74
|
+
// rewritten live listing is not.
|
|
68
75
|
const v = await client.editVersion(platform);
|
|
69
|
-
if (!v) {
|
|
70
|
-
|
|
76
|
+
if (!v) {
|
|
77
|
+
console.error(red(`fill ${platform}: no editable version — refusing to write to the live listing.`));
|
|
78
|
+
console.error(" `vydanne prepare --apply` creates the version to fill, then re-run this.");
|
|
79
|
+
ok = false;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
console.log(green(`fill ${platform} (metadata=${!skipMeta} screenshots=${!skipShots}) -> ${v.attributes.versionString} ${v.attributes.appStoreState}`));
|
|
71
83
|
const verLocs = await client.versionLocalizations(v.id);
|
|
72
84
|
|
|
73
85
|
if (!skipMeta) {
|
|
74
86
|
let failed = 0;
|
|
75
87
|
const dropped = new Set();
|
|
76
|
-
|
|
88
|
+
// Guarded: a metadataDir that doesn't exist used to surface as a raw ENOENT stack from readdirSync
|
|
89
|
+
// — the Play half of this command has always said it in a sentence, and there is no reason the
|
|
90
|
+
// Apple half should be the one that throws.
|
|
91
|
+
if (!fs.existsSync(config.metadataDir)) {
|
|
92
|
+
console.error(red(`fill ${platform}: no metadata directory at ${config.metadataDir}`));
|
|
93
|
+
console.error(" Create it (one folder per App Store locale), or point `metadataDir` at yours.");
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const all = fs.readdirSync(config.metadataDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
97
|
+
const dirs = all.filter((d) => VALID.has(d));
|
|
98
|
+
// A folder Apple has no locale for is dropped from the upload — silently, until now. `de` instead
|
|
99
|
+
// of `de-DE` is the exact mistake locales.mjs calls the #1 gotcha, and the old filter made it look
|
|
100
|
+
// like the locale had simply been forgotten. Naming it costs one line and saves a release.
|
|
101
|
+
const strays = all.filter((d) => !VALID.has(d));
|
|
102
|
+
if (strays.length) console.log(yellow(` ${strays.length} folder(s) are not App Store locale codes, skipped: ${strays.join(", ")} (\`vydanne locales\` lists the valid ones)`));
|
|
77
103
|
for (const code of dirs) {
|
|
78
104
|
const folder = path.join(config.metadataDir, code);
|
|
79
105
|
const read = (f) => { const p = path.join(folder, `${f}.txt`); return fs.existsSync(p) ? fs.readFileSync(p, "utf8").replace(/\n+$/, "") : null; };
|
|
80
106
|
// version localization (description/keywords/promo/whatsNew/urls)
|
|
81
107
|
let vl = verLocs.find((l) => l.attributes.locale === code);
|
|
82
|
-
if (!vl) {
|
|
108
|
+
if (!vl) {
|
|
109
|
+
const c = await client.post(`/v1/appStoreVersionLocalizations`, { data: { type: "appStoreVersionLocalizations", attributes: { locale: code }, relationships: { appStoreVersion: { data: { type: "appStoreVersions", id: v.id } } } } });
|
|
110
|
+
vl = c.json.data;
|
|
111
|
+
// A refused POST leaves `vl` undefined, and the PATCH below then reads `.id` off it — a raw
|
|
112
|
+
// TypeError that kills the whole fill on one bad locale. Report the locale Apple refused and
|
|
113
|
+
// carry on with the rest, the way every other per-locale failure here behaves.
|
|
114
|
+
if (!vl) {
|
|
115
|
+
console.error(red(` ✗ ${code}: could not create localization — ${JSON.stringify(c.json?.errors?.[0]?.detail || c.json).slice(0, 160)}`));
|
|
116
|
+
failed++;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
verLocs.push(vl);
|
|
120
|
+
}
|
|
83
121
|
const vattrs = {};
|
|
84
122
|
for (const [k, f] of Object.entries(VERSION_TXT)) { const t = read(f); if (t != null) vattrs[k] = t; }
|
|
85
123
|
if (Object.keys(vattrs).length) {
|
|
@@ -117,19 +155,42 @@ export async function run(config, client) {
|
|
|
117
155
|
}
|
|
118
156
|
|
|
119
157
|
async function uploadScreenshots(config, client, platform, verLocs) {
|
|
120
|
-
const base = platform
|
|
121
|
-
const DEV = platform
|
|
158
|
+
const base = screenshotBase(platform, config);
|
|
159
|
+
const DEV = deviceMap(platform);
|
|
122
160
|
if (!fs.existsSync(base)) return;
|
|
123
|
-
|
|
161
|
+
const dirs = fs.readdirSync(base, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
162
|
+
const strays = dirs.filter((d) => !VALID.has(d));
|
|
163
|
+
if (strays.length) console.log(yellow(` ${strays.length} screenshot folder(s) are not App Store locale codes, skipped: ${strays.join(", ")}`));
|
|
164
|
+
for (const code of dirs.filter((d) => VALID.has(d))) {
|
|
124
165
|
const loc = verLocs.find((l) => l.attributes.locale === code);
|
|
125
|
-
|
|
126
|
-
|
|
166
|
+
// Said, not skipped: with VYDANNE_SKIP_METADATA=1 (or a screenshots folder for a locale that has no
|
|
167
|
+
// metadata folder) no localization was created above, and a silent `continue` here reports success
|
|
168
|
+
// for a locale whose screenshots never left the disk.
|
|
169
|
+
if (!loc) { console.log(yellow(` ${code}: no App Store localization — screenshots skipped (run fill with metadata to create it)`)); continue; }
|
|
170
|
+
const files = fs.readdirSync(path.join(base, code)).filter((f) => IMAGE_FILE.test(f)).sort();
|
|
127
171
|
const byDev = {};
|
|
128
|
-
|
|
172
|
+
const unknown = [];
|
|
173
|
+
for (const f of files) { const dt = DEV[f.split("_")[0]]; dt ? (byDev[dt] ||= []).push(f) : unknown.push(f); }
|
|
174
|
+
// The prefix before the first underscore selects the device slot; a file with an unknown one used to
|
|
175
|
+
// vanish without a word — the docs even said "if a screenshot doesn't appear, check the name first",
|
|
176
|
+
// which is the tool telling the user to do its job. Name the files instead.
|
|
177
|
+
if (unknown.length) console.log(yellow(` ${code}: ${unknown.length} file(s) with no device prefix, not uploaded: ${unknown.slice(0, 3).join(", ")}${unknown.length > 3 ? ", …" : ""} (known: ${Object.keys(DEV).join(", ")})`));
|
|
129
178
|
const { json: sets } = await client.get(`/v1/appStoreVersionLocalizations/${loc.id}/appScreenshotSets?include=appScreenshots&limit=50`);
|
|
130
179
|
for (const [dt, list] of Object.entries(byDev)) {
|
|
131
180
|
let set = (sets.data || []).find((s) => s.attributes.screenshotDisplayType === dt);
|
|
132
|
-
|
|
181
|
+
// A populated slot used to `continue` unconditionally — "never duplicate", but it also meant a
|
|
182
|
+
// re-render could NEVER reach a listing that already had images, and because the skip happened
|
|
183
|
+
// before the log below, `fill` reported success having uploaded nothing. Same shape as previews
|
|
184
|
+
// now, and the same VYDANNE_REPLACE flag rather than a second one for the other asset kind.
|
|
185
|
+
const existing = set?.relationships?.appScreenshots?.data || [];
|
|
186
|
+
if (existing.length && process.env.VYDANNE_REPLACE !== "1") {
|
|
187
|
+
console.log(yellow(` ${code}/${dt}: already has ${existing.length}, skipping (set VYDANNE_REPLACE=1 to replace)`));
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
for (const s of existing) { // VYDANNE_REPLACE: drop the old shots so the new upload takes their place
|
|
191
|
+
await client.del(`/v1/appScreenshots/${s.id}`);
|
|
192
|
+
console.log(yellow(` ${code}/${dt}: ${client.dryRun ? "would remove" : "removed"} old screenshot ${s.id}`));
|
|
193
|
+
}
|
|
133
194
|
if (!set) { const c = await client.post(`/v1/appScreenshotSets`, { data: { type: "appScreenshotSets", attributes: { screenshotDisplayType: dt }, relationships: { appStoreVersionLocalization: { data: { type: "appStoreVersionLocalizations", id: loc.id } } } } }); set = c.json.data; }
|
|
134
195
|
for (const f of list) await uploadAsset(client, { type: "appScreenshots", setType: "appScreenshotSet", setId: set.id, filePath: path.join(base, code, f) });
|
|
135
196
|
console.log(green(` ${code}/${dt}: ${list.length} screenshots`));
|
package/src/commands/inspect.mjs
CHANGED
|
@@ -3,8 +3,10 @@ export async function run(config, client) {
|
|
|
3
3
|
await client.findApp(config.bundleId);
|
|
4
4
|
console.log(`APP ${client.app.attributes.name} (${config.bundleId}) id=${client.appId} primary=${client.app.attributes.primaryLocale}`);
|
|
5
5
|
for (const platform of config.platforms) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// allowLive: this command's whole job is reporting what is in the store, and on an app with nothing
|
|
7
|
+
// in preparation the live version is the answer — not something to withhold.
|
|
8
|
+
const v = await client.editVersion(platform, { allowLive: true });
|
|
9
|
+
if (!v) { console.log(` ${platform}: no version at all`); continue; }
|
|
8
10
|
const locs = await client.versionLocalizations(v.id);
|
|
9
11
|
console.log(` ${platform}: v${v.attributes.versionString} ${v.attributes.appStoreState} localizations=${locs.length}`);
|
|
10
12
|
const primary = locs.find((l) => l.attributes.locale === config.primaryLocale) || locs[0];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { green, red, yellow, LIMITS, VERSION_FIELDS } from "../util.mjs";
|
|
2
2
|
import { reportCrossStore } from "../crossStore.mjs";
|
|
3
|
+
import { localScreenshots, remoteScreenshots, compareShots, localScreenshotLocales, unknownScreenshotDirs } from "../screenshots.mjs";
|
|
3
4
|
|
|
4
5
|
// Verify a listing is submission-complete the CORRECT way — each localization read by id (not the sparse
|
|
5
6
|
// list), char limits, primary-locale coverage, per-platform — and warn on the gotchas before ASC does.
|
|
@@ -8,10 +9,33 @@ export async function run(config, client) {
|
|
|
8
9
|
const problems = [], notes = [];
|
|
9
10
|
const res = config.resolvedLocales;
|
|
10
11
|
if (res.unsupported.length) notes.push(`UI locales with no App Store listing (fall back to ${config.primaryLocale}): ${res.unsupported.join(", ")}`);
|
|
12
|
+
if (res.invalid?.length) problems.push(`localeMap points at code(s) Apple does not have: ${res.invalid.join(", ")}`);
|
|
13
|
+
|
|
14
|
+
// name/subtitle live on the APP-INFO record, not the version, which is why they were never checked
|
|
15
|
+
// here — LIMITS has carried a 30-char limit for each since the beginning and nothing read it, while
|
|
16
|
+
// the README listed them among the limits "checked before upload". Read-only, so `allowLive` is
|
|
17
|
+
// right: on an app with nothing in preparation the live record is the only one to measure.
|
|
18
|
+
const info = await client.appInfo({ allowLive: true });
|
|
19
|
+
if (info) {
|
|
20
|
+
const infoLocs = (await client.get(`/v1/appInfos/${info.id}/appInfoLocalizations?limit=200`)).json.data || [];
|
|
21
|
+
for (const il of infoLocs) {
|
|
22
|
+
const a = await client.localization(il.id, "appInfoLocalizations");
|
|
23
|
+
for (const f of ["name", "subtitle"]) {
|
|
24
|
+
const val = (a[f] || "").toString();
|
|
25
|
+
if (!val) { if (f === "name" && il.attributes.locale === config.primaryLocale) problems.push(`${il.attributes.locale}: name EMPTY`); continue; }
|
|
26
|
+
if (val.length > LIMITS[f]) problems.push(`${il.attributes.locale}: ${f} ${val.length}>${LIMITS[f]}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
11
30
|
|
|
12
31
|
for (const platform of config.platforms) {
|
|
32
|
+
// A blocker, and now reachable: this guard existed before but editVersion() handed back the LIVE
|
|
33
|
+
// version instead of null, so preflight validated the shipped listing and called it submittable.
|
|
13
34
|
const v = await client.editVersion(platform);
|
|
14
|
-
if (!v) {
|
|
35
|
+
if (!v) {
|
|
36
|
+
problems.push(`${platform}: no editable version — run \`vydanne prepare --apply\` to create one`);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
15
39
|
console.log(` ${platform}: version ${v.attributes.versionString} (${v.attributes.appStoreState})`);
|
|
16
40
|
const locs = await client.versionLocalizations(v.id);
|
|
17
41
|
const ascLocales = [...new Set([config.primaryLocale, ...Object.values(res.supported)])];
|
|
@@ -27,11 +51,40 @@ export async function run(config, client) {
|
|
|
27
51
|
}
|
|
28
52
|
}
|
|
29
53
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
54
|
+
// EVERY locale with a local screenshot folder, not just the primary one.
|
|
55
|
+
//
|
|
56
|
+
// By CONTENT, not by count — the same comparison `diff` runs (src/screenshots.mjs), so the two
|
|
57
|
+
// cannot disagree about what "in sync" means. The count-only check that replaced called a STALE
|
|
58
|
+
// set green: a full local recapture left three-local-vs-three-remote, preflight said "no blockers",
|
|
59
|
+
// and the submission would have shipped the old art — which is precisely the state Niva sat in with
|
|
60
|
+
// store screenshots still showing a three-tier selector the app no longer had.
|
|
61
|
+
//
|
|
62
|
+
// Restricting that to `primaryLocale` left the same hole open one locale over, and `bridge` widened
|
|
63
|
+
// it: it populates a folder per translated locale, so a de-DE set re-rendered upstream but never
|
|
64
|
+
// re-uploaded passed green while the primary one was checked in full.
|
|
65
|
+
const shotLocales = [...new Set([config.primaryLocale, ...localScreenshotLocales(platform, config)])];
|
|
66
|
+
const strays = unknownScreenshotDirs(platform, config);
|
|
67
|
+
if (strays.length) notes.push(`${platform}: screenshot folder(s) that are not App Store locale codes, never uploaded: ${strays.join(", ")}`);
|
|
68
|
+
|
|
69
|
+
for (const code of shotLocales) {
|
|
70
|
+
const loc = locs.find((l) => l.attributes.locale === code);
|
|
71
|
+
if (!loc) continue; // a missing primary localization is already a blocker above
|
|
72
|
+
const remote = await remoteScreenshots(client, loc.id);
|
|
73
|
+
const count = Object.values(remote).reduce((n, m) => n + m.size, 0);
|
|
74
|
+
// Only the primary listing MUST have screenshots — Apple falls back to it for any locale without.
|
|
75
|
+
if (!count && code === config.primaryLocale) problems.push(`${platform}/${code}: no screenshots`);
|
|
76
|
+
// Freshness is judged only where a local set exists: no local screenshots means there is nothing
|
|
77
|
+
// to compare against, not that the store's are wrong. A display type the store has and local
|
|
78
|
+
// lacks is likewise left alone — `fill` never deletes by omission, so this does not flag it.
|
|
79
|
+
for (const [dt, L] of Object.entries(localScreenshots(platform, code, config))) {
|
|
80
|
+
const c = compareShots(L, remote[dt] || new Map());
|
|
81
|
+
if (!c) continue;
|
|
82
|
+
const slot = dt.replace("APP_", "");
|
|
83
|
+
if (c.kind === "count") problems.push(`${platform}/${code}: screenshots ${slot} local ${c.local} / remote ${c.remote} — the store set is not the local one (\`fill\`, VYDANNE_REPLACE=1 to replace)`);
|
|
84
|
+
else if (c.kind === "renamed") problems.push(`${platform}/${code}: screenshots ${slot} ${c.names.length} local file(s) not on the store by name (\`fill\`, VYDANNE_REPLACE=1 to replace)`);
|
|
85
|
+
else if (c.kind === "stale") problems.push(`${platform}/${code}: screenshots ${slot} STALE — ${c.names.length} of ${c.of} differ in content; green would ship the old art (\`fill\`, VYDANNE_REPLACE=1 to replace)`);
|
|
86
|
+
else notes.push(`${platform}/${code}: screenshots ${slot} present, checksum not reported by Apple — content unverified`);
|
|
87
|
+
}
|
|
35
88
|
}
|
|
36
89
|
}
|
|
37
90
|
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { green, yellow, red } from "../util.mjs";
|
|
4
|
+
import { pointVersionAtBuild, LOCKED_STATES } from "./prerelease.mjs";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create — or reuse — the App Store version you are preparing, and point it at a build.
|
|
8
|
+
*
|
|
9
|
+
* THE GAP THIS CLOSES. Every other Apple command edits *the version being prepared*, which it finds
|
|
10
|
+
* through `client.editVersion()`. On an app whose only version is already on sale there is nothing
|
|
11
|
+
* editable to return, so that call falls back to the live record — and then `fill` aims its
|
|
12
|
+
* description/whatsNew PATCHes at the version customers are looking at, while `prerelease` declines
|
|
13
|
+
* to attach the build it just uploaded ("no editable App Store version — build uploaded, nothing to
|
|
14
|
+
* attach it to"). Neither command can recover on its own, because the thing that is missing is a
|
|
15
|
+
* *version*, and nothing in vydanne ever created one. So preparing a second release always started
|
|
16
|
+
* with a trip to the App Store Connect web UI — exactly the manual step this tool exists to delete.
|
|
17
|
+
*
|
|
18
|
+
* WHAT IT IS NOT. Creating a version is not submitting one. The record this POSTs lands in
|
|
19
|
+
* PREPARE_FOR_SUBMISSION: an editable draft, and the state `fill`, `previews` and `review-contact`
|
|
20
|
+
* all need before they can write anything. `releaseType: MANUAL` then keeps the release itself a
|
|
21
|
+
* human act even after Apple approves it. Add to Review and Submit stay exactly where they were —
|
|
22
|
+
* with you. There is no argument to this command that reaches a reviewer or the public.
|
|
23
|
+
*
|
|
24
|
+
* WHERE THE NUMBER COMES FROM. The newest build Apple holds, read off its preReleaseVersion — which
|
|
25
|
+
* is the archive's own CFBundleShortVersionString. The marketing version therefore travels with the
|
|
26
|
+
* binary, the same way `prerelease` already lets the build number travel with it: Apple assigns
|
|
27
|
+
* nothing and neither do we, so there is no second place to keep the number in step. Preparing a
|
|
28
|
+
* version *before* its build exists is the one case that needs telling, hence VYDANNE_VERSION.
|
|
29
|
+
*
|
|
30
|
+
* RE-RUNNING IS THE POINT. Find-or-create means the command is idempotent: run it before the build
|
|
31
|
+
* exists to get an empty draft, run it again after `prerelease` to attach the binary, run it a third
|
|
32
|
+
* time and it reports that everything already matches. And once the draft exists, `prerelease`
|
|
33
|
+
* attaches to it unaided — `editVersion()` starts finding a real editable version, so the "nothing
|
|
34
|
+
* to attach it to" dead end disappears for every future release too.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** How the CLI is meant to be driven, printed wherever the command can't finish the job itself. */
|
|
38
|
+
const NEXT_STEPS = [
|
|
39
|
+
" next: `vydanne fill --apply` for metadata, then Add to Review + Submit in App Store Connect.",
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
/** Every version Apple holds for this platform. Deliberately NOT `editVersion()`, which collapses the
|
|
43
|
+
* list to a single guess — finding a specific versionString is the whole job here. */
|
|
44
|
+
async function versionsFor(client, platform) {
|
|
45
|
+
const { json } = await client.get(
|
|
46
|
+
`/v1/apps/${client.appId}/appStoreVersions?filter[platform]=${platform}&limit=200` +
|
|
47
|
+
`&fields[appStoreVersions]=versionString,appStoreState`,
|
|
48
|
+
);
|
|
49
|
+
return json.data || [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The newest build, together with the marketing version its archive declares. */
|
|
53
|
+
async function newestBuildWithVersion(client) {
|
|
54
|
+
const { json } = await client.get(
|
|
55
|
+
`/v1/builds?filter[app]=${client.appId}&sort=-uploadedDate&limit=1` +
|
|
56
|
+
`&fields[builds]=version,processingState&include=preReleaseVersion` +
|
|
57
|
+
`&fields[preReleaseVersions]=version`,
|
|
58
|
+
);
|
|
59
|
+
const build = json.data?.[0] ?? null;
|
|
60
|
+
const marketing =
|
|
61
|
+
json.included?.find((r) => r.type === "preReleaseVersions")?.attributes?.version ?? null;
|
|
62
|
+
return { build, marketing };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `<metadataDir>/copyright.txt`, the same supply convention `fill` reads listing text from. */
|
|
66
|
+
function readCopyright(config) {
|
|
67
|
+
if (!config.metadataDir) return null;
|
|
68
|
+
const p = path.join(config.metadataDir, "copyright.txt");
|
|
69
|
+
if (!fs.existsSync(p)) return null;
|
|
70
|
+
return fs.readFileSync(p, "utf8").trim() || null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Is `a` a higher marketing version than `b`?
|
|
75
|
+
*
|
|
76
|
+
* Compared component-wise as NUMBERS, because Apple refuses a versionString that does not exceed the
|
|
77
|
+
* one on sale and a string compare gets the interesting case backwards: "1.10" < "1.9" as text, and
|
|
78
|
+
* 1.10 > 1.9 as a version. Worth a pre-check rather than a 409 the operator has to decode.
|
|
79
|
+
*/
|
|
80
|
+
export function isHigherVersion(a, b) {
|
|
81
|
+
const pa = String(a).split(".").map((n) => Number(n) || 0);
|
|
82
|
+
const pb = String(b).split(".").map((n) => Number(n) || 0);
|
|
83
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
84
|
+
const x = pa[i] || 0;
|
|
85
|
+
const y = pb[i] || 0;
|
|
86
|
+
if (x !== y) return x > y;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Find the version called `versionString`, or create it. Returns the version record, or null when it
|
|
93
|
+
* exists but Apple has locked it — a state only the operator can leave, by withdrawing in the UI.
|
|
94
|
+
*/
|
|
95
|
+
export async function ensureVersion(client, config, platform, versionString) {
|
|
96
|
+
const existing = (await versionsFor(client, platform)).find(
|
|
97
|
+
(v) => v.attributes.versionString === versionString,
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
if (existing) {
|
|
101
|
+
const state = existing.attributes.appStoreState;
|
|
102
|
+
// Reusing prerelease's LOCKED_STATES rather than enumerating the editable states here: one list
|
|
103
|
+
// to keep right, and it is already the list that decides whether a build may be re-pointed.
|
|
104
|
+
if (LOCKED_STATES.has(state)) {
|
|
105
|
+
console.error(red(` version ${versionString} is ${state} — Apple will not let it be edited.`));
|
|
106
|
+
// Two locked cases, two different fixes — telling someone to "withdraw" a version that is ON
|
|
107
|
+
// SALE is advice they cannot take. Shipped once already means the next release needs a HIGHER
|
|
108
|
+
// number, which is the everyday case: the newest build still declares the shipped version
|
|
109
|
+
// because MARKETING_VERSION was never bumped after release.
|
|
110
|
+
if (state === "READY_FOR_SALE" || state === "REPLACED_WITH_NEW_VERSION") {
|
|
111
|
+
console.error(` That version has shipped; the next release needs a higher number. Bump`);
|
|
112
|
+
console.error(` MARKETING_VERSION and re-archive — or name it now: VYDANNE_VERSION=<next> vydanne prepare --apply`);
|
|
113
|
+
} else {
|
|
114
|
+
console.error(" Withdrawing that submission has reviewer-facing consequences, so it stays your");
|
|
115
|
+
console.error(" call: withdraw it in App Store Connect, then re-run this.");
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
console.log(green(` version ${versionString} already exists (${state}) — reusing it`));
|
|
120
|
+
return existing;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const attributes = { platform, versionString, releaseType: "MANUAL" };
|
|
124
|
+
// Set at creation because it is a version-level field: nothing else in vydanne writes `copyright`,
|
|
125
|
+
// and a version submitted without one is a metadata rejection waiting to happen.
|
|
126
|
+
const copyright = readCopyright(config);
|
|
127
|
+
if (copyright) attributes.copyright = copyright;
|
|
128
|
+
|
|
129
|
+
const r = await client.post(`/v1/appStoreVersions`, {
|
|
130
|
+
data: {
|
|
131
|
+
type: "appStoreVersions",
|
|
132
|
+
attributes,
|
|
133
|
+
relationships: { app: { data: { type: "apps", id: client.appId } } },
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
if (r.status >= 300) {
|
|
138
|
+
console.error(red(` could not create version ${versionString} (${r.status})`));
|
|
139
|
+
for (const e of r.json?.errors || []) console.error(` ${e.title}: ${e.detail}`);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const how = copyright ? ", copyright set" : "";
|
|
144
|
+
// Said in the tense that happened. A dry run reported "created version 1.2" in green immediately
|
|
145
|
+
// after saying it would POST one — two lines that contradict each other, and the green one is the
|
|
146
|
+
// one people remember.
|
|
147
|
+
console.log(client.dryRun
|
|
148
|
+
? yellow(` WOULD create version ${versionString} — PREPARE_FOR_SUBMISSION, releaseType MANUAL${how}`)
|
|
149
|
+
: green(` created version ${versionString} — PREPARE_FOR_SUBMISSION, releaseType MANUAL${how}`));
|
|
150
|
+
return r.json.data;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export async function run(config, client) {
|
|
154
|
+
await client.findApp(config.bundleId);
|
|
155
|
+
// EVERY declared platform. iOS and macOS are separate App Store versions with separate records, and
|
|
156
|
+
// preparing only `platforms[0]` left the second one with nothing editable — so `fill MAC_OS` refused
|
|
157
|
+
// ("no editable version") on an app whose iOS draft had just been created, and `push` stopped there.
|
|
158
|
+
// `fill`, `previews` and `preflight` have always looped; this is the command that creates what they
|
|
159
|
+
// loop over.
|
|
160
|
+
let ok = true;
|
|
161
|
+
for (const platform of config.platforms) {
|
|
162
|
+
if (!(await prepareOne(config, client, platform))) ok = false;
|
|
163
|
+
}
|
|
164
|
+
if (!ok) return false;
|
|
165
|
+
|
|
166
|
+
console.log("prepare done — the version is editable.");
|
|
167
|
+
for (const line of NEXT_STEPS) console.log(line);
|
|
168
|
+
console.log(yellow(" Submitting for App Store review stays manual, by design."));
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async function prepareOne(config, client, platform) {
|
|
173
|
+
console.log(green(`prepare → App Store version (${platform})`));
|
|
174
|
+
|
|
175
|
+
const { build, marketing } = await newestBuildWithVersion(client);
|
|
176
|
+
const target = process.env.VYDANNE_VERSION || marketing;
|
|
177
|
+
|
|
178
|
+
if (!target) {
|
|
179
|
+
console.error(red("prepare: nothing tells me which version to prepare."));
|
|
180
|
+
console.error(" Apple holds no build to read a marketing version from. Either upload one —");
|
|
181
|
+
console.error(" `vydanne prerelease --apply` — or name the version yourself:");
|
|
182
|
+
console.error(" VYDANNE_VERSION=1.2 vydanne prepare --apply");
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const source = process.env.VYDANNE_VERSION ? "VYDANNE_VERSION" : `build ${build?.attributes?.version}`;
|
|
187
|
+
console.log(` preparing ${target} (from ${source})`);
|
|
188
|
+
|
|
189
|
+
// The version on sale is the floor Apple enforces. Checking it here turns an opaque 409 into a
|
|
190
|
+
// sentence, and catches the likelier mistake: forgetting to bump MARKETING_VERSION before archiving.
|
|
191
|
+
const versions = await versionsFor(client, platform);
|
|
192
|
+
const live = versions.find((v) => v.attributes.appStoreState === "READY_FOR_SALE");
|
|
193
|
+
if (live && live.attributes.versionString !== target && !isHigherVersion(target, live.attributes.versionString)) {
|
|
194
|
+
console.error(red(` ${target} does not exceed ${live.attributes.versionString}, which is on sale.`));
|
|
195
|
+
console.error(" Apple only accepts a higher version. Bump MARKETING_VERSION, re-archive, re-upload.");
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
if (live) console.log(` on sale: ${live.attributes.versionString}`);
|
|
199
|
+
|
|
200
|
+
const version = await ensureVersion(client, config, platform, target);
|
|
201
|
+
if (!version) return false;
|
|
202
|
+
|
|
203
|
+
if (!build) {
|
|
204
|
+
console.log(yellow(" no build uploaded yet — the version is ready for one."));
|
|
205
|
+
console.log(" `vydanne prerelease --apply` will upload it and attach it to this version.");
|
|
206
|
+
} else if (marketing && marketing !== target) {
|
|
207
|
+
// The newest build belongs to a DIFFERENT marketing version — almost always because the archive for
|
|
208
|
+
// this one has not been uploaded yet, and VYDANNE_VERSION named the version ahead of its binary.
|
|
209
|
+
// Attaching it would put the previous release's binary behind the new version's number: Apple rejects
|
|
210
|
+
// that at submission, and it is a confusing thing to debug from the reviewer's message.
|
|
211
|
+
console.log(yellow(` build ${build.attributes.version} declares ${marketing}, not ${target} — not attaching it.`));
|
|
212
|
+
console.log(` Archive ${target} and upload it (\`vydanne prerelease --apply\`); this version is waiting.`);
|
|
213
|
+
} else if (build.attributes.processingState === "PROCESSING") {
|
|
214
|
+
console.log(yellow(` build ${build.attributes.version} is still PROCESSING — not attaching it yet.`));
|
|
215
|
+
console.log(" Re-run once Apple finishes, or let `vydanne prerelease --apply` attach it.");
|
|
216
|
+
} else {
|
|
217
|
+
await pointVersionAtBuild(client, config, build, version);
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
@@ -127,7 +127,7 @@ export async function run(config, client, credentials) {
|
|
|
127
127
|
// right answer for an accident and a dead end for a re-run, so say which it is.
|
|
128
128
|
if (/already exists|redundant binary|previously uploaded/i.test(text)) {
|
|
129
129
|
console.error(red(" Apple already holds this build number."));
|
|
130
|
-
console.error(" Bump CFBundleVersion (
|
|
130
|
+
console.error(" Bump CFBundleVersion (the build number, not the marketing version) and re-archive.");
|
|
131
131
|
} else {
|
|
132
132
|
console.error(red(" upload failed:"));
|
|
133
133
|
console.error(indent(text));
|
|
@@ -207,14 +207,21 @@ async function assignToInternalGroup(client, build, groupName) {
|
|
|
207
207
|
else console.error(yellow(` could not add to "${groupName}" (${r.status})`));
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
/** Versions Apple will not let us re-point without the operator withdrawing them first.
|
|
211
|
-
|
|
210
|
+
/** Versions Apple will not let us re-point without the operator withdrawing them first. Exported
|
|
211
|
+
* because `prepare` needs the same answer about the same states — two lists would drift. */
|
|
212
|
+
export const LOCKED_STATES = new Set([
|
|
212
213
|
"WAITING_FOR_REVIEW",
|
|
213
214
|
"IN_REVIEW",
|
|
214
215
|
"PENDING_DEVELOPER_RELEASE",
|
|
215
216
|
"PENDING_APPLE_RELEASE",
|
|
216
217
|
"READY_FOR_SALE",
|
|
217
218
|
"REPLACED_WITH_NEW_VERSION",
|
|
219
|
+
// Both removed-from-sale states are shipped versions that Apple will not reopen for editing.
|
|
220
|
+
// client.mjs has always treated them as dead for `editVersion()`; leaving them out here meant
|
|
221
|
+
// `prepare` would "reuse" one and hand every later step a version whose first write Apple refuses —
|
|
222
|
+
// the refusal arriving as an opaque INVALID_STATE instead of the sentence below it.
|
|
223
|
+
"REMOVED_FROM_SALE",
|
|
224
|
+
"DEVELOPER_REMOVED_FROM_SALE",
|
|
218
225
|
]);
|
|
219
226
|
|
|
220
227
|
/**
|
|
@@ -222,12 +229,17 @@ const LOCKED_STATES = new Set([
|
|
|
222
229
|
*
|
|
223
230
|
* This is what makes "upload a fix and try again" one command rather than a trip to the web UI:
|
|
224
231
|
* the version → build relationship holds exactly one build, so a PATCH re-points it.
|
|
232
|
+
*
|
|
233
|
+
* [known] is the version to attach to, when the caller has already resolved it. `prepare` passes the
|
|
234
|
+
* draft it just found or created, because `editVersion()` cannot tell a fresh draft from the live
|
|
235
|
+
* record on an app that already has a version on sale — it returns whichever the list yields first.
|
|
225
236
|
*/
|
|
226
|
-
export async function pointVersionAtBuild(client, config, build) {
|
|
237
|
+
export async function pointVersionAtBuild(client, config, build, known = null) {
|
|
227
238
|
const platform = (config.platforms && config.platforms[0]) || "IOS";
|
|
228
|
-
const version = await client.editVersion(platform);
|
|
239
|
+
const version = known || (await client.editVersion(platform));
|
|
229
240
|
if (!version) {
|
|
230
241
|
console.log(yellow(" no editable App Store version — build uploaded, nothing to attach it to."));
|
|
242
|
+
console.log(" `vydanne prepare --apply` creates the version to attach it to, then re-run this.");
|
|
231
243
|
return;
|
|
232
244
|
}
|
|
233
245
|
const state = version.attributes.appStoreState;
|
|
@@ -5,16 +5,40 @@ import { uploadAsset, setPreviewPoster } from "../upload.mjs";
|
|
|
5
5
|
|
|
6
6
|
// Upload App Preview videos natively (reserve → chunked PUT → commit → poll processing → poster frame).
|
|
7
7
|
// config.previews: [{ platform, type, file, poster, locales }]. Skips locales that already have a preview.
|
|
8
|
+
//
|
|
9
|
+
// EVERY failure below is recorded, not just printed. This command used to `return true` unconditionally:
|
|
10
|
+
// each error path printed red and `continue`d, so a rejected upload was indistinguishable from a clean
|
|
11
|
+
// run to the one caller that asks — `push`, which promises to stop at the first failing step. It didn't:
|
|
12
|
+
// previews could fail loudly, push would carry on through age-rating/review-contact/accessibility, and
|
|
13
|
+
// preflight (which never inspects previews) would sign the whole thing off as green. The `continue`s are
|
|
14
|
+
// still right — one missing video must not hide the state of the rest — but the verdict has to survive
|
|
15
|
+
// them, so the loop keeps going and the RETURN carries the failure out.
|
|
8
16
|
export async function run(config, client) {
|
|
9
17
|
await client.findApp(config.bundleId);
|
|
10
18
|
const specs = config.previews || defaultSpecs(config);
|
|
19
|
+
const failures = [];
|
|
20
|
+
// defaultSpecs filters to files that exist, so with no `previews` config and no video on disk this
|
|
21
|
+
// command used to print NOTHING and exit 0 — indistinguishable from a successful upload in a CI log.
|
|
22
|
+
// Not a failure: an app with no previews is a normal app, and `push` must not stall on one.
|
|
23
|
+
if (!specs.length) console.log(yellow(" no previews configured and none found at the default paths — nothing to upload."));
|
|
11
24
|
for (const s of specs) {
|
|
12
25
|
const v = await client.editVersion(s.platform);
|
|
13
|
-
if (!v) {
|
|
26
|
+
if (!v) {
|
|
27
|
+
console.error(red(` ${s.platform}: no editable version — nothing to upload previews to.`));
|
|
28
|
+
console.error(" `vydanne prepare --apply` creates the version being submitted, then re-run this.");
|
|
29
|
+
failures.push(`${s.platform}: no editable version`);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
14
32
|
const locs = await client.versionLocalizations(v.id);
|
|
15
33
|
for (const code of s.locales || [config.primaryLocale]) {
|
|
16
34
|
const loc = locs.find((l) => l.attributes.locale === code);
|
|
17
|
-
|
|
35
|
+
// A configured locale the version doesn't have must be said, not skipped — the spec NAMES this
|
|
36
|
+
// locale, so silence here reports success for a preview that never left the disk.
|
|
37
|
+
if (!loc) {
|
|
38
|
+
console.error(red(` ${s.platform}/${code}: no App Store localization — preview skipped (run \`fill\` to create it)`));
|
|
39
|
+
failures.push(`${s.platform}/${code}: no App Store localization`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
18
42
|
try {
|
|
19
43
|
const { json: sets } = await client.get(`/v1/appStoreVersionLocalizations/${loc.id}/appPreviewSets?include=appPreviews&limit=50`);
|
|
20
44
|
let set = (sets.data || []).find((x) => x.attributes.previewType === s.type);
|
|
@@ -36,6 +60,7 @@ export async function run(config, client) {
|
|
|
36
60
|
// works. Name it and move on, so one missing video doesn't hide the rest of the report.
|
|
37
61
|
if (!fs.existsSync(file)) {
|
|
38
62
|
console.error(red(` ${s.platform}/${code}/${s.type}: ${path.relative(process.cwd(), file)} does not exist — nothing to upload`));
|
|
63
|
+
failures.push(`${s.platform}/${code}/${s.type}: ${path.relative(process.cwd(), file)} missing`);
|
|
39
64
|
continue;
|
|
40
65
|
}
|
|
41
66
|
console.log(` ${s.platform}/${code}/${s.type}: ${client.dryRun ? "would upload" : "uploading"} ${path.basename(file)}...`);
|
|
@@ -44,9 +69,15 @@ export async function run(config, client) {
|
|
|
44
69
|
if (!client.dryRun) console.log(green(` done ${s.platform}/${code}/${s.type}`));
|
|
45
70
|
} catch (e) {
|
|
46
71
|
console.error(red(` error ${s.platform}/${code}/${s.type}: ${e.message}`));
|
|
72
|
+
failures.push(`${s.platform}/${code}/${s.type}: ${e.message}`);
|
|
47
73
|
}
|
|
48
74
|
}
|
|
49
75
|
}
|
|
76
|
+
if (failures.length) {
|
|
77
|
+
console.error(red(`previews: ${failures.length} failed — nothing above was silently skipped:`));
|
|
78
|
+
for (const f of failures) console.error(` ${red("x")} ${f}`);
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
50
81
|
return true;
|
|
51
82
|
}
|
|
52
83
|
|