1 | const path = require('path');
|
2 | const { EOL } = require('os');
|
3 | const detectRepoChangelog = require('detect-repo-changelog');
|
4 |
|
5 | const conventionalIncrement = async ({ increment }) => {
|
6 | if (increment && increment.startsWith('conventional')) {
|
7 | const config = {
|
8 | plugins: {
|
9 | '@release-it/conventional-changelog': {
|
10 | preset: increment.split(':')[1]
|
11 | }
|
12 | }
|
13 | };
|
14 | const cwd = process.cwd();
|
15 | const changelogFile = await detectRepoChangelog(cwd);
|
16 | if (changelogFile) {
|
17 | config.plugins['@release-it/conventional-changelog'].infile = path.relative(cwd, changelogFile);
|
18 | }
|
19 | throw new Error(
|
20 | `The "${increment}" increment option is no longer valid since release-it v11. ` +
|
21 | 'Please `npm install -D @release-it/conventional-changelog` and configure the plugin:' +
|
22 | EOL +
|
23 | EOL +
|
24 | JSON.stringify(config, null, 2) +
|
25 | EOL +
|
26 | EOL +
|
27 | 'Please refer to https://github.com/release-it/release-it#conventional-changelog for more details.'
|
28 | );
|
29 | }
|
30 | };
|
31 |
|
32 | module.exports = async options => {
|
33 | await conventionalIncrement(options);
|
34 | };
|