diff --git a/crates/packager/Cargo.toml b/crates/packager/Cargo.toml index 0f429c3a..2b70c6bd 100644 --- a/crates/packager/Cargo.toml +++ b/crates/packager/Cargo.toml @@ -3,29 +3,34 @@ name = "cargo-packager" version = "0.10.2" description = "Executable packager and bundler distributed as a CLI and library." authors = [ - "CrabNebula Ltd.", - "Tauri Programme within The Commons Conservancy", - "George Burton " + "CrabNebula Ltd.", + "Tauri Programme within The Commons Conservancy", + "George Burton ", ] -keywords = [ "bundle", "package", "cargo" ] +keywords = ["bundle", "package", "cargo"] categories = [ - "command-line-interface", - "command-line-utilities", - "development-tools::cargo-plugins", - "development-tools::build-utils", - "os" + "command-line-interface", + "command-line-utilities", + "development-tools::cargo-plugins", + "development-tools::build-utils", + "os", ] edition = { workspace = true } license = { workspace = true } repository = { workspace = true } +[[bin]] +name = "cargo-packager" +# path = "src/bins/cli.rs" +required-features = ["cli"] + [package.metadata.docs.rs] -rustdoc-args = [ "--cfg", "doc_cfg" ] +rustdoc-args = ["--cfg", "doc_cfg"] default-target = "x86_64-unknown-linux-gnu" targets = [ - "x86_64-pc-windows-msvc", - "x86_64-unknown-linux-gnu", - "x86_64-apple-darwin" + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "x86_64-apple-darwin", ] [lints.rust] @@ -33,13 +38,13 @@ targets = [ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(doc_cfg)'] } [features] -default = [ "cli", "rustls-tls" ] -cli = [ "clap", "dep:tracing-subscriber" ] -schema = [ "schemars", "cargo-packager-utils/schema" ] -clap = [ "dep:clap", "cargo-packager-utils/clap" ] -native-tls = [ "ureq/native-tls" ] -native-tls-vendored = [ "native-tls", "native-tls/vendored" ] -rustls-tls = [ "ureq/tls" ] +default = ["cli", "rustls-tls"] +cli = ["clap", "dep:tracing-subscriber"] +schema = ["schemars", "cargo-packager-utils/schema"] +clap = ["dep:clap", "cargo-packager-utils/clap"] +native-tls = ["ureq/native-tls"] +native-tls-vendored = ["native-tls", "native-tls/vendored"] +rustls-tls = ["ureq/tls"] [dependencies] thiserror = { workspace = true } @@ -49,16 +54,18 @@ dunce = { workspace = true } dirs = { workspace = true } semver = { workspace = true } base64 = { workspace = true } -clap = { workspace = true, optional = true, features = [ "env" ] } +clap = { workspace = true, optional = true, features = ["env"] } tracing = { workspace = true } -tracing-subscriber = { version = "0.3", optional = true, features = [ "env-filter" ] } +tracing-subscriber = { version = "0.3", optional = true, features = [ + "env-filter", +] } toml = "0.8" cargo_metadata = "0.18" ureq = { version = "2.9", default-features = false } hex = "0.4" sha1 = "0.10" sha2 = "0.10" -zip = { version = "0.6", default-features = false, features = [ "deflate" ] } +zip = { version = "0.6", default-features = false, features = ["deflate"] } handlebars = "5.1" glob = "0.3" relative-path = "1.9" @@ -70,9 +77,11 @@ flate2 = "1.0" strsim = "0.11" schemars = { workspace = true, optional = true } native-tls = { version = "0.2", optional = true } -cargo-packager-utils = { version = "0.1.1", path = "../utils", features = [ "serde" ] } +cargo-packager-utils = { version = "0.1.1", path = "../utils", features = [ + "serde", +] } icns = { package = "tauri-icns", version = "0.1" } -time = { workspace = true, features = [ "formatting" ] } +time = { workspace = true, features = ["formatting"] } image = "0.25" tempfile = "3" plist = "1" @@ -80,15 +89,12 @@ plist = "1" [target."cfg(target_os = \"windows\")".dependencies] winreg = "0.52" once_cell = "1.19" -uuid = { version = "1", features = [ "v4", "v5" ] } +uuid = { version = "1", features = ["v4", "v5"] } regex = "1.10" - [target."cfg(target_os = \"windows\")".dependencies.windows-sys] - version = "0.52" - features = [ - "Win32_System_SystemInformation", - "Win32_System_Diagnostics_Debug" -] +[target."cfg(target_os = \"windows\")".dependencies.windows-sys] +version = "0.52" +features = ["Win32_System_SystemInformation", "Win32_System_Diagnostics_Debug"] [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"netbsd\", target_os = \"openbsd\"))".dependencies] image = "0.25" diff --git a/crates/packager/src/main.rs b/crates/packager/src/bin/cargo-packager.rs similarity index 100% rename from crates/packager/src/main.rs rename to crates/packager/src/bin/cargo-packager.rs diff --git a/crates/packager/src/error.rs b/crates/packager/src/error.rs index 3823fddf..718f8b0e 100644 --- a/crates/packager/src/error.rs +++ b/crates/packager/src/error.rs @@ -13,6 +13,7 @@ use thiserror::Error; pub enum Error { /// Clap error. #[error(transparent)] + #[cfg(feature = "cli")] Clap(#[from] clap::error::Error), /// Error while reading cargo metadata. #[error("Failed to read cargo metadata: {0}")] diff --git a/crates/packager/src/lib.rs b/crates/packager/src/lib.rs index bbc61dde..47cf1439 100644 --- a/crates/packager/src/lib.rs +++ b/crates/packager/src/lib.rs @@ -98,6 +98,7 @@ pub use sign::SigningConfig; pub use package::{package, PackageOutput}; use util::PathExt; +#[cfg(feature = "cli")] fn parse_log_level(verbose: u8) -> tracing::Level { match verbose { 0 => tracing_subscriber::EnvFilter::builder() @@ -144,6 +145,7 @@ pub fn init_tracing_subscriber(verbosity: u8) { } } +#[cfg(feature = "cli")] enum TracingFormatter { WithoutTime( tracing_subscriber::fmt::format::Format, @@ -151,10 +153,12 @@ enum TracingFormatter { WithTime(tracing_subscriber::fmt::format::Format), } +#[cfg(feature = "cli")] struct ShellFieldVisitor { message: String, } +#[cfg(feature = "cli")] impl tracing::field::Visit for ShellFieldVisitor { fn record_str(&mut self, field: &tracing::field::Field, value: &str) { if field.name() == "message" { @@ -169,6 +173,7 @@ impl tracing::field::Visit for ShellFieldVisitor { } } +#[cfg(feature = "cli")] impl tracing_subscriber::fmt::FormatEvent for TracingFormatter where S: tracing::Subscriber + for<'a> tracing_subscriber::registry::LookupSpan<'a>,