set shell := ["/bin/sh", "-c"]

rev := shell("git rev-parse HEAD")
cid := shell("jj show -r @- -T change_id --no-patch")

build:
  @just clean
  maivi build 2>&1 | hl -P
  cp -r static build/

serve:
  @just build
  (cd build && althttpd)

watch:
  watchexec -r -w lua -w static -- just serve

deploy:
  @just build
  git branch -D build || true
  git checkout --orphan build
  git ls-files -z | xargs -0 rm -f
  mv build/* .
  git add .
  git commit -m "$(echo 'build: deploy\n\ncommit: {{rev}}\nchange-id: {{cid}}')"
  git push --force origin build
  git checkout '{{rev}}'

clean:
  rm -rf build
