This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.mk
88 lines (71 loc) · 2.24 KB
/
default.mk
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
SHELL := /usr/bin/env bash
# https://stackoverflow.com/questions/2483182/recursive-wildcards-in-gnu-make
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))
TYPESCRIPT_SOURCE_FILES = $(sort $(call rwildcard,src test,*.ts *.tsx))
PRIVATE = $(shell node -e "console.log(require('./package.json').private)")
IS_TESTDATA = $(findstring -testdata,${CURDIR})
NPM_MODULE = $(shell cat package.json | jq .name --raw-output)
default: .tested
.PHONY: default
../../node_modules ../../package-lock.json: package.json
cd ../.. && npm install
.codegen:
touch $@
.tested: .tested-npm .built
.built: $(TYPESCRIPT_SOURCE_FILES) ../../node_modules ../../package-lock.json .codegen
pushd ../.. && \
npm run build && \
popd && \
touch $@
.tested-npm: $(TYPESCRIPT_SOURCE_FILES) ../../node_modules ../../package-lock.json .codegen
npm run test
touch $@
pre-release: clean update-version update-dependencies default
.PHONY: pre-release
update-dependencies:
../../node_modules/.bin/npm-check-updates --upgrade
.PHONY: update-dependencies
update-version:
ifeq ($(IS_TESTDATA),-testdata)
# no-op
else
ifdef NEW_VERSION
npm --no-git-tag-version --allow-same-version version "$(NEW_VERSION)"
# Update all npm packages that depend on us
pushd ../.. && \
./scripts/npm-each update_npm_dependency_if_exists package.json "$(NPM_MODULE)" "$(NEW_VERSION)"
# npm install
else
@echo -e "\033[0;31mNEW_VERSION is not defined. Can't update version :-(\033[0m"
exit 1
endif
endif
.PHONY: update-version
publish: .codegen
ifeq ($(IS_TESTDATA),-testdata)
# no-op
else
ifneq (true,$(PRIVATE))
npm publish --access public
else
@echo "Not publishing private npm module"
endif
endif
.PHONY: publish
post-release:
.PHONY: post-release
clean: clean-javascript
.PHONY: clean
clean-javascript:
rm -rf .deps .codegen .tested* coverage dist acceptance
.PHONY: clean-javascript
clobber: clean
rm -rf node_modules ../../node_modules
.PHONY: clobber
### COMMON stuff for all platforms
BERP_VERSION = 1.3.0
BERP_GRAMMAR = gherkin.berp
define berp-generate-parser =
-! dotnet tool list --tool-path /usr/bin | grep "berp\s*$(BERP_VERSION)" && dotnet tool update Berp --version $(BERP_VERSION) --tool-path /usr/bin
berp -g $(BERP_GRAMMAR) -t $< -o $@ --noBOM
endef