-
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
Add an experimental installer for wasm-pack #307
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::fs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
|
||
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)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
<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> |
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.
what do the parans do here? am curious
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 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