Skip to content

Commit

Permalink
Merge pull request #307 from alexcrichton/installers
Browse files Browse the repository at this point in the history
Add an experimental installer for wasm-pack
  • Loading branch information
ashleygwilliams committed Sep 17, 2018
2 parents 6ad8b0f + 69e5af8 commit 5304a49
Show file tree
Hide file tree
Showing 11 changed files with 574 additions and 15 deletions.
8 changes: 5 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@ test_script:

before_deploy:
- ps: |
$NAME = "wasm-pack-${env:APPVEYOR_REPO_TAG_NAME}-${env:TARGET}"
$NAME = "wasm-pack-${env:APPVEYOR_REPO_TAG_NAME}-x86_64-pc-windows-msvc"
New-Item -Path $NAME -ItemType directory
Copy-Item target/release/wasm-pack.exe "${NAME}/"
Copy-Item target/release/wasm-pack.exe wasm-pack-init.exe
Copy-Item LICENSE-MIT "${NAME}/"
Copy-Item LICENSE-APACHE "${NAME}/"
Copy-Item README.md "${NAME}/"
7z a -ttar "${NAME}.tar" "${NAME}"
7z a "${NAME}.tar.gz" "${NAME}.tar"
Push-AppveyorArtifact "${NAME}.tar.gz"
Push-AppveyorArtifact wasm-pack-init.exe
deploy:
artifact: /.*\.tar.gz/
artifact: /.*\.tar.gz/, /.*\.exe/
description: 'Appveyor Automated Release'
provider: GitHub
draft: false
prerelease: false
autho_token:
auth_token:
secure: iHsRUqwGf/Zh7OuYpHOWQL8buaOL+c8/6kXLRly8V2j0LCUo7CcDs0NxQ0vl2bhZ
on:
appveyor_repo_tag: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target/
tests/.crates.toml
tests/bin
wasm-pack.log
/build-installer
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ cache:
directories:
- /home/travis/.cargo

GH_TOKEN: &GH_TOKEN
secure: fx0rR5Ii1KcsydexE6QpkDbqItNdj3Lt6L5yFZaKKB/ejw9M555NkXA+0GZqV0sLZ54qfR8zTaXAf6eBFKgcG9etaCl7vTXqsvDrlssth82oki1zufP39uuoOy4WgFq8OfACOtUq7opDAgYmpaGzlFiny+c5j7asGwDtAU1Fc3JeJsvAnxHKg9+0spXFD6kBQd5CWpqDXv2rLFK0b8IM2fHAzd0PiJZQWqz//2Cj/r9rTiewtIzqigctAfOgFwYoQvfdM+0mKb4pefG+zXEGfxxQr4r5hqZ6UMO7hto3Jnm9LRjNR8dNaDQCqQ0bkdLTAMTC3nV/gZPM679yQU3KHueVjg9pleNzuKnuBgYmH9+BrlG1dW68kqA+6Xh+wIJYrLuagWhJDlCtiU6PM5QAbFg3mabPIBG3M2IHTrOVATme+iW5vpROARhgjbQEF235DyvZaT+Tml3+PY+PfcRax2DVUhvGQViv4tzppbT0PjjBlEbGct49cFLGdqZIJBiVrYW24I2QkENTnUgZsFIBuJlVCBHZwZlLo9ldVvu4XTMKw65z42zoTzobjtbC1QPEZPiaJXSxC7W569fqL/ORXwGToFk6rQjXwEqDP2okGiusR75LXrZD6qFibNpqeypRFtqOzntsOfTUGrlaN1yTt/6dz0V0j9uI7a9/CHVcblI=

DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB
before_deploy:
- git config --local user.name "Ashley Williams"
Expand All @@ -25,14 +28,11 @@ DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB
- tar czvf $name.tar.gz $name
deploy:
provider: releases
api_key:
secure: fx0rR5Ii1KcsydexE6QpkDbqItNdj3Lt6L5yFZaKKB/ejw9M555NkXA+0GZqV0sLZ54qfR8zTaXAf6eBFKgcG9etaCl7vTXqsvDrlssth82oki1zufP39uuoOy4WgFq8OfACOtUq7opDAgYmpaGzlFiny+c5j7asGwDtAU1Fc3JeJsvAnxHKg9+0spXFD6kBQd5CWpqDXv2rLFK0b8IM2fHAzd0PiJZQWqz//2Cj/r9rTiewtIzqigctAfOgFwYoQvfdM+0mKb4pefG+zXEGfxxQr4r5hqZ6UMO7hto3Jnm9LRjNR8dNaDQCqQ0bkdLTAMTC3nV/gZPM679yQU3KHueVjg9pleNzuKnuBgYmH9+BrlG1dW68kqA+6Xh+wIJYrLuagWhJDlCtiU6PM5QAbFg3mabPIBG3M2IHTrOVATme+iW5vpROARhgjbQEF235DyvZaT+Tml3+PY+PfcRax2DVUhvGQViv4tzppbT0PjjBlEbGct49cFLGdqZIJBiVrYW24I2QkENTnUgZsFIBuJlVCBHZwZlLo9ldVvu4XTMKw65z42zoTzobjtbC1QPEZPiaJXSxC7W569fqL/ORXwGToFk6rQjXwEqDP2okGiusR75LXrZD6qFibNpqeypRFtqOzntsOfTUGrlaN1yTt/6dz0V0j9uI7a9/CHVcblI=
file_glob: true
api_key: *GH_TOKEN
file: wasm-pack-$TRAVIS_TAG-$TARGET.tar.gz
skip_cleanup: true
on:
branch: master
condition: $DEPLOY = 1
tags: true

matrix:
Expand All @@ -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)
- rustc ./docs/installer/build-installer.rs
- ./build-installer
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
github-token: *GH_TOKEN
local-dir: docs/book
keep-history: false
on:
branch: master

# dist linux binary
- env: JOB=dist-linux TARGET=x86_64-unknown-linux-musl DEPLOY=1
- env: JOB=dist-linux TARGET=x86_64-unknown-linux-musl
rust: nightly
before_script: rustup target add $TARGET
script: cargo build --release --target $TARGET --locked --features vendored-openssl
Expand All @@ -81,7 +83,7 @@ matrix:
<<: *DEPLOY_TO_GITHUB

# dist OSX binary
- env: JOB=dist-osx MACOSX_DEPLOYMENT_TARGET=10.7 DEPLOY=1 TARGET=x86_64-apple-darwin
- env: JOB=dist-osx MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=x86_64-apple-darwin
os: osx
rust: nightly
script: cargo build --release --target $TARGET --locked
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ readme = "README.md"
categories = ["wasm"]

[dependencies]
atty = "0.2.11"
console = "0.6.1"
curl = "0.4.13"
failure = "0.1.2"
Expand Down
30 changes: 30 additions & 0 deletions docs/installer/build-installer.rs
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))
}
106 changes: 106 additions & 0 deletions docs/installer/index.html
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>
Loading

0 comments on commit 5304a49

Please sign in to comment.