Echte Seite WorkersPage im Prüfstand (Austausch-Module für Anmeldung, Mitarbeiterliste und Sitzungs-JWT), Skript-API mit Pult, Aktionen und Interessent samt Schaltern für 409, 400, Ausfall und Leerzustand, vier neue Szenarien (Freigabe, Interessent, Anhalten, Handy), jedes Szenario läuft für sich, und der Szenario Desktop bestätigt jetzt die Rückfrage vor dem Anhalten. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
65 lines
2.7 KiB
JavaScript
65 lines
2.7 KiB
JavaScript
// 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.
|
|
// Drei Module der App hängen an Appwrite (Anmeldung, Mitarbeiterliste, Sitzungs-JWT) und werden nur im Prüfstand ausgetauscht, damit die
|
|
// echte Seite WorkersPage (Reiter Hochhaus und Freigabe) samt PultList und ProspectPanel ohne Netz läuft: AuthContext -> stub-auth.js,
|
|
// useEmployees -> stub-employees.js, workersClient -> stub-client.js. Am Quelltext der App ändert das nichts.
|
|
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 STUBS = [
|
|
{ filter: /(^|\/)context\/AuthContext(\.jsx?)?$/, file: 'stub-auth.js' },
|
|
{ filter: /(^|\/)hooks\/useEmployees(\.jsx?)?$/, file: 'stub-employees.js' },
|
|
{ filter: /(^|\/)lib\/workersClient(\.jsx?)?$/, file: 'stub-client.js' },
|
|
]
|
|
const stubPlugin = {
|
|
name: 'harness-stubs',
|
|
setup(build) {
|
|
for (const stub of STUBS) {
|
|
build.onResolve({ filter: stub.filter }, () => ({ path: path.join(here, stub.file) }))
|
|
}
|
|
},
|
|
}
|
|
|
|
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/*'],
|
|
plugins: [stubPlugin],
|
|
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}`)
|