-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
97 lines (79 loc) · 2.62 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
.DEFAULT_GOAL:= build
MAKEFLAGS = -j1
PATH := ./node_modules/.bin:$(PATH)
SHELL := /bin/bash
args = $(filter-out $@, $(MAKECMDGOALS))
.PHONY: all install clean deep-clean reinstall setup build compile build-source-maps compile-source-maps docs docs-server docs-build docs-compile watch lint test coverage test-coverage code-coverage report-coverage report-code-coverage ci prepatch patch minor major publish release
all: build test
install:
npm install
# remove the build and log folders
clean:
rm -rf dist logs
# remove all files that are ignored by git
deep-clean:
make clean
rm -rf node_modules/ dist/ .nyc_output/ npm-debug.log yarn-error.log
# reinstall the node_modules and start with a fresh node build
reinstall setup:
make deep-clean
make install
# build the source files
build compile:
make clean
babel app --out-dir dist $(args)
# makes it easier to build files with source maps without errors
# from other make commands
build-source-maps compile-source-maps:
make clean
babel app --out-dir dist --source-maps $(args)
# start the server for the documentation
docs docs-server:
docs server
# compile the documentation
docs-build docs-compile:
docs compile docs-public
# When watching for changes we can assume it's a development env
# so build files with source maps
watch:
make build-source-maps -- --watch $(args)
# lint test files
lint:
command -v eslint >/dev/null 2>&1 && eslint 'app' 'test' || ./node_modules/lint-rules/node_modules/.bin/eslint 'app' 'test';
# run unit tests
test:
ava $(args)
# run coverage for the tests
coverage test-coverage code-coverage:
# if there's no instance source maps files then build the files with source maps
@[ -f ./dist/index.js.map ] || (echo "building files with source maps" && make build-source-maps)
NODE_ENV="test" nyc --silent -- ava --verbose --no-cache
# These commands only run the report of the code coverage
report-coverage report-code-coverage:
@if [ -d ./.nyc_output ]; then \
NODE_ENV="test" nyc report; \
else \
make test-coverage report-coverage; \
fi
# posts code coverage to coveralls
post-coverage:
@if [ -d ./.nyc_output ]; then \
nyc report --reporter=text-lcov | coveralls; \
else \
make test-coverage post-coverage; \
fi
# The command the ci server runs
ci:
make lint || exit 1
# if the tests fail then it will exit with an error
make coverage || exit 1
# show the coverage report
nyc report
# check check-coverage and if it fails then exit
nyc check-coverage --statements 95 --functions 95 --lines 95 || exit 1
publish release:
make reinstall
make ci || exit 1
# rebuild project without sourcemaps
make build
np --no-cleanup --yolo $(args)