-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMakefile
110 lines (89 loc) · 3.4 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
SHELL=/bin/bash
PROJECT_NAME=$(shell basename $(PWD))
REGISTRY_HOST=
REGISTRY_GROUP=
RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support
IMAGE=$(shell tr '[:upper:]' '[:lower:]' <<< $(PROJECT_NAME))
VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion)
TAG=$(shell . $(RELEASE_SUPPORT); getTag)
.PHONY: help version release lint test coverage start stop status log
help:
@echo 'Usage: make <target>'
@echo ''
@echo ' Targets:'
@echo ''
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo ''
version: .release ## Display Release Version.
@. $(RELEASE_SUPPORT); getVersion
.release:
@echo "release=0.0.0" > .release
@echo "tag=$(PROJECT_NAME)-0.0.0" >> .release
@echo INFO: .release created
@cat .release
check-release: .release
@. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [major,minor,micro]-release." >&2 && exit 1) ;
@. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [major,minor,micro]-release." ; exit 1)
check-status:
@. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ;
tag: TAG=$(shell . $(RELEASE_SUPPORT); getTag $(VERSION))
tag: check-status
@echo "Current version: $(VERSION)" # Debug statement
@echo "Current tag: $(TAG)" # Debug statement
@. $(RELEASE_SUPPORT) ; ! tagExists $(TAG) || (echo "ERROR: tag $(TAG) for version $(VERSION) already tagged in git" >&2 && exit 1) ;
@. $(RELEASE_SUPPORT) ; setRelease $(VERSION)
git add .release package.json
git commit -m "bumped to version $(VERSION)"
git tag $(TAG)
@[ -n "$(shell git remote -v)" ] && git push --tags
tag-major-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMajorLevel)
tag-major-release: .release tag
major-release: tag-major-release ## Major Release
@echo $(VERSION)
tag-minor-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMinorLevel)
tag-minor-release: .release tag
minor-release: tag-minor-release ## Minor Release
@echo $(VERSION)
tag-micro-release: VERSION := $(shell . $(RELEASE_SUPPORT); nextMicroLevel)
tag-micro-release: .release tag
micro-release: tag-micro-release ## Micro Release
@echo $(VERSION)
lint: ## Lint the project
npm run lint
test: ## Run tests
npm test
coverage: ## Generate test coverage
npm run coverage
PID_FILE=proxy.pid
LOG_FILE=proxy.log
start: ## Start the proxy server
@echo "Starting proxy server..."
@nohup node test/utils/proxy.js > $(LOG_FILE) 2>&1 & echo $$! > $(PID_FILE)
@echo "Proxy server started with PID $$(cat $(PID_FILE))"
stop: ## Stop the proxy server
@if [ -f $(PID_FILE) ]; then \
echo "Stopping proxy server..."; \
PID=$$(cat $(PID_FILE)); \
if kill $$PID 2>/dev/null; then \
rm -f $(PID_FILE); \
echo "Proxy server stopped"; \
else \
echo "Proxy server not running, removing stale PID file"; \
rm -f $(PID_FILE); \
fi \
else \
echo "Proxy server is not running"; \
fi
status: ## Check the status of the proxy server
@if [ -f $(PID_FILE) ]; then \
PID=$$(cat $(PID_FILE)); \
if ps -p $$PID > /dev/null; then \
echo "Proxy server is running with PID $$PID"; \
else \
echo "Proxy server is not running, but PID file exists"; \
fi \
else \
echo "Proxy server is not running"; \
fi
log: ## Tail the proxy server logs
@tail -f $(LOG_FILE)