Skip to content

Commit 5dfc7d6

Browse files
authored
Merge pull request #144 from Pauan/cleanup
Significant changes to clean things up and improve the user UX
2 parents b0bc67f + 7c63321 commit 5dfc7d6

20 files changed

+330
-6766
lines changed

.bin/create-rust-webpack.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const { spawnSync } = require("child_process");
44
const fs = require("fs");
5+
const path = require("path");
6+
const cpr = require("cpr");
7+
const rimraf = require("rimraf");
58

69
function run(cmd, args, opts) {
710
const output = spawnSync(cmd, args, opts);
@@ -24,10 +27,24 @@ if (process.argv.length >= 3) {
2427
}
2528
}
2629

27-
run("git", ["clone", "https://github.com/rustwasm/rust-webpack-template.git", folderName]);
30+
let gitFolder = path.join(folderName, "git-clone");
2831

29-
console.log(" 🦀 Rust + 🕸 WebAssembly + Webpack = ❤️ ");
32+
// This uses --no-tags and --depth 1 in order to make the cloning faster
33+
run("git", ["clone", "--no-tags", "--depth", "1", "https://github.com/rustwasm/rust-webpack-template.git", gitFolder]);
3034

31-
run("npm", ["install"], { cwd: folderName, shell: true });
35+
// Copies the template folder
36+
cpr(path.join(gitFolder, "template"), folderName, {}, function (err, files) {
37+
// Removes the git folder regardless of whether cpr succeeded or not
38+
rimraf.sync(gitFolder);
3239

33-
console.log(" Installed dependencies ✅ ");
40+
if (err) {
41+
throw err;
42+
43+
} else {
44+
console.log(" 🦀 Rust + 🕸 WebAssembly + Webpack = ❤️ ");
45+
46+
run("npm", ["install"], { cwd: folderName, shell: true });
47+
48+
console.log(" Installed dependencies ✅ ");
49+
}
50+
});

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
dist
21
node_modules
3-
crate/bin
4-
crate/pkg
5-
crate/target
6-
crate/wasm-pack.log
7-
crate/Cargo.lock
2+
/template/package-lock.json
3+
/template/Cargo.lock
4+
/template/git-clone

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ install:
77
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
88

99
script:
10+
- pushd template
1011
- npm install
1112
- npm run build
13+
- popd

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ npm init rust-webpack my-app
4545
This template comes pre-configured with all the boilerplate for compiling Rust
4646
to WebAssembly and hooking into a Webpack build pipeline.
4747

48-
* `npm run start` -- Serve the project locally for development at
49-
`http://localhost:8080`.
48+
* `npm start` -- Serve the project locally for development at
49+
`http://localhost:8080`. It auto-reloads when you make any changes.
5050

5151
* `npm run build` -- Bundle the project (in production mode).
52+
53+
* `npm test` -- Run the project's unit tests.

crate/Cargo.toml

Lines changed: 0 additions & 40 deletions
This file was deleted.

crate/src/lib.rs

Lines changed: 0 additions & 32 deletions
This file was deleted.

index.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

js/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)