diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7da7e5..68c8190 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,6 +44,9 @@ jobs: file katana-linux-x64 file katana-linux-arm64 + - name: Package modules directory + run: zip -r modules.zip modules + - name: Extract version from tag id: get_version run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT @@ -71,6 +74,7 @@ jobs: files: | katana-linux-x64 katana-linux-arm64 + modules.zip draft: false prerelease: false env: diff --git a/package.json b/package.json index 096f2b1..17e4f74 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "dev": "bun run src/cli.ts", "build:ui": "bun run src/ui/build.ts", - "build": "bun run build:ui && bun build --compile src/cli.ts --outfile bin/katana", + "build": "bun run build:ui && KATANA_COMPILED=true bun build --compile src/cli.ts --outfile bin/katana", "test": "bun test", "lint": "bunx biome check src/", "format": "bunx biome format --write src/" diff --git a/src/types/config.ts b/src/types/config.ts index 8f0aceb..c350c51 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,3 +1,4 @@ +import { isCompiled } from "@/utils/isCompiled" with { type: "macro" }; import { z } from "zod"; /** @@ -47,23 +48,43 @@ export type Config = z.infer; /** * Default configuration values */ -export const DEFAULT_CONFIG: Config = { - install_type: "local", - local_domain: "samurai.wtf", - dashboard_hostname: "katana", - paths: { - modules: "/opt/samurai/katana/modules", - data: "~/.local/share/katana", - certs: "~/.local/share/katana/certs", - state: "~/.local/share/katana/state.yml", - }, - proxy: { - http_port: 80, - https_port: 443, - bind_address: undefined, - }, - docker_network: "katana-net", -}; +export const DEFAULT_CONFIG: Config = ((compiled) => { + return compiled + ? { + install_type: "local", + local_domain: "samurai.wtf", + dashboard_hostname: "katana", + paths: { + modules: "/opt/katana/modules", + data: "~/.local/share/katana", + certs: "~/.local/share/katana/certs", + state: "~/.local/share/katana/state.yml", + }, + proxy: { + http_port: 80, + https_port: 443, + bind_address: undefined, + }, + docker_network: "katana-net", + } + : { + install_type: "local", + local_domain: "samurai.wtf", + dashboard_hostname: "katana", + paths: { + modules: "./modules", + data: "~/.local/share/katana", + certs: "~/.local/share/katana/certs", + state: "~/.local/share/katana/state.yml", + }, + proxy: { + http_port: 80, + https_port: 443, + bind_address: undefined, + }, + docker_network: "katana-net", + }; +})(isCompiled()); /** * Validate and parse config data diff --git a/src/utils/isCompiled.ts b/src/utils/isCompiled.ts new file mode 100644 index 0000000..f96643d --- /dev/null +++ b/src/utils/isCompiled.ts @@ -0,0 +1,6 @@ +// Macro as a janky workaround because Bun's documentation claims Bun.isStandaloneExecutable should tell this +// But it doesn't. Type definitions don't even show that property on the Bun object, and it's always undefined +// regardless of whether we build or run locally. +export function isCompiled() { + return Boolean(Bun.env.KATANA_COMPILED); +}