Skip to content

Commit

Permalink
added current-tag cli arg.
Browse files Browse the repository at this point in the history
  • Loading branch information
muratgozel committed Nov 21, 2021
1 parent da511bb commit bbae071
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/application/createReleaseByLevel.js
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bbae071

Please sign in to comment.