From e2345a8d4a6c88c53ee0f8df4e23a639cdba0124 Mon Sep 17 00:00:00 2001 From: Asai Neko Date: Fri, 19 Dec 2025 16:33:43 +0800 Subject: [PATCH] Add static router & mod justfile - default, run, build actions in justfile Signed-off-by: Asai Neko --- justfile | 15 ++++++++++++--- server/router.go | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/justfile b/justfile index 72c1b52..91a4efe 100644 --- a/justfile +++ b/justfile @@ -1,10 +1,19 @@ project_name := "nixcn-cms" server_enrty := "main.go" -output_dir := ".outputs" -client_dir := "./client" +output_dir := join(justfile_directory(), ".outputs") +client_dir := join(justfile_directory(), "client") +exec_path := join(output_dir, project_name) go_cmd := `realpath $(which go)` bun_cmd := `realpath $(which bun)` +default: clean build run + +clean: + rm -rf {{output_dir}}/* + build: mkdir -p {{ output_dir }} - {{ go_cmd }} build -o {{ output_dir }}/{{ project_name }}{{ if os() == "windows" { "exe" } else { "" } }} {{ server_enrty }} + {{ go_cmd }} build -o {{ exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} {{ server_enrty }} + +run: + cd {{ output_dir }} && {{ exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} diff --git a/server/router.go b/server/router.go index f367f4e..a2c77c0 100644 --- a/server/router.go +++ b/server/router.go @@ -3,4 +3,5 @@ package server import "github.com/gin-gonic/gin" func Router(e *gin.Engine) { + e.Static("/", "./static") }