commit-and-tag-version 11.2.3 → 11.3.0
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 +1 -1
- package/.github/workflows/release-please.yml +1 -1
- package/CHANGELOG.md +15 -0
- package/README.md +8 -0
- package/lib/lifecycles/bump.js +45 -5
- package/lib/updaters/index.js +5 -1
- package/lib/updaters/types/csproj.js +13 -0
- package/package.json +2 -1
- package/test/config-files.spec.js +5 -8
- package/test/core.spec.js +161 -83
- package/test/git.spec.js +4 -8
- package/test/mocks/Project-6.3.1.csproj +18 -0
- package/test/mocks/Project-6.4.0.csproj +18 -0
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
OS: ${{ matrix.os }}
|
|
17
17
|
NODE_VERSION: ${{ matrix.node }}
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
|
|
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'
|
|
@@ -15,7 +15,7 @@ jobs:
|
|
|
15
15
|
release-type: node
|
|
16
16
|
package-name: commit-and-tag-version
|
|
17
17
|
# The logic below handles the npm publication:
|
|
18
|
-
- uses: actions/checkout@
|
|
18
|
+
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
|
|
19
19
|
# these if statements ensure that a publication only occurs when
|
|
20
20
|
# a new release is created:
|
|
21
21
|
if: ${{ steps.release.outputs.release_created }}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
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
|
+
## [11.3.0](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.4...v11.3.0) (2023-10-10)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **updater:** add .csproj file support ([#95](https://github.com/absolute-version/commit-and-tag-version/issues/95)) ([a96554c](https://github.com/absolute-version/commit-and-tag-version/commit/a96554c9467bacdf6c9d898b223883ee32f63c15))
|
|
11
|
+
|
|
12
|
+
## [11.2.4](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.3...v11.2.4) (2023-10-02)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* allow bump task to handle versions with build metadata ([33913ee](https://github.com/absolute-version/commit-and-tag-version/commit/33913ee03bff2dfc26c9ffc942e1191c1f767949))
|
|
18
|
+
* handle invalid versions passed to releaseAs ([33913ee](https://github.com/absolute-version/commit-and-tag-version/commit/33913ee03bff2dfc26c9ffc942e1191c1f767949))
|
|
19
|
+
|
|
5
20
|
## [11.2.3](https://github.com/absolute-version/commit-and-tag-version/compare/v11.2.2...v11.2.3) (2023-08-22)
|
|
6
21
|
|
|
7
22
|
|
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ _Having problems? Want to contribute? Join us on the [node-tooling community Sla
|
|
|
19
19
|
- [How It Works:](#how-it-works)
|
|
20
20
|
- [`bumpFiles`, `packageFiles` and `updaters`](#bumpfiles-packagefiles-and-updaters)
|
|
21
21
|
- [Gradle Support (Java/Kotlin)](#gradle-support-javakotlin)
|
|
22
|
+
- [.NET Support](#net-support)
|
|
22
23
|
- [Installing `commit-and-tag-version`](#installing-commit-and-tag-version)
|
|
23
24
|
- [As a local `npm run` script](#as-a-local-npm-run-script)
|
|
24
25
|
- [As global `bin`](#as-global-bin)
|
|
@@ -88,6 +89,13 @@ If you are using Gradle, then just point to your `build.gradle` file (or `build.
|
|
|
88
89
|
commit-and-tag-version --packageFiles build.gradle --bumpFiles build.gradle
|
|
89
90
|
```
|
|
90
91
|
|
|
92
|
+
### .NET Support
|
|
93
|
+
|
|
94
|
+
If you are using .NET with `.csproj` files.
|
|
95
|
+
This is going to read and update only the `<Version>` tag in the file.
|
|
96
|
+
```sh
|
|
97
|
+
commit-and-tag-version --packageFiles <YOUR-PROJECT-NAME>.csproj --bumpFiles <YOUR-PROJECT-NAME>.csproj
|
|
98
|
+
```
|
|
91
99
|
|
|
92
100
|
## Installing `commit-and-tag-version`
|
|
93
101
|
|
package/lib/lifecycles/bump.js
CHANGED
|
@@ -20,16 +20,46 @@ async function Bump (args, version) {
|
|
|
20
20
|
configsToUpdate = {}
|
|
21
21
|
|
|
22
22
|
if (args.skip.bump) return version
|
|
23
|
+
|
|
24
|
+
if (args.releaseAs && !(['major', 'minor', 'patch'].includes(args.releaseAs.toLowerCase()) || semver.valid(args.releaseAs))) {
|
|
25
|
+
throw new Error("releaseAs must be one of 'major', 'minor' or 'patch', or a valid semvar version.")
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
let newVersion = version
|
|
24
29
|
await runLifecycleScript(args, 'prerelease')
|
|
25
30
|
const stdout = await runLifecycleScript(args, 'prebump')
|
|
26
|
-
if (stdout
|
|
27
|
-
|
|
31
|
+
if (stdout?.trim().length) {
|
|
32
|
+
const prebumpString = stdout.trim()
|
|
33
|
+
if (semver.valid(prebumpString)) args.releaseAs = prebumpString
|
|
34
|
+
}
|
|
28
35
|
if (!args.firstRelease) {
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
if (semver.valid(args.releaseAs)) {
|
|
37
|
+
const releaseAs = new semver.SemVer(args.releaseAs)
|
|
38
|
+
if (isString(args.prerelease) && releaseAs.prerelease.length && releaseAs.prerelease.slice(0, -1).join('.') !== args.prerelease) {
|
|
39
|
+
// If both releaseAs and the prerelease identifier are supplied, they must match. The behavior
|
|
40
|
+
// for a mismatch is undefined, so error out instead.
|
|
41
|
+
throw new Error('releaseAs and prerelease have conflicting prerelease identifiers')
|
|
42
|
+
} else if (isString(args.prerelease) && releaseAs.prerelease.length) {
|
|
43
|
+
newVersion = releaseAs.version
|
|
44
|
+
} else if (isString(args.prerelease)) {
|
|
45
|
+
newVersion = `${releaseAs.major}.${releaseAs.minor}.${releaseAs.patch}-${args.prerelease}.0`
|
|
46
|
+
} else {
|
|
47
|
+
newVersion = releaseAs.version
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Check if the previous version is the same version and prerelease, and increment if so
|
|
51
|
+
if (isString(args.prerelease) && ['prerelease', null].includes(semver.diff(version, newVersion)) && semver.lte(newVersion, version)) {
|
|
52
|
+
newVersion = semver.inc(version, 'prerelease', args.prerelease)
|
|
53
|
+
}
|
|
31
54
|
|
|
32
|
-
|
|
55
|
+
// Append any build info from releaseAs
|
|
56
|
+
newVersion = semvarToVersionStr(newVersion, releaseAs.build)
|
|
57
|
+
} else {
|
|
58
|
+
const release = await bumpVersion(args.releaseAs, version, args)
|
|
59
|
+
const releaseType = getReleaseType(args.prerelease, release.releaseType, version)
|
|
60
|
+
|
|
61
|
+
newVersion = semver.inc(version, releaseType, args.prerelease)
|
|
62
|
+
}
|
|
33
63
|
updateConfigs(args, newVersion)
|
|
34
64
|
} else {
|
|
35
65
|
checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))
|
|
@@ -42,6 +72,16 @@ Bump.getUpdatedConfigs = function () {
|
|
|
42
72
|
return configsToUpdate
|
|
43
73
|
}
|
|
44
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Convert a semver object to a full version string including build metadata
|
|
77
|
+
* @param {string} semverVersion The semvar version string
|
|
78
|
+
* @param {string[]} semverBuild An array of the build metadata elements, to be joined with '.'
|
|
79
|
+
* @returns {string}
|
|
80
|
+
*/
|
|
81
|
+
function semvarToVersionStr (semverVersion, semverBuild) {
|
|
82
|
+
return [semverVersion, semverBuild.join('.')].filter(Boolean).join('+')
|
|
83
|
+
}
|
|
84
|
+
|
|
45
85
|
function getReleaseType (prerelease, expectedReleaseType, currentVersion) {
|
|
46
86
|
if (isString(prerelease)) {
|
|
47
87
|
if (isInPrerelease(currentVersion)) {
|
package/lib/updaters/index.js
CHANGED
|
@@ -3,7 +3,8 @@ const JSON_BUMP_FILES = require('../../defaults').bumpFiles
|
|
|
3
3
|
const updatersByType = {
|
|
4
4
|
json: require('./types/json'),
|
|
5
5
|
'plain-text': require('./types/plain-text'),
|
|
6
|
-
gradle: require('./types/gradle')
|
|
6
|
+
gradle: require('./types/gradle'),
|
|
7
|
+
csproj: require('./types/csproj')
|
|
7
8
|
}
|
|
8
9
|
const PLAIN_TEXT_BUMP_FILES = ['VERSION.txt', 'version.txt']
|
|
9
10
|
|
|
@@ -25,6 +26,9 @@ function getUpdaterByFilename (filename) {
|
|
|
25
26
|
if (/build.gradle/.test(filename)) {
|
|
26
27
|
return getUpdaterByType('gradle')
|
|
27
28
|
}
|
|
29
|
+
if (filename.endsWith('.csproj')) {
|
|
30
|
+
return getUpdaterByType('csproj')
|
|
31
|
+
}
|
|
28
32
|
throw Error(
|
|
29
33
|
`Unsupported file (${filename}) provided for bumping.\n Please specify the updater \`type\` or use a custom \`updater\`.`
|
|
30
34
|
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const versionRegex = /<Version>(.*)<\/Version>/
|
|
2
|
+
|
|
3
|
+
module.exports.readVersion = function (contents) {
|
|
4
|
+
const matches = versionRegex.exec(contents)
|
|
5
|
+
if (matches === null || matches.length !== 2) {
|
|
6
|
+
throw new Error('Failed to read the Version field in your csproj file - is it present?')
|
|
7
|
+
}
|
|
8
|
+
return matches[1]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports.writeVersion = function (contents, version) {
|
|
12
|
+
return contents.replace(versionRegex, `<Version>${version}</Version>`)
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"bin": "bin/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"chai": "^4.2.0",
|
|
59
|
+
"chai-as-promised": "^7.1.1",
|
|
59
60
|
"eslint": "^8.16.0",
|
|
60
61
|
"eslint-config-standard": "^17.0.0",
|
|
61
62
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -8,7 +8,9 @@ const { Readable } = require('stream')
|
|
|
8
8
|
const mockery = require('mockery')
|
|
9
9
|
const stdMocks = require('std-mocks')
|
|
10
10
|
|
|
11
|
-
require('chai')
|
|
11
|
+
const chai = require('chai')
|
|
12
|
+
const expect = chai.expect
|
|
13
|
+
chai.use(require('chai-as-promised'))
|
|
12
14
|
|
|
13
15
|
function exec () {
|
|
14
16
|
const cli = require('../command')
|
|
@@ -168,12 +170,7 @@ describe('config files', () => {
|
|
|
168
170
|
it('throws an error when a non-object is returned from .versionrc.js', async function () {
|
|
169
171
|
mock({ bump: 'minor' })
|
|
170
172
|
fs.writeFileSync('.versionrc.js', 'module.exports = 3', 'utf-8')
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
/* istanbul ignore next */
|
|
174
|
-
throw new Error('Unexpected success')
|
|
175
|
-
} catch (error) {
|
|
176
|
-
error.message.should.match(/Invalid configuration/)
|
|
177
|
-
}
|
|
173
|
+
|
|
174
|
+
expect(exec).to.throw(/Invalid configuration/)
|
|
178
175
|
})
|
|
179
176
|
})
|
package/test/core.spec.js
CHANGED
|
@@ -14,7 +14,10 @@ const stripAnsi = require('strip-ansi')
|
|
|
14
14
|
const cli = require('../command')
|
|
15
15
|
const formatCommitMessage = require('../lib/format-commit-message')
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const chai = require('chai')
|
|
18
|
+
const should = chai.should()
|
|
19
|
+
const expect = chai.expect
|
|
20
|
+
chai.use(require('chai-as-promised'))
|
|
18
21
|
|
|
19
22
|
// set by mock()
|
|
20
23
|
let standardVersion
|
|
@@ -157,12 +160,7 @@ describe('cli', function () {
|
|
|
157
160
|
mock({ bump: 'minor', changelog: 'foo\n' })
|
|
158
161
|
await exec('--skip.changelog true')
|
|
159
162
|
getPackageVersion().should.equal('1.1.0')
|
|
160
|
-
|
|
161
|
-
fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
162
|
-
throw new Error('File should not exist')
|
|
163
|
-
} catch (err) {
|
|
164
|
-
err.code.should.equal('ENOENT')
|
|
165
|
-
}
|
|
163
|
+
expect(() => fs.readFileSync('CHANGELOG.md', 'utf-8')).to.throw(/ENOENT/)
|
|
166
164
|
})
|
|
167
165
|
})
|
|
168
166
|
|
|
@@ -217,12 +215,7 @@ describe('cli', function () {
|
|
|
217
215
|
|
|
218
216
|
it('[DEPRECATED] (--changelogHeader) exits with error if changelog header matches last version search regex', async function () {
|
|
219
217
|
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
220
|
-
|
|
221
|
-
await exec('--changelogHeader="## 3.0.2"')
|
|
222
|
-
throw new Error('That should not have worked')
|
|
223
|
-
} catch (error) {
|
|
224
|
-
error.message.should.match(/custom changelog header must not match/)
|
|
225
|
-
}
|
|
218
|
+
expect(exec('--changelogHeader="## 3.0.2"')).to.be.rejectedWith(/custom changelog header must not match/)
|
|
226
219
|
})
|
|
227
220
|
})
|
|
228
221
|
|
|
@@ -249,17 +242,11 @@ describe('cli', function () {
|
|
|
249
242
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
250
243
|
})
|
|
251
244
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
})
|
|
258
|
-
/* istanbul ignore next */
|
|
259
|
-
throw new Error('Unexpected success')
|
|
260
|
-
} catch (error) {
|
|
261
|
-
error.message.should.match(/prerelease fail/)
|
|
262
|
-
}
|
|
245
|
+
expect(exec({
|
|
246
|
+
scripts: {
|
|
247
|
+
prerelease: "node -e \"throw new Error('prerelease' + ' fail')\""
|
|
248
|
+
}
|
|
249
|
+
})).to.be.rejectedWith(/prerelease fail/)
|
|
263
250
|
})
|
|
264
251
|
})
|
|
265
252
|
|
|
@@ -277,6 +264,49 @@ describe('cli', function () {
|
|
|
277
264
|
})
|
|
278
265
|
const { stdout } = flush()
|
|
279
266
|
stdout.join('').should.match(/9\.9\.9/)
|
|
267
|
+
getPackageVersion().should.equal('9.9.9')
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it('should not allow prebump hook to return a releaseAs command', async function () {
|
|
271
|
+
mock({
|
|
272
|
+
bump: 'minor',
|
|
273
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
await exec({
|
|
277
|
+
scripts: {
|
|
278
|
+
prebump: "node -e \"console.log('major')\""
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
getPackageVersion().should.equal('1.1.0')
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
it('should allow prebump hook to return an arbitrary string', async function () {
|
|
285
|
+
mock({
|
|
286
|
+
bump: 'minor',
|
|
287
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
await exec({
|
|
291
|
+
scripts: {
|
|
292
|
+
prebump: "node -e \"console.log('Hello World')\""
|
|
293
|
+
}
|
|
294
|
+
})
|
|
295
|
+
getPackageVersion().should.equal('1.1.0')
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('should allow prebump hook to return a version with build info', async function () {
|
|
299
|
+
mock({
|
|
300
|
+
bump: 'minor',
|
|
301
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
await exec({
|
|
305
|
+
scripts: {
|
|
306
|
+
prebump: "node -e \"console.log('9.9.9-test+build')\""
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
getPackageVersion().should.equal('9.9.9-test+build')
|
|
280
310
|
})
|
|
281
311
|
})
|
|
282
312
|
|
|
@@ -302,18 +332,12 @@ describe('cli', function () {
|
|
|
302
332
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
303
333
|
})
|
|
304
334
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
await exec('--patch')
|
|
312
|
-
/* istanbul ignore next */
|
|
313
|
-
throw new Error('Unexpected success')
|
|
314
|
-
} catch (error) {
|
|
315
|
-
error.message.should.match(/postbump fail/)
|
|
316
|
-
}
|
|
335
|
+
expect(exec({
|
|
336
|
+
scripts: {
|
|
337
|
+
postbump: "node -e \"throw new Error('postbump' + ' fail')\""
|
|
338
|
+
}
|
|
339
|
+
})).to.be.rejectedWith(/postbump fail/)
|
|
340
|
+
expect(exec('--patch')).to.be.rejectedWith(/postbump fail/)
|
|
317
341
|
})
|
|
318
342
|
})
|
|
319
343
|
})
|
|
@@ -345,6 +369,12 @@ describe('cli', function () {
|
|
|
345
369
|
getPackageVersion().should.equal(`${nextVersion[type]}-${type}.0`)
|
|
346
370
|
})
|
|
347
371
|
})
|
|
372
|
+
|
|
373
|
+
it('exits with error if an invalid release type is provided', async function () {
|
|
374
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
375
|
+
|
|
376
|
+
expect(exec('--release-as invalid')).to.be.rejectedWith(/releaseAs must be one of/)
|
|
377
|
+
})
|
|
348
378
|
})
|
|
349
379
|
|
|
350
380
|
describe('release-as-exact', function () {
|
|
@@ -395,11 +425,59 @@ describe('cli', function () {
|
|
|
395
425
|
bump: 'patch',
|
|
396
426
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
397
427
|
pkg: {
|
|
398
|
-
version: '100.0.0-amazing.
|
|
428
|
+
version: '100.0.0-amazing.1'
|
|
399
429
|
}
|
|
400
430
|
})
|
|
401
431
|
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
402
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.
|
|
432
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.2')
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
it('release 100.0.0 with prerelease amazing correctly sets version', async function () {
|
|
436
|
+
mock({
|
|
437
|
+
bump: 'patch',
|
|
438
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
439
|
+
pkg: {
|
|
440
|
+
version: '99.0.0-amazing.0'
|
|
441
|
+
}
|
|
442
|
+
})
|
|
443
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
444
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
it('release 100.0.0-amazing.0 with prerelease amazing correctly sets version', async function () {
|
|
448
|
+
mock({
|
|
449
|
+
bump: 'patch',
|
|
450
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
451
|
+
pkg: {
|
|
452
|
+
version: '99.0.0-amazing.0'
|
|
453
|
+
}
|
|
454
|
+
})
|
|
455
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
456
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
457
|
+
})
|
|
458
|
+
|
|
459
|
+
it('release 100.0.0-amazing.0 with prerelease amazing retains build metadata', async function () {
|
|
460
|
+
mock({
|
|
461
|
+
bump: 'patch',
|
|
462
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
463
|
+
pkg: {
|
|
464
|
+
version: '100.0.0-amazing.0'
|
|
465
|
+
}
|
|
466
|
+
})
|
|
467
|
+
await exec('--release-as 100.0.0-amazing.0+build.1234 --prerelease amazing')
|
|
468
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.1+build.1234')
|
|
469
|
+
})
|
|
470
|
+
|
|
471
|
+
it('release 100.0.0-amazing.3 with prerelease amazing correctly sets prerelease version', async function () {
|
|
472
|
+
mock({
|
|
473
|
+
bump: 'patch',
|
|
474
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
475
|
+
pkg: {
|
|
476
|
+
version: '100.0.0-amazing.0'
|
|
477
|
+
}
|
|
478
|
+
})
|
|
479
|
+
await exec('--release-as 100.0.0-amazing.3 --prerelease amazing')
|
|
480
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.3')
|
|
403
481
|
})
|
|
404
482
|
})
|
|
405
483
|
|
|
@@ -427,6 +505,19 @@ describe('cli', function () {
|
|
|
427
505
|
await exec('--prerelease dev')
|
|
428
506
|
getPackageVersion().should.equal('1.1.0-dev.2')
|
|
429
507
|
})
|
|
508
|
+
|
|
509
|
+
it('exits with error if an invalid release version is provided', async function () {
|
|
510
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
511
|
+
|
|
512
|
+
expect(exec('--release-as 10.2')).to.be.rejectedWith(/releaseAs must be one of/)
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
it('exits with error if release version conflicts with prerelease', async function () {
|
|
516
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
517
|
+
|
|
518
|
+
expect(exec('--release-as 1.2.3-amazing.2 --prerelease awesome')).to.be
|
|
519
|
+
.rejectedWith(/releaseAs and prerelease have conflicting prerelease identifiers/)
|
|
520
|
+
})
|
|
430
521
|
})
|
|
431
522
|
|
|
432
523
|
it('appends line feed at end of package.json', async function () {
|
|
@@ -478,35 +569,20 @@ describe('commit-and-tag-version', function () {
|
|
|
478
569
|
|
|
479
570
|
it('should exit on bump error', async function () {
|
|
480
571
|
mock({ bump: new Error('bump err') })
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
/* istanbul ignore next */
|
|
484
|
-
throw new Error('Unexpected success')
|
|
485
|
-
} catch (err) {
|
|
486
|
-
err.message.should.match(/bump err/)
|
|
487
|
-
}
|
|
572
|
+
|
|
573
|
+
expect(exec()).to.be.rejectedWith(/bump err/)
|
|
488
574
|
})
|
|
489
575
|
|
|
490
576
|
it('should exit on changelog error', async function () {
|
|
491
577
|
mock({ bump: 'minor', changelog: new Error('changelog err') })
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
/* istanbul ignore next */
|
|
495
|
-
throw new Error('Unexpected success')
|
|
496
|
-
} catch (err) {
|
|
497
|
-
err.message.should.match(/changelog err/)
|
|
498
|
-
}
|
|
578
|
+
|
|
579
|
+
expect(exec()).to.be.rejectedWith(/changelog err/)
|
|
499
580
|
})
|
|
500
581
|
|
|
501
582
|
it('should exit with error without a package file to bump', async function () {
|
|
502
583
|
mock({ bump: 'patch', pkg: false })
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
/* istanbul ignore next */
|
|
506
|
-
throw new Error('Unexpected success')
|
|
507
|
-
} catch (err) {
|
|
508
|
-
err.message.should.equal('no package file found')
|
|
509
|
-
}
|
|
584
|
+
|
|
585
|
+
expect(exec({ gitTagFallback: false })).to.be.rejectedWith('no package file found')
|
|
510
586
|
})
|
|
511
587
|
|
|
512
588
|
it('bumps version # in bower.json', async function () {
|
|
@@ -693,6 +769,22 @@ describe('commit-and-tag-version', function () {
|
|
|
693
769
|
fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
|
|
694
770
|
})
|
|
695
771
|
|
|
772
|
+
it('bumps version in .NET `Project.csproj` file', async function () {
|
|
773
|
+
const expected = fs.readFileSync('./test/mocks/Project-6.4.0.csproj', 'utf-8')
|
|
774
|
+
const filename = 'Project.csproj'
|
|
775
|
+
mock({
|
|
776
|
+
bump: 'minor',
|
|
777
|
+
fs: {
|
|
778
|
+
[filename]: fs.readFileSync('./test/mocks/Project-6.3.1.csproj')
|
|
779
|
+
}
|
|
780
|
+
})
|
|
781
|
+
await exec({
|
|
782
|
+
packageFiles: [{ filename, type: 'csproj' }],
|
|
783
|
+
bumpFiles: [{ filename, type: 'csproj' }]
|
|
784
|
+
})
|
|
785
|
+
fs.readFileSync(filename, 'utf-8').should.equal(expected)
|
|
786
|
+
})
|
|
787
|
+
|
|
696
788
|
it('bumps version # in npm-shrinkwrap.json', async function () {
|
|
697
789
|
mock({
|
|
698
790
|
bump: 'minor',
|
|
@@ -880,24 +972,20 @@ describe('with mocked git', function () {
|
|
|
880
972
|
|
|
881
973
|
it('fails if git add fails', async function () {
|
|
882
974
|
const gitArgs = [['add', 'CHANGELOG.md', 'package.json']]
|
|
975
|
+
const gitError = new Error('Command failed: git\nfailed add')
|
|
883
976
|
const execFile = (_args, cmd, cmdArgs) => {
|
|
884
977
|
cmd.should.equal('git')
|
|
885
978
|
const expected = gitArgs.shift()
|
|
886
979
|
cmdArgs.should.deep.equal(expected)
|
|
980
|
+
|
|
887
981
|
if (expected[0] === 'add') {
|
|
888
|
-
return Promise.reject(
|
|
982
|
+
return Promise.reject(gitError)
|
|
889
983
|
}
|
|
890
984
|
return Promise.resolve('')
|
|
891
985
|
}
|
|
892
986
|
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
893
987
|
|
|
894
|
-
|
|
895
|
-
await exec({}, true)
|
|
896
|
-
/* istanbul ignore next */
|
|
897
|
-
throw new Error('Unexpected success')
|
|
898
|
-
} catch (error) {
|
|
899
|
-
error.message.should.match(/failed add/)
|
|
900
|
-
}
|
|
988
|
+
expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
901
989
|
})
|
|
902
990
|
|
|
903
991
|
it('fails if git commit fails', async function () {
|
|
@@ -905,24 +993,19 @@ describe('with mocked git', function () {
|
|
|
905
993
|
['add', 'CHANGELOG.md', 'package.json'],
|
|
906
994
|
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1']
|
|
907
995
|
]
|
|
996
|
+
const gitError = new Error('Command failed: git\nfailed commit')
|
|
908
997
|
const execFile = (_args, cmd, cmdArgs) => {
|
|
909
998
|
cmd.should.equal('git')
|
|
910
999
|
const expected = gitArgs.shift()
|
|
911
1000
|
cmdArgs.should.deep.equal(expected)
|
|
912
1001
|
if (expected[0] === 'commit') {
|
|
913
|
-
return Promise.reject(
|
|
1002
|
+
return Promise.reject(gitError)
|
|
914
1003
|
}
|
|
915
1004
|
return Promise.resolve('')
|
|
916
1005
|
}
|
|
917
1006
|
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
918
1007
|
|
|
919
|
-
|
|
920
|
-
await exec({}, true)
|
|
921
|
-
/* istanbul ignore next */
|
|
922
|
-
throw new Error('Unexpected success')
|
|
923
|
-
} catch (error) {
|
|
924
|
-
error.message.should.match(/failed commit/)
|
|
925
|
-
}
|
|
1008
|
+
expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
926
1009
|
})
|
|
927
1010
|
|
|
928
1011
|
it('fails if git tag fails', async function () {
|
|
@@ -931,23 +1014,18 @@ describe('with mocked git', function () {
|
|
|
931
1014
|
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'],
|
|
932
1015
|
['tag', '-a', 'v1.0.1', '-m', 'chore(release): 1.0.1']
|
|
933
1016
|
]
|
|
1017
|
+
const gitError = new Error('Command failed: git\nfailed tag')
|
|
934
1018
|
const execFile = (_args, cmd, cmdArgs) => {
|
|
935
1019
|
cmd.should.equal('git')
|
|
936
1020
|
const expected = gitArgs.shift()
|
|
937
1021
|
cmdArgs.should.deep.equal(expected)
|
|
938
1022
|
if (expected[0] === 'tag') {
|
|
939
|
-
return Promise.reject(
|
|
1023
|
+
return Promise.reject(gitError)
|
|
940
1024
|
}
|
|
941
1025
|
return Promise.resolve('')
|
|
942
1026
|
}
|
|
943
1027
|
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
944
1028
|
|
|
945
|
-
|
|
946
|
-
await exec({}, true)
|
|
947
|
-
/* istanbul ignore next */
|
|
948
|
-
throw new Error('Unexpected success')
|
|
949
|
-
} catch (error) {
|
|
950
|
-
error.message.should.match(/failed tag/)
|
|
951
|
-
}
|
|
1029
|
+
expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
952
1030
|
})
|
|
953
1031
|
})
|
package/test/git.spec.js
CHANGED
|
@@ -8,7 +8,9 @@ const { Readable } = require('stream')
|
|
|
8
8
|
const mockery = require('mockery')
|
|
9
9
|
const stdMocks = require('std-mocks')
|
|
10
10
|
|
|
11
|
-
require('chai')
|
|
11
|
+
const chai = require('chai')
|
|
12
|
+
const expect = chai.expect
|
|
13
|
+
chai.use(require('chai-as-promised'))
|
|
12
14
|
|
|
13
15
|
function exec (opt = '') {
|
|
14
16
|
if (typeof opt === 'string') {
|
|
@@ -356,13 +358,7 @@ describe('git', function () {
|
|
|
356
358
|
)
|
|
357
359
|
|
|
358
360
|
mock({ bump: 'minor' })
|
|
359
|
-
|
|
360
|
-
await exec('--patch')
|
|
361
|
-
/* istanbul ignore next */
|
|
362
|
-
throw new Error('Unexpected success')
|
|
363
|
-
} catch (error) {
|
|
364
|
-
error.message.should.match(/precommit-failure/)
|
|
365
|
-
}
|
|
361
|
+
expect(exec('--patch')).to.be.rejectedWith(/precommit-failure/)
|
|
366
362
|
})
|
|
367
363
|
|
|
368
364
|
it('should allow an alternate commit message to be provided by precommit script', async function () {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<TargetFramework>net7.0</TargetFramework>
|
|
5
|
+
<Nullable>enable</Nullable>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<Version>6.3.1</Version>
|
|
8
|
+
</PropertyGroup>
|
|
9
|
+
|
|
10
|
+
<ItemGroup>
|
|
11
|
+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10"/>
|
|
12
|
+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.10"/>
|
|
13
|
+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10"/>
|
|
14
|
+
<PackageReference Include="Microsoft.Identity.Web" Version="1.16.0"/>
|
|
15
|
+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
|
|
16
|
+
</ItemGroup>
|
|
17
|
+
|
|
18
|
+
</Project>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<TargetFramework>net7.0</TargetFramework>
|
|
5
|
+
<Nullable>enable</Nullable>
|
|
6
|
+
<ImplicitUsings>enable</ImplicitUsings>
|
|
7
|
+
<Version>6.4.0</Version>
|
|
8
|
+
</PropertyGroup>
|
|
9
|
+
|
|
10
|
+
<ItemGroup>
|
|
11
|
+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10"/>
|
|
12
|
+
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="7.0.10"/>
|
|
13
|
+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.10"/>
|
|
14
|
+
<PackageReference Include="Microsoft.Identity.Web" Version="1.16.0"/>
|
|
15
|
+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
|
|
16
|
+
</ItemGroup>
|
|
17
|
+
|
|
18
|
+
</Project>
|