-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
101 lines (78 loc) · 1.73 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
#!make
TAG = $(shell git describe --tags | sed -e 's/^v//')
PRERELEASE_TAG ?= rc
PUBLISH_FLAGS = publish --access public
PACKAGE_LOCK = package-lock.json
COVERAGE = .nyc_output coverage
ENVFILE = .env
SRC = src
SRC_FILES = $(shell find src -type f -name '[^test]*.ts')
DIST = dist
MODULES = node_modules node_modules/.bin
DOCKER = docker
COMPOSE ?= docker-compose
COMPOSE_FLAGS = --rm ${COMPOSE_SERVICE}
COMPOSE_SERVICE := build
RUN_IN_CONTAINER = docker-compose run --rm $(COMPOSE_SERVICE)
PM ?= npm
RM ?= rm
ifeq ($(CONTEXT), container)
PM = $(RUN_IN_CONTAINER) npm
RM = $(RUN_IN_CONTAINER) rm
endif
# TARGETS
.PHONY: all
all: $(DIST)
$(ENVFILE):
cp $(ENVFILE).defaults $(ENVFILE)
.PHONY: env
env: $(ENVFILE)
$(eval include $(ENVFILE))
$(eval export $(shell sed 's/=.*//' $(ENVFILE)))
$(MODULES):
$(PM) ci
$(DIST): $(MODULES) $(SRC_FILES)
$(PM) run build
@touch $(DIST)
.PHONY: publish
publish:
$(PM) publish
coverage:
$(PM) run coverage
package-lock.json:
$(PM) i
.PHONY: clean
clean:
$(RM) -rf $(DIST)
.PHONY: clean-coverage
clean-coverage:
$(RM) -rf $(COVERAGE)
.PHONY: clean-modules
clean-modules:
$(RM) -rf $(MODULES)/*
$(RM) $(PACKAGE_LOCK)
.PHONY: clean-all
clean-all: clean clean-modules clean-coverage
.PHONY: test
test: $(MODULES)
$(PM) t
.PHONY: container
container: package-lock.json
$(COMPOSE) build ${COMPOSE_SERVICE}
.PHONY: shell
shell:
$(COMPOSE) run $(COMPOSE_FLAGS) /bin/sh
.PHONY: release
release:
ifneq (,$(findstring n,$(MAKEFLAGS)))
+npx standard-version -s --dry-run
else
npx standard-version -s
endif
.PHONY: prerelease
prerelease:
ifneq (,$(findstring n,$(MAKEFLAGS)))
+npx standard-version -s --prerelease $(PRERELEASE_TAG) --dry-run
else
npx standard-version -s --prerelease $(PRERELEASE_TAG)
endif