# SPDX-FileCopyrightText: Gergely Nagy
# SPDX-FileContributor: Gergely Nagy
#
# SPDX-License-Identifier: MIT

set unstable

# Display this help screen
help:
    @just --list

# Format all sources
fmt:
    treefmt --ci

# Verify that all licenses are properly declared
license-check:
    reuse lint

# Build the crate documentation
crate-docs *OPTIONS:
  cargo doc -p iocaine-powder --lib {{ OPTIONS }}

# Update & commit a dependency. The dependency must be either "flake", "assets", "robots-json", or "fennel".
update dependency="flake" *OPTIONS:
  @just update-{{ dependency }} {{ OPTIONS }}

[private]
update-flake *OPTIONS:
  nix flake update --commit-lock-file {{ OPTIONS }}
  GIT_EDITOR=cat git commit --amend --gpg-sign

[private, script]
update-robots-json ROBOTS_VERSION="1.50":
  echo "* Updating ai.robots.txt/robots.json..."
  mkdir -p iocaine-label/assets
  curl -sL --fail --fail-early -o iocaine-label/assets/robots.json \
        "https://github.com/ai-robots-txt/ai.robots.txt/raw/refs/tags/v{{ ROBOTS_VERSION }}/robots.json"

[private, script]
update-fennel FENNEL_VERSION="1.6.1":
  echo "* Updating the fennel compiler..."
  mkdir -p iocaine-label/assets
  curl -sL --fail --fail-early "https://fennel-lang.org/downloads/fennel-{{ FENNEL_VERSION }}.lua" \
       -o iocaine-label/assets/fennel.lua

[private]
update-assets: update-robots-json update-fennel
