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
|
|
@ -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' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue