---
stages:
  - setup
  - test
  - deploy

Setup:
  stage: setup
  tags:
    - test-platform
  script:
    - npm i
  artifacts:
    paths:
      - node_modules/

NPM Audit:
  stage: test
  tags:
    - test-platform
  dependencies:
    - Setup
  script:
    - npm audit

Test:
  stage: test
  tags:
    - test-platform
  dependencies:
    - Setup
  script:
    - npm run test
    - npm run lint

deploy:
  stage: deploy
  only:
    - tags
    - triggers
  tags:
    - test-platform
  allow_failure: false
  script:
    - echo -e "//registry.npmjs.org/:_authToken=${NPM_TOKEN}\nunsafe-perm = true" > .npmrc
    - npm run build
    - npm publish --access public
