From e9d7c52bdd70cac8d1c6a918c0475b613cf9817d Mon Sep 17 00:00:00 2001 From: ghiscoding Date: Fri, 29 Jul 2022 21:57:09 -0400 Subject: [PATCH] feat(version): use conventional commit changelog writer for perf --- packages/core/package.json | 4 + .../__tests__/conventional-commits.spec.ts | 10 +- .../get-changelog-config.ts | 20 +-- .../core/src/conventional-commits/index.ts | 1 + .../conventional-commits/update-changelog.ts | 115 +++--------------- .../writer-opts-transform.ts | 103 ++++++++++++++++ packages/core/src/models/interfaces.ts | 12 ++ packages/version/README.md | 22 ++-- pnpm-lock.yaml | 18 ++- 9 files changed, 178 insertions(+), 127 deletions(-) create mode 100644 packages/core/src/conventional-commits/writer-opts-transform.ts diff --git a/packages/core/package.json b/packages/core/package.json index f5f037fb..b6cf97f3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -40,6 +40,8 @@ "config-chain": "^1.1.13", "conventional-changelog-angular": "^5.0.13", "conventional-changelog-core": "^4.2.4", + "conventional-changelog-writer": "^5.0.1", + "conventional-commits-parser": "^3.2.4", "conventional-recommended-bump": "^6.1.0", "cosmiconfig": "^7.0.1", "dedent": "^0.7.0", @@ -89,6 +91,8 @@ "@types/async": "^3.2.15", "@types/clone-deep": "^4.0.1", "@types/conventional-changelog-core": "^4.2.1", + "@types/conventional-changelog-writer": "^4.0.1", + "@types/conventional-commits-parser": "^3.0.2", "@types/conventional-recommended-bump": "^6.1.0", "@types/dedent": "^0.7.0", "@types/execa": "^2.0.0", diff --git a/packages/core/src/conventional-commits/__tests__/conventional-commits.spec.ts b/packages/core/src/conventional-commits/__tests__/conventional-commits.spec.ts index 77d46fe0..0eb0c7c9 100644 --- a/packages/core/src/conventional-commits/__tests__/conventional-commits.spec.ts +++ b/packages/core/src/conventional-commits/__tests__/conventional-commits.spec.ts @@ -726,7 +726,7 @@ describe('conventional-commits', () => { const opts = { changelogPreset: 'conventional-changelog-angular', - changelogIncludeCommitsGitAuthor: ' by (**%a**)', + changelogIncludeCommitsGitAuthor: ' by **%a** (%e)', }; const [changelogOne, changelogTwo] = await Promise.all([ updateChangelog(pkg1, 'independent', opts), @@ -739,7 +739,7 @@ describe('conventional-commits', () => { ### Bug Fixes - * **stuff:** changed ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) by (**Tester McPerson**) + * **stuff:** changed ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) by **Tester McPerson** (test@example.com) `); expect(changelogTwo.newEntry.trimRight()).toMatchInlineSnapshot(` # [1.1.0](/compare/package-2@1.0.0...package-2@1.1.0) (YYYY-MM-DD) @@ -747,7 +747,7 @@ describe('conventional-commits', () => { ### Features - * **thing:** added ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) by (**Tester McPerson**) + * **thing:** added ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) by **Tester McPerson** (test@example.com) `); }); @@ -787,7 +787,7 @@ describe('conventional-commits', () => { }; const opt2s = { changelogPreset: 'conventional-changelog-angular', - changelogIncludeCommitsClientLogin: ' by (@%l, %a)', + changelogIncludeCommitsClientLogin: ' from @%l, _%a (%e)_', commitsSinceLastRelease: [ { authorName: 'Tester McPerson', @@ -817,7 +817,7 @@ describe('conventional-commits', () => { ### Features - * **thing:** added ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) by (@tester-mcperson, Tester McPerson) + * **thing:** added ([SHA](https://github.com/lerna/conventional-commits-independent/commit/GIT_HEAD)) from @tester-mcperson, _Tester McPerson (test@example.com)_ `); }); }); diff --git a/packages/core/src/conventional-commits/get-changelog-config.ts b/packages/core/src/conventional-commits/get-changelog-config.ts index f8c9cac4..77051c6f 100644 --- a/packages/core/src/conventional-commits/get-changelog-config.ts +++ b/packages/core/src/conventional-commits/get-changelog-config.ts @@ -2,16 +2,20 @@ import log from 'npmlog'; import pify from 'pify'; import npa from 'npm-package-arg'; +import { ChangelogConfig, ChangelogPresetConfig } from '../models'; import { ValidationError } from '../validation-error'; export class GetChangelogConfig { static cfgCache = new Map(); - static isFunction(config) { + static isFunction(config: ChangelogConfig) { return Object.prototype.toString.call(config) === '[object Function]'; } - static resolveConfigPromise(presetPackageName: string, presetConfig: any) { + static resolveConfigPromise( + presetPackageName: string, + presetConfig: ChangelogPresetConfig + ): Promise { log.verbose('getChangelogConfig', 'Attempting to resolve preset %j', presetPackageName); let config = require(presetPackageName); @@ -32,19 +36,17 @@ export class GetChangelogConfig { } /** - * @param {import('..').ChangelogPresetConfig} [changelogPreset] + * @param {ChangelogPresetConfig} [changelogPreset] * @param {string} [rootPath] */ static getChangelogConfig( - changelogPreset: string | { name: string } = 'conventional-changelog-angular', + changelogPreset: ChangelogPresetConfig = 'conventional-changelog-angular', rootPath?: string - ) { + ): Promise { const presetName = typeof changelogPreset === 'string' ? changelogPreset : changelogPreset.name; - const presetConfig = typeof changelogPreset === 'object' ? changelogPreset : {}; - + const presetConfig = typeof changelogPreset === 'object' ? changelogPreset : ({} as ChangelogPresetConfig); const cacheKey = `${presetName}${presetConfig ? JSON.stringify(presetConfig) : ''}`; - - let config = GetChangelogConfig.cfgCache.get(cacheKey); + let config = GetChangelogConfig.cfgCache.get(cacheKey) as Promise; if (!config) { let presetPackageName = presetName; diff --git a/packages/core/src/conventional-commits/index.ts b/packages/core/src/conventional-commits/index.ts index 16583204..d7ba604c 100644 --- a/packages/core/src/conventional-commits/index.ts +++ b/packages/core/src/conventional-commits/index.ts @@ -6,3 +6,4 @@ export * from './make-bump-only-filter'; export * from './read-existing-changelog'; export * from './recommend-version'; export * from './update-changelog'; +export * from './writer-opts-transform'; diff --git a/packages/core/src/conventional-commits/update-changelog.ts b/packages/core/src/conventional-commits/update-changelog.ts index cb313af0..92db7ade 100644 --- a/packages/core/src/conventional-commits/update-changelog.ts +++ b/packages/core/src/conventional-commits/update-changelog.ts @@ -1,4 +1,5 @@ -import conventionalChangelogCore from 'conventional-changelog-core'; +import conventionalChangelogCore, { Context } from 'conventional-changelog-core'; +import { Options as WriterOptions } from 'conventional-changelog-writer'; import fs from 'fs-extra'; import getStream from 'get-stream'; import log from 'npmlog'; @@ -7,8 +8,9 @@ import { BLANK_LINE, CHANGELOG_HEADER, EOL } from './constants'; import { GetChangelogConfig } from './get-changelog-config'; import { makeBumpOnlyFilter } from './make-bump-only-filter'; import { readExistingChangelog } from './read-existing-changelog'; -import { ChangelogType, RemoteCommit, UpdateChangelogOption } from '../models'; +import { ChangelogConfig, ChangelogType, UpdateChangelogOption } from '../models'; import { Package } from '../package'; +import { setConfigChangelogCommitClientLogin, setConfigChangelogCommitGitAuthor } from './writer-opts-transform'; /** * Update changelog with the commits of the new release @@ -32,28 +34,28 @@ export async function updateChangelog(pkg: Package, type: ChangelogType, updateO } = updateOptions; const config = await GetChangelogConfig.getChangelogConfig(changelogPreset, rootPath); - const options: any = {}; - const context: any = {}; // pass as positional because cc-core's merge-config is wack + const options = {} as { config: ChangelogConfig; lernaPackage: string; tagPrefix: string; pkg: { path: string } }; + const context = {} as Context; // pass as positional because cc-core's merge-config is wack + const writerOpts = {} as WriterOptions; // cc-core mutates input :P if (config.conventionalChangelog) { // "new" preset API - options.config = Object.assign({}, config.conventionalChangelog); + options.config = Object.assign({}, config.conventionalChangelog) as ChangelogConfig; } else { // "old" preset API - options.config = Object.assign({}, config); + options.config = Object.assign({}, config) as ChangelogConfig; } // NOTE: must pass as positional argument due to weird bug in merge-config const gitRawCommitsOpts = Object.assign({}, options.config.gitRawCommitsOpts); - // when including commit author's name, we need to change the conventional commit format - // available formats can be found at Git's url: https://git-scm.com/docs/git-log#_pretty_formats - // we will later extract a defined token from the string, of ">>author=%an<<", - // and reformat the string to get a commit string that would add (@authorName) to the end of the commit string, ie: - // **deps:** update all non-major dependencies ([ed1db35](https://github.com/.../ed1db35)) (@Renovate-Bot) + // are we including commit author name/email or commit client login name if (changelogIncludeCommitsGitAuthor) { - gitRawCommitsOpts.format = '%B%n-hash-%n%H>>author=%an<<'; + setConfigChangelogCommitGitAuthor(config, gitRawCommitsOpts, writerOpts, changelogIncludeCommitsGitAuthor); + } else if (changelogIncludeCommitsClientLogin && commitsSinceLastRelease) { + // prettier-ignore + setConfigChangelogCommitClientLogin(config, gitRawCommitsOpts, writerOpts, commitsSinceLastRelease, changelogIncludeCommitsClientLogin); } if (type === 'root') { @@ -82,7 +84,7 @@ export async function updateChangelog(pkg: Package, type: ChangelogType, updateO } // generate the markdown for the upcoming release. - const changelogStream = conventionalChangelogCore(options, context, gitRawCommitsOpts); + const changelogStream = conventionalChangelogCore(options, context, gitRawCommitsOpts, undefined, writerOpts); return Promise.all([ // prettier-ignore @@ -91,17 +93,6 @@ export async function updateChangelog(pkg: Package, type: ChangelogType, updateO ]).then(([inputEntry, [changelogFileLoc, changelogContents]]) => { let newEntry = inputEntry; - // include commit author name or commit client login name - if (changelogIncludeCommitsGitAuthor) { - newEntry = parseChangelogCommitAuthorFullName(inputEntry, changelogIncludeCommitsGitAuthor); - } else if (changelogIncludeCommitsClientLogin && commitsSinceLastRelease) { - newEntry = parseChangelogCommitClientLogin( - inputEntry, - commitsSinceLastRelease, - changelogIncludeCommitsClientLogin - ); - } - log.silly(type, 'writing new entry: %j', newEntry); const changelogVersion = type === 'root' ? changelogVersionMessage : ''; @@ -125,79 +116,3 @@ export async function updateChangelog(pkg: Package, type: ChangelogType, updateO }); }); } - -/** - * From an input entry string that most often, not always, include commit author's name within defined tokens ">>author=AUTHOR_NAME<<" - * We will want to extract the author's name from the commit url and recreate the commit url string and add its author to the end of the string. - * You might be wondering, WHY is the commit author part of the commit url? - * Mainly because it seems that adding a `format` to the `conventional-changelog-core` of `gitRawCommitsOpts` - * will always include it as part of the final commit url because of this line where it parses the template and always seems to include whatever we add into the commit url - * https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/git-raw-commits/index.js#L27 - * - * We will transform a string that looks like this: - * "deps: update all non-major dependencies ([ed1db35](https://github.com/.../ed1db35>>author=Whitesource Renovate<<))" - * then extract the commit author's name and transform it into a new string that will look like below - * "deps: update all non-major dependencies ([ed1db35](https://github.com/.../ed1db35)) (Whitesource Whitesource)" - * @param {String} changelogEntry - changelog entry of a version being released which can contain multiple line entries - * @param {String | Boolean} [commitCustomFormat] - * @returns - */ -function parseChangelogCommitAuthorFullName(changelogEntry: string, commitCustomFormat?: string | boolean) { - // to transform the string into what we want, we need to move the substring outside of the url and remove extra search tokens - // from this: - // "...ed1db35>>author=Whitesource Renovate<<))" - // into this: - // "...ed1db35)) (Whitesource Renovate)" - // or as a custom message like this " by **%a**" into this: - // "...ed1db35)) by **Whitesource Renovate**" - return changelogEntry.replace( - /(.*)(>>author=)(.*)(<<)(.*)/g, - (_: string, lineStart: string, _tokenStart?: string, authorName?: string, _tokenEnd?: string, lineEnd?: string) => { - // rebuild the commit line entry string - const commitMsg = `${lineStart}${lineEnd || ''}`; - const authorMsg = - typeof commitCustomFormat === 'string' - ? commitCustomFormat.replace(/%a/g, authorName || '') - : ` (${authorName})`; - return commitMsg + authorMsg; - } - ); -} - -/** - * For each commit line entry, we will append the remote client login username for the first commit entry found, for example: - * "commit message ([ed1db35](https://github.com/.../ed1db35)) (@renovate-bot)" - * @param {String} changelogEntry - changelog entry of a version being released which can contain multiple line entries - * @param {Array} commitsSinceLastRelease - * @param {String | Boolean} [commitCustomFormat] - * @returns - */ -function parseChangelogCommitClientLogin( - changelogEntry: string, - commitsSinceLastRelease: RemoteCommit[], - commitCustomFormat?: string | boolean -) { - const entriesOutput: string[] = []; - - for (const lineEntry of changelogEntry.split('\n')) { - let lineEntryOutput = lineEntry; - const [_, __, shortSha] = lineEntry.match(/(\[([0-9a-f]{7})\])/) || []; // pull first commit match only - - if (shortSha) { - const remoteCommit = commitsSinceLastRelease.find((c) => c.shortHash === shortSha); - if (remoteCommit) { - const clientLogin = - typeof commitCustomFormat === 'string' - ? commitCustomFormat.replace(/%l/g, remoteCommit.login || '').replace(/%a/g, remoteCommit.authorName || '') - : ` (@${remoteCommit.login})`; - - // when we have a match, we need to remove any line breaks at the line ending only, - // then add our user info and finally add back a single line break - lineEntryOutput = lineEntry.replace(/\n*$/, '') + clientLogin; - } - } - entriesOutput.push(lineEntryOutput); - } - - return entriesOutput.join('\n'); -} diff --git a/packages/core/src/conventional-commits/writer-opts-transform.ts b/packages/core/src/conventional-commits/writer-opts-transform.ts new file mode 100644 index 00000000..d004ab88 --- /dev/null +++ b/packages/core/src/conventional-commits/writer-opts-transform.ts @@ -0,0 +1,103 @@ +import { Context, GitRawCommitsOptions } from 'conventional-changelog-core'; +import { Options as WriterOptions } from 'conventional-changelog-writer'; +import { Commit } from 'conventional-commits-parser'; +import { ChangelogConfig, RemoteCommit } from '../models'; + +const GIT_COMMIT_WITH_AUTHOR_FORMAT = + '%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n-authorName-%n%an%n-authorEmail-%n%ae%n-gpgStatus-%n%G?%n-gpgSigner-%n%GS'; + +/** + * Change the changelog config, we need to update the default format to include commit author name/email, + * available formats can be found at Git's url: https://git-scm.com/docs/git-log#_pretty_formats + * Add a `format` to the `conventional-changelog-core` of `gitRawCommitsOpts` will make it available in the commit template + * https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/git-raw-commits/index.js#L27 + * then no matter which changelog preset is loaded, we'll append the git author name to the commit template + * ie:: **deps:** update all non-major dependencies ([ed1db35](https://github.com/.../ed1db35)) (Renovate Bot) + * @param {ChangelogConfig} config + * @param {GitRawCommitsOptions} gitRawCommitsOpts + * @param {WriterOptions} writerOpts + * @param {string | boolean} [commitCustomFormat] + */ +export function setConfigChangelogCommitGitAuthor( + config: ChangelogConfig, + gitRawCommitsOpts: GitRawCommitsOptions, + writerOpts: WriterOptions, + commitCustomFormat?: string | boolean +) { + gitRawCommitsOpts.format = GIT_COMMIT_WITH_AUTHOR_FORMAT; + const extraCommitMsg = + typeof commitCustomFormat === 'string' + ? commitCustomFormat.replace(/%a/g, '{{authorName}}' || '').replace(/%e/g, '{{authorEmail}}' || '') + : `({{authorName}})`; + writerOpts.commitPartial = + config.writerOpts.commitPartial!.replace(/\n*$/, '') + ` {{#if @root.linkReferences~}}${extraCommitMsg}{{~/if}}\n`; +} + +/** + * Change the changelog config, we need to update the default format to include commit author name/email, + * available formats can be found at Git's url: https://git-scm.com/docs/git-log#_pretty_formats + * We also need to change the transform function and add remote client login (GitHub) + * Add a `format` to the `conventional-changelog-core` of `gitRawCommitsOpts` will make it available in the commit template + * https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/git-raw-commits/index.js#L27 + * then no matter which changelog preset is loaded, we'll append the git author name to the commit template + * ie:: **deps:** update all non-major dependencies ([ed1db35](https://github.com/.../ed1db35)) (@renovate-bot) + * @param {ChangelogConfig} config + * @param {GitRawCommitsOptions} gitRawCommitsOpts + * @param {WriterOptions} writerOpts + * @param {RemoteCommit[]} commitsSinceLastRelease + * @param {string | boolean} [commitCustomFormat] + */ +export function setConfigChangelogCommitClientLogin( + config: ChangelogConfig, + gitRawCommitsOpts: GitRawCommitsOptions, + writerOpts: WriterOptions, + commitsSinceLastRelease: RemoteCommit[], + commitCustomFormat?: string | boolean +) { + gitRawCommitsOpts.format = GIT_COMMIT_WITH_AUTHOR_FORMAT; + const extraCommitMsg = + typeof commitCustomFormat === 'string' + ? commitCustomFormat + .replace(/%a/g, '{{authorName}}' || '') + .replace(/%e/g, '{{authorEmail}}' || '') + .replace(/%l/g, '{{userLogin}}' || '') + : `(@{{userLogin}})`; + writerOpts.commitPartial = + config.writerOpts.commitPartial!.replace(/\n*$/, '') + ` {{#if @root.linkReferences~}}${extraCommitMsg}{{~/if}}\n`; + + // add commits since last release inte the transform function + writerOpts.transform = writerOptsTransform.bind( + null, + config.writerOpts.transform as (cmt: Commit, ctx: Context) => Commit, + commitsSinceLastRelease + ); +} + +/** + * Extend the writerOpts transform function from whichever preset config is loaded + * We will execute the original writerOpts transform function, then from it we'll add extra properties to the commit object + * @param {Transform} originalTransform + * @param {RemoteCommit[]} commitsSinceLastRelease + * @param {Commit} commit + * @param {Context} context + * @returns + */ +export function writerOptsTransform( + originalTransform: (cmt: Commit, ctx: Context) => Commit, + commitsSinceLastRelease: RemoteCommit[], + commit: Commit, + context: Context +) { + // execute original writerOpts transform + const extendedCommit = originalTransform(commit, context); + + // add client remote detail (login) + if (extendedCommit) { + const remoteCommit = commitsSinceLastRelease.find((c) => c.shortHash === commit.shortHash); + if (remoteCommit?.login) { + commit.userLogin = remoteCommit.login; + } + } + + return extendedCommit; +} diff --git a/packages/core/src/models/interfaces.ts b/packages/core/src/models/interfaces.ts index 6e3cd7cb..7d8a0b47 100644 --- a/packages/core/src/models/interfaces.ts +++ b/packages/core/src/models/interfaces.ts @@ -1,3 +1,6 @@ +import { GitRawCommitsOptions, ParserOptions } from 'conventional-changelog-core'; +import { Options as WriterOptions } from 'conventional-changelog-writer'; +import { Options as RecommendedBumpOptions } from 'conventional-recommended-bump'; import log from 'npmlog'; import npa from 'npm-package-arg'; @@ -14,6 +17,15 @@ export interface BaseChangelogOptions { tagPrefix?: string; } +export interface ChangelogConfig { + conventionalChangelog: { parserOpts: ParserOptions; writerOpts: WriterOptions }; + gitRawCommitsOpts: GitRawCommitsOptions & { path: string }; + key?: string; + parserOpts: ParserOptions; + recommendedBumpOpts: RecommendedBumpOptions; + writerOpts: WriterOptions; +} + export interface CommandOptions { rollPublish?: boolean; rollVersion?: boolean; diff --git a/packages/version/README.md b/packages/version/README.md index 37408290..36ef07d8 100644 --- a/packages/version/README.md +++ b/packages/version/README.md @@ -233,7 +233,9 @@ lerna version --conventional-commits --conventional-prerelease When run with this flag, `lerna version` will release with prerelease versions the specified packages (comma-separated) or all packages using `*`. Releases all unreleased changes as pre(patch/minor/major/release) by prefixing the version recommendation from `conventional-commits` with `pre`, eg. if present changes include a feature commit, the recommended bump will be `minor`, so this flag will result in a `preminor` release. If changes are present for packages that are not specified (if specifying packages), or for packages that are already in prerelease, those packages will be versioned as they normally would using `--conventional-commits`. ### `--changelog-include-commits-git-author [msg]` -Specify if we want to include the git commit author's name, appended to the end of each changelog commit entry, this is only available when using `--conventional-commits` with changelogs enabled. The default format will be appending the git commit author name at the end of each commit entry wrapped in `()`, we could also use a custom format by providing the `%a` token, see examples below. +Specify if we want to include the git commit author's name, appended to the end of each changelog commit entry, this is only available when using `--conventional-commits` with changelogs enabled. The default format will be appending the git commit author name at the end of each commit entry wrapped in `()`, we could also use a custom format by providing any of these tokens (`%a`, `%e`), see examples below. +- `%a`: git author name (ie: "Whitesource Renovate") +- `%e`: git author email (ie: "bot@renovateapp.com") > **Note** the author name is the name that configured in user's git, for more info please refer to [Git Configuration](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration). Also note, that is **not** the same as for example a GitHub login username, Git does not store such information in its commit history. If you really want the login, then use the next option shown below. @@ -243,13 +245,19 @@ Specify if we want to include the git commit author's name, appended to the end lerna version --conventional-commits --changelog-include-commits-git-author # **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) (Whitesource Renovate) -# custom format with %a token +## custom format with 1 of these 2 tokens: %a and/or %e ## lerna version --conventional-commits --changelog-include-commits-git-author " (by _%a_)" # **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) (by _Whitesource Renovate_) + +lerna version --conventional-commits --changelog-include-commits-client-login " by %a (%e)" --remote-client github +# **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) by Renovate Bot (bot@renovateapp.com) ``` ### `--changelog-include-commits-client-login [msg]` -Specify if we want to include commit remote client login (ie GitHub login username), appended to the end of each changelog commit entry, this is only available when using `--conventional-commits` with changelogs enabled. You most also provide 1 of these 2 options [`--create-release `](#--create-release-type) or [`--remote-client `](#--remote-client-type). The default format will be appending the remote client login username at the end of each changelog commit entry wrapped in `()`, we could also use a custom format by providing the `%a` and/or `%l` token(s), see examples below. +Specify if we want to include commit remote client login (ie GitHub login username), appended to the end of each changelog commit entry, this is only available when using `--conventional-commits` with changelogs enabled. You most also provide 1 of these 2 options [`--create-release `](#--create-release-type) or [`--remote-client `](#--remote-client-type). The default format will be appending the remote client login username at the end of each changelog commit entry wrapped in `()`, we could also use a custom format by providing any of these tokens (`%l`, `%a`, `%e`), see examples below. +- `%a`: git author name (ie: "Whitesource Renovate") +- `%e`: git author email (ie: "bot@renovateapp.com") +- `%l`: remote client login (ie: "@renovate-bot") > **Note** this will execute one or more remote API calls to the chosen remote server, which at the moment is only supporting the GitHub client type. This option will also require a valid `GH_TOKEN` with read access permissions to the GitHub API so that it can execute the query to fetch all commit details since the last release, for more info refer to the [`Remote Client Auth Tokens`](#--remote-client-auth-tokens) below. @@ -261,14 +269,12 @@ Specify if we want to include commit remote client login (ie GitHub login userna lerna version --conventional-commits --changelog-include-commits-client-login --create-release github # **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) (@renovate-bot) -# custom format with 1 of these 2 tokens: %l and/or %a -# %l: login name (ie: "renovate-bot"), or %a: git author name (ie: "Whitesource Renovate") - +## custom format with 1 of these 3 tokens: %l, %a and/or %e ## lerna version --conventional-commits --changelog-include-commits-client-login " by @%l" --remote-client github # **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) by @renovate-bot -lerna version --conventional-commits --changelog-include-commits-client-login " by @%l, %a" --remote-client github -# **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) by @renovate-bot, Whitesource Renovate +lerna version --conventional-commits --changelog-include-commits-client-login " by @%l, %a (%e)" --remote-client github +# **deps:** update dependency git-url-parse to v12 ([978bf36](https://github.com/.../978bf36)) by @renovate-bot, Renovate Bot (bot@renovateapp.com) ``` > We recommend you first try it with the `--git-dry-run` option so that you can validate your remote client access and inspect the changelog output. Make sure to revert your changes once you're satisfied with the output. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3b20e6a3..a503dcc9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -154,6 +154,8 @@ importers: '@types/async': ^3.2.15 '@types/clone-deep': ^4.0.1 '@types/conventional-changelog-core': ^4.2.1 + '@types/conventional-changelog-writer': ^4.0.1 + '@types/conventional-commits-parser': ^3.0.2 '@types/conventional-recommended-bump': ^6.1.0 '@types/dedent': ^0.7.0 '@types/execa': ^2.0.0 @@ -176,6 +178,8 @@ importers: config-chain: ^1.1.13 conventional-changelog-angular: ^5.0.13 conventional-changelog-core: ^4.2.4 + conventional-changelog-writer: ^5.0.1 + conventional-commits-parser: ^3.2.4 conventional-recommended-bump: ^6.1.0 cosmiconfig: ^7.0.1 dedent: ^0.7.0 @@ -231,6 +235,8 @@ importers: config-chain: 1.1.13 conventional-changelog-angular: 5.0.13 conventional-changelog-core: 4.2.4 + conventional-changelog-writer: 5.0.1 + conventional-commits-parser: 3.2.4 conventional-recommended-bump: 6.1.0 cosmiconfig: 7.0.1 dedent: 0.7.0 @@ -279,6 +285,8 @@ importers: '@types/async': 3.2.15 '@types/clone-deep': 4.0.1 '@types/conventional-changelog-core': 4.2.1 + '@types/conventional-changelog-writer': 4.0.1 + '@types/conventional-commits-parser': 3.0.2 '@types/conventional-recommended-bump': 6.1.0 '@types/dedent': 0.7.0 '@types/execa': 2.0.0 @@ -1558,13 +1566,13 @@ packages: resolution: {integrity: sha512-S7lJJByPMkkocMWnDKOtkSLi9yXu619+GhGejPnCiNK1Dgwjf5jjzBxXYgMv47tBG8MokmCCV1sWhI53lFl6FA==} dependencies: '@types/conventional-commits-parser': 3.0.2 - '@types/node': 17.0.41 + '@types/node': 18.0.0 dev: true /@types/conventional-commits-parser/3.0.2: resolution: {integrity: sha512-1kVPUHFaart1iGRFxKn8WNXYEDVAgMb+DLatgql2dGg9jTGf3bNxWtN//C/tDG3ckOLg4u7SSx+qcn8VjzI5zg==} dependencies: - '@types/node': 17.0.41 + '@types/node': 18.0.0 dev: true /@types/conventional-recommended-bump/6.1.0: @@ -1599,7 +1607,7 @@ packages: /@types/git-raw-commits/2.0.1: resolution: {integrity: sha512-vE2lbXxqJ0AqMDoP4N6d+WVfbcBla9+z8IL6e+37JNQIwYZCYY0z3J7hdpY8D/VGwFZ0yIYQLcqk8eCnfXsaEg==} dependencies: - '@types/node': 17.0.41 + '@types/node': 18.0.0 dev: true /@types/git-url-parse/9.0.1: @@ -1723,7 +1731,7 @@ packages: /@types/through/0.0.30: resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==} dependencies: - '@types/node': 17.0.41 + '@types/node': 18.0.0 dev: true /@types/write-file-atomic/4.0.0: @@ -6693,7 +6701,7 @@ packages: dev: true /wordwrap/1.0.0: - resolution: {integrity: sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=} + resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} dev: false /wrap-ansi/7.0.0: