This repository has been archived by the owner on Sep 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
148 lines (116 loc) · 4.31 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
ARTIFACT_DIR?=artifacts
TEST_REPORTS_DIR?=$(ARTIFACT_DIR)/reports
BUILD_DIR?=$(ARTIFACT_DIR)/webpack_build
ifdef CI
ESLINT_EXTRA_ARGS=--format junit --output-file $(TEST_REPORTS_DIR)/lint/eslint.junit.xml
JEST_ENV_VARIABLES=JEST_SUITE_NAME=yvm JEST_JUNIT_OUTPUT=$(TEST_REPORTS_DIR)/tests/jest.junit.xml
JEST_ARGS=--ci --maxWorkers=2 --reporters=default --reporters=jest-junit
WEBPACK_ARGS=
YARN_INSTALL_ARGS=--pure-lockfile --ci
else
ESLINT_EXTRA_ARGS=
JEST_ENV_VARIABLES=
JEST_ARGS=
WEBPACK_ARGS=--progress
YARN_INSTALL_ARGS=
endif
ESLINT_ARGS=--max-warnings 0 $(ESLINT_EXTRA_ARGS)
NODE_MODULES_BIN := node_modules/.bin
ESLINT := $(NODE_MODULES_BIN)/eslint $(ESLINT_ARGS)
MADGE := $(NODE_MODULES_BIN)/madge --circular src
BUNDLEWATCH := $(NODE_MODULES_BIN)/bundlewatch --config .bundlewatch.config.js
JEST := $(JEST_ENV_VARIABLES) $(NODE_MODULES_BIN)/jest $(JEST_ARGS)
WEBPACK := $(NODE_MODULES_BIN)/webpack $(WEBPACK_ARGS)
WEBPACK_BUILD_ := $(WEBPACK) --config webpack/webpack.config
WEBPACK_BUILD_DEV := $(WEBPACK_BUILD_).dev.js
WEBPACK_BUILD_DEV_WATCH := $(WEBPACK_BUILD_DEV) --watch
.PHONY: help
help:
echo $(JEST)
@echo "--------------------- Useful Commands for Development ----------------------"
@echo "make help - show tasks you can run"
@echo "make build - builds a bundle with development settings"
@echo "make build-watch - builds and watches code for local development"
@echo "make install-watch - runs install, and build-watch"
@echo "----------------------- Other Commands -------------------------"
@echo "make install - runs a set of scripts to ensure your environment is ready"
@echo "make lint - runs eslint"
@echo "make lint-fix - runs eslint --fix"
@echo "make lint-defend-circular - runs madge to defend against circular imports"
@echo "make test - runs the full test suite with jest"
@echo "make test-watch - runs tests as you develop"
@echo "make test-coverage - creates a coverage report and opens it in your browser"
@echo "make test-snapshots - runs test, updating snapshots"
@echo "make bundlewatch - runs bundlewatch to measure release size (run after build-production)"
@echo "make clean - removes node_modules and built artifacts"
@echo "----------------------- CI Commands -------------------------"
@echo "make build-production - builds a bundle with production settings"
# ---- Webpack ----
.PHONY: build-production
build-production: node_modules clean_webpack_build
$(WEBPACK_BUILD_).prod.js
.PHONY: build
build: node_modules clean_webpack_build
$(WEBPACK_BUILD_DEV)
.PHONY: build-watch
build-watch: node_modules clean_webpack_build
$(WEBPACK_BUILD_DEV_WATCH)
# ---- YVM Command Stuff ----
.PHONY: install-local
install-local:
@USE_LOCAL=true node scripts/install.js
.PHONY: install
install: build-production install-local
.PHONY: install-watch
install-watch: node_modules clean_webpack_build
$(WEBPACK_BUILD_DEV_WATCH) --env INSTALL=true
# -------------- Linting --------------
.PHONY: lint
lint:
$(ESLINT) .
.PHONY: lint-fix
lint-fix:
$(ESLINT) --fix .
.PHONY: lint-defend-circular
lint-defend-circular:
$(MADGE)
# -------------- Testing --------------
.PHONY: test
test:
$(JEST)
.PHONY: test-watch
test-watch:
$(JEST) --watch
# CODECOV_TOKEN is set by GitHub Actions
.PHONY: test-coverage
test-coverage:
$(JEST) --coverage
.PHONY: test-snapshots
test-snapshots:
$(JEST) --updateSnapshot
.PHONY: sanities-bash
sanities-bash:
YVM_DIR=~/.yvm bash ./test/scripts/yvm.test.sh
.PHONY: sanities-fish
sanities-fish:
YVM_DIR=~/.yvm fish ./test/scripts/yvm.test.fish
.PHONY: sanities-zsh
sanities-zsh:
YVM_DIR=~/.yvm zsh ./test/scripts/yvm.test.sh
# ----------------- Helpers ------------------
.PHONY: bundlewatch
bundlewatch:
$(BUNDLEWATCH)
.PHONY: node_modules
node_modules:
yarn install ${YARN_INSTALL_ARGS}
touch node_modules
.PHONY: clean_node_modules
clean_node_modules:
rm -rf node_modules
.PHONY: clean_webpack_build
clean_webpack_build:
rm -rf ${BUILD_DIR}
.PHONY: clean
clean: clean_node_modules clean_webpack_build
rm -rf ${ARTIFACT_DIR}