|
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/') |
| 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 |
5 | 13 |
|
6 | 14 | help:
|
7 | 15 | @echo
|
8 | 16 | @echo "Usage: make command [LANG=<language_short_code>]"
|
9 | 17 | @echo
|
10 |
| - @echo "Language short codes are found in LANGS.md. ( For eg: LANG=es )" |
11 |
| - @echo "Default Language is 'en'(English)." |
| 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 |
12 | 21 | @echo "Commands:"
|
13 |
| - @echo " init - Initialise and Start the server." |
14 |
| - @echo " serve - Start honkit server locally for development." |
15 |
| - @echo " setup - Setup the temporary language for the development." |
16 |
| - @echo " reset - Reset the temporarily set language." |
17 |
| - @echo " check - Check for root directory for various dependencies." |
18 |
| - @echo " help - Display command list." |
19 |
| - |
20 |
| -check: book.json LANGS.md package.json $(shell which node) $(shell which npx) |
21 |
| - |
22 |
| -reset: |
23 |
| - @if test -f "LANGS.md.bak"; then \ |
24 |
| - mv -f LANGS.md.bak LANGS.md && echo "Language file is reset"; \ |
25 |
| - else \ |
26 |
| - echo "Language file backup is not found."; \ |
| 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.";\ |
27 | 70 | fi
|
28 | 71 |
|
29 |
| -setup: reset |
30 |
| -ifneq ($(LANG_FILE), "LANGS.md.bak") |
31 |
| - @cp LANGS.md LANGS.md.bak && echo "Language file backup is created." |
32 |
| - @echo "$(LANG_DATA)" > LANGS.md && echo "Language list is reduced to $(LANG_NAME) for development" |
33 |
| -endif |
| 72 | +pdf: |
| 73 | + $(call ebook_support,pdf) |
34 | 74 |
|
35 |
| -serve: |
36 |
| - @npx honkit serve || (npm install && npx honkit serve) |
| 75 | +epub: |
| 76 | + $(call ebook_support,epub) |
37 | 77 |
|
38 |
| -init: check setup serve |
| 78 | +mobi: |
| 79 | + $(call ebook_support,mobi) |
39 | 80 |
|
40 |
| -.PHONY: help check reset setup serve init |
| 81 | +.PHONY: help check reset setup build build-dev serve dev pdf epub mobi mode exit |
0 commit comments