-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
160 lines (121 loc) · 3.88 KB
/
Copy pathMakefile
File metadata and controls
160 lines (121 loc) · 3.88 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# OctoCAT Supply Chain Management - Makefile
# Cross-platform compatible (Linux, macOS, Windows with Git Bash or WSL)
# Detect OS for platform-specific commands
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
RM_RF = powershell -Command "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue"
MKDIR_P = powershell -Command "New-Item -ItemType Directory -Force -Path"
else
DETECTED_OS := $(shell uname -s)
RM_RF = rm -rf
MKDIR_P = mkdir -p
endif
API_DIR := api
FRONTEND_DIR := frontend
.DEFAULT_GOAL := help
##@ General
.PHONY: help
help: ## Display this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: info
info: ## Show detected OS and directories
@echo "Detected OS: $(DETECTED_OS)"
@echo "API Directory: $(API_DIR)"
@echo "Frontend Directory: $(FRONTEND_DIR)"
##@ Installation
.PHONY: install
install: ## Install all dependencies
cd $(API_DIR) && npm install
cd $(FRONTEND_DIR) && npm install
##@ Development
.PHONY: dev
dev: ## Start development servers (API + Frontend)
ifeq ($(OS),Windows_NT)
npx concurrently --kill-others "cd $(API_DIR) && npm run dev" "cd $(FRONTEND_DIR) && set VITE_API_URL=http://localhost:3000 && npm run dev"
else
@trap 'kill 0' INT; \
(cd $(API_DIR) && npm run dev) & \
(cd $(FRONTEND_DIR) && VITE_API_URL=http://localhost:3000 npm run dev) & \
wait
endif
.PHONY: dev-api
dev-api: ## Start only the API development server
cd $(API_DIR) && npm run dev
.PHONY: dev-frontend
dev-frontend: ## Start only the frontend development server
cd $(FRONTEND_DIR) && npm run dev
##@ Database
.PHONY: db-init
db-init: ## Initialize database schema
cd $(API_DIR) && npm run db:init
.PHONY: db-seed
db-seed: ## Initialize and seed database with sample data
cd $(API_DIR) && npm run db:seed
##@ Building
.PHONY: build
build: ## Build all projects
cd $(API_DIR) && npm run build
cd $(FRONTEND_DIR) && npm run build
.PHONY: build-api
build-api: ## Build only the API
cd $(API_DIR) && npm run build
.PHONY: build-frontend
build-frontend: ## Build only the frontend
cd $(FRONTEND_DIR) && npm run build
##@ Testing
.PHONY: test
test: ## Run all tests
cd $(API_DIR) && npm run test
cd $(FRONTEND_DIR) && npm run test
.PHONY: test-api
test-api: ## Run API tests
cd $(API_DIR) && npm run test
.PHONY: test-frontend
test-frontend: ## Run frontend tests
cd $(FRONTEND_DIR) && npm run test
.PHONY: test-e2e
test-e2e: ## Run end-to-end tests
cd $(FRONTEND_DIR) && npm run test:e2e
.PHONY: test-coverage
test-coverage: ## Run tests with coverage
cd $(API_DIR) && npm run test:coverage
##@ Linting
.PHONY: lint
lint: ## Lint all code
cd $(API_DIR) && npm run lint
cd $(FRONTEND_DIR) && npm run lint
.PHONY: lint-fix
lint-fix: ## Lint and auto-fix issues
cd $(API_DIR) && npm run lint:fix
cd $(FRONTEND_DIR) && npm run lint -- --fix
.PHONY: format
format: ## Format code with prettier
npx prettier --write "$(API_DIR)/**/*.{ts,tsx}" "$(FRONTEND_DIR)/**/*.{ts,tsx}"
##@ Code Generation
.PHONY: swagger
swagger: ## Regenerate Swagger/OpenAPI spec (api-swagger.json)
cd $(API_DIR) && npm run swagger:generate
##@ Production
.PHONY: start
start: ## Start production server
cd $(API_DIR) && npm start
##@ Docker
.PHONY: docker-build
docker-build: ## Build Docker images
docker-compose build
.PHONY: docker-up
docker-up: ## Start Docker containers
docker-compose up
.PHONY: docker-down
docker-down: ## Stop Docker containers
docker-compose down
##@ Cleaning
.PHONY: clean
clean: ## Clean build artifacts and dependencies
$(RM_RF) node_modules $(API_DIR)/node_modules $(FRONTEND_DIR)/node_modules
$(RM_RF) $(API_DIR)/dist $(FRONTEND_DIR)/dist
ifeq ($(OS),Windows_NT)
$(RM_RF) $(API_DIR)/*.db,$(API_DIR)/*.db-*
else
$(RM_RF) $(API_DIR)/*.db $(API_DIR)/*.db-*
endif