Skip to content

Commit

Permalink
Support workspace protocol, rather than adding a config to the dep-ve…
Browse files Browse the repository at this point in the history
…rsion bumping
  • Loading branch information
NullVoxPopuli committed Oct 17, 2023
1 parent 84da534 commit e7de955
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,6 @@ This value replaces the value from `package.json`, and given the above
configuration `@release-it-plugins/workspaces` would publish each package (that was
not private) in `dist/packages` folder.

### skipReferenceUpdates

By default when the `version` of a package is updated, all consumers within the monorepo will have their `dependencies`, `devDependencies`, and `peerDependencies` updated as well. This may be undesired when using `pnpm`, as folks using release-it with `pnpm` will want to use `pnpm -r publish` so that packages have correctly have their `dependencies` (etc) updated during publish, but in source, the [workspace protocol](https://pnpm.io/workspaces#workspace-protocol-workspace) is maintained.

```json
{
"release-it": {
"plugins": {
"@release-it-plugins/workspaces": {
"skipReferenceUpdates": true
}
}
}
}
```

The default value is `false`, so `npm`, and `yarn` projects typically don't need to worry about this setting.

### additionalManifests

#### versionUpdates
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,11 @@ export default class WorkspacesPlugin extends Plugin {
}
};

const skipReferenceUpdates = this.getContext('skipReferenceUpdates');
workspaces.forEach(({ relativeRoot, pkgInfo }) => {
this.log.exec(`Processing ${relativeRoot}/package.json:`);

updateVersion(pkgInfo);
if (!skipReferenceUpdates) {
this._updateDependencies(pkgInfo, version);
}
this._updateDependencies(pkgInfo, version);

if (!isDryRun) {
pkgInfo.write();
Expand Down Expand Up @@ -334,6 +331,15 @@ export default class WorkspacesPlugin extends Plugin {
for (let dependency in dependencies) {
if (workspaces.find((w) => w.name === dependency)) {
const existingVersion = dependencies[dependency];

/**
* If pnpm is being used, the Workspace protocol may also be used
* https://pnpm.io/workspaces#workspace-protocol-workspace
* if it is, these version references are handled on publish
* by `pnpm publish`.
*/
if (existingVersion.startsWith('workspace:')) continue;

const replacementVersion = this._buildReplacementDepencencyVersion(
existingVersion,
newVersion
Expand Down

0 comments on commit e7de955

Please sign in to comment.