validate: removed-from-sale IAPs are no blockers; shots capture --device landscape (Mac / Chromebook frames from a web build); playwright lookup says why each place failed
This commit is contained in:
parent
cdd9321794
commit
d0f568ebc2
13 changed files with 230 additions and 48 deletions
|
|
@ -30,24 +30,30 @@ import * as rt from '../lib/rt';
|
|||
class PlaywrightShapeError extends Error {}
|
||||
|
||||
async function chromium(root: string): Promise<any> {
|
||||
// why each place failed, for the error: a swallowed import error read as "not found" (a Mac run had it installed)
|
||||
const tried: string[] = [];
|
||||
for (const base of [root, rt.packageRoot()]) {
|
||||
let p = '';
|
||||
try {
|
||||
const p = rt.resolveFrom('playwright', base);
|
||||
p = rt.resolveFrom('playwright', base);
|
||||
// only an installed copy (node_modules): outside a project Bun auto-installs the newest playwright into its global
|
||||
// cache (~/.bun/install/cache), whose browser build was never downloaded ("headless shell: not installed" on
|
||||
// Linux CI, where no Google Chrome hides it); storebound's own copy is next
|
||||
if (!isInstalledPackage(p)) continue;
|
||||
if (!isInstalledPackage(p)) { tried.push(`${p}: not an installed copy (Bun's global cache)`); continue; }
|
||||
// playwright's entry is CommonJS: depending on the runtime and version the ESM import puts chromium on the
|
||||
// namespace or only under default (a project's playwright 1.57 under a global Bun install gave undefined)
|
||||
const m = await rt.importPath(p);
|
||||
const c = m?.chromium ?? m?.default?.chromium;
|
||||
if (!c || typeof c.launch !== 'function') throw new PlaywrightShapeError(`playwright at ${p} has no chromium.launch (exports: ${Object.keys(m ?? {}).slice(0, 8).join(', ') || 'none'}${m?.default ? `; default: ${Object.keys(m.default).slice(0, 8).join(', ')}` : ''})`);
|
||||
return c;
|
||||
} catch (e) { if (e instanceof PlaywrightShapeError) throw e; /* next */ }
|
||||
} catch (e) {
|
||||
if (e instanceof PlaywrightShapeError) throw e;
|
||||
tried.push(p ? `${p}: ${(e as Error).message.split('\n')[0]}` : `not resolvable from ${base}`);
|
||||
}
|
||||
}
|
||||
// only reached in the compiled sidecar: the bundled playwright-core (not a runtime dependency of the npm package)
|
||||
if (compiled()) return (await import('playwright-core')).chromium;
|
||||
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)');
|
||||
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)\n ${tried.join('\n ')}`);
|
||||
}
|
||||
|
||||
/** A resolved module path inside a node_modules folder (not one of Bun's auto-installs from its global cache). */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue