In addition to the below, you should check out the wiki.
- First, set up your text editor.
- Install a text editor. VS Code is recommended since it has out of the box support for Typescript. Other text editors may work, but this guide assumes you are using VS Code so they may need extra configuration.
- Install the Prettier and TSLint extensions for VS Code. This will ensure that your code is linted so errors can be fixed before they even get tested, as well as automatically formatting code consistently.
- Install Node.js stable (not LTS), Yarn, and Docker
- Clone the repo.
- Run
yarn
in the root,./web
, and./server
directories to install their dependencies.
Now your environment is set up and you can start development.
A number of scripts are defined in the package.json
s for each dir.
The ones you would be using most often are:
yarn start
in root, which starts the server and db.yarn start
in./web
, which starts the webapp.yarn storybook
in./web
, which starts the Storybook.
Below are detailed explanations of what each script does.
yarn start
: Starts theserver
andpostgres
containers in dev mode. This will mount your./server
directory into the container and automatically restart the server whenever you make changes.- This simply runs
docker-compose up
, so you can also use this to, for example:- Just start the
server
container:yarn start server
(runsdocker-compose up server
) - Force rebuild of the containers:
yarn start --build
(runsdocker-compose up --build
)
- Just start the
- Internally this uses
docker-compose.yml
anddocker-compose.override.yml
, which sets up the containers and runs./server
'syarn start
.
- This simply runs
yarn start:prod
: Starts theserver
andpostgres
containers in prod mode.- This does a full build of the server container, meaning the
./server
dir is copied into the server container andyarn build
is run within the container, transpiling the source into JavaScript. The container will then run the transpiled source withnode build/index.js
.
- This does a full build of the server container, meaning the
yarn test
: Runsjest
using thetest
andpostgres
containers. You can pass arguments tojest
with this. Examples are below.yarn test
: Runs all tests.yarn test --watch
: Runsjest
in watch mode.yarn test entries
: Runs tests in files whose names contain "entries".- See https://jestjs.io/docs/en/cli.html for more.
yarn test:install
: Runsyarn
inside thetest
container.- You do not need to run this, it's just a helper for
yarn test
.
- You do not need to run this, it's just a helper for
yarn start
: Starts the webapp and live reloads it whenever you make changes.yarn build
: Builds the webapp by transpiling it into JavaScript such that the webapp can be served statically from the./build
directory.- You should not need to run this as it would be run when deploying the webapp.
yarn test
: Runs the test suite using Jest.yarn eject
: Removesreact-scripts-ts
from the project and converts it to work standalone.g- You DEFINITELY should not need to run this unless you know what you're doing.
yarn storybook
: Starts the Storybook and live reloads it whenever you make changes.yarn build-storybook
: Builds the Storybook into static files.- You should not need to run this unless you're serving the files for some reason.
yarn lint
: Lints the whole./web
TypeScript project.- You can run this via VS Code's task runner and it will integrate with the Problems panel allowing you to jump directly to the problems.
- Open the command palette with
Ctrl+Shift+p
. - Search for and select
Tasks: Run Task
. - Select
Run lint (web)
.
- Open the command palette with
- You can run this via VS Code's task runner and it will integrate with the Problems panel allowing you to jump directly to the problems.
yarn start
: Starts the server and restarts it whenever you make changes.- You should not need to run this as it is run by
yarn start
in root within the server container. - While this would work outside the container, it would not be able to connect to the
postgres
container i.e. the db.
- You should not need to run this as it is run by
yarn build
: Transpiles the server source code into JavaScript in the./server/build
directory.- You should not need to run this unless you want to locally test the production build.
- It is run when the
server
container is built in production mode.
yarn test
: Runsjest
.- You should not need to run this as it is run by
yarn test
in root within the server container. - While this would work outside the container, it would not be able to connect to the
postgres
container i.e. the db.
- You should not need to run this as it is run by
yarn lint
: Lints the whole./server
TypeScript project.- You can run this via VS Code's task runner and it will integrate with the Problems panel allowing you to jump directly to the problems.
- Open the command palette with
Ctrl+Shift+p
. - Search for and select
Tasks: Run Task
. - Select
Run lint (server)
.
- Open the command palette with
- You can run this via VS Code's task runner and it will integrate with the Problems panel allowing you to jump directly to the problems.