160 lines
6.2 KiB
Makefile
160 lines
6.2 KiB
Makefile
# Colors
|
|
GREEN = \033[32m
|
|
BLACK = \033[30m
|
|
CYAN = \033[36m
|
|
GREY = \033[0;90m
|
|
RED = \033[0;31m
|
|
GOLD = \033[38;5;220m
|
|
BROWN = \033[38;2;100;65;23m
|
|
WHITE = \033[38;2;255;255;255m
|
|
END = \033[0m
|
|
BOLD = \033[1m
|
|
ITALIC = \033[3m
|
|
UNDERLINE = \033[4m
|
|
|
|
PROJECT = ft_transcendence
|
|
BASE_PATH=$(shell realpath .)
|
|
ECHO = /usr/bin/env echo
|
|
|
|
all:
|
|
@$(MAKE) --no-print-directory header
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk
|
|
@$(MAKE) --no-print-directory footer
|
|
|
|
build:
|
|
@$(MAKE) --no-print-directory header
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk build
|
|
@$(MAKE) --no-print-directory footer
|
|
|
|
down:
|
|
@$(MAKE) --no-print-directory header
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk down
|
|
@$(MAKE) --no-print-directory footer
|
|
|
|
clean:
|
|
@$(MAKE) --no-print-directory header
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk clean
|
|
@$(MAKE) --no-print-directory footer
|
|
|
|
prune:
|
|
@$(MAKE) --no-print-directory header
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk prune
|
|
@$(MAKE) --no-print-directory footer
|
|
|
|
logs:
|
|
@$(MAKE) --no-print-directory -f ./Docker.mk logs
|
|
|
|
sql:
|
|
docker compose exec auth apk add sqlite
|
|
-docker compose exec -it auth sqlite3 /volumes/database/database.db
|
|
|
|
# Header
|
|
header:
|
|
@$(ECHO) -e ''
|
|
@$(ECHO) -e '$(GOLD) ******* ****** ******* $(END)'
|
|
@$(ECHO) -e '$(GOLD) ****** *** ******* $(END)'
|
|
@$(ECHO) -e '$(GOLD) ******* * ******* $(END)'
|
|
@$(ECHO) -e '$(GOLD) ****** ******* $(END)'
|
|
@$(ECHO) -e '$(GOLD) ******* ******* $(END)'
|
|
@$(ECHO) -e '$(GOLD) ******************* ******* * $(END)'
|
|
@$(ECHO) -e '$(GOLD) ******************* ******* *** $(END)'
|
|
@$(ECHO) -e '$(GOLD) ****** ******* ****** $(END)'
|
|
@$(ECHO) -e '$(GOLD) ****** $(END)'
|
|
@$(ECHO) -e '$(GOLD) ****** $(END)'
|
|
@$(ECHO) -e '$(GREY) $(END)'
|
|
@$(ECHO) -e '$(GREY) $(END)'
|
|
@$(ECHO) -e -n $(MSG);
|
|
|
|
PROJECT__NAME = $(CYAN)$(BOLD)$(UNDERLINE)FT_TRANSCENDENCE$(END)$(GOLD)
|
|
# Footer
|
|
footer:
|
|
@$(ECHO) -e '$(GREEN) $(END)'
|
|
@$(ECHO) -e '$(GREEN) , \\ / , $(END)'
|
|
@$(ECHO) -e '$(GREEN) / \\ )\\__/( / \\ $(END)'
|
|
@$(ECHO) -e '$(GREEN) / \\ (_\\ /_) / \\ $(END)'
|
|
@$(ECHO) -e '$(BROWN) ____$(GREEN)/$(BROWN)_____$(GREEN)\\$(BROWN)__$(GREEN)\\$(WHITE)@ @$(GREEN)/$(BROWN)___$(GREEN)/$(BROWN)_____$(GREEN)\\$(BROWN)____ $(END)'
|
|
@$(ECHO) -e '$(BROWN) | $(GREEN)|\\../| $(BROWN) | $(END)'
|
|
@$(ECHO) -e '$(BROWN) | $(GREEN) \\$(RED)vv$(GREEN)/ $(BROWN) | $(END)'
|
|
@$(ECHO) -e '$(BROWN) | $(PROJECT__NAME)$(BROWN) | $(END)'
|
|
@$(ECHO) -e '$(BROWN) |_________________________________| $(END)'
|
|
@$(ECHO) -e '$(GREEN) | _/\\ / \\\\ \\ / \\_ | $(END)'
|
|
@$(ECHO) -e '$(GREEN) | _/ V )) V \\_ | $(END)'
|
|
@$(ECHO) -e '$(GREEN) |/ ` // ` \\| $(END)'
|
|
@$(ECHO) -e '$(GREEN) ` V ` $(END)'
|
|
@$(ECHO) -e '$(BROWN) $(END)'
|
|
@$(ECHO) -e '$(GREY) The compilation is $(END)$(GOLD)finished$(END)'
|
|
@$(ECHO) -e '$(GREY) Have a good $(END)$(GOLD)correction$(END)'
|
|
|
|
# Restart (make re)
|
|
re:
|
|
@$(MAKE) --no-print-directory clean
|
|
@$(MAKE) --no-print-directory all
|
|
|
|
tokei:
|
|
@/bin/sh -c 'tokei'
|
|
|
|
npm@: npm;
|
|
npm:
|
|
@$(ECHO) "commands: "
|
|
@$(ECHO) " npm@install: install all dependencies"
|
|
@$(ECHO) " npm@fclean: clean every \`dist\` directory"
|
|
@$(ECHO) " npm@clean: clean \`node_modules\` directory"
|
|
@$(ECHO) " npm@build: build subprojects"
|
|
@$(ECHO) " npm@eslint: run eslint"
|
|
|
|
npm@eslint:
|
|
(cd ./src/ && npx pnpm run eslint)
|
|
|
|
npm@install:
|
|
(cd ./src/ && npx pnpm install --frozen-lockfile)
|
|
(cd ./frontend/ && npx pnpm install --frozen-lockfile)
|
|
|
|
npm@build:
|
|
(cd ./src/ && npx pnpm run build)
|
|
|
|
npm@update:
|
|
(cd ./src/ && rm -rf ./node_modules/ && npx pnpm install --lockfile-only && npx pnpm install --frozen-lockfile)
|
|
(cd ./frontend/ && rm -rf ./node_modules/ && npx pnpm install --lockfile-only && npx pnpm install --frozen-lockfile)
|
|
|
|
npm@openapi: openapi.jar
|
|
@(cd ./src/ && npx pnpm run --if-present -r build:openapi)
|
|
@rm -f ./src/openapi.json
|
|
@(cd ./src/ && npx pnpm exec redocly join --without-x-tag-groups)
|
|
@(cd ./src/ && java -jar ../openapi.jar generate -t ../openapi-template -g typescript-fetch -i openapi.json -o ../frontend/src/api/generated);
|
|
|
|
openapi.jar:
|
|
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.15.0/openapi-generator-cli-7.15.0.jar -O ./openapi.jar
|
|
|
|
tmux:
|
|
@tmux new-session -d -s $(PROJECT)
|
|
@tmux send-keys -t $(PROJECT):0 'vim' C-m
|
|
@tmux split-window -h -t $(PROJECT):0
|
|
@tmux resize-pane -t $(PROJECT):0.0 -x 70
|
|
@tmux new-window -t $(PROJECT):1 -n 'lazygit'
|
|
@tmux send-keys -t $(PROJECT):1 'lazygit' C-m
|
|
@tmux select-window -t $(PROJECT):0
|
|
@tmux attach-session -t $(PROJECT)
|
|
|
|
nginx-dev/nginx:
|
|
wget https://github.com/jirutka/nginx-binaries/raw/refs/heads/binaries/nginx-1.28.0-x86_64-linux -O nginx-dev/nginx
|
|
chmod +x nginx-dev/nginx
|
|
|
|
nginx-dev/nginx-selfsigned.crt nginx-dev/nginx-selfsigned.key &:
|
|
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./nginx-dev/nginx-selfsigned.key -out ./nginx-dev/nginx-selfsigned.crt -subj "/C=FR/OU=student/CN=local.maix.me";
|
|
|
|
fnginx: nginx-dev/nginx nginx-dev/nginx-selfsigned.crt nginx-dev/nginx-selfsigned.key
|
|
nginx-dev/nginx -p ./nginx-dev -c nginx.conf -e /dev/null >/dev/null 2>/dev/null &
|
|
-(cd ./frontend && npx pnpm exec tsc --noEmit --watch --preserveWatchOutput) &
|
|
-(cd ./frontend && npx pnpm exec vite --clearScreen false)
|
|
wait
|
|
|
|
jwt_secret:
|
|
sh -c "dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 | tr -d -- '\n' | tr -- '+/' '-_'; echo"
|
|
|
|
generateEnv:
|
|
cp env.example .env
|
|
sed -i 's/^JWT_SECRET=.*/JWT_SECRET=$(shell sh -c "dd if=/dev/urandom bs=32 count=1 2>/dev/null | base64 | tr -d -- '\n' | tr -- '+/' '-_'; echo")/' .env
|
|
|
|
|
|
# phony
|
|
.PHONY: all clean fclean re header footer npm@install npm@clean npm@fclean npm@build sql tmux logs jwt_secret
|