From bbae0717d7b31b618221c3edcce69e2149fcf22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Murat=20Go=CC=88zel?= Date: Sun, 21 Nov 2021 19:59:17 +0300 Subject: [PATCH] added current-tag cli arg. --- README.md | 6 ++++++ package.json | 2 +- src/application/createReleaseByLevel.js | 4 ++-- src/cli.js | 6 ++++++ src/index.js | 3 ++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9293879..29035d5 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,12 @@ Specify multiple messages: releaser minor -m "fixed something" -m "added something." ``` +Specify a tag as the current tag: +```sh +releaser major -m "initial release." --current-tag v3.0.0 +``` +Normally, module query git to find the current tag. + ## Default Plugins 1. **Github**: Github plugin is for creating releases on Github. 2. **Gitlab**: Gitlab plugin is for creating releases on Gitlab. diff --git a/package.json b/package.json index 53de09c..e3bdff3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-releaser", - "version": "0.6.1", + "version": "0.7.0", "description": "Automated versioning and package publishing tool. Supports semver and calver. Extendible with plugins.", "main": "src/index.js", "bin": { diff --git a/src/application/createReleaseByLevel.js b/src/application/createReleaseByLevel.js index fc48776..e58a951 100644 --- a/src/application/createReleaseByLevel.js +++ b/src/application/createReleaseByLevel.js @@ -1,7 +1,7 @@ const colors = require('colors/safe') module.exports = async function createReleaseByLevel(level, ctx) { - const {git, config, versioning, plugins, messages, forceCalverFormat} = ctx + const {git, config, versioning, plugins, messages, forceCalverFormat, inputCurrentTag} = ctx git.verifyCodebase() @@ -12,7 +12,7 @@ module.exports = async function createReleaseByLevel(level, ctx) { const scheme = config.get('versioning.scheme') const format = config.get('versioning.format') - const currentTag = git.getLatestTag(scheme, format, config, versioning) + const currentTag = inputCurrentTag || git.getLatestTag(scheme, format, config, versioning) const currentTagBare = plugins.getContext().getBareVersion(currentTag) const nextTagBare = versioning.generateNextTag(level, currentTagBare, scheme, format, {forceCalverFormat}) const nextTag = plugins.getContext().prefixTag(nextTagBare) diff --git a/src/cli.js b/src/cli.js index 64b9210..a2f467a 100755 --- a/src/cli.js +++ b/src/cli.js @@ -10,6 +10,12 @@ function registerLevelPositioners(yargs) { describe: 'Commit message. Can be specified multiple times to create multiline commit messages.' }) + yargs.positional('current-tag', { + type: 'string', + default: '', + describe: 'Take this as current tag. It won\'t query git for the current tag.' + }) + yargs.positional('force-calver-format', { type: 'boolean', default: false, diff --git a/src/index.js b/src/index.js index 128ec63..8f8f3dd 100644 --- a/src/index.js +++ b/src/index.js @@ -43,7 +43,8 @@ function lib() { async function createReleaseByLevelCLI(level, argv) { const messages = Array.isArray(argv.message) ? argv.message : [argv.message] const forceCalverFormat = argv.forceCalverFormat - return await createReleaseByLevel(level, {messages, forceCalverFormat}) + const inputCurrentTag = argv.currentTag + return await createReleaseByLevel(level, {messages, forceCalverFormat, inputCurrentTag}) } async function createReleaseByLevel(level, params) {