fix cli host

This commit is contained in:
Chris Wanstrath 2026-02-09 09:38:59 -08:00
parent 8fa7dd9993
commit eaae9ae993
3 changed files with 6 additions and 15 deletions

View File

@ -20,6 +20,7 @@
"cli:build": "bun run scripts/build.ts",
"cli:build:all": "bun run scripts/build.ts --all",
"cli:install": "bun cli:build && sudo cp dist/toes /usr/local/bin",
"cli:link": "ln -sf $(pwd)/src/cli/index.ts ~/.bun/bin/toes",
"cli:uninstall": "sudo rm /usr/local/bin",
"deploy": "./scripts/deploy.sh",
"dev": "rm pub/client/index.js && bun run --hot src/server/index.tsx",

View File

@ -18,19 +18,14 @@ export const STATE_ICONS: Record<string, string> = {
export async function configShow() {
console.log(`Host: ${color.bold(HOST)}`)
const source = process.env.TOES_URL
? 'TOES_URL'
: process.env.NODE_ENV === 'production'
? '(production)'
: '(development)'
const source = process.env.TOES_URL ? 'TOES_URL' : process.env.DEV ? 'DEV' : '(default)'
console.log(`Source: ${color.gray(source)}`)
if (process.env.TOES_URL) {
console.log(` TOES_URL=${process.env.TOES_URL}`)
}
if (process.env.NODE_ENV) {
console.log(` NODE_ENV=${process.env.NODE_ENV}`)
if (process.env.DEV) {
console.log(` DEV=${process.env.DEV}`)
}
}

View File

@ -1,11 +1,6 @@
import type { Manifest } from '@types'
function getDefaultHost(): string {
if (process.env.NODE_ENV === 'production') {
return `http://toes.local:${process.env.PORT ?? 80}`
}
return `http://localhost:${process.env.PORT ?? 3000}`
}
const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : 'http://toes.local'
const normalizeUrl = (url: string) =>
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`
@ -21,7 +16,7 @@ function tryParseError(text: string): string | undefined {
export const HOST = process.env.TOES_URL
? normalizeUrl(process.env.TOES_URL)
: getDefaultHost()
: DEFAULT_HOST
export function makeUrl(path: string): string {
return `${HOST}${path}`