-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (62 loc) · 1.97 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
SHELL := /bin/bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(.DEFAULT_GOAL),)
ifneq ($(shell test -f .env; echo $$?), 0)
$(error Cannot find a .env file; copy .env.sample and customise)
endif
endif
# Wrap the build in a check for an existing .env file
ifeq ($(shell test -f .env; echo $$?), 0)
include .env
ENVVARS := $(shell sed -ne 's/ *\#.*$$//; /./ s/=.*$$// p' .env )
$(foreach var,$(ENVVARS),$(eval $(shell echo export $(var)="$($(var))")))
.DEFAULT_GOAL := help
ASSETS_DIR := site/themes/staticfy/assets
ifeq (${ENVIRONMENT}, production)
NIKOLA_CONFIG := conf.py
THEME_CONFIG := config.js
else
NIKOLA_CONFIG := conf-local.py
THEME_CONFIG := local.js
endif
.PHONY: help
help: ## Show this help message
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' Makefile
.PHONY: setup
setup:
yarn install
pip install --upgrade pip
pip install -r requirements.txt
cp -R node_modules/staticfy-theme/themes site/
PHONY: theme-scripts
theme-scripts: node_modules/leaflet/dist/leaflet.js*
cp src/js/${THEME_CONFIG} $(ASSETS_DIR)/js/config.js
.PHONY: theme-css
theme-css: site tailwind.config.js src/css/tailwind.css
npx tailwindcss --input src/css/tailwind.css --output $(ASSETS_DIR)/css/tailwind.css
.PHONY: clean
clean: ## Clean everything
(cd site && nikola clean)
rm -rf site/public
rm -rf site/themes
.PHONY: site
site: ## Build the site content
(cd site && nikola build --conf=${NIKOLA_CONFIG})
BUILD_TARGETS := site theme-scripts theme-css
.PHONY: build
build: $(BUILD_TARGETS) ## Build everything
.PHONY: serve
serve: build ## Build and locally serve the site
(cd site && nikola serve -p ${NIKOLA_PORT} --conf=${NIKOLA_CONFIG})
.PHONY: deploy
deploy: build ## Deploy to production
ansible-playbook playbooks/deploy.yml
# No .env file; fail the build
else
.DEFAULT:
$(error Cannot find a .env file; copy .env.sample and customise)
endif