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,6 +1,8 @@
|
|||
// Release management for an App Store version.
|
||||
// storebound apple release --phased on|pause|resume|complete [--version 1.2.0] [--dry] [--yes]
|
||||
// storebound apple release --manual-release [--version 1.2.0] [--yes]
|
||||
// storebound apple release --phased on|pause|resume|complete [--version 1.2.0] [--platform ios|macos] [--dry] [--yes]
|
||||
// storebound apple release --manual-release [--version 1.2.0] [--platform ios|macos] [--yes]
|
||||
// The platform: --platform, else the only platform with a version the action applies to (an approved one for
|
||||
// --manual-release); two such platforms stop and ask (cli/lib/apple-platform.ts).
|
||||
// Phased release: 7-day automatic rollout to users with automatic updates (1, 2, 5, 10, 20, 50, 100 %); anyone can
|
||||
// still update by hand from the App Store. Pause holds it (up to 30 days in total), it is NOT a rollback: users who
|
||||
// updated keep the build. "complete" releases to everyone at once.
|
||||
|
|
@ -12,6 +14,7 @@ import { done, log } from '../lib/log';
|
|||
import { type PhasedAction, phasedRequest } from '../lib/release';
|
||||
import { createOnce } from '../lib/upsert';
|
||||
import { ascClient, type J } from './asc';
|
||||
import { onPlatform, parsePlatform, pickPlatform, platformName } from '../lib/apple-platform';
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
|
|
@ -23,15 +26,25 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const dry = a.has('dry');
|
||||
const c = await ascClient(root, need(config.apple?.bundleId, 'apple.bundleId'), config.apple?.appId);
|
||||
const appId = await c.app();
|
||||
const versions = await c.all(`/v1/apps/${appId}/appStoreVersions?filter[platform]=IOS&limit=20`);
|
||||
// every platform: --platform, else the only one with a version this action applies to (apple-platform.ts)
|
||||
const all = await c.all(`/v1/apps/${appId}/appStoreVersions?limit=50`);
|
||||
const want = a.get('version');
|
||||
const state = (v: J): string => v.attributes.appVersionState ?? v.attributes.appStoreState;
|
||||
const LIVE = ['READY_FOR_DISTRIBUTION', 'READY_FOR_SALE'];
|
||||
const fits = (x: J): boolean => manual ? state(x) === 'PENDING_DEVELOPER_RELEASE'
|
||||
: phased === 'on' ? !['READY_FOR_DISTRIBUTION', 'READY_FOR_SALE', 'REPLACED_WITH_NEW_VERSION', 'REMOVED_FROM_SALE'].includes(state(x))
|
||||
: LIVE.includes(state(x)) || !!x.attributes.phasedRelease;
|
||||
const what = manual ? 'a version waiting for developer release' : phased === 'on' ? 'a version not released yet' : 'a live version';
|
||||
const pick = pickPlatform(all, { flag: parsePlatform(a.get('platform')), version: want, want: fits, what });
|
||||
if (pick.note) log('apple', pick.note);
|
||||
const versions = onPlatform(all, pick.platform);
|
||||
const pname = platformName(pick.platform);
|
||||
const v: J | undefined = want ? versions.find(x => x.attributes.versionString === want)
|
||||
: manual ? versions.find(x => state(x) === 'PENDING_DEVELOPER_RELEASE')
|
||||
: phased === 'on' ? versions.find(x => !['READY_FOR_DISTRIBUTION', 'READY_FOR_SALE', 'REPLACED_WITH_NEW_VERSION', 'REMOVED_FROM_SALE'].includes(state(x)))
|
||||
: versions.find(x => ['READY_FOR_DISTRIBUTION', 'READY_FOR_SALE'].includes(state(x))) ?? versions[0];
|
||||
if (!v) throw new Error(want ? `no version ${want}` : manual ? 'no version waiting for developer release (PENDING_DEVELOPER_RELEASE)' : 'no matching version');
|
||||
const tag = `${v.attributes.versionString} (${state(v)})`;
|
||||
: versions.find(x => LIVE.includes(state(x))) ?? versions[0];
|
||||
if (!v) throw new Error(want ? `no ${pname} version ${want}` : manual ? `no ${pname} version waiting for developer release (PENDING_DEVELOPER_RELEASE)` : `no matching ${pname} version`);
|
||||
const tag = `${pname} ${v.attributes.versionString} (${state(v)})`;
|
||||
|
||||
if (manual) {
|
||||
if (state(v) !== 'PENDING_DEVELOPER_RELEASE') throw new Error(`${tag}: only an approved version waiting for developer release can be released`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue