ansible.l3d.space/Makefile

78 lines
2.7 KiB
Makefile
Raw Normal View History

2023-01-31 23:34:57 +01:00
LEKTOR_SERVER_FLAGS=-h 127.0.0.1
# minify javascript assets, compile scss assets
LEKTOR_PLUGIN_FLAGS=-f scss -f pretifyhtml
LEKTOR_DEPLOY_FLAGS=
2023-03-21 23:45:53 +01:00
.PHONY: all install venv build server dev deploy
2023-01-31 23:34:57 +01:00
all: build
install:
2023-03-21 23:45:53 +01:00
if hash apt-get 2>/dev/null; then \
2023-04-15 23:18:17 +02:00
apt-get update -qq >/dev/null && apt-get install -qq apt-utils imagemagick python3-pip python3-setuptools gcc git-lfs python3-venv rsync; \
2023-03-21 23:45:53 +01:00
elif hash pacman 2>/dev/null; then \
2023-04-15 23:18:17 +02:00
pacman -Syu imagemagick python-pip glibc lib32-glibc gcc git-lfs python3-venv rsync --noconfirm; \
2023-03-21 23:45:53 +01:00
elif hash dnf 2>/dev/null; then \
2023-04-15 23:18:17 +02:00
dnf install -y ImageMagick python3-pip gcc git-lfs rsync; \
2023-03-21 23:45:53 +01:00
else \
2023-04-15 23:18:17 +02:00
echo -e "Please install Imagemagick, python3-pip git-lfs, python3-venv, rsync and gcc"; \
2023-01-31 23:34:57 +01:00
fi
2023-03-21 23:45:53 +01:00
venv:
if [ -z "${VIRTUAL_ENV}" ]; then \
2023-04-15 23:18:17 +02:00
printf "Run 'python3 -m venv lektor' to create venv.\nRun 'source lektor/bin/activate' to activate venv.\n"; \
2023-03-21 23:45:53 +01:00
printf "Run 'pip3 install wheel --upgrade' next.\nRun 'pip3 install lektor --upgrade' to install lektor"; \
2023-03-21 19:39:23 +01:00
fi
2023-03-21 23:45:53 +01:00
build:
if [ -z "${VIRTUAL_ENV}" ]; then \
printf "Run 'source lektor/bin/activate' to enable venv. Or 'make install' to create venv"; \
else \
if python3 -m lektor --version 2>/dev/null; then \
python3 -m lektor build $(LEKTOR_PLUGIN_FLAGS); \
else \
lektor build $(LEKTOR_PLUGIN_FLAGS); \
fi; \
2023-01-31 23:34:57 +01:00
fi
server:
2023-03-21 23:45:53 +01:00
if [ -z "${VIRTUAL_ENV}" ]; then \
2023-04-15 23:18:17 +02:00
printf "Run 'source lektor/bin/activate' to enable venv. Or 'make install' to create venv"; \
2023-03-21 23:45:53 +01:00
else \
if python3 -m lektor --version 2>/dev/null; then \
python3 -m lektor server $(LEKTOR_SERVER_FLAGS) $(LEKTOR_PLUGIN_FLAGS); \
else \
lektor server $(LEKTOR_SERVER_FLAGS) $(LEKTOR_PLUGIN_FLAGS); \
fi; \
2023-01-31 23:34:57 +01:00
fi
2023-03-07 22:10:20 +01:00
dev:
2023-03-21 23:45:53 +01:00
if [ -z "${VIRTUAL_ENV}" ]; then \
2023-04-15 23:18:17 +02:00
printf "Run 'source lektor/bin/activate' to enable venv. Or 'make install' to create venv"; \
2023-03-21 23:45:53 +01:00
else \
lektor plugin flush-cache; \
2023-04-15 23:18:17 +02:00
lektor clean --yes; \
rm assets/svg/*; \
2023-03-21 23:45:53 +01:00
if python3 -m lektor --version 2>/dev/null; then \
python3 -m lektor server $(LEKTOR_SERVER_FLAGS) $(LEKTOR_PLUGIN_FLAGS); \
else \
lektor server $(LEKTOR_SERVER_FLAGS) $(LEKTOR_PLUGIN_FLAGS); \
fi; \
2023-03-07 22:10:20 +01:00
fi
2023-01-31 23:34:57 +01:00
deploy:
2023-03-21 23:45:53 +01:00
if [ -z "${VIRTUAL_ENV}" ]; then \
2023-04-15 23:18:17 +02:00
printf "Run 'source lektor/bin/activate' to enable venv. Or 'make install' to create venv"; \
else \
2023-03-21 23:45:53 +01:00
lektor plugin flush-cache; \
2023-04-15 23:18:17 +02:00
lektor clean --yes; \
rm assets/svg/*; \
if python3 -m lektor --version 2>/dev/null; then \
python3 -m lektor build $(LEKTOR_PLUGIN_FLAGS) $(LEKTOR_DEPLOY_FLAGS); \
python3 -m lektor deploy $(LEKTOR_PLUGIN_FLAGS) $(LEKTOR_DEPLOY_FLAGS); \
else \
lektor build $(LEKTOR_PLUGIN_FLAGS) $(LEKTOR_DEPLOY_FLAGS); \
lektor deploy $(LEKTOR_PLUGIN_FLAGS) $(LEKTOR_DEPLOY_FLAGS); \
fi; \
2023-03-21 19:39:23 +01:00
fi