#:schema ./schema/mise.json

min_version = "2024.1.1"
[env]
_.file = [".env"]
_.path = ["./target/debug"]
FOO = "bar"
FOO_NUM = 1
THIS_PROJECT = "{{config_root}}-{{cwd}}"

[tools]
#node = 'lts'
python = { version = "latest" }
shellcheck = "0.10"
shfmt = "3"
jq = "latest"
"cargo:cargo-edit" = "latest"
"cargo:cargo-show" = "latest"
"cargo:git-cliff" = "latest"
"npm:markdownlint-cli" = "0.38"
"npm:prettier" = "3"
direnv = "latest"
actionlint = "latest"
ripgrep = "latest"
"pipx:toml-sort" = "latest"
usage = "latest"
#python = { version = "latest", virtualenv = "{{env.HOME}}/.cache/venv" }
#ruby = "3.1"

[plugins]
nnnn = 'https://github.com/mise-plugins/rtx-nodejs#main'

[alias.tiny]
abc = '1'

[task_config]
includes = ["tasks"]

[tasks]
clean = "cargo clean"
release = "cargo release"
signal-test = "node ./test/fixtures/signal-test.js"
ci = { depends = ["format", "build", "test"] }
pre-commit = { depends = ["render", "lint"] }
lint = { depends = ["lint:*"] }

[tasks.build]
alias = "b"
run = "cargo build --color always --all-features"
#sources = ["Cargo.*", "src/**/*.rs"]
#outputs = ["target/debug/mise"]

[tasks."render:usage"]
depends = ["build"]
env = { CLICOLOR_FORCE = "0" }
run = [
    "mise usage > mise.usage.kdl",
    "mise generate task-docs > tasks.md",
    "usage generate markdown -m --out-dir docs/cli --url-prefix /cli --html-encode --file mise.usage.kdl",
    "markdownlint --fix docs/cli",
]

[tasks."render:completions"]
depends = ["build", "render:usage"]
env = { NO_COLOR = "1" }
run = '''
#!/usr/bin/env bash
set -xeuo pipefail
mise completion bash > completions/mise.bash
mise completion zsh > completions/_mise
mise completion fish > completions/mise.fish
'''

[tasks."render:registry"]
depends = ["build"]
run = "./scripts/render-registry.js"

[tasks."render:mangen"]
depends = ["build"]
env = { NO_COLOR = "1" }
run = "mise render-mangen"

[tasks."render:help"]
depends = ["build"]
env = { NO_COLOR = "1" }
run = ["mise render-help", "mise run show-output-on-failure -- mise x node@latest -- npx markdown-magic"]
sources = ["mise"]
outputs = ["README.md"]

[tasks.render]
alias = "render"
depends = ["render:*"]

[tasks.snapshots]
description = "update test snapshots"
run = "cargo insta test --accept --unreferenced delete"

[tasks.test]
description = "run all tests"
alias = 't'
run = ["mise tasks run test:unit", "mise tasks run test:e2e"]

[tasks."test:unit"]
description = "run unit tests"
run = "cargo test --all-features"
env = { CARGO_TERM_COLOR = "always", "RUST_TEST_THREADS" = "1" }

[tasks."docker:image"]
description = "build docker image from Dockerfile"
run = 'docker build --build-arg GITHUB_TOKEN=$GITHUB_API_TOKEN $root -f $root/packaging/dev/Dockerfile -t ghcr.io/jdx/mise:dev'

[tasks."docker:run"]
description = "run a command inside of development docker container"
run = 'docker run -ti --rm -e GITHUB_API_TOKEN -e TEST_ALL -v $root:/mise -v /tmp/mise/target:/tmp/mise/target -v /tmp/mise/registry:/tmp/mise/registry -w /mise ghcr.io/jdx/mise:dev'
depends = ["docker:image"]

[tasks."docker:cargo"]
description = "run cargo inside of development docker container"
run = 'mise tasks run docker:run cargo'

[tasks."docker:mise"]
description = "run mise inside of development docker container"
run = "mise tasks run -- docker:cargo run --"

[tasks."docker:e2e"]
description = "run e2e tests inside of development docker container"
run = "mise tasks run docker:mise run test:e2e"
