|
|
|
@ -205,7 +205,6 @@ struct NpmData { |
|
|
|
|
pub struct ManifestAndUnsedKeys { |
|
|
|
|
pub manifest: CargoManifest, |
|
|
|
|
pub unused_keys: BTreeSet<String>, |
|
|
|
|
pub has_possible_typo: bool, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl CrateData { |
|
|
|
@ -266,17 +265,15 @@ impl CrateData { |
|
|
|
|
let manifest = &mut toml::Deserializer::new(&manifest); |
|
|
|
|
|
|
|
|
|
let mut unused_keys = BTreeSet::new(); |
|
|
|
|
let mut has_possible_typo = false; |
|
|
|
|
let levenshtein_threshold = 1; |
|
|
|
|
|
|
|
|
|
let manifest: CargoManifest = serde_ignored::deserialize(manifest, |path| { |
|
|
|
|
let path_string = path.to_string(); |
|
|
|
|
|
|
|
|
|
if levenshtein(WASM_PACK_METADATA_KEY, &path_string) == levenshtein_threshold { |
|
|
|
|
has_possible_typo = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if path_string.contains(WASM_PACK_METADATA_KEY) { |
|
|
|
|
if path_string.starts_with("package.metadata") |
|
|
|
|
&& (path_string.contains("wasm-pack") |
|
|
|
|
|| levenshtein(WASM_PACK_METADATA_KEY, &path_string) <= levenshtein_threshold) |
|
|
|
|
{ |
|
|
|
|
unused_keys.insert(path_string); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -285,19 +282,12 @@ impl CrateData { |
|
|
|
|
Ok(ManifestAndUnsedKeys { |
|
|
|
|
manifest, |
|
|
|
|
unused_keys, |
|
|
|
|
has_possible_typo, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// Iterating through all the passed `unused_keys` and output
|
|
|
|
|
/// a warning for each unknown key.
|
|
|
|
|
pub fn warn_for_unused_keys(manifest_and_keys: &ManifestAndUnsedKeys) { |
|
|
|
|
if manifest_and_keys.has_possible_typo { |
|
|
|
|
PBAR.warn(&format!( |
|
|
|
|
"It's possible that you misspelled the \"{}\" setting in your Cargo.toml.", |
|
|
|
|
WASM_PACK_METADATA_KEY |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
manifest_and_keys.unused_keys.iter().for_each(|path| { |
|
|
|
|
PBAR.warn(&format!( |
|
|
|
|
"\"{}\" is a unknown key and will be ignored. Please check your Cargo.toml.", |
|
|
|
|