[package]
name = "bestool"
version = "1.9.1"
edition = "2024"
default-run = "bestool"

authors = ["Félix Saparelli <felix@passcod.name>", "BES Developers <contact@bes.au>"]
license = "GPL-3.0-or-later"
description = "BES Deployment tooling"
keywords = ["bes", "tamanu", "tupaia"]
categories = ["command-line-utilities"]
repository = "https://github.com/beyondessential/bestool"
exclude.workspace = true

[lints]
workspace = true

[dependencies]
algae-cli = { version = "1.0.19", path = "../algae-cli", optional = true }
bestool-alertd = { version = "2.0.1", path = "../alertd", default-features = false, optional = true }
bestool-psql = { version = "1.5.1", path = "../psql", default-features = false, optional = true }
binstalk-downloader = { version = "0.13.38", optional = true, features = ["hickory-dns"] }
blake3 = { version = "1.8.5", optional = true }
boxcar = "0.2.14"
bytes = "1.10.0"
base64 = { version = "0.22.1", optional = true }
clap = { workspace = true, features = ["env", "unicode", "string"] }
clap_complete = { version = "4.6.3", optional = true }
clap_complete_nushell = { version = "4.5.8", optional = true }
clap-markdown = "0.1.5"
comfy-table = { version = "7.2.0", optional = true }
ctrlc = { version = "3.5.0", optional = true }
detect-targets = { version = "0.1.84", optional = true }
dirs = { version = "6.0.0", optional = true }
duct = { version = "1.1.0", optional = true }
dunce = { version = "1.0.5", optional = true }
embedded-graphics = { version = "0.8.1", optional = true }
fs4 = { version = "1.1.0", features = ["tokio"], optional = true }
futures = { workspace = true }
glob = { version = "0.3.3", optional = true }
hickory-resolver = { version = "0.26.1", optional = true }
indicatif = { workspace = true, optional = true }
itertools = { workspace = true, optional = true }
jiff = { version = "0.2.24", features = ["serde"] }
json5 = { version = "1.3.0", optional = true }
leon = { version = "3.0.1", optional = true }
leon-macros = { version = "1.0.2", optional = true }
lloggs = "1.1.0"
mailgun-rs = { version = "2.0.2", optional = true }
merkle_hash = { version = "3.8.0", optional = true }
miette = { workspace = true, features = ["fancy"] }
mimalloc = "0.1.50"
node-semver = { version = "2.2.0", optional = true }
owo-colors = { version = "4.2.3", optional = true }
p256 = { version = "0.13.2", features = ["pkcs8", "pem"], optional = true }
percent-encoding = { version = "2.3.1", optional = true }
privilege = { version = "0.3.0", optional = true }
pulldown-cmark = { version = "0.13.3", optional = true }
quick-xml = { version = "0.39.2", features = ["serialize"], optional = true }
rand_core = { version = "0.6", features = ["getrandom"], optional = true }
regex = { version = "1.11.2", optional = true }
reqwest = { workspace = true }
rpi-st7789v2-driver = { version = "0.3.12", path = "../rpi-st7789v2-driver", features = ["miette"], optional = true }
rppal = { version = "0.22.1", optional = true }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.143"
serde_path_to_error = { version = "0.1.17", optional = true }
serde_yaml = { version = "0.9.33", optional = true }
ssh-key = { version = "0.6.6", optional = true }
sysinfo = { workspace = true, optional = true }
target-tuples = { version = "0.16.1", optional = true }
tempfile = "3.21.0"
tera = { version = "1.19.1", optional = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["full"] }
tokio-postgres = { version = "0.7.17", features = ["with-jiff-0_2", "with-uuid-1"], optional = true }
tokio-util = { workspace = true, optional = true }
tracing = { workspace = true }
upgrade = { version = "2.0.1", optional = true }
uuid = { version = "1.23.1", features = ["v4"] }
walkdir = { version = "2.5.0", optional = true }
zip = { version = "8.6.0", optional = true, default-features = false, features = ["time"] }
zmq = { version = "0.10.0", optional = true }

[target.'cfg(windows)'.dependencies]
tauri-winrt-notification = { version = "0.7.2", optional = true }
windows-acl = { version = "0.3.0", optional = true }
windows-env = { version = "0.2.0", optional = true }
windows-service = { version = "0.8.0", optional = true }

[build-dependencies]
windows_exe_info = { version = "0.5.2", features = ["manifest"] }

[features]
default = ["caddy", "completions", "crypto", "rdp", "self-update", "ssh", "tamanu"]

