commit-and-tag-version 9.5.0 → 10.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yaml +4 -4
- package/.github/workflows/release-please.yml +4 -4
- package/CHANGELOG.md +39 -0
- package/README.md +8 -4
- package/command.js +5 -0
- package/defaults.js +1 -0
- package/index.js +1 -1
- package/lib/lifecycles/bump.js +8 -4
- package/lib/lifecycles/commit.js +1 -1
- package/lib/lifecycles/tag.js +7 -4
- package/lib/updaters/index.js +13 -9
- package/package.json +12 -11
- package/test/core.spec.js +89 -1
- package/test/git.spec.js +8 -0
- package/test/mocks/increment-version.txt +1 -0
- package/test/mocks/updater/increment-updater.js +7 -0
|
@@ -10,17 +10,17 @@ jobs:
|
|
|
10
10
|
runs-on: ${{ matrix.os }}
|
|
11
11
|
strategy:
|
|
12
12
|
matrix:
|
|
13
|
-
node: [
|
|
13
|
+
node: [14, 16, 18]
|
|
14
14
|
os: [ubuntu-latest, windows-latest]
|
|
15
15
|
env:
|
|
16
16
|
OS: ${{ matrix.os }}
|
|
17
17
|
NODE_VERSION: ${{ matrix.node }}
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
20
|
- run: git fetch --prune --unshallow
|
|
21
21
|
- run: git config --global user.name 'Actions'
|
|
22
22
|
- run: git config --global user.email 'dummy@example.org'
|
|
23
|
-
- uses: actions/setup-node@
|
|
23
|
+
- uses: actions/setup-node@v3
|
|
24
24
|
with:
|
|
25
25
|
node-version: ${{ matrix.node }}
|
|
26
26
|
- run: node --version
|
|
@@ -28,6 +28,6 @@ jobs:
|
|
|
28
28
|
- run: npm test
|
|
29
29
|
- run: npm run coverage
|
|
30
30
|
- name: Codecov
|
|
31
|
-
uses: codecov/codecov-action@
|
|
31
|
+
uses: codecov/codecov-action@v3
|
|
32
32
|
with:
|
|
33
33
|
env_vars: OS, NODE_VERSION
|
|
@@ -12,15 +12,15 @@ jobs:
|
|
|
12
12
|
with:
|
|
13
13
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
14
14
|
release-type: node
|
|
15
|
-
package-name:
|
|
15
|
+
package-name: commit-and-tag-version
|
|
16
16
|
# The logic below handles the npm publication:
|
|
17
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
18
|
# these if statements ensure that a publication only occurs when
|
|
19
19
|
# a new release is created:
|
|
20
20
|
if: ${{ steps.release.outputs.release_created }}
|
|
21
|
-
- uses: actions/setup-node@
|
|
21
|
+
- uses: actions/setup-node@v3
|
|
22
22
|
with:
|
|
23
|
-
node-version:
|
|
23
|
+
node-version: 16
|
|
24
24
|
registry-url: 'https://registry.npmjs.org'
|
|
25
25
|
if: ${{ steps.release.outputs.release_created }}
|
|
26
26
|
- run: npm ci
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [10.0.1](https://github.com/absolute-version/commit-and-tag-version/compare/v10.0.0...v10.0.1) (2022-05-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* No longer warn inappropriately when a custom updater is provided as an object ([5eb8886](https://github.com/absolute-version/commit-and-tag-version/commit/5eb8886a56c6b14c13544192edb3d0e18f91184a))
|
|
11
|
+
|
|
12
|
+
## [10.0.0](https://github.com/absolute-version/commit-and-tag-version/compare/v9.6.0...v10.0.0) (2022-05-25)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### ⚠ BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* Drop support for node 10 and 12, support node 16 and 18
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* **deps:** update dependency yargs to v17 ([d190c51](https://github.com/absolute-version/commit-and-tag-version/commit/d190c51507026adefe640cdd75f0a643afd81b87))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Build System
|
|
25
|
+
|
|
26
|
+
* Drop support for node 10 and 12, support node 16 and 18 ([0f75115](https://github.com/absolute-version/commit-and-tag-version/commit/0f751158c2df9cbf7a2c16bef55a5de084f0d17d))
|
|
27
|
+
|
|
28
|
+
## [9.6.0](https://github.com/absolute-version/commit-and-tag-version/compare/v9.5.0...v9.6.0) (2022-05-25)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* **tag:** add an option to force tag replacement ([df5a94a](https://github.com/absolute-version/commit-and-tag-version/commit/df5a94a978c6966e334ec0e4c9f082fae8deb4f9))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* Combining both release-as and prerelease now doesn't break package ([5ecfa2e](https://github.com/absolute-version/commit-and-tag-version/commit/5ecfa2e250e134dbfd3ce8d3c6e9d3be28f6f2b8))
|
|
39
|
+
* Fallback to git tag if no version in package file ([57e7091](https://github.com/absolute-version/commit-and-tag-version/commit/57e70916c8afbce16347ed1f710984f5a483152a))
|
|
40
|
+
* 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))
|
|
41
|
+
* Use relative path from .gitignore to avoid files matching inappropriately ([d2491bc](https://github.com/absolute-version/commit-and-tag-version/commit/d2491bc8b61a60cd438045ac409278f5b84621dd))
|
|
42
|
+
* 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))
|
|
43
|
+
|
|
5
44
|
## [9.5.0](https://github.com/conventional-changelog/standard-version/compare/v9.4.0...v9.5.0) (2022-05-15)
|
|
6
45
|
|
|
7
46
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Commit and Tag Version
|
|
2
2
|
|
|
3
3
|
> **`commit-and-tag-version` is a fork of `standard-version`**. Because of maintainer availability, `standard-version` was [deprecated on 15th May 2022](https://github.com/conventional-changelog/standard-version/pull/907). The previous maintainer recommends [release-please](https://github.com/googleapis/release-please) as an alternative for those who are using GitHub actions. This fork exists for those who can't switch to `release-please`, or who would like to continue using `standard-version`.
|
|
4
4
|
|
|
5
|
-
> **`Why was it renamed commit-and-tag-version?`**. I
|
|
5
|
+
> **`Why was it renamed commit-and-tag-version?`**. I didn't want to scope the package or name it `standard-version-fork`, and it was a good opportunity to make the purpose of the tool clearer. I also wanted to distinguish it from the other tool in this organisation, [`absolute-version`](https://github.com/absolute-version/absolute-version-js), which just prints version information for pre-releases. To migrate, you can drop in `commit-and-tag-version` in place of `standard-version`. There are no changes in 9.5.0, other than to add the package.json config key `commit-and-tag-version` (the previous configuration key `standard-version` will still work).
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
A utility for versioning using [semver](https://semver.org/) and CHANGELOG generation powered by [Conventional Commits](https://conventionalcommits.org).
|
|
@@ -106,7 +106,7 @@ be provided via configuration. Please refer to the [conventional-changelog-confi
|
|
|
106
106
|
|
|
107
107
|
### Customizing CHANGELOG Generation
|
|
108
108
|
|
|
109
|
-
By default
|
|
109
|
+
By default, `commit-and-tag-version` uses the [conventionalcommits preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits).
|
|
110
110
|
|
|
111
111
|
This preset:
|
|
112
112
|
|
|
@@ -324,6 +324,10 @@ If you do not want to have any tag prefix you can use the `-t` flag and provide
|
|
|
324
324
|
|
|
325
325
|
> Note: simply -t or --tag-prefix without any value will fallback to the default 'v'
|
|
326
326
|
|
|
327
|
+
### Tag replacement
|
|
328
|
+
|
|
329
|
+
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.
|
|
330
|
+
|
|
327
331
|
### CLI Help
|
|
328
332
|
|
|
329
333
|
```sh
|
|
@@ -379,7 +383,7 @@ For this reason, we recommend keeping the scope of each PR to one general featur
|
|
|
379
383
|
|
|
380
384
|
### Can I use `commit-and-tag-version` for additional metadata files, languages or version files?
|
|
381
385
|
|
|
382
|
-
|
|
386
|
+
You can configure multiple `bumpFiles` and `packageFiles`:
|
|
383
387
|
|
|
384
388
|
1. Specify a custom `bumpFile` "`filename`", this is the path to the file you want to "bump"
|
|
385
389
|
2. Specify the `bumpFile` "`updater`", this is _how_ the file will be bumped.
|
package/command.js
CHANGED
|
@@ -73,6 +73,11 @@ const yargs = require('yargs')
|
|
|
73
73
|
type: 'string',
|
|
74
74
|
default: defaults.tagPrefix
|
|
75
75
|
})
|
|
76
|
+
.option('tag-force', {
|
|
77
|
+
describe: 'Allow tag replacement',
|
|
78
|
+
type: 'boolean',
|
|
79
|
+
default: defaults.tagForce
|
|
80
|
+
})
|
|
76
81
|
.option('scripts', {
|
|
77
82
|
describe:
|
|
78
83
|
'Provide scripts to execute for lifecycle events (prebump, precommit, etc.,)',
|
package/defaults.js
CHANGED
package/index.js
CHANGED
package/lib/lifecycles/bump.js
CHANGED
|
@@ -27,7 +27,9 @@ async function Bump (args, version) {
|
|
|
27
27
|
const release = await bumpVersion(args.releaseAs, version, args)
|
|
28
28
|
if (!args.firstRelease) {
|
|
29
29
|
const releaseType = getReleaseType(args.prerelease, release.releaseType, version)
|
|
30
|
-
|
|
30
|
+
const releaseTypeAsVersion = releaseType === 'pre' + release.releaseType ? semver.valid(release.releaseType + '-' + args.prerelease + '.0') : semver.valid(releaseType)
|
|
31
|
+
|
|
32
|
+
newVersion = releaseTypeAsVersion || semver.inc(version, releaseType, args.prerelease)
|
|
31
33
|
updateConfigs(args, newVersion)
|
|
32
34
|
} else {
|
|
33
35
|
checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))
|
|
@@ -145,20 +147,22 @@ function updateConfigs (args, newVersion) {
|
|
|
145
147
|
}
|
|
146
148
|
const configPath = path.resolve(process.cwd(), updater.filename)
|
|
147
149
|
try {
|
|
148
|
-
if (dotgit.ignore(
|
|
150
|
+
if (dotgit.ignore(updater.filename)) return
|
|
149
151
|
const stat = fs.lstatSync(configPath)
|
|
150
152
|
|
|
151
153
|
if (!stat.isFile()) return
|
|
152
154
|
const contents = fs.readFileSync(configPath, 'utf8')
|
|
155
|
+
const newContents = updater.updater.writeVersion(contents, newVersion)
|
|
156
|
+
const realNewVersion = updater.updater.readVersion(newContents)
|
|
153
157
|
checkpoint(
|
|
154
158
|
args,
|
|
155
159
|
'bumping version in ' + updater.filename + ' from %s to %s',
|
|
156
|
-
[updater.updater.readVersion(contents),
|
|
160
|
+
[updater.updater.readVersion(contents), realNewVersion]
|
|
157
161
|
)
|
|
158
162
|
writeFile(
|
|
159
163
|
args,
|
|
160
164
|
configPath,
|
|
161
|
-
|
|
165
|
+
newContents
|
|
162
166
|
)
|
|
163
167
|
// flag any config files that we modify the version # for
|
|
164
168
|
// as having been updated.
|
package/lib/lifecycles/commit.js
CHANGED
|
@@ -46,7 +46,7 @@ async function execCommit (args, newVersion) {
|
|
|
46
46
|
checkpoint(args, msg, paths)
|
|
47
47
|
|
|
48
48
|
// nothing to do, exit without commit anything
|
|
49
|
-
if (args.skip.changelog && args.skip.bump && toAdd.length === 0) {
|
|
49
|
+
if (!args.commitAll && args.skip.changelog && args.skip.bump && toAdd.length === 0) {
|
|
50
50
|
return
|
|
51
51
|
}
|
|
52
52
|
|
package/lib/lifecycles/tag.js
CHANGED
|
@@ -14,14 +14,17 @@ module.exports = async function (newVersion, pkgPrivate, args) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async function execTag (newVersion, pkgPrivate, args) {
|
|
17
|
-
|
|
17
|
+
const tagOption = []
|
|
18
18
|
if (args.sign) {
|
|
19
|
-
tagOption
|
|
19
|
+
tagOption.push('-s')
|
|
20
20
|
} else {
|
|
21
|
-
tagOption
|
|
21
|
+
tagOption.push('-a')
|
|
22
|
+
}
|
|
23
|
+
if (args.tagForce) {
|
|
24
|
+
tagOption.push('-f')
|
|
22
25
|
}
|
|
23
26
|
checkpoint(args, 'tagging release %s%s', [args.tagPrefix, newVersion])
|
|
24
|
-
await runExecFile(args, 'git', ['tag', tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
|
|
27
|
+
await runExecFile(args, 'git', ['tag', ...tagOption, args.tagPrefix + newVersion, '-m', `${formatCommitMessage(args.releaseCommitMessageFormat, newVersion)}`])
|
|
25
28
|
const currentBranch = await runExecFile('', 'git', ['rev-parse', '--abbrev-ref', 'HEAD'])
|
|
26
29
|
let message = 'git push --follow-tags origin ' + currentBranch.trim()
|
|
27
30
|
if (pkgPrivate !== true && bump.getUpdatedConfigs()['package.json']) {
|
package/lib/updaters/index.js
CHANGED
|
@@ -44,6 +44,7 @@ function getCustomUpdaterFromPath (updater) {
|
|
|
44
44
|
*/
|
|
45
45
|
function isValidUpdater (obj) {
|
|
46
46
|
return (
|
|
47
|
+
obj &&
|
|
47
48
|
typeof obj.readVersion === 'function' &&
|
|
48
49
|
typeof obj.writeVersion === 'function'
|
|
49
50
|
)
|
|
@@ -63,16 +64,19 @@ module.exports.resolveUpdaterObjectFromArgument = function (arg) {
|
|
|
63
64
|
filename: arg
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
|
|
68
|
+
if (!isValidUpdater(updater.updater)) {
|
|
69
|
+
try {
|
|
70
|
+
if (typeof updater.updater === 'string') {
|
|
71
|
+
updater.updater = getCustomUpdaterFromPath(updater.updater)
|
|
72
|
+
} else if (updater.type) {
|
|
73
|
+
updater.updater = getUpdaterByType(updater.type)
|
|
74
|
+
} else {
|
|
75
|
+
updater.updater = getUpdaterByFilename(updater.filename)
|
|
76
|
+
}
|
|
77
|
+
} catch (err) {
|
|
78
|
+
if (err.code !== 'ENOENT') console.warn(`Unable to obtain updater for: ${JSON.stringify(arg)}\n - Error: ${err.message}\n - Skipping...`)
|
|
73
79
|
}
|
|
74
|
-
} catch (err) {
|
|
75
|
-
if (err.code !== 'ENOENT') console.warn(`Unable to obtain updater for: ${JSON.stringify(arg)}\n - Error: ${err.message}\n - Skipping...`)
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* We weren't able to resolve an updater for the argument.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.1",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"bin": "bin/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"repository": "absolute-version/commit-and-tag-version",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=14"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"conventional-changelog",
|
|
@@ -50,20 +50,21 @@
|
|
|
50
50
|
"git-semver-tags": "^4.0.0",
|
|
51
51
|
"semver": "^7.1.1",
|
|
52
52
|
"stringify-package": "^1.0.1",
|
|
53
|
-
"yargs": "^
|
|
53
|
+
"yargs": "^17.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"chai": "^4.2.0",
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"eslint-config-standard": "^
|
|
59
|
-
"eslint-plugin-import": "^2.
|
|
60
|
-
"eslint-plugin-
|
|
61
|
-
"eslint-plugin-promise": "^
|
|
62
|
-
"mocha": "^
|
|
63
|
-
"mock-fs": "^
|
|
57
|
+
"eslint": "^8.16.0",
|
|
58
|
+
"eslint-config-standard": "^17.0.0",
|
|
59
|
+
"eslint-plugin-import": "^2.26.0",
|
|
60
|
+
"eslint-plugin-n": "^15.2.0",
|
|
61
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
62
|
+
"mocha": "^10.0.0",
|
|
63
|
+
"mock-fs": "^5.0.0",
|
|
64
64
|
"mockery": "^2.1.0",
|
|
65
65
|
"nyc": "^15.1.0",
|
|
66
66
|
"shelljs": "^0.8.4",
|
|
67
|
-
"std-mocks": "^1.0.1"
|
|
67
|
+
"std-mocks": "^1.0.1",
|
|
68
|
+
"strip-ansi": "^6.0.0"
|
|
68
69
|
}
|
|
69
70
|
}
|
package/test/core.spec.js
CHANGED
|
@@ -9,11 +9,12 @@ const { Readable } = require('stream')
|
|
|
9
9
|
const mockFS = require('mock-fs')
|
|
10
10
|
const mockery = require('mockery')
|
|
11
11
|
const stdMocks = require('std-mocks')
|
|
12
|
+
const stripAnsi = require('strip-ansi')
|
|
12
13
|
|
|
13
14
|
const cli = require('../command')
|
|
14
15
|
const formatCommitMessage = require('../lib/format-commit-message')
|
|
15
16
|
|
|
16
|
-
require('chai').should()
|
|
17
|
+
const should = require('chai').should()
|
|
17
18
|
|
|
18
19
|
// set by mock()
|
|
19
20
|
let standardVersion
|
|
@@ -364,6 +365,42 @@ describe('cli', function () {
|
|
|
364
365
|
await exec('--release-as 200.0.0-amazing')
|
|
365
366
|
getPackageVersion().should.equal('200.0.0-amazing')
|
|
366
367
|
})
|
|
368
|
+
|
|
369
|
+
it('releases as 100.0.0 with prerelease amazing', async function () {
|
|
370
|
+
mock({
|
|
371
|
+
bump: 'patch',
|
|
372
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' },
|
|
373
|
+
pkg: {
|
|
374
|
+
version: '1.0.0'
|
|
375
|
+
}
|
|
376
|
+
})
|
|
377
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
378
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
379
|
+
})
|
|
380
|
+
|
|
381
|
+
it('release 100.0.0 with prerelease amazing bumps build', async function () {
|
|
382
|
+
mock({
|
|
383
|
+
bump: 'patch',
|
|
384
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
385
|
+
pkg: {
|
|
386
|
+
version: '100.0.0-amazing.0'
|
|
387
|
+
}
|
|
388
|
+
})
|
|
389
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
390
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.1')
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
it('release 100.0.0-amazing.0 with prerelease amazing bumps build', async function () {
|
|
394
|
+
mock({
|
|
395
|
+
bump: 'patch',
|
|
396
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
397
|
+
pkg: {
|
|
398
|
+
version: '100.0.0-amazing.0'
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
402
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.1')
|
|
403
|
+
})
|
|
367
404
|
})
|
|
368
405
|
|
|
369
406
|
it('creates a prerelease with a new minor version after two prerelease patches', async function () {
|
|
@@ -536,6 +573,37 @@ describe('commit-and-tag-version', function () {
|
|
|
536
573
|
})
|
|
537
574
|
fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('1.1.0')
|
|
538
575
|
})
|
|
576
|
+
|
|
577
|
+
it('displays the new version from custom bumper with --dry-run', async function () {
|
|
578
|
+
const updater = 'increment-updater.js'
|
|
579
|
+
const updaterModule = require('./mocks/updater/increment-updater')
|
|
580
|
+
mock({
|
|
581
|
+
bump: 'minor',
|
|
582
|
+
fs: {
|
|
583
|
+
'increment-version.txt': fs.readFileSync(
|
|
584
|
+
'./test/mocks/increment-version.txt'
|
|
585
|
+
)
|
|
586
|
+
}
|
|
587
|
+
})
|
|
588
|
+
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
|
|
589
|
+
|
|
590
|
+
const origInfo = console.info
|
|
591
|
+
const capturedOutput = []
|
|
592
|
+
console.info = (...args) => {
|
|
593
|
+
capturedOutput.push(...args)
|
|
594
|
+
origInfo(...args)
|
|
595
|
+
}
|
|
596
|
+
try {
|
|
597
|
+
await exec({
|
|
598
|
+
bumpFiles: [{ filename: 'increment-version.txt', updater: 'increment-updater.js' }],
|
|
599
|
+
dryRun: true
|
|
600
|
+
})
|
|
601
|
+
const logOutput = capturedOutput.join(' ')
|
|
602
|
+
stripAnsi(logOutput).should.include('bumping version in increment-version.txt from 1 to 2')
|
|
603
|
+
} finally {
|
|
604
|
+
console.info = origInfo
|
|
605
|
+
}
|
|
606
|
+
})
|
|
539
607
|
})
|
|
540
608
|
|
|
541
609
|
describe('custom `packageFiles` support', function () {
|
|
@@ -775,6 +843,26 @@ describe('with mocked git', function () {
|
|
|
775
843
|
gitArgs.should.have.lengthOf(0)
|
|
776
844
|
})
|
|
777
845
|
|
|
846
|
+
it('--tag-force forces tag replacement', async function () {
|
|
847
|
+
const gitArgs = [
|
|
848
|
+
['add', 'CHANGELOG.md', 'package.json'],
|
|
849
|
+
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'],
|
|
850
|
+
['tag', '-a', '-f', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
851
|
+
['rev-parse', '--abbrev-ref', 'HEAD']
|
|
852
|
+
]
|
|
853
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
854
|
+
cmd.should.equal('git')
|
|
855
|
+
const expected = gitArgs.shift()
|
|
856
|
+
cmdArgs.should.deep.equal(expected)
|
|
857
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master')
|
|
858
|
+
return Promise.resolve('')
|
|
859
|
+
}
|
|
860
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
861
|
+
|
|
862
|
+
await exec('--tag-force', true)
|
|
863
|
+
gitArgs.should.have.lengthOf(0)
|
|
864
|
+
})
|
|
865
|
+
|
|
778
866
|
it('fails if git add fails', async function () {
|
|
779
867
|
const gitArgs = [['add', 'CHANGELOG.md', 'package.json']]
|
|
780
868
|
const execFile = (_args, cmd, cmdArgs) => {
|
package/test/git.spec.js
CHANGED
|
@@ -193,6 +193,14 @@ describe('git', function () {
|
|
|
193
193
|
await exec('-n')
|
|
194
194
|
})
|
|
195
195
|
|
|
196
|
+
it('replaces tags if version not bumped', async function () {
|
|
197
|
+
mock({ bump: 'minor', tags: ['v1.0.0'] })
|
|
198
|
+
await exec({})
|
|
199
|
+
shell.exec('git describe').stdout.should.match(/v1\.1\.0/)
|
|
200
|
+
await exec('--tag-force --skip.bump')
|
|
201
|
+
shell.exec('git describe').stdout.should.match(/v1\.1\.0/)
|
|
202
|
+
})
|
|
203
|
+
|
|
196
204
|
it('allows the commit phase to be skipped', async function () {
|
|
197
205
|
const changelogContent = 'legacy header format<a name="1.0.0">\n'
|
|
198
206
|
writePackageJson('1.0.0')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1
|