Local Environment Setup

Local Environment Setup

Setup

Required Software

Install the following software on your local development machine:

  1. git

  2. Bash (this guide assumes a bash shell)

  3. vscode

  4. Docker (for Mongodb and MQTT dependencies)

  5. Node.js (see package.json for version; use nvm to manage Node.js installations)

  6. yarn

    • With Node.js installed, run corepack enable in the repo directory.

Preparing Codebase

  1. Fork the playnite-web repo

  2. Clone your forked repo to your local development machine.

  3. Open the repo in vscode.

  4. Run yarn

  5. Run yarn nx prepare devenv. This is only required for the first time working with the codebase.

  6. Run yarn nx start playnite-web-app and navigate to http://localhost:3000

    • Note an empty games database will be started automaticallk via Docker.

    • Restore a test database via yarn nx use-snpashot playnite-web-app SNAPSHOT_NAME. See available snapshots.

  7. [Optional]: override environment variables when running locally via cp apps/playnite-web/local.env apps/playnite-web/overrides.env

    • REMEMBER: do not commit overrides.env or sensitive information in local.env.

Running Application/Services

Playnite Web App

Command

Notes

Command

Notes

yarn nx start playnite-web-app

Run Playnite Web application locally. Will automatically start dependent services via docker-compose (Database and MQTT). Navigate to http://localhost:3000 in a browser.

yarn nx demo-data playnite-web-app

Run only after Playnite Web is running; will seed database with demo data. To remove all data, simply delete the Database container that was started via the start target.

yarn nx test/components playnite-web-app

Run component tests for development.

yarn nx test/components/update playnite-web-app

Run component tests with intention to update a baseline screenshot.

yarn nx test/components/update playnite-web-app $GLOB_FILE_MATCH

Run component tests with intention to update baseline screenshots. Runs only tests matching glob CLI parameter; e.g. yarn nx run playnite-web:test/components/update FilterForm*

yarn nx test/e2e/dev playnite-web-app

Run end-to-end (e2e) tests for development (including visual regression capabilities). The database will be cleared and repopulated before every test to ensure a consistent dataset for testing.

yarn nx test/e2e/update playnite-web-app

Run end-to-end (e2e) tests with intention to update a baseline screenshot.

yarn nx test/e2e/update playnite-web-app $GLOB_FILE_MATCH

Run end-to-end (e2e) tests with intention to update a baseline screenshot. Runs only tests matching glob CLI parameter' e.g. yarn nx run playnite-web-app:test/e2e/update **/browse*

yarn nx test/e2e playnite-web-app

Build and package to run end-to-end (e2e) tests. Note updates to the source application will not be reflected after running this command and will require re-running the command. Tests packaged docker image.

yarn nx test/e2e playnite-web-app --configuration dev

Build and package to run end-to-end (e2e) tests, but for debugging CI failures. Note updates to the source application will not be reflected after running this command and will require re-running the command. Tests packaged docker image.

yarn nx test/unit playnite-web-app

Run Jest-based unit tests.

Sync Library Processor

Command

Notes

Command

Notes

yarn nx start sync-library-processor

Starts service.

yarn nx test/e2e sync-library-processor

Runs Jest-based e2e tests, found in the __integration_tests__ directory.

Database/schema Changes

Changing the database schema (defined in the schema.prisma file) will require the changes to be tracked as a database migration. Make necessary changes to schema, then create a migration via yarn nx create-migration db-client. The generated migation files should be committed to the repo.

Playnite Web Plugin Development

To develop the Playnite Web plugin, a Windows machine is required. Playnite must be installed. Recommendation is to use Visual Studio Community edition for development.

  1. Install required software

    • Playnite

    • Visual Studio

  2. Open the solution file in Visual Studio; located in apps/PlayniteWebPlugin/src/PlayniteWeb.sln.

  3. Build the solution.

  4. Open Playnite and add the path to the bin directory as a local plugin. This setting is found under the Developer section in the settings.

  5. Debugging opens Playnite with the plugin installed.