diff --git a/README.md b/README.md index 4509ce9..a2fd047 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,40 @@ And to make sure DNS is working: bun dev open localhost:3000 +## Production Dev + +Make sure you bundle the JS: + + bun run bundle + +If you want to test (or run) production with DNS features, use `NO_DNS`: + + env NO_DNS=1 NODE_ENV=production bun start + +You can also use the package commands: + + # run without DNS + bun prod-nodns + # run normally + bun prod + ## Commands -Commands can return one of three types: +Commands can return one of these types: - `string` - `{ error: string }` - `{ html: string }` +- `{ text: string }` They can also `throw` to display an error. +Additionally, you can return JS that gets immediately run in the browser using `script:`: + +- `{ html: string, script: string }` +- `{ text: string, script: string }` +- `{ script: string }` + ## Fonts Use this to examine what's inside the C64 .woff2 font file in public/vendor: @@ -60,7 +84,7 @@ https://wakamaifondue.com/ - [ ] "project"-based rehaul - [ ] game/bin/www cartridges - [-] pico8-style games - - [x] init/update/draw + - [x] init/update/draw - [x] simple drawing api - [x] gamepad support - [ ] sounds diff --git a/package.json b/package.json index bbf48c7..cecc1b2 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "dev": "env BUN_HOT=1 bun --hot src/server.tsx", "start": "bun src/server.tsx", "prod": "env NODE_ENV=production bun src/server.tsx", + "prod-nodns": "env NO_DNS=1 NODE_ENV=production bun src/server.tsx", "build": "./scripts/build.sh", "runner": "env NODE_ENV=production bun run src/runner.ts", diff --git a/src/dns.ts b/src/dns.ts index 1c1ee13..225ed9c 100644 --- a/src/dns.ts +++ b/src/dns.ts @@ -17,6 +17,7 @@ const host = hostRaw.toString().trim() let dnsInit = false export async function initDNS() { + if (process.env.NO_DNS) return if (process.env.NODE_ENV !== "production") return if (!await expectShellCmd("avahi-publish")) return @@ -36,6 +37,7 @@ export async function initDNS() { } export function publishAppDNS(app: string) { + if (process.env.NO_DNS) return if (process.env.NODE_ENV !== "production") return if (!dnsInit) throw "publishAppDNS() must be called after initDNS()"