-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
97 lines (74 loc) · 2.56 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
###########################################################
# Build script
###########################################################
# Operating System (darwin or linux)
ARCH=x64
PLATFORM:=$(shell uname | tr A-Z a-z)
PROJECT_ROOT=$(shell git rev-parse --show-toplevel)
# Nodejs
NODE=lib/nodejs/bin/node
NODE_MODULES_BIN=node_modules/.bin
NODE_VERSION=12.14.0
# Values
NPM=lib/nodejs/bin/npm
PORT=8081
SRC_FILES=$(shell find . -name "*js" ! -path "*node_modules*" ! -path "*.dist.js")
TEST_FILES=$(shell find . -name "*_test.js" ! -path "*node_modules*")
WEBPACK_CLIENT_CONFIG=webpack-client.config.js
# Derived values
ESLINT=$(NODE_MODULES_BIN)/eslint
MOCHA=$(NODE_MODULES_BIN)/mocha
NODEMON=${NODE_MODULES_BIN}/nodemon
NODE_FILENAME=node-v$(NODE_VERSION)-$(PLATFORM)-$(ARCH)
NYC=$(NODE_MODULES_BIN)/nyc
WEBPACK=$(NODE_MODULES_BIN)/webpack
YARN=$(NODE_MODULES_BIN)/yarn
.PHONY: build coverage test test-w test-debug dev-install build build-module lint clean
# Build the example app distribution
example/stream/app.dist.js: ${SRC_FILES}
${YARN} webpack -o example/stream/app.dist.js --mode development example/stream/app.js
# Build any source files
build: ${NODE} example/stream/app.dist.js
# Run all JavaScript tests
test: ${NODE}
${NYC} ${MOCHA} -r esm ${TEST_FILES}
test-w: ${NODE}
${NYC} ${MOCHA} -r esm ${TEST_FILES} -w
# Open a new chrome tab at chrome://inspect and click the small blue link
# that says, "Open dedicated DevTools for Node."
test-debug: ${NODE}
${NYC} ${MOCHA} ${TEST_FILES} --inspect-brk
# NOTE: Currently broken b/c eslint dependencies are too painful
lint:
$(ESLINT) --config $(PROJECT_ROOT)/.eslintrc.json ${SRC_FILES}
module-install:
$(NPM) install
integrate: clean lint test
serve:
${NODE} example/stream/static_server.jsm ${PORT}
serve-dev:
${NODEMON} -x "make build serve || true" -i example/stream/app.dist.js -w .
coverage:
${NYC} report --reporter=text-lcov > coverage.lcov && codecov
clean:
rm -rf example/stream/app.dist.js
rm -rf tmp
rm -f .tmp-view.html
yarn:
$(NPM) install yarn --save-dev
# Intall development dependencies (OS X and Linux only)
dev-install: $(NODE) yarn
yarn-install:
$(YARN) install
# Download and unpack the Node binaries into lib/nodejs.
$(NODE):
mkdir -p tmp
wget -O tmp/nodejs.tar.xz --no-check-certificate "https://nodejs.org/dist/v$(NODE_VERSION)/$(NODE_FILENAME).tar.xz"
touch tmp/nodejs.tar.xz
mkdir -p lib/nodejs
tar -xvf tmp/nodejs.tar.xz -C lib/nodejs --strip 1
touch lib/nodejs/README.md
rm -rf tmp
# Install npm dependencies
$(NODE_MODULES_BIN): $(PROJECT_ROOT)/package.json
$(NPM) install --development