Setup your development environment

A tutorial describing how to setup your development environment for the DojoExerciseChecker.

Introduction

This tutorial describes how to setup your development environment for building the Dojo Exercise Checker by detailing the prerequisites and dependencies needed.

Technologies

The cli is built using NodeJS and NPM.

The programming language used is Typescript v5.

Prerequisites

In order to build the exercise checker you will need the following tools:

  • NodeJS (version 18 or higher)
  • NPM (version 10 or higher)

Install NodeJS and NPM by following the instructions on the official website. Or via Node Version Manager (NVM) by following the instructions on the official website.

Dependencies

Here are the main dependencies used by the exercise checker (you don't need to install them manually or globally on your system):

  • Axios: a promise-based HTTP client for the browser and Node.js. It is used to make HTTP(S) requests to the Dojo backend and Gitlab.
  • Boxen: used to display messages in a box in the terminal.
  • Chalk: used to add colors to the messages in the terminal.
  • Commander.js: a library to write command-line interfaces.
  • Dotenv: used to load environment variables from a .env file.
  • Dotenv-vault: a CLI to sync .env files across machines, environments, and team members.
  • ora: used to display elegantly in the terminal.
  • zod: a TypeScript-first schema validation with static type inference. Used in the projet to validate json files created by the user.

Installation

First of all, you need to clone the repository:

git clone --recurse-submodule https://gitedu.hesge.ch/dojo_project/projects/pipelines/dojoexercisechecker.git

Then, you need to move to the project's directory:

cd NodeApp

To install the dependencies listed above you can use the following command in the base directory of the project:

npm install

Environment variables

Environment variables are used to store sensitive information such as API keys, passwords, etc. They are also used to store configuration information that can be changed without modifying the code.

You can decrypt env var stored in the .env.vault file with the following commands in the project's main folder:

> npx dotenv-vault local keys
 environment DOTENV_KEY
 ─────────── ─────────────────────────────────────────────────────────────────────────
 development dotenv://:key_1234@dotenv.local/vault/.env.vault?environment=development

Set DOTENV_KEY on your server

> npx dotenv-vault local decrypt dotenv://:key_1234@dotenv.local/vault/.env.vault?environment=development > .env.development

The .env.keys file have to be requested to the project maintainer: Michaël Minelli.

Run the cli

To run the exercise checker (in dev mode) you can use the following command in the base directory of the project:

npm run start:dev