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
yarnin the root,./web, and./serverdirectories to install their dependencies.
Now your environment is set up and you can start development.
A number of scripts are defined in the package.jsons for each dir.
The ones you would be using most often are:
yarn startin root, which starts the server and db.yarn startin./web, which starts the webapp.yarn storybookin./web, which starts the Storybook.
Below are detailed explanations of what each script does.
yarn start: Starts theserverandpostgrescontainers in dev mode. This will mount your./serverdirectory 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
servercontainer: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.ymlanddocker-compose.override.yml, which sets up the containers and runs./server'syarn start.
- This simply runs
yarn start:prod: Starts theserverandpostgrescontainers in prod mode.- This does a full build of the server container, meaning the
./serverdir is copied into the server container andyarn buildis 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: Runsjestusing thetestandpostgrescontainers. You can pass arguments tojestwith this. Examples are below.yarn test: Runs all tests.yarn test --watch: Runsjestin 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: Runsyarninside thetestcontainer.- 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./builddirectory.- 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-tsfrom 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./webTypeScript 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 startin root within the server container. - While this would work outside the container, it would not be able to connect to the
postgrescontainer 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/builddirectory.- You should not need to run this unless you want to locally test the production build.
- It is run when the
servercontainer is built in production mode.
yarn test: Runsjest.- You should not need to run this as it is run by
yarn testin root within the server container. - While this would work outside the container, it would not be able to connect to the
postgrescontainer i.e. the db.
- You should not need to run this as it is run by
yarn lint: Lints the whole./serverTypeScript 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.