-
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.
BREAKING CHANGES(conventional-changelog): All preset exports factory …
…functions * @see: conventional-changelog/conventional-changelog#1045
- Loading branch information
Showing
11 changed files
with
206 additions
and
181 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
packages/conventional-changelog-lmc-bitbucket/src/conventionalChangelog.js
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,25 @@ | ||
/* eslint-disable no-param-reassign */ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
const { readFile } = require('fs').promises; | ||
const { resolve } = require('path'); | ||
|
||
async function createConventionalChangelogOpts (parserOpts, writerOpts) { | ||
return Promise.all([ | ||
readFile(resolve(__dirname, 'templates/template.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/header.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/commit.hbs'), 'utf-8'), | ||
readFile(resolve(__dirname, 'templates/footer.hbs'), 'utf-8'), | ||
]).then(([template, header, commit, footer]) => { | ||
writerOpts.mainTemplate = template; | ||
writerOpts.headerPartial = header; | ||
writerOpts.commitPartial = commit; | ||
writerOpts.footerPartial = footer; | ||
|
||
return { | ||
parserOpts, | ||
writerOpts, | ||
}; | ||
}); | ||
} | ||
|
||
module.exports.createConventionalChangelogOpts = createConventionalChangelogOpts; |
27 changes: 16 additions & 11 deletions
27
packages/conventional-changelog-lmc-bitbucket/src/index.js
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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
const conventionalChangelog = require(`./conventional-changelog`); | ||
const { parserOpts, writerOpts, recommendedBumpOpts } = require('@lmc-eu/conventional-changelog-lmc'); | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
const { createConventionalChangelogOpts } = require(`./conventionalChangelog`); | ||
const { createParserOpts, createWriterOpts, createConventionalRecommendedBumpOpts } = require('@lmc-eu/conventional-changelog-lmc'); | ||
|
||
module.exports = Promise.all([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]).then( | ||
// Using same configuration as other configurations | ||
// Did not find any documentation whether the output must be in this format | ||
// eslint-disable-next-line no-shadow | ||
([conventionalChangelog, parserOpts, recommendedBumpOpts, writerOpts]) => ({ | ||
conventionalChangelog, | ||
async function createPreset () { | ||
const parserOpts = createParserOpts() | ||
const writerOpts = createWriterOpts() | ||
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts) | ||
const conventionalChangelog = await createConventionalChangelogOpts(parserOpts, writerOpts) | ||
|
||
return { | ||
parserOpts, | ||
recommendedBumpOpts, | ||
writerOpts, | ||
}), | ||
); | ||
recommendedBumpOpts, | ||
conventionalChangelog | ||
} | ||
} | ||
|
||
module.exports = createPreset; |
20 changes: 0 additions & 20 deletions
20
packages/conventional-changelog-lmc-github/src/conventional-changelog.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
packages/conventional-changelog-lmc/src/conventionalRecommendedBump.js
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,38 @@ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
|
||
function createConventionalRecommendedBumpOpts (parserOpts) { | ||
return { | ||
parserOpts, | ||
|
||
whatBump: (commits) => { | ||
let level = 2; | ||
let breakings = 0; | ||
let features = 0; | ||
|
||
commits.forEach((commit) => { | ||
if (commit.notes.length > 0) { | ||
breakings += commit.notes.length; | ||
level = 0; | ||
} else if (commit.type === 'BREAKING CHANGE' || commit.type === 'BREAKING CHANGES') { | ||
breakings += 1; | ||
level = 0; | ||
} else if (commit.type === `Feat`) { | ||
features += 1; | ||
if (level === 2) { | ||
level = 1; | ||
} | ||
} | ||
}); | ||
|
||
return { | ||
level, | ||
reason: | ||
breakings === 1 | ||
? `There are ${breakings} BREAKING CHANGE and ${features} features` | ||
: `There are ${breakings} BREAKING CHANGES and ${features} features`, | ||
}; | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports.createConventionalRecommendedBumpOpts = createConventionalRecommendedBumpOpts; |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
const parserOpts = require('./parser-opts'); | ||
const writerOpts = require('./writer-opts'); | ||
const recommendedBumpOpts = require('./bump-opts'); | ||
const { createParserOpts } = require('./parserOpts'); | ||
const { createWriterOpts } = require('./writerOpts'); | ||
const { createConventionalRecommendedBumpOpts } = require('./conventionalRecommendedBump'); | ||
|
||
module.exports = { | ||
parserOpts, | ||
recommendedBumpOpts, | ||
writerOpts, | ||
createParserOpts, | ||
createWriterOpts, | ||
createConventionalRecommendedBumpOpts, | ||
}; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-disable jsdoc/require-jsdoc */ | ||
|
||
function createParserOpts () { | ||
return { | ||
headerPattern: /^(?:Pull request #[0-9]+: )?(?:([a-zA-Z]*-[0-9_]*)(?: ))* ?([\w ]*)(?:\((.*)\))?!?: (.*)$/, | ||
breakingHeaderPattern: /^(?:([a-zA-Z]*-[0-9_]*)(?: ))* ?([\w ]*)(?:\((.*)\))?!: (.*)$/, | ||
headerCorrespondence: ['body', 'type', 'scope', 'subject'], | ||
noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES'], | ||
revertPattern: /^(?:Revert:)\s"?([\s\S]+?)"?\s*This reverts commit (\w*)\./i, | ||
revertCorrespondence: ['header', 'hash'], | ||
}; | ||
}; | ||
|
||
module.exports.createParserOpts = createParserOpts; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.