[workspace]
members = ["macros", "examples"]

[workspace.dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.0", features = ["full"] }
validator = { version = "0.19", features = ["derive"] }
schemars = "0.8"
thiserror = "2.0"
criterion = { version = "0.5", features = ["html_reports"] }

[package]
name = "confers"
version = "0.2.1"
edition = "2021"
rust-version = "1.75"
authors = ["Kirky.X <kirkyx@outlook.com>"]
license = "MIT"
description = "A modern, type-safe configuration management library with validation, diff, and hot-reload support"
documentation = "https://docs.rs/confers"
homepage = "https://github.com/Kirky-X/confers"
repository = "https://github.com/Kirky-X/confers"
readme = "README.md"
keywords = ["configuration", "config", "type-safe", "serde", "validation"]
categories = ["config", "development-tools", "parser-implementations"]
include = ["src/**", "tests/**", "README.md", "LICENSE-MIT", "LICENSE-APACHE"]

[dependencies]
# Core dependencies (always required)
confers-macros = { path = "macros", version = "0.2.1", optional = true }
serde = { workspace = true }
serde_json = "1.0"
toml = "0.8"
serde_yaml = "0.9"
serde_ini = "0.2"
figment = { version = "0.10", features = ["toml", "json", "yaml", "env"] }
thiserror = { workspace = true }
anyhow = "1.0"

# Validation (optional but recommended)
validator = { workspace = true, optional = true }

# Async runtime (required for many features)
tokio = { workspace = true }

# Path handling
dirs = "5.0"
path-absolutize = "3.1"

# Utility dependencies (using std::sync::LazyLock instead of once_cell/lazy_static)
shellexpand = "3.1.1"
# Optimize regex - only enable essential features
regex = { version = "1.10", default-features = false, features = ["std", "perf-literal"] }
chrono = { version = "0.4", features = ["serde"], optional = true }
sysinfo = { version = "0.33", optional = true }

# Logging (optional - can be disabled for smaller binary)
tracing = { version = "0.1", optional = true }
tracing-subscriber = { version = "0.3", optional = true }

# Schema generation
schemars = { workspace = true }

# URL handling
url = "2.5.7"

# LRU cache
lru = { version = "0.16", optional = true }

# Encryption dependencies (optional)
aes = { version = "0.8.4", optional = true }
cbc = { version = "0.1.2", optional = true }
rand = { version = "0.9.2", optional = true }
base64 = { version = "0.22.1", optional = true }
pbkdf2 = { version = "0.12.2", optional = true }
hmac = { version = "0.12.1", optional = true }
sha2 = { version = "0.10.9", optional = true }
aes-gcm = { version = "0.10.3", optional = true }
zeroize = { version = "1.8", features = ["zeroize_derive"], optional = true }
hex = { version = "0.4", optional = true }
flate2 = { version = "1.0", optional = true }

# File watching (optional)
notify = { version = "6.1", optional = true }
notify-debouncer-full = { version = "0.3", optional = true }

# CLI tools (optional)
clap = { version = "4.5", features = ["derive", "env", "cargo"], optional = true }
clap_complete = { version = "4.5", optional = true }

# Remote configuration (optional)
etcd-client = { version = "0.14", optional = true, features = ["tls"] }
reqwest = { version = "0.11", features = ["json", "rustls-tls", "blocking"], default-features = false, optional = true }
failsafe = { version = "1.3.0", optional = true }
rustls = { version = "0.23", default-features = false, features = ["ring", "logging", "std", "tls12"], optional = true }
rustls-pki-types = { version = "1.13.2", optional = true }
tokio-rustls = { version = "0.26.4", default-features = false, features = ["ring", "logging", "tls12"], optional = true }

# Schema validation (optional)
jsonschema = { version = "0.28", optional = true }

# Parallel processing (optional)
rayon = { version = "1.10", optional = true }

[dev-dependencies]
tempfile = "3.10"
assert_cmd = "2.0"
predicates = "3.1"
temp-env = "0.3"
mockall = "0.12"
wiremock = "0.6"
warp = "0.3"
cargo-tarpaulin = "0.27"
criterion = { workspace = true }

[features]
default = ["derive"]

# Preset feature combinations
minimal = ["derive"]                      # 仅核心配置加载
recommended = ["derive", "validation"]   # 推荐：配置加载 + 验证
dev = ["derive", "validation", "cli", "schema", "audit", "monitoring", "tracing"]  # 开发配置
production = ["derive", "validation", "watch", "encryption", "remote", "monitoring", "tracing"]  # 生产配置

# Core features
derive = ["confers-macros"]
validation = ["validator", "confers-macros/validation"]

# Optional features
watch = ["notify", "notify-debouncer-full"]
audit = []
schema = ["jsonschema"]
parallel = ["rayon"]
monitoring = ["sysinfo"]
tracing = ["dep:tracing", "dep:tracing-subscriber"]

# Remote configuration features
remote = ["etcd", "consul", "http", "rustls", "rustls-pki-types", "tokio-rustls", "failsafe", "base64"]
etcd = ["etcd-client"]
consul = ["reqwest"]
http = ["reqwest"]

# Encryption features
encryption = ["aes", "cbc", "rand", "base64", "pbkdf2", "hmac", "sha2", "aes-gcm", "zeroize", "lru", "chrono", "hex", "flate2"]

# CLI features
cli = ["clap", "clap_complete", "derive", "encryption", "validation", "confers-macros/cli"]

# Full feature set (enables all optional features)
full = [
    "derive",
    "validation",
    "watch",
    "audit",
    "schema",
    "parallel",
    "remote",
    "encryption",
    "cli",
    "monitoring",
    "tracing",
]
