WIP from the MacBook: apple platform helper for submit, resubmit, release and status
This commit is contained in:
parent
3e4015b686
commit
96c1074701
8 changed files with 169 additions and 57 deletions
|
|
@ -1,5 +1,8 @@
|
|||
// Resubmit an App Store version after a rejection (Invalid Binary, Guideline 2.1, ...) with a new build.
|
||||
// storebound apple resubmit --build <n> [--version 1.0.0] [--resolve-iaps] [--dry] [--yes] [--json]
|
||||
// storebound apple resubmit --build <n> [--version 1.0.0] [--platform ios|macos|tvos|visionos] [--resolve-iaps] [--dry] [--yes] [--json]
|
||||
// The platform: --platform, else the only one the app has, else the one platform with a rejected version or a
|
||||
// submission back from App Review (macOS, tvOS and visionOS versions are resubmitted like iOS ones); rejected
|
||||
// versions on two platforms stop and ask for --platform. The build is looked up on that platform.
|
||||
// 1. The rejected version (--version, else the one in the submission back from App Review, else the one in a
|
||||
// rejected state) gets build n attached, by explicit number (never "the latest"); it must be VALID.
|
||||
// 2. The open review submission is reused: the one with UNRESOLVED_ISSUES (it holds the version and its in-app
|
||||
|
|
@ -25,6 +28,7 @@ import { allSubscriptions } from '../lib/subscriptions';
|
|||
import { ascClient, type J } from './asc';
|
||||
import { readSubmitState, submitPlanned } from './iap-submit';
|
||||
import { openSubmissions } from './submission';
|
||||
import { onPlatform, parsePlatform, pickPlatform, platformName, platformOf, platformSlug } from '../lib/apple-platform';
|
||||
|
||||
/** App Store version states a first submission may send: the editable version (Prepare for Submission, a rejected
|
||||
* one, or one already Ready for Review in a draft). */
|
||||
|
|
@ -38,28 +42,38 @@ export async function submitVersion(ctx: Ctx, mode: 'submit' | 'resubmit'): Prom
|
|||
const { config, root } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
const number = a.get('build');
|
||||
if (!number || !/^\d+(\.\d+)*$/.test(number)) throw new Error(`usage: apple ${mode} --build <n> [--version x.y.z] [--dry] [--yes]: the build number you just uploaded (never "the latest")`);
|
||||
if (!number || !/^\d+(\.\d+)*$/.test(number)) throw new Error(`usage: apple ${mode} --build <n> [--version x.y.z] [--platform ios|macos] [--dry] [--yes]: the build number you just uploaded (never "the latest")`);
|
||||
const c = await ascClient(root, need(config.apple?.bundleId, 'apple.bundleId'), config.apple?.appId);
|
||||
const appId = await c.app();
|
||||
const ids = [...(config.products ?? []).filter(p => sellsOn(config, p, 'apple')).map(p => p.id), ...allSubscriptions(config.subscriptions).filter(x => sellsOn(config, x.sub, 'apple')).map(x => x.sub.id)];
|
||||
|
||||
// the version to resubmit
|
||||
const versions = await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=50`);
|
||||
// the version to resubmit, on its platform: one app record holds iOS, macOS, tvOS and visionOS versions, each with
|
||||
// its own review submission. Every platform is read; --platform picks one, else the one platform that has a version
|
||||
// back from App Review (or, for submit, an editable one); two such platforms refuse and ask (apple-platform.ts)
|
||||
const all = await c.all(`/v1/apps/${appId}/appStoreVersions?limit=50`);
|
||||
const stateOf = (v: J): string => v.attributes.appVersionState ?? v.attributes.appStoreState;
|
||||
const open = await openSubmissions(c, appId);
|
||||
const held = new Set(open.filter(s => s.state === 'UNRESOLVED_ISSUES').flatMap(s => s.items.filter(i => i.kind === 'appStoreVersion').map(i => i.versionId)));
|
||||
const openAll = await openSubmissions(c, appId, undefined, 'all');
|
||||
const heldAll = new Set(openAll.filter(s => s.state === 'UNRESOLVED_ISSUES').flatMap(s => s.items.filter(i => i.kind === 'appStoreVersion').map(i => i.versionId)));
|
||||
const want = a.get('version');
|
||||
const wanted = (x: J): boolean => heldAll.has(x.id) || (mode === 'submit' ? SUBMITTABLE_APP : REJECTED_APP).has(stateOf(x));
|
||||
const pick = pickPlatform(all, { flag: parsePlatform(a.get('platform')), version: want, want: wanted, what: mode === 'submit' ? 'a version to submit' : 'a rejected version' });
|
||||
const platform = pick.platform;
|
||||
const pname = platformName(platform);
|
||||
if (pick.note && !a.has('json')) log(TAG, pick.note);
|
||||
const versions = onPlatform(all, platform);
|
||||
const held = new Set(openAll.filter(s => s.state === 'UNRESOLVED_ISSUES' && s.platform === platform).flatMap(s => s.items.filter(i => i.kind === 'appStoreVersion').map(i => i.versionId)));
|
||||
const v: J | undefined = want ? versions.find((x: J) => x.attributes.versionString === want)
|
||||
: versions.find((x: J) => held.has(x.id)) ?? versions.find((x: J) => (mode === 'submit' ? SUBMITTABLE_APP : REJECTED_APP).has(stateOf(x)));
|
||||
if (!v) throw new Error(want ? `no App Store version ${want} on iOS`
|
||||
: mode === 'submit' ? 'no App Store version to submit (none in Prepare for Submission or rejected): storebound apple listing --version x.y.z first'
|
||||
: 'no rejected App Store version and no review submission with UNRESOLVED_ISSUES: nothing to resubmit (storebound apple status)');
|
||||
if (mode === 'submit' && !SUBMITTABLE_APP.has(stateOf(v)) && !held.has(v.id)) throw new Error(`App Store version ${String(v.attributes.versionString)} is ${stateOf(v)}: only a version in Prepare for Submission (or a rejected one) can be submitted`);
|
||||
const seen = `App Store Connect has: ${all.length ? all.map((x: J) => `${String(x.attributes.versionString)} ${platformName(platformOf(x))} ${stateOf(x)}`).join(', ') : 'no version'}`;
|
||||
if (!v) throw new Error(want ? `no App Store version ${want} on ${pname} (${seen})`
|
||||
: mode === 'submit' ? `no ${pname} App Store version to submit (none in Prepare for Submission or rejected; ${seen}): storebound apple listing --version x.y.z${platform === 'IOS' ? '' : ` --platform ${platformSlug(platform)}`} first`
|
||||
: `no rejected App Store version and no review submission with UNRESOLVED_ISSUES on any platform: nothing to resubmit (${seen}; storebound apple status)`);
|
||||
if (mode === 'submit' && !SUBMITTABLE_APP.has(stateOf(v)) && !held.has(v.id)) throw new Error(`${pname} App Store version ${String(v.attributes.versionString)} is ${stateOf(v)}: only a version in Prepare for Submission (or a rejected one) can be submitted`);
|
||||
const versionString = String(v.attributes.versionString);
|
||||
if (!a.has('json')) log(TAG, `app version ${versionString}: ${stateOf(v)}`);
|
||||
if (!a.has('json')) log(TAG, `${pname} app version ${versionString}: ${stateOf(v)}`);
|
||||
|
||||
// the build, by its number
|
||||
const b = (await c.all(`/v1/builds?filter[app]=${appId}&filter[version]=${number}&filter[preReleaseVersion.version]=${versionString}&filter[preReleaseVersion.platform]=IOS`))[0];
|
||||
const b = (await c.all(`/v1/builds?filter[app]=${appId}&filter[version]=${number}&filter[preReleaseVersion.version]=${versionString}&filter[preReleaseVersion.platform]=${platform}`))[0];
|
||||
const cur = (await c.maybe(`/v1/appStoreVersions/${v.id}/build`))?.data;
|
||||
const current = cur ? String(cur.attributes?.version ?? cur.id) : null;
|
||||
const build: BuildStep = !b ? { number, id: null, current, action: 'refuse', reason: `build ${versionString} (${number}) not found (still uploading or processing? storebound apple status)` }
|
||||
|
|
@ -68,7 +82,7 @@ export async function submitVersion(ctx: Ctx, mode: 'submit' | 'resubmit'): Prom
|
|||
: { number, id: b.id, current, action: 'attach', reason: `attach build ${number}${current ? ` instead of ${current}` : ''}` };
|
||||
if (b && b.attributes.usesNonExemptEncryption == null) warn(TAG, `build ${number} has no export compliance answer yet: storebound apple encryption (Apple refuses the submission without it)`);
|
||||
|
||||
const state = await readSubmitState(c, appId, ids, { appVersionId: v.id });
|
||||
const state = await readSubmitState(c, appId, ids, { appVersionId: v.id, platform });
|
||||
const plan = planIapSubmission(state, ids, { withVersion: true, appVersionId: v.id });
|
||||
// --build is a fixed build for the version: its REJECTED item is marked resolved; IAP items only on --resolve-iaps
|
||||
const resolve: ResolveScope = { version: true, iaps: a.has('resolve-iaps') };
|
||||
|
|
@ -77,7 +91,7 @@ export async function submitVersion(ctx: Ctx, mode: 'submit' | 'resubmit'): Prom
|
|||
const blockers = [...(build.action === 'refuse' ? [build.reason] : []), ...plan.blockers];
|
||||
const dry = a.has('dry') || !a.has('yes');
|
||||
if (a.has('json')) {
|
||||
printJson({ dryRun: dry, version: { id: v.id, versionString, state: stateOf(v) }, build, submission: state.choice ?? null, resolve: marks, rows, skipped: plan.skipped, blockers });
|
||||
printJson({ dryRun: dry, platform, platformPick: pick, version: { id: v.id, versionString, state: stateOf(v), platform }, build, submission: state.choice ?? null, resolve: marks, rows, skipped: plan.skipped, blockers });
|
||||
// the desktop's owner dialog shows the output text: the plan table goes with the result there
|
||||
if (process.env.STOREBOUND_MACHINE === '1') { console.log(formatRows(rows)); for (const x of blockers) warn(TAG, x); }
|
||||
if (blockers.length) process.exitCode = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue