Skip to content

Commit 6bf6e2f

Browse files
committed
Polish.
1 parent eab63e3 commit 6bf6e2f

File tree

9 files changed

+78
-34
lines changed

9 files changed

+78
-34
lines changed

Cargo.lock

+45-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ reqwest-middleware = { version = "0.4.0", default-features = false, features = [
3232
"http2",
3333
] }
3434
reqwest-netrc = "0.1.2"
35-
rustc-hash = "2.1.0"
36-
scc = "2.3.0"
35+
rustc-hash = "2.1.1"
36+
scc = "2.3.3"
3737
schematic = { version = "0.17.11", default-features = false }
3838
semver = { version = "1.0.25", features = ["serde"] }
3939
serde = { version = "1.0.217", features = ["derive"] }
@@ -66,7 +66,7 @@ starbase_utils = { version = "0.10.1", default-features = false, features = [
6666
thiserror = "2.0.11"
6767
tokio = { version = "1.43.0", features = ["full", "tracing"] }
6868
tracing = "0.1.41"
69-
uuid = { version = "1.12.1", features = ["v4"] }
69+
uuid = { version = "1.13.1", features = ["v4"] }
7070

7171
[profile.dist]
7272
inherits = "release"

crates/pdk-api/src/api/build_source.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::is_false;
22
use crate::ToolContext;
33
use rustc_hash::FxHashMap;
44
use semver::VersionReq;
5-
use std::collections::HashMap;
65
use std::path::PathBuf;
76
use system_env::SystemDependency;
87
use warpgate_api::{api_enum, api_struct};
@@ -67,7 +66,8 @@ api_struct!(
6766
pub exe: PathBuf,
6867

6968
/// Secondary executables, relative from the source root.
70-
pub exes: HashMap<String, PathBuf>,
69+
#[serde(default, skip_serializing_if = "FxHashMap::is_empty")]
70+
pub exes: FxHashMap<String, PathBuf>,
7171

7272
/// The Git source location for the builder.
7373
pub git: GitSource,

crates/pdk-api/src/api/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ api_struct!(
3131
}
3232
);
3333

34-
api_enum!(
34+
api_unit_enum!(
3535
/// Supported types of plugins.
36-
#[derive(Default)]
3736
pub enum PluginType {
3837
#[serde(alias = "CLI")]
3938
CommandLine,
@@ -69,9 +68,8 @@ api_struct!(
6968
}
7069
);
7170

72-
api_enum!(
71+
api_unit_enum!(
7372
/// Supported strategies for installing a tool.
74-
#[derive(Copy, Default)]
7573
pub enum InstallStrategy {
7674
BuildFromSource,
7775
#[default]

crates/system-env/src/deps.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ impl Default for DependencyName {
3636
#[serde(default)]
3737
pub struct DependencyConfig {
3838
/// Only install on this architecture.
39+
#[serde(skip_serializing_if = "Option::is_none")]
3940
pub arch: Option<SystemArch>,
4041

4142
/// The dependency name or name(s) to install.
4243
pub dep: DependencyName,
4344

4445
/// Only install with this package manager.
46+
#[serde(skip_serializing_if = "Option::is_none")]
4547
pub manager: Option<SystemPackageManager>,
4648

4749
/// Only install on this operating system.
50+
#[serde(skip_serializing_if = "Option::is_none")]
4851
pub os: Option<SystemOS>,
4952

50-
/// Install using sudo.
51-
pub sudo: bool,
52-
5353
/// The version to install.
54+
#[serde(skip_serializing_if = "Option::is_none")]
5455
pub version: Option<String>,
5556
}
5657

crates/system-env/src/pm_vendor.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ impl ListParser {
3434
let mut packages = HashMap::default();
3535

3636
for line in output.lines() {
37-
if let Some(caps) = self.regex.captures(line.trim()) {
37+
let line = line.trim();
38+
39+
if line.starts_with('#') || line.starts_with("//") {
40+
continue;
41+
}
42+
43+
if let Some(caps) = self.regex.captures(line) {
3844
let Some(name) = caps.name("package") else {
3945
continue;
4046
};

crates/system-env/src/system.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl System {
6565

6666
for arg in base_args {
6767
if arg == "$" {
68-
args.extend(self.extract_package_args(dep_config, &pm_config, &pm)?);
68+
args.extend(self.extract_package_args(dep_config, &pm_config, pm)?);
6969
} else {
7070
args.push(arg);
7171
}
@@ -97,7 +97,7 @@ impl System {
9797
for arg in base_args {
9898
if arg == "$" {
9999
for dep_config in dep_configs {
100-
args.extend(self.extract_package_args(dep_config, &pm_config, &pm)?);
100+
args.extend(self.extract_package_args(dep_config, &pm_config, pm)?);
101101
}
102102
} else {
103103
args.push(arg);

crates/warpgate-api/src/host_funcs.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
use crate::virtual_path::VirtualPath;
2-
use crate::{api_enum, api_struct, AnyResult};
2+
use crate::{api_struct, api_unit_enum, AnyResult};
33
use rustc_hash::FxHashMap;
44
use serde::de::DeserializeOwned;
55

6-
api_enum!(
6+
api_unit_enum!(
77
/// Target where host logs should be written to.
8-
#[derive(Default)]
9-
#[serde(rename_all = "lowercase")]
108
pub enum HostLogTarget {
119
Stderr,
1210
Stdout,

crates/warpgate-api/src/lib.rs

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ macro_rules! api_enum {
3131
};
3232
}
3333

34+
/// Wrap a unit-only enum with common derives and serde required attributes.
35+
#[macro_export]
36+
macro_rules! api_unit_enum {
37+
($struct:item) => {
38+
#[derive(Clone, Copy, Debug, Default, serde::Deserialize, PartialEq, serde::Serialize)]
39+
#[serde(rename_all = "kebab-case")]
40+
#[cfg_attr(feature = "schematic", derive(schematic::Schematic))]
41+
$struct
42+
};
43+
}
44+
3445
api_struct!(
3546
/// Represents an empty input.
3647
pub struct EmptyInput {}

0 commit comments

Comments
 (0)