diff --git a/package.json b/package.json index fbd482d..8992404 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cli/commands/manage.ts b/src/cli/commands/manage.ts index 6a07ec9..1f41cc2 100644 --- a/src/cli/commands/manage.ts +++ b/src/cli/commands/manage.ts @@ -18,19 +18,14 @@ export const STATE_ICONS: Record = { 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}`) } } diff --git a/src/cli/http.ts b/src/cli/http.ts index c71f83a..c879258 100644 --- a/src/cli/http.ts +++ b/src/cli/http.ts @@ -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}`