-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up for Development
This project uses VS Code development containers.
Linux users should install Docker Engine, Docker CLI & Docker Compose.
Windows and macOS users will need Docker Desktop. Windows users should also ensure WSL2 is enabled.
More info on ensuring your Docker installation is compatible with VS Code dev containers can be found here.
-
Ensure you've installed the above prerequisites and your form of Docker is running.
-
Start VS Code.
-
Clone the repository
- Use
CTRL+SHIFT+P
and select the taskDev Containers: Clone Repository in Named Container Volume
and follow the instructions to clone this repo. - This will error as the .env file is not available. Accept the option to reopen in a recovery container.
- Use
-
Setup development .env variables
- Copy the
.devcontainer/.env.empty
file to .env, then add your RAWG API token to the RAWG_API_TOKEN variable (not publicly available, request it or make your own). - Use
CTRL+SHIFT+P
and selectDev Containers: Rebuild Container
to apply the change.
- Copy the
The repository will cloned into a Linux volume for the dev container to use which should be faster for Windows and macOS users.
Upon connecting to your dev container, it will start up a development MySQL database in Docker for you.
-
Use
CTRL+SHIFT+P
and selectTasks: Run Task
,First Time DB Setup
to create and migrate the database. -
Use
CTRL+SHIFT+P
and selectTasks: Run Task
,Dev
to start the client and api. You're now ready to start developing. -
Connect to the app on your host machine at localhost:5173.
As this app and repo are set up for CD, you should be aware of the basic setup and processes that will occur when pushing to the repo.
If the cloud infrastructure for the app isn't set up, you'll need to follow the instructions in Setting Up the CD & Cloud Infrastructure to configure it first.
Even if the infrastructure is available, you should be aware of the state of the Elastic Beanstalk application and its configuration. Familiarize yourself with Continuous Delivery and Hosting.
This project uses database migrations and these must be run to get the database into a usable state.
During development you will work with a completely local and fresh database. Any pre-existing data for users, games or entries will have to be provided by database seeding.
First Time DB Setup
- Creates and migrates the database to the latest version.
Create Database
- Creates the database if it doesn't already exist.
Migrate Database
- Runs all migrations.
Seed Database
- Populates the database with test data.
Clear Database
- Clears all data from the database. Used for testing.
You can use the Sequelize CLI to generate migration scripts and models.
Models generated by the CLI must be manually converted to typescript. They must also be manually updated to reflect changes in the database caused by additional migrations.
Migration scripts must remain Javascript. CLI generated migrations will also often need manual tweaking, e.g. adding constraints to columns.
To see exactly what files are going to be used by the CLI on running migrations you can look at the .sequelizerc
file.
The dev container contains the SQLTools extension for connecting to and running commands against the database.
Open the SQLTools tab on the left in VS Code and select the dev-db connection. It should be pre-configured and you can authenticate with "devpassword".
The .vscode/useful_queries
directory contains saved SQL scripts you might want to use for exploring the database.
The app has basic testing for the frontend with Vitest and React Testing Library.
-
Make sure the database is initialized with
First Time DB Setup
or other commands listed above. -
If the API server isn't running, start it by hitting
CTRL+SHIFT+P
and selectingTasks: Run Task
, thenStart API
orDev
(if you want to start Vite as well) -
Hit
CTRL+SHIFT+P
and selectTasks: Run Task
,Test
.- This will clear the database, seed it with test data and run automated testing.