version: 2.1
orbs:
  node: circleci/node@5.2.0
  
defaults: &defaults
  working_directory: ~/workspace
  docker:
    - image: circleci/node:16

jobs:
  test:
    <<: *defaults
    steps:
      - checkout
      - run:
          name: Packages audit
          command: |
            npx audit-ci@^6 --config ./audit-ci.jsonc
      - run:
          name: Add npm token
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
      - node/install-packages
      - run:
          name: Test
          command: |
            npm run test

workflows: 
  version: 2
  test:
    jobs:
      - test:
          context: org-default