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

fix(node-workspace): Add update-peer-dependencies option that also updates peer dependencies. Fixes #1943 #2094

Merged
merged 9 commits into from
Dec 11, 2023
13 changes: 11 additions & 2 deletions __snapshots__/node-workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ exports['NodeWorkspace plugin run respects version prefix 1'] = `
"name": "@here/plugin1",
"version": "4.4.4",
"peerDependencies": {
"@here/pkgA": "^3.3.3"
"@here/pkgA": "^2.2.2"
}
}
`

exports['NodeWorkspace plugin run should ignore peer dependencies 1'] = `
exports['NodeWorkspace plugin run should not ignore peer dependencies 1'] = `
:robot: I have created a release *beep* *boop*
---

Expand All @@ -127,6 +127,15 @@ exports['NodeWorkspace plugin run should ignore peer dependencies 1'] = `
Release notes for path: node1, releaseType: node
</details>

<details><summary>@here/plugin1: 4.4.5</summary>

### Dependencies

* The following workspace dependencies were updated
* peerDependencies
* @here/pkgA bumped from ^3.3.3 to ^3.3.4
</details>

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/node-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
const allPackages = Array.from(packagesByPath.values());
this.packageGraph = new PackageGraph(
allPackages,
'allDependencies',
'allPlusPeerDependencies',
this.alwaysLinkLocal
);

Expand Down Expand Up @@ -178,7 +178,8 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
updatedPackage.updateLocalDependency(
resolved,
depVersion.toString(),
prefix
prefix,
true
);
this.logger.info(
`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`
Expand Down Expand Up @@ -257,7 +258,8 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
updatedPackage.updateLocalDependency(
resolved,
depVersion.toString(),
prefix
prefix,
true
);
this.logger.info(
`${pkg.name}.${depName} updated to ${prefix}${depVersion.toString()}`
Expand Down Expand Up @@ -373,6 +375,7 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
...(packageJson.dependencies ?? {}),
...(packageJson.devDependencies ?? {}),
...(packageJson.optionalDependencies ?? {}),
...(packageJson.peerDependencies ?? {}),
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/node-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ describe('NodeWorkspace plugin', () => {
const update3 = assertHasUpdate(updates, 'node3/CHANGELOG.md', Changelog);
snapshot((update3.updater as Changelog).changelogEntry);
});
it('should ignore peer dependencies', async () => {
it('should not ignore peer dependencies', async () => {
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest('node1', 'node', '3.3.4', {
component: '@here/pkgA',
Expand Down Expand Up @@ -404,7 +404,7 @@ describe('NodeWorkspace plugin', () => {
expect(nodeCandidate).to.not.be.undefined;
const updates = nodeCandidate!.pullRequest.updates;
assertHasUpdate(updates, 'node1/package.json');
assertNoHasUpdate(updates, 'plugin1/package.json');
assertHasUpdate(updates, 'plugin1/package.json');
snapshot(dateSafe(nodeCandidate!.pullRequest.body.toString()));
});
});
Expand Down