Prerequisites

Ensure that the required tools and libraries are installed on your machine:

  1. Node.js: This project relies on Node.js to manage dependencies and scripts. Make sure you have an appropriate version installed.

  2. Firebase Tools: If you are planning to deploy the project using Firebase, you will need the Firebase CLI. Install it globally using the following command:

    npm install -g firebase-tools
    

Step 1: Clone the Repository

Start by cloning the repository for the project. Execute the following command in your terminal:

git clone https://github.com/trackjs/javascript-gameshow.git
cd javascript-gameshow

Step 2: Install Dependencies

To install all the necessary dependencies referenced in the project, run:

npm install

This command utilizes the package.json file to fetch all required libraries.

Step 3: Run the Development Server

For development purposes, you can start the development server which supports Hot Module Replacement (HMR). Use the following command:

npm run dev

After executing this command, the application should be accessible via http://localhost:3000 (or whichever port is configured).

Step 4: Build for Production

To create a production-ready version of your application, use the following command:

npm run build

This creates an optimized build in the dist directory or the configured output location, making it ready for deployment.

Step 5: Run a Production-like Server

To simulate a production environment, you can start the following server:

npm run serve

This server will serve the content in the same way a real production server would.

Step 6: Lint TypeScript Files

To ensure code quality and adherence to standards, lint your TypeScript files using ESLint:

npm run lint

This command helps in identifying any potential issues or deviations from predefined coding standards.

Step 7: Run Tests

For testing purposes, run the unit tests using Jest and Enzyme. Execute the following command:

npm run test

Using this command will run your tests with the enzyme-adapter-preact-pure, as specified in the testing configuration.

Step 8: Deploy to Firebase

To deploy the audience application, ensure you are within the directory and execute:

npm run deploy

This command will upload your application build to Firebase hosting, assuming you have configured your project to use Firebase.

Additional Configuration (if needed)

If your application requires Firebase configuration, ensure you have a .firebaserc file as follows:

{
  "projects": {
    "default": "javascript-gameshow"
  },
  "targets": {
    "javascript-gameshow": {
      "hosting": {
        "audience-app": [
          "javascript-gameshow"
        ]
      }
    }
  },
  "etags": {}
}

Important Code Snippets

A key interface used in the project can be found as follows:

export interface Game {
  id: string;
  playerName: string;
  startedOn: DateTime;
  lifeLines: GameLifeLine[];
  questionsAsked: GameQuestionAsked[];
  prizeStack: Prize[];
  prizeWon: Prize[];
  isFinished: boolean;
}

This interface outlines the structure of your game objects, encapsulating essential game information.

For further details on how the CLI commands function, consult the appropriate CLI Readme documentation.