sutty-base-jekyll-theme/Makefile

102 lines
3.8 KiB
Makefile
Raw Normal View History

2020-11-12 16:28:24 +00:00
SHELL := bash
.DEFAULT_GOAL := help
2020-06-17 19:58:05 +00:00
2020-11-12 16:28:24 +00:00
site ?= $(patsubst %-jekyll-theme,%,$(notdir $(PWD)))
domain ?= $(site).sutty.local
env ?= development
hainish ?= ../haini.sh/haini.sh
hain ?= ../hain
JEKYLL_ENV := $(env)
2020-11-12 16:28:24 +00:00
# Copiar el archivo de configuración y avisar cuando hay que
# actualizarlo.
.env: .env.example
@test -f $@ || cp -v $< $@
@test -f $@ && echo "Revisa $@ para actualizarlo con respecto a $<"
@test -f $@ && diff -auN --color $@ $<
# Incluir la configuracion
2020-11-12 16:28:24 +00:00
include .env
2020-06-17 19:58:05 +00:00
export
help: always ## Ayuda
@grep "^[^\t]\+:.*##" Makefile | sed -re "s/(.*):.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/"
all: install fa serve build ## Todas las tareas necesarias para desarrollar
install: node_modules Gemfile.lock ## Instalar las dependencias
2020-06-17 19:58:05 +00:00
build: ## Compilar el sitio (env=production)
make bundle args="exec jekyll build --profile --trace"
@echo -e "\a"
2020-06-17 19:58:05 +00:00
bundle: ## Correr comandos con bundler (args="install")
$(hainish) 'bundle $(args)'
2020-11-12 16:28:24 +00:00
serve: /etc/hosts $(hain)/run/nginx/nginx.pid ## Servidor de desarrollo
@echo "Iniciado servidor web en https://$(domain):4000/"
2020-11-12 16:28:24 +00:00
2020-11-12 17:42:00 +00:00
webpack: assets/js/pack.js ## Compilar JS
@echo -e "\a"
2020-11-12 17:42:00 +00:00
2021-01-06 16:23:09 +00:00
webpack-dev-server: /tmp/webpack.pid ## Servidor de prueba de Webpack
2020-06-17 19:58:05 +00:00
2020-11-12 16:28:24 +00:00
fa: assets/fonts/forkawesome-webfont.woff2 ## Fork Awesome
@echo -e "\a"
2020-11-12 16:28:24 +00:00
fa-%: always ## Agregar un ícono de Fork Awesome (reemplazar % por el nombre)
@echo Agregando $* a la lista de íconos
@grep -q "$*" fa.txt || grep '^$$fa-var-$*: ' node_modules/fork-awesome/scss/_variables.scss | sed -re "s/^.*: \"\\\(.*)\";/\1 $*/" >> fa.txt
gfont: ## Descarga tipografías de Google Fonts (css="url del css")
@test -n "$(css)"
wget "$(css)" -nv -kO /tmp/gfont
cd assets/fonts/ && grep -Eo "https://[^\"')]+" /tmp/gfont | sort -u | wget -i - -x -nH -nv --cut-dir 1 -N
grep -q "$(css)" _sass/fonts.scss || sed -r -e "1i // $(css)" -e "s,https://fonts\.gstatic\.com/s/,../fonts/," -e "s/\.[to]tf/-subset.woff2/g" -e "s/(true|open)type/woff2/g" /tmp/gfont >> _sass/fonts.scss
find assets/fonts/ -name "*.?tf" | sed -re "s/\.[ot]tf/-subset.woff2/" | xargs make
2020-11-12 18:03:43 +00:00
push: ## Publica los cambios locales
sudo chgrp -R 82 _site
rsync -avi --delete-after _site/ root@athshe.sutty.nl:/srv/sutty/srv/http/data/_deploy/$(site).sutty.nl/
node_modules: package.json
$(hainish) yarn
Gemfile.lock: Gemfile
$(hainish) 'bundle install'
# XXX: Cada vez que se reinicia el sistema, cambia la fecha de creación
# del pid 1 y lo usamos como medida para saber si hay que iniciar nginx.
# Si nginx se cae después de iniciarlo, no vamos a reiniciarlo así.
$(hain)/run/nginx/nginx.pid: /proc/1
$(hainish) nginx
/tmp/webpack.pid:
$(hainish) ./node_modules/.bin/webpack-dev-server --public $(domain):4000 --host 127.0.0.1 --port 65001 & echo $$! > /tmp/webpack.pid
2020-11-12 16:28:24 +00:00
/etc/hosts: always
@echo "Chequeando si es necesario agregar el dominio local $(domain)"
@grep -q " $(domain)$$" $@ || echo -e "127.0.0.1 $(domain)\n::1 $(domain)" | sudo tee -a $@
2021-01-12 17:14:14 +00:00
js = $(wildcard _packs/*.js) $(wildcard _packs/*/*.js) $(wildcard *.js)
2020-11-12 17:42:00 +00:00
assets/js/pack.js: $(js)
$(hainish) ./node_modules/.bin/webpack --config webpack.prod.js
2020-11-12 17:42:00 +00:00
# Tomar los códigos de los íconos de este archivo y copiarlos a fa.txt
# node_modules/font-awesome/scss/_variables.scss
assets/fonts/forkawesome-webfont.woff2: fa.txt
grep -v "^#" fa.txt | sed "s/^/U+/" | cut -d " " -f 1 | tr "\n" "," | xargs -rI {} glyphhanger --subset=node_modules/fork-awesome/fonts/forkawesome-webfont.ttf --formats=woff2 --whitelist="{}"
mv node_modules/fork-awesome/fonts/forkawesome-webfont-subset.woff2 $@
# Generar woff2 reducidas al alfabeto latino
%-subset.woff2: %.ttf
glyphhanger --subset=$< --formats=woff2 --LATIN
# Generar woff2 reducidas al alfabeto latino
%-subset.woff2: %.otf
glyphhanger --subset=$< --formats=woff2 --LATIN
2020-11-12 16:28:24 +00:00
.PHONY: always