Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest: fix serialization of component dependency section #2842

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>")]
karthik2804 marked this conversation as resolved.
Show resolved Hide resolved
#[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
Loading