-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an experimental installer for wasm-pack
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!
- Loading branch information
1 parent
0bd0b5a
commit e753ebe
Showing
11 changed files
with
562 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ target/ | |
tests/.crates.toml | ||
tests/bin | ||
wasm-pack.log | ||
/build-installer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::fs; | ||
|
||
fn main() { | ||
fs::create_dir_all("docs/book/installer").unwrap(); | ||
fs::copy( | ||
"docs/installer/wasm-pack.js", | ||
"docs/book/installer/wasm-pack.js", | ||
).unwrap(); | ||
let index = fs::read_to_string("docs/installer/index.html").unwrap(); | ||
fs::write( | ||
"docs/book/installer/index.html", | ||
fixup(&index), | ||
).unwrap(); | ||
|
||
let init = fs::read_to_string("docs/installer/init.sh").unwrap(); | ||
fs::write( | ||
"docs/book/installer/init.sh", | ||
fixup(&init), | ||
).unwrap(); | ||
} | ||
|
||
fn fixup(input: &str) -> String { | ||
let manifest = fs::read_to_string("Cargo.toml").unwrap(); | ||
let version = manifest.lines() | ||
.find(|line| line.starts_with("version =")) | ||
.unwrap(); | ||
let version = &version[version.find('"').unwrap() + 1..version.rfind('"').unwrap()]; | ||
|
||
input.replace("$VERSION", &format!("v{}", version)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>wasm-pack</title> | ||
<style> | ||
body { | ||
text-align: center; | ||
margin: 100px; | ||
font-size: 150%; | ||
} | ||
#main { | ||
padding: 100px; | ||
} | ||
.instructions { | ||
padding: 100px; | ||
border: 1px solid black; | ||
} | ||
.winlink { | ||
display: block; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id='main'> | ||
Install wasm-pack! A tool with a blurb here. | ||
</div> | ||
|
||
<div id="platform-instructions-unix" style="display: none;"> | ||
<pre>curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh</pre> | ||
<p> | ||
You appear to be running Unix. If not, | ||
<a class="default-platform-button" href="#">display all supported installers</a>. | ||
</p> | ||
</div> | ||
|
||
<div id="platform-instructions-win64" class="instructions" style="display: none;"> | ||
<p> | ||
You appear to be running windows 64-bit, download and run | ||
<a class='winlink' href="https://github.com/rustwasm/wasm-pack/releases/download/$VERSION/wasm-pack-init.exe">wasm-pack-init.exe</a> | ||
then follow the onscreen | ||
instructions. | ||
</p> | ||
<hr/> | ||
<p> | ||
If you're a Windows Subsystem for Linux user run the following in your | ||
terminal, then follow the onscreen instructions to install wasm-pack. | ||
</p> | ||
<pre>curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh</pre> | ||
<hr/> | ||
<p> | ||
You appear to be running Windows 64-bit. If not, | ||
<a class="default-platform-button" href="#"> | ||
display all supported installers | ||
</a>. | ||
</p> | ||
</div> | ||
|
||
<div id="platform-instructions-unknown" class="instructions" style="display: none;"> | ||
<p>I don't recognize your platform.</p> | ||
<p> | ||
We would appreciate it if you | ||
<a href="https://github.com/rustwasm/wasm-pack/issues/new">reported an issue</a>, | ||
along with the following values: | ||
</p> | ||
|
||
<div> | ||
<div>navigator.platform:</div> | ||
<div id="nav-plat"></div> | ||
<div>navigator.appVersion:</div> | ||
<div id="nav-app"></div> | ||
</div> | ||
</div> | ||
|
||
<div id="platform-instructions-default" class="instructions"> | ||
<div> | ||
<p> | ||
To install wasm-pack, if you are running Unix,<br/> | ||
run the following in your terminal, then follow the onscreen | ||
instructions. | ||
</p> | ||
<pre>curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh</pre> | ||
</div> | ||
|
||
<hr/> | ||
|
||
<div> | ||
<p> | ||
If you are running Windows 64-bit,<br/>download and run | ||
<a class='winlink' href="https://github.com/rustwasm/wasm-pack/releases/download/$VERSION/wasm-pack-init.exe">wasm-pack-init.exe</a> | ||
then follow the onscreen instructions. | ||
</p> | ||
</div> | ||
|
||
<hr/> | ||
|
||
<div> | ||
<p> | ||
For all other platforms, run the following in your terminal: | ||
</p> | ||
<pre>cargo install wasm-pack</pre> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript" src="wasm-pack.js"></script> |
Oops, something went wrong.