-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
134 lines (99 loc) · 2.66 KB
/
Makefile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
.PHONY: all install wipe-wireit build fast-build test start pm2-start install-prod prisma-studio initialize-db initialize-env initialize initialize-prod clean fclean re compose-up compose-down compose-build compose-up-detached docker-bot-app-entrypoint
MAKEFLAGS += --silent
#==============
# § I. CONFIG
#==============
PM := bun
ENV_EXAMPLE := .env.example
ENV_FILE := .env
ENV_TEST_EXAMPLE := .env.test.example
ENV_TEST_FILE := .env.test
DIST := ./dist/
TYPECHECK_DIST := ./typecheck-dist/
ESLINT_CACHE := .eslintcache
INIT_MIGRATION_TMP_FILE := 0_init.tmp.23456789876543qsldklfjkhsqsjSQDFGHFDSQS
#=================
# § II. COMMANDS
#=================
#-------------------------
# **** II. 1) PM Related
#-------------------------
# @Mirror
%:
$(PM) "$@"
# @Default
all: build
# @Mirror
install:
$(PM) install
# @Override
wipe-wireit:
$(PM) rimraf .wireit
# @Mirror
build:
$(PM) run build
# @Mirror
fast-build:
$(PM) run fast-build
# @Override
test:
$(PM) run test
# @Override
start: initialize-db
$(PM) run start
pm2-start: initialize-db
pm2-runtime start ./pm2.config.cjs
#------------------
# **** II. 2) DSL
#------------------
install-prod:
CI=1 $(PM) install --production
prisma-studio:
bunx prisma studio
initialize-db:
@{ \
mkdir -p prisma/migrations/0_init 2>/dev/null; \
rm -f $(INIT_MIGRATION_TMP_FILE); \
if [ -e "prisma/migrations/0_init/migration.sql" ]; then \
: ; \
else \
bunx prisma migrate diff \
--from-empty \
--to-schema-datamodel prisma/schema.prisma \
--script > prisma/migrations/0_init/migration.sql 2>/dev/null && \
echo 'create extension if not exists pgcrypto;' | cat - prisma/migrations/0_init/migration.sql > $(INIT_MIGRATION_TMP_FILE) && \
rm -f prisma/migrations/0_init/migration.sql && \
mv $(INIT_MIGRATION_TMP_FILE) prisma/migrations/0_init/migration.sql && \
bunx prisma migrate deploy; \
fi \
}
initialize-env:
[ -e "$(ENV_FILE)" ] || cp "$(ENV_EXAMPLE)" "$(ENV_FILE)"
[ -e "$(ENV_TEST_FILE)" ] || cp "$(ENV_TEST_EXAMPLE)" "$(ENV_TEST_FILE)"
initialize: install initialize-env
$(PM) run codegen
bunx prisma generate
initialize-prod: install-prod initialize-env
$(PM) run codegen
bunx prisma generate
clean: wipe-wireit
$(PM) rimraf $(DIST)
$(PM) rimraf $(TYPECHECK_DIST)
$(PM) rimraf $(ESLINT_CACHE)
fclean: clean
$(PM) rimraf node_modules
re: fclean initialize build
#---------------------
# **** II. 3) Docker
#---------------------
compose-watch:
docker compose watch
compose-up:
docker compose up
compose-down:
docker compose down
compose-build:
docker compose build
compose-up-detached:
docker compose up -d
docker-bot-app-entrypoint: initialize-prod fast-build pm2-start