image: node:latest

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - node_modules/

before_script:
  - node -v
  - npm -v
  - npm ci

stages:
  - lint
  - bundle
  - test
  - performance
  - deploy

lint:
  stage: lint
  script:
   - npm run tslint

bundle:
  stage: bundle
  script:
   - npm run build

test:
  stage: test
  script:
   - npm test

performance:
  stage: performance
  script:
   - npm run perf

pages:
  stage: deploy
  script:
  - cd dashboard && npm ci && npm rebuild node-sass && npm run build && cd ..
  - mkdir .public
  - cp -r dashboard/build/fonts .public
  - cp dashboard/build/dashboard.* .public
  - cp dashboard/build/index.html .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master
