Skip to content

Commit

Permalink
fix(crates-io): fix late partial publishing (#4491)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Feb 6, 2025
1 parent 7c19334 commit 0a9b9bc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions scripts/src/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ wasm_init() {
rustup update stable
fi

rustup target add wasm32v1-none --toolchain stable
rustup target add wasm32v1-none --toolchain nightly
}

Expand Down
4 changes: 2 additions & 2 deletions utils/crates-io/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub fn crates_io_name(pkg: &str) -> &str {
}

/// Patch specified manifest by provided name.
pub fn patch(pkg: &Package, is_published: bool) -> Result<Manifest> {
let mut manifest = Manifest::new(pkg, is_published)?;
pub fn patch(pkg: &Package, is_published: bool, is_actualized: bool) -> Result<Manifest> {
let mut manifest = Manifest::new(pkg, is_published, is_actualized)?;
let doc = &mut manifest.mutable_manifest;

match manifest.name.as_str() {
Expand Down
6 changes: 5 additions & 1 deletion utils/crates-io/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Workspace {
mutable_manifest,
path,
is_published: true,
is_actualized: true,
},
lock_file: LockFile {
content,
Expand Down Expand Up @@ -190,12 +191,14 @@ pub struct Manifest {
pub path: PathBuf,
/// Whether the crate is published
pub is_published: bool,
/// Whether the current version is published
pub is_actualized: bool,
}

impl Manifest {
/// Complete the manifest of the specified crate from
/// the workspace manifest
pub fn new(pkg: &Package, is_published: bool) -> Result<Self> {
pub fn new(pkg: &Package, is_published: bool, is_actualized: bool) -> Result<Self> {
let original_manifest: DocumentMut = fs::read_to_string(&pkg.manifest_path)?.parse()?;
let mut mutable_manifest = original_manifest.clone();

Expand All @@ -210,6 +213,7 @@ impl Manifest {
mutable_manifest,
path: pkg.manifest_path.clone().into(),
is_published,
is_actualized,
})
}

Expand Down
8 changes: 5 additions & 3 deletions utils/crates-io/src/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl Publisher {
}

let mut is_published = false;
let mut is_actualized = false;

if verify {
match crate::verify_owners(name).await? {
Expand All @@ -116,10 +117,11 @@ impl Publisher {

if verify && crate::verify(name, &version, self.simulator.as_ref()).await? {
println!("Package {name}@{version} already published!");
continue;
is_actualized = true;
}

self.graph.push(handler::patch(pkg, is_published)?);
self.graph
.push(handler::patch(pkg, is_published, is_actualized)?);
}

workspace.complete(self.index.clone(), self.simulator.is_some())?;
Expand Down Expand Up @@ -188,7 +190,7 @@ impl Publisher {
path,
is_published,
..
} in self.graph.iter()
} in self.graph.iter().filter(|m| !m.is_actualized)
{
println!("Publishing {path:?}");
let status = crate::publish(&path.to_string_lossy())?;
Expand Down

0 comments on commit 0a9b9bc

Please sign in to comment.