Skip to content

Commit

Permalink
chore(release): override angular issue prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
khanhduy1407 committed Dec 3, 2023
1 parent cabfca3 commit df06921
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
34 changes: 34 additions & 0 deletions scripts/utils/conventional-changelog-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Options for [conventional-changelog](https://github.com/conventional-changelog/conventional-changelog), which is
* used to generate the Rindo changelog at release time.
*/
module.exports = {
parserOpts: {
/**
* Override the conventional-changelog parser default configuration and any provided preset (e.g. 'Angular') for
* detecting issues. Rindo uses the "Angular preset", which defaults the "issuesPrefixes" field to a single pound
* sign ('#'). This sometimes gets mistaken by the changelog generator as an issue that is fixed, when it fact it's
* cross-reference to another issue.
*
* Note: Only the git commit message is being parsed, not the GitHub Issue summary. For any of the values below to
* be picked up by conventional-changelog, they must be added to the git commit message.
*
* Reference for this property: [GitHub README]{@link https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#issueprefixes}
* By default, [these are case-insensitive]{@link https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#issueprefixescasesensitive)}
*/
issuePrefixes: [
'fixes: #',
'fixes:#',
'fixes- #',
'fixes-#',
'fixes #',
'fixes#',
'closes: #',
'closes:#',
'closes- #',
'closes-#',
'closes #',
'closes#',
],
},
};
29 changes: 26 additions & 3 deletions scripts/utils/release-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import color from 'ansi-colors';
import fs from 'fs-extra';
import { join } from 'path';
import semver from 'semver';

import { BuildOptions } from './options';
Expand Down Expand Up @@ -89,13 +90,35 @@ export function prettyVersionDiff(oldVersion: string, inc: any): string {
}

/**
* Write CHANGELOG.md to disk. Rindo uses the Angular-variant of conventional commits; commits must be formatted
* accordingly in order to be added to the changelog properly.
* Write changes to the local CHANGELOG.md on disk.
*
* Rindo uses the Angular-variant of conventional commits; commits must be formatted accordingly in order to be added
* to the changelog properly.
* @param opts build options to be used to update the changelog
*/
export async function updateChangeLog(opts: BuildOptions): Promise<void> {
const ccPath = join(opts.nodeModulesDir, '.bin', 'conventional-changelog');
const { execa } = await import('execa');
await execa('npm', ['run', 'changelog'], { cwd: opts.rootDir });
const ccConfigPath = join(opts.scriptsBuildDir, 'utils', 'conventional-changelog-config.js');
// await execa('npm', ['run', 'changelog'], { cwd: opts.rootDir });
// API Docs for conventional-changelog: https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core#api
await execa(
'node',
[
ccPath,
'--preset',
'angular',
'--infile',
opts.changelogPath,
'--outfile',
'--same-file',
'--config',
ccConfigPath,
],
{
cwd: opts.rootDir,
},
);

let changelog = await fs.readFile(opts.changelogPath, 'utf8');
changelog = changelog.replace(/\# \[/, '# ' + opts.vermoji + ' [');
Expand Down

0 comments on commit df06921

Please sign in to comment.