Workers P2: Prüfstand mit Skript-API und Playwright-Abnahme

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-18 04:55:51 +00:00
1 parent 0b78379b9b
commit d67f8cc471
6 files changed
+896

No files matched your search

+46
View File
@@ -0,0 +1,46 @@
// Baut den Prüfstand: node scripts/workers-harness/build.mjs <outDir>
// entry.jsx -> harness.js + harness.css (esbuild, Entwicklungsmodus, damit StrictMode wie in der Entwicklung zweimal einhängt), dazu index.html.
// outDir muss ein neuer oder leerer Ordner unter dem Temp-Ordner (TMPDIR, sonst /tmp) oder unter .superpowers/ im Repo sein.
// Die Schrift /fonts/* bleibt außen vor: der Server von shot.cjs liefert sie aus public/fonts.
import esbuild from 'esbuild'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const here = path.dirname(fileURLToPath(import.meta.url))
const repo = path.resolve(here, '../..')
const arg = process.argv[2]
if (!arg) {
console.error('usage: node scripts/workers-harness/build.mjs <outDir>')
process.exit(2)
}
const out = path.resolve(arg)
const tmp = path.resolve(process.env.TMPDIR || os.tmpdir())
const allowed = [tmp, path.join(repo, '.superpowers')]
if (!allowed.some((base) => out.startsWith(base + path.sep))) {
console.error(`refusing: outDir must be below ${allowed.join(' or ')}`)
process.exit(2)
}
if (fs.existsSync(out) && fs.readdirSync(out).length > 0) {
console.error('refusing: outDir must be new or empty')
process.exit(2)
}
fs.mkdirSync(out, { recursive: true })
const result = await esbuild.build({
entryPoints: [path.join(here, 'entry.jsx')],
outfile: path.join(out, 'harness.js'),
bundle: true,
format: 'iife',
platform: 'browser',
jsx: 'automatic',
external: ['/fonts/*'],
define: { 'process.env.NODE_ENV': '"development"' },
logLevel: 'warning',
metafile: true,
})
fs.copyFileSync(path.join(here, 'index.html'), path.join(out, 'index.html'))
const sizes = Object.entries(result.metafile.outputs).map(([file, info]) => `${path.basename(file)} ${info.bytes}`)
console.log(`built ${sizes.join(', ')} -> ${out}`)