-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: cleanup presets interface (#1215)
BREAKING CHANGES: now preset object provides `commits`, `parser`, `writer` and `whatBump` properties.
- Loading branch information
Showing
66 changed files
with
308 additions
and
494 deletions.
There are no files selected for viewing
6 changes: 0 additions & 6 deletions
6
packages/conventional-changelog-angular/conventionalChangelog.js
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
packages/conventional-changelog-angular/conventionalRecommendedBump.js
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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { createParserOpts } from './parserOpts.js' | ||
import { createWriterOpts } from './writerOpts.js' | ||
import { createConventionalChangelogOpts } from './conventionalChangelog.js' | ||
import { createConventionalRecommendedBumpOpts } from './conventionalRecommendedBump.js' | ||
import { createParserOpts } from './parser.js' | ||
import { createWriterOpts } from './writer.js' | ||
import { whatBump } from './whatBump.js' | ||
|
||
export default async function createPreset () { | ||
const parserOpts = createParserOpts() | ||
const writerOpts = await createWriterOpts() | ||
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts) | ||
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts) | ||
|
||
return { | ||
parserOpts, | ||
writerOpts, | ||
recommendedBumpOpts, | ||
conventionalChangelog | ||
parser: createParserOpts(), | ||
writer: await createWriterOpts(), | ||
whatBump | ||
} | ||
} |
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
File renamed without changes.
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,24 @@ | ||
export function 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 === 'feat') { | ||
features += 1 | ||
if (level === 2) { | ||
level = 1 | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
level, | ||
reason: breakings === 1 | ||
? `There is ${breakings} BREAKING CHANGE and ${features} features` | ||
: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||
} | ||
} |
File renamed without changes.
6 changes: 0 additions & 6 deletions
6
packages/conventional-changelog-atom/conventionalChangelog.js
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
packages/conventional-changelog-atom/conventionalRecommendedBump.js
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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { createParserOpts } from './parserOpts.js' | ||
import { createWriterOpts } from './writerOpts.js' | ||
import { createConventionalChangelogOpts } from './conventionalChangelog.js' | ||
import { createConventionalRecommendedBumpOpts } from './conventionalRecommendedBump.js' | ||
import { createParserOpts } from './parser.js' | ||
import { createWriterOpts } from './writer.js' | ||
import { whatBump } from './whatBump.js' | ||
|
||
export default async function createPreset () { | ||
const parserOpts = createParserOpts() | ||
const writerOpts = await createWriterOpts() | ||
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts) | ||
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts) | ||
|
||
return { | ||
parserOpts, | ||
writerOpts, | ||
recommendedBumpOpts, | ||
conventionalChangelog | ||
parser: createParserOpts(), | ||
writer: await createWriterOpts(), | ||
whatBump | ||
} | ||
} |
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
File renamed without changes.
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,22 @@ | ||
export function 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 === 'feat') { | ||
features += 1 | ||
if (level === 2) { | ||
level = 1 | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
level, | ||
reason: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||
} | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/conventional-changelog-cli/test/fixtures/promise-config.cjs
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,5 +1,5 @@ | ||
module.exports = Promise.resolve({ | ||
writerOpts: { | ||
writer: { | ||
mainTemplate: '{{commitGroups.[0].commits.[0].type}}{{testContext}}template' | ||
} | ||
}) |
6 changes: 0 additions & 6 deletions
6
packages/conventional-changelog-codemirror/conventionalChangelog.js
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
packages/conventional-changelog-codemirror/conventionalRecommendedBump.js
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 |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import { createParserOpts } from './parserOpts.js' | ||
import { createWriterOpts } from './writerOpts.js' | ||
import { createConventionalChangelogOpts } from './conventionalChangelog.js' | ||
import { createConventionalRecommendedBumpOpts } from './conventionalRecommendedBump.js' | ||
import { createParserOpts } from './parser.js' | ||
import { createWriterOpts } from './writer.js' | ||
import { whatBump } from './whatBump.js' | ||
|
||
export default async function createPreset () { | ||
const parserOpts = createParserOpts() | ||
const writerOpts = await createWriterOpts() | ||
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(parserOpts) | ||
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts) | ||
|
||
return { | ||
parserOpts, | ||
writerOpts, | ||
recommendedBumpOpts, | ||
conventionalChangelog | ||
parser: createParserOpts(), | ||
writer: await createWriterOpts(), | ||
whatBump | ||
} | ||
} |
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
File renamed without changes.
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,22 @@ | ||
export function 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 === 'feat') { | ||
features += 1 | ||
if (level === 2) { | ||
level = 1 | ||
} | ||
} | ||
}) | ||
|
||
return { | ||
level, | ||
reason: `There are ${breakings} BREAKING CHANGES and ${features} features` | ||
} | ||
} |
File renamed without changes.
6 changes: 0 additions & 6 deletions
6
packages/conventional-changelog-conventionalcommits/conventionalChangelog.js
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
packages/conventional-changelog-conventionalcommits/conventionalRecommendedBump.js
This file was deleted.
Oops, something went wrong.
21 changes: 7 additions & 14 deletions
21
packages/conventional-changelog-conventionalcommits/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,25 +1,18 @@ | ||
import { DEFAULT_COMMIT_TYPES } from './constants.js' | ||
import { createParserOpts } from './parserOpts.js' | ||
import { createWriterOpts } from './writerOpts.js' | ||
import { createConventionalChangelogOpts } from './conventionalChangelog.js' | ||
import { createConventionalRecommendedBumpOpts } from './conventionalRecommendedBump.js' | ||
import { createParserOpts } from './parser.js' | ||
import { createWriterOpts } from './writer.js' | ||
import { createWhatBump } from './whatBump.js' | ||
|
||
export { DEFAULT_COMMIT_TYPES } | ||
|
||
export default async function createPreset (config) { | ||
const parserOpts = createParserOpts(config) | ||
const writerOpts = await createWriterOpts(config) | ||
const recommendedBumpOpts = createConventionalRecommendedBumpOpts(config, parserOpts) | ||
const conventionalChangelog = createConventionalChangelogOpts(parserOpts, writerOpts) | ||
|
||
return { | ||
gitRawCommitsOpts: { | ||
commits: { | ||
ignore: config?.ignoreCommits, | ||
noMerges: null | ||
}, | ||
parserOpts, | ||
writerOpts, | ||
recommendedBumpOpts, | ||
conventionalChangelog | ||
parser: createParserOpts(config), | ||
writer: await createWriterOpts(config), | ||
whatBump: createWhatBump(config) | ||
} | ||
} |
Oops, something went wrong.