Compare commits
4 Commits
6c493a667d
...
243304780a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243304780a | ||
|
|
2c2bcfda39 | ||
|
|
f49dad32b0 | ||
|
|
8706c55585 |
26
README.md
26
README.md
|
|
@ -26,16 +26,40 @@ And to make sure DNS is working:
|
||||||
bun dev
|
bun dev
|
||||||
open localhost:3000
|
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
|
||||||
|
|
||||||
Commands can return one of three types:
|
Commands can return one of these types:
|
||||||
|
|
||||||
- `string`
|
- `string`
|
||||||
- `{ error: string }`
|
- `{ error: string }`
|
||||||
- `{ html: string }`
|
- `{ html: string }`
|
||||||
|
- `{ text: string }`
|
||||||
|
|
||||||
They can also `throw` to display an error.
|
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
|
## Fonts
|
||||||
|
|
||||||
Use this to examine what's inside the C64 .woff2 font file in public/vendor:
|
Use this to examine what's inside the C64 .woff2 font file in public/vendor:
|
||||||
|
|
|
||||||
21
bin/env.ts
21
bin/env.ts
|
|
@ -7,14 +7,19 @@ import { highlightToHTML } from "../lib/highlight"
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
return highlightToHTML([
|
return highlightToHTML([
|
||||||
`NODE_ENV=${process.env.NODE_ENV || "(none)"}`,
|
`NODE_ENV=${valueOrNone(process.env.NODE_ENV)}`,
|
||||||
`BUN_HOT=${process.env.BUN_HOT || "(none)"}`,
|
`NO_DNS=${valueOrNone(process.env.NO_DNS)}`,
|
||||||
`PORT=${process.env.PORT || "(none)"}`,
|
`BUN_HOT=${valueOrNone(process.env.BUN_HOT)}`,
|
||||||
`USER=${process.env.USER || "(none)"}`,
|
`PORT=${valueOrNone(process.env.PORT)}`,
|
||||||
`PWD=${process.env.PWD || "(none)"}`,
|
`USER=${valueOrNone(process.env.USER)}`,
|
||||||
|
`PWD=${valueOrNone(process.env.PWD)}`,
|
||||||
`NOSE_STARTED=${NOSE_STARTED}`,
|
`NOSE_STARTED=${NOSE_STARTED}`,
|
||||||
`NOSE_SYS_BIN=${NOSE_SYS_BIN}`,
|
`NOSE_SYS_BIN="${NOSE_SYS_BIN}"`,
|
||||||
`NOSE_DIR=${NOSE_DIR}`,
|
`NOSE_DIR="${NOSE_DIR}"`,
|
||||||
`GIT_SHA=${GIT_SHA.slice(0, 8)}`,
|
`GIT_SHA="${GIT_SHA}"`,
|
||||||
].join("\n"))
|
].join("\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function valueOrNone(val: string | undefined): string {
|
||||||
|
return val ? `"${val}"` : ""
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ export default async function () {
|
||||||
return { error: "Can only update in production." }
|
return { error: "Can only update in production." }
|
||||||
}
|
}
|
||||||
|
|
||||||
const { stdout } = await $`cd .. && git pull`.quiet()
|
const { stdout } = await $`git pull`.quiet()
|
||||||
const out = stdout.toString()
|
const out = stdout.toString()
|
||||||
|
|
||||||
if (/up to date/.test(out)) {
|
if (/up to date/.test(out)) {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
"dev": "env BUN_HOT=1 bun --hot src/server.tsx",
|
"dev": "env BUN_HOT=1 bun --hot src/server.tsx",
|
||||||
"start": "bun src/server.tsx",
|
"start": "bun src/server.tsx",
|
||||||
"prod": "env NODE_ENV=production 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",
|
"build": "./scripts/build.sh",
|
||||||
|
|
||||||
"runner": "env NODE_ENV=production bun run src/runner.ts",
|
"runner": "env NODE_ENV=production bun run src/runner.ts",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ const host = hostRaw.toString().trim()
|
||||||
let dnsInit = false
|
let dnsInit = false
|
||||||
|
|
||||||
export async function initDNS() {
|
export async function initDNS() {
|
||||||
|
if (process.env.NO_DNS) return
|
||||||
if (process.env.NODE_ENV !== "production") return
|
if (process.env.NODE_ENV !== "production") return
|
||||||
if (!await expectShellCmd("avahi-publish")) return
|
if (!await expectShellCmd("avahi-publish")) return
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ export async function initDNS() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function publishAppDNS(app: string) {
|
export function publishAppDNS(app: string) {
|
||||||
|
if (process.env.NO_DNS) return
|
||||||
if (process.env.NODE_ENV !== "production") return
|
if (process.env.NODE_ENV !== "production") return
|
||||||
if (!dnsInit) throw "publishAppDNS() must be called after initDNS()"
|
if (!dnsInit) throw "publishAppDNS() must be called after initDNS()"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user