Skip to content

Commit 0a9b49f

Browse files
committed
chore: support chore-only releases
1 parent b1276cb commit 0a9b49f

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

scripts/release.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const validTypes = [
2424
]
2525
const validPreIds = ['alpha', 'beta', 'rc']
2626

27+
const includeChoresFlag = '--chores'
2728
const isNextBranch = branch => /^next\/v\d+\.(\d+\.)?x$/.test(branch)
2829
const isSupportBranch = branch => /^v\d+\.x$/.test(branch)
2930

@@ -236,7 +237,7 @@ const formatList = (header, list) => {
236237
*
237238
* Output markdown at the beginning of the CHANGELOG.md file
238239
*/
239-
const generateChangelog = async (type, tagName) => {
240+
const generateChangelog = async (type, tagName, includeChores) => {
240241
const [day, month, year] = new Date().toUTCString().split(' ').slice(1, 4)
241242
const date = `${month} ${day.replace(/^0/, '')}, ${year}`
242243
const file = 'CHANGELOG.md'
@@ -274,8 +275,8 @@ const generateChangelog = async (type, tagName) => {
274275
features.push(item)
275276
} else if (/^fix[(!:]/.test(message)) {
276277
fixes.push(item)
277-
} else if (/^chore(\(.+?\))?!:/.test(message)) {
278-
// only include breaking chores
278+
} else if ((includeChores ? /^chore[(!:]/ : /^chore(\(.+?\))?!:/).test(message)) {
279+
// only include breaking chores if !includeChores
279280
item.message = `Chore: ${shortMessage}`
280281
chores.push(item)
281282
}
@@ -314,7 +315,7 @@ const generateChangelog = async (type, tagName) => {
314315

315316
if (!notes.trim() && !chores.length && !features.length && !fixes.length) {
316317
console.error(
317-
'\nNo fixes, features, or chores since last release and no notes given. Exiting.\n'
318+
`\nNo fixes, features, or chores since last release and no notes given. Maybe you meant to include the "${includeChoresFlag}" flag. Exiting.\n`
318319
)
319320
process.exit(1)
320321
}
@@ -632,7 +633,7 @@ const returnToBranch = async (branch, tagName) => {
632633
* If type is 'pre<major|minor|patch>', also pass a preId of 'alpha', 'beta', or
633634
* 'rc'
634635
*/
635-
const run = async (type, preId) => {
636+
const run = async ([type, preId], flags) => {
636637
assertValidArgs(type, preId)
637638

638639
const isPrerelease = type.startsWith('pre')
@@ -659,7 +660,7 @@ const run = async (type, preId) => {
659660

660661
// start modifying things
661662
const tagName = await incrementVersion(packages, type, preId)
662-
const changelogBody = await generateChangelog(type, tagName)
663+
const changelogBody = await generateChangelog(type, tagName, flags.includes(includeChoresFlag))
663664

664665
await commitChanges(tagName)
665666

@@ -674,4 +675,11 @@ const run = async (type, preId) => {
674675
logPackageLinks(packages)
675676
}
676677

677-
run(...process.argv.slice(2))
678+
const { args, flags } = process.argv.slice(2).reduce((buckets, argOrFlag) => {
679+
const bucket = argOrFlag.startsWith('-') ? buckets.flags : buckets.args
680+
bucket.push(argOrFlag)
681+
682+
return buckets
683+
}, { args: [], flags: [] })
684+
685+
run(args, flags)

0 commit comments

Comments
 (0)