[tools]
rust = { version = "latest", profile = "default", components = "rust-analyzer,rustfmt,clippy", targets = "wasm32-unknown-unknown" }
node = "lts"
pnpm = "latest"
bun = "latest"
deno = "latest"
"cargo:wasm-pack" = "latest"

[tasks.fmt]
description = "Format all files"
depends = ["fmt:rust", "fmt:markdown"]

[tasks."fmt:rust"]
description = "Format Rust code"
run = "cargo fmt"

[tasks."fmt:markdown"]
description = "Format Markdown files"
run = "cargo run -- --write"

[tasks.check]
description = "Run all quality checks"
depends = ["check:clippy", "check:fmt", "check:type", "check:markdown"]

[tasks."check:clippy"]
description = "Run clippy linter"
run = "cargo clippy -- -D warnings"

[tasks."check:fmt"]
description = "Check code formatting"
run = "cargo fmt --check"

[tasks."check:type"]
description = "Run Rust type checking"
run = "cargo check"

[tasks."check:markdown"]
description = "Check Markdown formatting"
run = "cargo run -- --check"

[tasks.test]
description = "Run all tests"
depends = ["test:rust", "test:wasm"]

[tasks."test:rust"]
description = "Run Rust tests"
run = "cargo test"

[tasks."test:wasm"]
description = "Run WASM package tests"
depends = ["build:wasm"]
run = "pnpm --filter @hongdown/wasm test"

[tasks."build:wasm"]
description = "Build WASM package"
run = """
wasm-pack build --target web --features wasm
mkdir -p packages/wasm/pkg
cp -r pkg/* packages/wasm/pkg/
pnpm --filter @hongdown/wasm install
pnpm --filter @hongdown/wasm build
"""
