|
|
|
@ -723,20 +723,11 @@ struct Node<'a> {
|
|
|
|
|
// begin.elapsed(),
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
fn parse_manifests( |
|
|
|
|
fn parse_one_manifest( |
|
|
|
|
config: &Config, |
|
|
|
|
crate_versions: HashMap<String, Vec<IndexMeta>>, |
|
|
|
|
) -> Result<HashMap<String, Vec<VersionMeta>>, Error> { |
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
|
|
|
|
|
let out: HashMap<String, Vec<VersionMeta>> = crate_versions |
|
|
|
|
.into_par_iter() |
|
|
|
|
// .into_iter()
|
|
|
|
|
.map(|(crate_name, versions)| -> Result<(String, Vec<VersionMeta>), Error> { |
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
debug!(%crate_name, "parsing manifests"); |
|
|
|
|
let mut version_metas = Vec::new(); |
|
|
|
|
for index_meta in versions { |
|
|
|
|
crate_name: &str, |
|
|
|
|
index_meta: IndexMeta, |
|
|
|
|
) -> Result<VersionMeta, Error> { |
|
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
|
trace!(%crate_name, %version, "processing crate version"); |
|
|
|
|
let dot_crate_path = config.src.crate_files_dir |
|
|
|
@ -794,7 +785,7 @@ fn parse_manifests(
|
|
|
|
|
// // .other_options(["--frozen"].into_iter().map(|x| x.to_owned()).collect::<Vec<_>>())
|
|
|
|
|
// .exec()?;
|
|
|
|
|
|
|
|
|
|
version_metas.push(VersionMeta { |
|
|
|
|
Ok(VersionMeta { |
|
|
|
|
index_meta, |
|
|
|
|
manifest_files, |
|
|
|
|
dot_crate_path, |
|
|
|
@ -803,11 +794,44 @@ fn parse_manifests(
|
|
|
|
|
tmp, |
|
|
|
|
modified_manifest_toml: None, |
|
|
|
|
// meta,
|
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn parse_manifests( |
|
|
|
|
config: &Config, |
|
|
|
|
crate_versions: HashMap<String, Vec<IndexMeta>>, |
|
|
|
|
) -> Result<HashMap<String, Vec<VersionMeta>>, Error> { |
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
|
|
|
|
|
let out: HashMap<String, Vec<VersionMeta>> = crate_versions |
|
|
|
|
.into_par_iter() |
|
|
|
|
// .into_iter()
|
|
|
|
|
.filter_map(|(crate_name, versions)| -> Option<(String, Vec<VersionMeta>)> { |
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
debug!(%crate_name, "parsing manifests"); |
|
|
|
|
let mut version_metas = Vec::new(); |
|
|
|
|
let mut n_err = 0; |
|
|
|
|
for index_meta in versions { |
|
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
|
match parse_one_manifest(config, &crate_name, index_meta) { |
|
|
|
|
Ok(meta) => { |
|
|
|
|
version_metas.push(meta); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Err(err) => { |
|
|
|
|
error!(?err, %crate_name, %version, "failed to parse manifest; skipping"); |
|
|
|
|
n_err += 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
debug!(%crate_name, n_err, "parsed {} manifests in {:?}", version_metas.len(), begin.elapsed()); |
|
|
|
|
if version_metas.is_empty() { |
|
|
|
|
warn!(%crate_name, n_err, "parsed zero manifests successfully for crate!"); |
|
|
|
|
None |
|
|
|
|
} else { |
|
|
|
|
Some((crate_name, version_metas)) |
|
|
|
|
} |
|
|
|
|
debug!(%crate_name, "parsed {} manifests in {:?}", version_metas.len(), begin.elapsed()); |
|
|
|
|
Ok((crate_name, version_metas)) |
|
|
|
|
}).collect::<Result<_, Error>>()?; |
|
|
|
|
}).collect(); |
|
|
|
|
|
|
|
|
|
info!("parsed crate version manifests in {:?}", begin.elapsed()); |
|
|
|
|
|
|
|
|
@ -822,6 +846,11 @@ fn parse_manifests(
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// conditional dep tables aren't handled right:
|
|
|
|
|
//
|
|
|
|
|
// [target.'cfg(not(target_env = "msvc"))'.dependencies]
|
|
|
|
|
// dep-one = { version = "0.1.0", registry = "old-registry" }
|
|
|
|
|
//
|
|
|
|
|
fn edit_dep_registries( |
|
|
|
|
dep_key: &str, |
|
|
|
|
manifest: &mut toml_edit::Document, |
|
|
|
@ -832,11 +861,17 @@ fn edit_dep_registries(
|
|
|
|
|
let src_index_url = config.src.index_url.as_str(); |
|
|
|
|
let dst_index_url = config.dst.index_url.as_str(); |
|
|
|
|
|
|
|
|
|
let Some(deps) = manifest.get_mut(dep_key).and_then(|item| item.as_table_like_mut()) else { |
|
|
|
|
trace!("missing key in manifest toml: {}", dep_key); |
|
|
|
|
return Ok(()) |
|
|
|
|
}; |
|
|
|
|
let dep_key_ends_with = format!(".{dep_key}"); |
|
|
|
|
|
|
|
|
|
let it = manifest.iter_mut() |
|
|
|
|
.filter(|(k, v)| { |
|
|
|
|
k == dep_key || k.ends_with(&dep_key_ends_with) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (outer_k, outer_v) in it { |
|
|
|
|
let Some(deps) = outer_v.as_table_like_mut() else { |
|
|
|
|
anyhow::bail!("failed to cast deps item as table"); |
|
|
|
|
}; |
|
|
|
|
for (k, v) in deps.iter_mut() { |
|
|
|
|
let Some(t) = v.as_table_like_mut() else { continue }; |
|
|
|
|
|
|
|
|
@ -854,6 +889,7 @@ fn edit_dep_registries(
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -978,9 +1014,11 @@ fn cargo_publish_modified_source_dir(config: &Config, meta: &VersionMeta) -> Res
|
|
|
|
|
let stdout = std::str::from_utf8(&output.stdout).unwrap_or("utf8err"); |
|
|
|
|
let stderr = std::str::from_utf8(&output.stderr).unwrap_or("utf8err"); |
|
|
|
|
error!(exit_status = ?output.status, "cargo publish error!\nstdout:\n{}\nstderr:\n:{}\n\n", stdout, stderr); |
|
|
|
|
if !stderr.contains("already exists") { |
|
|
|
|
debug!("cargo publish error - original Cargo.toml:\n***\n{}\n***", meta.manifest_files.cargo_toml_orig); |
|
|
|
|
debug!("cargo publish error - modified Cargo.toml:\n***\n{}\n***", meta.modified_manifest_toml.as_ref().unwrap()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
info!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "finished cargo publish in {:?}", begin.elapsed()); |
|
|
|
|
Ok(()) |
|
|
|
|