-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pr): create a release script that outputs conventional changes f…
…or a range of commits/branches
- Loading branch information
1 parent
382d8bd
commit 1afd939
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env node | ||
'use strict' | ||
|
||
const conventionalChangelog = require('conventional-changelog') | ||
const resolve = require('path').resolve | ||
const _ = require('lodash') | ||
const meow = require('meow') | ||
|
||
const cli = meow(` | ||
Usage | ||
create-release-notes | ||
Example | ||
create-release-notes --from beta --to HEAD | ||
Options | ||
-g --group Group all messages under the same group. Needs to | ||
-f, --from Commit or branch to start from when processing the release notes | ||
-t, --to Commit or branch to end to when processing the release notes | ||
-n, --config A filepath of your config script | ||
Example of a config script: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-cli/test/fixtures/config.js | ||
`, { | ||
booleanDefault: undefined, | ||
flags: { | ||
config: { | ||
alias: 'n', | ||
type: 'string' | ||
}, | ||
group: { | ||
alias: 'g', | ||
type: 'boolean' | ||
}, | ||
from: { | ||
type: 'string' | ||
}, | ||
to: { | ||
type: 'string' | ||
}, | ||
} | ||
}) | ||
|
||
let config; | ||
const flags = cli.flags | ||
let options = {}; | ||
|
||
if (flags.group) { | ||
options.tagPrefix = 'null' // This allows us to igonre tags when generating release notes, this way we get all the changes in a single grouped release block. | ||
} | ||
|
||
if (flags.config) { | ||
config = require(resolve(process.cwd(), flags.config)) | ||
} else { | ||
config = _.merge(config, { | ||
writerOpts: { | ||
headerPartial: '## Changes : ' | ||
}, | ||
options: { | ||
preset: { | ||
name: 'conventionalcommits' | ||
} | ||
} | ||
}) | ||
} | ||
|
||
options.config = config | ||
options = _.merge(options, config.options) | ||
|
||
const gitRawCommitsOpts = _.merge({}, config.gitRawCommitsOpts || {}) | ||
|
||
if (flags.from) { | ||
gitRawCommitsOpts.from = flags.from | ||
} | ||
|
||
if (flags.to) { | ||
gitRawCommitsOpts.to = flags.to | ||
} | ||
|
||
conventionalChangelog(options, {}, gitRawCommitsOpts, config.parserOpts, config.writerOpts) | ||
.pipe(process.stdout); // or any writable stream |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters