Skip to content

Commit

Permalink
readme formatting and details (#55)
Browse files Browse the repository at this point in the history
Build step, cleanup and sweep installation as optional tasks,
explained how/when to use it and what it is useful for
Added instructions for staging postgres and applying initdb.sql
Instructions on how to create unit tests and run full cargo test
Specify default build target for cargo so developers do not need to specify the parameter manually
Added details for wasm-bindgen and webpack
Added details about the generated files from the build process
  • Loading branch information
elysiumplain authored Jan 22, 2024
1 parent 19a446d commit 2a088e7
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 9 deletions.
75 changes: 67 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,79 @@ openEtG is an open source fork of the Flash ccg [Elements](http://elementsthegam

## Developer Instructions

Copy `config-sample.json` to `config.json`, & `wsconfig-sample.json` to `wsconfig.json`
### Getting Started
1. Download all dependencies listed below
2. Clone the repository:
```bash
git clone https://github.com/serprex/openEtG && cd openEtG
3. Install atlas files:
```bash
curl --compressed 'https://etg.dek.im/assets/{atlas.json,atlas.webp,atlas.css}' -o 'assets/#1'
4. Copy sample configuration files:
```bash
cp config-sample.json config.json
cp wsconfig-sample.json wsconfig.json
5. Configure `config.json` to connect your instance of postgresql
- Specify the http port you will listen on for web service requests
- This should match your `wsconfig.json` `wsport`
- Specify the user to connect your postgres server
- Ensure that you created the user on your postgres server and provided proper permissions
- `postgres` is default administrative account
- `initdb.sql` script will generate a userrole `Codesmith` by default to enable special in-game commands
- You can verify your specified DB was created with:
```bash
psql -d postgres -c "select * from pg_database;"
- Specify the host of your postgres server
- Specify the port number of your postgres server
- Specify the database name you created on your postgres server
- If certificates are required to access your instance, they can be included under the `certs` key
6. Build
- Compile to WebAssembly using Rust's compiler/package manager
```bash
cargo build --release --manifest-path ../openEtG/src/rs/server/Cargo.toml --target wasm32-unknown-unknown
- Generate JavaScript and TypeScript bindings to the output directories
- This will generate:
1. `_bg.js` in `./pkg` as the translator between JS and WAsm
2. `_bg.wasm` in `./pkg` as a background support for the WAsm
3. The primary `.wasm` file in the `./release` folder
```bash
wasm-bindgen --no-typescript --weak-refs --out-dir ./src/rs/pkg ./src/rs/target/wasm32-unknown-unknown/release/etg.wasm
- Tell Webpack to build the Javascript and other assets specified in `webpack.config.js` for a specific distribution mode
```bash
webpack --mode=production
8. Clean up hanging build files to prevent build-caching issues (optional)
```bash
cargo sweep ../openEtG/src/rs/server -i
Configure `config.json` to connect your instance of postgresql.
### Testing
_Note: following instructions have not been updated to include postgresql_
1. Add unit tests to `lib.rs` and tag them with `[#test]`. _When generating tests, apply the MVP philosophy to keep lib.rs small_
2. To run unit tests:
```bash
cargo test --lib --manifest-path=../openEtG/src/rs/Cargo.toml
3. To run a fully test:
```bash
cargo test --manifest-path==../openEtG/src/rs/Cargo.toml
### Dependencies
## Dependencies
1. git
1. node
1. nodejs
1. postgresql
1. rustup
1. `cargo install wasm-bindgen-cli`
- Install
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
- Update your terminals environment parameters, or reboot
```bash
source "$HOME/.cargo/env"
1. rust's JavaScript type translation which allows JavaScript to call Rust APIs and Rust functions to catch JavaScript exceptions
```bash
cargo install wasm-bindgen-cli

1. Clone the repository: `git clone https://github.com/serprex/openEtG && cd openEtG`
1. Install atlas files: `curl --compressed 'https://etg.dek.im/assets/{atlas.json,atlas.webp,atlas.css}' -o 'assets/#1'`
### Optional

1. cargo sweep helps to clean up caching issues between builds
```bash
cargo install cargo-sweep
5 changes: 4 additions & 1 deletion src/rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ wasm-opt = false
[profile.release]
opt-level = "z"
lto = "fat"
codegen-units = 1
codegen-units = 1

[build]
target = "wasm32-unknown-unknown"

0 comments on commit 2a088e7

Please sign in to comment.