From c5003dcf7ae8210bc96154db1abbead44ef0a86f Mon Sep 17 00:00:00 2001 From: mgillam Date: Thu, 23 Jul 2026 08:57:47 -0400 Subject: [PATCH 1/3] Adding modules.zip bundle to `release` GH action --- .github/workflows/release.yml | 4 ++++ 1 file changed, 4 insertions(+) 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: From 951518154d0c97c3d02fe9439a404985b2b721e0 Mon Sep 17 00:00:00 2001 From: mgillam Date: Thu, 23 Jul 2026 10:24:16 -0400 Subject: [PATCH 2/3] Making default modules path `/opt/katana/modules` when config created by standalone executable, keeping relative path for local dev --- package.json | 2 +- src/types/config.ts | 54 ++++++++++++++++++++++++++++------------- src/utils/isCompiled.ts | 6 +++++ 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 src/utils/isCompiled.ts 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 0595c81..81d96b9 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,4 +1,5 @@ import { z } from "zod"; +import { isCompiled } from "@/utils/isCompiled" with { type: "macro" }; /** * Main configuration schema @@ -47,23 +48,42 @@ 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: "./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..4687143 --- /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); +} \ No newline at end of file From 096f0794226f825180c41bccc026820fe6ca40d0 Mon Sep 17 00:00:00 2001 From: mgillam Date: Thu, 23 Jul 2026 10:42:00 -0400 Subject: [PATCH 3/3] Formatting / lint fixes --- src/types/config.ts | 71 +++++++++++++++++++++-------------------- src/utils/isCompiled.ts | 4 +-- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/types/config.ts b/src/types/config.ts index 81d96b9..043bc0a 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -1,5 +1,5 @@ -import { z } from "zod"; import { isCompiled } from "@/utils/isCompiled" with { type: "macro" }; +import { z } from "zod"; /** * Main configuration schema @@ -49,40 +49,41 @@ export type Config = z.infer; * Default configuration values */ 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", - }; - + 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()); /** diff --git a/src/utils/isCompiled.ts b/src/utils/isCompiled.ts index 4687143..f96643d 100644 --- a/src/utils/isCompiled.ts +++ b/src/utils/isCompiled.ts @@ -1,6 +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. +// regardless of whether we build or run locally. export function isCompiled() { return Boolean(Bun.env.KATANA_COMPILED); -} \ No newline at end of file +}