11use serde:: Serialize ;
22use tsify:: Tsify ;
33
4- use crate :: { commit:: StringCommit , date:: Date , plugin:: full:: FullPluginData } ;
4+ use crate :: { commit:: StringCommit , date:: Date , plugin:: { full:: FullPluginData , LicenseInfo } } ;
55
66#[ derive( Tsify , Debug , Clone , Serialize ) ]
77#[ tsify( into_wasm_abi) ]
@@ -21,7 +21,7 @@ pub enum PluginWarning {
2121 Unlicensed ( PluginWarningUnlicensed ) ,
2222 NoLicense ( PluginWarningNoLicense ) ,
2323 MismatchedLicense ( PluginWarningMismatchedLicense ) ,
24- MissingExtendedData ( PLuginWarningMissingExtendedData ) ,
24+ MissingExtendedData ( PluginWarningMissingExtendedData ) ,
2525 MissingRepoData ( PluginWarningMissingRepoData ) ,
2626}
2727
@@ -78,7 +78,7 @@ pub struct PluginWarningMismatchedLicense {
7878
7979#[ derive( Tsify , Debug , Clone , Serialize ) ]
8080#[ tsify( into_wasm_abi) ]
81- pub struct PLuginWarningMissingExtendedData {
81+ pub struct PluginWarningMissingExtendedData {
8282 pub severity : PluginWarningSeverity ,
8383}
8484
@@ -202,27 +202,20 @@ fn get_license_warnings(data: &FullPluginData, warnings: &mut Vec<PluginWarning>
202202 return ;
203203 } ;
204204
205- if repo. license_file == "explicitly unlicensed" {
205+ if repo. file_license == LicenseInfo :: Known ( "explicitly unlicensed" . to_string ( ) ) {
206206 warnings. push ( PluginWarning :: Unlicensed ( PluginWarningUnlicensed {
207207 severity : PluginWarningSeverity :: CAUTION ,
208208 } ) ) ;
209- } else if repo. license_file == "no license" {
209+ } else if repo. file_license == LicenseInfo :: NotFound {
210210 warnings. push ( PluginWarning :: NoLicense ( PluginWarningNoLicense {
211211 severity : PluginWarningSeverity :: CAUTION ,
212212 } ) ) ;
213- } else if repo. license_file != "unknown"
214- && repo. license_file != "not found"
215- && repo. package_json_license != "unknown"
216- && repo. package_json_license != "not found"
217- && repo. package_json_license != "no license"
218- && !repo. package_json_license . starts_with ( & repo. license_file )
219- && !repo. license_file . starts_with ( & repo. package_json_license )
220- {
213+ } else if !repo. file_license . matches ( & repo. package_json_license ) {
221214 warnings. push ( PluginWarning :: MismatchedLicense (
222215 PluginWarningMismatchedLicense {
223216 severity : PluginWarningSeverity :: CAUTION ,
224- license_file : repo. license_file . clone ( ) ,
225- package_json_license : repo. package_json_license . clone ( ) ,
217+ license_file : repo. file_license . to_fancy_string ( ) ,
218+ package_json_license : repo. package_json_license . to_fancy_string ( ) ,
226219 } ,
227220 ) ) ;
228221 }
@@ -231,7 +224,7 @@ fn get_license_warnings(data: &FullPluginData, warnings: &mut Vec<PluginWarning>
231224fn get_missing_warnings ( data : & FullPluginData , warnings : & mut Vec < PluginWarning > ) {
232225 if data. extended . is_none ( ) {
233226 warnings. push ( PluginWarning :: MissingExtendedData (
234- PLuginWarningMissingExtendedData {
227+ PluginWarningMissingExtendedData {
235228 severity : PluginWarningSeverity :: DANGER ,
236229 } ,
237230 ) ) ;
0 commit comments