47 lines
1.5 KiB
Makefile
47 lines
1.5 KiB
Makefile
project_name := "nixcn-cms"
|
|
go_cmd := `realpath $(which go)`
|
|
pnpm_cmd := `realpath $(which pnpm)`
|
|
project_dir := justfile_directory()
|
|
output_dir := join(project_dir, ".outputs")
|
|
client_dir := join(project_dir, "client")
|
|
client_output_dir := join(output_dir, "client")
|
|
client_cms_dir := join(client_dir, "cms")
|
|
server_exec_path := join(output_dir, project_name)
|
|
server_entry := "main.go"
|
|
|
|
install: install-cms
|
|
|
|
install-cms:
|
|
cd {{ client_cms_dir }} && {{ pnpm_cmd }} install
|
|
|
|
clean:
|
|
mkdir -p .outputs
|
|
find .outputs -mindepth 1 ! -path .outputs/config.yaml -exec rm -rf {} +
|
|
|
|
build-client-cms:
|
|
cd {{ client_cms_dir }} && {{ pnpm_cmd }} run build --outDir {{ join(client_output_dir, "cms") }}
|
|
|
|
build-back:
|
|
{{ go_cmd }} build -o {{ server_exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }} {{ server_entry }}
|
|
|
|
run-back:
|
|
cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} {{ server_exec_path }}{{ if os() == "windows" { ".exe" } else { "" } }}
|
|
|
|
test-back:
|
|
cd {{ output_dir }} && CONFIG_PATH={{ output_dir }} GO_ENV=test go test -C .. ./...
|
|
|
|
gen-back:
|
|
cd {{ project_dir }} && go generate .
|
|
|
|
watch-back:
|
|
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 gen-back
|
|
devenv up --verbose
|
|
|
|
dev-client-cms: install-cms
|
|
devenv up client-cms --verbose
|
|
|
|
dev-back: clean gen-back
|
|
devenv up backend postgres redis meilisearch --verbose
|