This document describes how to set up your development environment to build and test RDS-JS.
It also explains the basic mechanics of using git
, node
, and npm
.
- Prerequisite Software
- Getting the Sources
- Installing NPM Modules
- Building
- Running Tests Locally
- Formatting your Source Code
- Linting/verifying your Source Code
See the contribution guidelines if you'd like to contribute to RDS-JS.
Before you can build and test RDS-JS, you must install and configure the following products on your development machine:
-
Git and/or the GitHub app (for Mac or Windows); GitHub's Guide to Installing Git is a good source of information.
-
Node.js, (version specified in the engines field of
package.json
) which is used to run a development web server, run tests, and generate distributable files.
Fork and clone the RDS-JS repository:
- Login to your GitHub account or create one by following the instructions given here.
- Fork the RDS-JS repository.
- Clone your fork of the RDS-JS repository and define an
upstream
remote pointing back to the RDS-JS repository that you forked in the first place.
# Clone your GitHub repository:
git clone git@github.com:<github username>/rds-js.git
# Go to the RDS-JS directory:
cd rds-js
# Add the main RDS-JS repository as an upstream remote to your repository:
git remote add upstream https://github.com/mtna/rds-js.git
Next, install the JavaScript modules needed to build and test RDS-JS:
# Install RDS-JS project dependencies (package.json)
npm install
To build RDS-JS run:
npm run build
- Results are put in the
dist/
folder. - Generated documentation is put in the
docs/
folder.
Jest is used as the primary tool for testing RDS-JS.
You should execute all test suites before submitting a PR to GitHub:
npm run test
All the tests are executed on our Continuous Integration infrastructure. PRs can only be merged if the code is formatted properly and all tests are passing.
RDS-JS uses prettier to format the source code. If the source code is not properly formatted, the CI will fail and the PR cannot be merged.
You can automatically format your code by running:
npm run precommit
- This will also happen automatically if you commit via
npm run commit
A better way is to set up your IDE to format the changed file on each file save.
You can check that your code is properly formatted and adheres to coding style by running:
$ npm run lint