-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lockfiles): Use Cargo.lock
to identify wasm-bindgen versions
#324
Conversation
Crap, I forgot to add these test cases:
|
e37b06b
to
790ff99
Compare
Added the missing test cases. |
src/command/test.rs
Outdated
step_add_wasm_target, | ||
step_build_tests, | ||
step_check_crate_config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about it some more, we might want to still check the crate config as the first thing we do, but have checking crate config not check wasm-bindgen versions. Then when we go to install wasm-bindgen, we look at the lockfile at tjhat time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i think that's a good call. crate config should def be one of the first things we do because it's a quick fix for folks who it fails for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done.
790ff99
to
44c0565
Compare
44c0565
to
5334bcc
Compare
src/lockfile.rs
Outdated
} | ||
|
||
/// Get the version of `wasm-bindgen` dependency used in the `Cargo.lock`. | ||
pub fn get_wasm_bindgen_version(path: &Path) -> Result<String, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might recommend returning Option
here to leave Error
for things like I/O errors and such, and then callers can determine if they care about the presence or not
src/lockfile.rs
Outdated
fn read_cargo_lock(crate_path: &Path) -> Result<Lockfile, Error> { | ||
let lock_path = get_lockfile_path(crate_path)?; | ||
let mut lockfile = String::new(); | ||
File::open(lock_path)?.read_to_string(&mut lockfile)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend fs::read_to_string(...)
nowadays
Ideally this would also use failure
's with_context
method to add the filename to the error message too
This lets us leverage `cargo` for semver finding and then ensure that we get the exact same version of the CLI that cargo selected. It also lets us support fuzzy dependencies like "0.2" instead of exact dependencies like "0.2.21" again.
This way when future wasm-bindgen version are published the tests will continue working!
5334bcc
to
76a34b3
Compare
This can be somewhat expensive, so make sure we don't have to chew through too much!
76a34b3
to
9b24dcb
Compare
closing in favor of #365. hopefully for the last time <3<3 |
fixes #270, #344
This lets us leverage
cargo
for semver finding and then ensure that we get the exact same version of the CLI that cargo selected. It also lets us support fuzzy dependencies like "0.2" instead of exact dependencies like "0.2.21" again.Additionally, this lets us remove the
_
vs-
normalization, sincecargo
also handles that for us.This is a updated version of #302. In addition to a rebase, this also removes the old
Cargo.toml
checking code, migrates callers to this new version, and ensures that we never check the wasm-bindgen version until after aCargo.lock
exists.Make sure these boxes are checked! 📦✅
rustfmt
installed and have yourcloned directory set to nightly
$ rustup override set nightly $ rustup component add rustfmt-preview --toolchain nightly
rustfmt
on the code base before submitting✨✨ 😄 Thanks so much for contributing to wasm-pack! 😄 ✨✨