crt-ship 0.1.0: CLI, Claude Code skills and templates for shipping mobile games to Google Play and the App Store
This commit is contained in:
commit
ecb3dc3dc3
64 changed files with 4509 additions and 0 deletions
23
cli/shots/browser.ts
Normal file
23
cli/shots/browser.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Playwright is not a dependency of crt-ship: it is resolved from the project (or the crt-ship folder), so a project
|
||||
// that never renders screenshots never downloads a browser. Launch order: Playwright's own Chromium, then an installed
|
||||
// Google Chrome (channel "chrome"), so `bunx playwright install chromium` is optional when Chrome is there.
|
||||
import { join } from 'node:path';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async function chromium(root: string): Promise<any> {
|
||||
for (const base of [root, join(import.meta.dir, '../..')]) {
|
||||
try {
|
||||
const p = Bun.resolveSync('playwright', base);
|
||||
return (await import(p)).chromium;
|
||||
} catch { /* next */ }
|
||||
}
|
||||
throw new Error('playwright not found: in your project run `bun add -d playwright` (and `bunx playwright install chromium` if Google Chrome is not installed)');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export async function launch(root: string, opts: Record<string, unknown>): Promise<any> {
|
||||
const c = await chromium(root);
|
||||
try { return await c.launch(opts); } catch (e) {
|
||||
try { return await c.launch({ ...opts, channel: 'chrome' }); } catch { throw e; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue