-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (88 loc) · 2.12 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
###############################
# Common defaults/definitions #
###############################
comma := ,
# Checks two given strings for equality.
eq = $(if $(or $(1),$(2)),$(and $(findstring $(1),$(2)),\
$(findstring $(2),$(1))),1)
###############
# Git Section #
###############
MAINLINE_BRANCH := dev
CURRENT_BRANCH := $(shell git branch | grep \* | cut -d ' ' -f2)
# Squash changes of the current Git branch onto another Git branch.
#
# WARNING: You must merge `onto` branch in the current branch before squash!
#
# Usage:
# make squash [onto=] [del=(no|yes)]
onto ?= $(MAINLINE_BRANCH)
del ?= no
upstream ?= origin
squash:
ifeq ($(CURRENT_BRANCH),$(onto))
@echo "--> Current branch is '$(onto)' already" && false
endif
git checkout $(onto)
git branch -m $(CURRENT_BRANCH) orig-$(CURRENT_BRANCH)
git checkout -b $(CURRENT_BRANCH)
git branch --set-upstream-to $(upstream)/$(CURRENT_BRANCH)
git merge --squash orig-$(CURRENT_BRANCH)
ifeq ($(del),yes)
git branch -d orig-$(CURRENT_BRANCH)
endif
###########
# Aliases #
###########
start: npm.start
test: npm.test
down: docker.down
up: docker.up
##################
# Node.js commands #
##################
# Maven command.
#
# Usage:
# make mvn [task=]
task ?=
node.image = alpine
npm:
docker run \
--rm \
--name node-worker \
-v $(PWD):/app \
-w /app \
node:$(node.image) \
npm $(task)
# start command
npm.start:
@make npm task='start'
# test command
npm.test:
@make npm task='test'
###################
# Docker commands #
###################
# Stop project in Docker Compose development environment
# and remove all related containers.
#
# Usage:
# make docker.down
docker.down:
docker-compose down --rmi=local -v
# Run Docker Compose development environment.
#
# Usage:
# make docker.up [rebuild=(yes|no)]
# [background=(no|yes)]
rebuild ?= yes
background ?= no
docker.up: docker.down
docker-compose up \
$(if $(call eq,$(rebuild),no),,--build) \
$(if $(call eq,$(background),yes),-d,--abort-on-container-exit)
.PHONY: squash \
start test up down \
npm npm.test npm.start \
docker.up docker.down