Skip to content
This repository has been archived by the owner. It is now read-only.
[DEPRECATED] Package helper for linking and building
JavaScript TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

📦 packages

dhis2-cli Compatible Conventional Commits Greenkeeper badge

Standardised tool for dealing with DHIS2 Packages.


  • focus on "flatpak" packages (publish from inside build directory)
  • copies package.json from ${pkg} to ${pkg}/build/
  • updates build/package.json with private: false and publicAccess props
  • bundles formatters for code-style and commit-style from @dhis2/code-style
  • plugin architecture based on yargs command modules

Monorepo aware

  • monorepo support (packages in ${repo}/packages/)
  • figures out interdependencies between packages
  • create symlinks between interdependent packages from inside build/ directory


npm install --save-dev @dhis2/packages
# or
yarn add -D @dhis2/packages


packages help
usage: packages <command> [options]

# ... list of commands ...

Adding hooks

Install Husky (preferred) or another hook-manager:

npm install husky --save-dev
"husky": {
    "hooks": {
      "commit-msg": "packages commit-style",
      "pre-commit": "packages code-style"

Once you are using those hooks, we can generate for each release, e.g. as we do in @dhis2/ui/


Packages supports both tools but yields to Yarn if there exists both a yarn.lock and a package-lock.json file.


And example implementation of a monorepo with workspaces is here: d2-ui/package.json.

The packages exec command is important for monorepos as it runs the given command with its arguments on each of the sub-packages inside of ${repo}/packages/.

Common configuration could be to add the following scripts:

    "build": "packages build",
    "watch": "packages exec yarn watch",
    "lint": "packages exec yarn lint",

NPM/Yarn without workspaces

Packages supports monorepos without using the concept of workspaces, but it makes some assumptions about how the project is structured:

  • all packages are inside ${repo}/packages/
  • devs need to run packages install which then runs install in each sub-package

The workflow would be:

packages install
packages link
packages build

packages install takes care to first run the install command in the ${repo}/, and then running install in each sub-package in parallel.

Yarn Workspaces

Using workspaces, a developer could simplify the workflow with the configuration:

  "scripts": {
    "postinstall": "packages link",
  "workspaces": [

Yielding the workflow:

yarn install
packages build

yarn install with workspaces enabled automatically installs all dependencies for the sub-packages in one go.

You can’t perform that action at this time.