Skip to content

Commit 7fc381e

Browse files
committed
Added Makefile for fast development
Added Makefile Added .gitignore line for LANGS.md.bak
1 parent 4441ae1 commit 7fc381e

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
package-lock.json
66
.idea
77
.swp
8+
LANGS.md.bak

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
LANG := en
2+
LANG_FILE := $(shell test -f LANGS.md.bak && echo LANGS.md.bak || echo LANGS.md)
3+
LANG_DATA := $(shell grep "$(LANG)/" $(LANG_FILE))
4+
LANG_NAME := $(shell echo "$(LANG_DATA)" | sed 's/.*\[\(.*\)\].*/\1/')
5+
6+
define ebook_support
7+
@if which ebook-convert 1> /dev/null; then\
8+
npx honkit $(1) ./ ./djangogirls.$(1);\
9+
else\
10+
echo "Error: ebook-convert is not found. Follow the guide at https://honkit.netlify.app/ebook";\
11+
fi
12+
endef
13+
14+
help:
15+
@echo
16+
@echo "Usage: make command [LANG=<language_short_code>]"
17+
@echo
18+
@echo " LANG : Language short codes are found in LANGS.md. Default is 'en'(English)."
19+
@echo " ( Refer $(LANG_FILE) for short codes of Languages avaiable. )"
20+
@echo
21+
@echo "Commands:"
22+
@echo " help - Display make command list."
23+
@echo " dev - Setup project and start the development server with debugging enabled."
24+
@echo " check - Check for root directory for various dependencies."
25+
@echo " setup - Setup the temporary language and install node dependencies for the development. Default is 'en'"
26+
@echo " build - Build the honkit project."
27+
@echo " build-dev - Build the honkit project with debug log."
28+
@echo " serve - Start honkit server locally for development."
29+
@echo " pdf - Generate PDF version of DjangoGirls tutorial."
30+
@echo " epub - Generate EPUB version of DjangoGirls tutorial."
31+
@echo " mobi - Generate MOBI version of DjangoGirls tutorial."
32+
@echo " mode - Shows the development mode status."
33+
@echo " exit - Reset the project and exit development mode."
34+
35+
check: package.json book.json LANGS.md
36+
@if ! which node 1> /dev/null; then\
37+
echo "Node.js not found. Please install/reinstall Node.js. NVM is recommended for installation(https://github.com/nvm-sh/nvm).";\
38+
fi
39+
40+
setup: check
41+
@if ! test -f "LANGS.md.bak"; then\
42+
cp LANGS.md LANGS.md.bak && echo "Language file backup is created.";\
43+
echo "$(LANG_DATA)" > LANGS.md && echo "Language list is reduced to $(LANG_NAME) for development";\
44+
npm install && echo "Project is ready for development.";\
45+
fi
46+
47+
build: setup
48+
@npx honkit build
49+
50+
build-dev: setup
51+
@npx honkit build --log=debug
52+
53+
serve: setup
54+
@npx honkit serve
55+
56+
dev: setup
57+
@npx honkit serve --log=debug
58+
59+
mode:
60+
@if test -f "LANGS.md.bak"; then\
61+
echo "You are in development mode";\
62+
else\
63+
echo "You are not in development mode";\
64+
fi
65+
66+
exit:
67+
@if test -f "LANGS.md.bak"; then\
68+
mv -f LANGS.md.bak LANGS.md && echo "Language file is reset";\
69+
rm -rf node_modules _book && echo "The project exited development mode.";\
70+
fi
71+
72+
pdf:
73+
$(call ebook_support,pdf)
74+
75+
epub:
76+
$(call ebook_support,epub)
77+
78+
mobi:
79+
$(call ebook_support,mobi)
80+
81+
.PHONY: help check reset setup build build-dev serve dev pdf epub mobi mode exit

0 commit comments

Comments
 (0)