## Common dep groups (not meant to be used directly)
download = ["dep:binstalk-downloader", "dep:detect-targets", "dep:hickory-resolver"]

## Subcommands
caddy = ["download", "dep:tera"]
completions = ["dep:clap_complete", "dep:clap_complete_nushell"]
crypto = ["dep:algae-cli", "dep:blake3", "dep:merkle_hash"]
file = ["dep:blake3", "dep:indicatif", "dep:tokio-util"]
rdp = ["dep:duct", "dep:privilege", "dep:quick-xml", "dep:tauri-winrt-notification", "dep:windows-service"]
self-update = ["download", "dep:upgrade", "dep:windows-env"]
ssh = ["dep:dirs", "dep:duct", "dep:fs4", "dep:ssh-key", "dep:privilege", "dep:windows-acl"]

## Tamanu subcommands
tamanu = [ # enable all tamanu subcommands
	"tamanu-alerts",
	"tamanu-alertd",
	"tamanu-artifacts",
	"tamanu-backup",
	"tamanu-backup-configs",
	"tamanu-config",
	"tamanu-url",
	"tamanu-doctor",
	"tamanu-download",
	"tamanu-find",
	"tamanu-greenmask",
	"tamanu-meta-ticket",
	"tamanu-psql",
]
tamanu-alerts = [
	"__tamanu",
	"tamanu-config",
	"dep:bestool-alertd",
	"dep:mailgun-rs",
	"dep:p256",
	"dep:pulldown-cmark",
	"dep:serde_path_to_error",
	"dep:serde_yaml",
	"dep:sysinfo",
	"dep:tera",
	"dep:tokio-postgres",
	"dep:walkdir",
]
tamanu-alertd = ["__tamanu", "tamanu-config", "dep:bestool-alertd", "dep:p256", "dep:serde_path_to_error", "dep:serde_yaml", "dep:tokio-postgres", "dep:walkdir"]
tamanu-artifacts = ["__tamanu", "dep:comfy-table", "dep:detect-targets", "dep:target-tuples"]
tamanu-backup = ["__tamanu", "file", "tamanu-config", "dep:bestool-psql", "dep:algae-cli", "dep:duct"]
tamanu-backup-configs = ["__tamanu", "tamanu-backup", "dep:walkdir", "dep:zip"]
tamanu-config = ["__tamanu"]
tamanu-doctor = [
	"__tamanu",
	"tamanu-config",
	"dep:bestool-alertd",
	"dep:bestool-psql",
	"dep:duct",
	"dep:hickory-resolver",
	"dep:owo-colors",
	"dep:p256",
	"dep:sysinfo",
	"dep:tokio-postgres",
]
tamanu-url = ["__tamanu", "tamanu-config", "dep:percent-encoding"]
tamanu-download = ["__tamanu", "download"]
tamanu-find = ["__tamanu"]
tamanu-greenmask = ["__tamanu", "tamanu-config", "dep:bestool-psql", "dep:dunce", "dep:serde_yaml", "dep:walkdir"]
tamanu-meta-ticket = ["__tamanu", "tamanu-config", "dep:base64", "dep:bestool-psql", "dep:p256", "dep:rand_core", "dep:sysinfo", "dep:tokio-postgres"]
tamanu-psql = ["__tamanu", "tamanu-config", "dep:bestool-psql"]
__tamanu = [ # internal feature to enable the tamanu subcommand common code
	"dep:dirs",
	"dep:glob",
	"dep:itertools",
	"dep:json5",
	"dep:leon-macros",
	"dep:leon",
	"dep:node-semver",
	"dep:regex",
]

## Iti subcommands
iti = [ # enable all iti subcommands
	"iti-battery",
	"iti-lcd",
	"iti-temperature",
]
iti-battery = ["__iti", "dep:rppal"]
iti-lcd = ["__iti", "dep:ctrlc", "dep:embedded-graphics", "dep:rpi-st7789v2-driver", "dep:sysinfo"]
iti-temperature = ["__iti", "dep:duct"]
__iti = ["dep:zmq"] # internal feature to enable the iti subcommand common code

## Legacy noop features to avoid breaking builds
tamanu-upgrade = []
walg = []

[dev-dependencies]
trycmd = "1.2.0"

[package.metadata.binstall]
pkg-url = "https://tools.ops.tamanu.io/bestool/{ version }/{ target }/{ name }{ binary-ext }"
pkg-fmt = "bin"
