Skip to content
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

Add an experimental installer for wasm-pack #307

Merged
merged 1 commit into from
Sep 17, 2018

Conversation

alexcrichton
Copy link
Contributor

This commit kicks off the addition of installers for wasm-pack, with the main
goals of being:

  • Users should have a one-click (ideally) solution to download and install
    wasm-pack.
  • We should ideally not have to worry about picking up "heavy" dependencies in
    wasm-pack like C++ or C code (if necessary).

The general idea here is very similar to rustup (and in fact a good deal of code
is copied from them!). The installation worklow for wasm-pack in theory after
this commit looks like:

  1. First, a users visits the installer landing page. A preview is available at
    https://alexcrichton.github.io/wasm-pack/installer/. Clearly this page needs
    a better stylesheet!

  2. The user performs the instructions presented on the page. The website
    automatically detects what platform you're running on, basically giving you a
    curl/sh script or a Windows installer. There's various options for seeing
    other installers as well, and the fallback of cargo install is presented if
    we don't recognize the platform (or if we don't think we have precompiled
    binaries).

3a. On Unix, users execute a curl/sh script like:

```
curl https://alexcrichton.github.io/wasm-pack/installer/init.sh -sSf | sh
```

This command will download the shell script included in this PR, which will
in turn do some further platform detection (like OSX vs Linux) and then
download the most recent version of `wasm-pack` from GitHub releases. This
is then extracted, the `wasm-pack` binary is renamed to `wasm-pack-init`,
and then that binary is run. The binary will refuse by default to overwrite
a previous installation, but that can be overridden with the `-f` flag.

3b. On Windows users download a binary. This binary, when run, will pop up a
console window. This window will have the same output as the shell script
installer, and will wait at the end of its execution to ensure the user has
time to read everything.

And... that's it! The deployment process for all this looks like so:

  • All CI builds will update the website and shell script (published to
    gh-pages). A small script at docs/installer/build-installer.rs fills in the
    current version number inferred from Cargo.toml.

  • Tagged CI builds will publish releases, as usual.

  • "Pushing a release" is done by bumping the version number in Cargo.toml.
    When bumped all online installers will now point to the new release. There
    will be a window of time, though, when the version number is bumped and the
    release hasn't finished building on CI. In this case users will get errors
    (unfortunately).

This is all still a work-in-progress and feedback is definitely appreicated and
welcome on all this!

Closes #295

@ashleygwilliams
Copy link
Member

ashleygwilliams commented Sep 14, 2018

EDIT: nevermind, i misunderstood what was happening. will just review. ignore this.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

That js platform detection is fun...

src/installer.rs Outdated
// Find `rustup.exe` in PATH, we'll be using its installation directory as
// our installation directory.
let path = env::var_os("PATH").unwrap_or_default();
let rustup = env::split_paths(&path)
Copy link
Member

Choose a reason for hiding this comment

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

FWIW we already have which as a dependency

// If we're actually running as the installer then execute our
// self-installation, otherwise just continue as usual.
if me.file_stem().and_then(|s| s.to_str()) == Some("wasm-pack-init") {
installer::install();
Copy link
Member

Choose a reason for hiding this comment

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

nice

This commit kicks off the addition of installers for wasm-pack, with the main
goals of being:

* Users should have a one-click (ideally) solution to download and install
  wasm-pack.
* We should ideally not have to worry about picking up "heavy" dependencies in
  wasm-pack like C++ or C code (if necessary).

The general idea here is very similar to rustup (and in fact a good deal of code
is copied from them!). The installation worklow for wasm-pack in theory after
this commit looks like:

1. First, a users visits the installer landing page. A preview is available at
   https://alexcrichton.github.io/wasm-pack/installer/. Clearly this page needs
   a better stylesheet!

2. The user performs the instructions presented on the page. The website
   automatically detects what platform you're running on, basically giving you a
   curl/sh script or a Windows installer. There's various options for seeing
   other installers as well, and the fallback of `cargo install` is presented if
   we don't recognize the platform (or if we don't think we have precompiled
   binaries).

3a. On Unix, users execute a curl/sh script like:

    ```
    curl https://alexcrichton.github.io/wasm-pack/installer/init.sh -sSf | sh
    ```

    This command will download the shell script included in this PR, which will
    in turn do some further platform detection (like OSX vs Linux) and then
    download the most recent version of `wasm-pack` from GitHub releases. This
    is then extracted, the `wasm-pack` binary is renamed to `wasm-pack-init`,
    and then that binary is run. The binary will refuse by default to overwrite
    a previous installation, but that can be overridden with the `-f` flag.

3b. On Windows users download a binary. This binary, when run, will pop up a
    console window. This window will have the same output as the shell script
    installer, and will wait at the end of its execution to ensure the user has
    time to read everything.

And... that's it! The deployment process for all this looks like so:

* All CI builds will update the website and shell script (published to
  gh-pages). A small script at `docs/installer/build-installer.rs` fills in the
  current version number inferred from `Cargo.toml`.

* Tagged CI builds will publish releases, as usual.

* "Pushing a release" is done by bumping the version number in `Cargo.toml`.
  When bumped all online installers will now point to the new release. There
  will be a window of time, though, when the version number is bumped and the
  release hasn't finished building on CI. In this case users will get errors
  (unfortunately).

This is all still a work-in-progress and feedback is definitely appreicated and
welcome on all this!
Copy link
Member

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

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

have a few questions! the only real blocker is i'd like to hear a little more about what you are doing with Error in the main... otherwise i think i'm good to merge

@@ -59,18 +59,20 @@ matrix:
- (test -x $HOME/.cargo/bin/mdbook || cargo install --vers "^0.1" mdbook)
- cargo install-update -a
script:
- cd docs && mdbook build
- (cd docs && mdbook build)
Copy link
Member

Choose a reason for hiding this comment

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

what do the parans do here? am curious

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah this is because travis generates a literal shell script and without the parens the cd changes the directory for the rest of the script, so by using parens here the cwd is changed for just this one step

@@ -0,0 +1,30 @@
use std::fs;
Copy link
Member

Choose a reason for hiding this comment

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

curious why this is in the docs dir? (not necessarily opposed just not entirely clear why)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah just threw it in here as it was deployed to gh-pages, would be fine to have it anywhere!

@@ -0,0 +1,106 @@
<!DOCTYPE html>
Copy link
Member

Choose a reason for hiding this comment

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

if we land this i would love to do something where it's not just an installer page but actually just the landing page for wasmpack, e.g. links to the docs, shows an example... no need to actually change this but thought i'd mention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

use std::env;
use structopt::StructOpt;
use wasm_pack::{command::run_wasm_pack, error::Error, logger, Cli};
Copy link
Member

Choose a reason for hiding this comment

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

curious about what you are doing with Error here... can you explain?

@ashleygwilliams
Copy link
Member

ok! in air convo with @alexcrichton answered most of my questions. will note that this PR leaves us in a bit of an in between sitch re: error handling, though the diff is mostly localized. we are now split between failure::Error and our error enum- i know @fitzgen would like to move us over to full failure::Error, so let's prioritize that now that we are merging this so we spend as little time as possible in the mixed state. :)

@ashleygwilliams ashleygwilliams merged commit 5304a49 into rustwasm:master Sep 17, 2018
@ashleygwilliams ashleygwilliams added this to the 0.5.0 milestone Sep 17, 2018
@alexcrichton alexcrichton deleted the installers branch September 17, 2018 18:49
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