Skip to main content

Migration Guide

From previous d2-style version to 5.x

Going from a previous version of d2-style, it is best to first uninstall it, only to install it fresh after.

  1. Remove @dhis2/cli-style:

    yarn remove @dhis2/cli-style
  2. Clear out the local Git hooks (if the uninstall did not do it automatically):

    rm .git/hooks/*
  3. Take this opportunity to clear out (or back up) any Husky configuration you have around, e.g. in package.json or in .huskyrc{,.js}.

  4. If you have modified any of the d2-style controlled configuration files, back them up now.

  5. Now, let us get down to business. Install @dhis2/cli-style:

    yarn add @dhis2/cli-style --dev
  6. At this point the newest version of d2-style will be installed, and Husky will have written updated hooks to .git/hooks.

  7. Depending on the project, you will want to vary the next command, but in all cases you will want to regenerate new configuration files:

    # no assumption about the project
    yarn d2-style install project/base --force

    # assuming a javascript project
    yarn d2-style install project/js --force

    # assuming a react project
    yarn d2-style install project/react --force

    (You did take a backup of modified configuration files earlier, right?)

  8. (Optional) Copy back any of your old customizations that you still need from the backups, then remove the backups.

From existing Husky/ESLint/Prettier..

Let's deal with these one by one before installing d2-style.

1. Cleaning up

Husky

Uninstall Husky by running:

yarn remove husky

Husky should clean up after itself, but if it has left hooks in .git/hooks for some reason, wipe them manually:

rm .git/hooks/*

Now remove any Husky configuration from package.json and/or .huskyrc{,.js} files.

ESLint

If you have any ESLint configuration files laying around, move them to a backup file for now. You might want to add some rules back in after generating DHIS2 configurations.

Prettier

The Prettier configuration you should remove. There is no reason to keep a custom Prettier configuration file around. The only reason d2-style generates one is to allow your IDE to pick up the configuration from the default location.

2. Setting up d2-style

At this point you should be at a pristine starting position and be able to follow the fresh install instructions in the getting started guide.