forked from google/node-sec-roadmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
113 lines (93 loc) · 3.27 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
# This Makefile builds various versions of the Gitbook, runs
# sanity checks, and sets up a deployment directory.
#
# See `make help`
define HELP
Targets
=======
`make book` puts HTML files under www/
`make pdf` builds the PDF version
`make serve_static` serve the book from http://localhost:4000/
`make serve` launch the builtin gitbook debug server
`make check` runs sanity checks
`make deploy` builds the deployment directory and runs checks
Setup
=====
This assumes that PATH includes
https://github.com/gjtorikian/html-proofer
https://calibre-ebook.com/download
that the following environment variables point to reasonable values:
HTML_PROOFER # path to htmlproofer executable
CALIBRE_HOME # path to directory containing calibre executables
Deploying
=========
`make deploy` builds the deploy directory.
From that directory `gcloud app deploy --project node-sec-roadmap`
deploys to the canonical location if you have the right
privileges and have run `gcloud auth login`.
endef
export HELP
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# External dependency used to detect dead links
ifeq ($(HTML_PROOFER),)
HTML_PROOFER:=${HOME}/.gem/ruby/2.4.0/gems/html-proofer-3.8.0/bin/htmlproofer
ifeq (,$(wildcard ${HTML_PROOFER}))
HTML_PROOFER:=/bin/echo
endif
endif
# External dependency used to build pdf
ifeq ($(CALIBRE_HOME),)
CALIBRE_HOME:=/Applications/calibre.app/Contents/console.app/Contents/MacOS/
endif
# Bits that gitbook depends on
GITBOOK_DEPS := node_modules book.json cover.md SUMMARY.md CONTRIBUTORS.md \
$(wildcard chapter-*/*.md) appendix/experiments.md \
styles/website.css images/*
help:
@echo "$$HELP"
book.json : book.json.withcomments
@cat book.json.withcomments \
| perl -ne 'print unless m/^[ \t]*#/' > book.json
pdf : www/node-sec-roadmap.pdf
www/node-sec-roadmap.pdf : $(GITBOOK_DEPS)
PATH="${PATH}:./node_modules/.bin/:${CALIBRE_HOME}" \
./node_modules/.bin/gitbook pdf . www/node-sec-roadmap.pdf
book : www/.book.tstamp
www/.book.tstamp : $(GITBOOK_DEPS)
"${ROOT_DIR}"/node_modules/.bin/gitbook build . www
@touch www/.book.tstamp
check : .check.tstamp
.check.tstamp : deploy/.deploy.tstamp
touch .check.tstamp
echo Checking that we correctly capitalize npm and Nodejs
echo and that all Markdown link names are defined.
@! find deploy/www/ -name \*.html \
| xargs egrep '\]\[|[nN][oO][dD][eE]J[sS]|\bN[Pp][Mm]\b' \
| egrep -v 'x\[a\]\[b\]|this\[x\]\[|[.]jfrog[.]com/'
echo Checking for dead links
@if [ "${HTML_PROOFER}" = "/bin/echo" ]; then \
echo "Warning: HTML_PROOFER not available"; \
else \
echo Running htmlproofer; \
"${HTML_PROOFER}" \
--alt-ignore=example/graphs/full.svg \
"${ROOT_DIR}"/deploy/www/; \
fi
@find deploy -name node_modules \
|| (echo "deploy/ should not include node_modules"; false)
serve : $(GITBOOK_DEPS)
"${ROOT_DIR}"/node_modules/.bin/gitbook serve
serve_static : book
pushd www; python -m SimpleHTTPServer 4000; popd
clean :
rm -rf www/ deploy/ _book/ book.json .*.tstamp
node_modules : package.json
npm install --only=prod
@touch node_modules/
deploy : deploy/.deploy.tstamp check
deploy/.deploy.tstamp : book pdf app.yaml
rm -rf deploy/
mkdir deploy/
cp app.yaml deploy/
cp -r www/ deploy/www/
@touch deploy/.deploy.tstamp