2020-11-12 16:28:24 +00:00
|
|
|
SHELL := bash
|
2021-05-08 22:34:55 +00:00
|
|
|
.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
|
2021-05-08 22:34:55 +00:00
|
|
|
env ?= development
|
|
|
|
hainish ?= ../haini.sh/haini.sh
|
|
|
|
hain ?= ../hain
|
|
|
|
|
|
|
|
JEKYLL_ENV := $(env)
|
2020-11-12 16:28:24 +00:00
|
|
|
|
2021-05-27 21:01:56 +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
|
|
|
|
|
2021-05-08 22:34:55 +00:00
|
|
|
help: always ## Ayuda
|
2021-08-25 13:19:57 +00:00
|
|
|
@grep "^[^[:space:]]\+:.*##" Makefile | sed -re "s/(.*):.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/"
|
2021-05-08 22:34:55 +00:00
|
|
|
|
2021-05-24 18:57:07 +00:00
|
|
|
all: install fa serve build ## Todas las tareas necesarias para desarrollar
|
2021-05-08 19:59:37 +00:00
|
|
|
|
2021-05-08 22:34:55 +00:00
|
|
|
install: node_modules Gemfile.lock ## Instalar las dependencias
|
2020-06-17 19:58:05 +00:00
|
|
|
|
2021-05-08 23:15:58 +00:00
|
|
|
build: ## Compilar el sitio (env=production)
|
2021-05-08 22:34:55 +00:00
|
|
|
make bundle args="exec jekyll build --profile --trace"
|
2021-04-13 16:16:59 +00:00
|
|
|
@echo -e "\a"
|
2020-06-17 19:58:05 +00:00
|
|
|
|
2021-05-31 16:48:08 +00:00
|
|
|
sassdoc: _sassdoc/index.html ## Genera la documentación de SCSS
|
|
|
|
|
2021-05-27 21:27:19 +00:00
|
|
|
hain: ## Correr comandos con hain (args="comandos")
|
|
|
|
$(hainish) '$(args)'
|
|
|
|
|
2021-05-08 22:34:55 +00:00
|
|
|
bundle: ## Correr comandos con bundler (args="install")
|
2021-05-27 21:27:19 +00:00
|
|
|
$(MAKE) hain args="bundle $(args)"
|
|
|
|
|
|
|
|
yarn: ## Correr comandos con yarn (args="add paquete")
|
|
|
|
$(MAKE) hain args="yarn $(args)"
|
|
|
|
|
|
|
|
npx: ## Correr comandos con npx (args="run")
|
|
|
|
$(MAKE) hain args="npx $(args)"
|
|
|
|
|
|
|
|
npm: ## Correr comandos con npm (args="install -g paquete")
|
|
|
|
$(MAKE) hain args="npm $(args)"
|
2020-11-12 16:28:24 +00:00
|
|
|
|
2021-11-22 17:45:20 +00:00
|
|
|
prettier: ## Arreglar JS (por ahora)
|
|
|
|
$(MAKE) yarn args="prettier --write _packs/"
|
|
|
|
|
2021-11-22 17:46:18 +00:00
|
|
|
format-check: ## Verificar JS
|
|
|
|
$(MAKE) yarn args="prettier --check _packs/"
|
2021-11-22 17:45:20 +00:00
|
|
|
|
2021-05-08 22:34:55 +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
|
|
|
|
2021-05-31 22:16:06 +00:00
|
|
|
webpack: node_modules assets/js/pack.js ## Compilar JS
|
2021-04-13 16:16:59 +00:00
|
|
|
@echo -e "\a"
|
2020-11-12 17:42:00 +00:00
|
|
|
|
2021-05-31 22:16:06 +00:00
|
|
|
webpack-dev-server: node_modules $(hain)/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
|
2021-04-13 16:16:59 +00:00
|
|
|
@echo -e "\a"
|
2020-11-12 16:28:24 +00:00
|
|
|
|
2021-05-08 22:50:40 +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
|
|
|
|
|
2021-08-25 13:58:00 +00:00
|
|
|
fonts := $(patsubst %.otf,%-subset.woff2,$(wildcard assets/fonts/*))
|
2021-08-25 13:21:50 +00:00
|
|
|
fonts: $(fonts) ## Minifica todas las tipografías
|
|
|
|
|
2021-05-08 23:15:58 +00:00
|
|
|
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/
|
|
|
|
|
2021-05-08 22:34:55 +00:00
|
|
|
node_modules: package.json
|
2021-05-27 21:27:19 +00:00
|
|
|
$(MAKE) yarn
|
2021-05-08 22:34:55 +00:00
|
|
|
|
|
|
|
Gemfile.lock: Gemfile
|
2021-05-27 21:27:19 +00:00
|
|
|
$(MAKE) bundle args=install
|
2021-05-08 22:34:55 +00:00
|
|
|
|
2021-09-01 20:31:20 +00:00
|
|
|
# Para poder optimizar los SVG necesitamos trabajar sobre el mismo
|
|
|
|
# archivo, pero make no nos va a dejar, así que lo corremos siempre.
|
|
|
|
%.svg: always ## Optimizar un archivo SVG (% = ubicación del archivo)
|
|
|
|
$(MAKE) hain args='./node_modules/.bin/svgo $@'
|
|
|
|
|
2021-05-26 22:30:21 +00:00
|
|
|
# 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
|
2021-05-27 21:27:19 +00:00
|
|
|
$(MAKE) hain args=nginx
|
2021-05-08 22:34:55 +00:00
|
|
|
|
2021-05-27 21:27:19 +00:00
|
|
|
$(hain)/tmp/webpack.pid:
|
|
|
|
$(MAKE) hain args="./node_modules/.bin/webpack-dev-server --public $(domain):4000 --host 127.0.0.1 --port 65001 & echo $$! > /tmp/webpack.pid"
|
2021-05-08 22:34:55 +00:00
|
|
|
|
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)
|
2021-05-27 21:27:19 +00:00
|
|
|
$(MAKE) hain args="./node_modules/.bin/webpack --config webpack.prod.js"
|
2020-11-12 17:42:00 +00:00
|
|
|
|
2021-05-08 22:34:55 +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
|
2021-05-27 23:33:42 +00:00
|
|
|
grep -v "^#" fa.txt | sed "s/^/U+/" | cut -d " " -f 1 | tr "\n" "," | xargs -rI {} make hain args="pyftsubset node_modules/fork-awesome/fonts/forkawesome-webfont.ttf --output-file=$@ --unicodes={} --layout-features='*' --flavor=woff2"
|
|
|
|
|
|
|
|
# Rangos Unicode para alfabeto latino.
|
|
|
|
latin_unicode := "U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD"
|
2021-05-08 22:34:55 +00:00
|
|
|
|
2021-05-08 23:15:58 +00:00
|
|
|
# Generar woff2 reducidas al alfabeto latino
|
|
|
|
%-subset.woff2: %.ttf
|
2021-05-27 23:33:42 +00:00
|
|
|
make hain args="pyftsubset $< --output-file=$@ --unicodes=$(latin_unicode) --layout-features='*' --flavor=woff2"
|
2021-05-08 23:15:58 +00:00
|
|
|
|
|
|
|
# Generar woff2 reducidas al alfabeto latino
|
|
|
|
%-subset.woff2: %.otf
|
2021-05-27 23:33:42 +00:00
|
|
|
make hain args="pyftsubset $< --output-file=$@ --unicodes=$(latin_unicode) --layout-features='*' --flavor=woff2"
|
2021-05-08 23:15:58 +00:00
|
|
|
|
2021-05-31 16:48:08 +00:00
|
|
|
sass_files := $(wildcard _sass/*.scss) assets/css/styles.scss .sassdocrc
|
|
|
|
_sassdoc/index.html: yarn $(sass_files)
|
|
|
|
./node_modules/.bin/sassdoc _sass/ assets/css/ --dest ./_sassdoc
|
2020-11-12 17:42:00 +00:00
|
|
|
|
2020-11-12 16:28:24 +00:00
|
|
|
.PHONY: always
|