Skip to content

Commit

Permalink
feat(plugin-release): support configuring commit types that count as …
Browse files Browse the repository at this point in the history
…code changes
  • Loading branch information
kherock committed Aug 14, 2021
1 parent b8c22fd commit 5d130e1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-release/sources/commands/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class ReleaseCommand extends BaseCommand {
if (requiresVersion && !this.firstRelease) {
const recommendedStrategy = await recommendedBump(workspace, {prerelease: this.prerelease !== false, preid});
if (!recommendedStrategy) {
report.reportWarning(MessageName.UNNAMED, `No commits since last release`);
report.reportWarning(MessageName.UNNAMED, `No code changes since last release`);
return;
}
const version = new SemVer(workspace.locator.reference);
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-release/sources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {releaseUtils};
declare module "@yarnpkg/core" {
interface ConfigurationValueMap {
releaseCalverFormat: string;
releaseCodeChangeTypes: Array<string>;
conventionalChangelogPreset: string;
}
}
Expand All @@ -20,6 +21,12 @@ const plugin: Plugin = {
type: SettingsType.STRING,
default: `YY.MM.micro`,
},
releaseCodeChangeTypes: {
description: `A list of commit types that correlate to code changes. Types outside of this set will not generate new releases.`,
isArray: true,
type: SettingsType.STRING,
default: [`feat`, `fix`, `perf`, `refactor`],
},
conventionalChangelogPreset: {
description: `A preset value to pass to conventional-changelog-preset-loader`,
type: SettingsType.STRING,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-release/sources/releaseUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function recommendedBump(workspace: Workspace, {prerelease, preid}:

const conventionalChangelogPreset = project.configuration.get(`conventionalChangelogPreset`);
const releaseCalverFormat = project.configuration.get(`releaseCalverFormat`);
const releaseCodeChangeTypes = new Set(project.configuration.get(`releaseCodeChangeTypes`));

const conventionalRecommendedBumpPromise = promisify<
conventionalRecommendedBump.Options,
Expand All @@ -77,8 +78,7 @@ export async function recommendedBump(workspace: Workspace, {prerelease, preid}:
skipUnstable: !prerelease,
lernaPackage: structUtils.stringifyIdent(workspace.locator),
whatBump: commits => {
const codeChanges = new Set([`feat`, `fix`, `perf`, `refactor`, `revert`]);
const shouldBump = commits.some(commit => codeChanges.has(commit.type!));
const shouldBump = commits.some(commit => releaseCodeChangeTypes.has(commit.type!));
return recommendedBumpOpts?.whatBump && shouldBump
? recommendedBumpOpts.whatBump(commits)
: {};
Expand Down

0 comments on commit 5d130e1

Please sign in to comment.