Skip to content

Commit

Permalink
new: Add version_spec types. (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj authored Sep 25, 2023
1 parent b2ff5e5 commit 62b59d6
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### 🚀 Updates

- Added support for `f32` and `f64` types.
- Added `type_version_spec` feature, that implements schematic types for the `version_spec` crate.

#### ⚙️ Internal

Expand Down
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ relative-path = "1.9.0"
semver = "1.0.19"
serde = { version = "1.0.188", features = ["derive"] }
url = "2.4.1"
version_spec = "0.1.0"
warpgate = "0.5.7"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,5 @@ The following Cargo features are available:
- `type_relative_path` - Implements schematic for the `relative-path` crate.
- `type_semver` - Implements schematic for the `semver` crate.
- `type_url` - Implements schematic for the `url` crate.
- `type_version_spec` - Implements schematic for the `version_spec` crate.
- `type_warpgate` - Implements schematic for the `warpgate` crate.
7 changes: 5 additions & 2 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "schematic"
version = "0.11.7"
edition = "2021"
license = "MIT"
description = "A light-weight, macro-based, layered serde configuration and schema library."
description = "A light-weight, macro-based, and layered serde configuration and schema library."
repository = "https://github.com/moonrepo/schematic"
readme = "../../README.md"

Expand Down Expand Up @@ -54,9 +54,10 @@ yaml = ["dep:serde_yaml"]

type_chrono = ["schematic_types/chrono"]
type_regex = ["schematic_types/regex"]
type_relative_path = ["schematic_types/relative-path"]
type_relative_path = ["schematic_types/relative_path"]
type_semver = ["schematic_types/semver"]
type_url = ["schematic_types/url"]
type_version_spec = ["schematic_types/version_spec"]
type_warpgate = ["schematic_types/warpgate"]

valid_email = ["garde/email"]
Expand All @@ -74,6 +75,7 @@ schematic = { path = ".", features = [
"type_relative_path",
"type_semver",
"type_url",
"type_version_spec",
"type_warpgate",
"url",
"valid_email",
Expand All @@ -89,4 +91,5 @@ regex = { workspace = true }
relative-path = { workspace = true, features = ["serde"] }
semver = { workspace = true, features = ["serde"] }
url = { workspace = true, features = ["serde"] }
version_spec = { workspace = true }
warpgate = { workspace = true }
2 changes: 2 additions & 0 deletions crates/config/tests/generator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct GenConfig {
url: Option<url::Url>,
version: Option<semver::Version>,
version_req: semver::VersionReq,
spec: version_spec::VersionSpec,
spec_unresolved: version_spec::UnresolvedVersionSpec,
id: warpgate::Id,
locator: Option<warpgate::PluginLocator>,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ expression: "fs::read_to_string(file).unwrap()"
"number",
"path",
"relPath",
"spec",
"specUnresolved",
"string",
"time",
"url",
Expand Down Expand Up @@ -92,6 +94,12 @@ expression: "fs::read_to_string(file).unwrap()"
"type": "string",
"format": "path"
},
"spec": {
"type": "string"
},
"specUnresolved": {
"type": "string"
},
"string": {
"type": "string"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export type GenConfig = {
number: number,
path: string,
relPath: string,
spec: string,
specUnresolved: string,
string: string,
time: string,
url: string | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface GenConfig {
number: number;
path: string;
relPath: string;
spec: string;
specUnresolved: string;
string: string;
time: string;
url: string | null;
Expand Down
7 changes: 5 additions & 2 deletions crates/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@ regex = { workspace = true, optional = true }
relative-path = { workspace = true, optional = true }
semver = { workspace = true, optional = true }
url = { workspace = true, optional = true }
version_spec = { workspace = true, optional = true }
warpgate = { workspace = true, optional = true }

[dev-dependencies]
schematic_types = { path = ".", features = [
"chrono",
"regex",
"relative-path",
"relative_path",
"semver",
"url",
"version_spec",
"warpgate",
] }

[features]
default = []
chrono = ["dep:chrono"]
regex = ["dep:regex"]
relative-path = ["dep:relative-path"]
relative_path = ["dep:relative-path"]
semver = ["dep:semver"]
url = ["dep:url"]
version_spec = ["dep:version_spec"]
warpgate = ["dep:warpgate"]
10 changes: 9 additions & 1 deletion crates/types/src/externals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod regex_feature {
impl_string_format!(regex::Regex, "regex");
}

#[cfg(feature = "relative-path")]
#[cfg(feature = "relative_path")]
mod relative_path_feature {
use super::*;

Expand All @@ -85,6 +85,14 @@ mod url_feature {
impl_string_format!(url::Url, "uri");
}

#[cfg(feature = "version_spec")]
mod version_spec_feature {
use super::*;

impl_string!(version_spec::UnresolvedVersionSpec);
impl_string!(version_spec::VersionSpec);
}

#[cfg(feature = "warpgate")]
mod warpgate_feature {
use super::*;
Expand Down

0 comments on commit 62b59d6

Please sign in to comment.