Skip to content

Commit

Permalink
feat: enable specifying changelog section headings in the CLI (#1162)
Browse files Browse the repository at this point in the history
Fixes #511
  • Loading branch information
chingor13 committed Dec 22, 2021
1 parent fc73b6d commit aaa8342
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions __snapshots__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ Options:
project? [string] [default: "CHANGELOG.md"]
--changelog-type type of changelog to build
[choices: "default", "github"]
--changelog-sections comma-separated list of scopes to include in
the changelog [string]
--last-package-version last version # that package was released as
[deprecated: use --latest-tag-version instead] [string]
--latest-tag-version Override the detected latest tag version
Expand Down
4 changes: 4 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Extra options:
| `--release-label` | `string` | Comma-separated list of labels to apply to the pull request after the release has been tagged. Defaults to `autorelease: tagged` |
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
| `--extra-files` | `string[]` | Extra file paths for the release strategy to consider |
| `--version-file` | `string` | Ruby only. Path to the `version.rb` file |
Expand Down Expand Up @@ -98,6 +99,9 @@ need to specify your release options:
| `--bump-patch-for-minor-pre-major` | boolean | Configuration option for the versioning strategy. If set, will bump the patch version for features for versions < 1.0.0 |
| `--draft-pull-request` | boolean | If set, create pull requests as drafts |
| `--label` | string | Comma-separated list of labels to apply to the release pull requests. Defaults to `autorelease: pending` |`autorelease: tagged` |
| `--changelog-path` | `string` | Override the path to the managed CHANGELOG. Defaults to `CHANGELOG.md` |
| `--changelog-type` | [`ChangelogType`](/docs/customizing.md#changelog-types) | Strategy for building the changelog contents. Defaults to `default` |
| `--changelog-sections` | `string` | Comma-separated list of commit scopes to show in changelog headings |
| `--monorepo-tags` | boolean | Add prefix to tags and branches, allowing multiple libraries to be released from the same repository |
| `--pull-request-title-pattern` | `string` | Override the pull request title pattern. Defaults to `chore${scope}: release${component} ${version}` |
| `--signoff` | string | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \<email@example.com\>") |
Expand Down
12 changes: 11 additions & 1 deletion src/bin/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {coerceOption} from '../util/coerce-option';
import * as yargs from 'yargs';
import {GitHub, GH_API_URL, GH_GRAPHQL_URL} from '../github';
import {Manifest, ManifestOptions, ROOT_PROJECT_PATH} from '../manifest';
import {ChangelogSection} from '../changelog-notes';
import {ChangelogSection, buildChangelogSections} from '../changelog-notes';
import {logger, setLogger, CheckpointLogger} from '../util/logger';
import {
getReleaserTypes,
Expand Down Expand Up @@ -281,6 +281,16 @@ function pullRequestStrategyOptions(yargs: yargs.Argv): yargs.Argv {
describe: 'type of changelog to build',
choices: getChangelogTypes(),
})
.option('changelog-sections', {
describe: 'comma-separated list of scopes to include in the changelog',
type: 'string',
coerce: (arg?: string) => {
if (arg) {
return buildChangelogSections(arg.split(','));
}
return arg;
},
})
.option('last-package-version', {
describe: 'last version # that package was released as',
type: 'string',
Expand Down
24 changes: 24 additions & 0 deletions src/changelog-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,27 @@ export interface ChangelogSection {
section: string;
hidden?: boolean;
}

const DEFAULT_HEADINGS: Record<string, string> = {
feat: 'Features',
fix: 'Bug Fixes',
perf: 'Performance Improvements',
deps: 'Dependencies',
revert: 'Reverts',
docs: 'Documentation',
style: 'Styles',
chore: 'Miscellaneous Chores',
refactor: 'Code Refactoring',
test: 'Tests',
build: 'Build System',
ci: 'Continuous Integration',
};

export function buildChangelogSections(scopes: string[]): ChangelogSection[] {
return scopes.map(scope => {
return {
type: scope,
section: DEFAULT_HEADINGS[scope] || scope,
};
});
}

0 comments on commit aaa8342

Please sign in to comment.