serve: every CLI area for the desktop app (prices.current, project.declarations / listing_text / renders / render, import.fastlane for a new folder; owner.prices_import, owner.ppo_start / stop)
prices export --json reads the current prices without writing; inspect --declarations gives Data safety, the App Privacy answers it suggests, app info, export compliance and App Review details with every question only the owner can answer; play data-safety keeps the uploaded CSV in .storebound/ so changes since the upload show (Play cannot read the form back); shots gallery --json carries the renders folder; inspect --render returns one render as a data: URL from inside the renders folder only.
This commit is contained in:
parent
67e490520b
commit
c3b2dc288f
10 changed files with 432 additions and 25 deletions
|
|
@ -1,12 +1,20 @@
|
|||
// Offline summary of the project config: app name, store ids, languages, products, shots. No network, no credentials.
|
||||
// storebound inspect [--json]
|
||||
// storebound inspect --icon --json the app icon as a data: URL (for the desktop app)
|
||||
// storebound inspect --listings [--json] listing completeness per language on both stores (+ rendered screenshots)
|
||||
// storebound inspect --icon --json the app icon as a data: URL (for the desktop app)
|
||||
// storebound inspect --listings [--json] listing completeness per language on both stores (+ rendered screenshots)
|
||||
// storebound inspect --listing-text --json the listing files as they are (desktop export)
|
||||
// storebound inspect --declarations [--json] Data safety, App Privacy, app info, export compliance and App Review
|
||||
// details from the config, with what only the owner can answer
|
||||
// storebound inspect --render <file> --json one render (relative to the renders folder) as a data: URL
|
||||
import { existsSync, readFileSync, statSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { platformsOf, profileOf, sellsOn } from './lib/config';
|
||||
import type { Ctx } from './lib/ctx';
|
||||
import { maskUser, reviewContact, reviewDemoAccount } from './lib/credentials';
|
||||
import { DATA_SAFETY_UPLOADED, declarations } from './lib/declarations';
|
||||
import type { ProjectSummary } from './lib/desktop-protocol';
|
||||
import { log, printJson } from './lib/log';
|
||||
import { findIcon, iconDataUrl, listingCompleteness } from './lib/project-files';
|
||||
import { findIcon, iconDataUrl, listingCompleteness, listingText, renderImage } from './lib/project-files';
|
||||
|
||||
export function summarize(ctx: Ctx): ProjectSummary {
|
||||
const { config, root, path } = ctx.loaded;
|
||||
|
|
@ -32,21 +40,40 @@ export function summarize(ctx: Ctx): ProjectSummary {
|
|||
testflightGroups: config.apple?.testflight?.groups?.length ?? 0,
|
||||
profile: profileOf(config),
|
||||
icon: findIcon(config, root),
|
||||
variants: Object.keys(config.shots?.variants ?? {}),
|
||||
playReports: !!config.play?.reportsBucket,
|
||||
};
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
if (ctx.args.has('icon')) { printJson(iconDataUrl(findIcon(config, root))); return; }
|
||||
if (ctx.args.has('listings')) {
|
||||
const { config, root, resolve } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
if (a.has('icon')) { printJson(iconDataUrl(findIcon(config, root))); return; }
|
||||
if (a.has('listing-text')) { printJson(listingText(config, root)); return; }
|
||||
if (a.get('render') !== undefined) {
|
||||
printJson(renderImage(resolve(config.renders ?? config.shots?.out ?? 'store/renders'), a.get('render') ?? ''));
|
||||
return;
|
||||
}
|
||||
if (a.has('declarations')) {
|
||||
const up = join(root, DATA_SAFETY_UPLOADED);
|
||||
let uploaded: { csv: string; at: string } | null = null;
|
||||
try { if (existsSync(up)) uploaded = { csv: readFileSync(up, 'utf8'), at: statSync(up).mtime.toISOString() }; } catch { /* unreadable: never uploaded */ }
|
||||
const demo = reviewDemoAccount(root), contact = reviewContact(root);
|
||||
const d = declarations(config, { demoUser: demo ? maskUser(demo.username) : null, contactEmail: contact ? maskUser(contact.email) : null, uploaded });
|
||||
if (a.has('json')) { printJson(d); return; }
|
||||
for (const x of d.ask) log('inspect', `ask the owner (${x.area}): ${x.text} -> ${x.fix}`);
|
||||
if (!d.ask.length) log('inspect', 'declarations: every answer comes from the config');
|
||||
return;
|
||||
}
|
||||
if (a.has('listings')) {
|
||||
const l = listingCompleteness(config, root);
|
||||
if (ctx.args.has('json')) { printJson(l); return; }
|
||||
if (a.has('json')) { printJson(l); return; }
|
||||
for (const p of l.problems) log('inspect', p);
|
||||
for (const x of l.locales) log('inspect', `${x.lang.padEnd(6)} ${Math.round(x.complete * 100)} % complete${x.screenshots === null ? '' : ` · ${x.screenshots} screenshots`}`);
|
||||
return;
|
||||
}
|
||||
const s = summarize(ctx);
|
||||
if (ctx.args.has('json')) { printJson(s); return; }
|
||||
if (a.has('json')) { printJson(s); return; }
|
||||
log('inspect', `${s.name} · ${s.platforms.join(' + ')} · ${s.languages.length} languages · ${s.products} products · ${s.subscriptions} subscriptions`);
|
||||
log('inspect', `play ${s.play?.packageName ?? '-'} · apple ${s.apple?.bundleId ?? '-'}${s.apple?.appId ? ` (${s.apple.appId})` : ''}`);
|
||||
log('inspect', `config ${s.config}`);
|
||||
|
|
|
|||
144
cli/lib/declarations.ts
Normal file
144
cli/lib/declarations.ts
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
// The store declarations of one app as data, from the config and the local files only (the desktop "App info &
|
||||
// privacy" tab, `storebound inspect --declarations --json`): Play Data safety answers (and what changed since the
|
||||
// last upload, because Play has no API that reads the form back), the App Store App Privacy answers they suggest
|
||||
// (App Privacy has no API at all: the owner enters it in App Store Connect), app info (categories, age rating,
|
||||
// content rights), the export compliance answer and the App Review details (presence only, masked). Every answer the
|
||||
// config does not prove is an "ask the owner" item, never a guess (AGENTS.md rule 5). Pure.
|
||||
import { parseCsv } from './csv';
|
||||
import { type DataSafety, type PlayPurpose, profileOf, type ShipConfig } from './config';
|
||||
import { CATEGORIES, dataSafetyCsv } from './data-safety';
|
||||
import type { DeclarationsResult, DeclAsk } from './desktop-protocol';
|
||||
import { NOTES_MAX_BYTES, reviewNotes } from './review-details';
|
||||
|
||||
/** Where `storebound play data-safety` keeps the CSV it uploaded last (gitignored). */
|
||||
export const DATA_SAFETY_UPLOADED = '.storebound/data-safety.uploaded.csv';
|
||||
|
||||
/** Play data type -> the App Store App Privacy data type it usually is (Apple's own names). */
|
||||
export const APPLE_PRIVACY: Record<string, [string, string]> = {
|
||||
PSL_NAME: ['Contact Info', 'Name'], PSL_EMAIL: ['Contact Info', 'Email Address'], PSL_PHONE: ['Contact Info', 'Phone Number'],
|
||||
PSL_ADDRESS: ['Contact Info', 'Physical Address'], PSL_OTHER_PERSONAL: ['Contact Info', 'Other User Contact Info'], PSL_USER_ACCOUNT: ['Identifiers', 'User ID'],
|
||||
PSL_RACE_ETHNICITY: ['Sensitive Info', 'Sensitive Info'], PSL_POLITICAL_RELIGIOUS: ['Sensitive Info', 'Sensitive Info'], PSL_SEXUAL_ORIENTATION_GENDER_IDENTITY: ['Sensitive Info', 'Sensitive Info'],
|
||||
PSL_PURCHASE_HISTORY: ['Purchases', 'Purchase History'], PSL_CREDIT_SCORE: ['Financial Info', 'Credit Info'], PSL_CREDIT_DEBIT_BANK_ACCOUNT_NUMBER: ['Financial Info', 'Payment Info'],
|
||||
PSL_OTHER: ['Financial Info', 'Other Financial Info'], PSL_APPROX_LOCATION: ['Location', 'Coarse Location'], PSL_PRECISE_LOCATION: ['Location', 'Precise Location'],
|
||||
PSL_WEB_BROWSING_HISTORY: ['Browsing History', 'Browsing History'], PSL_EMAILS: ['User Content', 'Emails or Text Messages'], PSL_SMS_CALL_LOG: ['User Content', 'Emails or Text Messages'],
|
||||
PSL_OTHER_MESSAGES: ['User Content', 'Emails or Text Messages'], PSL_PHOTOS: ['User Content', 'Photos or Videos'], PSL_VIDEOS: ['User Content', 'Photos or Videos'],
|
||||
PSL_AUDIO: ['User Content', 'Audio Data'], PSL_MUSIC: ['User Content', 'Audio Data'], PSL_OTHER_AUDIO: ['User Content', 'Audio Data'], PSL_HEALTH: ['Health & Fitness', 'Health'],
|
||||
PSL_FITNESS: ['Health & Fitness', 'Fitness'], PSL_CONTACTS: ['Contacts', 'Contacts'], PSL_CALENDAR: ['Other Data', 'Other Data Types'],
|
||||
PSL_CRASH_LOGS: ['Diagnostics', 'Crash Data'], PSL_PERFORMANCE_DIAGNOSTICS: ['Diagnostics', 'Performance Data'], PSL_OTHER_PERFORMANCE: ['Diagnostics', 'Other Diagnostic Data'],
|
||||
PSL_FILES_AND_DOCS: ['User Content', 'Other User Content'], PSL_USER_INTERACTION: ['Usage Data', 'Product Interaction'], PSL_IN_APP_SEARCH_HISTORY: ['Search History', 'Search History'],
|
||||
PSL_APPS_ON_DEVICE: ['Other Data', 'Other Data Types'], PSL_USER_GENERATED_CONTENT: ['User Content', 'Other User Content'], PSL_OTHER_APP_ACTIVITY: ['Usage Data', 'Other Usage Data'],
|
||||
PSL_DEVICE_ID: ['Identifiers', 'Device ID'],
|
||||
};
|
||||
|
||||
/** Play purpose -> App Privacy purpose. Advertising depends on who shows the ads (shared = third-party advertising). */
|
||||
export function applePurpose(p: PlayPurpose, shared: boolean): string {
|
||||
switch (p) {
|
||||
case 'analytics': return 'Analytics';
|
||||
case 'advertising': return shared ? 'Third-Party Advertising' : 'Developer\'s Advertising or Marketing';
|
||||
case 'communications': return 'Developer\'s Advertising or Marketing';
|
||||
case 'personalization': return 'Product Personalization';
|
||||
default: return 'App Functionality';
|
||||
}
|
||||
}
|
||||
|
||||
const categoryOf = (type: string): string => CATEGORIES.find(([, ts]) => ts.includes(type))?.[0].replace('PSL_DATA_TYPES_', '').toLowerCase().replace(/_/g, ' ') ?? 'other';
|
||||
|
||||
/** Rows of a Data safety CSV keyed by question + response -> value (header dropped). */
|
||||
export function dataSafetyAnswers(csv: string): Map<string, string> {
|
||||
const m = new Map<string, string>();
|
||||
for (const r of parseCsv(csv).slice(1)) m.set(`${r[0] ?? ''}|${r[1] ?? ''}`, (r[2] ?? '').trim());
|
||||
return m;
|
||||
}
|
||||
|
||||
/** What differs between the CSV uploaded last and the one the config makes now (answers only, labels ignored). */
|
||||
export function dataSafetyChanges(uploaded: string, now: string): { question: string; response: string; from: string; to: string }[] {
|
||||
const a = dataSafetyAnswers(uploaded), b = dataSafetyAnswers(now);
|
||||
const out: { question: string; response: string; from: string; to: string }[] = [];
|
||||
for (const k of new Set([...a.keys(), ...b.keys()])) {
|
||||
const from = a.get(k) ?? '', to = b.get(k) ?? '';
|
||||
if (from !== to) { const [question, response] = k.split('|') as [string, string]; out.push({ question, response, from, to }); }
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export interface DeclarationInputs {
|
||||
/** The demo account and review contact, masked (credentials.json / env): presence only, never the secrets. */
|
||||
demoUser: string | null;
|
||||
contactEmail: string | null;
|
||||
/** The last uploaded Data safety CSV and its time, when there is one. */
|
||||
uploaded: { csv: string; at: string } | null;
|
||||
}
|
||||
|
||||
export function declarations(config: ShipConfig, inp: DeclarationInputs): DeclarationsResult {
|
||||
const ask: DeclAsk[] = [];
|
||||
const play = !!config.play, apple = !!config.apple;
|
||||
const profile = profileOf(config);
|
||||
const ds: DataSafety | undefined = config.dataSafety;
|
||||
let dataSafety: DeclarationsResult['dataSafety'] = null;
|
||||
if (play && !ds) ask.push({ area: 'dataSafety', id: 'ds-missing', text: 'The config has no dataSafety answers, so storebound cannot fill the Play Data safety form.', fix: 'Answer what the app and its SDKs collect (store-declarations skill), then add dataSafety to storebound.config.ts.' });
|
||||
if (ds) {
|
||||
let csv = '';
|
||||
try { csv = dataSafetyCsv(ds); } catch (e) { ask.push({ area: 'dataSafety', id: 'ds-invalid', text: (e as Error).message, fix: 'Use the Play data type ids (PSL_...) in dataSafety.data.' }); }
|
||||
const types = Object.entries(ds.data).map(([id, u]) => ({ id, category: categoryOf(id), shared: !!u.shared, ephemeral: !!u.ephemeral, optional: !!u.optional, collect: [...u.collect], share: [...(u.shared ? u.share ?? [] : [])] }));
|
||||
dataSafety = {
|
||||
collectsData: ds.collectsData, encryptedInTransit: ds.encryptedInTransit, deletionRequest: ds.deletionRequest, accountCreation: ds.accountCreation ?? ['PSL_ACM_NONE'],
|
||||
types, extra: ds.extra?.length ?? 0, csv, rows: csv ? csv.trim().split('\n').length - 1 : 0,
|
||||
uploaded: inp.uploaded && csv ? { at: inp.uploaded.at, changes: dataSafetyChanges(inp.uploaded.csv, csv) } : null,
|
||||
};
|
||||
if (ds.collectsData && !types.length) ask.push({ area: 'dataSafety', id: 'ds-no-types', text: 'collectsData is true but no data type is listed.', fix: 'List each data type the app or its SDKs collect in dataSafety.data, or set collectsData: false if nothing is.' });
|
||||
if (!ds.collectsData && types.length) ask.push({ area: 'dataSafety', id: 'ds-contradiction', text: 'collectsData is false but data types are listed.', fix: 'Decide which is true; Play rejects a form that says both.' });
|
||||
if (profile === 'game' && !ds.data.PSL_DEVICE_ID) ask.push({ area: 'dataSafety', id: 'ds-ads-id', text: 'A game profile usually ships an ads or analytics SDK that reads the advertising id, but PSL_DEVICE_ID is not declared.', fix: 'Check every SDK\'s data disclosure; declare PSL_DEVICE_ID (advertising, analytics) if any reads it.' });
|
||||
if (config.accounts?.enabled && (ds.accountCreation ?? ['PSL_ACM_NONE']).includes('PSL_ACM_NONE')) ask.push({ area: 'dataSafety', id: 'ds-accounts', text: 'The app has accounts, but the form says no account creation.', fix: 'Set dataSafety.accountCreation to the methods the app offers, and the delete-account URL in dataSafety.extra.' });
|
||||
if (!ds.deletionRequest && config.accounts?.enabled) ask.push({ area: 'dataSafety', id: 'ds-deletion', text: 'Users can create accounts but deletionRequest is false.', fix: 'Both stores want account deletion (account-deletion skill); then set deletionRequest: true.' });
|
||||
}
|
||||
|
||||
// App Privacy: suggested from the Data safety answers; linked / tracking are questions only the owner can answer
|
||||
const byType = new Map<string, { apple: string; category: string; from: string[]; purposes: Set<string>; thirdParty: boolean }>();
|
||||
for (const [id, u] of Object.entries(ds?.data ?? {})) {
|
||||
const [category, name] = APPLE_PRIVACY[id] ?? ['Other Data', 'Other Data Types'];
|
||||
const e = byType.get(name) ?? { apple: name, category, from: [], purposes: new Set<string>(), thirdParty: false };
|
||||
e.from.push(id);
|
||||
for (const p of u.collect) e.purposes.add(applePurpose(p, false));
|
||||
for (const p of u.shared ? u.share ?? [] : []) e.purposes.add(applePurpose(p, true));
|
||||
e.thirdParty ||= !!u.shared;
|
||||
byType.set(name, e);
|
||||
}
|
||||
const appPrivacy: DeclarationsResult['appPrivacy'] = apple ? {
|
||||
items: [...byType.values()].map(e => ({ apple: e.apple, category: e.category, from: e.from, purposes: [...e.purposes].sort(), thirdParty: e.thirdParty })),
|
||||
fromDataSafety: !!ds,
|
||||
} : null;
|
||||
if (apple) {
|
||||
if (!ds) ask.push({ area: 'appPrivacy', id: 'ap-unknown', text: 'App Privacy (App Store Connect > App Privacy) cannot be suggested without dataSafety answers in the config.', fix: 'Answer the data collection once in dataSafety; storebound then lists the matching App Privacy answers to enter.' });
|
||||
else ask.push({ area: 'appPrivacy', id: 'ap-linked', text: 'App Privacy asks per data type whether it is linked to the user\'s identity and whether it is used for tracking; the config cannot prove either.', fix: 'Answer both in App Store Connect > App Privacy for each type below (tracking also needs App Tracking Transparency in the app).' });
|
||||
}
|
||||
|
||||
const info = config.apple?.info;
|
||||
const appInfo: DeclarationsResult['appInfo'] = apple ? {
|
||||
categories: info?.categories ?? null,
|
||||
ageRating: Object.entries(info?.ageRating ?? {}).map(([q, v]) => ({ question: q, value: v === null ? 'none' : String(v) })),
|
||||
contentRights: info?.contentRights ?? null,
|
||||
free: info?.free !== false,
|
||||
} : null;
|
||||
if (apple) {
|
||||
if (!info?.categories) ask.push({ area: 'appInfo', id: 'ai-categories', text: 'No App Store category in the config.', fix: 'Set apple.info.categories.primary (for example GAMES with primarySubOne GAMES_PUZZLE).' });
|
||||
if (!info?.ageRating) ask.push({ area: 'appInfo', id: 'ai-age', text: 'No age rating answers: storebound would answer every content question "none".', fix: 'Confirm that is true (ads, user-generated content, chat, loot boxes, web access count), or set apple.info.ageRating overrides.' });
|
||||
if (!info?.contentRights) ask.push({ area: 'appInfo', id: 'ai-rights', text: 'Content rights are not declared.', fix: 'Set apple.info.contentRights: DOES_NOT_USE_THIRD_PARTY_CONTENT or USES_THIRD_PARTY_CONTENT (you hold the rights).' });
|
||||
}
|
||||
const encryption = apple ? config.apple?.usesNonExemptEncryption ?? null : null;
|
||||
if (apple && encryption === null) ask.push({ area: 'encryption', id: 'enc-unset', text: 'Export compliance is not answered (apple.usesNonExemptEncryption).', fix: 'Decide it with the export-compliance skill; false only when the app uses no encryption beyond the OS. storebound never guesses it.' });
|
||||
|
||||
const notes = reviewNotes(config);
|
||||
const signIn = config.reviewAccess ? config.reviewAccess.signInRequired : null;
|
||||
const review: DeclarationsResult['review'] = {
|
||||
signInRequired: signIn, accounts: !!config.accounts?.enabled,
|
||||
contact: inp.contactEmail, demoAccount: inp.demoUser,
|
||||
notes, notesBytes: new TextEncoder().encode(notes).length, notesMax: NOTES_MAX_BYTES,
|
||||
};
|
||||
if (apple) {
|
||||
if (signIn === null) ask.push({ area: 'review', id: 'rv-signin', text: 'The config does not say whether reviewers need to sign in.', fix: 'Set reviewAccess.signInRequired (true needs a demo account; review-access skill).' });
|
||||
if (signIn && !inp.demoUser) ask.push({ area: 'review', id: 'rv-demo', text: 'Sign-in is required but there is no demo account.', fix: 'Add "reviewDemoAccount": { "username", "password" } to .storebound/credentials.json (it stays on this machine).' });
|
||||
if (!inp.contactEmail) ask.push({ area: 'review', id: 'rv-contact', text: 'No App Review contact.', fix: 'Add "reviewContact": { firstName, lastName, phone, email } to .storebound/credentials.json (personal data stays there).' });
|
||||
if (review.notesBytes > NOTES_MAX_BYTES) ask.push({ area: 'review', id: 'rv-notes', text: `Review notes are ${review.notesBytes} bytes; App Store Connect takes ${NOTES_MAX_BYTES}.`, fix: 'Shorten apple.info.reviewNotes or reviewAccess.instructions.' });
|
||||
}
|
||||
return { profile, stores: { apple, play }, dataSafety, appPrivacy, appInfo, encryption, review, ask };
|
||||
}
|
||||
|
|
@ -96,6 +96,10 @@ export interface ProjectSummary {
|
|||
profile?: string;
|
||||
/** Absolute path of the app icon the config or the usual places point at (project.icon reads it), or null. */
|
||||
icon?: string | null;
|
||||
/** A/B screenshot variant ids (shots.variants: store listing experiments, Product Page Optimization treatments). */
|
||||
variants?: string[];
|
||||
/** play.reportsBucket is set (Play statistics for analytics snapshots). */
|
||||
playReports?: boolean;
|
||||
}
|
||||
|
||||
// ---- App-centric model (one app = one product on up to two platforms; a workspace holds many apps) ----
|
||||
|
|
@ -249,3 +253,70 @@ export interface AccountCheck {
|
|||
* its temp folder. Read methods only.
|
||||
*/
|
||||
export interface VirtualProject { name: string; apple?: { bundleId: string; appId?: string | null } | null; play?: { packageName: string } | null }
|
||||
|
||||
// ---- Desktop: every CLI area in the window (prices, declarations, renders, experiments, analytics) ----
|
||||
/** prices.current (`prices export --json`): the current prices on both stores, one row per product x store x region. */
|
||||
export interface PriceRowData { product: string; store: 'apple' | 'play'; region: string; territory?: string; currency: string; price: number; startDate?: string; kind?: 'manual' | 'auto' }
|
||||
export interface PricesCurrent { csv: string; products: string[]; stores: ('apple' | 'play')[]; missing: { product: string; store: 'apple' | 'play' }[]; rows: PriceRowData[] }
|
||||
/** prices.diff (`prices import --dry --json`): the sheet against the stores. */
|
||||
export interface PriceDiffRow { product: string; store: 'apple' | 'play'; region: string; startDate?: string; currency: string; from: number | null; to: number; change: 'new' | 'change' | 'same' }
|
||||
export interface PricesDiff { csv: string; diff: PriceDiffRow[]; changed: string[] }
|
||||
/** One "ask the owner" item: the config does not prove the answer (AGENTS.md rule 5). */
|
||||
export interface DeclAsk { area: 'dataSafety' | 'appPrivacy' | 'appInfo' | 'encryption' | 'review'; id: string; text: string; fix: string }
|
||||
/** project.declarations (`inspect --declarations --json`): store declarations from the config and local files. */
|
||||
export interface DeclarationsResult {
|
||||
profile: string;
|
||||
stores: { apple: boolean; play: boolean };
|
||||
dataSafety: null | {
|
||||
collectsData: boolean; encryptedInTransit: boolean; deletionRequest: boolean; accountCreation: string[];
|
||||
types: { id: string; category: string; shared: boolean; ephemeral: boolean; optional: boolean; collect: string[]; share: string[] }[];
|
||||
/** Extra CSV rows of questions storebound does not model. */
|
||||
extra: number;
|
||||
/** The Play CSV the upload sends (it replaces the whole form). */
|
||||
csv: string;
|
||||
rows: number;
|
||||
/** Play cannot read the form back: changes since the CSV storebound uploaded last (null: never uploaded from here). */
|
||||
uploaded: { at: string; changes: { question: string; response: string; from: string; to: string }[] } | null;
|
||||
};
|
||||
/** App Store App Privacy (no API): the answers the Data safety answers suggest; the owner enters them in App Store Connect. */
|
||||
appPrivacy: null | { items: { apple: string; category: string; from: string[]; purposes: string[]; thirdParty: boolean }[]; fromDataSafety: boolean };
|
||||
appInfo: null | {
|
||||
categories: { primary: string; primarySubOne?: string; primarySubTwo?: string; secondary?: string } | null;
|
||||
/** Overrides of the age rating declaration (every other question: none / false). */
|
||||
ageRating: { question: string; value: string }[];
|
||||
contentRights: string | null;
|
||||
free: boolean;
|
||||
};
|
||||
/** apple.usesNonExemptEncryption (null: not answered; storebound never guesses). */
|
||||
encryption: boolean | null;
|
||||
/** contact / demoAccount: masked ("d***@example.com"), null when missing; never the password. */
|
||||
review: { signInRequired: boolean | null; accounts: boolean; contact: string | null; demoAccount: string | null; notes: string; notesBytes: number; notesMax: number };
|
||||
ask: DeclAsk[];
|
||||
}
|
||||
/** project.listing_text: the listing files as they are (for export). */
|
||||
export interface ListingText { play: { path: string; text: string } | null; apple: { path: string; text: string } | null }
|
||||
/** project.render: one rendered image as a data: URL (null when missing or too big). */
|
||||
export interface RenderImage { file: string; dataUrl: string | null; bytes: number }
|
||||
/** project.renders (`shots gallery --json`): every render per variant, language and size, with the store check issues. */
|
||||
export interface RenderIssue { level: 'error' | 'warn'; code: string; msg: string }
|
||||
export interface RenderTile { src: string; kind: 'image' | 'video'; poster?: string; name: string; w: number; h: number; bytes: number; issues: RenderIssue[] }
|
||||
export interface RendersResult {
|
||||
title: string; generated: string;
|
||||
/** The renders folder relative to the app folder. */
|
||||
dir?: string;
|
||||
variants: { id: string; label: string; langs: { lang: string; rows: { size: string; label: string; store: 'apple' | 'play'; tiles: RenderTile[]; issues: RenderIssue[] }[] }[] }[];
|
||||
totals: { images: number; videos: number; errors: number; warnings: number };
|
||||
}
|
||||
/** apple.ppo_status (`apple ppo status --json`). */
|
||||
export interface PpoTest { id: string; name: string; state: string; trafficProportion?: number; startDate?: string | null; endDate?: string | null; treatments: { id: string; name: string; locales: number }[] }
|
||||
export interface PpoStatus { tests: PpoTest[] }
|
||||
/** analytics.compare (`analytics compare --json`): daily series from the snapshots and the store changes from git. */
|
||||
export interface AnalyticsTotals { impressions?: number; pageViews?: number; downloads?: number; conversion?: number | null; visitors?: number; acquisitions?: number; installs?: number }
|
||||
export interface AnalyticsCompare {
|
||||
snapshots: number; since: string;
|
||||
series: {
|
||||
apple: { date: string; impressions: number; uniqueImpressions: number; pageViews: number; uniquePageViews: number; downloads: number; firstTimeDownloads: number }[];
|
||||
play: { date: string; visitors: number; acquisitions: number; installs: number }[];
|
||||
};
|
||||
effects: { event: { date: string; commit: string; subject: string; files: string[] }; store: 'apple' | 'play'; before: AnalyticsTotals; after: AnalyticsTotals; daysBefore: number; daysAfter: number }[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|||
import { extname, isAbsolute, join, resolve } from 'node:path';
|
||||
import { type ShipConfig, playCodes } from './config';
|
||||
import { APPLE_LIMITS, len, PLAY_LIMITS } from './copy';
|
||||
import type { DraftsResult, IconResult, ListingField, ListingLocale, ListingsResult, ReplyDraft } from './desktop-protocol';
|
||||
import type { DraftsResult, IconResult, ListingField, ListingLocale, ListingsResult, ListingText, RenderImage, ReplyDraft } from './desktop-protocol';
|
||||
import { parseFrontMatter, stringifyFrontMatter } from './frontmatter';
|
||||
import { checkReply, parseDraft } from './reviews';
|
||||
|
||||
|
|
@ -148,6 +148,33 @@ export function listingCompleteness(config: ShipConfig, root: string): ListingsR
|
|||
return { files: { play: playFile.path, apple: appleFile.path }, problems, locales };
|
||||
}
|
||||
|
||||
/** The listing files as they are (the desktop export), or null where the config has no store / the file is missing. */
|
||||
export function listingText(config: ShipConfig, root: string): ListingText {
|
||||
const one = (rel: string): { path: string; text: string } | null => {
|
||||
const p = resolve(root, rel);
|
||||
try { return { path: p, text: readFileSync(p, 'utf8') }; } catch { return null; }
|
||||
};
|
||||
return { play: config.play ? one(config.play.listing ?? 'store/listing.md') : null, apple: config.apple ? one(config.apple.listing ?? 'store/appstore.md') : null };
|
||||
}
|
||||
|
||||
export const RENDER_MAX_BYTES = 12_000_000;
|
||||
/** A render path as the gallery data names it: relative, no "..", an image. */
|
||||
export const RENDER_FILE_RE = /^(?!.*(^|\/)\.\.?(\/|$))(?!\/)[A-Za-z0-9._ @+()/-]{1,300}\.(png|jpe?g|webp)$/i;
|
||||
|
||||
/** One render (a path relative to the renders folder) as a data: URL for the desktop gallery; null when it is not
|
||||
* an image inside the folder or is bigger than RENDER_MAX_BYTES. */
|
||||
export function renderImage(rendersDir: string, file: string): RenderImage {
|
||||
if (!RENDER_FILE_RE.test(file)) return { file, dataUrl: null, bytes: 0 };
|
||||
const base = resolve(rendersDir), p = resolve(base, file);
|
||||
if (!p.startsWith(base + '/') && !p.startsWith(base + '\\')) return { file, dataUrl: null, bytes: 0 };
|
||||
try {
|
||||
const st = statSync(p);
|
||||
const mime = MIME[extname(p).toLowerCase()];
|
||||
if (!st.isFile() || !mime || st.size > RENDER_MAX_BYTES) return { file, dataUrl: null, bytes: st.size };
|
||||
return { file, dataUrl: `data:${mime};base64,${readFileSync(p).toString('base64')}`, bytes: st.size };
|
||||
} catch { return { file, dataUrl: null, bytes: 0 }; }
|
||||
}
|
||||
|
||||
/** Local reply drafts with their send checks. Unparsable files become problems. */
|
||||
export function readReplyDrafts(dir: string): DraftsResult {
|
||||
const out: DraftsResult = { dir, drafts: [], problems: [] };
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
// Play Data safety form through applications.dataSafety (CSV import; replaces every earlier answer).
|
||||
// storebound play data-safety [--csv out.csv] [--dry]
|
||||
// Answers come from `dataSafety` in storebound.config.ts. --dry only writes / prints the CSV.
|
||||
import { writeFileSync } from 'node:fs';
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import type { Ctx } from '../lib/ctx';
|
||||
import { need } from '../lib/ctx';
|
||||
import { dataSafetyCsv } from '../lib/data-safety';
|
||||
import { DATA_SAFETY_UPLOADED } from '../lib/declarations';
|
||||
import { done, log } from '../lib/log';
|
||||
import { playClient } from './client';
|
||||
|
||||
|
|
@ -18,5 +20,7 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (ctx.args.has('dry')) { if (!out) process.stdout.write(csv); return; }
|
||||
const play = await playClient(root, need(config.play?.packageName, 'play.packageName'));
|
||||
await play.call('POST', `${play.API}/dataSafety`, { safetyLabels: csv });
|
||||
// Play cannot read the form back: keep what went up, so the desktop app can show what changed since (gitignored).
|
||||
try { mkdirSync(join(root, '.storebound'), { recursive: true }); writeFileSync(join(root, DATA_SAFETY_UPLOADED), csv); } catch { /* the upload itself worked */ }
|
||||
done('play', `data safety updated (${csv.split('\n').length - 2} rows)`);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// In-app product prices for many products and regions from one CSV (both stores).
|
||||
// storebound prices export [--out store/prices.csv] [--store apple|play] [--only ids] [--with-automatic] [--dry]
|
||||
// storebound prices export [--out store/prices.csv] [--store apple|play] [--only ids] [--with-automatic] [--dry] [--json]
|
||||
// storebound prices import [--csv store/prices.csv] [--store apple|play] [--only ids] [--reconvert] [--all] [--dry] [--yes]
|
||||
// CSV columns: product, store (apple | play | both), region (ISO alpha-2), currency, price, start_date (App Store
|
||||
// only, a future YYYY-MM-DD = scheduled change), kind (manual | auto; auto rows are Apple's equalized prices, exported
|
||||
|
|
@ -68,23 +68,30 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
|
||||
// current state of every product on the chosen stores
|
||||
const current: PriceRow[] = [];
|
||||
const missing: { product: string; store: 'apple' | 'play' }[] = [];
|
||||
const iaps = new Map<string, { id: string; base: string | null }>();
|
||||
const playProducts = new Map<string, PlayProduct>();
|
||||
for (const [i, p] of products.entries()) {
|
||||
log(TAG, `${step(i + 1, products.length, p.id)}: reading current prices`);
|
||||
if (c) {
|
||||
const id = await iapId(c, appId, p.id);
|
||||
if (!id) warn(TAG, `${p.id}: not on App Store Connect (storebound apple iap creates it)`);
|
||||
if (!id) { warn(TAG, `${p.id}: not on App Store Connect (storebound apple iap creates it)`); missing.push({ product: p.id, store: 'apple' }); }
|
||||
else { const cur = await appleCurrent(c, id, p.id, sub === 'export' && a.has('with-automatic')); current.push(...cur.rows); iaps.set(p.id, { id, base: cur.base }); }
|
||||
}
|
||||
if (play) {
|
||||
const pp = await playProduct(play, p.id);
|
||||
if (!pp) warn(TAG, `${p.id}: not on Google Play (storebound play products creates it)`);
|
||||
if (!pp) { warn(TAG, `${p.id}: not on Google Play (storebound play products creates it)`); missing.push({ product: p.id, store: 'play' }); }
|
||||
else { current.push(...playPriceRows(pp)); playProducts.set(p.id, pp); }
|
||||
}
|
||||
}
|
||||
|
||||
if (sub === 'export') {
|
||||
// --json: the current prices as data (the desktop price view); read-only, never writes the CSV
|
||||
if (a.has('json')) {
|
||||
printJson({ csv: csvPath, products: products.map(p => p.id), stores: [...(useApple ? ['apple'] : []), ...(usePlay ? ['play'] : [])], missing,
|
||||
rows: current.map(({ pointId: _p, ...r }) => r) });
|
||||
return;
|
||||
}
|
||||
const csv = pricesCsv(current);
|
||||
if (dry) { console.log(csv); done(TAG, `dry run: would write ${current.length} rows to ${csvPath}`); return; }
|
||||
writeFileSync(csvPath, csv);
|
||||
|
|
|
|||
50
cli/serve.ts
50
cli/serve.ts
|
|
@ -20,6 +20,7 @@ import {
|
|||
DESKTOP_PROTOCOL, ERR, type AppStatus, type MethodDescriptor, type PortfolioResult, type ProjectSummary, type ToolResult, type VirtualProject,
|
||||
} from './lib/desktop-protocol';
|
||||
import { appIdentity, appleProductIds, appleReleases, catalogParity, playProductIds, playReleases, releaseTrains } from './lib/portfolio';
|
||||
import { RENDER_FILE_RE } from './lib/project-files';
|
||||
import { detectTools } from './lib/tools';
|
||||
import { compiled, pickCallEnv, runCommand, type RunOptions, type Running } from './lib/runner';
|
||||
import { inputSchema, type ToolDef, TOOLS, toArgv, validateInput } from './mcp-tools';
|
||||
|
|
@ -32,16 +33,21 @@ export type Runner = (argv: string[], o: RunOptions) => Running;
|
|||
|
||||
const MAX_OUTPUT = 60_000;
|
||||
|
||||
/** MCP tools the desktop profile leaves out (sending builds to testers on Play, release state changes; the fastlane import
|
||||
* needs a folder without a config, which the desktop first-run guide does not offer yet). */
|
||||
export const DESKTOP_EXCLUDED = new Set(['play_release_testing', 'apple_phased_release', 'import_fastlane']);
|
||||
const opt = (flag: string, v: unknown): string[] => (v === undefined || v === null || v === '' ? [] : [`--${flag}`, String(v)]);
|
||||
const lang = { type: 'string', pattern: '^[A-Za-z0-9_-]{1,20}(,[A-Za-z0-9_-]{1,20}){0,99}$', description: 'Comma-separated language ids from the config (default: all)' };
|
||||
/** A price sheet: any .csv file path the owner picked (read only), never an option. */
|
||||
export const PRICE_SHEET_RE = /^(?!-)[^\x00-\x1f]{1,1000}\.[cC][sS][vV]$/;
|
||||
|
||||
/** MCP tools the desktop profile leaves out (sending builds to testers on Play, release state changes: the window has
|
||||
* the owner actions for those). */
|
||||
export const DESKTOP_EXCLUDED = new Set(['play_release_testing', 'apple_phased_release']);
|
||||
/** Words no desktop method name may contain. */
|
||||
export const FORBIDDEN_METHOD_WORDS = /submit|release|publish|rollout|resume|complete|send|start|stop|cancel|delete|remove|invite/i;
|
||||
|
||||
/** Read tools whose command prints a structured result with --json. */
|
||||
export const JSON_TOOLS = new Set(['check', 'check_aso', 'validate', 'health', 'reviews_list', 'prices_diff', 'analytics_compare', 'apple_status',
|
||||
'apple_next_build', 'play_status', 'play_next_version_code', 'shots_check', 'apple_testflight_status', 'apple_ppo_status', 'catalog_diff',
|
||||
'project_icon', 'project_listings', 'reviews_drafts']);
|
||||
'project_icon', 'project_listings', 'reviews_drafts', 'project_declarations', 'project_listing_text', 'project_renders', 'project_render', 'prices_current']);
|
||||
|
||||
/**
|
||||
* Methods only the desktop profile has (not MCP tools): offline reads of the project's own files, and two local
|
||||
|
|
@ -67,6 +73,21 @@ export const DESKTOP_ONLY: ToolDef[] = [
|
|||
{ name: 'project_init', title: 'Start an app folder', command: ['init'], write: true, network: false, idempotent: true,
|
||||
description: 'Copies the storebound templates (config, listing, screenshot copy, declarations, privacy policy) for a profile into an empty app folder; existing files are kept.',
|
||||
props: { profile: { type: 'string', enum: ['app', 'game', 'subscription-app'], default: 'app' } }, args: i => ['--profile', String(i.profile ?? 'app')] },
|
||||
{ name: 'project_declarations', title: 'Store declarations', command: ['inspect', '--declarations'], write: false, network: false,
|
||||
description: 'Play Data safety answers (and the changes since the last upload: Play cannot read the form back), the App Privacy answers they suggest (App Privacy has no API), App Store categories, age rating, content rights, export compliance and App Review details (contact and demo account masked) from the config, with every question only the owner can answer.' },
|
||||
{ name: 'project_listing_text', title: 'Listing files', command: ['inspect', '--listing-text'], write: false, network: false,
|
||||
description: 'The Play and App Store listing files (store/listing.md, store/appstore.md) as they are, for an export.' },
|
||||
{ name: 'project_renders', title: 'Store art', command: ['shots', 'gallery'], write: false, network: false,
|
||||
description: 'Every rendered screenshot and app preview per variant, language and size with the store check issues (the data of the review gallery; nothing is written).',
|
||||
props: { lang }, args: i => opt('lang', i.lang) },
|
||||
{ name: 'project_render', title: 'One render', command: ['inspect'], write: false, network: false,
|
||||
description: 'One rendered image of the renders folder as a data: URL (at most 12 MB), for the desktop gallery.',
|
||||
props: { file: { type: 'string', pattern: RENDER_FILE_RE.source, description: 'Path relative to the renders folder, as project.renders names it' } },
|
||||
required: ['file'], args: i => ['--render', String(i.file)] },
|
||||
{ name: 'prices_current', title: 'Current prices', command: ['prices', 'export'], write: false, network: true,
|
||||
description: 'Read-only: the current price of every product on both stores per region (Apple manual prices, with with_automatic also the equalized ones). Writes nothing.',
|
||||
props: { store: { type: 'string', enum: ['apple', 'play'] }, with_automatic: { type: 'boolean', default: false } },
|
||||
args: i => [...opt('store', i.store), ...(i.with_automatic === true ? ['--with-automatic'] : [])] },
|
||||
];
|
||||
/**
|
||||
* Owner actions (desktop only, kind "owner"): changes the owner decides because users see them at once. Each is a dry
|
||||
|
|
@ -95,12 +116,24 @@ export const OWNER_TOOLS: ToolDef[] = [
|
|||
description: 'Adds the testers of the project\'s testers CSV (.storebound/testers.csv, gitignored) to their TestFlight groups; Apple emails them an invitation once the group has a build. Emails stay masked in every line. Removing testers stays a terminal command.',
|
||||
props: { groups: { type: 'string', pattern: '^[^,;]{1,60}(,[^,;]{1,60}){0,19}$', description: 'Comma-separated group names (default: every group in the CSV)' } },
|
||||
args: i => (i.groups ? ['--group', String(i.groups)] : []) },
|
||||
{ name: 'owner_prices_import', title: 'Apply the price sheet', command: ['prices', 'import'], write: true, network: true,
|
||||
description: 'Writes the prices of the price sheet (CSV) that differ from the stores: App Store price schedules and Google Play regional prices. Users see them as soon as the stores apply them; an App Store price increase cannot be undone once it starts.',
|
||||
props: { csv: { type: 'string', pattern: PRICE_SHEET_RE.source, description: 'The price sheet: a .csv path (default: prices.csv of the config, else store/prices.csv)' }, store: { type: 'string', enum: ['apple', 'play'] },
|
||||
only: { type: 'string', pattern: '^[A-Za-z0-9._]{1,100}(,[A-Za-z0-9._]{1,100}){0,49}$', description: 'Comma-separated product ids' } },
|
||||
args: i => [...opt('csv', i.csv), ...opt('store', i.store), ...opt('only', i.only)] },
|
||||
{ name: 'owner_ppo_start', title: 'Start the Product Page Optimization test', command: ['apple', 'ppo', 'start'], write: true, network: true,
|
||||
description: 'Starts an App Store Product Page Optimization test: the share of App Store visitors it names sees a treatment (treatments not yet approved go to App Review with the next version first).',
|
||||
props: { experiment: { type: 'string', pattern: '^[^\\x00-\\x1f]{1,64}$', description: 'Test name (default: the one editable test)' } }, args: i => opt('experiment', i.experiment) },
|
||||
{ name: 'owner_ppo_stop', title: 'Stop the Product Page Optimization test', command: ['apple', 'ppo', 'stop'], write: true, network: true,
|
||||
description: 'Stops a running App Store Product Page Optimization test. A stopped test cannot be restarted; the results stay in App Store Connect.',
|
||||
props: { experiment: { type: 'string', pattern: '^[^\\x00-\\x1f]{1,64}$', description: 'Test name (default: the running test)' } }, args: i => opt('experiment', i.experiment) },
|
||||
];
|
||||
/** Flags no owner action may ever produce. */
|
||||
/** Flags no owner action may ever produce (`--csv` only for the price sheet of owner.prices_import). */
|
||||
export const OWNER_FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--submit-review', '--remove', '--invite', '--production', '--csv', 'submit', 'publish', 'distribute'];
|
||||
const OWNER_ALLOWED_ARGS: Record<string, string[]> = { owner_prices_import: ['--csv'] };
|
||||
|
||||
/** Desktop-only methods whose `project` is a folder without a config yet. */
|
||||
const NEW_PROJECT = new Set(['project_init']);
|
||||
/** Desktop-only methods whose `project` is a folder without a config yet (the host picks it in a native dialog). */
|
||||
export const NEW_PROJECT = new Set(['project_init', 'import_fastlane']);
|
||||
|
||||
/** `apple_testflight_status` -> `apple.testflight_status`: first underscore becomes the namespace dot. */
|
||||
export const methodName = (tool: string): string => tool.replace('_', '.');
|
||||
|
|
@ -334,7 +367,8 @@ export class Session {
|
|||
const json = !t.write && JSON_TOOLS.has(t.name);
|
||||
const argv = json ? [...built.argv, '--json'] : built.argv;
|
||||
if (OWNER.has(t.name)) {
|
||||
if (argv.some(a => OWNER_FORBIDDEN_ARGS.includes(a))) throw new RpcError(ERR.invalidParams, `${method}: not an owner action from here`);
|
||||
const allowed = OWNER_ALLOWED_ARGS[t.name] ?? [];
|
||||
if (argv.some(a => OWNER_FORBIDDEN_ARGS.includes(a) && !allowed.includes(a))) throw new RpcError(ERR.invalidParams, `${method}: not an owner action from here`);
|
||||
// the verified token is the owner's answer to the command's own question; nothing else can set it
|
||||
if (!dryRun) env.STOREBOUND_OWNER_CONFIRMED = '1';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
import { existsSync, writeFileSync } from 'node:fs';
|
||||
import { join, relative } from 'node:path';
|
||||
import type { Ctx } from '../lib/ctx';
|
||||
import { done, log, warn } from '../lib/log';
|
||||
import { done, log, printJson, warn } from '../lib/log';
|
||||
import { SIZES } from './lib';
|
||||
import { allIssues, requiredSets, type RendersScan, scanRenders } from './report';
|
||||
import { type Issue, IMAGE_SPECS, VIDEO_TARGETS } from './spec';
|
||||
|
|
@ -244,7 +244,8 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const scan = scanRenders(dir, { langs, variants, required: lang => requiredSets(config, lang) });
|
||||
if (!scan.images.length && !scan.videos.length) warn('shots', `no renders in ${dir} (storebound shots render)`);
|
||||
const data = galleryData(scan, { at: join(out, '..'), title: `${config.app.name} · store renders`, exists: existsSync });
|
||||
if (a.has('json')) { console.log(JSON.stringify(data, null, 2)); return; }
|
||||
// --json: the data only (the desktop gallery), with the renders folder relative to the app folder; writes nothing
|
||||
if (a.has('json')) { printJson({ ...data, dir: relative(ctx.loaded.root, dir).split('\\').join('/') || '.' }); return; }
|
||||
if (a.has('dry')) { log('shots', `would write ${out}: ${data.totals.images} images, ${data.totals.videos} videos, ${data.totals.errors} errors`); return; }
|
||||
writeFileSync(out, galleryHtml(data));
|
||||
log('shots', `${data.totals.images} images, ${data.totals.videos} videos, ${data.variants.length} variant tab(s): ${data.totals.errors} errors, ${data.totals.warnings} warnings`);
|
||||
|
|
|
|||
62
tests/desktop-complete.test.ts
Normal file
62
tests/desktop-complete.test.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Desktop full CLI coverage, CLI side: store declarations as data (ask the owner, never guess), Data safety changes
|
||||
// since the last upload, renders as data: URLs only from inside the renders folder.
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import type { ShipConfig } from '../cli/lib/config';
|
||||
import { dataSafetyCsv } from '../cli/lib/data-safety';
|
||||
import { applePurpose, dataSafetyChanges, declarations } from '../cli/lib/declarations';
|
||||
import { RENDER_FILE_RE, renderImage } from '../cli/lib/project-files';
|
||||
|
||||
const base = (o: Partial<ShipConfig> = {}): ShipConfig => ({
|
||||
app: { name: 'Demo', privacyPolicyUrl: 'https://example.com/p', supportUrl: 'https://example.com/s', website: 'https://example.com', contactEmail: 'a@example.com', profile: 'app' },
|
||||
languages: [{ id: 'en', play: 'en-US', apple: 'en-US' }], play: { packageName: 'com.example.demo' }, apple: { bundleId: 'com.example.demo' }, ...o,
|
||||
} as ShipConfig);
|
||||
const none = { demoUser: null, contactEmail: null, uploaded: null };
|
||||
|
||||
describe('declarations', () => {
|
||||
test('an empty config asks the owner everything it cannot prove', () => {
|
||||
const d = declarations(base(), none);
|
||||
expect(d.ask.map(a => a.id).sort()).toEqual(['ai-age', 'ai-categories', 'ai-rights', 'ap-unknown', 'ds-missing', 'enc-unset', 'rv-contact', 'rv-signin']);
|
||||
expect(d.encryption).toBeNull();
|
||||
expect(d.dataSafety).toBeNull();
|
||||
});
|
||||
test('Data safety answers become App Privacy suggestions; linked / tracking stay questions', () => {
|
||||
const cfg = base({
|
||||
dataSafety: { collectsData: true, encryptedInTransit: true, deletionRequest: true, data: {
|
||||
PSL_DEVICE_ID: { shared: true, collect: ['analytics'], share: ['advertising'] }, PSL_CRASH_LOGS: { shared: false, collect: ['analytics'] } } },
|
||||
apple: { bundleId: 'com.example.demo', usesNonExemptEncryption: false, info: { categories: { primary: 'UTILITIES' }, ageRating: {}, contentRights: 'DOES_NOT_USE_THIRD_PARTY_CONTENT' } },
|
||||
reviewAccess: { signInRequired: false },
|
||||
});
|
||||
const d = declarations(cfg, { ...none, contactEmail: 'a***@example.com' });
|
||||
expect(d.appPrivacy!.items.find(x => x.apple === 'Device ID')).toEqual({ apple: 'Device ID', category: 'Identifiers', from: ['PSL_DEVICE_ID'], purposes: ['Analytics', 'Third-Party Advertising'], thirdParty: true });
|
||||
expect(d.ask.map(a => a.id)).toEqual(['ap-linked']);
|
||||
expect(d.encryption).toBe(false);
|
||||
expect(d.review.contact).toBe('a***@example.com');
|
||||
expect(applePurpose('advertising', false)).toBe('Developer\'s Advertising or Marketing');
|
||||
});
|
||||
test('changes since the last upload compare answers, not labels', () => {
|
||||
const ds = { collectsData: true, encryptedInTransit: true, deletionRequest: false, data: { PSL_CRASH_LOGS: { shared: false, collect: ['analytics' as const] } } };
|
||||
const before = dataSafetyCsv(ds);
|
||||
expect(dataSafetyChanges(before, before)).toEqual([]);
|
||||
const after = dataSafetyCsv({ ...ds, deletionRequest: true });
|
||||
expect(dataSafetyChanges(before, after)).toEqual([{ question: 'PSL_DATA_COLLECTION_USER_REQUEST_DELETE', response: '', from: 'FALSE', to: 'TRUE' }]);
|
||||
const d = declarations(base({ dataSafety: { ...ds, deletionRequest: true } }), { ...none, uploaded: { csv: before, at: '2026-10-01T00:00:00Z' } });
|
||||
expect(d.dataSafety!.uploaded!.changes.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renders as data: URLs', () => {
|
||||
test('only image paths inside the renders folder', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sb-renders-'));
|
||||
mkdirSync(join(dir, 'en', 'ios69'), { recursive: true });
|
||||
writeFileSync(join(dir, 'en', 'ios69', '01.png'), Buffer.from([0x89, 0x50, 0x4e, 0x47]));
|
||||
writeFileSync(join(dir, 'secret.txt'), 'x');
|
||||
expect(renderImage(dir, 'en/ios69/01.png').dataUrl).toStartWith('data:image/png;base64,');
|
||||
for (const bad of ['../x.png', 'en/../../x.png', '/etc/x.png', 'secret.txt', 'en/./01.png', '-x.png']) {
|
||||
if (bad !== '-x.png') expect(RENDER_FILE_RE.test(bad), bad).toBe(false);
|
||||
expect(renderImage(dir, bad).dataUrl, bad).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -40,6 +40,11 @@ const D3_WRITES: [string, J][] = [
|
|||
['shots.render', {}], ['shots.video', {}], ['shots.gallery', {}], ['icons', {}],
|
||||
['owner.play_rollout', { action: 'percent', percent: 50 }], ['owner.play_rollout', { action: 'halt' }], ['owner.ios_phased', { action: 'pause', version: '2.3.0' }],
|
||||
['owner.ios_phased', { action: 'resume' }], ['owner.reply_send', { file: 'play-r-p1.md' }], ['owner.testflight_testers', { groups: 'Friends and family' }],
|
||||
// full CLI coverage: price sheet, Data safety, app info, PPO, analytics
|
||||
['owner.prices_import', {}], ['owner.prices_import', { csv: '/tmp/sheets/prices autumn.csv', store: 'play' }], ['prices.export', {}],
|
||||
['play.data_safety', {}], ['apple.appinfo', {}], ['apple.review_details', {}], ['apple.encryption', {}],
|
||||
['apple.ppo_create', { variants: 'b', traffic: 30 }], ['apple.ppo_upload', { variant: 'b', experiment: 'storebound b' }],
|
||||
['owner.ppo_start', { experiment: 'storebound b' }], ['owner.ppo_stop', {}], ['analytics.snapshot', {}], ['analytics.setup', {}],
|
||||
];
|
||||
|
||||
describe('D3 writes: token binding for every method the window offers', () => {
|
||||
|
|
@ -82,7 +87,7 @@ describe('D3 writes: token binding for every method the window offers', () => {
|
|||
|
||||
describe('owner actions', () => {
|
||||
test('exactly these, desktop only, kind owner, never a submit / release request / cancel / external TestFlight flag', () => {
|
||||
expect(OWNER_TOOLS.map(t => methodName(t.name)).sort()).toEqual(['owner.ios_phased', 'owner.play_rollout', 'owner.reply_send', 'owner.testflight_testers']);
|
||||
expect(OWNER_TOOLS.map(t => methodName(t.name)).sort()).toEqual(['owner.ios_phased', 'owner.play_rollout', 'owner.ppo_start', 'owner.ppo_stop', 'owner.prices_import', 'owner.reply_send', 'owner.testflight_testers']);
|
||||
for (const t of OWNER_TOOLS) expect(TOOLS.some(x => x.name === t.name)).toBe(false);
|
||||
const ds = describeMethods().filter(m => m.method.startsWith('owner.'));
|
||||
for (const d of ds) expect(d.kind).toBe('owner');
|
||||
|
|
@ -111,12 +116,37 @@ describe('owner actions', () => {
|
|||
const s = await session();
|
||||
for (const [m, args] of [['owner.play_rollout', { action: 'manual' }], ['owner.play_rollout', { action: 'percent', percent: 100 }], ['owner.play_rollout', { action: 'percent', percent: 0.5 }],
|
||||
['owner.ios_phased', { action: 'release' }], ['owner.ios_phased', { action: 'on', version: '--manual-release' }], ['owner.reply_send', { file: '../../etc/passwd' }],
|
||||
['owner.reply_send', {}], ['reviews.reply', { file: 'play-1.md', text: '--yes' }], ['reviews.reply', { file: 'play-1.md', text: 'x'.repeat(6001) }]] as [string, J][])
|
||||
['owner.reply_send', {}], ['reviews.reply', { file: 'play-1.md', text: '--yes' }],
|
||||
['owner.prices_import', { csv: '--yes.csv' }], ['owner.prices_import', { csv: 'prices.txt' }], ['owner.prices_import', { only: 'a,--yes' }], ['owner.ppo_stop', { experiment: '--yes' }],
|
||||
['project.render', { file: '../../etc/passwd.png' }], ['project.render', { file: '/etc/x.png' }], ['project.render', { file: 'en/ios69/01.txt' }], ['reviews.reply', { file: 'play-1.md', text: 'x'.repeat(6001) }]] as [string, J][])
|
||||
expect(err(await s.call(m, { project: DEMO, args })).code).toBe(ERR.invalidParams);
|
||||
expect(s.calls.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('full CLI coverage: new methods', () => {
|
||||
test('argv of the price sheet, PPO start / stop and the offline reads', async () => {
|
||||
const t = (name: string) => OWNER_TOOLS.find(x => x.name === name)!;
|
||||
expect(toArgv(t('owner_prices_import'), { csv: '/tmp/p.csv', dry_run: false }).argv).toEqual(['prices', 'import', '--csv', '/tmp/p.csv']);
|
||||
expect(toArgv(t('owner_ppo_start'), { experiment: 'storebound b' }).argv).toEqual(['apple', 'ppo', 'start', '--experiment', 'storebound b', '--dry']);
|
||||
expect(toArgv(t('owner_ppo_stop'), { dry_run: false }).argv).toEqual(['apple', 'ppo', 'stop']);
|
||||
const s = await session();
|
||||
for (const [m, args, argv] of [
|
||||
['project.declarations', {}, ['inspect', '--declarations', '--json']], ['project.listing_text', {}, ['inspect', '--listing-text', '--json']],
|
||||
['project.renders', { lang: 'en' }, ['shots', 'gallery', '--lang', 'en', '--json']], ['project.render', { file: 'b/en/ios69/01.png' }, ['inspect', '--render', 'b/en/ios69/01.png', '--json']],
|
||||
['prices.current', { with_automatic: true }, ['prices', 'export', '--with-automatic', '--json']], ['prices.diff', { csv: '/tmp/p.csv' }, ['prices', 'import', '--csv', '/tmp/p.csv', '--dry', '--json']],
|
||||
] as [string, J, string[]][]) {
|
||||
expect(err(await s.call(m, { project: DEMO, args }))).toBeUndefined();
|
||||
expect(s.calls.at(-1)!.argv).toEqual(argv);
|
||||
}
|
||||
// the fastlane import runs only on a folder without a config, and never through write_with_confirm's project list
|
||||
expect(err(await s.call('import.fastlane', { project: DEMO, args: {} })).code).toBe(ERR.invalidParams);
|
||||
const empty = mkdtempSync(join(tmpdir(), 'sb-fl-'));
|
||||
expect(err(await s.call('import.fastlane', { project: empty, args: {} }))).toBeUndefined();
|
||||
expect(s.calls.at(-1)!.argv).toEqual(['import', 'fastlane', '--dry']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the owner flag', () => {
|
||||
const saved = { ...process.env };
|
||||
afterEach(() => { for (const k of ['STOREBOUND_SERVE', 'STOREBOUND_OWNER_CONFIRMED']) { if (saved[k] === undefined) delete process.env[k]; else process.env[k] = saved[k]; } });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue