Skip to content

Commit

Permalink
feat: parse versioning type from the manifest config (#1572)
Browse files Browse the repository at this point in the history
Fixes #1569
  • Loading branch information
chingor13 authored Aug 11, 2022
1 parent d4b67f3 commit 8a7bfc1
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/manifest-releaser.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ minimal content required defines at least one package:
}
}
```
The following example shows all the possibilities. Note: for illustration
purposes the top level values set here are **NOT** the defaults (those are
documented in comments)
The following example shows most of the available options. See the documented
[JSON schema](/schemas/config.json) for the complete configuration definition.
Note: for illustration purposes the top level values set here are **NOT** the
defaults (those are documented in comments)
```js
{
// if this is the first time running `manifest-pr` on a repo
Expand Down
5 changes: 5 additions & 0 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"description": "Feature changes only bump semver patch if version < 1.0.0",
"type": "boolean"
},
"versioning": {
"description": "Versioning strategy. Defaults to `default`",
"type": "string"
},
"changelog-sections": {
"description": "Override the Changelog configuration sections",
"type": "array",
Expand Down Expand Up @@ -305,6 +309,7 @@
"release-type": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"versioning": true,
"changelog-sections": true,
"release-as": true,
"skip-github-release": true,
Expand Down
3 changes: 3 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ export interface CandidateRelease extends Release {

interface ReleaserConfigJson {
'release-type'?: ReleaseType;
versioning?: VersioningStrategyType;
'bump-minor-pre-major'?: boolean;
'bump-patch-for-minor-pre-major'?: boolean;
'changelog-sections'?: ChangelogSection[];
Expand Down Expand Up @@ -1161,6 +1162,7 @@ function extractReleaserConfig(
releaseType: config['release-type'],
bumpMinorPreMajor: config['bump-minor-pre-major'],
bumpPatchForMinorPreMajor: config['bump-patch-for-minor-pre-major'],
versioning: config['versioning'],
changelogSections: config['changelog-sections'],
changelogPath: config['changelog-path'],
changelogHost: config['changelog-host'],
Expand Down Expand Up @@ -1478,6 +1480,7 @@ function mergeReleaserConfig(
bumpPatchForMinorPreMajor:
pathConfig.bumpPatchForMinorPreMajor ??
defaultConfig.bumpPatchForMinorPreMajor,
versioning: pathConfig.versioning ?? defaultConfig.versioning,
changelogSections:
pathConfig.changelogSections ?? defaultConfig.changelogSections,
changelogPath: pathConfig.changelogPath ?? defaultConfig.changelogPath,
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/manifest/config/versioning.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"release-type": "simple",
"versioning": "always-bump-patch",
"packages": {
".": {
"component": "root"
},
"packages/bot-config-utils": {
"component": "bot-config-utils",
"versioning": "default"
}
}
}
32 changes: 32 additions & 0 deletions test/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,38 @@ describe('Manifest', () => {
).to.eql('default');
});

it('should read versioning type from manifest', async () => {
const getFileContentsStub = sandbox.stub(
github,
'getFileContentsOnBranch'
);
getFileContentsStub
.withArgs('release-please-config.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/config/versioning.json'
)
)
.withArgs('.release-please-manifest.json', 'main')
.resolves(
buildGitHubFileContent(
fixturesPath,
'manifest/versions/versions.json'
)
);
const manifest = await Manifest.fromManifest(
github,
github.repository.defaultBranch
);
expect(manifest.repositoryConfig['.'].versioning).to.eql(
'always-bump-patch'
);
expect(
manifest.repositoryConfig['packages/bot-config-utils'].versioning
).to.eql('default');
});

it('should throw a configuration error for a missing manifest config', async () => {
const getFileContentsStub = sandbox.stub(
github,
Expand Down

0 comments on commit 8a7bfc1

Please sign in to comment.