From cc634dd1559ea47ecfd8e11e110f9269a09f804f Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 11 May 2023 09:39:23 +0200 Subject: [PATCH] Improve build and error handling --- Makefile | 14 +++++++++++--- internal/runtimeEnv/setup.go | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ad1b647..dfd833b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ TARGET = ./cc-backend VAR = ./var +CFG = config.json .env FRONTEND = ./web/frontend VERSION = 1 GIT_HASH := $(shell git rev-parse --short HEAD || echo 'development') @@ -31,7 +32,7 @@ SVELTE_SRC = $(wildcard $(FRONTEND)/src/*.svelte) \ .NOTPARALLEL: -$(TARGET): $(VAR) $(SVELTE_TARGETS) +$(TARGET): $(VAR) $(CFG) $(SVELTE_TARGETS) $(info ===> BUILD cc-backend) @go build -ldflags=${LD_FLAGS} ./cmd/cc-backend @@ -58,11 +59,18 @@ tags: $(VAR): @mkdir $(VAR) - cd web/frontend && npm install + +config.json: + $(info ===> Initialize config.json file) + @cp configs/config.json config.json + +.env: + $(info ===> Initialize .env file) + @cp configs/env-template.txt .env $(SVELTE_TARGETS): $(SVELTE_SRC) $(info ===> BUILD frontend) - cd web/frontend && npm run build + cd web/frontend && npm install && npm run build install: $(TARGET) @WORKSPACE=$(PREFIX) diff --git a/internal/runtimeEnv/setup.go b/internal/runtimeEnv/setup.go index a98bf39..5407a0e 100644 --- a/internal/runtimeEnv/setup.go +++ b/internal/runtimeEnv/setup.go @@ -24,7 +24,7 @@ import ( func LoadEnv(file string) error { f, err := os.Open(file) if err != nil { - log.Error("Error while opening file") + log.Error("Error while opening .env file") return err }