Skip to content

Latest commit

 

History

History
79 lines (49 loc) · 2.44 KB

local-typescript-setup.md

File metadata and controls

79 lines (49 loc) · 2.44 KB

Setting up a local TypeScript environment

This page describes how to set up the TypeScript and JavaScript tooling to build the Grapher component from source and test it in your browser on your local machine. If you also want to be able to use the admin UI to graphically configure grapher charts you will need to set up the MySQL database, by using our docker compose MySQL setup.

This local environment requires some manual setup. For a faster way to get started have a look at the VS Code devcontainer setup.

You need the following to be able to compile the grapher project and run the tests or use our Storybook:

All further dependencies will be automatically installed by the yarn package manager.

We recommend using the nvm Node Version manager and Visual Studio Code as the editor.

Below are steps to set up nvm and yarn. Further down are the steps to run the tests and use the storybook for development.

Setting up Node and Yarn

MacOS specific first steps

  1. Install Homebrew first, follow the instructions here: https://brew.sh/

  2. Install nvm:

    brew update
    brew install nvm
    source $(brew --prefix nvm)/nvm.sh

Linux/Windows specific first steps

Note: on Windows we strongly recommend using the Windows Subsystem for Linux for development as all our utility scripts are written in bash.

  1. Run the following install script to set up NVM (from a WSL terminal when on windows):

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Further steps for all OSs

  1. Clone this project if you haven't already, and switch to the project directory

  2. Install Node:

    nvm install

    (this will pick up the right version from .nvmrc)

  3. Enable Corepack, which provides yarn versions:

    corepack enable
  4. Run yarn inside the repo folder to install dependencies:

    yarn

Running tests

To run our test suite you first need to build the TypeScript files into JavaScript and then run jest:

  1. Build JavaScript

    yarn lerna run build && yarn buildTsc
  2. Run jest

    yarn testJest