Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preversion/postversion script for propagating versions in npm workspaces #5303

Merged
merged 10 commits into from
Sep 24, 2024

Conversation

compulim
Copy link
Contributor

@compulim compulim commented Sep 24, 2024

Changelog Entry

(No changelog for build scripts update.)

Description

npm has limited workspace support on npm version.

In a npm workspace, when running npm version --workspaces 1.2.3, npm does not update version numbers in dependencies and devDependencies for local dependencies. That means, it could point to an outdated version and could also look for it on public registry.

We are introducing preversion and postversion scripts that would remove local dependencies while running npm version.

As npm version by default would run npm update afterwards, after our postversion restoring the local dependencies, npm update should update package-lock.json and point to the right version inside the workspace.

We prefer preversion and postversion as we can leverage npm version and lower learning curve.

In the future, we should have a script at root-level to automatically generate the localDependencies in each package.json.

Design

Updated package.json/localDependencies field for a single map for both development and production dependencies.

bump will bump non-local dependencies.

preversion/postversion will temporarily remove local dependencies, run npm version, then restore local dependencies. By default, npm version will also run npm update automatically to link the newer version number in package-lock.json.

Specific Changes

  • Updated all package.json
    • Added new preversion and postversion script to temporarily remove local dependencies from dependencies and devDependencies
    • Updated localPeerDependencies/localPeerDevDependencies array to localDependencies map for consolidation
    • Updated bump script for the new localDependencies
  • I have added tests and executed them locally
  • I have updated CHANGELOG.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

@compulim compulim marked this pull request as ready for review September 24, 2024 00:15
@compulim compulim merged commit 0537887 into main Sep 24, 2024
27 checks passed
@compulim compulim deleted the feat-postversion branch September 24, 2024 07:22
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.

2 participants