Skip to content

feat(publish): allow directory path for wkg publish#212

Merged
ricochet merged 14 commits into
bytecodealliance:mainfrom
mkatychev:feat/publish-directory
Jun 22, 2026
Merged

feat(publish): allow directory path for wkg publish#212
ricochet merged 14 commits into
bytecodealliance:mainfrom
mkatychev:feat/publish-directory

Conversation

@mkatychev

@mkatychev mkatychev commented Jun 2, 2026

Copy link
Copy Markdown
Member

Moved parts of wkg wit build into shared function to allow logic reuse between publish and build:

/// Build a WIT package from a directory, returning the resolved package ref, optional
/// version, and the encoded component bytes.
pub async fn build_wit_dir(
dir: impl AsRef<Path>,
client: CachingClient<FileCache>,
mut lock_file: &mut LockFile,
) -> anyhow::Result<(PackageRef, Option<Version>, Vec<u8>)> {
check_dir(&dir).await?;
let wkg_config = wasm_pkg_core::config::Config::load().await?;
let result = wit::build_package(&wkg_config, dir, &mut lock_file, client).await?;
Ok(result)
}

wkg publish ./wit/ will abort if it would result in changing wkg.lock

Comment thread crates/wasm-pkg-core/src/lock.rs
Comment thread crates/wkg/src/main.rs
Comment thread crates/wkg/src/main.rs Outdated
Comment thread crates/wasm-pkg-common/src/lib.rs Outdated
mkatychev and others added 2 commits June 18, 2026 16:14
Co-authored-by: Bailey Hayes <ricochet@users.noreply.github.com>
Co-authored-by: Bailey Hayes <ricochet@users.noreply.github.com>
@mkatychev mkatychev requested a review from ricochet June 18, 2026 21:19
Comment thread crates/wkg/src/main.rs
wit::build_wit_dir(&self.path, client.clone(), &mut lock_file).await?;
// There is no way to check if we are in a git repository unlike `cargo publish --allow-dirty` so
// check against previous values.
if lock_file != prev_lock_ref && !self.dry_run {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this check is even needed yet

@vados-cosmonic vados-cosmonic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mkatychev this looks great!

Either in this PR or as a follow up (this PR has certainly been waiting too long!), what do you think about adding a regression test for this real quick? If there are any convenient-to-add adjacent tests those would be great too, but reading over the code this makes me think that we should really be testing the at multiple levels (core/client & CLI) to make sure we don't regress.

@ricochet ricochet merged commit 9dc967c into bytecodealliance:main Jun 22, 2026
3 checks passed
@mkatychev

mkatychev commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@vados-cosmonic I agree, one of my hesitations in doing config/data driven coverage testing is that I plan to add overlay support cargo style sometime after #215. Note this commit from the multi package publishing PR:

https://github.com/mkatychev/wasm-pkg-tools/blob/9de6af4ed5fad54b71f7ccb8b8e77b953e0910c5/crates/wkg/src/main.rs#L273-L304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants