flows, listing translate, scan 2.2 + --originality, prices export with subscriptions, site sections
- storebound flow list|validate|run: repo-local workflows (store/workflows/*.yml, storebound.workflows.*), writes dry unless --apply, owner steps never run, --from / --resume; init templates for app and game; MCP flow_list + dry flow_run; release-flows skill - storebound listing translate|check|reviewed: per-language listing drafts with store limits and keyword rules, agent or --translate hook, marked until reviewed; MCP listing_translate / listing_check; listing-localization skill - scan: Apple 2.2 beta/demo/test wording rule; scan --originality [--against] - prices export includes subscriptions; prices import skips their rows - site: rejection scan section, Desktop app section with fixture-mode screenshots, Everything else grid, FAQ 4.3 answer - README, CHANGELOG, adapters, API tables
This commit is contained in:
parent
e44897ca4e
commit
526dfd3b09
45 changed files with 2176 additions and 53 deletions
|
|
@ -81,7 +81,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'apps_perfPowerMetrics_getToManyRelated': 'health',
|
||||
'apps_promotedPurchases_getToManyRelated': 'apple/promoted',
|
||||
'apps_promotedPurchases_replaceToManyRelationship': 'lib/offers',
|
||||
'apps_subscriptionGroups_getToManyRelated': 'apple/iap-submit apple/promoted apple/subscriptions apple/win-back catalog validate',
|
||||
'apps_subscriptionGroups_getToManyRelated': 'apple/iap-submit apple/promoted apple/subscriptions apple/win-back catalog prices validate',
|
||||
'apps_updateInstance': 'apple/appinfo',
|
||||
'betaAppLocalizations_createInstance': 'lib/testflight',
|
||||
'betaAppLocalizations_updateInstance': 'lib/testflight',
|
||||
|
|
@ -164,7 +164,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'subscriptionGroupLocalizations_createInstance': 'apple/subscriptions',
|
||||
'subscriptionGroups_createInstance': 'apple/subscriptions',
|
||||
'subscriptionGroups_subscriptionGroupLocalizations_getToManyRelated': 'apple/subscriptions validate',
|
||||
'subscriptionGroups_subscriptions_getToManyRelated': 'apple/iap-submit apple/promoted apple/subscriptions apple/win-back catalog validate',
|
||||
'subscriptionGroups_subscriptions_getToManyRelated': 'apple/iap-submit apple/promoted apple/subscriptions apple/win-back catalog prices validate',
|
||||
'subscriptionGroups_versions_getToManyRelated': 'apple/iap-submit',
|
||||
'subscriptionLocalizations_createInstance': 'apple/subscriptions',
|
||||
'subscriptionOfferCodeCustomCodes_createInstance': 'apple/subscriptions',
|
||||
|
|
@ -178,7 +178,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'subscriptions_introductoryOffers_getToManyRelated': 'apple/subscriptions catalog',
|
||||
'subscriptions_offerCodes_getToManyRelated': 'apple/subscriptions catalog',
|
||||
'subscriptions_pricePoints_getToManyRelated': 'apple/subscriptions apple/win-back',
|
||||
'subscriptions_prices_getToManyRelated': 'apple/subscriptions apple/win-back catalog',
|
||||
'subscriptions_prices_getToManyRelated': 'apple/subscriptions apple/win-back catalog prices',
|
||||
'subscriptions_promotionalOffers_getToManyRelated': 'apple/subscriptions catalog',
|
||||
'subscriptions_subscriptionAvailability_getToOneRelated': 'apple/subscriptions',
|
||||
'subscriptions_subscriptionLocalizations_getToManyRelated': 'apple/subscriptions catalog validate',
|
||||
|
|
@ -219,6 +219,7 @@ export const WRAPPED: { apple: Record<string, string>; play: Record<string, stri
|
|||
'androidpublisher.monetization.subscriptions.basePlans.offers.create': 'play/subscriptions',
|
||||
'androidpublisher.monetization.subscriptions.basePlans.offers.list': 'catalog play/subscriptions',
|
||||
'androidpublisher.monetization.subscriptions.create': 'play/subscriptions',
|
||||
'androidpublisher.monetization.subscriptions.get': 'prices',
|
||||
'androidpublisher.monetization.subscriptions.list': 'catalog play/subscriptions validate',
|
||||
'androidpublisher.monetization.subscriptions.patch': 'play/subscriptions',
|
||||
'androidpublisher.reviews.list': 'reviews',
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
if (missing.length) note(`appstore listing has no section for ${missing.join(', ')}`);
|
||||
return `${Object.keys(copy).length} locales`;
|
||||
});
|
||||
// listing translation drafts (storebound listing translate): fine to keep working on, not to push unreviewed
|
||||
for (const f of [config.apple ? resolve(config.apple.listing ?? 'store/appstore.md') : '', config.play ? resolve(config.play.listing ?? 'store/listing.md') : ''].filter(Boolean)) {
|
||||
if (!existsSync(f)) continue;
|
||||
const marks = [...readFileSync(f, 'utf8').matchAll(/^## (\S+)[^\n]*\n(?:<!--\s*play:[^\n]*\n)?<!--\s*storebound-translation\s+from=\S+\s+status=(translate|draft)/gm)];
|
||||
const todo = marks.filter(m => m[2] === 'translate').map(m => m[1]!), drafts = marks.filter(m => m[2] === 'draft').map(m => m[1]!);
|
||||
if (todo.length) note(`${relative(process.cwd(), f) || f}: not translated yet (status=translate): ${todo.join(', ')}`);
|
||||
if (drafts.length) note(`${relative(process.cwd(), f) || f}: machine-translated drafts not reviewed: ${drafts.join(', ')} (storebound listing check, then listing reviewed --lang <ids>)`);
|
||||
}
|
||||
if (config.dataSafety) tryDo('data safety', () => `${dataSafetyRows(config.dataSafety!).length - 1} CSV rows`);
|
||||
for (const p of config.products ?? []) for (const [lang, l] of Object.entries(p.listings)) {
|
||||
if (config.apple && len(l.description) > APPLE_IAP_LIMITS.description) problems.push(`product ${p.id} ${lang}: description ${len(l.description)} > ${APPLE_IAP_LIMITS.description} (App Store limit)`);
|
||||
|
|
|
|||
220
cli/flow.ts
Normal file
220
cli/flow.ts
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
// Repo-local workflows: named, ordered storebound steps kept in the project (definitions and rules: lib/flow.ts).
|
||||
// storebound flow list [--json] the flows of this project and their steps
|
||||
// storebound flow validate [--json] definitions, sub-flow cycles, commands, variables; exit 1 on a problem
|
||||
// storebound flow run <name> [NAME=value ...] [--dry | --apply] [--from <step> | --resume] [--json]
|
||||
// default: read steps run, write steps run with --dry (nothing changes), wait steps check once, shell steps are
|
||||
// skipped, owner steps (submit, release, rollout ...) are shown as "your click" and never run
|
||||
// --dry: only the plan: nothing runs at all
|
||||
// --apply: write steps and shell steps run for real; every write command still asks the owner itself
|
||||
// --from <step>: start at that step (variables captured by the last run are reused); --resume: from the first step
|
||||
// the last run did not finish (.storebound/flows/<name>.json)
|
||||
// Progress: "[flow] 3/9 upload: storebound apple upload --no-wait --dry" before each step, the step's own output
|
||||
// indented, then ok / failed with the time. Exit 1 when a step failed (and had no continueOnError).
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, join, relative } from 'node:path';
|
||||
import type { Args } from './lib/args';
|
||||
import { CONFIG_NAMES, loadConfig } from './lib/config';
|
||||
import {
|
||||
type CondCtx, expand, type Flow, flowsOfFile, kindOf, type Mode, parseParams, planStep, type PlannedStep, resumePoint, type RunState, startIndex,
|
||||
type StepResult, validateFlows,
|
||||
} from './lib/flow';
|
||||
import { done, log, printJson, step, warn } from './lib/log';
|
||||
import { childEnv, pump, selfCommand } from './lib/runner';
|
||||
import { parseYaml } from './lib/yaml';
|
||||
|
||||
const TAG = 'flow';
|
||||
const EXT = ['.yml', '.yaml', '.json', '.ts'];
|
||||
|
||||
/** Project folder: the folder of the nearest storebound.config.* above the working directory, else the working directory. */
|
||||
export function projectRoot(start = process.cwd()): string {
|
||||
for (let d = start; ; d = dirname(d)) {
|
||||
if (CONFIG_NAMES.some(n => existsSync(join(d, n))) || existsSync(join(d, 'store', 'workflows'))) return d;
|
||||
if (dirname(d) === d) return start;
|
||||
}
|
||||
}
|
||||
|
||||
async function readData(path: string): Promise<unknown> {
|
||||
if (path.endsWith('.ts')) { const m = await import(path) as { default?: unknown }; return m.default; }
|
||||
const text = readFileSync(path, 'utf8');
|
||||
if (path.endsWith('.json')) return JSON.parse(text);
|
||||
return parseYaml(text);
|
||||
}
|
||||
|
||||
/** Every flow file of a project, read and checked. */
|
||||
export async function loadFlows(root: string): Promise<{ flows: Flow[]; errors: string[]; files: string[] }> {
|
||||
const flows: Flow[] = [], errors: string[] = [], files: string[] = [];
|
||||
const add = async (path: string, single: string | null) => {
|
||||
const rel = relative(root, path);
|
||||
files.push(rel);
|
||||
try { const r = flowsOfFile(rel, await readData(path), single); flows.push(...r.flows); errors.push(...r.errors); }
|
||||
catch (e) { errors.push(`${rel}: ${(e as Error).message}`); }
|
||||
};
|
||||
for (const ext of EXT) { const p = join(root, `storebound.workflows${ext}`); if (existsSync(p)) await add(p, null); }
|
||||
const dir = join(root, 'store', 'workflows');
|
||||
if (existsSync(dir)) for (const f of readdirSync(dir).sort()) { const ext = EXT.find(x => f.endsWith(x)); if (ext) await add(join(dir, f), f.slice(0, -ext.length)); }
|
||||
return { flows, errors, files };
|
||||
}
|
||||
|
||||
/** Command names of this storebound (from `storebound help`), for `flow validate`. */
|
||||
function commandNames(): Set<string> {
|
||||
const r = Bun.spawnSync([...selfCommand(), 'help'], { stdout: 'pipe', stderr: 'pipe' });
|
||||
const names = new Set<string>(['help', 'version']);
|
||||
for (const l of r.stdout.toString().split('\n')) if (/^ {2}[a-z]/.test(l)) { const n = l.slice(2, 27).trim(); if (n && !n.includes(':')) names.add(n); }
|
||||
return names;
|
||||
}
|
||||
|
||||
function statePath(root: string, name: string): string { return join(root, '.storebound', 'flows', `${name}.json`); }
|
||||
function readState(root: string, name: string): RunState | null {
|
||||
try { return JSON.parse(readFileSync(statePath(root, name), 'utf8')) as RunState; } catch { return null; }
|
||||
}
|
||||
|
||||
async function condCtx(root: string): Promise<CondCtx> {
|
||||
let apple = false, play = false;
|
||||
try { const { config } = await loadConfig(undefined, root); apple = !!config.apple; play = !!config.play; } catch { /* no config: store conditions are false */ }
|
||||
return { apple, play, exists: p => existsSync(join(root, p)) };
|
||||
}
|
||||
|
||||
const KIND_LABEL: Record<string, string> = { read: 'read', write: 'write', wait: 'wait', owner: 'your click', shell: 'shell' };
|
||||
|
||||
function describe(p: PlannedStep): string {
|
||||
if (p.owner !== undefined) return p.owner;
|
||||
if (p.shell !== undefined) return `sh: ${p.shell}`;
|
||||
return `storebound ${p.argv!.join(' ')}`;
|
||||
}
|
||||
|
||||
/** Runs one storebound step (or shell line) with stdin attached, so the command's own confirmation works; output indented. */
|
||||
async function exec(p: PlannedStep, root: string, quiet: boolean): Promise<{ code: number; last: string; out: string }> {
|
||||
const cmd = p.shell !== undefined ? ['sh', '-c', p.shell] : [...selfCommand(), ...p.argv!];
|
||||
const proc = Bun.spawn(cmd, { cwd: root, stdin: 'inherit', stdout: 'pipe', stderr: 'pipe', env: childEnv() });
|
||||
const lines: string[] = [];
|
||||
let last = '';
|
||||
const each = (line: string, kind: 'stdout' | 'stderr') => {
|
||||
lines.push(line);
|
||||
if (kind === 'stdout' && line.trim()) last = line.trim();
|
||||
if (!quiet) (kind === 'stderr' ? console.error : console.log)(` ${line}`);
|
||||
};
|
||||
await Promise.all([pump(proc.stdout, 'stdout', each), pump(proc.stderr, 'stderr', each)]);
|
||||
return { code: await proc.exited, last, out: lines.join('\n') };
|
||||
}
|
||||
|
||||
async function list(args: Args, root: string): Promise<void> {
|
||||
const { flows, errors, files } = await loadFlows(root);
|
||||
const all = new Map(flows.map(f => [f.name, f] as const));
|
||||
const shown = flows.filter(f => !f.private);
|
||||
const rows = shown.map(f => ({ name: f.name, file: f.file, description: f.description ?? '', params: f.params,
|
||||
steps: expand(f, all).steps.map(s => ({ id: s.id, kind: kindOf(s), what: s.run ?? s.sh ?? s.owner ?? '' })) }));
|
||||
if (args.has('json')) { printJson({ root, files, flows: rows, errors }); return; }
|
||||
if (!files.length) { log(TAG, 'no flows here: storebound init --profile app|game writes store/workflows/release.yml and beta.yml, or add storebound.workflows.yml'); return; }
|
||||
for (const f of rows) {
|
||||
console.log(`\n${f.name} (${f.file})${f.description ? ` ${f.description}` : ''}`);
|
||||
if (Object.keys(f.params).length) console.log(` params: ${Object.entries(f.params).map(([k, v]) => `${k}=${v || '""'}`).join(' ')}`);
|
||||
f.steps.forEach((s, i) => console.log(` ${String(i + 1).padStart(2)}. ${s.id.padEnd(18)} ${KIND_LABEL[s.kind]!.padEnd(10)} ${s.what}`));
|
||||
}
|
||||
for (const e of errors) warn(TAG, e);
|
||||
if (errors.length) process.exitCode = 1;
|
||||
}
|
||||
|
||||
async function validate(args: Args, root: string): Promise<void> {
|
||||
const { flows, errors, files } = await loadFlows(root);
|
||||
const problems = [...errors, ...validateFlows(flows, { commands: commandNames() })];
|
||||
if (args.has('json')) printJson({ root, files, flows: flows.map(f => f.name), problems, ok: !problems.length });
|
||||
else {
|
||||
for (const p of problems) warn(TAG, p);
|
||||
done(TAG, problems.length ? `${problems.length} problem(s) in ${files.length} file(s)` : `${flows.length} flow(s) in ${files.length} file(s): ok`);
|
||||
}
|
||||
if (problems.length) process.exitCode = 1;
|
||||
}
|
||||
|
||||
async function runFlow(args: Args, root: string): Promise<void> {
|
||||
const name = args._[1];
|
||||
if (!name) throw new Error('usage: storebound flow run <name> [NAME=value ...] [--dry | --apply] [--from <step> | --resume]');
|
||||
if (args.has('dry') && args.has('apply')) throw new Error('--dry or --apply, not both');
|
||||
const { flows, errors } = await loadFlows(root);
|
||||
const problems = [...errors, ...validateFlows(flows)];
|
||||
if (problems.length) throw new Error(`flow definitions have problems (storebound flow validate):\n ${problems.join('\n ')}`);
|
||||
const all = new Map(flows.map(f => [f.name, f] as const));
|
||||
const flow = all.get(name);
|
||||
if (!flow || flow.private) throw new Error(`no flow "${name}" (${flows.filter(f => !f.private).map(f => f.name).join(', ') || 'none: storebound flow list'})`);
|
||||
const mode: Mode = args.has('apply') ? 'apply' : args.has('dry') ? 'plan' : 'dry';
|
||||
const json = args.has('json');
|
||||
const parts = { before: expand(flow, all, 'before').steps, steps: expand(flow, all, 'steps').steps, after: expand(flow, all, 'after').steps, onError: expand(flow, all, 'onError').steps };
|
||||
const last = readState(root, name);
|
||||
if (args.has('resume') && args.has('from')) throw new Error('--from or --resume, not both');
|
||||
const from = args.has('resume') ? resumePoint(parts.steps, last) : args.get('from');
|
||||
if (args.has('resume') && !from) throw new Error(last ? `the last run of ${name} finished every step; nothing to resume` : `no earlier run of ${name} to resume`);
|
||||
const begin = startIndex(parts.steps, from);
|
||||
const params = parseParams(args._.slice(2));
|
||||
const subParams = expand(flow, all, 'steps').params;
|
||||
const vars: Record<string, string> = { ...subParams, ...flow.params, ...(from ? last?.vars ?? {} : {}), ...params };
|
||||
const c = await condCtx(root);
|
||||
const state: RunState = { flow: name, mode, startedAt: new Date().toISOString(), vars, results: [], ok: true };
|
||||
const env = process.env as Record<string, string | undefined>;
|
||||
const save = () => { if (mode === 'plan') return; mkdirSync(dirname(statePath(root, name)), { recursive: true }); writeFileSync(statePath(root, name), JSON.stringify(state, null, 2) + '\n'); };
|
||||
|
||||
if (!json) {
|
||||
log(TAG, `${name}${flow.description ? `: ${flow.description}` : ''}`);
|
||||
log(TAG, mode === 'plan' ? 'plan only (--dry): nothing runs' : mode === 'dry' ? 'reads run, writes run as dry runs (--apply runs them for real), owner steps are yours' : '--apply: writes run for real; each command asks before it changes a store');
|
||||
if (from) log(TAG, `starting at ${parts.steps[begin]!.id}${args.has('resume') ? ' (--resume)' : ''}`);
|
||||
}
|
||||
// results of the steps before --from carry over, so a later --resume knows they are done
|
||||
if (from && last) state.results.push(...last.results.filter(r => r.part === 'steps' && parts.steps.slice(0, begin).some(s => s.id === r.id)));
|
||||
|
||||
const runPart = async (part: PlannedStep['part'], steps: typeof parts.steps, offset = 0): Promise<boolean> => {
|
||||
for (let i = offset; i < steps.length; i++) {
|
||||
const s = steps[i]!;
|
||||
const p = planStep(s, part, mode, vars, c, env);
|
||||
const label = `${part === 'steps' ? '' : `${part} `}${step(i + 1, steps.length, s.id)}`;
|
||||
const r: StepResult = { id: s.id, part, kind: p.kind, status: 'planned', command: describe(p) };
|
||||
if (p.skip) {
|
||||
r.status = p.kind === 'owner' && !p.skip.startsWith('if ') ? 'owner' : mode === 'plan' && !p.skip.startsWith('if ') && p.kind !== 'shell' ? 'planned' : 'skipped';
|
||||
r.detail = p.skip;
|
||||
if (!json) log(TAG, `${label}: ${p.kind === 'owner' && r.status === 'owner' ? `YOUR CLICK ${describe(p)}` : `${describe(p)} (${p.skip})`}`);
|
||||
state.results.push(r); save();
|
||||
continue;
|
||||
}
|
||||
if (!json) log(TAG, `${label}: ${describe(p)}${p.dryAdded ? ' (dry run)' : ''}`);
|
||||
const t = Date.now();
|
||||
const x = await exec(p, root, json);
|
||||
r.exitCode = x.code; r.ms = Date.now() - t;
|
||||
if (x.code === 0) {
|
||||
r.status = 'ok';
|
||||
if (p.capture) {
|
||||
if (/^[\w.:/@+-]{1,200}$/.test(x.last)) { vars[p.capture] = x.last; r.detail = `${p.capture}=${x.last}`; }
|
||||
else warn(TAG, `${s.id}: capture ${p.capture}: the last output line is not a single value ("${x.last.slice(0, 60)}")`);
|
||||
}
|
||||
if (!json) log(TAG, `${label}: ok (${(r.ms / 1000).toFixed(1)}s)${r.detail ? ` ${r.detail}` : ''}`);
|
||||
} else {
|
||||
r.status = 'failed';
|
||||
r.detail = x.out.split('\n').filter(Boolean).slice(-1)[0]?.slice(0, 300);
|
||||
if (!json) warn(TAG, `${label}: failed (exit ${x.code})${p.continueOnError ? ', continueOnError: going on' : ''}`);
|
||||
}
|
||||
state.vars = vars; state.results.push(r); save();
|
||||
if (r.status === 'failed' && !p.continueOnError) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
let ok = (await runPart('before', parts.before)) && (await runPart('steps', parts.steps, begin));
|
||||
if (ok) ok = await runPart('after', parts.after);
|
||||
else if (parts.onError.length) await runPart('onError', parts.onError);
|
||||
state.ok = ok; state.finishedAt = new Date().toISOString(); save();
|
||||
|
||||
const owner = state.results.filter(r => r.status === 'owner');
|
||||
if (json) printJson({ ...state, stateFile: mode === 'plan' ? null : relative(root, statePath(root, name)) });
|
||||
else {
|
||||
if (owner.length) { console.log('\nYour clicks (storebound never does these):'); for (const r of owner) console.log(` - ${r.command}`); }
|
||||
const failed = state.results.find(r => r.status === 'failed' && r.part === 'steps');
|
||||
if (!ok && failed) log(TAG, `stopped at ${failed.id}. Fix it, then: storebound flow run ${name} --resume${mode === 'apply' ? ' --apply' : ''}`);
|
||||
done(TAG, `${name}: ${ok ? 'done' : 'failed'} (${mode === 'plan' ? 'plan only' : mode === 'dry' ? 'dry run: nothing changed' : 'applied'})`);
|
||||
}
|
||||
if (!ok) process.exitCode = 1;
|
||||
}
|
||||
|
||||
export async function run(args: Args): Promise<void> {
|
||||
const root = projectRoot();
|
||||
const sub = args._[0] ?? 'list';
|
||||
if (sub === 'list') return list(args, root);
|
||||
if (sub === 'validate') return validate(args, root);
|
||||
if (sub === 'run') return runFlow(args, root);
|
||||
throw new Error('usage: storebound flow list | validate | run <name> [NAME=value ...] [--dry | --apply] [--from <step> | --resume]');
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ const PLAIN: Record<string, [() => Promise<Plain>, string]> = {
|
|||
'privacy-manifest': [() => import('./privacy-manifest'), 'iOS PrivacyInfo.xcprivacy + required-reason API + SDK manifest scan (--ios <path>)'],
|
||||
'ws': [() => import('./workspace'), 'many apps and studios (storebound.workspace.json): init | list | status (apps x stores, parallel) | check | validate | run <command> --apps a,b|--all (writes dry unless --apply) | apps import --account <profile> | desktop export|import'],
|
||||
'release': [() => import('./release'), 'status [--app a,b] [--versions]: both stores on one train per version (build > testing > review > live > rollout %) | plan <version>: what is left on each store, in fix order; read-only, --json'],
|
||||
'flow': [() => import('./flow'), 'repo-local workflows (store/workflows/*.yml, storebound.workflows.*): list | validate | run <name> [NAME=value] [--dry plan only | --apply] [--from <step> | --resume]; writes run as dry runs unless --apply, owner steps (submit, release, rollout) are never run'],
|
||||
'ads': [() => import('./ads'), 'scan --ios <path>: AdAttributionKit / SKAdNetwork checks of Info.plist (network ids, postback copy endpoints, attribution windows, cooldown) and sources; --json'],
|
||||
};
|
||||
const COMMANDS: Record<string, [() => Promise<Mod>, string]> = {
|
||||
|
|
@ -42,6 +43,7 @@ const COMMANDS: Record<string, [() => Promise<Mod>, string]> = {
|
|||
'console fill': [() => import('./console/fill'), '<form> [--store apple|play]: AI-assisted autofill of console forms without an API in a visible Chromium you sign in to yourself; stops before Save / Submit'],
|
||||
'reviews': [() => import('./reviews'), 'list | draft (local reply drafts in .storebound/replies) | send (approved drafts only, asks first)'],
|
||||
'originality': [() => import('./originality'), 'Guideline 4.3 check vs your other apps (--against <folders>): listing text, name, icon and screenshot perceptual hashes, project structure; scores, flags, suggestions; offline, exit 1 on a near-duplicate'],
|
||||
'listing': [() => import('./listing'), 'translate --to de-DE,ja [--from en-US] [--translate "<command>"]: listing translation drafts per language (App Store name, subtitle, promo text, keywords, description; Play title, short, full) with store limits and keyword rules, marked until reviewed | check | reviewed --lang <ids>; local files only'],
|
||||
'whats-new': [() => import('./whats-new'), 'draft user-facing release notes from git log into the listing files (--since <tag>); --languages a,b: one file per language to translate | check | apply'],
|
||||
'play products': [() => import('./play/products'), 'one-time products: create / update, regional prices, activate'],
|
||||
'play subscriptions': [() => import('./play/subscriptions'), 'auto-renewable subscriptions: listings, base plan, regional prices, intro offer, activate (--csv prices sheet; asks first)'],
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ export const FILES: [string, string][] = [
|
|||
['privacy-policy.html', 'store/privacy-policy.html'],
|
||||
['credentials.example.json', '.storebound/credentials.json'],
|
||||
['testers.csv', '.storebound/testers.csv'],
|
||||
['workflows/release.yml', 'store/workflows/release.yml'],
|
||||
['workflows/beta.yml', 'store/workflows/beta.yml'],
|
||||
];
|
||||
|
||||
/** Template folders a profile reads from (relative to templates/), most specific first. game = the root templates. */
|
||||
|
|
@ -67,5 +69,5 @@ export async function run(args: Args): Promise<void> {
|
|||
else writeFileSync(gi, '# storebound: credentials, fonts, temp files\n.storebound/\n');
|
||||
log('init', '.gitignore: added .storebound/');
|
||||
}
|
||||
log('init', 'next: edit storebound.config.ts, store/*.md and .storebound/credentials.json, then `storebound check`');
|
||||
log('init', 'next: edit storebound.config.ts, store/*.md and .storebound/credentials.json, then `storebound check`; store/workflows/*.yml: storebound flow list');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export function parseArgs(argv: string[], booleans: string[] = []): Args {
|
|||
const repeated = new Map<string, string[]>();
|
||||
const set = (k: string, v: string) => { flags.set(k, v); repeated.set(k, [...(repeated.get(k) ?? []), v]); };
|
||||
const _: string[] = [];
|
||||
const bool = new Set(['dry', 'yes', 'help', 'json', 'verbose', 'all-pages', ...booleans]);
|
||||
const bool = new Set(['dry', 'yes', 'help', 'json', 'verbose', 'all-pages', 'apply', 'resume', 'force', ...booleans]);
|
||||
for (let i = 0; i < argv.length; i++) {
|
||||
const a = argv[i]!;
|
||||
if (!a.startsWith('--')) { _.push(a); continue; }
|
||||
|
|
|
|||
320
cli/lib/flow.ts
Normal file
320
cli/lib/flow.ts
Normal file
|
|
@ -0,0 +1,320 @@
|
|||
// Repo-local workflows (`storebound flow`): named, ordered storebound steps kept in the project, e.g. a release flow
|
||||
// next-build -> build -> upload -> wait -> whats-new apply -> validate -> scan -> plan -> your Submit click. Pure parts:
|
||||
// reading and checking the definitions, classifying each step (read / write / owner / shell / wait), variables, `if`
|
||||
// conditions and the run plan. The runner is cli/flow.ts.
|
||||
//
|
||||
// Where flows live (all are read; a name defined twice is an error):
|
||||
// storebound.workflows.(yml|yaml|json|ts) several flows: { flows: { <name>: Flow } } or { <name>: Flow }
|
||||
// store/workflows/<name>.(yml|yaml|json|ts) one flow per file, named after the file
|
||||
// A flow:
|
||||
// description: text
|
||||
// params: { VERSION: "1.0.0" } defaults; `flow run release VERSION=1.2.0` overrides
|
||||
// before: [steps] steps: [steps] after: [steps] onError: [steps] (hooks: before / after the steps, on a failure)
|
||||
// private: true only usable as a sub-flow (`flow: <name>` step), not listed or run directly
|
||||
// A step (exactly one of run / sh / owner / flow):
|
||||
// id: next-build unique in the flow; `--from <id>` resumes there
|
||||
// run: apple next-build a storebound command line (no "storebound" prefix); ${VAR} substituted
|
||||
// sh: npm run build:web a shell command of yours: only runs with --apply
|
||||
// owner: "App Store Connect: Submit for Review" never run: shown as "your click"
|
||||
// flow: beta the steps of another flow (ids prefixed "beta.")
|
||||
// capture: BUILD the last stdout line becomes ${BUILD} for later steps
|
||||
// if: apple | play | exists <path> | ${VAR} | !${VAR} | ${A} == x | ${A} != x
|
||||
// continueOnError: true a failure is reported and the flow goes on
|
||||
// Safety: write steps run with --dry unless `flow run --apply`; `--yes` is refused in any step (the commands ask the
|
||||
// owner themselves); owner steps (submit, release, rollout, sending replies, price changes, inviting testers, starting
|
||||
// experiments ...) are never executed, also when written as `run:`.
|
||||
|
||||
export type StepKind = 'read' | 'write' | 'wait' | 'owner' | 'shell';
|
||||
|
||||
export interface FlowStep {
|
||||
id: string;
|
||||
run?: string;
|
||||
sh?: string;
|
||||
owner?: string;
|
||||
flow?: string;
|
||||
capture?: string;
|
||||
if?: string;
|
||||
continueOnError?: boolean;
|
||||
/** Free text shown next to the step. */
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface Flow {
|
||||
name: string;
|
||||
file: string;
|
||||
description?: string;
|
||||
params: Record<string, string>;
|
||||
before: FlowStep[];
|
||||
steps: FlowStep[];
|
||||
after: FlowStep[];
|
||||
onError: FlowStep[];
|
||||
private: boolean;
|
||||
}
|
||||
|
||||
/** Commands that only read (stores or local files); they run for real in every mode except a --dry plan. */
|
||||
const READ: string[][] = [
|
||||
['check'], ['validate'], ['scan'], ['inspect'], ['doctor'], ['apps'], ['release', 'status'], ['release', 'plan'], ['originality'],
|
||||
['apple', 'next-build'], ['play', 'next-version-code'], ['apple', 'status'], ['play', 'status'], ['health'], ['catalog', 'diff'], ['triage'],
|
||||
['shots', 'check'], ['whats-new', 'check'], ['listing', 'check'], ['apple', 'testflight', 'status'], ['apple', 'testflight', 'groups'],
|
||||
['apple', 'signing', 'status'], ['apple', 'preorder', 'status'], ['apple', 'cpp', 'list'], ['apple', 'events', 'list'], ['ads', 'scan'],
|
||||
['privacy-manifest'], ['apple', 'encryption'], ['ws', 'list'], ['ws', 'status'], ['ws', 'check'], ['ws', 'validate'], ['apple', 'adhoc', 'devices'],
|
||||
['revenuecat', 'diff'], ['ads', 'apple', 'status'], ['ads', 'apple', 'campaigns'], ['ads', 'apple', 'report'], ['analytics', 'compare'],
|
||||
];
|
||||
/** Waits for a store (build processing): with --dry it checks once instead of waiting. */
|
||||
const WAIT: string[][] = [['apple', 'testflight', 'wait']];
|
||||
/** Never executed by a flow: the owner does these (AGENTS.md rule 1). */
|
||||
const OWNER: string[][] = [
|
||||
['apple', 'release'], ['play', 'rollout'], ['reviews', 'send'], ['prices', 'import'], ['apple', 'iap-submit'], ['apple', 'ppo', 'start'], ['apple', 'ppo', 'stop'],
|
||||
['apple', 'cpp', 'submit'], ['apple', 'cpp', 'visible'], ['apple', 'events', 'submit'], ['apple', 'preorder', 'enable'], ['apple', 'preorder', 'end'],
|
||||
['apple', 'testflight', 'testers'], ['apple', 'testflight', 'expire'], ['apple', 'offer-codes'], ['apple', 'win-back'], ['ads', 'apple', 'bid'],
|
||||
['ads', 'apple', 'budget'], ['ads', 'apple', 'pause'], ['apple', 'adhoc', 'register'],
|
||||
];
|
||||
const OWNER_ARGS = ['--submit-review', '--manual-release', '--cancel-submission', '--production', '--phased', 'submit', 'publish', '--remove', '--invite'];
|
||||
/** Never allowed inside a flow step. */
|
||||
const REFUSED_ARGS = ['--yes', '--apply'];
|
||||
|
||||
/** Words of a command line, honouring "double" and 'single' quotes. */
|
||||
export function splitArgs(line: string): string[] {
|
||||
const out: string[] = [];
|
||||
let cur = '', q: string | null = null, any = false;
|
||||
for (const c of line.trim()) {
|
||||
if (q) { if (c === q) q = null; else cur += c; continue; }
|
||||
if (c === '"' || c === '\'') { q = c; any = true; continue; }
|
||||
if (/\s/.test(c)) { if (cur || any) out.push(cur); cur = ''; any = false; continue; }
|
||||
cur += c;
|
||||
}
|
||||
if (q) throw new Error(`unterminated quote in: ${line}`);
|
||||
if (cur || any) out.push(cur);
|
||||
return out;
|
||||
}
|
||||
|
||||
const words = (argv: string[]): string[] => { const w: string[] = []; for (const a of argv) { if (a.startsWith('-')) break; w.push(a); } return w; };
|
||||
const starts = (w: string[], p: string[]) => p.length <= w.length && p.every((x, i) => w[i] === x);
|
||||
|
||||
/** What a `run:` step is. */
|
||||
export function classify(argv: string[]): StepKind {
|
||||
const w = words(argv);
|
||||
if (OWNER.some(p => starts(w, p)) || argv.some(a => OWNER_ARGS.includes(a))) return argv.includes('--dry') && !argv.some(a => OWNER_ARGS.includes(a)) ? 'read' : 'owner';
|
||||
if (WAIT.some(p => starts(w, p))) return 'wait';
|
||||
if (READ.some(p => starts(w, p))) return 'read';
|
||||
// `api` reads run, writes stay dry inside the command itself; treat it as a write so it gets --dry
|
||||
return 'write';
|
||||
}
|
||||
|
||||
export const kindOf = (s: FlowStep, argv?: string[]): StepKind =>
|
||||
s.owner !== undefined ? 'owner' : s.sh !== undefined ? 'shell' : classify(argv ?? splitArgs(s.run ?? ''));
|
||||
|
||||
// ---- loading ----
|
||||
|
||||
const ID_RE = /^[a-z0-9][a-z0-9._-]{0,62}$/;
|
||||
const VAR_RE = /^[A-Z][A-Z0-9_]{0,40}$/;
|
||||
const STEP_KEYS = ['id', 'run', 'sh', 'owner', 'flow', 'capture', 'if', 'continueOnError', 'note'];
|
||||
const FLOW_KEYS = ['description', 'params', 'before', 'steps', 'after', 'onError', 'private'];
|
||||
|
||||
function asSteps(v: unknown, where: string, e: string[]): FlowStep[] {
|
||||
if (v === undefined || v === null) return [];
|
||||
if (!Array.isArray(v)) { e.push(`${where}: must be a list of steps`); return []; }
|
||||
const out: FlowStep[] = [];
|
||||
v.forEach((x, i) => {
|
||||
const at = `${where}[${i}]`;
|
||||
if (typeof x !== 'object' || x === null || Array.isArray(x)) { e.push(`${at}: a step is a map (id, run | sh | owner | flow, ...)`); return; }
|
||||
const o = x as Record<string, unknown>;
|
||||
for (const k of Object.keys(o)) if (!STEP_KEYS.includes(k)) e.push(`${at}: unknown key "${k}" (${STEP_KEYS.join(', ')})`);
|
||||
const kinds = ['run', 'sh', 'owner', 'flow'].filter(k => o[k] !== undefined);
|
||||
if (kinds.length !== 1) e.push(`${at}: exactly one of run, sh, owner, flow`);
|
||||
for (const k of ['id', 'run', 'sh', 'owner', 'flow', 'capture', 'if', 'note']) if (o[k] !== undefined && typeof o[k] !== 'string') e.push(`${at}.${k}: must be a string`);
|
||||
const id = typeof o.id === 'string' ? o.id : typeof o.flow === 'string' ? o.flow : '';
|
||||
if (!ID_RE.test(id)) e.push(`${at}.id: "${id}" (lowercase letters, digits, . _ -)`);
|
||||
if (o.capture !== undefined && !VAR_RE.test(String(o.capture))) e.push(`${at}.capture: an UPPER_CASE name`);
|
||||
if (o.continueOnError !== undefined && typeof o.continueOnError !== 'boolean') e.push(`${at}.continueOnError: true or false`);
|
||||
out.push({ ...(o as unknown as FlowStep), id });
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/** One flow definition (already parsed from YAML / JSON / TS) -> Flow, with every problem. */
|
||||
export function toFlow(name: string, file: string, v: unknown): { flow: Flow | null; errors: string[] } {
|
||||
const e: string[] = [];
|
||||
const at = `${file}: ${name}`;
|
||||
if (!ID_RE.test(name)) e.push(`${at}: flow name must be lowercase letters, digits, . _ -`);
|
||||
if (typeof v !== 'object' || v === null || Array.isArray(v)) return { flow: null, errors: [...e, `${at}: a flow is a map (description, params, steps, ...)`] };
|
||||
const o = v as Record<string, unknown>;
|
||||
for (const k of Object.keys(o)) if (!FLOW_KEYS.includes(k)) e.push(`${at}: unknown key "${k}" (${FLOW_KEYS.join(', ')})`);
|
||||
const params: Record<string, string> = {};
|
||||
if (o.params !== undefined) {
|
||||
if (typeof o.params !== 'object' || o.params === null || Array.isArray(o.params)) e.push(`${at}.params: a map of NAME: default`);
|
||||
else for (const [k, val] of Object.entries(o.params)) {
|
||||
if (!VAR_RE.test(k)) e.push(`${at}.params.${k}: UPPER_CASE names`);
|
||||
params[k] = val === null || val === undefined ? '' : String(val);
|
||||
}
|
||||
}
|
||||
const flow: Flow = {
|
||||
name, file, ...(typeof o.description === 'string' ? { description: o.description } : {}), params,
|
||||
before: asSteps(o.before, `${at}.before`, e), steps: asSteps(o.steps, `${at}.steps`, e), after: asSteps(o.after, `${at}.after`, e),
|
||||
onError: asSteps(o.onError, `${at}.onError`, e), private: o.private === true,
|
||||
};
|
||||
if (!flow.steps.length) e.push(`${at}: no steps`);
|
||||
return { flow, errors: e };
|
||||
}
|
||||
|
||||
/** Flows of one file: a single-flow file (store/workflows/<name>.*) or a multi-flow file (storebound.workflows.*). */
|
||||
export function flowsOfFile(file: string, data: unknown, single: string | null): { flows: Flow[]; errors: string[] } {
|
||||
if (single) { const r = toFlow(single, file, data); return { flows: r.flow ? [r.flow] : [], errors: r.errors }; }
|
||||
if (typeof data !== 'object' || data === null || Array.isArray(data)) return { flows: [], errors: [`${file}: expected a map of flows`] };
|
||||
const d = data as Record<string, unknown>;
|
||||
const map = (d.flows && typeof d.flows === 'object' && !Array.isArray(d.flows) ? d.flows : d) as Record<string, unknown>;
|
||||
const flows: Flow[] = [], errors: string[] = [];
|
||||
for (const [n, v] of Object.entries(map)) { const r = toFlow(n, file, v); if (r.flow) flows.push(r.flow); errors.push(...r.errors); }
|
||||
return { flows, errors };
|
||||
}
|
||||
|
||||
/** Steps with `flow:` sub-flows expanded (ids prefixed), with cycle and unknown-flow errors. */
|
||||
export function expand(flow: Flow, all: Map<string, Flow>, part: 'before' | 'steps' | 'after' | 'onError' = 'steps', stack: string[] = []): { steps: FlowStep[]; errors: string[]; params: Record<string, string> } {
|
||||
const errors: string[] = [];
|
||||
const out: FlowStep[] = [];
|
||||
const params: Record<string, string> = {};
|
||||
for (const s of flow[part]) {
|
||||
if (s.flow === undefined) { out.push(s); continue; }
|
||||
const sub = all.get(s.flow);
|
||||
if (!sub) { errors.push(`${flow.name}: step ${s.id}: no flow "${s.flow}"`); continue; }
|
||||
if ([...stack, flow.name].includes(sub.name)) { errors.push(`${flow.name}: cycle ${[...stack, flow.name, sub.name].join(' -> ')}`); continue; }
|
||||
const r = expand(sub, all, 'steps', [...stack, flow.name]);
|
||||
errors.push(...r.errors);
|
||||
for (const [k, v] of Object.entries({ ...sub.params, ...r.params })) if (!(k in params)) params[k] = v;
|
||||
for (const x of r.steps) out.push({ ...x, id: `${s.id}.${x.id}`, ...(s.if && x.if ? { if: `${s.if} && ${x.if}` } : s.if ? { if: s.if } : {}) });
|
||||
}
|
||||
return { steps: out, errors, params };
|
||||
}
|
||||
|
||||
/** Everything wrong with a set of flows: duplicate names and ids, refused args, unknown commands and variables. */
|
||||
export function validateFlows(flows: Flow[], o: { commands?: Set<string> } = {}): string[] {
|
||||
const e: string[] = [];
|
||||
const all = new Map<string, Flow>();
|
||||
for (const f of flows) { if (all.has(f.name)) e.push(`flow "${f.name}" is defined in ${all.get(f.name)!.file} and ${f.file}`); else all.set(f.name, f); }
|
||||
for (const f of all.values()) {
|
||||
const vars = new Set(Object.keys(f.params));
|
||||
for (const part of ['before', 'steps', 'after', 'onError'] as const) {
|
||||
const r = expand(f, all, part);
|
||||
e.push(...r.errors);
|
||||
for (const k of Object.keys(r.params)) vars.add(k);
|
||||
const ids = new Set<string>();
|
||||
for (const s of r.steps) {
|
||||
const at = `${f.name}: ${part === 'steps' ? '' : `${part} `}step ${s.id}`;
|
||||
if (ids.has(s.id)) e.push(`${at}: id used twice`);
|
||||
ids.add(s.id);
|
||||
for (const t of [s.run, s.sh, s.owner, s.if].filter((x): x is string => typeof x === 'string'))
|
||||
for (const m of t.matchAll(/\$\{([^}]*)\}/g)) if (!vars.has(m[1]!) && !/^env\.[A-Z0-9_]+$/.test(m[1]!)) e.push(`${at}: \${${m[1]}} is not a param or an earlier capture`);
|
||||
if (s.capture) vars.add(s.capture);
|
||||
if (s.run !== undefined) {
|
||||
let argv: string[] = [];
|
||||
try { argv = splitArgs(s.run); } catch (x) { e.push(`${at}: ${(x as Error).message}`); continue; }
|
||||
if (!argv.length) { e.push(`${at}: empty run`); continue; }
|
||||
if (argv[0] === 'storebound') e.push(`${at}: write the command without "storebound" (run: ${argv.slice(1).join(' ')})`);
|
||||
if (argv[0] === 'flow') e.push(`${at}: use a "flow: <name>" step instead of run: flow ...`);
|
||||
const bad = argv.find(a => REFUSED_ARGS.includes(a.split('=')[0]!));
|
||||
if (bad) e.push(`${at}: ${bad} is not allowed in a flow (writes are confirmed by the owner, --apply is for flow run)`);
|
||||
if (o.commands) {
|
||||
const w = words(argv);
|
||||
const known = o.commands.has(`${w[0]} ${w[1]}`) || o.commands.has(`${w[0]} ${w[1]} ${w[2]}`) || o.commands.has(w[0] ?? '');
|
||||
if (!known && argv[0] !== 'storebound' && argv[0] !== 'flow') e.push(`${at}: "${w.slice(0, 2).join(' ')}" is not a storebound command`);
|
||||
}
|
||||
}
|
||||
if (s.if !== undefined && !/\S/.test(s.if)) e.push(`${at}: empty if`);
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
// ---- variables, conditions ----
|
||||
|
||||
/** ${VAR} and ${env.NAME} substituted; unknown ones stay as written (the plan shows them). */
|
||||
export function substitute(text: string, vars: Record<string, string>, env: Record<string, string | undefined> = {}): string {
|
||||
return text.replace(/\$\{([^}]*)\}/g, (m, k: string) => (k.startsWith('env.') ? env[k.slice(4)] ?? m : vars[k] ?? m));
|
||||
}
|
||||
|
||||
export interface CondCtx { apple: boolean; play: boolean; exists(path: string): boolean }
|
||||
|
||||
/** `if:` after substitution: apple | play | exists <path> | !x | a == b | a != b | x (non-empty, not false / 0); && joins. */
|
||||
export function evalIf(expr: string, c: CondCtx): boolean {
|
||||
return expr.split('&&').every(part => {
|
||||
const s = part.trim();
|
||||
if (s.startsWith('!')) return !evalIf(s.slice(1), c);
|
||||
if (s === 'apple') return c.apple;
|
||||
if (s === 'play') return c.play;
|
||||
const ex = /^exists\s+(.+)$/.exec(s);
|
||||
if (ex) return c.exists(ex[1]!.trim());
|
||||
const cmp = /^(.*?)\s*(==|!=)\s*(.*)$/.exec(s);
|
||||
if (cmp) { const eq = cmp[1]!.trim() === cmp[3]!.trim(); return cmp[2] === '==' ? eq : !eq; }
|
||||
return s !== '' && s !== 'false' && s !== '0' && !/^\$\{[^}]*\}$/.test(s);
|
||||
});
|
||||
}
|
||||
|
||||
/** `KEY=value` positionals of `flow run <name> KEY=value ...`. */
|
||||
export function parseParams(args: string[]): Record<string, string> {
|
||||
const out: Record<string, string> = {};
|
||||
for (const a of args) {
|
||||
const i = a.indexOf('=');
|
||||
if (i < 1 || !VAR_RE.test(a.slice(0, i))) throw new Error(`"${a}": parameters are NAME=value (UPPER_CASE name)`);
|
||||
out[a.slice(0, i)] = a.slice(i + 1);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// ---- the plan ----
|
||||
|
||||
export type Mode = 'plan' | 'dry' | 'apply';
|
||||
|
||||
export interface PlannedStep {
|
||||
id: string;
|
||||
part: 'before' | 'steps' | 'after' | 'onError';
|
||||
kind: StepKind;
|
||||
/** What runs: storebound argv (run steps), the shell line (sh), the owner's click text (owner). */
|
||||
argv?: string[];
|
||||
shell?: string;
|
||||
owner?: string;
|
||||
/** Not run in this mode, and why. */
|
||||
skip?: string;
|
||||
/** --dry was added (write steps without --apply, wait steps without --apply). */
|
||||
dryAdded: boolean;
|
||||
capture?: string;
|
||||
continueOnError: boolean;
|
||||
note?: string;
|
||||
}
|
||||
|
||||
/** How one step runs in a mode, with the variables known so far. Pure. */
|
||||
export function planStep(s: FlowStep, part: PlannedStep['part'], mode: Mode, vars: Record<string, string>, c: CondCtx, env: Record<string, string | undefined> = {}): PlannedStep {
|
||||
const base = { id: s.id, part, continueOnError: !!s.continueOnError, ...(s.capture ? { capture: s.capture } : {}), ...(s.note ? { note: s.note } : {}) };
|
||||
if (s.if !== undefined && !evalIf(substitute(s.if, vars, env), c)) {
|
||||
const what = s.owner !== undefined ? { owner: substitute(s.owner, vars, env) } : s.sh !== undefined ? { shell: substitute(s.sh, vars, env) } : { argv: splitArgs(substitute(s.run ?? '', vars, env)) };
|
||||
return { ...base, ...what, kind: kindOf(s), dryAdded: false, skip: `if ${s.if}: false` };
|
||||
}
|
||||
if (s.owner !== undefined) return { ...base, kind: 'owner', owner: substitute(s.owner, vars, env), dryAdded: false, skip: 'your click' };
|
||||
if (s.sh !== undefined) {
|
||||
const shell = substitute(s.sh, vars, env);
|
||||
return { ...base, kind: 'shell', shell, dryAdded: false, ...(mode === 'apply' ? {} : { skip: 'shell step: runs with --apply' }) };
|
||||
}
|
||||
const argv = splitArgs(substitute(s.run ?? '', vars, env));
|
||||
const kind = classify(argv);
|
||||
if (kind === 'owner') return { ...base, kind, owner: `storebound ${argv.join(' ')}`, dryAdded: false, skip: 'your click (owner step: run it yourself after checking)' };
|
||||
const addDry = (kind === 'write' || kind === 'wait') && mode !== 'apply' && !argv.includes('--dry');
|
||||
return { ...base, kind, argv: addDry ? [...argv, '--dry'] : argv, dryAdded: addDry, ...(mode === 'plan' ? { skip: 'plan only' } : {}) };
|
||||
}
|
||||
|
||||
/** Index of the step to start from: --from <id> (exact, or the first id under a sub-flow prefix). */
|
||||
export function startIndex(steps: FlowStep[], from: string | undefined): number {
|
||||
if (!from) return 0;
|
||||
const i = steps.findIndex(s => s.id === from || s.id.startsWith(`${from}.`));
|
||||
if (i < 0) throw new Error(`--from ${from}: no such step (${steps.map(s => s.id).join(', ')})`);
|
||||
return i;
|
||||
}
|
||||
|
||||
export interface StepResult { id: string; part: PlannedStep['part']; kind: StepKind; status: 'ok' | 'failed' | 'skipped' | 'owner' | 'planned'; exitCode?: number; ms?: number; detail?: string; command?: string }
|
||||
export interface RunState { flow: string; mode: Mode; startedAt: string; finishedAt?: string; vars: Record<string, string>; results: StepResult[]; ok: boolean }
|
||||
|
||||
/** First step of the last run that did not finish (failed, or never reached): where `--resume` starts. */
|
||||
export function resumePoint(steps: FlowStep[], last: RunState | null): string | undefined {
|
||||
if (!last) return undefined;
|
||||
const done = new Set(last.results.filter(r => r.part === 'steps' && (r.status === 'ok' || r.status === 'skipped' || r.status === 'owner')).map(r => r.id));
|
||||
return steps.find(s => !done.has(s.id))?.id;
|
||||
}
|
||||
158
cli/lib/listing-translate.ts
Normal file
158
cli/lib/listing-translate.ts
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
// Listing localization: per-language sections of the two listing files (store/appstore.md, store/listing.md) as
|
||||
// translation drafts. Pure. The CLI never calls a translation service: your agent translates the status=translate
|
||||
// sections (listing-localization skill), or `storebound listing translate --translate "<command>"` runs a command of
|
||||
// yours once per field. Every generated section carries a marker line until a human reviewed it:
|
||||
// <!-- storebound-translation from=en-US status=translate --> source text copied in, still to translate
|
||||
// <!-- storebound-translation from=en-US status=draft --> machine-translated: review, then `listing reviewed`
|
||||
// Limits per store field (characters; App Store keywords also 100 bytes, as the existing listing check counts them):
|
||||
// App Store (appStoreVersionLocalizations / appInfoLocalizations): name 30, subtitle 30, promotionalText 170,
|
||||
// keywords 100, description 4000. https://developer.apple.com/help/app-store-connect/reference/app-information
|
||||
// Google Play (edits.listings): title 30, shortDescription 80, fullDescription 4000.
|
||||
// https://support.google.com/googleplay/android-developer/answer/9859152
|
||||
// Keyword rules (App Store): comma separated, no spaces around commas, no duplicates, no words already in the name or
|
||||
// subtitle (they are indexed anyway), whole keywords cut at the limit.
|
||||
import { APPLE_LIMITS, len, PLAY_LIMITS } from './copy';
|
||||
|
||||
export type TStatus = 'translate' | 'draft';
|
||||
export const MARK_RE = /^<!--\s*storebound-translation\s+from=(\S+)\s+status=(translate|draft)\s*-->\s*$/m;
|
||||
export const mark = (from: string, status: TStatus): string => `<!-- storebound-translation from=${from} status=${status} -->`;
|
||||
|
||||
export const APPLE_FIELDS = ['name', 'subtitle', 'promotionalText', 'keywords', 'description'] as const;
|
||||
export type AppleTField = typeof APPLE_FIELDS[number];
|
||||
export const PLAY_FIELDS = ['title', 'short', 'full'] as const;
|
||||
export type PlayTField = typeof PLAY_FIELDS[number];
|
||||
export const FIELD_LIMITS = {
|
||||
apple: Object.fromEntries(APPLE_FIELDS.map(f => [f, APPLE_LIMITS[f]])) as Record<AppleTField, number>,
|
||||
play: { title: PLAY_LIMITS.title, short: PLAY_LIMITS.short, full: PLAY_LIMITS.full } as Record<PlayTField, number>,
|
||||
};
|
||||
|
||||
const fence = (t: string) => '```\n' + t + '\n```';
|
||||
|
||||
/** "## " sections of a listing file (index 0 = the preamble). */
|
||||
export const sections = (md: string): string[] => md.split(/^(?=## )/m);
|
||||
|
||||
/** "### heading" -> first fenced block text, in order. */
|
||||
export function blocksOf(sec: string): { heading: string; text: string }[] {
|
||||
const out: { heading: string; text: string }[] = [];
|
||||
for (const part of sec.split(/^### /m).slice(1)) {
|
||||
const heading = part.split('\n')[0]!.trim();
|
||||
const m = /^```[^\n]*\n([\s\S]*?)\n```/m.exec(part);
|
||||
if (m) out.push({ heading, text: m[1]!.trim() });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export const appleLocaleOf = (sec: string): string | null => {
|
||||
if (!sec.startsWith('## ')) return null;
|
||||
const l = sec.slice(3).split(/[\s·]/)[0]!.trim();
|
||||
return /^[a-z]{2,3}(-[A-Za-z]{2,4})?$/.test(l) ? l : null;
|
||||
};
|
||||
export const playCodesOf = (sec: string): string[] => {
|
||||
const m = /^<!--\s*play:\s*([^>]+?)\s*-->$/m.exec(sec);
|
||||
return m ? m[1]!.split(',').map(s => s.trim()).filter(Boolean) : [];
|
||||
};
|
||||
export function markerOf(sec: string): { from: string; status: TStatus } | null {
|
||||
const m = MARK_RE.exec(sec);
|
||||
return m ? { from: m[1]!, status: m[2] as TStatus } : null;
|
||||
}
|
||||
|
||||
export function appleFields(sec: string): Partial<Record<AppleTField | 'whatsNew', string>> {
|
||||
const out: Partial<Record<AppleTField | 'whatsNew', string>> = {};
|
||||
for (const b of blocksOf(sec)) if ((APPLE_FIELDS as readonly string[]).includes(b.heading) || b.heading === 'whatsNew') out[b.heading as AppleTField] = b.text;
|
||||
return out;
|
||||
}
|
||||
|
||||
export function playFields(sec: string): Partial<Record<PlayTField | 'whatsNew', string>> {
|
||||
const out: Partial<Record<PlayTField | 'whatsNew', string>> = {};
|
||||
for (const b of blocksOf(sec)) {
|
||||
const k = /what'?s new|release notes/i.test(b.heading) ? 'whatsNew' : /\btitle\b/i.test(b.heading) ? 'title' : /\bshort\b/i.test(b.heading) ? 'short' : /\bfull\b/i.test(b.heading) ? 'full' : null;
|
||||
if (k && out[k] === undefined) out[k] = b.text;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export const findAppleSection = (md: string, locale: string): string | undefined => sections(md).find(s => appleLocaleOf(s) === locale);
|
||||
export const findPlaySection = (md: string, codes: string[]): string | undefined => sections(md).find(s => playCodesOf(s).some(c => codes.includes(c)));
|
||||
|
||||
export function appleSectionText(locale: string, label: string, f: Partial<Record<AppleTField | 'whatsNew', string>>, marker: string | null): string {
|
||||
const parts = [`## ${locale}${label ? ` · ${label}` : ''}`, ...(marker ? [marker] : []), ''];
|
||||
for (const k of [...APPLE_FIELDS, 'whatsNew'] as const) if (f[k] !== undefined && f[k] !== '') parts.push(`### ${k}`, fence(f[k]!), '');
|
||||
return parts.join('\n') + '\n';
|
||||
}
|
||||
|
||||
const PLAY_HEAD: Record<PlayTField | 'whatsNew', string> = { title: 'Play title (max 30)', short: 'Play short description (max 80)', full: 'Play full description (max 4000)', whatsNew: 'What\'s new (max 500)' };
|
||||
export function playSectionText(codes: string[], label: string, f: Partial<Record<PlayTField | 'whatsNew', string>>, marker: string | null): string {
|
||||
const parts = [`## ${label || codes[0]} (${codes.join(', ')})`, `<!-- play: ${codes.join(', ')} -->`, ...(marker ? [marker] : []), ''];
|
||||
for (const k of [...PLAY_FIELDS, 'whatsNew'] as const) if (f[k] !== undefined && f[k] !== '') parts.push(`### ${PLAY_HEAD[k]}`, fence(f[k]!), '');
|
||||
return parts.join('\n') + '\n';
|
||||
}
|
||||
|
||||
/** Replaces the section `old` (exact text) with `text`, or appends `text` at the end. */
|
||||
export function putSection(md: string, old: string | undefined, text: string): string {
|
||||
if (old !== undefined) {
|
||||
const parts = sections(md);
|
||||
const i = parts.indexOf(old);
|
||||
// keep what ended the old section (blank lines, a --- rule)
|
||||
let body = old.replace(/\s+$/, '');
|
||||
while (/\n---$/.test(body)) body = body.slice(0, -4).replace(/\s+$/, '');
|
||||
const tail = old.slice(body.length);
|
||||
parts[i] = text.replace(/\s+$/, '') + (tail || '\n');
|
||||
return parts.join('');
|
||||
}
|
||||
return md.replace(/\s*$/, '') + '\n\n' + text;
|
||||
}
|
||||
|
||||
/** Removes the translation marker of one section (after review). */
|
||||
export const unmark = (sec: string): string => sec.replace(/^<!--\s*storebound-translation[^>]*-->[ \t]*\n/m, '');
|
||||
|
||||
// ---- keyword rules ----
|
||||
|
||||
/** App Store keywords: split on commas (also 、,،), trimmed, deduplicated (case-insensitive), words of the name /
|
||||
* subtitle dropped, joined with "," and cut at whole keywords to fit 100 characters and 100 bytes. Pure. */
|
||||
export function normalizeKeywords(text: string, o: { name?: string; subtitle?: string; limit?: number } = {}): { text: string; dropped: { kw: string; why: string }[] } {
|
||||
const limit = o.limit ?? APPLE_LIMITS.keywords;
|
||||
const taken = new Set(`${o.name ?? ''} ${o.subtitle ?? ''}`.toLocaleLowerCase().split(/[\s,.:;!?·|/–-]+/).filter(w => w.length > 1));
|
||||
const seen = new Set<string>();
|
||||
const dropped: { kw: string; why: string }[] = [];
|
||||
const kept: string[] = [];
|
||||
for (const raw of text.split(/[,、,،;\n]/)) {
|
||||
const kw = raw.trim().replace(/\s+/g, ' ');
|
||||
if (!kw) continue;
|
||||
const key = kw.toLocaleLowerCase();
|
||||
if (seen.has(key)) { dropped.push({ kw, why: 'duplicate' }); continue; }
|
||||
seen.add(key);
|
||||
if (taken.has(key)) { dropped.push({ kw, why: 'already in the name or subtitle' }); continue; }
|
||||
const next = [...kept, kw].join(',');
|
||||
if (len(next) > limit || Buffer.byteLength(next) > limit) { dropped.push({ kw, why: `over ${limit}` }); continue; }
|
||||
kept.push(kw);
|
||||
}
|
||||
return { text: kept.join(','), dropped };
|
||||
}
|
||||
|
||||
export interface FieldCheck { store: 'apple' | 'play'; field: string; chars: number; limit: number; problems: string[] }
|
||||
|
||||
/** Limits and rules of one translated section. `source` = the source language's fields (identical text is flagged). */
|
||||
export function checkFields(store: 'apple' | 'play', f: Record<string, string | undefined>, source: Record<string, string | undefined> = {}, status?: TStatus): FieldCheck[] {
|
||||
const fields = store === 'apple' ? APPLE_FIELDS : PLAY_FIELDS;
|
||||
const out: FieldCheck[] = [];
|
||||
for (const k of fields) {
|
||||
const v = f[k];
|
||||
if (v === undefined) continue;
|
||||
const limit = (FIELD_LIMITS[store] as Record<string, number>)[k]!;
|
||||
const c: FieldCheck = { store, field: k, chars: len(v), limit, problems: [] };
|
||||
if (len(v) > limit) c.problems.push(`${len(v)} > ${limit} characters`);
|
||||
if (store === 'apple' && k === 'keywords') {
|
||||
if (Buffer.byteLength(v) > limit) c.problems.push(`${Buffer.byteLength(v)} bytes > ${limit}`);
|
||||
if (/,\s|\s,/.test(v)) c.problems.push('spaces around commas');
|
||||
const words = v.split(',').map(w => w.trim().toLocaleLowerCase()).filter(Boolean);
|
||||
const dup = words.filter((w, i) => words.indexOf(w) !== i);
|
||||
if (dup.length) c.problems.push(`duplicates: ${[...new Set(dup)].join(', ')}`);
|
||||
if (/,,|^,|,$/.test(v)) c.problems.push('empty keyword');
|
||||
}
|
||||
if (!v.trim() && k !== 'title' && k !== 'name') c.problems.push('empty');
|
||||
if (status === 'translate') c.problems.push('not translated yet (status=translate)');
|
||||
else if (source[k] !== undefined && v.trim() === source[k]!.trim() && v.trim().length > 12) c.problems.push('identical to the source language');
|
||||
out.push(c);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@ import { CONFIG_NAMES, loadConfig, type ShipConfig } from '../config';
|
|||
import { reviewDemoAccount } from '../credentials';
|
||||
import { proposeDeclarations, type Proposal } from './declare';
|
||||
import { detectProject, ECO_LABEL, type ProjectFacts, type Stack, where } from './project';
|
||||
import { type ScanFinding, scanRules, type Severity } from './rules';
|
||||
import type { OriginalityReport } from '../originality';
|
||||
import { APPLE_GUIDELINES, type ScanFinding, scanRules, type Severity, sortScan } from './rules';
|
||||
import type { SdkCategory } from './sdks';
|
||||
|
||||
export interface ScanReport {
|
||||
|
|
@ -23,6 +24,8 @@ export interface ScanReport {
|
|||
declarations: Proposal;
|
||||
scanned: number;
|
||||
notes: string[];
|
||||
/** `scan --originality`: the 4.3 / repetitive content comparison with the owner's other apps. */
|
||||
originality?: { compared: number; flagged: number; threshold: number; pairs: { app: string; folder: string; overall: number; flagged: boolean }[] } | { error: string };
|
||||
}
|
||||
|
||||
export interface ScanRun { report: ScanReport; facts: ProjectFacts; config: ShipConfig | null; configPath: string | null }
|
||||
|
|
@ -122,7 +125,34 @@ export function formatScan(r: ScanReport, o: { declarations?: boolean } = {}): s
|
|||
if (d.appPrivacyChange) L.push(` ~ appPrivacy.tracking: ${d.appPrivacyChange.from ?? 'unset'} -> ${d.appPrivacyChange.to}`);
|
||||
} else if (r.config) L.push('', ` No changes to ${r.config}: the dataSafety / appPrivacy blocks already cover what was detected.`);
|
||||
}
|
||||
if (r.originality) {
|
||||
if ('error' in r.originality) L.push('', `Originality (4.3): not run: ${r.originality.error}`);
|
||||
else L.push('', `Originality (4.3 / Play repetitive content): ${r.originality.compared} app(s) compared, ${r.originality.flagged} near-duplicate(s) at ${r.originality.threshold}${r.originality.pairs.length ? ` · ${r.originality.pairs.map(p => `${p.app} ${Math.round(p.overall * 100)}%`).join(', ')}` : ''}`);
|
||||
}
|
||||
if (r.notes.length) L.push('', ...r.notes.map(n => `note: ${n}`));
|
||||
L.push('', 'Checked at review, not by scan: crashes and bugs on the reviewer\'s device, broken links (storebound validate checks the URLs), screenshots that do not match the app, minimum functionality and spam judgement (4.2, 4.3), local law (5.2). See the review-rejections skill.');
|
||||
L.push('', 'Checked at review, not by scan: crashes and bugs on the reviewer\'s device, broken links (storebound validate checks the URLs), screenshots that do not match the app, minimum functionality and spam judgement (4.2, 4.3: scan --originality compares your own apps), local law (5.2). See the review-rejections skill.');
|
||||
return L.join('\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* `scan --originality`: the near-duplicates of an originality report as scan findings (App Store 4.3 spam, Google
|
||||
* Play repetitive content), owner-accepted through `scan.ignore` like every rule (rule id "originality"). Pure.
|
||||
*/
|
||||
export function addOriginality(r: ScanReport, o: OriginalityReport, stores: { apple: boolean; play: boolean }, config: ShipConfig | null, rel: (p: string) => string): void {
|
||||
const ignore = config?.scan?.ignore ?? [];
|
||||
for (const p of o.pairs.filter(x => x.flagged)) {
|
||||
const evidence = [{ file: rel(p.other.dir) || '.', line: 1, text: `${p.other.name}: ${Math.round(p.overall * 100)}% overall (${p.reasons.slice(0, 2).join('; ')})` }];
|
||||
const fix = `${p.suggestions.slice(0, 2).join(' ') || 'Make the app different in mechanic, content and listing.'} Run storebound originality --against ${rel(p.other.dir) || '.'} for every axis; the portfolio-originality skill has the checklist.`;
|
||||
const base = { rule: 'originality', severity: 'high' as const, title: `Near-duplicate of your app ${p.other.name} (${Math.round(p.overall * 100)}% similar)`, evidence, fix, skill: 'portfolio-originality' };
|
||||
if (stores.apple) r.findings.push({ ...base, guideline: '4.3', store: 'apple', ref: APPLE_GUIDELINES });
|
||||
if (stores.play) r.findings.push({ ...base, guideline: 'Play: Repetitive content', store: 'play', ref: 'https://support.google.com/googleplay/android-developer/answer/9898783' });
|
||||
}
|
||||
for (const f of r.findings) if (f.rule === 'originality' && !f.accepted) {
|
||||
const hit = ignore.find(i => i.rule === f.rule && (!i.store || i.store === f.store));
|
||||
if (hit) f.accepted = hit.reason;
|
||||
}
|
||||
r.findings = sortScan(r.findings);
|
||||
r.counts = { blocker: 0, high: 0, medium: 0, low: 0, accepted: 0 };
|
||||
for (const f of r.findings) { if (f.accepted) r.counts.accepted++; else r.counts[f.severity]++; }
|
||||
r.originality = { compared: o.pairs.length, flagged: o.flagged, threshold: o.threshold, pairs: o.pairs.map(p => ({ app: p.other.name, folder: rel(p.other.dir) || '.', overall: Math.round(p.overall * 1000) / 1000, flagged: p.flagged })) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
//
|
||||
// Sources, checked 2026-10-11:
|
||||
// - Apple App Review Guidelines: https://developer.apple.com/app-store/review/guidelines/
|
||||
// 2.1(a) app completeness (demo account, placeholder text), 2.3.7 metadata (names, keywords, no prices or other
|
||||
// 2.1(a) app completeness (demo account, placeholder text), 2.2 betas, demos and trial versions (TestFlight), 2.3.7 metadata (names, keywords, no prices or other
|
||||
// apps' names), 2.3.8 ("For Kids" is reserved for the Kids Category), 2.3.10 other mobile platforms, 2.5.1 public
|
||||
// APIs, 2.5.5 IPv6-only networks, 3.1.1 restore mechanism, 3.1.2(c) subscription information (+ Schedule 2 of the
|
||||
// Developer Program License Agreement: Terms of Use and privacy policy links), 4.2 minimum functionality
|
||||
|
|
@ -324,6 +324,19 @@ export function scanRules(inp: ScanInput): ScanFinding[] {
|
|||
const stuffed = listingHits(inp.listings.apple, /^([^,|]{1,24}[,|]){5,}/, { field: /^(name|subtitle)$/ });
|
||||
if (stuffed.length)
|
||||
add({ rule: 'metadata-keywords', guideline: '2.3.7', store: 'apple', severity: 'medium', title: 'Keyword list in the name or subtitle', evidence: stuffed.slice(0, 2), fix: 'Name and subtitle are a short phrase; keywords belong in the keywords field.', skill: 'aso-basics' });
|
||||
// 2.2: demos, betas and trial versions belong on TestFlight, not on the App Store (the name and the listing say so)
|
||||
const BETA = /\b(beta|demo|trial version|test (version|build|app)|testing build|early access|prototype|preview (build|version)|alpha (build|version))\b/i;
|
||||
const betaName: Hit[] = [];
|
||||
if (c?.app?.name && BETA.test(c.app.name)) betaName.push(...cfg(c.app.name, `app.name: ${c.app.name}`));
|
||||
for (const k of ['CFBundleDisplayName', 'CFBundleName']) {
|
||||
const v = plistVal(k);
|
||||
if (typeof v?.value === 'string' && BETA.test(v.value) && !/\$\(/.test(v.value)) betaName.push({ ...v.at, text: `${k}: ${v.value}` });
|
||||
}
|
||||
const betaText = listingHits(inp.listings.apple, BETA, { field: /^(name|subtitle|promotionalText|keywords|description)$/ })
|
||||
.filter(h => !/\bdemo account\b|\bdemo (video|mode)\b/i.test(h.text));
|
||||
if (betaName.length || betaText.length)
|
||||
add({ rule: 'beta-wording', guideline: '2.2', store: 'apple', severity: betaName.length ? 'high' : 'medium', title: '"Beta", "demo", "trial" or "test" wording in the app name or App Store text', evidence: [...betaName, ...betaText].slice(0, 4),
|
||||
fix: 'Apple 2.2: demos, betas and trial versions do not belong on the App Store (use TestFlight). Remove the word from the name, subtitle, keywords and description; a free tier or a trial of a subscription is fine when it is described as such ("free trial of Pro").', skill: 'review-rejections' });
|
||||
const kids = [...listingHits(inp.listings.apple, /\bfor (kids|children|toddlers)\b/i), ...listingHits(inp.listings.captions, /\bfor (kids|children|toddlers)\b/i, { fenced: false })];
|
||||
const kidsBand = c?.apple?.info?.ageRating?.kidsAgeBand;
|
||||
if (kids.length && !kidsBand)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
import type { IntroOffer, Language, OfferCodeDef, PriceOverride, Subscription, SubscriptionGroup, SubscriptionOfferDef, SubscriptionPeriod } from './config';
|
||||
import { playCodes } from './config';
|
||||
import { ALPHA3, fromMoney, type Money, toMoney } from './money';
|
||||
import type { PriceRow } from './prices';
|
||||
import { alpha2, type PriceRow } from './prices';
|
||||
|
||||
// ---- mappings ----
|
||||
|
||||
|
|
@ -505,3 +505,16 @@ export function pickPoint(points: ApplePoint[], territory: string, price: number
|
|||
const near = [...inT].sort((a, b) => Math.abs(a.price - price) - Math.abs(b.price - price)).slice(0, 3).map(p => p.price);
|
||||
throw new Error(`${territory} has no subscription price point ${price}${near.length ? ` (nearest ${near.join(', ')})` : ''}`);
|
||||
}
|
||||
|
||||
// ---- the prices sheet (storebound prices export) ----
|
||||
|
||||
/** App Store prices of one subscription (in effect today + scheduled) as price sheet rows. Pure. */
|
||||
export function appleSubPriceRows(product: string, resp: JsonApi, today?: string): PriceRow[] {
|
||||
return appleSubPrices(resp, today).map(p => ({ product, store: 'apple' as const, region: alpha2(p.territory), territory: p.territory, currency: p.currency ?? '', price: p.price, ...(p.startDate ? { startDate: p.startDate } : {}) }));
|
||||
}
|
||||
|
||||
/** Google Play regional prices of one subscription's base plan as price sheet rows. Pure. */
|
||||
export function playSubPriceRows(sub: PlaySubscription, basePlan: string): PriceRow[] {
|
||||
const bp = sub.basePlans?.find(b => b.basePlanId === basePlan) ?? sub.basePlans?.[0];
|
||||
return (bp?.regionalConfigs ?? []).filter(r => r.price).map(r => ({ product: sub.productId, store: 'play' as const, region: r.regionCode, currency: r.price!.currencyCode, price: fromMoney(r.price!) }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ import t21 from '../../templates/testers.csv' with { type: 'text' };
|
|||
import tWebAppstore from '../../templates/web/appstore.svg' with { type: 'text' };
|
||||
import tWebGoogleplay from '../../templates/web/googleplay.svg' with { type: 'text' };
|
||||
import tWebLanding from '../../templates/web/landing.html' with { type: 'text' };
|
||||
import tWfAppRelease from '../../templates/profiles/app/workflows/release.yml' with { type: 'text' };
|
||||
import tWfAppBeta from '../../templates/profiles/app/workflows/beta.yml' with { type: 'text' };
|
||||
import tWfRelease from '../../templates/workflows/release.yml' with { type: 'text' };
|
||||
import tWfBeta from '../../templates/workflows/beta.yml' with { type: 'text' };
|
||||
|
||||
/** Template text by its path under templates/ (forward slashes). */
|
||||
export const TEMPLATE_TEXT: Record<string, string> = {
|
||||
|
|
@ -54,4 +58,8 @@ export const TEMPLATE_TEXT: Record<string, string> = {
|
|||
'web/appstore.svg': tWebAppstore as unknown as string,
|
||||
'web/googleplay.svg': tWebGoogleplay as unknown as string,
|
||||
'web/landing.html': tWebLanding as unknown as string,
|
||||
'profiles/app/workflows/release.yml': tWfAppRelease as unknown as string,
|
||||
'profiles/app/workflows/beta.yml': tWfAppBeta as unknown as string,
|
||||
'workflows/release.yml': tWfRelease as unknown as string,
|
||||
'workflows/beta.yml': tWfBeta as unknown as string,
|
||||
};
|
||||
|
|
|
|||
171
cli/lib/yaml.ts
Normal file
171
cli/lib/yaml.ts
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
// A small YAML subset reader for repo-local files (store/workflows/*.yml), so storebound stays at zero runtime
|
||||
// dependencies. Pure. Supported: block maps (`key: value`), block lists (`- item`, `- key: value` with the rest of the
|
||||
// map indented below), nested by indentation (spaces only), plain / 'single' / "double" quoted scalars, inline lists
|
||||
// `[a, b]`, `#` comments, `|` and `>` block scalars, true / false / null / numbers. Not supported (an error names the
|
||||
// line): anchors, aliases, tags, multi-document files, inline maps `{...}`, tabs for indentation.
|
||||
|
||||
export type YamlValue = string | number | boolean | null | YamlValue[] | { [k: string]: YamlValue };
|
||||
|
||||
interface Line { n: number; indent: number; text: string }
|
||||
|
||||
function stripComment(s: string): string {
|
||||
let q: string | null = null;
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
const c = s[i]!;
|
||||
if (q) { if (c === q && !(q === '"' && s[i - 1] === '\\')) q = null; continue; }
|
||||
if (c === '"' || c === '\'') { if (i === 0 || /[\s:[,-]/.test(s[i - 1]!)) q = c; continue; }
|
||||
if (c === '#' && (i === 0 || /\s/.test(s[i - 1]!))) return s.slice(0, i).trimEnd();
|
||||
}
|
||||
return s.trimEnd();
|
||||
}
|
||||
|
||||
function scalar(raw: string, n: number): YamlValue {
|
||||
const s = raw.trim();
|
||||
if (s === '' || s === '~' || s === 'null') return s === '' ? '' : null;
|
||||
if (s.startsWith('"')) {
|
||||
if (!s.endsWith('"') || s.length < 2) throw new Error(`line ${n}: unterminated "string"`);
|
||||
try { return JSON.parse(s) as string; } catch { throw new Error(`line ${n}: bad "string"`); }
|
||||
}
|
||||
if (s.startsWith('\'')) {
|
||||
if (!s.endsWith('\'') || s.length < 2) throw new Error(`line ${n}: unterminated 'string'`);
|
||||
return s.slice(1, -1).replace(/''/g, '\'');
|
||||
}
|
||||
if (s.startsWith('[')) {
|
||||
if (!s.endsWith(']')) throw new Error(`line ${n}: unterminated [list]`);
|
||||
const inner = s.slice(1, -1).trim();
|
||||
if (!inner) return [];
|
||||
const parts: string[] = [];
|
||||
let q: string | null = null, cur = '';
|
||||
for (const c of inner) {
|
||||
if (q) { cur += c; if (c === q) q = null; continue; }
|
||||
if (c === '"' || c === '\'') { q = c; cur += c; continue; }
|
||||
if (c === ',') { parts.push(cur); cur = ''; continue; }
|
||||
cur += c;
|
||||
}
|
||||
parts.push(cur);
|
||||
return parts.map(p => scalar(p, n));
|
||||
}
|
||||
if (s.startsWith('{')) throw new Error(`line ${n}: inline maps {...} are not supported; use one key per line`);
|
||||
if (/^[&*!]/.test(s)) throw new Error(`line ${n}: anchors, aliases and tags are not supported`);
|
||||
if (s === 'true') return true;
|
||||
if (s === 'false') return false;
|
||||
if (/^-?\d+(\.\d+)?$/.test(s) && !/^0\d/.test(s)) return Number(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Index of the `:` that separates a map key from its value (outside quotes), or -1. */
|
||||
function keyColon(s: string): number {
|
||||
let q: string | null = null;
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
const c = s[i]!;
|
||||
if (q) { if (c === q) q = null; continue; }
|
||||
if ((c === '"' || c === '\'') && i === 0) { q = c; continue; }
|
||||
if (c === ':' && (i === s.length - 1 || s[i + 1] === ' ')) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function parseYaml(text: string): YamlValue {
|
||||
const lines: Line[] = [];
|
||||
const raw = text.replace(/\r\n?/g, '\n').split('\n');
|
||||
for (let i = 0; i < raw.length; i++) {
|
||||
const l = raw[i]!;
|
||||
if (/^\t/.test(l) || /^ *\t/.test(l)) throw new Error(`line ${i + 1}: tabs are not allowed for indentation`);
|
||||
if (/^(---|\.\.\.)\s*$/.test(l)) { if (lines.length) throw new Error(`line ${i + 1}: one document per file`); continue; }
|
||||
lines.push({ n: i + 1, indent: l.length - l.trimStart().length, text: l.trim() });
|
||||
}
|
||||
let pos = 0;
|
||||
const content = (l: Line) => l.text !== '' && !l.text.startsWith('#');
|
||||
const skip = () => { while (pos < lines.length && !content(lines[pos]!)) pos++; };
|
||||
|
||||
/** Block scalar (| or >) below a key at `parentIndent`. */
|
||||
function block(style: string, parentIndent: number): string {
|
||||
const out: string[] = [];
|
||||
let ind = -1;
|
||||
while (pos < lines.length) {
|
||||
const l = lines[pos]!;
|
||||
const rawLine = raw[l.n - 1]!;
|
||||
if (l.text === '') { out.push(''); pos++; continue; }
|
||||
if (l.indent <= parentIndent) break;
|
||||
if (ind < 0) ind = l.indent;
|
||||
out.push(rawLine.slice(Math.min(ind, l.indent)));
|
||||
pos++;
|
||||
}
|
||||
while (out.length && out[out.length - 1] === '') out.pop();
|
||||
const keep = style.endsWith('-') ? '' : '\n';
|
||||
return (style.startsWith('>') ? out.join('\n').replace(/([^\n])\n(?=[^\n])/g, '$1 ') : out.join('\n')) + (out.length ? keep : '');
|
||||
}
|
||||
|
||||
function value(indent: number): YamlValue {
|
||||
skip();
|
||||
if (pos >= lines.length) return null;
|
||||
const first = lines[pos]!;
|
||||
if (first.indent < indent) return null;
|
||||
return first.text.startsWith('- ') || first.text === '-' ? list(first.indent) : map(first.indent);
|
||||
}
|
||||
|
||||
function entry(rest: string, n: number, ownIndent: number): [string, YamlValue] {
|
||||
const c = keyColon(rest);
|
||||
if (c < 0) throw new Error(`line ${n}: expected "key: value"`);
|
||||
const key = String(scalar(rest.slice(0, c), n));
|
||||
const v = stripComment(rest.slice(c + 1)).trim();
|
||||
if (v === '') {
|
||||
skip();
|
||||
const next = lines[pos];
|
||||
// a list may sit at the key's own indentation ("steps:\n- id: a")
|
||||
if (next && next.indent === ownIndent && (next.text.startsWith('- ') || next.text === '-')) return [key, list(ownIndent)];
|
||||
return [key, value(ownIndent + 1) ?? null];
|
||||
}
|
||||
if (/^[|>][+-]?$/.test(v)) return [key, block(v, ownIndent)];
|
||||
return [key, scalar(v, n)];
|
||||
}
|
||||
|
||||
function map(indent: number): { [k: string]: YamlValue } {
|
||||
const out: { [k: string]: YamlValue } = {};
|
||||
for (;;) {
|
||||
skip();
|
||||
if (pos >= lines.length) break;
|
||||
const l = lines[pos]!;
|
||||
if (l.indent < indent) break;
|
||||
if (l.indent > indent) throw new Error(`line ${l.n}: unexpected indentation`);
|
||||
if (l.text.startsWith('- ')) throw new Error(`line ${l.n}: a list item where a "key: value" was expected`);
|
||||
pos++;
|
||||
const [k, v] = entry(stripComment(l.text), l.n, indent);
|
||||
if (k in out) throw new Error(`line ${l.n}: "${k}" twice`);
|
||||
out[k] = v;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function list(indent: number): YamlValue[] {
|
||||
const out: YamlValue[] = [];
|
||||
for (;;) {
|
||||
skip();
|
||||
if (pos >= lines.length) break;
|
||||
const l = lines[pos]!;
|
||||
if (l.indent < indent) break;
|
||||
if (l.indent > indent) throw new Error(`line ${l.n}: expected a list item "- ..."`);
|
||||
if (!(l.text.startsWith('- ') || l.text === '-')) break;
|
||||
pos++;
|
||||
const rest = stripComment(l.text.slice(1)).trim();
|
||||
if (rest === '') { out.push(value(indent + 1)); continue; }
|
||||
const itemIndent = indent + (l.text.length - l.text.slice(1).trimStart().length);
|
||||
if (keyColon(rest) >= 0 && !/^["'[]/.test(rest)) {
|
||||
// "- key: value" starts a map whose other keys are indented to the item's text column
|
||||
const [k, v] = entry(rest, l.n, itemIndent);
|
||||
const m: { [k: string]: YamlValue } = { [k]: v };
|
||||
skip();
|
||||
if (pos < lines.length && lines[pos]!.indent === itemIndent && !lines[pos]!.text.startsWith('- ')) {
|
||||
for (const [k2, v2] of Object.entries(map(itemIndent))) { if (k2 in m) throw new Error(`line ${l.n}: "${k2}" twice`); m[k2] = v2; }
|
||||
}
|
||||
out.push(m);
|
||||
} else out.push(scalar(rest, l.n));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const v = value(0);
|
||||
skip();
|
||||
if (pos < lines.length) throw new Error(`line ${lines[pos]!.n}: unexpected content`);
|
||||
return v;
|
||||
}
|
||||
214
cli/listing.ts
Normal file
214
cli/listing.ts
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
// Listing localization: translation drafts of the listing fields in both listing files (rules: lib/listing-translate.ts).
|
||||
// storebound listing translate --to de-DE,ja [--from en-US] [--store apple|play] [--translate "<command>"] [--force] [--dry] [--json]
|
||||
// per target language: the App Store section (name, subtitle, promotionalText, keywords, description) in
|
||||
// store/appstore.md and the Play section (title, short, full) in store/listing.md. Without --translate the source
|
||||
// text is copied in with status=translate for your agent to translate in place (listing-localization skill); with
|
||||
// --translate your command runs once per field with the source text on stdin and STOREBOUND_SOURCE_LANG,
|
||||
// STOREBOUND_TARGET_LANG, STOREBOUND_STORE, STOREBOUND_FIELD, STOREBOUND_LIMIT in the environment; its stdout is
|
||||
// the translation (status=draft). Keywords are cleaned up (commas, duplicates, name / subtitle words, 100 limit).
|
||||
// Reviewed sections (no marker) are kept unless --force; a section's What's new is kept.
|
||||
// storebound listing check [--json] limits, keyword rules, untranslated and draft sections; exit 1 on a problem
|
||||
// storebound listing reviewed --lang de-DE[,ja] | --all [--dry] a human read the draft: remove its marker
|
||||
// --to / --from / --lang take config language ids, App Store locales or Play codes. Local files only: nothing is sent
|
||||
// to a store (apple listing / play listing push them after `storebound check`).
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import type { Language } from './lib/config';
|
||||
import { playCodes } from './lib/config';
|
||||
import type { Ctx } from './lib/ctx';
|
||||
import { done, log, printJson, warn } from './lib/log';
|
||||
import {
|
||||
APPLE_FIELDS, appleFields, appleLocaleOf, appleSectionText, checkFields, FIELD_LIMITS, type FieldCheck, findAppleSection, findPlaySection, mark,
|
||||
markerOf, normalizeKeywords, PLAY_FIELDS, playCodesOf, playFields, playSectionText, putSection, sections, unmark,
|
||||
} from './lib/listing-translate';
|
||||
import { textTable } from './lib/table';
|
||||
import { resolveLanguages } from './lib/whats-new';
|
||||
|
||||
const TAG = 'listing';
|
||||
const storeCode = (l: Language): string => l.apple ?? playCodes(l)[0] ?? l.id;
|
||||
|
||||
interface Files { apple?: { path: string; md: string }; play?: { path: string; md: string } }
|
||||
|
||||
function readFiles(ctx: Ctx, store?: string): Files {
|
||||
const { config, resolve } = ctx.loaded;
|
||||
const out: Files = {};
|
||||
if (config.apple && store !== 'play') { const p = resolve(config.apple.listing ?? 'store/appstore.md'); if (existsSync(p)) out.apple = { path: p, md: readFileSync(p, 'utf8') }; else warn(TAG, `${p} missing: App Store skipped`); }
|
||||
if (config.play && store !== 'apple') { const p = resolve(config.play.listing ?? 'store/listing.md'); if (existsSync(p)) out.play = { path: p, md: readFileSync(p, 'utf8') }; else warn(TAG, `${p} missing: Google Play skipped`); }
|
||||
if (!out.apple && !out.play) throw new Error('no listing file to work on (store/appstore.md, store/listing.md; storebound init creates them)');
|
||||
return out;
|
||||
}
|
||||
|
||||
function sourceLanguage(ctx: Ctx): Language {
|
||||
const { config } = ctx.loaded;
|
||||
const want = ctx.args.get('from');
|
||||
if (want) return resolveLanguages(config.languages, [want])[0]!;
|
||||
const primary = config.apple?.primaryLocale ?? config.play?.defaultLanguage;
|
||||
return config.languages.find(l => l.apple === primary || playCodes(l).includes(primary ?? '')) ?? config.languages[0]!;
|
||||
}
|
||||
|
||||
interface Row { lang: string; store: 'apple' | 'play'; action: string; checks: FieldCheck[] }
|
||||
|
||||
async function translate(ctx: Ctx): Promise<void> {
|
||||
const { config } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
const store = a.get('store');
|
||||
if (store && store !== 'apple' && store !== 'play') throw new Error('--store apple | play');
|
||||
const targets = resolveLanguages(config.languages, a.list('to'));
|
||||
if (!targets.length) throw new Error('--to <languages>: config language ids, App Store locales or Play codes (add a language to languages[] in the config first)');
|
||||
const src = sourceLanguage(ctx);
|
||||
const files = readFiles(ctx, store);
|
||||
const hook = a.get('translate');
|
||||
const dry = a.has('dry');
|
||||
const rows: Row[] = [];
|
||||
const runHook = (text: string, l: Language, st: 'apple' | 'play', field: string, limit: number): string | null => {
|
||||
const r = Bun.spawnSync(['sh', '-c', hook!], { stdin: new TextEncoder().encode(text), stdout: 'pipe', stderr: 'pipe',
|
||||
env: { ...process.env, STOREBOUND_SOURCE_LANG: storeCode(src), STOREBOUND_TARGET_LANG: st === 'apple' ? l.apple ?? l.id : playCodes(l)[0] ?? l.id, STOREBOUND_TARGET_LANG_ID: l.id,
|
||||
STOREBOUND_STORE: st, STOREBOUND_FIELD: field, STOREBOUND_LIMIT: String(limit) } });
|
||||
const out = r.stdout.toString().trim();
|
||||
if (r.exitCode !== 0 || !out) { warn(TAG, `${l.id} ${st}.${field}: --translate failed (exit ${r.exitCode}): ${r.stderr.toString().trim().slice(0, 200)}`); return null; }
|
||||
return out;
|
||||
};
|
||||
|
||||
for (const l of targets) {
|
||||
if (l === src) { warn(TAG, `${l.id} is the source language: skipped`); continue; }
|
||||
// ---- App Store ----
|
||||
if (files.apple && l.apple && src.apple) {
|
||||
const srcSec = findAppleSection(files.apple.md, src.apple);
|
||||
const cur = findAppleSection(files.apple.md, l.apple);
|
||||
if (!srcSec) warn(TAG, `${files.apple.path}: no ${src.apple} section to translate from`);
|
||||
else if (cur && !markerOf(cur) && !a.has('force')) rows.push({ lang: l.id, store: 'apple', action: 'kept (reviewed; --force replaces it)', checks: [] });
|
||||
else {
|
||||
const s = appleFields(srcSec);
|
||||
const f: Record<string, string> = {};
|
||||
let failed = false;
|
||||
for (const k of APPLE_FIELDS) {
|
||||
if (s[k] === undefined) continue;
|
||||
if (hook && !dry) { const t = runHook(s[k]!, l, 'apple', k, FIELD_LIMITS.apple[k]); if (t === null) failed = true; f[k] = t ?? s[k]!; }
|
||||
else f[k] = s[k]!;
|
||||
}
|
||||
const status = hook && !dry && !failed ? 'draft' : 'translate';
|
||||
if (f.keywords && status === 'draft') {
|
||||
const n = normalizeKeywords(f.keywords, { name: f.name, subtitle: f.subtitle });
|
||||
for (const d of n.dropped) log(TAG, `${l.apple} keywords: dropped "${d.kw}" (${d.why})`);
|
||||
f.keywords = n.text;
|
||||
}
|
||||
const keep = cur ? appleFields(cur).whatsNew : undefined;
|
||||
const text = appleSectionText(l.apple, l.id, { ...f, ...(keep ? { whatsNew: keep } : {}) }, mark(src.apple, status));
|
||||
files.apple.md = putSection(files.apple.md, cur, text);
|
||||
rows.push({ lang: l.id, store: 'apple', action: `${cur ? 'replaced' : 'added'} (status=${status})`, checks: checkFields('apple', f, s, status) });
|
||||
}
|
||||
}
|
||||
// ---- Google Play ----
|
||||
const codes = playCodes(l), srcCodes = playCodes(src);
|
||||
if (files.play && codes.length && srcCodes.length) {
|
||||
const srcSec = findPlaySection(files.play.md, srcCodes);
|
||||
const cur = findPlaySection(files.play.md, codes);
|
||||
if (!srcSec) warn(TAG, `${files.play.path}: no ${srcCodes.join(', ')} section to translate from`);
|
||||
else if (cur && !markerOf(cur) && !a.has('force')) rows.push({ lang: l.id, store: 'play', action: 'kept (reviewed; --force replaces it)', checks: [] });
|
||||
else {
|
||||
const s = playFields(srcSec);
|
||||
const f: Record<string, string> = {};
|
||||
let failed = false;
|
||||
for (const k of PLAY_FIELDS) {
|
||||
if (s[k] === undefined) continue;
|
||||
if (hook && !dry) { const t = runHook(s[k]!, l, 'play', k, FIELD_LIMITS.play[k]); if (t === null) failed = true; f[k] = t ?? s[k]!; }
|
||||
else f[k] = s[k]!;
|
||||
}
|
||||
const status = hook && !dry && !failed ? 'draft' : 'translate';
|
||||
const keep = cur ? playFields(cur).whatsNew : undefined;
|
||||
// the section keeps serving every Play code it served (es-ES, es-419), plus the language's own
|
||||
const allCodes = [...new Set([...(cur ? playCodesOf(cur) : []), ...codes])];
|
||||
const text = playSectionText(allCodes, l.id, { ...f, ...(keep ? { whatsNew: keep } : {}) }, mark(srcCodes[0]!, status));
|
||||
files.play.md = putSection(files.play.md, cur, text);
|
||||
rows.push({ lang: l.id, store: 'play', action: `${cur ? 'replaced' : 'added'} (status=${status})`, checks: checkFields('play', f, s, status) });
|
||||
}
|
||||
}
|
||||
}
|
||||
const problemsOf = (r: Row) => r.checks.flatMap(c => c.problems.filter(p => !p.startsWith('not translated')).map(p => `${c.field}: ${p}`));
|
||||
if (a.has('json')) printJson({ source: src.id, dryRun: dry, hook: !!hook, files: { apple: files.apple?.path ?? null, play: files.play?.path ?? null }, results: rows.map(r => ({ ...r, problems: problemsOf(r) })) });
|
||||
else {
|
||||
console.log(textTable(['language', 'store', 'section', 'fields', 'problems'], rows.map(r => [r.lang, r.store === 'apple' ? 'App Store' : 'Google Play', r.action,
|
||||
r.checks.map(c => `${c.field} ${c.chars}/${c.limit}`).join(', '), problemsOf(r).join('; ')])));
|
||||
}
|
||||
const json = a.has('json');
|
||||
if (dry) { if (!json) done(TAG, 'dry run: listing files not written'); return; }
|
||||
if (files.apple) writeFileSync(files.apple.path, files.apple.md);
|
||||
if (files.play) writeFileSync(files.play.path, files.play.md);
|
||||
if (json) return;
|
||||
const todo = rows.filter(r => r.action.includes('status=translate')).length;
|
||||
done(TAG, todo ? `${todo} section(s) to translate in place (keep the marker line, set status=draft), then storebound listing check` : 'drafts written: review them, storebound listing check, then storebound listing reviewed --lang <ids>');
|
||||
}
|
||||
|
||||
interface SecReport { file: string; store: 'apple' | 'play'; lang: string; status: 'reviewed' | 'translate' | 'draft'; from: string | null; checks: FieldCheck[] }
|
||||
|
||||
function report(files: Files): SecReport[] {
|
||||
const out: SecReport[] = [];
|
||||
if (files.apple) for (const sec of sections(files.apple.md)) {
|
||||
const loc = appleLocaleOf(sec);
|
||||
if (!loc) continue;
|
||||
const m = markerOf(sec);
|
||||
const srcSec = m ? findAppleSection(files.apple.md, m.from) : undefined;
|
||||
out.push({ file: files.apple.path, store: 'apple', lang: loc, status: m?.status ?? 'reviewed', from: m?.from ?? null, checks: checkFields('apple', appleFields(sec), srcSec ? appleFields(srcSec) : {}, m?.status) });
|
||||
}
|
||||
if (files.play) for (const sec of sections(files.play.md)) {
|
||||
const codes = playCodesOf(sec);
|
||||
if (!codes.length) continue;
|
||||
const m = markerOf(sec);
|
||||
const srcSec = m ? findPlaySection(files.play.md, [m.from]) : undefined;
|
||||
out.push({ file: files.play.path, store: 'play', lang: codes.join(', '), status: m?.status ?? 'reviewed', from: m?.from ?? null, checks: checkFields('play', playFields(sec), srcSec ? playFields(srcSec) : {}, m?.status) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function check(ctx: Ctx): void {
|
||||
const files = readFiles(ctx);
|
||||
const r = report(files);
|
||||
const bad = r.filter(x => x.checks.some(c => c.problems.length));
|
||||
const drafts = r.filter(x => x.status === 'draft');
|
||||
if (ctx.args.has('json')) printJson({ sections: r, ok: !bad.length, drafts: drafts.map(d => `${d.store}:${d.lang}`) });
|
||||
else {
|
||||
console.log(textTable(['store', 'language', 'status', 'fields', 'problems'], r.map(x => [x.store === 'apple' ? 'App Store' : 'Google Play', x.lang,
|
||||
x.status === 'draft' ? 'DRAFT (review)' : x.status === 'translate' ? 'TO TRANSLATE' : 'reviewed', x.checks.map(c => `${c.field} ${c.chars}/${c.limit}`).join(', '),
|
||||
x.checks.flatMap(c => c.problems.map(p => `${c.field}: ${p}`)).join('; ')])));
|
||||
if (drafts.length) warn(TAG, `${drafts.length} machine-translated draft(s) not reviewed yet: ${drafts.map(d => `${d.store}:${d.lang}`).join(', ')} (storebound listing reviewed --lang <ids> after reading them)`);
|
||||
done(TAG, bad.length ? `${bad.length} section(s) with problems` : `${r.length} section(s) within the store limits`);
|
||||
}
|
||||
if (bad.length) process.exitCode = 1;
|
||||
}
|
||||
|
||||
function reviewed(ctx: Ctx): void {
|
||||
const { config } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
const files = readFiles(ctx);
|
||||
const all = a.has('all');
|
||||
const langs = all ? [] : resolveLanguages(config.languages, a.list('lang'));
|
||||
if (!all && !langs.length) throw new Error('--lang <ids> | --all');
|
||||
const changed: string[] = [], refused: string[] = [];
|
||||
const pick = (sec: string, store: 'apple' | 'play'): boolean => {
|
||||
if (all) return true;
|
||||
return store === 'apple' ? langs.some(l => l.apple && appleLocaleOf(sec) === l.apple) : langs.some(l => playCodes(l).some(c => playCodesOf(sec).includes(c)));
|
||||
};
|
||||
for (const store of ['apple', 'play'] as const) {
|
||||
const f = files[store];
|
||||
if (!f) continue;
|
||||
f.md = sections(f.md).map(sec => {
|
||||
const m = markerOf(sec);
|
||||
if (!m || !pick(sec, store)) return sec;
|
||||
const label = `${store}:${store === 'apple' ? appleLocaleOf(sec) : playCodesOf(sec).join(',')}`;
|
||||
if (m.status === 'translate') { refused.push(label); return sec; }
|
||||
changed.push(label);
|
||||
return unmark(sec);
|
||||
}).join('');
|
||||
}
|
||||
for (const r of refused) warn(TAG, `${r}: still status=translate (translate it first)`);
|
||||
if (a.has('dry')) { done(TAG, `dry run: would mark ${changed.length} section(s) reviewed: ${changed.join(', ') || 'none'}`); return; }
|
||||
for (const store of ['apple', 'play'] as const) if (files[store]) writeFileSync(files[store]!.path, files[store]!.md);
|
||||
done(TAG, `${changed.length} section(s) marked reviewed${changed.length ? `: ${changed.join(', ')}` : ''}`);
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const sub = ctx.args._[0];
|
||||
if (sub === 'translate') return translate(ctx);
|
||||
if (sub === 'check') return check(ctx);
|
||||
if (sub === 'reviewed') return reviewed(ctx);
|
||||
throw new Error('usage: storebound listing translate --to <languages> [--from <language>] [--translate "<command>"] [--dry] | check | reviewed --lang <ids>');
|
||||
}
|
||||
|
|
@ -41,8 +41,10 @@ export const TOOLS: ToolDef[] = [
|
|||
args: i => ['--aso', ...opt('storefront', i.storefront)] },
|
||||
{ name: 'scan', title: 'Rejection-risk scan of the project', command: ['scan'], write: false, network: false,
|
||||
description: 'Offline, read-only scan of the project itself before submitting: detects the stack (iOS, Android, React Native, Expo, Capacitor, Cordova, Flutter, Unity, Godot) and SDKs (ads, analytics, crash, sign-in, payments, push) with versions and file:line, then reports App Store and Google Play rejection risks with the guideline, evidence, fix, severity and skill (demo account 2.1, account deletion 5.1.1(v), Sign in with Apple 4.8, Restore Purchases 3.1.1, subscription info 3.1.2, ATT 5.1.2, purpose strings, privacy manifest, other platforms 2.3.10, keywords 2.3.7, placeholder text, web wrappers 4.2, UIWebView, ATS, IPv6, export compliance, kids ads, Play target SDK, delete-account URL, restricted permissions and their declarations (background location, photo / video, All files access, accessibility, install packages, Health Connect, full-screen intent, VPN, foreground services, exact alarms, QUERY_ALL_PACKAGES, SMS / call log), prominent disclosure, Families, AD_ID, 16 KB page sizes, testing for personal accounts, Play metadata, ads at launch, payments, impersonation) and proposes the Data safety / App Privacy / ATT / privacy manifest answers as a diff against the config. Never writes (the owner runs `storebound scan --write` in a terminal).',
|
||||
props: { store: { type: 'string', enum: ['apple', 'play'], description: 'Only this store\'s findings (default: both)' } },
|
||||
args: i => opt('store', i.store) },
|
||||
props: { store: { type: 'string', enum: ['apple', 'play'], description: 'Only this store\'s findings (default: both)' },
|
||||
originality: { type: 'boolean', default: false, description: 'Also the 4.3 / Play repetitive content check against your other apps (folders from against, else originality.against in the config)' },
|
||||
against: { type: 'string', description: 'Comma-separated folders of your other apps (with originality)' } },
|
||||
args: i => [...opt('store', i.store), ...flag('originality', i.originality), ...(i.originality ? opt('against', i.against) : [])] },
|
||||
{ name: 'validate', title: 'Store readiness report', command: ['validate'], write: false, network: true,
|
||||
description: 'Read-only readiness report for App Store Connect and/or Google Play with ordered blockers (build, encryption, metadata, screenshots, review details and demo account, age rating, prices, IAPs, subscriptions, privacy, delete-account and terms URLs, app-ads.txt, tracks, products, base plans).',
|
||||
props: { store: { type: 'string', enum: ['both', 'apple', 'play'], default: 'both' } },
|
||||
|
|
@ -283,6 +285,18 @@ export const TOOLS: ToolDef[] = [
|
|||
no_validate: { type: 'boolean', default: false, description: 'Skip the store readiness read' }, json: { type: 'boolean', default: false } },
|
||||
required: ['version'], args: i => [String(i.version), ...opt('app', i.app), ...flag('no-validate', i.no_validate), ...flag('json', i.json)] },
|
||||
|
||||
{ name: 'flow_list', title: 'Repo-local workflows', command: ['flow', 'list'], write: false, network: false,
|
||||
description: 'The named workflows of this project (store/workflows/*.yml, storebound.workflows.*) with their params and steps, each step classified as read, write (runs as a dry run), wait, shell or "your click" (owner steps such as Submit for Review, never run).',
|
||||
args: () => ['--json'] },
|
||||
{ name: 'flow_run', title: 'Run a workflow as a dry run', command: ['flow', 'run'], write: false, network: true,
|
||||
description: 'Run one workflow step by step: read steps run, every write step runs with --dry (nothing changes on a store or in files), wait steps check once, shell steps are skipped, owner steps are listed as the owner\'s clicks. plan_only shows the plan without running anything. Running the writes for real is a terminal command the owner runs (storebound flow run <name> --apply).',
|
||||
props: { name: { type: 'string', pattern: '^[a-z0-9][a-z0-9._-]{0,62}$', description: 'Flow name (flow_list)' },
|
||||
params: { type: 'object', additionalProperties: { type: 'string' }, description: 'Flow params, e.g. {"VERSION": "1.2.0"}' },
|
||||
from: { type: 'string', pattern: '^[a-z0-9][a-z0-9._-]{0,62}$', description: 'Start at this step id' },
|
||||
plan_only: { type: 'boolean', default: false } },
|
||||
required: ['name'],
|
||||
args: i => [String(i.name), ...Object.entries((i.params ?? {}) as Record<string, unknown>).filter(([k]) => /^[A-Z][A-Z0-9_]{0,40}$/.test(k)).map(([k, v]) => `${k}=${String(v)}`), ...opt('from', i.from), ...flag('dry', i.plan_only), '--json'] },
|
||||
|
||||
// ---- store operations (read-only plans, local pulls and reports; submits, codes, offers and pre-orders stay terminal-only) ----
|
||||
{ name: 'apple_testflight_wait', title: 'Wait for a TestFlight build', command: ['apple', 'testflight', 'wait'], write: false, network: true,
|
||||
description: 'Poll one uploaded build (exact number) until processing ends: exit 0 VALID, 1 FAILED / INVALID, 7 timeout. Read-only. check_once reads the state once without waiting.',
|
||||
|
|
@ -313,6 +327,14 @@ export const TOOLS: ToolDef[] = [
|
|||
{ name: 'whats_new_apply', title: 'Apply release notes per language', command: ['whats-new', 'apply'], write: true, network: false, idempotent: true,
|
||||
description: 'Write the checked per-language release notes into both listing files (Play "What\'s new" per Play code, App Store whatsNew per locale). Refuses while a language is over a limit or untranslated. Local files only; nothing is sent to a store.',
|
||||
args: () => ['--json'] },
|
||||
{ name: 'listing_translate', title: 'Listing translation drafts', command: ['listing', 'translate'], write: true, network: false, idempotent: true,
|
||||
description: 'Add a section per target language to both listing files (App Store: name, subtitle, promotionalText, keywords, description; Google Play: title, short, full) with the source language\'s text and a status=translate marker. Then translate each field in place within the store limits (App Store subtitle 30, promotional text 170, keywords 100 comma-separated without duplicates or name words, description 4000; Play title 30, short 80, full 4000), set the marker to status=draft and run listing_check. The owner reviews the drafts (storebound listing reviewed). Reviewed sections are kept. Local files only.',
|
||||
props: { to: { type: 'string', pattern: '^[A-Za-z0-9_-]+(,[A-Za-z0-9_-]+)*$', description: 'Comma-separated target languages (config ids, App Store locales or Play codes)' },
|
||||
from: { type: 'string', pattern: '^[A-Za-z0-9_-]+$', description: 'Source language (default: the primary one)' }, store: { type: 'string', enum: ['apple', 'play'] } },
|
||||
required: ['to'], args: i => [...opt('to', i.to), ...opt('from', i.from), ...opt('store', i.store), '--json'] },
|
||||
{ name: 'listing_check', title: 'Check listing translations', command: ['listing', 'check'], write: false, network: false,
|
||||
description: 'Offline: every language section of both listing files against the store limits and keyword rules, with untranslated (status=translate) and unreviewed machine-translated (status=draft) sections.',
|
||||
args: () => ['--json'] },
|
||||
{ name: 'reports', title: 'Sales and finance reports', command: ['reports'], write: true, network: true, idempotent: true,
|
||||
description: 'Download a sales or finance report into .storebound/reports/ (gitignored) and print a summary per product and currency (amounts never added across currencies) plus a summary CSV. Apple needs ASC_VENDOR_NUMBER and a team key; Play needs play.reportsBucket and "View financial data". dry_run shows the request only.',
|
||||
props: { kind: { type: 'string', enum: ['apple-sales', 'apple-finance', 'play-earnings', 'play-sales'] }, month: { type: 'string', pattern: '^\\d{4}-\\d{2}$', description: 'YYYY-MM (apple-finance: Apple fiscal month; Play reports)' },
|
||||
|
|
|
|||
|
|
@ -7,35 +7,42 @@
|
|||
// (mechanic, content, differentiator sentence) is the portfolio-originality skill.
|
||||
import { realpathSync } from 'node:fs';
|
||||
import { relative } from 'node:path';
|
||||
import { loadConfig } from './lib/config';
|
||||
import { loadConfig, type ShipConfig } from './lib/config';
|
||||
import type { Ctx } from './lib/ctx';
|
||||
import { done, log, printJson, warn } from './lib/log';
|
||||
import { DEFAULT_THRESHOLD, findApps, fingerprint, report } from './lib/originality';
|
||||
import { type AppFingerprint, DEFAULT_THRESHOLD, findApps, fingerprint, type OriginalityReport, report } from './lib/originality';
|
||||
import { textTable } from './lib/table';
|
||||
|
||||
const TAG = 'originality';
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root, resolve } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
const folders = (a.list('against').length ? a.list('against') : config.originality?.against ?? []).map(f => resolve(f));
|
||||
/** The 4.3 comparison of one app against the apps in `against` (also used by `storebound scan --originality`). */
|
||||
export async function compareAgainst(o: { config: ShipConfig; root: string; resolve(p: string): string }, against: string[], thresholdArg?: number, onSkip: (msg: string) => void = () => {}): Promise<{ report: OriginalityReport; me: AppFingerprint; others: number }> {
|
||||
const { config, root, resolve } = o;
|
||||
const folders = (against.length ? against : config.originality?.against ?? []).map(f => resolve(f));
|
||||
if (!folders.length) throw new Error('nothing to compare with: --against <folder of another app, or a folder holding several> (or originality.against in the config)');
|
||||
const threshold = a.has('threshold') ? a.num('threshold', DEFAULT_THRESHOLD) : config.originality?.threshold ?? DEFAULT_THRESHOLD;
|
||||
const threshold = thresholdArg ?? config.originality?.threshold ?? DEFAULT_THRESHOLD;
|
||||
if (!(threshold > 0 && threshold < 1)) throw new Error('--threshold: between 0 and 1');
|
||||
const self = realpathSync(root);
|
||||
const configs = findApps(folders.map(f => { try { return realpathSync(f); } catch { return f; } }), self);
|
||||
if (!configs.length) throw new Error(`no other app (storebound.config.ts) in ${folders.map(f => relative(root, f) || '.').join(', ')}`);
|
||||
const json = a.has('json');
|
||||
if (!json) log(TAG, `${config.app.name} vs ${configs.length} app(s), offline`);
|
||||
const me = fingerprint(config, root);
|
||||
const others = [];
|
||||
for (const p of configs) {
|
||||
try {
|
||||
const l = await loadConfig(p);
|
||||
others.push(fingerprint(l.config, l.root));
|
||||
} catch (e) { warn(TAG, `${p}: skipped (${(e as Error).message.split('\n')[0]?.slice(0, 160)})`); }
|
||||
} catch (e) { onSkip(`${p}: skipped (${(e as Error).message.split('\n')[0]?.slice(0, 160)})`); }
|
||||
}
|
||||
const r = report(me, others, threshold);
|
||||
return { report: report(me, others, threshold), me, others: configs.length };
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
const a = ctx.args;
|
||||
const json = a.has('json');
|
||||
const { report: r, me, others } = await compareAgainst(ctx.loaded, a.list('against'), a.has('threshold') ? a.num('threshold', DEFAULT_THRESHOLD) : undefined, m => warn(TAG, m));
|
||||
if (!json) log(TAG, `${config.app.name} vs ${others} app(s), offline`);
|
||||
const threshold = r.threshold;
|
||||
if (json) { printJson(r); if (r.flagged) process.exitCode = 1; return; }
|
||||
for (const n of me.notes) warn(TAG, `${config.app.name}: ${n}`);
|
||||
const pct = (x: number | null) => (x === null ? '-' : `${Math.round(x * 100)}%`);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
// 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] [--json]
|
||||
// storebound prices export [--out store/prices.csv] [--store apple|play] [--only ids] [--with-automatic] [--no-subscriptions] [--dry] [--json]
|
||||
// one-time products and (unless --no-subscriptions) auto-renewable subscriptions: Apple's current and scheduled
|
||||
// subscription prices per territory, Play's regional prices of the base plan. Subscription rows use the same
|
||||
// columns; `apple subscriptions --csv` / `play subscriptions --csv` read them back (prices import skips them).
|
||||
// storebound prices import [--csv store/prices.csv] [--store apple|play] [--only ids] [--reconvert] [--all] [--dry] [--yes]
|
||||
// storebound prices ppp [--base <USD>] [...] purchasing power price sheet (prices-ppp.ts)
|
||||
// CSV columns: product, store (apple | play | both), region (ISO alpha-2), currency, price, start_date (App Store
|
||||
|
|
@ -21,6 +24,7 @@ import {
|
|||
pointKey, type PriceRow, pricesCsv, sameSchedule,
|
||||
} from './lib/prices';
|
||||
import { playClient, type PlayClient } from './play/client';
|
||||
import { allSubscriptions, appleSubPriceRows, basePlanId, type PlaySubscription, playSubPriceRows } from './lib/subscriptions';
|
||||
|
||||
const TAG = 'prices';
|
||||
|
||||
|
|
@ -60,7 +64,9 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
const useApple = (!store || store === 'apple') && !!config.apple;
|
||||
const usePlay = (!store || store === 'play') && !!config.play;
|
||||
const only = a.list('only');
|
||||
const products = need(config.products, 'products').filter(p => !only.length || only.includes(p.id));
|
||||
const products = (config.products ?? []).filter(p => !only.length || only.includes(p.id));
|
||||
const subs = sub === 'export' && !a.has('no-subscriptions') ? allSubscriptions(config.subscriptions).map(x => x.sub).filter(s => !only.length || only.includes(s.id)) : [];
|
||||
if (!products.length && !subs.length) need(undefined, sub === 'export' ? 'products or subscriptions' : 'products');
|
||||
const csvPath = resolve(a.get(sub === 'export' ? 'out' : 'csv') ?? config.prices?.csv ?? 'store/prices.csv');
|
||||
const dry = a.has('dry');
|
||||
|
||||
|
|
@ -87,22 +93,46 @@ export async function run(ctx: Ctx): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
if (sub === 'export' && subs.length) {
|
||||
const appleSubs = new Map<string, string>();
|
||||
if (c) for (const g of await c.all(`/v1/apps/${appId}/subscriptionGroups?limit=200`))
|
||||
for (const x of await c.all(`/v1/subscriptionGroups/${g.id}/subscriptions?limit=200`)) appleSubs.set(String(x.attributes.productId), x.id);
|
||||
for (const [i, s] of subs.entries()) {
|
||||
log(TAG, `${step(i + 1, subs.length, s.id)}: reading subscription prices`);
|
||||
if (c) {
|
||||
const id = appleSubs.get(s.id);
|
||||
if (!id) { warn(TAG, `${s.id}: subscription not on App Store Connect (storebound apple subscriptions creates it)`); missing.push({ product: s.id, store: 'apple' }); }
|
||||
else current.push(...appleSubPriceRows(s.id, await pages(c, `/v1/subscriptions/${id}/prices?include=subscriptionPricePoint,territory&limit=200`)));
|
||||
}
|
||||
if (play) {
|
||||
let ps: PlaySubscription | null = null;
|
||||
try { ps = await play.call<PlaySubscription>('GET', `${play.API}/subscriptions/${encodeURIComponent(s.id)}`); } catch (e) { if (!/-> 404/.test(String(e))) throw e; }
|
||||
if (!ps) { warn(TAG, `${s.id}: subscription not on Google Play (storebound play subscriptions creates it)`); missing.push({ product: s.id, store: 'play' }); }
|
||||
else current.push(...playSubPriceRows(ps, basePlanId(s)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
printJson({ csv: csvPath, products: products.map(p => p.id), subscriptions: subs.map(s => s.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);
|
||||
done(TAG, `${current.length} rows -> ${csvPath} (edit, then storebound prices import --dry)`);
|
||||
done(TAG, `${current.length} rows -> ${csvPath} (edit, then storebound prices import --dry${subs.length ? '; subscription rows: apple subscriptions --csv / play subscriptions --csv' : ''})`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!existsSync(csvPath)) throw new Error(`no prices CSV at ${csvPath} (storebound prices export writes one)`);
|
||||
const wantedAll = parsePriceCsv(readFileSync(csvPath, 'utf8'), { products: config.products!.map(p => p.id) })
|
||||
const subIds = allSubscriptions(config.subscriptions).map(x => x.sub.id);
|
||||
const sheet = parsePriceCsv(readFileSync(csvPath, 'utf8'), { products: [...(config.products ?? []).map(p => p.id), ...subIds] });
|
||||
const subRows = sheet.filter(r => subIds.includes(r.product));
|
||||
if (subRows.length) log(TAG, `${subRows.length} subscription row(s) skipped here: storebound apple subscriptions --csv ${a.get('csv') ?? config.prices?.csv ?? 'store/prices.csv'} --dry (and play subscriptions --csv) apply them`);
|
||||
const wantedAll = sheet
|
||||
.filter(r => products.some(p => p.id === r.product) && ((r.store === 'apple' && useApple) || (r.store === 'play' && usePlay)));
|
||||
const diff = diffPrices(current, wantedAll);
|
||||
const changed = new Set(diff.filter(d => d.change !== 'same').map(d => `${d.product}|${d.store}`));
|
||||
|
|
|
|||
19
cli/scan.ts
19
cli/scan.ts
|
|
@ -1,6 +1,8 @@
|
|||
// Offline, read-only scan of the project itself for App Store and Google Play rejection risks, before you submit.
|
||||
// storebound scan [--dir <project>] [--config <file>] [--store apple|play] [--json] [--no-declarations]
|
||||
// storebound scan --write also write the detected dataSafety / appPrivacy answers into the config
|
||||
// storebound scan --originality [--against <folders>] [--threshold 0.7] also the 4.3 / Play repetitive content
|
||||
// check against your other apps (storebound originality; folders default to originality.against in the config)
|
||||
// Reads the project files (Xcode project, Info.plist, entitlements, privacy manifests, Podfile.lock, Package.resolved,
|
||||
// Gradle files, AndroidManifest.xml and a local build's merged manifest, res/xml and strings.xml, CMake / ndk-build
|
||||
// files, package.json, app.json, capacitor.config, pubspec, Unity and Godot settings and ProjectVersion.txt), the
|
||||
|
|
@ -9,12 +11,13 @@
|
|||
// answers as a diff against the config. Nothing is written without --write (and --dry always wins). No network.
|
||||
// Exit 1 while an open blocker is left.
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { dirname, join, relative, resolve } from 'node:path';
|
||||
import type { Args } from './lib/args';
|
||||
import { CONFIG_NAMES } from './lib/config';
|
||||
import { log, printJson, warn } from './lib/log';
|
||||
import { upsertBlock } from './lib/scan/config-edit';
|
||||
import { formatScan, runScan } from './lib/scan';
|
||||
import { addOriginality, formatScan, runScan } from './lib/scan';
|
||||
import { compareAgainst } from './originality';
|
||||
|
||||
/** Project folder: --dir, else the folder of the nearest storebound.config.* above the working directory, else it. */
|
||||
function projectDir(args: Args): string {
|
||||
|
|
@ -28,7 +31,17 @@ function projectDir(args: Args): string {
|
|||
export async function run(args: Args): Promise<void> {
|
||||
const dir = projectDir(args);
|
||||
if (!existsSync(dir)) throw new Error(`${dir} does not exist`);
|
||||
const { report, configPath } = await runScan(dir, { config: args.get('config') });
|
||||
const { report, configPath, config } = await runScan(dir, { config: args.get('config') });
|
||||
if (args.has('originality')) {
|
||||
if (!config || !configPath) report.originality = { error: 'no storebound.config.ts loaded in this project' };
|
||||
else {
|
||||
const base = dirname(configPath);
|
||||
try {
|
||||
const { report: o } = await compareAgainst({ config, root: base, resolve: p => resolve(base, p) }, args.list('against'), args.has('threshold') ? args.num('threshold', 0.7) : undefined, m => warn('scan', m));
|
||||
addOriginality(report, o, { apple: !!config.apple, play: !!config.play }, config, p => relative(dir, p));
|
||||
} catch (e) { report.originality = { error: (e as Error).message }; }
|
||||
}
|
||||
}
|
||||
const store = args.get('store');
|
||||
if (store === 'apple' || store === 'play') {
|
||||
report.findings = report.findings.filter(f => f.store === store);
|
||||
|
|
|
|||
1
cli/text-modules.d.ts
vendored
1
cli/text-modules.d.ts
vendored
|
|
@ -3,3 +3,4 @@ declare module '*.md' { const text: string; export default text; }
|
|||
declare module '*.csv' { const text: string; export default text; }
|
||||
declare module '*.html' { const text: string; export default text; }
|
||||
declare module '*.svg' { const text: string; export default text; }
|
||||
declare module '*.yml' { const text: string; export default text; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue