-
Notifications
You must be signed in to change notification settings - Fork 0
/
task
executable file
·90 lines (74 loc) · 1.85 KB
/
task
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
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env zsh
# shellcheck shell=bash
dev () { #: prepare stuff and watch
dev="public/assets/dev"
npx hash-and-manifest empty
clean-dev
clean-dist
COMMANDS=(
# Site
"npx browser-sync start --port 3000 --proxy 'http://tpl-project-local-domain.test/' --watch --files 'content' 'site' --open"
"npx tailwindcss -i assets/main.css -o $dev/main.css --postcss --watch"
"npx esbuild --bundle --watch --sourcemap assets/*.js --outdir=$dev"
)
NODE_ENV=development npx concurrently -n " bs,css, js" "${COMMANDS[@]}"
}
prod () { #: run through the whole pipeline
dist="public/assets/dist"
export NODE_ENV=production
clean-dev
clean-dist
vendor-assets
# Site
npx tailwindcss -i assets/main.css -o $dist/main.css --postcss
npx esbuild --bundle --target=es6 --minify assets/*.js --outdir=$dist
npx hash-and-manifest
}
install () { #: Install all dependencies
composer install -no && pnpm i
}
clean-dev() {
rm -rf public/assets/dev
}
clean-dist() {
rm -rf public/assets/dist
}
vendor-assets() {
rsync -a assets/vendor public/assets
}
fonts () { #: subset fonts
setopt extended_glob
assets='public/assets'
rm -r $assets/fonts 2>/dev/null
mkdir -p $assets/fonts 2>/dev/null
cp assets/fonts-raw/* ./$assets/fonts/
wait
for f in $assets/fonts/*; do
glyphhanger --formats=woff2 --subset="$(dirname "$0")/$f" --css --LATIN --whitelist="ÁÄÉÍÓÔÚÝáäéíóôúýČĎŇŠŽčďňšžŤťŔ༾Ĺ" --string --json
done
wait
rm ./$assets/fonts/^*subset.*
}
#
# BOILERPLATE
#
r='./task'
NAME='tpl-project-name'
about () { #: show help & commands
echo "$NAME script runner"
echo "Commands:"
sed -nr 's/^(.*) \(\).* #: (.*)$/ \1\t\2/p' $r | expand -20
}
if [[ $# -gt 0 ]]; then
command="$1"
shift 1
if type "$command" 2>/dev/null | grep -q 'function'; then
$command "$@"
else
about
echo "No command '$command'."
fi;
else
# about
dev
fi