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

Implement npm-version with pnpm workspace support #8064

Open
1 task
james-yeoman opened this issue May 9, 2024 · 0 comments
Open
1 task

Implement npm-version with pnpm workspace support #8064

james-yeoman opened this issue May 9, 2024 · 0 comments

Comments

@james-yeoman
Copy link

Contribution

Describe the user story

As a developer, I want to be able to use the version command, so that I can handle version bumps in a single command.

As a developer, I want pnpm to implement the version command instead of passing through to npm, so that I can bump versions in a workspace context.

Describe the solution you'd like

npm has the version command, which is meant to be workspace-aware. However, it's not pnpm-workspace-aware, which means that in order to use it via pnpm, I have to do the following:

pnpm --filter <workspace_name> exec pnpm version <version bump type>

While this works to run the version command on a particular workspace, it's cumbersome (since the -w flag on the version command doesn't know about pnpm workspaces, and you have to use exec pnpm after filtering the workspace).

Additionally, npm has this 4 year old npm bug regarding the version command, which means that it won't handle committing the package.json change and tagging when using it on non-root packages (i.e. workspaces). It changes the package.json version field correctly, but that's all it accomplishes.

Ideally, pnpm would implement the version command, which would make it pnpm-workspace-aware, and also ensuring the aforementioned bug doesn't occur.

Describe the drawbacks of your solution

It's additional code with an admittedly small overall benefit for a package manager (even though it's an entirely isolated piece of functionality, and is highly unlikely to have code-churn).

Describe alternatives you've considered

The following works, but is overly cumbersome. Also requires a weird hack to fool version into thinking it's at the top level (creating an empty .git directory).

pushd <workspace filepath> && mkdir .git && npm version <version bump type> && rm -r .git && popd

The following would work, but again requires a weird hack to fool version into thinking it's at the top level. It also requires being defined in each workspace's package.json.

{
  //...
  "scripts": {
    //...
    "preversion": "mkdir .git",
    "bump": "npm version",
    "postversion": "rm -r .git",
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant