-
Notifications
You must be signed in to change notification settings - Fork 824
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
Port "wapm install" to Wasmer #3317
Conversation
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.
Okay overall, just make sure we don't implement the SplitVersion
x number of times, since we seem to reuse it for specifying generators, bindings, install, run, etc.
lib/cli/src/commands/install.rs
Outdated
} | ||
|
||
fn target(&self) -> Target { | ||
match (self.pip, self.npm, self.yarn) { |
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 would refactor this to:
if self.pip { return Target::Pip; }
if self.npm { return Target::Npm }
if self.yarn { return Target::Yarn }
unreachable!("Clap should ensure at least one item in the \"bindings\" group is specified")
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 prefer to keep the match
version because it shows that exactly one of pip
, npm
, and yarn
can be set.
I don't want a potential update to those fields (e.g. updating the #[clap]
attribute to clap 4.0 or adding a new package manager) to mess up the logic so --npm --pip
is accidentally allowed and we silently favour pip
.
lib/cli/src/commands/install.rs
Outdated
|
||
/// The full name and optional version number for a WAPM package. | ||
#[derive(Debug)] | ||
struct PackageSpecifier { |
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.
Technically you can use SplitVersion
from crate::cli
, which also has tests. I would want to avoid making n number of copies for parsing the namespace/name@version
thing.
Line 274 in 0d5e7d9
SplitVersion::new("registry.wapm.io/graphql/python/python").unwrap(), |
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've switched the Add
command over to SplitVersion
.
At some point we'll need to refactor SplitVersion
. Currently it's fulfilling multiple somewhat contradictory roles (URL dependency, a package name, a package's command, etc.) and we're silently ignoring issues (e.g. wasmer add --yarn namespace/package:command
would be permitted, but doesn't make logical sense).
lib/registry/src/lib.rs
Outdated
@@ -347,6 +350,15 @@ pub enum Registries { | |||
Multi(MultiRegistry), | |||
} | |||
|
|||
impl Registries { | |||
pub fn current(&self) -> &str { |
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 will likely conflict with my code, just copy the entire impl Registries
block from wapm-cli
.
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.
It's not wrong, but I will have to overwrite it when I port the other commands from wapm-cli
.
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've copied the impl Registries
block across. You'll probably get some small merge conflicts because I replaced println!()
statements with log::warn!()
and friends - libraries shouldn't be printing to stdout.
@@ -1296,6 +1308,30 @@ pub struct BindingsGenerator { | |||
pub command: String, | |||
} | |||
|
|||
impl Display for BindingsGenerator { |
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.
Isn't this the same syntax as crate::cli::SplitVersion
again? Want to avoid having n number of parsers / displayers for the same syntax
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.
Good catch! I didn't know that had been ported across from wapm
, so I implemented it again.
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.
Actually, it's not quite the same as SplitVersion
because this includes a command in the output and the struct has different fields. The SplitVersion
type is also part of the wasmer-cli
crate, so I can't import it.
@@ -10,6 +10,8 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C | |||
|
|||
## Added | |||
|
|||
- [#3317](https://github.com/wasmerio/wasmer/pull/3317) Add a `wasmer add` command for adding bindings for a WAPM package to your project (only Python and JavaScript are supported for now) |
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.
By the way, you don't need to update the changelog at all in PRs. When doing a release, I just do gh search --prs --merged --repo wasmerio/wasmer
and then copy the list since the last release. Otherwise I'd have to look if every PR has included this message. So this commit is nice, but pointless.
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.
Ah okay. We should probably update the pull request template so we don't tell people to update the changelog.
f111faf
to
660992c
Compare
660992c
to
c3ebf06
Compare
bors r+ |
This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried. Additional information: {"message":"Changes must be made through a pull request.","documentation_url":"https://docs.github.com/articles/about-protected-branches"} |
This ports the
wapm install
command (wasmerio/wapm-cli#262) to thewasmer
CLI under the namewasmer add
.Fixes #3303.