Additional documentation can be found in the docs/
directory of each package.
-
Install pnpm on your machine
-
Install Docker on your machine
-
Install global dependencies
pnpm install -g @dotenvx/dotenvx tsx prisma firebase-tools concurrently
-
Install local dependencies
pnpm install
This project uses firebase-admin
to handle server side authentication. In order to develop locally you will need to set up a service account and provide the credentials locally.
- Generate a new service account for the XMA QA project.
- Download the file
- Save it to
secrets/firebase-service-account.json
.
This project uses the firebase API to handle authentication. In order to develop locally you will need to set up a firebase project and provide the credentials locally.
-
Navigate your project on the Firebase Console
-
Click on the gear icon next to "Project Overview" and select "Project Settings"
-
Copy the
apiKey
, andprojectId
values from the firebase config -
Rename .env.local.example from the root directory as
.env.local
and fill in the values:FIREBASE_PROJECT_ID=<your_project_id> FIREBASE_API_KEY=<your_api_key>
In order to correctly handle data in the project we need to supply the absolute path to the root of the project.
-
Run the following command from the root directory of the project:
pwd
-
Assign the output to the
ROOT_DIRECTORY
variable in your.env.local
file:ROOT_DIR=</absolute/path/to/xma-portal>
- The local website is available at localhost:3000
- The Firebase Auth Emulator is available at localhost:4000/auth
- Prisma Studio is available at localhost:5555
- The Redis Queue runs on
localhost:6379
but does not have a UI - The MySQL database runs on
localhost:3306
but does not have a UI
The dev
script starts and seeds a local server with the source code. Note that the development server handles hot-reloading for when code changes are made though you may occasionally need to.
NODE_ENV | Portal | Transcode Worker | Firebase | Seeding? | Watch Mode? |
---|---|---|---|---|---|
development | source | source | Emulators | True | True |
The start:test
script first builds the source code for NODE_ENV=test
. Then it starts and seeds a local server with that built code.
NODE_ENV | Portal | Transcode Worker | Firebase | Seeding? | Watch Mode? |
---|---|---|---|---|---|
test | built | built | Emulators | True | False |
The start:prod
script first builds the source code for NODE_ENV=production
. Then it starts and seeds a local server with that built code.
NODE_ENV | Portal | Transcode Worker | Firebase | Seeding? | Watch Mode? |
---|---|---|---|---|---|
production | built | built | Emulators | True | False |
The docker-staging
scripts builds a local instance of the application's Docker images and runs them in a local "staging" environment. This mode is most useful for ensuring the CI workflow will build the Docker images correctly and run the application as expected.
NODE_ENV | Portal | Transcode Worker | Firebase | Seeding? | Watch Mode? |
---|---|---|---|---|---|
staging | docker | docker | Emulators | False | False |
The staging environment is designed to mimic the production environment as closely as possible while still allowing for local data. It builds and runs the application's Docker images, which means that you can test the application using the exact image that will be deployed to production. However, it still connects to a local MySQL database, Redis queue, and and the Firebase Emulators.
A basic script is provided to seed the staging environment with fake data. Run it by:
-
Overriding the
seed.bke.ts
script with the staging version:docker cp packages/portal/scripts/seed.staging.ts xma-portal-staging-portal-1:app/scripts/seed.bke.ts
-
Running the seed script in the staging environment:
[!TIP] You can run this directly from the container instead of the command line by using the Docker Desktop app
docker exec -it xma-portal-staging-portal-1 pnpm run seed
Note
Testing scripts can only be run in the packages/portal
directory currently.
This project uses Vitest for running unit and integration tests. It uses Cypress and Playwright for running end to end tests. Each test is run with a unique script that can be run individually. The project's Github Actions workflows utilize these tests on every pull request.
Cypress does not run tests in parallel without a subscription to Cypress Cloud. However, we can run tests in parallel by executing multiple scripts at once.
-
Move to the
packages/portal
directorycd packages/portal
-
Run the dev server in test mode
pnpm run -w start:test
-
Run the following command in a separate terminal:
concurrently \ 'pnpm exec cypress run --reporter min --spec cypress/e2e/file.cy.ts' \ 'pnpm exec cypress run --reporter min --spec cypress/e2e/individual.cy.ts' \ 'pnpm exec cypress run --reporter min --spec cypress/e2e/study.cy.ts'
Recursively builds each package in the project.
Cleans the project's dependencies, builds, caches, and other temporary files by running a custom bash script.
Recursively runs each package's source code in parallel. See the Dev Mode section for more details.
Note
The predev
script starts the docker containers needed for local development before running this script.
Runs the dev script with the REACT_APP_PORTAL
environment variable set to hma
.
Runs the dev script with the REACT_APP_PORTAL
environment variable set to xma
.
Runs the dev script with the REACT_APP_PORTAL
environment variable set to zms
.
Runs the docker containers needed for local development. The containers will run in the background uninterrupted.
Removes the application's docker containers. It stops and removes the containers from both the docker and docker-staging scripts.
Warning
The docker-down script must be run before this command as the ports conflict
Builds the docker images for each package and runs the containers needed for a local staging environment. See the Staging Mode section for more details.
Runs Prettier on the source code. See .prettierrc.cjs
for the project's configuration.
It's recommended to install an editor plugin (e.g. prettier-vscode) to get auto-formatting on save.
Lints the code using Eslint. See .eslintrc.cjs
for the project's configuration.
Caution
This script is only intended to be run in local environments. It will (intentionally) fail in production environments.
Runs the ORM's reset script to reset the application's MySQL database.
Caution
This script does not set the NODE_ENV
environment variable and will therefore fail. The start:prod or start:test script should be used instead
Recursively builds and runs each package's source code in parallel.
Note
The prestart
script builds the source code and starts the docker containers needed for local development before running this script.
Sets NODE_ENV
to production and recursively builds and runs each package's source code in parallel. See the Production Mode section for more details.
Note
The prestart:prod
runs the base prestart
script with NODE_ENV
set to production.
Sets NODE_ENV
to test and recursively builds and runs each package's source code in parallel. See the Test Mode section for more details.
Note
The prestart:test
runs the base prestart
script with NODE_ENV
set to test.
Type checks the code using Typescript. See tsconfig.json
for the project's configuration.
Runs the project's static analysis tools and its entire test suite using a custom bash script.
Madge is a useful tool for visualizing module dependencies. It can be installed via npm as a global dependency (pnpm i -g madge
).
The following command generates a list of every file's dependencies:
madge --ts-config ./tsconfig.json --extensions ts,tsx app/
--circular
flag shows circular dependencies in the codebase--orphans
flag shows modules not used anywhere in the codebase--image madge.png
flag saves the outputs graph as an image
Tip
Madge is extremely useful for debugging issues that appear in the built code but not in development. The culprit is likely circular dependencies that Remix's build process does not catch.