diff --git a/CHANGELOG.md b/CHANGELOG.md index e6abad72c..3d5b2677a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- `--display-name` flag to release command + ## [3.8.0-beta] - 2021-06-09 ### Removed diff --git a/docs/commands.md b/docs/commands.md index 8aa0cb234..d973e415c 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -774,6 +774,7 @@ OPTIONS -h, --help show CLI help -v, --verbose Show debug level logs --trace Ensure all requests to VTEX IO are traced + --display-name Add the project name to the tag and release commit EXAMPLES vtex release diff --git a/src/commands/release.ts b/src/commands/release.ts index 754e80abf..1201b45ef 100644 --- a/src/commands/release.ts +++ b/src/commands/release.ts @@ -1,6 +1,7 @@ +import { flags as oclifFlags } from '@oclif/command' + import { CustomCommand } from '../api/oclif/CustomCommand' import appsRelease, { releaseTypeAliases, supportedReleaseTypes, supportedTagNames } from '../modules/release' - import { ColorifyConstants } from '../api/constants/Colors' export default class Release extends CustomCommand { @@ -17,6 +18,10 @@ export default class Release extends CustomCommand { static flags = { ...CustomCommand.globalFlags, + 'display-name': oclifFlags.boolean({ + description: 'Add the project name to the tag and release commit', + default: false, + }), } static args = [ @@ -33,8 +38,9 @@ export default class Release extends CustomCommand { async run() { const { args: { releaseType, tagName }, + flags: { 'display-name': displayName }, } = this.parse(Release) - await appsRelease(releaseType, tagName) + await appsRelease(releaseType, tagName, displayName) } } diff --git a/src/modules/release/index.ts b/src/modules/release/index.ts index 8341472a6..7c45cfb1b 100644 --- a/src/modules/release/index.ts +++ b/src/modules/release/index.ts @@ -4,6 +4,7 @@ import semver from 'semver' import log from '../../api/logger' import { ReleaseUtils } from './utils' +import { ManifestEditor } from '../../api/manifest' export const releaseTypeAliases = { pre: 'prerelease', @@ -59,13 +60,15 @@ Valid release tags are: ${supportedTagNames.join(', ')}`) export default async ( releaseType = 'patch', // This arg. can also be a valid (semver) version. - tagName = 'beta' + tagName = 'beta', + displayName = false ) => { const utils = new ReleaseUtils() utils.checkGit() utils.checkIfInGitRepo() const normalizedReleaseType = prop(releaseType, releaseTypeAliases) || releaseType const [oldVersion, newVersion] = getNewAndOldVersions(utils, normalizedReleaseType, tagName) + const manifest = await ManifestEditor.getManifestEditor() log.info(`Old version: ${chalk.bold(oldVersion)}`) log.info(`New version: ${chalk.bold.yellow(newVersion)}`) @@ -75,7 +78,7 @@ export default async ( .split('/') // Pachamama v2 requires that version tags start with a 'v' character. - const tagText = `v${newVersion}` + const tagText = `${displayName ? `${manifest.name}@` : 'v'}${newVersion}` const changelogVersion = `\n\n## [${newVersion}] - ${year}-${month}-${day}` if (!(await utils.confirmRelease())) {