oclaw/uds-auth/scripts/bundle-qrcode.mjs
oliver 3ba4461566
Some checks are pending
ci / test (push) Waiting to run
ci / test-postgresql (push) Waiting to run
Ship uds-auth offline tgz without npm qrcode fetch (0.2.20).
Bundle qrcode SVG into lib/qrcode-bundled.cjs and drop the runtime dependency so Desktop field installs work without registry.npmjs.org.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-10 20:06:40 +08:00

35 lines
972 B
JavaScript

/**
* Bundle `qrcode` (SVG path) into lib/qrcode-bundled.cjs so Desktop tgz
* installs need no npm registry fetch for dependencies.
*
* Usage: bun run scripts/bundle-qrcode.mjs
*/
import { mkdirSync, writeFileSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
const entry = join(root, 'scripts', 'qrcode-entry.cjs')
const out = join(root, 'lib', 'qrcode-bundled.cjs')
mkdirSync(dirname(out), { recursive: true })
const result = await Bun.build({
entrypoints: [entry],
outfile: out,
target: 'node',
format: 'cjs',
sourcemap: 'none',
minify: false,
})
if (!result.success) {
console.error(result.logs)
throw new Error('bundle qrcode failed')
}
// Bun may write via outfile; also ensure content if outputs differ.
if (result.outputs[0]) {
writeFileSync(out, await result.outputs[0].text(), 'utf8')
}
console.log(`wrote ${out}`)