Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit fe73f46

Browse files
committed
move contributing.md to root
1 parent 0a5ae23 commit fe73f46

File tree

2 files changed

+30
-81
lines changed

2 files changed

+30
-81
lines changed

Diff for: .github/CONTRIBUTING.md renamed to CONTRIBUTING.md

+30-27
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ Repository.
1212
- [Environment Setup](#environment-setup)
1313
* [Latest Rust](#latest-rust)
1414
* [Formatting](#formatting)
15-
* [Wasm Build](#wasm-build)
16-
* [Coding Style](#coding-style)
15+
* [WASM Build](#wasm-build)
1716

1817
- [Code of Conduct](#code-of-conduct)
1918

@@ -23,14 +22,17 @@ Repository.
2322
### Latest Rust
2423
This project uses a few things that you should set yourself up with before
2524
starting work. First of all, make sure you have the latest `rust` and `cargo`
26-
installed. The best way to do that is with `rustup`, and you can read about it
27-
more in the [rust
28-
book](https://doc.rust-lang.org/book/second-edition/ch01-01-installation.html).
29-
But to get yourself uptodate with all the things:
25+
installed. The best way to do that is with `rustup`, and you can read about
26+
it more in the [rust
27+
book](https://doc.rust-lang.org/book/ch01-01-installation.html). Similarly
28+
working with cargo is better described in [the
29+
book](https://doc.rust-lang.org/book/ch01-03-hello-cargo.html)
3030

31+
To get yourself uptodate with all the things:
3132
```bash
3233
rustup update
3334
```
35+
3436
### Formatting
3537
We are using two tools to help with best-practice fromatting:
3638
[rustfmt](https://github.com/rust-lang-nursery/rustfmt) and
@@ -54,43 +56,44 @@ augroup filetype_rust
5456
augroup END
5557
```
5658
`rust-nursery` also has support for other editors, like
57-
[vscode](https://github.com/rust-lang-nursery/rls-vscode).
58-
59-
`rustfmt` will also run as a pre-commit hook. You will need to copy the file
60-
that's currently in `./hooks/pre-commit` to your local `.git` directory:
61-
```bash
62-
cp hooks/pre-commit ./git/hooks/pre-commit
63-
```
59+
[vscode](https://github.com/rust-lang-nursery/rls-vscode). You can just add
60+
this plugin to your VSCode setup, and magic :sparkles:, everything works!
6461

65-
### Wasm Build
62+
### WASM Build
6663
To be able to use this module in JavaScript and Node, we compile it to WASM. For
6764
that we use [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) inside our
6865
`lib.rs`, and [wasm-pack](https://github.com/rustwasm/wasm-pack) to make a
6966
package to be published to `npm`. To do so, install `wasm-pack`:
7067
```bash
71-
cargo install wasm-pack
68+
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
7269
```
70+
7371
and run build that will generate a `pkg` directory that can be then published to
7472
npm:
73+
7574
```bash
76-
wasm-pack build
75+
wasm-pack build --no-typescript --release --scope=mongodb-rust
7776
```
78-
Travis CI will also run a wasm-pack build to check we are able to compile this correctly.
7977

80-
### Coding Style
81-
82-
A few things to follow when working on this project.
78+
If you are developing locally, you can also point your javascript imports to
79+
the build. For example:
80+
```js
81+
var schemaWasm = import('../../mongodb-schema-parser/pkg')
82+
```
8383

84-
1. Avoid using `unsafe-rust`. `lib.rs` is already setup with
85-
`#[deny(unsafe-rust)]` to help with that.
84+
To publish you can also use `wasm-pack`:
85+
```bash
86+
wasm-pack publish --access=public
87+
```
8688

87-
2. Structs should implement `Copy` and `Debug` traits to avoid future
88-
complications. These can be simple appended with:
89-
``` rust
90-
#[derive(Debug, Copy)]
91-
struct Pair(Box<i32>, Box<i32>)
89+
As you are developing sometimes it's useful to know whether you can compile
90+
to WASM. Especially when you add a new crate to the setup:
91+
```bash
92+
cargo check --target wasm32-unknown-unknown
9293
```
9394

95+
Travis CI will also run a wasm-pack build to check we are able to compile this correctly.
96+
9497
## Code of Conduct
9598
The project has a [Code of Conduct](./CODE_OF_CONDUCT.md) that *all*
9699
contributors are expected to follow. This code describes the *minimum* behavior

Diff for: hooks/pre-commit

-54
This file was deleted.

0 commit comments

Comments
 (0)