Socket
Socket
Sign inDemoInstall

commit-and-tag-version

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commit-and-tag-version - npm Package Compare versions

Comparing version 9.5.0 to 9.6.0

test/mocks/increment-version.txt

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Changelog

## [9.6.0](https://github.com/absolute-version/commit-and-tag-version/compare/v9.5.0...v9.6.0) (2022-05-25)
### Features
* **tag:** add an option to force tag replacement ([df5a94a](https://github.com/absolute-version/commit-and-tag-version/commit/df5a94a978c6966e334ec0e4c9f082fae8deb4f9))
### Bug Fixes
* Combining both release-as and prerelease now doesn't break package ([5ecfa2e](https://github.com/absolute-version/commit-and-tag-version/commit/5ecfa2e250e134dbfd3ce8d3c6e9d3be28f6f2b8))
* Fallback to git tag if no version in package file ([57e7091](https://github.com/absolute-version/commit-and-tag-version/commit/57e70916c8afbce16347ed1f710984f5a483152a))
* No longer skips the commit if changelog and bump are both skipped but `commitAll` is set ([08a0121](https://github.com/absolute-version/commit-and-tag-version/commit/08a01212f0eea7ee5e454adf560755df67234d2f))
* Use relative path from .gitignore to avoid files matching inappropriately ([d2491bc](https://github.com/absolute-version/commit-and-tag-version/commit/d2491bc8b61a60cd438045ac409278f5b84621dd))
* When a custom updater reports a version other than the new computed semver, that version is now correctly reported in log output ([f2e83bf](https://github.com/absolute-version/commit-and-tag-version/commit/f2e83bfac711ac5ba4de940d654269af69fc7312))
## [9.5.0](https://github.com/conventional-changelog/standard-version/compare/v9.4.0...v9.5.0) (2022-05-15)

@@ -7,0 +23,0 @@

@@ -76,2 +76,7 @@ const spec = require('conventional-changelog-config-spec')

})
.option('tag-force', {
describe: 'Allow tag replacement',
type: 'boolean',
default: defaults.tagForce
})
.option('scripts', {

@@ -78,0 +83,0 @@ describe:

1

defaults.js

@@ -14,2 +14,3 @@ const spec = require('conventional-changelog-config-spec')

dryRun: false,
tagForce: false,
gitTagFallback: true,

@@ -16,0 +17,0 @@ preset: require.resolve('conventional-changelog-conventionalcommits')

2

index.js

@@ -76,3 +76,3 @@ const bump = require('./lib/lifecycles/bump')

let version
if (pkg) {
if (pkg && pkg.version) {
version = pkg.version

@@ -79,0 +79,0 @@ } else if (args.gitTagFallback) {

@@ -30,3 +30,5 @@ 'use strict'

const releaseType = getReleaseType(args.prerelease, release.releaseType, version)
newVersion = semver.valid(releaseType) || semver.inc(version, releaseType, args.prerelease)
const releaseTypeAsVersion = releaseType === 'pre' + release.releaseType ? semver.valid(release.releaseType + '-' + args.prerelease + '.0') : semver.valid(releaseType)
newVersion = releaseTypeAsVersion || semver.inc(version, releaseType, args.prerelease)
updateConfigs(args, newVersion)

@@ -149,3 +151,3 @@ } else {

try {
if (dotgit.ignore(configPath)) return
if (dotgit.ignore(updater.filename)) return
const stat = fs.lstatSync(configPath)

@@ -155,6 +157,8 @@

const contents = fs.readFileSync(configPath, 'utf8')
const newContents = updater.updater.writeVersion(contents, newVersion)
const realNewVersion = updater.updater.readVersion(newContents)
checkpoint(
args,
'bumping version in ' + updater.filename + ' from %s to %s',
[updater.updater.readVersion(contents), newVersion]
[updater.updater.readVersion(contents), realNewVersion]
)

@@ -164,3 +168,3 @@ writeFile(

configPath,
updater.updater.writeVersion(contents, newVersion)
newContents
)

@@ -167,0 +171,0 @@ // flag any config files that we modify the version # for

@@ -49,3 +49,3 @@ const bump = require('../lifecycles/bump')

// nothing to do, exit without commit anything
if (args.skip.changelog && args.skip.bump && toAdd.length === 0) {
if (!args.commitAll && args.skip.changelog && args.skip.bump && toAdd.length === 0) {
return

@@ -52,0 +52,0 @@ }

@@ -17,10 +17,13 @@ const bump = require('../lifecycles/bump')

async function execTag (newVersion, pkgPrivate, args) {
let tagOption
const tagOption = []
if (args.sign) {
tagOption = '-s'
tagOption.push('-s')
} else {
tagOption = '-a'
tagOption.push('-a')
}
if (args.tagForce) {
tagOption.push('-f')
}
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
await runExecFile(args, 'git', ['tag', ...tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
const currentBranch = await runExecFile('', 'git', ['rev-parse', '--abbrev-ref', 'HEAD'])

@@ -27,0 +30,0 @@ let message = 'git push --follow-tags origin ' + currentBranch.trim()

{
"name": "commit-and-tag-version",
"version": "9.5.0",
"version": "9.6.0",
"description": "replacement for `npm version` with automatic CHANGELOG generation",

@@ -67,4 +67,5 @@ "bin": "bin/cli.js",

"shelljs": "^0.8.4",
"std-mocks": "^1.0.1"
"std-mocks": "^1.0.1",
"strip-ansi": "^6.0.0"
}
}

@@ -109,3 +109,3 @@ # Standard Version

By default (as of `6.0.0`), `commit-and-tag-version` uses the [conventionalcommits preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits).
By default, `commit-and-tag-version` uses the [conventionalcommits preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits).

@@ -328,2 +328,6 @@ This preset:

### Tag replacement
If you've already run `standard-version` when creating your release, you may want to alter the release content and changelog without bumping the version, by using `standard-version --skip.bump`. By default, tagging with an already existing tag make `git` fails. You can add the `--tag-force` flag to make use of `-f` option when calling `git tag`, then the existing version tag will be replaced.
### CLI Help

@@ -384,3 +388,3 @@

As of version `7.1.0` you can configure multiple `bumpFiles` and `packageFiles`.
You can configure multiple `bumpFiles` and `packageFiles`:

@@ -387,0 +391,0 @@ 1. Specify a custom `bumpFile` "`filename`", this is the path to the file you want to "bump"

@@ -12,2 +12,3 @@ /* global describe it afterEach */

const stdMocks = require('std-mocks')
const stripAnsi = require('strip-ansi')

@@ -17,3 +18,3 @@ const cli = require('../command')

require('chai').should()
const should = require('chai').should()

@@ -369,2 +370,38 @@ // set by mock()

})
it('releases as 100.0.0 with prerelease amazing', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' },
pkg: {
version: '1.0.0'
}
})
await exec('--release-as 100.0.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.0')
})
it('release 100.0.0 with prerelease amazing bumps build', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
pkg: {
version: '100.0.0-amazing.0'
}
})
await exec('--release-as 100.0.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.1')
})
it('release 100.0.0-amazing.0 with prerelease amazing bumps build', async function () {
mock({
bump: 'patch',
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
pkg: {
version: '100.0.0-amazing.0'
}
})
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
should.equal(getPackageVersion(), '100.0.0-amazing.1')
})
})

@@ -542,2 +579,33 @@

})
it('displays the new version from custom bumper with --dry-run', async function () {
const updater = 'increment-updater.js'
const updaterModule = require('./mocks/updater/increment-updater')
mock({
bump: 'minor',
fs: {
'increment-version.txt': fs.readFileSync(
'./test/mocks/increment-version.txt'
)
}
})
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
const origInfo = console.info
const capturedOutput = []
console.info = (...args) => {
capturedOutput.push(...args)
origInfo(...args)
}
try {
await exec({
bumpFiles: [{ filename: 'increment-version.txt', updater: 'increment-updater.js' }],
dryRun: true
})
const logOutput = capturedOutput.join(' ')
stripAnsi(logOutput).should.include('bumping version in increment-version.txt from 1 to 2')
} finally {
console.info = origInfo
}
})
})

@@ -782,2 +850,22 @@

it('--tag-force forces tag replacement', async function () {
const gitArgs = [
['add', 'CHANGELOG.md', 'package.json'],
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'],
['tag', '-a', '-f', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
['rev-parse', '--abbrev-ref', 'HEAD']
]
const execFile = (_args, cmd, cmdArgs) => {
cmd.should.equal('git')
const expected = gitArgs.shift()
cmdArgs.should.deep.equal(expected)
if (expected[0] === 'rev-parse') return Promise.resolve('master')
return Promise.resolve('')
}
mock({ bump: 'patch', changelog: 'foo\n', execFile })
await exec('--tag-force', true)
gitArgs.should.have.lengthOf(0)
})
it('fails if git add fails', async function () {

@@ -784,0 +872,0 @@ const gitArgs = [['add', 'CHANGELOG.md', 'package.json']]

@@ -196,2 +196,10 @@ /* global describe it beforeEach afterEach */

it('replaces tags if version not bumped', async function () {
mock({ bump: 'minor', tags: ['v1.0.0'] })
await exec({})
shell.exec('git describe').stdout.should.match(/v1\.1\.0/)
await exec('--tag-force --skip.bump')
shell.exec('git describe').stdout.should.match(/v1\.1\.0/)
})
it('allows the commit phase to be skipped', async function () {

@@ -198,0 +206,0 @@ const changelogContent = 'legacy header format<a name="1.0.0">\n'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc