Skip to content

Commit 3bae613

Browse files
authored
refactor: move updatePeerDependencies config to node-workspace plugin (#2164)
* refactor: move updatePeerDependencies config to node-workspace plugin * docs: adjust guidance on updatePeerDependencies * fix: remove extra update-peer-dependencies reference
1 parent 59f4a6a commit 3bae613

7 files changed

Lines changed: 113 additions & 17 deletions

File tree

docs/manifest-releaser.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,6 @@ defaults (those are documented in comments)
207207
// absence defaults to true
208208
"always-link-local": false,
209209

210-
// when using the `node-workspace` plugin, update peer dependency fields
211-
// that reference bumped packages.
212-
// absence defaults to false, and peer dependency fields are not updated.
213-
"update-peer-dependencies": true,
214-
215210
// if true, create separate pull requests for each package instead of a
216211
// single manifest release pull request
217212
// absence defaults to false and one pull request will be raised
@@ -504,7 +499,18 @@ your local dependencies bumped if they are within the SemVer range, you can set
504499

505500
By default, the `node-workspace` plugin doesn't modify `peerDependencies` fields in
506501
package.json. If you would like version bumps to be also linked in `peerDependencies`
507-
fields, set `"update-peer-dependencies"` to `true` in your manifest config.
502+
fields, set `"updatePeerDependencies"` to `true` in your manifest plugin config.
503+
504+
```
505+
{
506+
"plugins": [
507+
{
508+
"type": "node-workspace",
509+
"updatePeerDependencies": true
510+
}
511+
]
512+
}
513+
```
508514

509515
### cargo-workspace
510516

schemas/config.json

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,6 @@
248248
"description": "When using the `node-workspace` plugin, force all local dependencies to be linked.",
249249
"type": "boolean"
250250
},
251-
"update-peer-dependencies": {
252-
"description": "When using the `node-workspace` plugin, also bump peer dependency versions if they are modified.",
253-
"type": "boolean"
254-
},
255251
"plugins": {
256252
"description": "Plugins to apply to pull requests. Plugins can be added to perform extra release processing that cannot be achieved by an individual release strategy.",
257253
"type": "array",
@@ -304,7 +300,31 @@
304300
"type": "string",
305301
"enum": [
306302
"cargo-workspace",
307-
"maven-workspace",
303+
"maven-workspace"
304+
]
305+
},
306+
"updateAllPackages": {
307+
"description": "Whether to force updating all packages regardless of the dependency tree. Defaults to `false`.",
308+
"type": "boolean"
309+
},
310+
"merge": {
311+
"description": "Whether to merge in-scope pull requests into a combined release pull request. Defaults to `true`.",
312+
"type": "boolean"
313+
},
314+
"considerAllArtifacts": {
315+
"description": "Whether to analyze all packages in the workspace for cross-component version bumping. This currently only works for the maven-workspace plugin. Defaults to `true`.",
316+
"type": "boolean"
317+
}
318+
}
319+
},
320+
{
321+
"description": "Configuration for various `workspace` plugins.",
322+
"type": "object",
323+
"properties": {
324+
"type": {
325+
"description": "The name of the plugin.",
326+
"type": "string",
327+
"enum": [
308328
"node-workspace"
309329
]
310330
},
@@ -319,6 +339,10 @@
319339
"considerAllArtifacts": {
320340
"description": "Whether to analyze all packages in the workspace for cross-component version bumping. This currently only works for the maven-workspace plugin. Defaults to `true`.",
321341
"type": "boolean"
342+
},
343+
"updatePeerDependencies": {
344+
"description": "Also bump peer dependency versions if they are modified. Defaults to `false`.",
345+
"type": "boolean"
322346
}
323347
}
324348
},
@@ -387,7 +411,6 @@
387411
"bootstrap-sha": true,
388412
"last-release-sha": true,
389413
"always-link-local": true,
390-
"update-peer-dependencies": true,
391414
"plugins": true,
392415
"group-pull-request-title-pattern": true,
393416
"release-search-depth": true,

src/manifest.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ export interface ManifestOptions {
181181
bootstrapSha?: string;
182182
lastReleaseSha?: string;
183183
alwaysLinkLocal?: boolean;
184-
updatePeerDependencies?: boolean;
185184
separatePullRequests?: boolean;
186185
plugins?: PluginType[];
187186
fork?: boolean;
@@ -224,6 +223,9 @@ export interface WorkspacePluginConfig extends ConfigurablePluginType {
224223
merge?: boolean;
225224
considerAllArtifacts?: boolean;
226225
}
226+
export interface NodeWorkspacePluginConfig extends WorkspacePluginConfig {
227+
updatePeerDependencies?: boolean;
228+
}
227229
export interface GroupPriorityPluginConfig extends ConfigurablePluginType {
228230
groups: string[];
229231
}
@@ -233,7 +235,8 @@ export type PluginType =
233235
| GroupPriorityPluginConfig
234236
| LinkedVersionPluginConfig
235237
| SentenceCasePluginConfig
236-
| WorkspacePluginConfig;
238+
| WorkspacePluginConfig
239+
| NodeWorkspacePluginConfig;
237240

238241
/**
239242
* This is the schema of the manifest config json
@@ -243,7 +246,6 @@ export interface ManifestConfig extends ReleaserConfigJson {
243246
'bootstrap-sha'?: string;
244247
'last-release-sha'?: string;
245248
'always-link-local'?: boolean;
246-
'update-peer-dependencies'?: boolean;
247249
plugins?: PluginType[];
248250
'group-pull-request-title-pattern'?: string;
249251
'release-search-depth'?: number;
@@ -1391,7 +1393,6 @@ async function parseConfig(
13911393
bootstrapSha: config['bootstrap-sha'],
13921394
lastReleaseSha: config['last-release-sha'],
13931395
alwaysLinkLocal: config['always-link-local'],
1394-
updatePeerDependencies: config['update-peer-dependencies'],
13951396
separatePullRequests: config['separate-pull-requests'],
13961397
groupPullRequestTitlePattern: config['group-pull-request-title-pattern'],
13971398
plugins: config['plugins'],

src/plugins/node-workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface NodeWorkspaceOptions extends WorkspacePluginOptions {
6767
*/
6868
export class NodeWorkspace extends WorkspacePlugin<Package> {
6969
private alwaysLinkLocal: boolean;
70-
private updatePeerDependencies: boolean;
70+
readonly updatePeerDependencies: boolean;
7171
constructor(
7272
github: GitHub,
7373
targetBranch: string,

test/factories/plugin-factory.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {LinkedVersions} from '../../src/plugins/linked-versions';
2525
import {ManifestPlugin} from '../../src/plugin';
2626
import {GitHub} from '../../src';
2727
import {GroupPriority} from '../../src/plugins/group-priority';
28+
import {NodeWorkspace} from '../../src/plugins/node-workspace';
2829

2930
describe('PluginFactory', () => {
3031
let github: GitHub;
@@ -97,6 +98,20 @@ describe('PluginFactory', () => {
9798
expect(plugin).to.not.be.undefined;
9899
expect(plugin).instanceof(GroupPriority);
99100
});
101+
it('should build workspace options', () => {
102+
const plugin = buildPlugin({
103+
github,
104+
type: {
105+
type: 'node-workspace',
106+
updatePeerDependencies: true,
107+
},
108+
targetBranch: 'target-branch',
109+
repositoryConfig,
110+
manifestPath: '.manifest.json',
111+
});
112+
expect(plugin).to.not.be.undefined;
113+
expect(plugin).instanceof(NodeWorkspace);
114+
});
100115
});
101116
describe('getPluginTypes', () => {
102117
it('should return default types', () => {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"release-type": "node",
3+
"plugins": [
4+
{
5+
"type": "node-workspace",
6+
"considerAllArtifacts": true,
7+
"updatePeerDependencies": true
8+
}
9+
],
10+
"packages": {
11+
"pkg1": {
12+
"component": "pkg1"
13+
},
14+
"pkg2": {
15+
"component": "pkg2"
16+
},
17+
"pkg3": {
18+
"component": "pkg3"
19+
}
20+
}
21+
}

test/manifest.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,36 @@ describe('Manifest', () => {
773773
).to.eql('default');
774774
});
775775

776+
it('should read plugins from manifest', async () => {
777+
const getFileContentsStub = sandbox.stub(
778+
github,
779+
'getFileContentsOnBranch'
780+
);
781+
getFileContentsStub
782+
.withArgs('release-please-config.json', 'main')
783+
.resolves(
784+
buildGitHubFileContent(
785+
fixturesPath,
786+
'manifest/config/node-workspace-plugins.json'
787+
)
788+
)
789+
.withArgs('.release-please-manifest.json', 'main')
790+
.resolves(
791+
buildGitHubFileContent(
792+
fixturesPath,
793+
'manifest/versions/versions.json'
794+
)
795+
);
796+
const manifest = await Manifest.fromManifest(
797+
github,
798+
github.repository.defaultBranch
799+
);
800+
expect(manifest.plugins).lengthOf(1);
801+
expect(manifest.plugins[0]).instanceOf(NodeWorkspace);
802+
const workspacePlugin = manifest.plugins[0] as NodeWorkspace;
803+
expect(workspacePlugin.updatePeerDependencies).to.be.true;
804+
});
805+
776806
it('should throw a configuration error for a missing manifest config', async () => {
777807
const getFileContentsStub = sandbox.stub(
778808
github,

0 commit comments

Comments
 (0)