Skip to content

Conversation

@kabaros
Copy link
Contributor

@kabaros kabaros commented Jul 23, 2025

This PR decouples the dependency of cli-app-scripts on yarn@v1 allowing apps and consumers of the CLI to use more modern package managers such as pnpm (or even npm).

d2-with-pnpm.webm

relates to the CLI PR: dhis2/cli#629
implements https://dhis2.atlassian.net/browse/LIBS-800

Some notes:

  • The PR keeps backwards compatibility - by default, initialising new apps would use yarn@1 and should behave the same as before. Users are able to pass a --pnpm argument to opt for using pnpm instead.
  • When using pnpm, the dependencies of a new a project are installed using the specified package manager, and the lock file updated.
  • For pnpm, we needed to public hoist in order to make phantom dependencies of @dhis2/app-shell work. These were used directly by the shell, and worked before because of the behaviour of yarn 1 (which was dropped in subsequent yarn versions) to hoist and make available all dependencies - at some point, we should look at app-shell behaviour in order to avoid the issue, but for now, this works without issues for consumers.
  • Added a packageManager field to package.json - this enables consumers to know what package manager to use and install it with corepack (which is available for modern node version from 14+) .
  • This also gets rid of all the warnings when initialising a new app! 🥳

To test:

  • install the alpha version of CLI pnpm i -g @dhis2/cli@alpha (you can use npm or yarn if you'd like)
  • initialise a new app with d2 app scripts init sample --pnpm
    • if you haven't before, enable corepack with corepack enable - this is just convenient and good practice in general.
  • you can then test the normal operations of cli-app-scripts: pnpm start, pnpm build pnpm test....
  • repeat the same without the --pnpm flag to ensure things work with yarn as before.

kabaros and others added 20 commits July 23, 2025 07:38
# [12.7.0-alpha.1](v12.6.4...v12.7.0-alpha.1) (2025-07-23)

### Bug Fixes

* **deps:** get rid of warnings shown on initialising new d2 projects ([#929](#929)) ([f5b499f](f5b499f)), closes [#927](#927) [#927](#927) [#928](#928) [#928](#928) [#930](#930) [#930](#930)

### Features

* support pnpm and other package managers ([9c81f35](9c81f35))
# [12.7.0-alpha.2](v12.7.0-alpha.1...v12.7.0-alpha.2) (2025-07-23)

### Bug Fixes

* correct cli-app-script link ([1d889ff](1d889ff))
# [12.7.0-alpha.3](v12.7.0-alpha.2...v12.7.0-alpha.3) (2025-07-23)

### Bug Fixes

* default to pnpm as a package manager ([2fb963f](2fb963f))
# [12.7.0-alpha.4](v12.7.0-alpha.3...v12.7.0-alpha.4) (2025-07-24)

### Bug Fixes

* change hoist options for phantom app-shell dependencies ([ac9aa78](ac9aa78))
# [12.7.0-alpha.5](v12.7.0-alpha.4...v12.7.0-alpha.5) (2025-07-24)

### Bug Fixes

* add styled-jsx to hoisted dependencies ([9e692bc](9e692bc))
# [12.7.0-alpha.6](v12.7.0-alpha.5...v12.7.0-alpha.6) (2025-07-24)

### Bug Fixes

* change cli option for package manager to boolean '--pnpm' ([e971c3d](e971c3d))
# [12.7.0-alpha.7](v12.7.0-alpha.6...v12.7.0-alpha.7) (2025-07-24)

### Bug Fixes

* default args to undefined not 'false' to avoid conflict ([2b54a06](2b54a06))
# [12.7.0-alpha.8](v12.7.0-alpha.7...v12.7.0-alpha.8) (2025-07-24)

### Bug Fixes

* recommend the use of 'pnpm' as a warning on init command ([e0cda6d](e0cda6d))
# [12.7.0-alpha.9](v12.7.0-alpha.8...v12.7.0-alpha.9) (2025-07-24)

### Bug Fixes

* capitalise log messages ([e480586](e480586))
)} to ${path.relative(paths.base, srcNodeModules)}...`
)
await fs.ensureSymlink(srcNodeModules, destNodeModules)
fs.ensureSymlinkSync(srcNodeModules, destNodeModules)
Copy link
Contributor Author

@kabaros kabaros Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this - and other fs.xSync calls - fix a race condition that happened before the first time we run start where the symlink is sometimes not yet created

kabaros and others added 6 commits July 24, 2025 10:50
# [12.7.0-alpha.10](v12.7.0-alpha.9...v12.7.0-alpha.10) (2025-07-24)

### Bug Fixes

* ensure app-shell symlink is created to avoid race conditon ([223350e](223350e))
* ensure npm works as well as pnpm ([2975d2e](2975d2e))
# [12.7.0-alpha.11](v12.7.0-alpha.10...v12.7.0-alpha.11) (2025-07-24)

### Bug Fixes

* race condition with symlinks ([fe2d496](fe2d496))
# [12.7.0-alpha.12](v12.7.0-alpha.11...v12.7.0-alpha.12) (2025-07-24)

### Bug Fixes

* add corepack packageManager field ([acb4ac0](acb4ac0))
@kabaros kabaros marked this pull request as ready for review July 24, 2025 11:27
@kabaros kabaros requested review from KaiVandivier and d-rita July 24, 2025 12:18
dhis2-bot and others added 5 commits July 24, 2025 12:21
# [12.7.0-alpha.13](v12.7.0-alpha.12...v12.7.0-alpha.13) (2025-07-24)

### Bug Fixes

* force alpha release to npm ([78a2e69](78a2e69))
* **deps:** deduplicate dependencies ([#931](#931)) ([b255039](b255039))
# [12.7.0-alpha.14](v12.7.0-alpha.13...v12.7.0-alpha.14) (2025-07-25)

### Bug Fixes

* expose init command in the package ([cc8b7f5](cc8b7f5))
# [12.7.0-alpha.15](v12.7.0-alpha.14...v12.7.0-alpha.15) (2025-07-28)

### Bug Fixes

* hoist dependencies needed for plugins and PWAs ([fa91bc5](fa91bc5))
kabaros and others added 2 commits July 28, 2025 20:26
# [12.8.0-alpha.1](v12.7.0...v12.8.0-alpha.1) (2025-07-28)

### Bug Fixes

* add corepack packageManager field ([acb4ac0](acb4ac0))
* add styled-jsx to hoisted dependencies ([9e692bc](9e692bc))
* capitalise log messages ([e480586](e480586))
* change cli option for package manager to boolean '--pnpm' ([e971c3d](e971c3d))
* change hoist options for phantom app-shell dependencies ([ac9aa78](ac9aa78))
* correct cli-app-script link ([1d889ff](1d889ff))
* default args to undefined not 'false' to avoid conflict ([2b54a06](2b54a06))
* default to pnpm as a package manager ([2fb963f](2fb963f))
* ensure app-shell symlink is created to avoid race conditon ([223350e](223350e))
* ensure npm works as well as pnpm ([2975d2e](2975d2e))
* expose init command in the package ([cc8b7f5](cc8b7f5))
* force alpha release to npm ([78a2e69](78a2e69))
* hoist dependencies needed for plugins and PWAs ([fa91bc5](fa91bc5))
* race condition with symlinks ([fe2d496](fe2d496))
* recommend the use of 'pnpm' as a warning on init command ([e0cda6d](e0cda6d))

### Features

* support pnpm and other package managers ([9c81f35](9c81f35))
@sonarqubecloud
Copy link

kabaros and others added 4 commits October 29, 2025 15:03
# [12.8.0-alpha.2](v12.8.0-alpha.1...v12.8.0-alpha.2) (2025-10-29)

### Bug Fixes

* allow passing a reporter to init command ([ca36333](ca36333))
# [12.8.0-alpha.3](v12.8.0-alpha.2...v12.8.0-alpha.3) (2025-10-29)

### Bug Fixes

* Revert "fix: allow passing a reporter to init command ([6028374](6028374))
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
20 New issues
1 New Critical Issues (required ≤ 0)
20 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants