Skip to content

Commit

Permalink
Merge pull request #2842 from karthik2804/manifest_serde
Browse files Browse the repository at this point in the history
manifest: fix serialization of component dependency section
  • Loading branch information
fibonacci1729 authored Sep 19, 2024
2 parents 02918e2 + 672a4e4 commit dada4d8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 31 deletions.
10 changes: 1 addition & 9 deletions crates/manifest/src/schema/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,20 +197,12 @@ pub struct Component {

/// Component dependencies
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
#[serde(try_from = "Map<DependencyName, ComponentDependency>")]
#[serde(transparent)]
pub struct ComponentDependencies {
/// `dependencies = { "foo:bar" = ">= 0.1.0" }`
pub inner: Map<DependencyName, ComponentDependency>,
}

impl TryFrom<Map<DependencyName, ComponentDependency>> for ComponentDependencies {
type Error = anyhow::Error;

fn try_from(value: Map<DependencyName, ComponentDependency>) -> Result<Self, Self::Error> {
Ok(ComponentDependencies { inner: value })
}
}

impl ComponentDependencies {
/// This method validates the correct specification of dependencies in a
/// component section of the manifest. See the documentation on the methods
Expand Down
42 changes: 20 additions & 22 deletions crates/manifest/tests/ui/maximal.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,26 @@
},
"dependencies_inherit_configuration": true,
"dependencies": {
"inner": {
"a:b/c": {
"version": "^1.2.3",
"registry": "my-registry.com",
"package": "a:b",
"export": "foo"
},
"foo:bar/[email protected]": {
"path": "path/to/component.wasm",
"export": null
},
"fib:fub/fob": {
"path": "path/to/component.wasm",
"export": "my-export"
},
"fizz:buzz": ">=0.1.0",
"abc:[email protected]": {
"version": "=0.1.0",
"registry": null,
"package": null,
"export": null
}
"a:b/c": {
"version": "^1.2.3",
"registry": "my-registry.com",
"package": "a:b",
"export": "foo"
},
"foo:bar/[email protected]": {
"path": "path/to/component.wasm",
"export": null
},
"fib:fub/fob": {
"path": "path/to/component.wasm",
"export": "my-export"
},
"fizz:buzz": ">=0.1.0",
"abc:[email protected]": {
"version": "=0.1.0",
"registry": null,
"package": null,
"export": null
}
}
}
Expand Down

0 comments on commit dada4d8

Please sign in to comment.