Open in Google Play Console deep-links the app: Play developer id per credential profile (accounts play-developer, desktop Accounts), shared playAppUrl builder for desktop, CLI and watch; developer chooser instead of the console root

This commit is contained in:
CRTkafa 2026-10-23 09:20:35 +08:00
parent 7c769c18f4
commit 4a74989a95
33 changed files with 311 additions and 40 deletions

View file

@ -9,6 +9,8 @@
export const ASC = 'https://appstoreconnect.apple.com';
export const PLAY_CONSOLE = 'https://play.google.com/console';
/** The developer account chooser: the fallback when no developer id is known (never the bare console root). */
export const PLAY_DEVELOPERS = `${PLAY_CONSOLE}/u/0/developers`;
export interface ConsoleIds { appleAppId?: string | null; playDeveloperId?: string | null; playAppId?: string | null }
@ -94,7 +96,7 @@ export function consoleUrl(page: ConsolePage, ids: ConsoleIds = current): string
return app ? `${ASC}/apps/${app}${p.path}` : `${ASC}/apps`;
}
const dev = id(ids.playDeveloperId ?? current.playDeveloperId), app = id(ids.playAppId ?? current.playAppId);
if (!dev) return PLAY_CONSOLE;
if (!dev) return PLAY_DEVELOPERS;
const base = `${PLAY_CONSOLE}/u/0/developers/${dev}`;
if (p.scope === 'developer') return `${base}/${p.path}`;
return app ? `${base}/app/${app}/${p.path}` : `${base}/app-list`;
@ -103,7 +105,22 @@ export function consoleUrl(page: ConsolePage, ids: ConsoleIds = current): string
/** True when the URL is the page itself (ids known), false when it is a fallback (app list, chooser). */
export function consoleUrlExact(page: ConsolePage, ids: ConsoleIds = current): boolean {
const u = consoleUrl(page, ids);
return u !== PLAY_CONSOLE && !(CONSOLE_PAGES[page].scope === 'app' && (u === `${ASC}/apps` || u.endsWith('/app-list')));
return u !== PLAY_DEVELOPERS && !(CONSOLE_PAGES[page].scope === 'app' && (u === `${ASC}/apps` || u.endsWith('/app-list')));
}
/**
* "Open in Google Play Console" for one app: its dashboard when the developer id and the console's app id are known,
* else that developer's app list (searchable, the package name finds the row), else the developer chooser. Every
* desktop / CLI / watch link to an app's Play page goes through here.
*/
export function playAppUrl(ids: { developerId?: string | null; appId?: string | null }): string {
return consoleUrl('play.dashboard', { playDeveloperId: ids.developerId ?? null, playAppId: ids.appId ?? null, appleAppId: null });
}
/** The first candidate that is a console id (digits); the order of the sources is in play-ids.ts. */
export function pickConsoleId(...candidates: (string | null | undefined)[]): string | null {
for (const c of candidates) if (c && /^\d{1,25}$/.test(c.trim())) return c.trim();
return null;
}
/** "Readable > path: https://..." (the path suffix, e.g. "> Copy Cloud Storage URI", is appended to the label). */