Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ Install [nvm](https://github.com/nvm-sh/nvm):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
```

Optionally, you may install [just](https://just.systems/man/en/), which is
essentially a modernized makefile. It is not required, but it is convenient.
This repo's `justfile` has some useful commands. that are also referenced
in this README. And after installing `just`, then you can run the command
to see all available recipes:

![just recipes](./docs/just-recipes.png 'just recipes')
(just recipes as of 18-Sep-2023)

Follow any extra instructions from the script and restart your terminal. Then run:

```bash
Expand All @@ -31,12 +40,16 @@ Install npm and then run:

```bash
npm install
# OR
just init
```

To start a web server that auto-reloads on changes, run:

```bash
npm start
# OR
just dev
```

## Test Release version
Expand All @@ -45,6 +58,8 @@ Run:

```bash
npm run start:dist
# OR
just start-dist
```

Note that you need Python 3.8 (2019 release) or newer,
Expand All @@ -59,6 +74,8 @@ To publish/deploy run:

```bash
npm run deploy
# OR
just publish
```

## Test
Expand All @@ -69,14 +86,18 @@ Run all tests:

```bash
npm run test:node
# OR
just test-node
```

That command is an alias for `WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --node`.

Or run a specific test file:

```bash
npm run test:node -- --test tier_0
npm run test:node -- --test tier_0 --test tier_1
# OR
just test-node tier_0 tier_1
```

### Manual Way
Expand Down
Binary file added docs/just-recipes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# bash/justfile

# https://just.systems/man/en/chapter_1.html

[private]
@default:
echo "View file 'justfile' to see internals of any recipe."
just --list --unsorted

# ------------------------------------------------------------------------------
# BASICS
# ------------------------------------------------------------------------------

# TODO: add check for all installations (rust, npm, nvm/n, wasm-pack, etc.),
# and auto-install anything missing.
# Initialize the repo. Necessary after initial git-clone.
@init:
npm install
echo "Note that this init script does not (yet) install Rust, nvm/n, wasm-pack, etc."
echo "Please follow the guidance in the README.md file to install everything."

# Clean up the repo by removing all generated files.
@clean:
rm -rf dist pkg

# ------------------------------------------------------------------------------
# LINTING
# ------------------------------------------------------------------------------

# Lint all code.
@lint: lint-js lint-rs

# Only lint the JavaScript code via eslint.
@lint-js:
eslint --ext .js,.vue --ignore-path .gitignore --fix js

# Only lint the Rust code via Clippy.
@lint-rs:
cargo clippy --all-targets --all-features -- -D warnings

# ------------------------------------------------------------------------------
# RUN LOCAL SERVERS
# ------------------------------------------------------------------------------

# Run the development server, which has hot-reloading and debug-mode.
@start-dev: clean
webpack-dev-server --open -d
alias dev := start-dev

# Run the distribution server, which does NOT have hot-reloading or debug-mode.
@start-dist: build
python3 -m http.server 8000 --directory dist

# ------------------------------------------------------------------------------
# BUILD & DEPLOY
# ------------------------------------------------------------------------------

# Build the deployable distribution.
@build: clean
webpack

# Manually publish the app to GitHub Pages.
@publish: build && clean
gh-pages -d dist

# ------------------------------------------------------------------------------
# TESTING
# ------------------------------------------------------------------------------

# Run all tests.
test: test-rs test-wasm test-node

# Run Rust tests.
@test-rs:
cargo test

# Run headless Wasm tests. Optionally give specific browsers; ex: just test-wasm chrome safari
@test-wasm *BROWSERS='node chrome firefox safari':
BROWSER_ARG=$(echo {{BROWSERS}} | sed 's/[^ ]* */--&/g') && \
wasm-pack test --headless $BROWSER_ARG; \

# Run Wasm tests with Node.js. Optionally give specific tests; ex: just test-node tier_0 tier_1
@test-node *TESTS:
if [ -z "{{TESTS}}" ]; then \
WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --node; \
else \
TEST_ARG=$(echo {{TESTS}} | sed 's/[^ ]* */--test &/g') && \
WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --node -- $TEST_ARG; \
fi