-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
58 lines (47 loc) · 2.13 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
chineseWordsCnt := $(shell find book.zh -iname "*.md" -print0 | grep -z -v _book | grep -z -v node_modules | wc -m --files0-from - | tail -n 1 | cut -f1)
englishWordsCnt := $(shell find book.en -iname "*.md" -print0 | grep -z -v zh_CN | grep -z -v _book | grep -z -v node_modules | wc -m --files0-from - | tail -n 1 | cut -f1)
deploy := https://github.com/hitzhangjie/debugger101.io
tmpdir := /tmp/debugger101.io
book := book.zh
.PHONY: english chinese stat clean deploy
PWD := $(shell pwd -P)
english:
rm -rf book.en/_book
#gitbook install book.en
#gitbook serve book.en
# docker run --name gitbook --rm -v ${PWD}/book.en:/root/gitbook hitzhangjie/gitbook-cli:latest gitbook install .
docker run --name gitbook --rm -v ${PWD}/book.en:/root/gitbook -p 4000:4000 -p 35729:35729 hitzhangjie/gitbook-cli:latest gitbook serve .
chinese:
rm -rf book.zh/_book
#gitbook install book.zh
#gitbook serve book.zh
docker run --name gitbook --rm -v ${PWD}/book.zh:/root/gitbook hitzhangjie/gitbook-cli:latest gitbook install .
docker run --name gitbook --rm -v ${PWD}/book.zh:/root/gitbook -p 4000:4000 -p 35729:35729 hitzhangjie/gitbook-cli:latest gitbook serve .
pdfchinese:
@echo "Warn: must do it mannually so far for lack of proper docker image,"
@echo "- install 'calibre' first (see https://calibre-ebook.com/download),"
@echo "- make sure 'ebook-convert' could be found in envvar 'PATH',"
@echo " take macOS for example:"
@echo " run 'sudo ln -s /Applications/calibre.app/Contents/MacOS/ebook-convert /usr/bin'."
@echo "- run 'gitbook pdf <book> <book.pdf>'"
@echo ""
stat:
@echo "Chinese version, words: ${chineseWordsCnt}"
@echo "English version, words: ${englishWordsCnt}"
clean:
rm -rf book.zh/_book
rm -rf book.en/_book
#rm -rf ./node_modules
deploy:
# ./deploy.sh
rm -rf ${tmpdir}
echo "deploying updates to GitHub..."
git clone ${deploy} ${tmpdir}
docker run --name gitbook --rm -v ${PWD}:/root/gitbook -v ${tmpdir}:${tmpdir} hitzhangjie/gitbook-cli:latest gitbook build ${book} tmpdir
cp -r tmpdir/* ${tmpdir}/
rm -rf tmpdir
cd ${tmpdir}
git add .
git commit -m "rebuilding site"
git push -f -u origin master
rm -rf ${tmpdir}