← Files Flows by plugin.spaceARCHIVED FILE

scripts/setup-capture.mjs

1.32 KB · Nov 30, 2026 · 00:17 UTC

↓ Download file

#!/usr/bin/env node
import { launcherCommand } from '../lib/node-runtime.mjs';
import { isEntrypoint } from '../lib/entrypoint.mjs';
import { prepareCaptureRuntime } from '../lib/capture-runtime.mjs';

export async function main(args = process.argv.slice(2)) {
  if (args.includes('--help')) { console.log(`Prepare Flows screenshot capture without changing the app dependencies.\n${launcherCommand('setup-capture')} [--install] [--project /app] [--runtime /dedicated/cache] [--channel chrome]\nWithout --install, checks only. With --install, downloads pinned Playwright into the user cache and Chromium only when needed.`); return; }
  const options = {};
  for (let i = 0; i < args.length; i++) {
    if (args[i] === '--install') { options.install = true; continue; }
    const key = { '--project': 'project', '--runtime': 'runtimeDirectory', '--channel': 'channel' }[args[i]];
    if (!key || !args[i + 1]) throw new Error('Invalid option. Use --help.');
    options[key] = args[++i];
  }
  const { runtime, channel } = await prepareCaptureRuntime({ ...options, onProgress: line => console.error(line) });
  console.log(JSON.stringify({ ready: true, runtime: runtime.directory, playwright: runtime.version, browser: channel }));
}
if (isEntrypoint(import.meta.url)) main().catch(error => { console.error(error.message); process.exitCode = 1; });

SHA-256: 9c390fcf24a24945d804bd58b2ed749c43dfd1ceca9f26baf1fd7f5d0fe2a8a2