console fill play-app-record: Play Console's Create app form (account picked by developerId / workspace / play.developerAccount, else stop and list; Create app opener allowlisted only on the app list, never in the form, EN + TR; name, default language, app or game, free or paid as an owner check; declarations never ticked; package name set by the first AAB upload)
This commit is contained in:
parent
96f3df443b
commit
20d34fa0ec
26 changed files with 592 additions and 41 deletions
|
|
@ -5,6 +5,9 @@
|
|||
// from play.developerId (config), STOREBOUND_PLAY_DEVELOPER_ID (a workspace account's developerId, set by
|
||||
// `ws`), or the cache; else storebound reads every developer account link on the chooser
|
||||
// (/console/u/0/developers) and looks for play.packageName in each app list.
|
||||
// play-app-record (Create app) is a FIRST create: no account has the package yet, so the account is picked, not
|
||||
// searched: play.developerId / the workspace's id / the cache, else the one account the login sees, else the
|
||||
// chooser entry named exactly play.developerAccount. Ambiguous or not set -> storebound stops and lists them.
|
||||
// Apple: the team is switched in the account menu at the top right (the team list; Apple's help "Switch between
|
||||
// teams"). The order tried: the cached team, the menu entry that names apple.teamId, then every other team; the
|
||||
// app is found by its list entry (App Privacy) or, for a new app, by the bundle id in the New App dialog's Bundle ID
|
||||
|
|
@ -192,6 +195,39 @@ export async function openAcross(page: Page, o: AcrossOpts): Promise<{ nav: NavR
|
|||
}
|
||||
}
|
||||
|
||||
/** Play account names compare by whole name, spaces and case aside. */
|
||||
const sameName = (a: string, b: string) => a.trim().replace(/\s+/g, ' ').toLocaleLowerCase('tr') === b.trim().replace(/\s+/g, ' ').toLocaleLowerCase('tr');
|
||||
|
||||
/**
|
||||
* play-app-record: the developer account to create the app in. Never guessed among several: play.developerId (or the
|
||||
* workspace's STOREBOUND_PLAY_DEVELOPER_ID, or the remembered one for this package), else the only account the login
|
||||
* sees, else the chooser entry named play.developerAccount. Remembered under play.packageName once the form is open.
|
||||
*/
|
||||
async function pickPlayAccount(page: Page, config: ShipConfig, o: AcrossOpts, cache: AccountsCache, file: string,
|
||||
nav: (plan: NavStep[], ms?: number) => Promise<NavResult>, quick: number, stop: Stop): Promise<{ nav: NavResult; plan: NavStep[] }> {
|
||||
const say = o.say, bases = o.bases ?? NAV_BASES, pkg = config.play?.packageName, want = config.play?.developerAccount;
|
||||
const planFor = (id?: string) => navPlan(o.form, id ? { ...config, play: { ...config.play!, developerId: id } } : config, bases);
|
||||
const go = async (id: string, account?: string) => {
|
||||
const plan = planFor(id), r = await nav(plan);
|
||||
if (r.ok && pkg) rememberPlay(pkg, { developerId: id, ...(account ? { account } : {}) }, file);
|
||||
return { nav: r, plan };
|
||||
};
|
||||
const known = config.play?.developerId ?? (pkg ? cache.play[pkg]?.developerId : undefined);
|
||||
if (known) { say(`creating the app in developer account ${known}${config.play?.developerId ? ' (play.developerId)' : ` (remembered in ${file})`}`); return go(known, pkg ? cache.play[pkg]?.account : undefined); }
|
||||
const all = await playAccounts(page, bases.play, quick, stop);
|
||||
const list = all.map(a => a.name ? `${a.name} (${a.id})` : a.id).join(', ');
|
||||
const stopHere = (why: string) => ({ nav: { ok: false, steps: [], failed: 'the developer account', why, ...(all.length ? { candidates: all.map(a => a.name || a.id) } : {}) } as NavResult, plan: planFor() });
|
||||
if (want) {
|
||||
const hits = all.filter(a => a.name && sameName(a.name, want));
|
||||
if (hits.length === 1) { say(`creating the app in developer account "${hits[0]!.name}" (play.developerAccount)`); return go(hits[0]!.id, hits[0]!.name); }
|
||||
return stopHere(hits.length ? `more than one developer account is named "${want}" (${list}): set play.developerId`
|
||||
: `no developer account named "${want}" (play.developerAccount) on the chooser${all.length ? `: ${list}` : ''}. Set play.developerAccount to one of them, or play.developerId`);
|
||||
}
|
||||
if (all.length === 1) { say(`this Google login has one developer account: ${all[0]!.name || all[0]!.id}`); return go(all[0]!.id, all[0]!.name || undefined); }
|
||||
if (all.length > 1) return stopHere(`this Google login sees ${all.length} developer accounts (${list}): set play.developerAccount (the name) or play.developerId to pick the one for the new app`);
|
||||
return stopHere('could not read the developer accounts on the "Choose a developer account" page: set play.developerId (or play.developerAccount)');
|
||||
}
|
||||
|
||||
async function across(page: Page, o: AcrossOpts): Promise<{ nav: NavResult; plan: NavStep[] }> {
|
||||
const config = withAccountIds(o.config, o.env), file = o.file ?? accountsFile(), cache = readAccounts(file);
|
||||
const bases = o.bases ?? NAV_BASES, say = o.say;
|
||||
|
|
@ -201,6 +237,7 @@ async function across(page: Page, o: AcrossOpts): Promise<{ nav: NavResult; plan
|
|||
const store = o.form.startsWith('play-') ? 'play' : 'apple';
|
||||
const quick = Math.min(o.navMs, 8000);
|
||||
|
||||
if (store === 'play' && o.form === 'play-app-record') return pickPlayAccount(page, config, o, cache, file, nav, quick, stop);
|
||||
if (store === 'play') {
|
||||
const pkg = config.play?.packageName;
|
||||
const planFor = (id?: string) => navPlan(o.form, id ? { ...config, play: { ...config.play!, developerId: id } } : config, bases);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
// storebound console fill <form> --dry [--json] the answers and the step-by-step guidance; opens no browser
|
||||
// storebound console fill <form> [--store apple|play] [--json] [--profile <dir>]
|
||||
// Forms: apple-app-record, apple-age-rating (guide only: `storebound apple appinfo` sets it), apple-app-privacy,
|
||||
// play-content-rating, play-target-audience. Answers come from the config only (cli/lib/console-answers.ts); anything
|
||||
// play-app-record (Play Console's Create app form: the Play Developer API cannot create apps), play-content-rating,
|
||||
// play-target-audience. Answers come from the config only (cli/lib/console-answers.ts); anything
|
||||
// it does not prove stays EMPTY and highlighted (AGENTS.md rule 5).
|
||||
// Safety: storebound never types passwords, never touches sign-in pages (it waits while the owner signs in), never reads
|
||||
// cookies or storage, and never clicks Save / Submit / Publish / Create / Next: every click goes through safeClick and
|
||||
|
|
@ -28,7 +29,7 @@ import { join } from 'node:path';
|
|||
import type { Ctx } from '../lib/ctx';
|
||||
import { type Answer, type ConsoleResult, consoleResult, DISCLAIMER, FORM_IDS, type FormId, fillValue, formMeta, isForm, valueText } from '../lib/console-answers';
|
||||
import type { ShipConfig } from '../lib/config';
|
||||
import { consoleReached, type FieldDef, type FormDef, formDef, FORM_OPENERS, forbiddenControl, hasToken, isSignInText, isSignInUrl, type Name, navAllowed, type NavBases, type NavStep, navPlan } from '../lib/console-forms';
|
||||
import { ALL_APPS, consoleReached, CREATE_FORM_FIELD, createAppAllowed, type FieldDef, type FormDef, formDef, FORM_OPENERS, forbiddenControl, hasToken, isSignInText, isSignInUrl, type Name, navAllowed, type NavBases, type NavStep, navPlan } from '../lib/console-forms';
|
||||
import { log, printJson, warn } from '../lib/log';
|
||||
import { openAcross, withAccountIds } from './accounts';
|
||||
import { type ConsoleBrowser, openConsoleBrowser } from './session';
|
||||
|
|
@ -145,16 +146,21 @@ async function setField(r: Resolved, v: string | boolean): Promise<boolean> {
|
|||
const exact = labels.indexOf(want);
|
||||
if (exact >= 0) return exact;
|
||||
const near = labels.map((l, i) => [l, i] as const).filter(([l]) => l.endsWith(` - ${want}`) || l.endsWith(`(${want})`) || l.includes(want));
|
||||
return near.length === 1 ? near[0]![1] : -1;
|
||||
if (near.length === 1) return near[0]![1];
|
||||
// a Play language ("English (United States) – en-US") in a console of another UI language: by its code suffix
|
||||
const code = /\s[–-]\s([A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,4})?)$/.exec(want)?.[1];
|
||||
if (!code) return -1;
|
||||
const byCode = labels.map((l, i) => [l, i] as const).filter(([l]) => l.endsWith(` – ${code}`) || l.endsWith(` - ${code}`));
|
||||
return byCode.length === 1 ? byCode[0]![1] : -1;
|
||||
}, String(v));
|
||||
if (idx < 0) return false;
|
||||
await r.loc.selectOption({ index: idx });
|
||||
return true;
|
||||
}
|
||||
|
||||
async function mark(r: Resolved): Promise<void> {
|
||||
if (r.loc) return highlight(r.loc);
|
||||
for (const o of Object.values(r.options ?? {})) await highlight(o);
|
||||
async function mark(r: Resolved, text = CHECK): Promise<void> {
|
||||
if (r.loc) return highlight(r.loc, text);
|
||||
for (const o of Object.values(r.options ?? {})) await highlight(o, text);
|
||||
}
|
||||
|
||||
export interface FillStep {
|
||||
|
|
@ -197,8 +203,10 @@ export async function fillPage(page: Page, def: FormDef, answers: Answer[], done
|
|||
if (!r.ok) continue;
|
||||
const a = byId.get(r.field.id);
|
||||
if (!a) continue;
|
||||
// an agreement is never ticked, whatever the answer says: highlighted for the owner
|
||||
if (r.field.agreement || a.agreement) { await mark(r, 'storebound: you agree to this, never ticked'); highlighted.push(a.id); continue; }
|
||||
const set = a.certain && a.value !== null ? await setField(r, a.value) : false;
|
||||
if (set) filled.push(a.id); else { await mark(r); highlighted.push(a.id); }
|
||||
if (set) { filled.push(a.id); if (a.ownerCheck) await mark(r, 'storebound: owner check'); } else { await mark(r); highlighted.push(a.id); }
|
||||
}
|
||||
done.add(i);
|
||||
return { section: i, title: sec.title, filled, highlighted, missing, fallback: false };
|
||||
|
|
@ -251,13 +259,27 @@ export async function realRole(loc: Locator): Promise<string> {
|
|||
* so (the click gate stays absolute: never Save / Submit / Publish / Create / Send / Next ...; only a link named exactly
|
||||
* Start / Manage / Başla / Yönet is let through). Every navigation click goes through here.
|
||||
*/
|
||||
export async function navClick(loc: Locator): Promise<{ clicked: boolean; name: string }> {
|
||||
export async function navClick(loc: Locator, createApp = false): Promise<{ clicked: boolean; name: string }> {
|
||||
const name = await accName(loc), role = await realRole(loc);
|
||||
if (!navAllowed(name, role)) { warn(TAG, `not clicking "${name}" while opening the form: storebound never presses save, submit, publish, next or similar`); return { clicked: false, name }; }
|
||||
if (createApp ? !await createAppHere(loc, name, role) : !navAllowed(name, role)) { warn(TAG, `not clicking "${name}" while opening the form: storebound never presses save, submit, publish, next or similar`); return { clicked: false, name }; }
|
||||
await loc.click();
|
||||
return { clicked: true, name };
|
||||
}
|
||||
|
||||
/**
|
||||
* The Create app opener check (createAppAllowed) with what the page shows now: the app list (an All apps / Home heading
|
||||
* or an /app-list URL), no Create app form open (no App name field), and the control not inside a form or dialog.
|
||||
*/
|
||||
export async function createAppHere(loc: Locator, name: string, role: string): Promise<boolean> {
|
||||
const page: Page = loc.page();
|
||||
const inForm: boolean = await loc.evaluate((el: any) => !!el.closest('form, [role="form"], [role="dialog"], dialog'));
|
||||
const formOpen = (await findAny(page, ['textbox'], CREATE_FORM_FIELD)).state !== 'none';
|
||||
let appList = false;
|
||||
try { appList = /\/app-list(?:[/?#]|$)/.test(new URL(page.url()).pathname); } catch { /* about:blank */ }
|
||||
if (!appList) for (const n of ALL_APPS) if (await vis(page.getByRole('heading', nameOpts(n))).count() > 0) { appList = true; break; }
|
||||
return createAppAllowed(name, role, { appList, formOpen, inForm });
|
||||
}
|
||||
|
||||
export interface NavResult {
|
||||
ok: boolean;
|
||||
/** Labels of the steps done (["already open"] when the form was already on the page). */
|
||||
|
|
@ -400,7 +422,7 @@ export async function navigate(page: Page, plan: NavStep[], opts: NavOpts = {}):
|
|||
const f = await poll(s.optional ? Math.min(ms, 2000) : ms, async () => { const r = await findAny(page, s.roles, s.names); return r.state === 'none' ? null : r; }, stop);
|
||||
if (!f) { if (s.optional) { say(' (not on this page, skipped)'); continue; } return fail(s, 'not found'); }
|
||||
if (f.state !== 'ok') return fail(s, 'more than one match');
|
||||
const c = await navClick(f.loc);
|
||||
const c = await navClick(f.loc, !!s.createApp);
|
||||
if (!c.clicked) return fail(s, `refused to click "${c.name}"`);
|
||||
} else if (s.kind === 'pickApp') {
|
||||
if (!s.tokens.length && !s.name) return fail(s, 'no bundle id, package name or app name in the config');
|
||||
|
|
@ -451,7 +473,10 @@ export async function resumeAt(page: Page, plan: NavStep[]): Promise<number | nu
|
|||
|
||||
function printText(res: ConsoleResult): void {
|
||||
console.log(`${res.title}\n${res.url}\n`);
|
||||
for (const a of res.answers) console.log(` ${a.certain ? '[ok] ' : '[check]'} ${a.label}: ${valueText(a)} (${a.source})${a.certain || !a.note ? '' : `\n ${a.note}`}`);
|
||||
for (const a of res.answers) {
|
||||
const tag = a.agreement ? '[you] ' : a.ownerCheck ? '[owner]' : a.certain ? '[ok] ' : '[check]';
|
||||
console.log(` ${tag} ${a.label}: ${a.agreement ? '(you tick it; storebound never does)' : valueText(a)} (${a.source})${(a.certain && !a.ownerCheck) || !a.note ? '' : `\n ${a.note}`}`);
|
||||
}
|
||||
console.log(`\n${res.uncertain} answer(s) to check yourself.\n\nSteps:\n${res.guidance.map(g => ` - ${g}`).join('\n')}`);
|
||||
}
|
||||
|
||||
|
|
@ -587,10 +612,12 @@ export async function fillSession(b: ConsoleBrowser, o: FillSessionOpts): Promis
|
|||
// refused / ambiguous: not retried on this page; "not found" / "did not appear" is retried when the step shows up
|
||||
if (!/^(not found|did not appear)$/.test(r.why ?? '')) tried = `${(active() ?? b.page).url()}#${plan.findIndex(s => s.label === r.failed)}`;
|
||||
warn(TAG, `could not open the form by itself at step "${r.failed}" (${r.why}). Open it yourself; storebound keeps watching and fills it when it appears:`);
|
||||
if (r.candidates) say(`apps that match: ${r.candidates.join(' | ')} (set apple.appId / play.packageName in the config to pick one)`);
|
||||
if (r.candidates) say(r.failed === 'the developer account' ? `developer accounts: ${r.candidates.join(' | ')} (set play.developerAccount or play.developerId to pick one)`
|
||||
: `apps that match: ${r.candidates.join(' | ')} (set apple.appId / play.packageName in the config to pick one)`);
|
||||
if (first) for (const s of meta.open) say(`open the form: ${s}`);
|
||||
};
|
||||
|
||||
for (const n of meta.notes ?? []) say(n);
|
||||
await b.page.goto(startUrl ?? meta.url).catch(() => { /* the owner can navigate */ });
|
||||
await signedIn();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue