live read run fixes: Xcode-managed profiles in signing, TestFlight-only release trains, scan skips agent worktrees and takes an absolute --config, --all-pages paging meta, iap-submit json, report hints
This commit is contained in:
parent
0856f2d1b2
commit
3a775f7808
15 changed files with 282 additions and 30 deletions
|
|
@ -250,6 +250,12 @@ export function mergePages(a: Record<string, unknown>, b: Record<string, unknown
|
|||
delete out.nextPageToken;
|
||||
if (out.tokenPagination) delete out.tokenPagination;
|
||||
if (out.links && typeof out.links === 'object') out.links = { ...(out.links as Record<string, unknown>), next: undefined };
|
||||
// Apple's paging meta of the first page ("nextCursor", the page limit) would say there is more: keep only the total
|
||||
const meta = out.meta as { paging?: Record<string, unknown> } | undefined;
|
||||
if (meta?.paging && typeof meta.paging === 'object') {
|
||||
const { nextCursor: _c, limit: _l, ...rest } = meta.paging;
|
||||
out.meta = { ...meta, paging: rest };
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'bundleIdCapabilities_createInstance': 'lib/signing',
|
||||
'bundleIds_createInstance': 'apple/bundle',
|
||||
'bundleIds_getCollection': 'apple/adhoc apple/bundle apple/signing',
|
||||
'bundleIds_profiles_getToManyRelated': 'apple/adhoc apple/signing',
|
||||
'bundleIds_profiles_getToManyRelated': 'apple/adhoc lib/signing',
|
||||
'certificates_createInstance': 'apple/signing lib/signing',
|
||||
'certificates_getCollection': 'apple/adhoc apple/signing',
|
||||
'customerReviewResponses_createInstance': 'lib/reviews',
|
||||
|
|
@ -146,7 +146,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'inAppPurchasesV2_offerCodes_getToManyRelated': 'apple/offer-codes',
|
||||
'inAppPurchasesV2_pricePoints_getToManyRelated': 'apple/iap apple/offer-codes prices prices-ppp',
|
||||
'inAppPurchasesV2_versions_getToManyRelated': 'apple/iap-submit',
|
||||
'profiles_certificates_getToManyRelationship': 'apple/signing',
|
||||
'profiles_certificates_getToManyRelationship': 'lib/signing',
|
||||
'profiles_createInstance': 'apple/adhoc lib/signing',
|
||||
'profiles_devices_getToManyRelated': 'apple/adhoc',
|
||||
'profiles_getInstance': 'apple/signing',
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ export async function readSubmitState(c: Asc, appId: string, want: string[]): Pr
|
|||
return { appVersions, iaps, subs, groups, draft };
|
||||
}
|
||||
|
||||
/** The requests a run would send: none when nothing is left to submit (seen live: every product already in review). */
|
||||
export function planRequests<R>(prepare: R[], plan: { items: unknown[]; submit: R }): R[] {
|
||||
return plan.items.length ? [...prepare, plan.submit] : [];
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
|
|
@ -73,7 +78,7 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const prepare = plan.prepare.map(r => bindIds(r, { app: appId }));
|
||||
if (a.has('json')) {
|
||||
printJson({ dryRun: dry, items: plan.items, skipped: plan.skipped, firstOfType: plan.firstOfType, hasApprovedVersion: plan.hasApprovedVersion,
|
||||
needsAppVersion: plan.needsAppVersion, blockers: plan.blockers, draft: state.draft?.id ?? null, requests: [...prepare, plan.submit].map(r => describeReq(r)) });
|
||||
needsAppVersion: plan.needsAppVersion, blockers: plan.blockers, draft: state.draft?.id ?? null, requests: planRequests(prepare, plan).map(r => describeReq(r)) });
|
||||
if (dry || plan.blockers.length) { if (plan.blockers.length) process.exitCode = 1; return; }
|
||||
} else {
|
||||
for (const it of plan.items) log(TAG, `submit: ${it.label}`);
|
||||
|
|
@ -84,7 +89,7 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (plan.blockers.length) { process.exitCode = 1; done(TAG, 'nothing sent: fix the blockers above'); return; }
|
||||
if (!plan.items.length) { done(TAG, 'nothing to submit'); return; }
|
||||
if (dry) {
|
||||
await execute(c.asc, [...prepare, plan.submit], { dry, tag: TAG });
|
||||
await execute(c.asc, planRequests(prepare, plan), { dry, tag: TAG });
|
||||
done(TAG, `dry run: ${plan.items.length} item(s) would go into ${state.draft ? `draft ${state.draft.id}` : 'a new draft submission'}`);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { buildCsr, csrContent, newSigningKey, spkiOfKey } from '../lib/csr';
|
|||
import { done, log, printJson, warn } from '../lib/log';
|
||||
import {
|
||||
type ApiCert, type ApiProfile, type AppleSigning, capabilitySpecs, CERT_LIMIT, certificateReq, certSha1, certSpki, type CertType,
|
||||
explainCertError, parseIdentities, pickCertificate, planCapabilities, planProfile, profileDirs, type ProfileType,
|
||||
explainCertError, parseIdentities, pickCertificate, planCapabilities, planProfile, profileDirs, type ProfileType, readProfiles,
|
||||
} from '../lib/signing';
|
||||
import { textTable } from '../lib/table';
|
||||
import { type Asc, ascClient, type J } from './asc';
|
||||
|
|
@ -55,15 +55,7 @@ export async function findBundleId(c: Asc, identifier: string): Promise<J | null
|
|||
return hit;
|
||||
}
|
||||
|
||||
async function profilesOf(c: Asc, bundleIdId: string, type: ProfileType): Promise<ApiProfile[]> {
|
||||
const ps = await c.all(`/v1/bundleIds/${bundleIdId}/profiles?limit=200`);
|
||||
const out: ApiProfile[] = [];
|
||||
for (const p of ps.filter((p: J) => p.attributes.profileType === type)) {
|
||||
const certs = await c.all(`/v1/profiles/${p.id}/relationships/certificates?limit=200`);
|
||||
out.push({ id: p.id, attributes: p.attributes, certIds: certs.map((x: J) => x.id) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
const profilesOf = (c: Asc, bundleIdId: string, type: ProfileType): Promise<ApiProfile[]> => readProfiles(p => c.all(p), bundleIdId, type);
|
||||
|
||||
const installedAt = (uuid: string | undefined): string[] => (uuid ? profileDirs(homedir()).map(d => join(d, `${uuid}.mobileprovision`)).filter(existsSync) : []);
|
||||
|
||||
|
|
@ -143,6 +135,10 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const p = profiles.get(id)!;
|
||||
if (!bundles.get(id)) return { bundleId: id, name: null, uuid: null, state: 'bundle id not registered', installed: false, why: 'register it first (storebound apple bundle for the app; extensions in Certificates, Identifiers & Profiles)' };
|
||||
const r = p.plan?.reuse;
|
||||
const managed = p.list.find(x => x.managed && x.attributes.profileState === 'ACTIVE');
|
||||
if (!r && managed && (s.style ?? 'automatic') === 'automatic')
|
||||
return { bundleId: id, name: managed.attributes.name ?? null, uuid: managed.attributes.uuid ?? null, state: 'Xcode-managed', installed: installedAt(managed.attributes.uuid).length > 0,
|
||||
why: `automatic signing: xcodebuild -allowProvisioningUpdates keeps it (expires ${managed.attributes.expirationDate?.slice(0, 10) ?? '?'})` };
|
||||
return { bundleId: id, name: r?.attributes.name ?? null, uuid: r?.attributes.uuid ?? null, state: r ? 'ACTIVE' : 'needs a new profile',
|
||||
installed: installedAt(r?.attributes.uuid).length > 0, why: p.plan?.why ?? 'waits for a usable certificate' };
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,18 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (!/READY_FOR_SALE|READY_FOR_DISTRIBUTION|PENDING_DEVELOPER_RELEASE|PENDING_APPLE_RELEASE|ACCEPTED/.test(st)) continue;
|
||||
phased[v.id] = (await c.maybe(`/v1/appStoreVersions/${v.id}/appStoreVersionPhasedRelease`))?.data ?? null;
|
||||
}
|
||||
printJson({ app, versions, builds: builds.data, iaps, subs, phased });
|
||||
// builds attached to a version but older than the five newest (so the train shows their number too)
|
||||
const known = new Set((builds.data as { id: string }[]).map(b => b.id));
|
||||
const missing = [...new Set(versions.map(v => v.relationships?.build?.data?.id).filter((id): id is string => !!id && !known.has(id)))];
|
||||
const attachedBuilds = missing.length ? ((await c.asc('GET', `/v1/builds?filter[id]=${missing.join(',')}&limit=${missing.length}`)).data ?? []) : [];
|
||||
// build id -> marketing version (CFBundleShortVersionString): a TestFlight-only version is a train at "testing"
|
||||
const buildVersions: Record<string, string> = {};
|
||||
const pre = new Map(((builds.included ?? []) as { id: string; type?: string; attributes?: { version?: string } }[]).map(p => [p.id, p.attributes?.version] as const));
|
||||
for (const b of builds.data as { id: string; relationships?: { preReleaseVersion?: { data?: { id?: string } } } }[]) {
|
||||
const v = pre.get(b.relationships?.preReleaseVersion?.data?.id ?? '');
|
||||
if (v) buildVersions[b.id] = v;
|
||||
}
|
||||
printJson({ app, versions, builds: builds.data, attachedBuilds, buildVersions, iaps, subs, phased });
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,10 @@ export function phasedFraction(p: { state?: string; currentDayNumber?: number |
|
|||
|
||||
export function appleReleases(data: unknown): StoreRelease[] {
|
||||
const versions = ((data as J)?.versions ?? []) as J[];
|
||||
const builds = new Map((((data as J)?.builds ?? []) as J[]).map(b => [b.id, b.attributes?.version] as const));
|
||||
const recent = (((data as J)?.builds ?? []) as J[]);
|
||||
const builds = new Map([...recent, ...(((data as J)?.attachedBuilds ?? []) as J[])].map(b => [b.id, b.attributes?.version] as const));
|
||||
const phasedById = (((data as J)?.phased ?? {}) as Record<string, J | null>);
|
||||
return versions.filter(v => typeof v?.attributes?.versionString === 'string' && (v.attributes.platform ?? 'IOS') === 'IOS').map(v => {
|
||||
const rows = versions.filter(v => typeof v?.attributes?.versionString === 'string' && (v.attributes.platform ?? 'IOS') === 'IOS').map(v => {
|
||||
const state = String(v.attributes.appVersionState ?? v.attributes.appStoreState ?? 'UNKNOWN');
|
||||
const buildId = v.relationships?.build?.data?.id;
|
||||
let phase = applePhase(state);
|
||||
|
|
@ -64,6 +65,21 @@ export function appleReleases(data: unknown): StoreRelease[] {
|
|||
if (typeof v.attributes.createdDate === 'string') r.date = v.attributes.createdDate;
|
||||
return r;
|
||||
});
|
||||
return [...rows, ...testflightReleases(recent, ((data as J)?.buildVersions ?? {}) as Record<string, string>, new Set(rows.map(r => r.version)))];
|
||||
}
|
||||
|
||||
/** Marketing versions that have a processed build but no App Store version yet: on the train at "testing" (TestFlight),
|
||||
* with the highest build number. Seen live: builds of 0.6.0 in TestFlight while 0.5.0 waited for review. */
|
||||
export function testflightReleases(builds: J[], buildVersions: Record<string, string>, versions: Set<string | null>): StoreRelease[] {
|
||||
const best = new Map<string, string>();
|
||||
for (const b of builds) {
|
||||
const v = buildVersions[b?.id];
|
||||
const n = b?.attributes?.version;
|
||||
if (!v || versions.has(v) || typeof n !== 'string' || b.attributes.processingState !== 'VALID' || b.attributes.expired) continue;
|
||||
const cur = best.get(v);
|
||||
if (!cur || cmpVersion(n, cur) > 0) best.set(v, n);
|
||||
}
|
||||
return [...best].map(([version, build]) => ({ store: 'ios' as const, version, build, state: 'TESTFLIGHT', phase: 'testing' as const, fraction: null, track: 'TestFlight' }));
|
||||
}
|
||||
|
||||
/** Leading dotted version of a Play release name ("2.3.0 (45)" -> "2.3.0"). */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// `storebound scan` engine: detect the project, run the rejection-risk rules, propose the declarations. Offline and
|
||||
// read-only (the only write is `--write`, done by the command, never here).
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { join, relative } from 'node:path';
|
||||
import { join, relative, resolve } from 'node:path';
|
||||
import { CONFIG_NAMES, loadConfig, type ShipConfig } from '../config';
|
||||
import { reviewDemoAccount } from '../credentials';
|
||||
import { proposeDeclarations, type Proposal } from './declare';
|
||||
|
|
@ -30,7 +30,7 @@ export interface ScanRun { report: ScanReport; facts: ProjectFacts; config: Ship
|
|||
/** Find the project's config: --config, else storebound.config.* in `dir` (no upward search: a fixture or a
|
||||
* sub-project must not pick up a parent's config). */
|
||||
async function findConfig(dir: string, explicit?: string): Promise<{ config: ShipConfig | null; path: string | null; error: string | null }> {
|
||||
const path = explicit ? join(dir, explicit) : CONFIG_NAMES.map(n => join(dir, n)).find(existsSync);
|
||||
const path = explicit ? resolve(dir, explicit) : CONFIG_NAMES.map(n => join(dir, n)).find(existsSync);
|
||||
if (!path) return { config: null, path: null, error: null };
|
||||
try { return { config: (await loadConfig(path)).config, path, error: null }; } catch (e) { return { config: null, path, error: (e as Error).message.split('\n').slice(0, 4).join('; ') }; }
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ async function findConfig(dir: string, explicit?: string): Promise<{ config: Shi
|
|||
export async function runScan(dir: string, o: { config?: string } = {}): Promise<ScanRun> {
|
||||
const facts = detectProject(dir);
|
||||
const { config, path: configPath, error } = await findConfig(dir, o.config);
|
||||
const rel = (p: string) => relative(dir, p) || p;
|
||||
const rel = (p: string) => { const r = relative(dir, p); return r && !r.startsWith('..') ? r : p; };
|
||||
const readRel = (p: string | undefined): { path: string; text: string } | undefined => {
|
||||
if (!p) return undefined;
|
||||
const abs = join(dir, p);
|
||||
|
|
|
|||
|
|
@ -91,11 +91,18 @@ export interface ProjectFacts {
|
|||
|
||||
const SKIP_DIRS = new Set(['.git', 'node_modules', 'Pods', 'build', 'Build', 'DerivedData', '.gradle', '.dart_tool', '.build', 'Library', 'Temp', 'Logs',
|
||||
'obj', 'UserSettings', '.storebound', 'renders', '.idea', '.vscode', '.expo', 'vendor', 'xcuserdata', 'Carthage', '.next', 'coverage', '.godot',
|
||||
'intermediates', 'generated', 'outputs', 'tmp', '.cxx', 'fastlane', 'dist', 'www', 'public', 'clips', 'frames', 'fonts', '.fvm']);
|
||||
'intermediates', 'generated', 'outputs', 'tmp', '.cxx', 'fastlane', 'dist', 'www', 'public', 'clips', 'frames', 'fonts', '.fvm',
|
||||
// AI tool folders: .claude/worktrees holds whole copies of the repo (seen live: evidence pointed into them)
|
||||
'.claude', '.cursor', '.windsurf', '.codex', '.gemini']);
|
||||
const SRC_EXT = new Set(['.swift', '.m', '.mm', '.h', '.kt', '.java', '.dart', '.js', '.jsx', '.ts', '.tsx', '.cs', '.gd', '.html', '.vue', '.svelte']);
|
||||
const MAX_FILES = 25_000;
|
||||
const MAX_TEXT = 1_500_000;
|
||||
|
||||
/** A linked git worktree: its .git is a file pointing into <repo>/.git/worktrees/ (a submodule's points into modules/). */
|
||||
function isWorktree(dir: string): boolean {
|
||||
try { return /^gitdir:.*[\\/]worktrees[\\/]/m.test(readFileSync(join(dir, '.git'), 'utf8')); } catch { return false; }
|
||||
}
|
||||
|
||||
/** Every file under root (relative paths), skipping build output, dependency folders and VCS data. Native libraries
|
||||
* (.so) of any size also go into `bins` when given (they are not read, only listed). */
|
||||
export function listFiles(root: string, bins?: string[]): string[] {
|
||||
|
|
@ -112,6 +119,8 @@ export function listFiles(root: string, bins?: string[]): string[] {
|
|||
if (st.isDirectory()) {
|
||||
// compiled frameworks are SDK binaries, not app code
|
||||
if (/\.(xc)?framework$|\.xcassets$|\.bundle$|\.app$|\.dSYM$/.test(n)) continue;
|
||||
// a git worktree inside the project (another checkout of the same repo; submodules stay in)
|
||||
if (isWorktree(p)) continue;
|
||||
walk(p, depth + 1);
|
||||
} else {
|
||||
if (bins && n.endsWith('.so')) bins.push(relative(root, p).split(sep).join('/'));
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export const SIGNALS = {
|
|||
privateScheme: /["'`](App-Prefs|prefs):root\b/,
|
||||
ratePrompt: /["'`>](Rate (us|this app)|Enjoying [A-Z][\w ]{0,30}\?|Love (this|the) app\?)/,
|
||||
reviewApi: /SKStoreReviewController|requestReview|StoreReview\.requestReview|InAppReview|in_app_review|react-native-rate|requestReviewFlow|ReviewManager/,
|
||||
incentiveRating: /(rate|review)\b[^"'`\n]{0,60}\b(reward|coins?|gems?|bonus|free (lives|spins|coins))|(reward|coins?|gems?|bonus)\b[^"'`\n]{0,40}\b(for|to) (rating|reviewing|rate|review)\b|5[- ]?stars?\b[^"'`\n]{0,40}\b(reward|get|earn)/i,
|
||||
incentiveRating: /(?<![\w-])(rate|review)(?![\w-])(?!\s+limit)[^"'`\n]{0,60}\b(rewards?|rewarded|coins?|gems?|bonus|free (lives|spins|coins))\b|(reward|coins?|gems?|bonus)\b[^"'`\n]{0,40}\b(for|to) (rating|reviewing|rate|review)\b|5[- ]?stars?\b[^"'`\n]{0,40}\b(reward|get|earn)/i,
|
||||
externalBuy: /\b(buy|subscribe|purchase|upgrade|pay)\b[^.\n]{0,40}\b(on|at|via|from) (our )?(website|web ?site|web|site)\b/i,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,31 @@ export function explainCertError(err: unknown, type: CertType): string | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
export interface ApiProfile { id: string; attributes: { name?: string; profileType?: string; profileState?: string; expirationDate?: string; uuid?: string; profileContent?: string }; certIds?: string[] }
|
||||
export interface ApiProfile {
|
||||
id: string; attributes: { name?: string; profileType?: string; profileState?: string; expirationDate?: string; uuid?: string; profileContent?: string };
|
||||
certIds?: string[];
|
||||
/** Xcode-managed profile (automatic signing, "iOS Team Store Provisioning Profile: ..."): listed under the bundle id,
|
||||
* but /v1/profiles/{id} answers 404 for it, so its certificates are unknown and storebound never reuses it. */
|
||||
managed?: boolean;
|
||||
}
|
||||
|
||||
/** The profiles of one bundle id of `type`, each with its certificate ids. A profile the profiles API does not serve
|
||||
* (404: Xcode-managed, seen live October 2026) is kept with `managed: true` instead of failing the whole read. */
|
||||
export async function readProfiles(all: (path: string) => Promise<{ id: string; attributes?: Record<string, unknown> }[]>, bundleIdId: string, type: ProfileType): Promise<ApiProfile[]> {
|
||||
const ps = await all(`/v1/bundleIds/${bundleIdId}/profiles?limit=200`);
|
||||
const out: ApiProfile[] = [];
|
||||
for (const p of ps.filter(p => p.attributes?.profileType === type)) {
|
||||
const attributes = p.attributes as ApiProfile['attributes'];
|
||||
try {
|
||||
const certs = await all(`/v1/profiles/${p.id}/relationships/certificates?limit=200`);
|
||||
out.push({ id: p.id, attributes, certIds: certs.map(x => x.id) });
|
||||
} catch (e) {
|
||||
if (!/-> 404\b/.test((e as Error).message)) throw e;
|
||||
out.push({ id: p.id, attributes, managed: true });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export const profileName = (bundleId: string, type: ProfileType, date = new Date()): string =>
|
||||
`storebound ${bundleId} ${type === 'IOS_APP_STORE' ? 'App Store' : type} ${date.toISOString().slice(0, 16).replace('T', ' ')}`;
|
||||
|
|
@ -136,8 +160,12 @@ export function planProfile(existing: ApiProfile[], o: { bundleId: string; bundl
|
|||
&& Date.parse(p.attributes.expirationDate ?? '') - now > 14 * 86_400_000 && (p.certIds ?? []).includes(o.certId))
|
||||
.sort((a, b) => Date.parse(b.attributes.expirationDate!) - Date.parse(a.attributes.expirationDate!));
|
||||
if (ok[0]) return { reuse: ok[0], create: null, why: `profile "${ok[0].attributes.name}" is active (expires ${ok[0].attributes.expirationDate?.slice(0, 10)})` };
|
||||
const stale = existing.filter(p => p.attributes.profileType === o.type);
|
||||
const why = stale.length ? `${stale.length} ${o.type} profile(s), none active with this certificate (states: ${[...new Set(stale.map(p => p.attributes.profileState))].join(', ')})` : `no ${o.type} profile`;
|
||||
const stale = existing.filter(p => p.attributes.profileType === o.type && !p.managed);
|
||||
const managed = existing.filter(p => p.attributes.profileType === o.type && p.managed);
|
||||
const why = [
|
||||
stale.length ? `${stale.length} ${o.type} profile(s), none active with this certificate (states: ${[...new Set(stale.map(p => p.attributes.profileState))].join(', ')})` : '',
|
||||
managed.length ? `${managed.length} Xcode-managed (automatic signing; not readable through the API, not reused)` : '',
|
||||
].filter(Boolean).join('; ') || `no ${o.type} profile`;
|
||||
return { reuse: null, why, create: {
|
||||
method: 'POST', path: '/v1/profiles', note: `create ${o.type} profile for ${o.bundleId}`,
|
||||
body: { data: { type: 'profiles', attributes: { name: profileName(o.bundleId, o.type, new Date(now)), profileType: o.type },
|
||||
|
|
|
|||
|
|
@ -169,7 +169,9 @@ function storeSteps(store: 'ios' | 'android', v: string, r: StoreRelease | null,
|
|||
: { kind: 'owner', text: `send the production draft of ${v} for review (owner)`, fix: 'Play Console > Publishing overview > Send for review' });
|
||||
break;
|
||||
case 'testing':
|
||||
steps.push({ kind: 'owner', text: `promote ${v} from ${r!.track ?? 'testing'} to production (owner)`, fix: 'Play Console > Test and release > Production, or `storebound play release <aab> --production draft` in a terminal' });
|
||||
steps.push(store === 'ios'
|
||||
? { kind: 'store', text: `${v} is in TestFlight (build ${r!.build ?? '?'}) but has no App Store version yet: create it with that build and its texts`, fix: `storebound apple listing --version ${v} --build ${r!.build ?? '<N>'} --dry` }
|
||||
: { kind: 'owner', text: `promote ${v} from ${r!.track ?? 'testing'} to production (owner)`, fix: 'Play Console > Test and release > Production, or `storebound play release <aab> --production draft` in a terminal' });
|
||||
break;
|
||||
case 'rejected':
|
||||
steps.push({ kind: 'owner', text: `resubmit ${v} after the fix (owner)`, fix: store === 'ios' ? 'App Store Connect > App Review > reply / resubmit' : 'Play Console > Publishing overview' });
|
||||
|
|
|
|||
|
|
@ -47,6 +47,14 @@ function save(dir: string, name: string, raw: string | Uint8Array, rows: Summary
|
|||
return { raw: rawFile, summary };
|
||||
}
|
||||
|
||||
/** What a failed Sales and Trends / finance download usually means. Seen live: a wrong vendor number gets a 500
|
||||
* (after the retries) from salesReports and a 400 PARAMETER_ERROR.INVALID from financeReports. Pure. */
|
||||
export function appleReportHint(msg: string): string | null {
|
||||
if (/salesReports -> 500|financeReports -> 400 .*vendor number/i.test(msg)) return 'check the vendor number (App Store Connect > Payments and Financial Reports, the number next to the legal entity name); reports also need a team key with Sales or Finance access';
|
||||
if (/-> 403/.test(msg)) return 'the API key may not read reports: it needs the Admin, Finance or Sales role (Users and Access > Integrations)';
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root, resolve } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
|
|
@ -58,7 +66,7 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
|
||||
if (sub === 'apple-sales' || sub === 'apple-finance') {
|
||||
const vendor = a.get('vendor') ?? ascVendorNumber(root);
|
||||
if (!vendor || !/^\d{5,12}$/.test(vendor)) throw new Error('vendor number missing: ASC_VENDOR_NUMBER in env or .storebound/credentials.json, or --vendor (App Store Connect > Payments and Financial Reports)');
|
||||
if (!vendor || !/^\d{5,12}$/.test(vendor)) throw new Error('vendor number missing: ASC_VENDOR_NUMBER in env, .storebound/credentials.json or the credential profile (--account), or --vendor (App Store Connect > Payments and Financial Reports)');
|
||||
let path: string, name: string;
|
||||
if (sub === 'apple-sales') {
|
||||
const type = a.str('type', 'SALES').toUpperCase();
|
||||
|
|
@ -76,7 +84,8 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (dry) { if (a.has('json')) printJson({ dryRun: true, request: `GET ${shown}`, file: join(out, name) }); else log(TAG, `would GET ${shown} -> ${join(out, name)}`); return; }
|
||||
const c = await ascClient(root, need(config.apple?.bundleId, 'apple.bundleId'), config.apple?.appId);
|
||||
log(TAG, `GET ${shown}`);
|
||||
const gz = await c.bytes(path);
|
||||
let gz: Uint8Array | null;
|
||||
try { gz = await c.bytes(path); } catch (e) { const hint = appleReportHint((e as Error).message); throw new Error(hint ? `${(e as Error).message}\n${hint}` : (e as Error).message); }
|
||||
if (!gz) { done(TAG, 'no report for that date (no sales then, or not published yet: daily reports come out the next day, monthly ones about a week later)'); if (a.has('json')) printJson({ report: name, empty: true }); return; }
|
||||
const text = new TextDecoder().decode(gz[0] === 0x1f && gz[1] === 0x8b ? Bun.gunzipSync(gz as Uint8Array<ArrayBuffer>) : gz);
|
||||
const rows = parseTsv(text);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue