version: 2.1

orbs:
  node: circleci/node@5.0.2

defaults: &defaults
  working_directory: ~/repo
  docker:
    - image: circleci/node:latest

jobs:
  test:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
      - run: npm install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: npm test
      - persist_to_workspace:
          root: ~/repo
          paths: .

  build:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run: npm prepare
      - persist_to_workspace:
          root: ~/repo
          paths: .

  publish:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - run:
          name: Publish package
          command: npm publish
      - run: yarn chromatic

workflows:
  run:
    jobs:
      - test
      - build:
          requires:
            - test
      - publish:
          filters:
            tags:
              only: /^v.*/
            branches:
              only:
                - master
          requires:
            - build

version: 2.1

orbs:
  node: circleci/node@5.0.2

defaults: &defaults
  working_directory: ~/repo
  docker:
    - image: circleci/node:latest

jobs:
  test:
    <<: *defaults
    steps:
      - checkout
      - restore_cache:
          keys:
            - v1-dependencies-{{ checksum "package.json" }}
            - v1-dependencies-
      - run: yarn install
      - save_cache:
          paths:
            - node_modules
          key: v1-dependencies-{{ checksum "package.json" }}
      - run: yarn test
      - persist_to_workspace:
          root: ~/repo
          paths: .

  build:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run: yarn prepare
      - persist_to_workspace:
          root: ~/repo
          paths: .

  publish:
    <<: *defaults
    steps:
      - attach_workspace:
          at: ~/repo
      - run:
          name: Authenticate with registry
          command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
      - run:
          name: Publish package
          command: npm publish
      - run: yarn chromatic

workflows:
  run:
    jobs:
      - test
      - build:
          requires:
            - test
      - publish:
          filters:
            tags:
              only: /^v.*/
            branches:
              only:
                - master
          requires:
            - build

Revert "change commands on circle ci to use npm instead of yarn"
Revert "change commands on circle ci to use npm instead of yarn"

This reverts commit 78425f98b12ef982c390498449702d47b0486261.
