Files
buuh/packages/bankai/cli.js
T
Bendik Aagaard LynghaugandClaude Fable 5 ce1ec9e4a9 rebrand: buuh — a friendly public fork under the uhhm org
Packages renamed to the @uhhm scope (@uhhm/buuh, @uhhm/buuh-html,
@uhhm/buuh-component, @uhhm/buuh-devtools, @uhhm/buuh-migrate,
@uhhm/bankai). Scoping is load-bearing twice over: npm routes registries
per scope so @uhhm/* resolves against project.uhhm.no while everything
else stays on npmjs, and it means this fork never squats upstream's
names anywhere. The codemod now migrates choo v7 apps to the @uhhm
names. README rewritten with the fork framing and full upstream credit;
the choojs RFC moves to docs/upstream-rfc-draft.md, in the drawer for if
this work ever goes home. API unchanged — choo() is still choo().

Also: Gitea Actions CI + release workflows (npm publish to the uhhm
registry on tag push, CDN bundle uploaded as a generic package),
npm run bundle producing dist-cdn/buuh.js (the whole framework as one
minified ES module for import-map use), docs/publishing.md explaining
what Gitea Packages is (a real npm registry) and is not (a CDN — serve
the bundle from a static host with module-safe MIME instead), and
onload.js constructing window.MutationObserver to match its own guard
(surfaced by smoke-testing the bundle outside a full browser).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014NgfSjHE11oFpoSnLVKLXd
2026-09-08 19:55:20 +02:00

67 lines
2.7 KiB
JavaScript
Executable File

#!/usr/bin/env node
// bankai <command> [entry] [options]
//
// bankai start <entry> dev server: Vite + HMR + streaming SSR
// bankai build <entry> production build (client bundle, manifest,
// service worker, precompression)
// bankai serve production server for a built app: static
// assets + 103 Early Hints + streaming SSR
// bankai inspect size report for the built output
//
// options: --port <n> --out <dir> --title <text>
// --prerender </,/about> (build: comma-separated routes)
// --h2 (serve: HTTP/2 + local cert, so
// browsers act on the Early Hints)
import { parseArgs } from 'node:util'
const { values, positionals } = parseArgs({
allowPositionals: true,
options: {
port: { type: 'string' },
out: { type: 'string', default: 'dist' },
title: { type: 'string', default: 'choo' },
prerender: { type: 'string' },
h2: { type: 'boolean', default: false }
}
})
const [command, entry] = positionals
const port = values.port ? Number(values.port) : 8080
try {
if (command === 'start') {
requireEntry(entry)
const { default: dev } = await import('./lib/dev.js')
const { origin } = await dev({ entry, port, title: values.title })
console.log(`bankai: dev server streaming on ${origin}`)
} else if (command === 'build') {
requireEntry(entry)
const { default: build } = await import('./lib/build.js')
const prerender = values.prerender ? values.prerender.split(',').map((r) => r.trim()).filter(Boolean) : []
const { outDir, compressed, prerendered } = await build({ entry, outDir: values.out, title: values.title, prerender })
const extra = prerendered.length ? `, ${prerendered.length} route(s) prerendered` : ''
console.log(`bankai: built to ${outDir} (${compressed} asset(s) precompressed${extra}) — bankai serve to run it`)
} else if (command === 'serve') {
const { default: serve } = await import('./lib/serve.js')
const { origin } = await serve({ outDir: values.out, port, h2: values.h2 })
console.log(`bankai: production server on ${origin}`)
} else if (command === 'inspect') {
const { default: inspect } = await import('./lib/inspect.js')
await inspect({ outDir: values.out })
} else {
console.log('usage: bankai <start|build|serve|inspect> [entry] [--port n] [--out dir] [--title text]')
process.exit(command ? 1 : 0)
}
} catch (err) {
console.error('bankai:', err.message)
process.exit(1)
}
function requireEntry (value) {
if (!value) {
console.error('bankai: an entry module is required, e.g. bankai start app.js')
process.exit(1)
}
}