You want to contribute to this repo? Nice! You are the best! Here is a guide on how to work with it and what to expect.
- Run tests
- Format and lint the code
- Build the library
- Build library documentation
- Commit changes
- Recommended workflow for release
First things first, clone the repo and ...
For this repository the package manager pnpm is used as a drop-in replacement for npm. Here you can find a guide on installing pnpm on your machine: getting started with pnpm.
To generate reference values in C++ please ensure that g++ is setup correctly (check by running g++ --version
in your terminal).
The following command will generate reference values into a JSON file in src/reference/cpp/results.json
that will be picked-up by the tests to match results against the C++ implementation. This will ensure that the JavaScript implementation produces the same values as the C++ one.
pnpm build:reference:code
# Run tests
pnpm test
# Run production tests
pnpm test:prod
# Test if the application is tree shakable
pnpm test:treeshaking
Tests can also be executed in a browser of your choice. To generate the browser tests run:
pnpm build:tests
This will generate the necessary tests files compatible for the browser in compiled_tests/
. After that you can open the src/__tests__/browser.html
in a browser to view the tests.
# Lint the application
pnpm lint
# Check the formatting, enforced by prettier
pnpm format:check
# Format the code with prettier
pnpm format
To build the project run:
pnpm build
to generate a minified version of the library under lib/
.
You can serve the documentation locally or via your local network by running:
pnpm docs:local
This will use JSDoc to generate the documentation.
This repo is Commitizen-friendly! (read more in the official commitizen documentation)
Checkout a new branch, there is no naming convention for branches, only for commits. Add your changes and run pnpx git-cz
(or pnpm commit
) to start the commitizen cli to create a proper commit message.
Push the changes with your feature branch and create a "Pull Request" on GitHub.
- Make changes
- Commit those changes with
pnpx git-cz
(orpnpm commit
) - Create a new release with
pnpm release
- Push your release
git push --follow-tags origin main
- Publish:
NPM_CONFIG_OTP=XXXXXX npm publish
(replaceXXXXXX
with a valid 2FA token) - Done!
For more information on building a release see https://github.com/absolute-version/commit-and-tag-version