Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions __snapshots__/node-workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,29 @@ Release notes for path: node1, releaseType: node
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
`

exports['NodeWorkspace plugin run should not include peer dependency notes in changelog when package has both dev and peer deps 1'] = `
:robot: I have created a release *beep* *boop*
---


<details><summary>@here/pkgA: 3.3.4</summary>

Release notes for path: node1, releaseType: node
</details>

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

### Dependencies

* The following workspace dependencies were updated
* devDependencies
* @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).
`

exports['NodeWorkspace plugin run walks dependency tree and updates previously untouched packages (prerelease) 1'] = `
:robot: I have created a release *beep* *boop*
---
Expand Down Expand Up @@ -349,6 +372,31 @@ exports['NodeWorkspace plugin with updatePeerDependencies: true respects version
}
`

exports['NodeWorkspace plugin with updatePeerDependencies: true should include peer dependency notes in changelog when package has both dev and peer deps 1'] = `
:robot: I have created a release *beep* *boop*
---


<details><summary>@here/pkgA: 3.3.4</summary>

Release notes for path: node1, releaseType: node
</details>

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

### Dependencies

* The following workspace dependencies were updated
* devDependencies
* @here/pkgA bumped from ^3.3.3 to ^3.3.4
* 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).
`

exports['NodeWorkspace plugin with updatePeerDependencies: true should not ignore peer dependencies 1'] = `
:robot: I have created a release *beep* *boop*
---
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/node-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
pkg,
updatedPackage,
updatedVersions,
this.logger
this.logger,
this.updatePeerDependencies
);

existingCandidate.pullRequest.updates =
Expand Down Expand Up @@ -268,7 +269,8 @@ export class NodeWorkspace extends WorkspacePlugin<Package> {
pkg,
updatedPackage,
updatedVersions,
this.logger
this.logger,
this.updatePeerDependencies
);

const strategy = this.strategiesByPath[updatedPackage.path];
Expand Down Expand Up @@ -454,7 +456,8 @@ function getChangelogDepsNotes(
original: Package,
updated: Package,
updateVersions: VersionsMap,
logger: Logger
logger: Logger,
updatePeerDependencies = true
): string {
let depUpdateNotes = '';
type DT =
Expand All @@ -465,7 +468,7 @@ function getChangelogDepsNotes(
const depTypes: DT[] = [
'dependencies',
'devDependencies',
'peerDependencies',
...(updatePeerDependencies ? (['peerDependencies'] as const) : []),
'optionalDependencies',
];
const updates: Map<DT, string[]> = new Map();
Expand Down
10 changes: 10 additions & 0 deletions test/fixtures/plugins/node-workspace/plugin2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@here/plugin2",
"version": "4.4.4",
"peerDependencies": {
"@here/pkgA": "^3.3.3"
},
"devDependencies": {
"@here/pkgA": "^3.3.3"
}
}
84 changes: 84 additions & 0 deletions test/plugins/node-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,45 @@ describe('NodeWorkspace plugin', () => {
assertNoHasUpdate(updates, 'plugin1/package.json');
snapshot(dateSafe(nodeCandidate!.pullRequest.body.toString()));
});
it('should not include peer dependency notes in changelog when package has both dev and peer deps', async () => {
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest('node1', 'node', '3.3.4', {
component: '@here/pkgA',
updates: [
buildMockPackageUpdate('node1/package.json', 'node1/package.json'),
],
}),
];
stubFilesFromFixtures({
sandbox,
github,
fixturePath: fixturesPath,
files: ['node1/package.json', 'plugin2/package.json'],
flatten: false,
targetBranch: 'main',
});
plugin = new NodeWorkspace(github, 'main', {
node1: {
releaseType: 'node',
},
plugin2: {
releaseType: 'node',
},
});
const newCandidates = await plugin.run(candidates);
expect(newCandidates).lengthOf(1);
const nodeCandidate = newCandidates.find(
candidate => candidate.config.releaseType === 'node'
);
expect(nodeCandidate).to.not.be.undefined;
const updates = nodeCandidate!.pullRequest.updates;
assertHasUpdate(updates, 'node1/package.json');
assertHasUpdate(updates, 'plugin2/package.json');
const body = nodeCandidate!.pullRequest.body.toString();
expect(body).to.include('devDependencies');
expect(body).to.not.include('peerDependencies');
snapshot(dateSafe(body));
});
});
describe('with updatePeerDependencies: true', () => {
const options = {updatePeerDependencies: true};
Expand Down Expand Up @@ -741,6 +780,51 @@ describe('NodeWorkspace plugin', () => {
snapshot(dateSafe(nodeCandidate!.pullRequest.body.toString()));
});

it('should include peer dependency notes in changelog when package has both dev and peer deps', async () => {
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest('node1', 'node', '3.3.4', {
component: '@here/pkgA',
updates: [
buildMockPackageUpdate('node1/package.json', 'node1/package.json'),
],
}),
];
stubFilesFromFixtures({
sandbox,
github,
fixturePath: fixturesPath,
files: ['node1/package.json', 'plugin2/package.json'],
flatten: false,
targetBranch: 'main',
});
plugin = new NodeWorkspace(
github,
'main',
{
node1: {
releaseType: 'node',
},
plugin2: {
releaseType: 'node',
},
},
options
);
const newCandidates = await plugin.run(candidates);
expect(newCandidates).lengthOf(1);
const nodeCandidate = newCandidates.find(
candidate => candidate.config.releaseType === 'node'
);
expect(nodeCandidate).to.not.be.undefined;
const updates = nodeCandidate!.pullRequest.updates;
assertHasUpdate(updates, 'node1/package.json');
assertHasUpdate(updates, 'plugin2/package.json');
const body = nodeCandidate!.pullRequest.body.toString();
expect(body).to.include('devDependencies');
expect(body).to.include('peerDependencies');
snapshot(dateSafe(body));
});

it('respects version prefix and updates peer dependencies', async () => {
const candidates: CandidateReleasePullRequest[] = [
buildMockCandidatePullRequest('plugin1', 'node', '4.4.4', {
Expand Down
Loading