-
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
generate #623
generate #623
Conversation
38fc3e1
to
a6bbcfd
Compare
this is still a WIP since i need to sort the testing but i'd love some feedback on the approach. additionally @alexcrichton if you rebase your #625 i think you can take advantage of some of the refactoring i've done here |
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.
All's looking good to me!
docs/src/commands/generate.md
Outdated
The `wasm-pack generate` command can be given and optional name argument, e.g.: | ||
|
||
``` | ||
wasm-pack generate --name myproject |
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 wonder if it might be better to wasm-pack generate myproject
? That jives with cargo new
and I think commands like git init
as well.
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.
so the reason i did a flag was that you can also pass --template.. we could have name be positional tho and still have the other flags. i think conforming to similar tools makes more sense.
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 yeah I meant just having --name
be a positional argument instead (but keeping --template
). We could perhaps take a leaf out of git clone
's book though and do something like:
# generates a new project named "foo"
$ wasm-pack generate https://github.com/alexcrichton/foo
# generates a new project named "bar"
$ wasm-pack generate https://github.com/alexcrichton/foo bar
I don't really feel too strongly any direction, but I do think that having the name be a positional argument rather than a flag might be nice.
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 really like this.
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 think this would be a neat feature but let's put it off til another PR as i'm worried this one is getting a lil big
use serde::Deserialize; | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct Krate { |
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.
FWIW I typically only use "krate" for the literal name "crate", but other variations like "Crate" I tend to use instead of "Krate" b/c it's valid Rust both ways (only crate
is invalid)
@@ -23,6 +23,7 @@ glob = "0.2" | |||
log = "0.4.6" | |||
openssl = { version = '0.10.11', optional = true } | |||
parking_lot = "0.6" | |||
reqwest = "0.9.14" |
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.
Could this perhaps use curl
to use the same downloading backend as binary-install
?
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.
would you mind if we did this in another PR- it's... a little tricky with the interface and i'm worried this PR is getting pretty big cc @drager
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.
Personally I think that would be fine, as long as we have a tracking issue for it and planning to do it in the near future.
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.
Ok, deferring it to an issue seems fine
To bikeshed a little bit, if we ignore backwards compatibility and that |
@alexcrichton i honestly had the same feeling when i was making this PR, i think init has been deprecated for a lot of cycles at this point. i'd be open to replacing it, or we can go with |
I think I'd vote for |
88ce9b5
to
fb9a671
Compare
One recommendation I might have for testing comes from Cargo's test suite which is to use local file paths to git repositories. The general idea would be to make a builder-style API which creates a bunch of files in a directory, and then has a The various git helpers for Cargo are located in https://github.com/rust-lang/cargo/blob/master/tests/testsuite/support/git.rs and largely rely on |
@@ -3,9 +3,14 @@ | |||
`wasm-pack` has several commands to help you during the process of building | |||
a Rust-generated WebAssembly project. | |||
|
|||
- `init`: This command has been deprecated in favor of `build`. | |||
- `new`: This command generates a new project for you using a template. [Learn more][generate] |
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.
Broken link here? Shouldn't it be [Learn more][new]?
``` | ||
|
||
The mode pass can be either "normal", "noinstall", or "force". "normal is passed by | ||
degault. |
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.
degault. | |
default. |
@@ -52,8 +52,8 @@ matrix: | |||
- cargo fmt --version | |||
- cargo fmt --all -- --check | |||
- rustup component add clippy-preview | |||
- cargo clippy --version | |||
- cargo clippy | |||
# - cargo clippy --version |
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.
Shouldn't these be brought back?
1. `cd hello-wasm` | ||
1. Run `wasm-pack build`. | ||
1. This tool generates files in a `pkg` dir | ||
1. To publish to npm, run `wasm-pack publish`. You may need to login to the |
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.
Should we consider mention that publishing to npm is optional?
@ashleygwilliams About the tests I agree with you that some more test would be nice to have. However, I think we can add those afterwards. Let's get this PR merged first. |
fixes #373
noinstall