-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.env
executable file
·53 lines (43 loc) · 1.93 KB
/
Makefile.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
NAME ?= $(lastword $(subst /, ,$(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))))
APP_NAME ?= app
PACKAGE_NAME ?= github.com\/alexvelfr\/${NAME}
REGISTRY_URL ?= registry.url.here
.DEFAULT_GOAL := set_env
define sedi
sed --version >/dev/null 2>&1 && sed -i -- $(1) || sed -i "" $(1)
endef
.PHONY: set_env
set_env: set_package_paths set_dir_app_name set_project_name set_default_config clear git_clear
.PHONY: set_package_paths
set_package_paths:
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./server/app.go)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./cmd/main.go)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./app/usecase/usecase.go)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./app/delivery/http/handler.go)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./app/delivery/http/register.go)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./go.mod)
$(call sedi,"s/github.com\/alexvelfr\/go-template/${PACKAGE_NAME}/g;" ./Makefile)
$(call sedi,"s/{{REGISTRY_URL}}/${REGISTRY_URL}/g;" ./Makefile)
.PHONY: set_dir_app_name
set_dir_app_name:
mv ./app ./${APP_NAME}
$(call sedi,"s/app/${APP_NAME}/g;" ./server/app.go)
$(call sedi,"s/app/${APP_NAME}/g;" ./${APP_NAME}/delivery/http/handler.go)
$(call sedi,"s/app/${APP_NAME}/g;" ./${APP_NAME}/delivery/http/register.go)
$(call sedi,"s/app/${APP_NAME}/g;" ./${APP_NAME}/usecase/usecase.go)
$(call sedi,"s/app/${APP_NAME}/;" ./${APP_NAME}/usecase.go)
$(call sedi,"s/app/${APP_NAME}/;" ./${APP_NAME}/repo.go)
.PHONY: set_project_name
set_project_name:
$(call sedi,"s/service-template/${NAME}/g;" ./Makefile)
echo "# ${APP_NAME}" > ./README.md
.PHONY: set_default_config
set_project_name:
cp ./config/config_exmlp.yml ./config/config.yml
.PHONY: git_clear
git_clear:
rm -rf .git
git init
.PHONY: clear
clear:
rm -rf Makefile.env