[tools] caddy = "latest" [tasks.gen] run = "weft -gitignore . https://tjp.lol" [tasks.clean] description = "Remove Weft-generated outputs" run = ''' if [ -f .weft-generated.json ]; then jq -r '.outputs[]' .weft-generated.json | xargs -n 1 rm -f else awk '/^# BEGIN weft generated outputs$/ { generated = 1; next } /^# END weft generated outputs$/ { generated = 0 } generated { sub(/^\//, ""); print }' .gitignore | xargs -n 1 rm -f fi rm -f .weft-txn-* ''' [tasks.dev] description = "Run the auto-reloading dev server and open the site in a browser" run = "(sleep 1 && open http://127.0.0.1:8001/) & exec air" [tasks."deploy:weft"] description = "Build and deploy weft to tjp.lol" run = ''' set -euo pipefail cd ../weft env GOOS=freebsd GOARCH=amd64 go build -o weft-freebsd-amd64 . trap 'rm weft-freebsd-amd64' EXIT scp weft-freebsd-amd64 t@tjp.lol:weft ssh t@tjp.lol "doas sh -c 'mv weft /jail/containers/code-push/usr/local/bin/weft && chown root:wheel /jail/containers/code-push/usr/local/bin/weft'" ''' [tasks."deploy:site"] description = "Push the current 'main' bookmark to deploy the site" run = "jj git push -b main" [tasks.deploy] description = "Push the 'main' bookmark and update weft on the server" run = "mise run deploy:weft && mise run deploy:site" [tasks."upload:image"] description = "Upload an image to the production server" usage = ''' arg "file" arg "path" ''' run = ''' set -euo pipefail fname=`basename $usage_file` dirpath=`dirname $usage_path` site_imgs=/jail/volumes/web/https/images scp $usage_file t@tjp.lol:/tmp/$fname ssh t@tjp.lol "doas sh -c 'mkdir -p ${site_imgs}/${dirpath} && mv /tmp/${fname} ${site_imgs}/${usage_path} && chown root:wheel ${site_imgs}/${usage_path}'" '''