version: 2
jobs:
  build:
    working_directory: ~/app
    docker:
      - image: circleci/node:12.16.3-browsers
    steps:
      - checkout
      - restore_cache:
          keys:
            - cache-{{ .Branch }}-{{ checksum "package.json" }}
      - run:
          name: Install dependencies
          command: npm ci
      - save_cache:
          key: cache-{{ .Branch }}-{{ checksum "package.json" }}
          paths:
            - ~/.npm
            - ~/.cache
      - run:
          name: Run typescript checker
          command: npx tsc --noEmit
      - run:
          name: Build application
          command: npm run build
