fix cli host
This commit is contained in:
parent
8fa7dd9993
commit
eaae9ae993
|
|
@ -20,6 +20,7 @@
|
||||||
"cli:build": "bun run scripts/build.ts",
|
"cli:build": "bun run scripts/build.ts",
|
||||||
"cli:build:all": "bun run scripts/build.ts --all",
|
"cli:build:all": "bun run scripts/build.ts --all",
|
||||||
"cli:install": "bun cli:build && sudo cp dist/toes /usr/local/bin",
|
"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",
|
"cli:uninstall": "sudo rm /usr/local/bin",
|
||||||
"deploy": "./scripts/deploy.sh",
|
"deploy": "./scripts/deploy.sh",
|
||||||
"dev": "rm pub/client/index.js && bun run --hot src/server/index.tsx",
|
"dev": "rm pub/client/index.js && bun run --hot src/server/index.tsx",
|
||||||
|
|
|
||||||
|
|
@ -18,19 +18,14 @@ export const STATE_ICONS: Record<string, string> = {
|
||||||
export async function configShow() {
|
export async function configShow() {
|
||||||
console.log(`Host: ${color.bold(HOST)}`)
|
console.log(`Host: ${color.bold(HOST)}`)
|
||||||
|
|
||||||
const source = process.env.TOES_URL
|
const source = process.env.TOES_URL ? 'TOES_URL' : process.env.DEV ? 'DEV' : '(default)'
|
||||||
? 'TOES_URL'
|
|
||||||
: process.env.NODE_ENV === 'production'
|
|
||||||
? '(production)'
|
|
||||||
: '(development)'
|
|
||||||
|
|
||||||
console.log(`Source: ${color.gray(source)}`)
|
console.log(`Source: ${color.gray(source)}`)
|
||||||
|
|
||||||
if (process.env.TOES_URL) {
|
if (process.env.TOES_URL) {
|
||||||
console.log(` TOES_URL=${process.env.TOES_URL}`)
|
console.log(` TOES_URL=${process.env.TOES_URL}`)
|
||||||
}
|
}
|
||||||
if (process.env.NODE_ENV) {
|
if (process.env.DEV) {
|
||||||
console.log(` NODE_ENV=${process.env.NODE_ENV}`)
|
console.log(` DEV=${process.env.DEV}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,6 @@
|
||||||
import type { Manifest } from '@types'
|
import type { Manifest } from '@types'
|
||||||
|
|
||||||
function getDefaultHost(): string {
|
const DEFAULT_HOST = process.env.DEV ? 'http://localhost:3000' : 'http://toes.local'
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
return `http://toes.local:${process.env.PORT ?? 80}`
|
|
||||||
}
|
|
||||||
return `http://localhost:${process.env.PORT ?? 3000}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalizeUrl = (url: string) =>
|
const normalizeUrl = (url: string) =>
|
||||||
url.startsWith('http://') || url.startsWith('https://') ? url : `http://${url}`
|
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
|
export const HOST = process.env.TOES_URL
|
||||||
? normalizeUrl(process.env.TOES_URL)
|
? normalizeUrl(process.env.TOES_URL)
|
||||||
: getDefaultHost()
|
: DEFAULT_HOST
|
||||||
|
|
||||||
export function makeUrl(path: string): string {
|
export function makeUrl(path: string): string {
|
||||||
return `${HOST}${path}`
|
return `${HOST}${path}`
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user