project_name := "nixcn-cms" go_cmd := `realpath $(which go)` project_dir := justfile_directory() output_dir := join(project_dir, ".outputs") server_exec_path := join(output_dir, project_name) server_entry := "main.go" install: go install github.com/swaggo/swag/cmd/swag@latest cd {{ project_dir }} && go mod tidy generate: cd {{ project_dir }} && go generate . clean: mkdir -p .outputs find .outputs -mindepth 1 ! -path .outputs/config.yaml -exec rm -rf {} + build: {{ go_cmd }} build -o {{ server_exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} {{ server_entry }} run: cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} {{ server_exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} test: cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} GO_ENV=test go test -C .. ./... watch: watchexec -r -e go,yaml,tpl -i '.devenv/**' -i '.direnv/**' -i 'client/**' -i 'vendor/**' 'go build -o {{ server_exec_path }} . && cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} {{ server_exec_path }}' dev: clean install generate devenv up --verbose back: clean install generate devenv up postgres redis lgtm --verbose