-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathMakefile
124 lines (87 loc) · 2.57 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
#
# Directories
#
ROOT_SLASH := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
ROOT := $(patsubst %/,%,$(ROOT_SLASH))
TEST := $(ROOT)/test
TOOLS := $(ROOT)/tools
GITHOOKS_SRC := $(TOOLS)/githooks
GITHOOKS_DEST := $(ROOT)/.git/hooks
#
# Generated Directories
#
NODE_MODULES := $(ROOT)/node_modules
NODE_BIN := $(NODE_MODULES)/.bin
COVERAGE := $(ROOT)/coverage
#
# Tools and binaries
#
YARN := yarn
NPM := npm
COVERALLS := $(NODE_BIN)/coveralls
ESLINT := $(NODE_BIN)/eslint
ISTANBUL := $(NODE_BIN)/nyc
MOCHA := $(NODE_BIN)/mocha
_MOCHA := $(NODE_BIN)/_mocha
UNLEASH := $(NODE_BIN)/unleash
CONVENTIONAL_RECOMMENDED_BUMP := $(NODE_BIN)/conventional-recommended-bump
#
# Files
#
LCOV := $(ROOT)/coverage/lcov.info
PACKAGE_JSON := $(ROOT)/package.json
YARN_LOCK := $(ROOT)/yarn.lock
GITHOOKS := $(wildcard $(GITHOOKS_SRC)/*)
ALL_FILES := $(shell find $(ROOT) \
-not \( -path $(NODE_MODULES) -prune \) \
-not \( -path $(COVERAGE) -prune \) \
-name '*.js' -type f)
#
# Targets
#
.PHONY: help
help:
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all: node_modules lint test clean-coverage
$(YARN_LOCK): $(PACKAGE_JSON)
@$(YARN)
$(NODE_MODULES): $(PACKAGE_JSON)
@$(YARN)
@touch $(NODE_MODULES)
.PHONY: githooks
githooks: ## Install githooks
@ln -s $(GIT_HOOK_SRC) $(GIT_HOOK_DEST)
.PHONY: release-dry
release-dry: $(NODE_MODULES) ## Dry run of `release` target
$(UNLEASH) -d --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p angular)
.PHONY: release
release: $(NODE_MODULES) ## Versions, tags, and updates changelog based on commit messages
$(UNLEASH) --type=$(shell $(CONVENTIONAL_RECOMMENDED_BUMP) -p angular) --no-publish
$(NPM) publish
.PHONY: lint
lint: $(NODE_MODULES) ## Run lint and style checks
@$(ESLINT) $(ALL_FILES)
.PHONY: prepush
prepush: $(NODE_MODULES) lint test ## Run all required tasks for a git push
.PHONY: test
test: $(NODE_MODULES) ## Run unit tests
@$(MOCHA) -R spec --full-trace
.PHONY: coverage
coverage: $(NODE_MODULES) clean-coverage ## Generate test coverage
@$(ISTANBUL) --report lcovonly $(_MOCHA) -R spec
.PHONY: report-coverage
report-coverage: $(NODE_MODULES) coverage ## Report test coverage to Coveralls
$(ISTANBUL) report --reporter=text-lcov | $(COVERALLS)
.PHONY: clean-coverage
clean-coverage:
@rm -rf $(COVERAGE)
.PHONY: clean
clean: clean-coverage ## Clean all generated directories
@rm -rf $(NODE_MODULES)
#
## Debug -- print out a a variable via `make print-FOO`
#
print-% : ; @echo $* = $($*)