-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
108 lines (92 loc) · 3.21 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
NO_COLOR=\033[0m
OK_COLOR=\033[32;01m
ERROR_COLOR=\033[31;01m
WARN_COLOR=\033[33;01m
PWD=$(shell pwd)
MODULES=${PWD}/node_modules/
BIN=${MODULES}.bin/
run:
@make lint
@make test
# Build production ready statics to dist/
.PHONY: dist
dist:
@echo "$(OK_COLOR)Build dist package$(NO_COLOR)"
@rm -rf dist && mkdir dist && cp favicons/* dist/ && NODE_ENV=production webpack -p
@echo "$(WARN_COLOR)Are you build swagger.json before build dist?$(NO_COLOR)"
# Build release ZIP file with statics
.PHONY: release
release:
@echo "$(OK_COLOR)Build release package$(NO_COLOR)"
rm -rf dist
mkdir dist
cp favicons/* dist/
NODE_ENV=production webpack -p
zip -r bearded_fronted dist/
# Build api description from backend to app/lib/swagge.json.
# This file should be builded every time server API changed.
# Also is good to build it before "make dist".
.PHONY: swagger.json
swagger.json:
LINK=http://localhost:3003/apidocs.json
@echo "$(OK_COLOR)Updating app/lib/swagger.json from ${LINK}$(NO_COLOR)"
@${BIN}fetch-swagger-schema ${LINK} app/lib/swagger.json
# Start code linting, show only errors
.PHONY: lint
lint:
@echo "$(OK_COLOR)Run lint in quiet mode$(NO_COLOR)"
@node_modules/.bin/eslint app/ --quiet
@echo "$(OK_COLOR)No lint errors$(NO_COLOR)"
# Start unit testing
.PHONY: test
test:
@echo "$(OK_COLOR)Run unit tests$(NO_COLOR)"
@${BIN}mocha --require pretest.js -R spec "app/**/*.t.js"
# Build coverage into app/coverage
.PHONY: coverage
coverage:
@echo "$(OK_COLOR)Run unit tests with coverage$(NO_COLOR)"
@(cd app && ../node_modules/babel-istanbul/lib/cli.js --include-all-sources --babel-stage=0 \
cover ../node_modules/mocha/bin/_mocha -- --require ../pretest.js -t 5000 -R spec "./**/*.t.js")
# Task for travis.ci automatic tests
# Should not been called manual
.PHONY: travis-build
travis-build:
@echo "$(OK_COLOR)Run travis build$(NO_COLOR)"
@make lint
@echo "$(OK_COLOR)Run tests + coverage$(NO_COLOR)"
(cd app && ../node_modules/babel-istanbul/lib/cli.js --include-all-sources --babel-stage=0 cover\
../node_modules/mocha/bin/_mocha --report lcovonly -- --require ../pretest.js -t 15000 -R spec "./**/*.t.js")
@echo "$(OK_COLOR)Upload coverage to codecov.io$(NO_COLOR)"
cat app/coverage/lcov.info | ./node_modules/codecov.io/bin/codecov.io.js
# Install project dependencies
.PHONY: deps
deps:
@echo "$(OK_COLOR)Install dependencies$(NO_COLOR)"
@npm install
# Start protractor e2e testingg
# Require webdriver-manager to be started (make e2e-server)
.PHONY: e2e
e2e:
@echo "$(OK_COLOR)Run end to end tests$(NO_COLOR)"
@${BIN}protractor protractor.js
# Start wselenium server for e2e testing
.PHONY: e2e-server
e2e-server:
@echo "$(OK_COLOR)Run webdriver server$(NO_COLOR)"
@${BIN}webdriver-manager start
# Update webrdiver
.PHONY: e2e-update-server
e2e-update-server:
@echo "$(OK_COLOR)Update webdriver$(NO_COLOR)"
@${BIN}webdriver-manager update --standalone
# Start webpack developer server
.PHONY: dev-server
dev-server:
@echo "$(OK_COLOR)Run webpack developer server$(NO_COLOR)"
@${BIN}webpack-dev-server --devtool eval --progress --colors --hot --content-base build/ --inline
# Start unit testing
.PHONY: test-w
test-w:
@echo "$(OK_COLOR)Run unit tests$(NO_COLOR)"
@${BIN}mocha --require pretest.js -w -R spec "app/**/*.t.js"