@@ -9,7 +9,6 @@ use anyhow::{Context, Result};
99use semver:: VersionReq ;
1010use serde:: { Deserialize , Serialize } ;
1111use tokio:: io:: AsyncWriteExt ;
12- use wasm_metadata:: { Link , LinkType , RegistryMetadata } ;
1312
1413/// The default name of the configuration file.
1514pub const CONFIG_FILE_NAME : & str = "wkg.toml" ;
@@ -75,56 +74,22 @@ pub struct Override {
7574pub struct Metadata {
7675 /// The authors of the package.
7776 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
78- pub authors : Option < Vec < String > > ,
79- /// The categories of the package.
80- #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
81- pub categories : Option < Vec < String > > ,
77+ pub author : Option < String > ,
8278 /// The package description.
8379 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
8480 pub description : Option < String > ,
8581 /// The package license.
8682 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
87- pub license : Option < String > ,
88- /// The package documentation URL.
83+ pub licenses : Option < String > ,
84+ /// The package source code URL.
8985 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
90- pub documentation : Option < String > ,
86+ pub source : Option < String > ,
9187 /// The package homepage URL.
9288 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
9389 pub homepage : Option < String > ,
94- /// The package repository URL .
90+ /// The package source control revision .
9591 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
96- pub repository : Option < String > ,
97- }
98-
99- impl From < Metadata > for wasm_metadata:: RegistryMetadata {
100- fn from ( value : Metadata ) -> Self {
101- let mut meta = RegistryMetadata :: default ( ) ;
102- meta. set_authors ( value. authors ) ;
103- meta. set_categories ( value. categories ) ;
104- meta. set_description ( value. description ) ;
105- meta. set_license ( value. license ) ;
106- let mut links = Vec :: new ( ) ;
107- if let Some ( documentation) = value. documentation {
108- links. push ( Link {
109- ty : LinkType :: Documentation ,
110- value : documentation,
111- } ) ;
112- }
113- if let Some ( homepage) = value. homepage {
114- links. push ( Link {
115- ty : LinkType :: Homepage ,
116- value : homepage,
117- } ) ;
118- }
119- if let Some ( repository) = value. repository {
120- links. push ( Link {
121- ty : LinkType :: Repository ,
122- value : repository,
123- } ) ;
124- }
125- meta. set_links ( ( !links. is_empty ( ) ) . then_some ( links) ) ;
126- meta
127- }
92+ pub revision : Option < String > ,
12893}
12994
13095#[ cfg( test) ]
@@ -144,13 +109,12 @@ mod tests {
144109 } ,
145110 ) ] ) ) ,
146111 metadata : Some ( Metadata {
147- authors : Some ( vec ! [ "foo" . to_string( ) , "bar" . to_string( ) ] ) ,
148- categories : Some ( vec ! [ "foo" . to_string( ) , "bar" . to_string( ) ] ) ,
149- description : Some ( "foo" . to_string ( ) ) ,
150- license : Some ( "foo" . to_string ( ) ) ,
151- documentation : Some ( "foo" . to_string ( ) ) ,
152- homepage : Some ( "foo" . to_string ( ) ) ,
153- repository : Some ( "foo" . to_string ( ) ) ,
112+ author : Some ( "Foo Bar" . to_string ( ) ) ,
113+ description : Some ( "Foobar baz" . to_string ( ) ) ,
114+ licenses : Some ( "FBB" . to_string ( ) ) ,
115+ source : Some ( "https://gitfoo/bar" . to_string ( ) ) ,
116+ homepage : Some ( "https://foo.bar" . to_string ( ) ) ,
117+ revision : Some ( "f00ba4" . to_string ( ) ) ,
154118 } ) ,
155119 } ;
156120
0 commit comments