commit-and-tag-version 11.2.4 → 12.0.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/.eslintrc +10 -2
- package/.github/dependabot.yml +19 -0
- package/.github/workflows/ci.yaml +3 -3
- package/.github/workflows/release-please.yml +3 -3
- package/CHANGELOG.md +19 -0
- package/README.md +11 -1
- package/lib/lifecycles/changelog.js +28 -7
- package/lib/updaters/index.js +5 -1
- package/lib/updaters/types/csproj.js +13 -0
- package/package.json +13 -11
- package/test/config-files.spec.js +1 -1
- package/test/core.spec.js +610 -539
- package/test/git.spec.js +6 -6
- package/test/mocks/Project-6.3.1.csproj +18 -0
- package/test/mocks/Project-6.4.0.csproj +18 -0
- package/test/preset.spec.js +1 -1
- package/test/utils.spec.js +1 -1
- package/renovate.json +0 -9
package/test/core.spec.js
CHANGED
|
@@ -165,17 +165,73 @@ describe('cli', function () {
|
|
|
165
165
|
})
|
|
166
166
|
|
|
167
167
|
describe('CHANGELOG.md exists', function () {
|
|
168
|
-
it('appends the new release above the last release, removing the old header (legacy format)', async function () {
|
|
168
|
+
it('appends the new release above the last release, removing the old header (legacy format), and does not retain any front matter', async function () {
|
|
169
|
+
const frontMatter =
|
|
170
|
+
'---\nstatus: new\n---\n'
|
|
169
171
|
mock({
|
|
170
172
|
bump: 'patch',
|
|
171
173
|
changelog: 'release 1.0.1\n',
|
|
172
|
-
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' },
|
|
174
|
+
fs: { 'CHANGELOG.md': frontMatter + 'legacy header format<a name="1.0.0">\n' },
|
|
173
175
|
tags: ['v1.0.0']
|
|
174
176
|
})
|
|
175
177
|
await exec()
|
|
176
178
|
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
177
179
|
content.should.match(/1\.0\.1/)
|
|
178
180
|
content.should.not.match(/legacy header format/)
|
|
181
|
+
content.should.not.match(/---status: new---/)
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('appends the new release above the last release, replacing the old header (standard-version format) with header (new format), and retains any front matter', async function () {
|
|
185
|
+
const { header } = require('../defaults')
|
|
186
|
+
|
|
187
|
+
const standardVersionHeader =
|
|
188
|
+
'# Changelog\n\nAll notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.'
|
|
189
|
+
|
|
190
|
+
const frontMatter =
|
|
191
|
+
'---\nstatus: new\n---\n'
|
|
192
|
+
|
|
193
|
+
const changelog101 =
|
|
194
|
+
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n'
|
|
195
|
+
|
|
196
|
+
const changelog100 =
|
|
197
|
+
'### [1.0.0](/compare/v0.0.1...v1.0.0) (YYYY-MM-DD)\n\n\n### Features\n\n* Version one feature set\n'
|
|
198
|
+
|
|
199
|
+
const initialChangelog = frontMatter + '\n' + standardVersionHeader + '\n' + changelog100
|
|
200
|
+
|
|
201
|
+
mock({
|
|
202
|
+
bump: 'patch',
|
|
203
|
+
changelog: changelog101,
|
|
204
|
+
fs: { 'CHANGELOG.md': initialChangelog },
|
|
205
|
+
tags: ['v1.0.0']
|
|
206
|
+
})
|
|
207
|
+
await exec()
|
|
208
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
209
|
+
content.should.equal(frontMatter + '\n' + header + '\n' + changelog101 + changelog100)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('appends the new release above the last release, removing the old header (new format), and retains any front matter', async function () {
|
|
213
|
+
const { header } = require('../defaults')
|
|
214
|
+
const frontMatter =
|
|
215
|
+
'---\nstatus: new\n---\n'
|
|
216
|
+
|
|
217
|
+
const changelog101 =
|
|
218
|
+
'### [1.0.1](/compare/v1.0.0...v1.0.1) (YYYY-MM-DD)\n\n\n### Bug Fixes\n\n* patch release ABCDEFXY\n'
|
|
219
|
+
|
|
220
|
+
const changelog100 =
|
|
221
|
+
'### [1.0.0](/compare/v0.0.1...v1.0.0) (YYYY-MM-DD)\n\n\n### Features\n\n* Version one feature set\n'
|
|
222
|
+
|
|
223
|
+
const initialChangelog = frontMatter + '\n' + header + '\n' + changelog100
|
|
224
|
+
|
|
225
|
+
mock({
|
|
226
|
+
bump: 'patch',
|
|
227
|
+
changelog: changelog101,
|
|
228
|
+
fs: { 'CHANGELOG.md': initialChangelog },
|
|
229
|
+
tags: ['v1.0.0']
|
|
230
|
+
})
|
|
231
|
+
await exec()
|
|
232
|
+
|
|
233
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
234
|
+
content.should.equal(frontMatter + '\n' + header + '\n' + changelog101 + changelog100)
|
|
179
235
|
})
|
|
180
236
|
|
|
181
237
|
it('appends the new release above the last release, removing the old header (new format)', async function () {
|
|
@@ -215,11 +271,11 @@ describe('cli', function () {
|
|
|
215
271
|
|
|
216
272
|
it('[DEPRECATED] (--changelogHeader) exits with error if changelog header matches last version search regex', async function () {
|
|
217
273
|
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
218
|
-
expect(exec('--changelogHeader="## 3.0.2"')).to.be.rejectedWith(/custom changelog header must not match/)
|
|
274
|
+
await expect(exec('--changelogHeader="## 3.0.2"')).to.be.rejectedWith(/custom changelog header must not match/)
|
|
219
275
|
})
|
|
220
276
|
})
|
|
221
277
|
|
|
222
|
-
describe('lifecycle scripts', ()
|
|
278
|
+
describe('lifecycle scripts', function () {
|
|
223
279
|
describe('prerelease hook', function () {
|
|
224
280
|
it('should run the prerelease hook when provided', async function () {
|
|
225
281
|
const flush = mock({
|
|
@@ -242,7 +298,7 @@ describe('cli', function () {
|
|
|
242
298
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
243
299
|
})
|
|
244
300
|
|
|
245
|
-
expect(exec({
|
|
301
|
+
await expect(exec({
|
|
246
302
|
scripts: {
|
|
247
303
|
prerelease: "node -e \"throw new Error('prerelease' + ' fail')\""
|
|
248
304
|
}
|
|
@@ -332,684 +388,699 @@ describe('cli', function () {
|
|
|
332
388
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
333
389
|
})
|
|
334
390
|
|
|
335
|
-
expect(exec({
|
|
391
|
+
await expect(exec({
|
|
336
392
|
scripts: {
|
|
337
393
|
postbump: "node -e \"throw new Error('postbump' + ' fail')\""
|
|
338
394
|
}
|
|
339
395
|
})).to.be.rejectedWith(/postbump fail/)
|
|
340
|
-
expect(exec('--patch')).to.be.rejectedWith(/postbump fail/)
|
|
341
396
|
})
|
|
342
397
|
})
|
|
343
|
-
})
|
|
344
398
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
399
|
+
describe('manual-release', function () {
|
|
400
|
+
describe('release-types', function () {
|
|
401
|
+
const regularTypes = ['major', 'minor', 'patch']
|
|
402
|
+
const nextVersion = { major: '2.0.0', minor: '1.1.0', patch: '1.0.1' }
|
|
403
|
+
|
|
404
|
+
regularTypes.forEach(function (type) {
|
|
405
|
+
it('creates a ' + type + ' release', async function () {
|
|
406
|
+
mock({
|
|
407
|
+
bump: 'patch',
|
|
408
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
409
|
+
})
|
|
410
|
+
await exec('--release-as ' + type)
|
|
411
|
+
getPackageVersion().should.equal(nextVersion[type])
|
|
412
|
+
})
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
// this is for pre-releases
|
|
416
|
+
regularTypes.forEach(function (type) {
|
|
417
|
+
it('creates a pre' + type + ' release', async function () {
|
|
418
|
+
mock({
|
|
419
|
+
bump: 'patch',
|
|
420
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
421
|
+
})
|
|
422
|
+
await exec('--release-as ' + type + ' --prerelease ' + type)
|
|
423
|
+
getPackageVersion().should.equal(`${nextVersion[type]}-${type}.0`)
|
|
424
|
+
})
|
|
425
|
+
})
|
|
426
|
+
|
|
427
|
+
it('exits with error if an invalid release type is provided', async function () {
|
|
428
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
429
|
+
|
|
430
|
+
await expect(exec('--release-as invalid')).to.be.rejectedWith(/releaseAs must be one of/)
|
|
431
|
+
})
|
|
432
|
+
})
|
|
349
433
|
|
|
350
|
-
|
|
351
|
-
it('
|
|
434
|
+
describe('release-as-exact', function () {
|
|
435
|
+
it('releases as v100.0.0', async function () {
|
|
352
436
|
mock({
|
|
353
437
|
bump: 'patch',
|
|
354
438
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
355
439
|
})
|
|
356
|
-
await exec('--release-as '
|
|
357
|
-
getPackageVersion().should.equal(
|
|
440
|
+
await exec('--release-as v100.0.0')
|
|
441
|
+
getPackageVersion().should.equal('100.0.0')
|
|
358
442
|
})
|
|
359
|
-
})
|
|
360
443
|
|
|
361
|
-
|
|
362
|
-
regularTypes.forEach(function (type) {
|
|
363
|
-
it('creates a pre' + type + ' release', async function () {
|
|
444
|
+
it('releases as 200.0.0-amazing', async function () {
|
|
364
445
|
mock({
|
|
365
446
|
bump: 'patch',
|
|
366
447
|
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
367
448
|
})
|
|
368
|
-
await exec('--release-as '
|
|
369
|
-
getPackageVersion().should.equal(
|
|
449
|
+
await exec('--release-as 200.0.0-amazing')
|
|
450
|
+
getPackageVersion().should.equal('200.0.0-amazing')
|
|
370
451
|
})
|
|
371
|
-
})
|
|
372
|
-
|
|
373
|
-
it('exits with error if an invalid release type is provided', async function () {
|
|
374
|
-
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
375
452
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
453
|
+
it('releases as 100.0.0 with prerelease amazing', async function () {
|
|
454
|
+
mock({
|
|
455
|
+
bump: 'patch',
|
|
456
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' },
|
|
457
|
+
pkg: {
|
|
458
|
+
version: '1.0.0'
|
|
459
|
+
}
|
|
460
|
+
})
|
|
461
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
462
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
385
463
|
})
|
|
386
|
-
await exec('--release-as v100.0.0')
|
|
387
|
-
getPackageVersion().should.equal('100.0.0')
|
|
388
|
-
})
|
|
389
464
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
465
|
+
it('release 100.0.0 with prerelease amazing bumps build', async function () {
|
|
466
|
+
mock({
|
|
467
|
+
bump: 'patch',
|
|
468
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
469
|
+
pkg: {
|
|
470
|
+
version: '100.0.0-amazing.0'
|
|
471
|
+
}
|
|
472
|
+
})
|
|
473
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
474
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.1')
|
|
394
475
|
})
|
|
395
|
-
await exec('--release-as 200.0.0-amazing')
|
|
396
|
-
getPackageVersion().should.equal('200.0.0-amazing')
|
|
397
|
-
})
|
|
398
476
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
477
|
+
it('release 100.0.0-amazing.0 with prerelease amazing bumps build', async function () {
|
|
478
|
+
mock({
|
|
479
|
+
bump: 'patch',
|
|
480
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
481
|
+
pkg: {
|
|
482
|
+
version: '100.0.0-amazing.1'
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
486
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.2')
|
|
406
487
|
})
|
|
407
|
-
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
408
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
409
|
-
})
|
|
410
488
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
489
|
+
it('release 100.0.0 with prerelease amazing correctly sets version', async function () {
|
|
490
|
+
mock({
|
|
491
|
+
bump: 'patch',
|
|
492
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
493
|
+
pkg: {
|
|
494
|
+
version: '99.0.0-amazing.0'
|
|
495
|
+
}
|
|
496
|
+
})
|
|
497
|
+
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
498
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
418
499
|
})
|
|
419
|
-
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
420
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.1')
|
|
421
|
-
})
|
|
422
500
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
501
|
+
it('release 100.0.0-amazing.0 with prerelease amazing correctly sets version', async function () {
|
|
502
|
+
mock({
|
|
503
|
+
bump: 'patch',
|
|
504
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
505
|
+
pkg: {
|
|
506
|
+
version: '99.0.0-amazing.0'
|
|
507
|
+
}
|
|
508
|
+
})
|
|
509
|
+
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
510
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
430
511
|
})
|
|
431
|
-
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
432
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.2')
|
|
433
|
-
})
|
|
434
512
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
513
|
+
it('release 100.0.0-amazing.0 with prerelease amazing retains build metadata', async function () {
|
|
514
|
+
mock({
|
|
515
|
+
bump: 'patch',
|
|
516
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
517
|
+
pkg: {
|
|
518
|
+
version: '100.0.0-amazing.0'
|
|
519
|
+
}
|
|
520
|
+
})
|
|
521
|
+
await exec('--release-as 100.0.0-amazing.0+build.1234 --prerelease amazing')
|
|
522
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.1+build.1234')
|
|
442
523
|
})
|
|
443
|
-
await exec('--release-as 100.0.0 --prerelease amazing')
|
|
444
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
445
|
-
})
|
|
446
524
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
525
|
+
it('release 100.0.0-amazing.3 with prerelease amazing correctly sets prerelease version', async function () {
|
|
526
|
+
mock({
|
|
527
|
+
bump: 'patch',
|
|
528
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="100.0.0-amazing.0">\n' },
|
|
529
|
+
pkg: {
|
|
530
|
+
version: '100.0.0-amazing.0'
|
|
531
|
+
}
|
|
532
|
+
})
|
|
533
|
+
await exec('--release-as 100.0.0-amazing.3 --prerelease amazing')
|
|
534
|
+
should.equal(getPackageVersion(), '100.0.0-amazing.3')
|
|
454
535
|
})
|
|
455
|
-
await exec('--release-as 100.0.0-amazing.0 --prerelease amazing')
|
|
456
|
-
should.equal(getPackageVersion(), '100.0.0-amazing.0')
|
|
457
536
|
})
|
|
458
537
|
|
|
459
|
-
it('
|
|
538
|
+
it('creates a prerelease with a new minor version after two prerelease patches', async function () {
|
|
539
|
+
let releaseType = 'patch'
|
|
540
|
+
const bump = (_, __, cb) => cb(null, { releaseType })
|
|
460
541
|
mock({
|
|
461
|
-
bump
|
|
462
|
-
fs: { 'CHANGELOG.md': 'legacy header format<a name="
|
|
463
|
-
pkg: {
|
|
464
|
-
version: '100.0.0-amazing.0'
|
|
465
|
-
}
|
|
542
|
+
bump,
|
|
543
|
+
fs: { 'CHANGELOG.md': 'legacy header format<a name="1.0.0">\n' }
|
|
466
544
|
})
|
|
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
545
|
|
|
471
|
-
|
|
472
|
-
|
|
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')
|
|
481
|
-
})
|
|
482
|
-
})
|
|
546
|
+
await exec('--release-as patch --prerelease dev')
|
|
547
|
+
getPackageVersion().should.equal('1.0.1-dev.0')
|
|
483
548
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
549
|
+
await exec('--prerelease dev')
|
|
550
|
+
getPackageVersion().should.equal('1.0.1-dev.1')
|
|
551
|
+
|
|
552
|
+
releaseType = 'minor'
|
|
553
|
+
await exec('--release-as minor --prerelease dev')
|
|
554
|
+
getPackageVersion().should.equal('1.1.0-dev.0')
|
|
555
|
+
|
|
556
|
+
await exec('--release-as minor --prerelease dev')
|
|
557
|
+
getPackageVersion().should.equal('1.1.0-dev.1')
|
|
558
|
+
|
|
559
|
+
await exec('--prerelease dev')
|
|
560
|
+
getPackageVersion().should.equal('1.1.0-dev.2')
|
|
490
561
|
})
|
|
491
562
|
|
|
492
|
-
|
|
493
|
-
|
|
563
|
+
it('exits with error if an invalid release version is provided', async function () {
|
|
564
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
494
565
|
|
|
495
|
-
|
|
496
|
-
|
|
566
|
+
await expect(exec('--release-as 10.2')).to.be.rejectedWith(/releaseAs must be one of/)
|
|
567
|
+
})
|
|
497
568
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
getPackageVersion().should.equal('1.1.0-dev.0')
|
|
569
|
+
it('exits with error if release version conflicts with prerelease', async function () {
|
|
570
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
501
571
|
|
|
502
|
-
|
|
503
|
-
|
|
572
|
+
await expect(exec('--release-as 1.2.3-amazing.2 --prerelease awesome')).to.be
|
|
573
|
+
.rejectedWith(/releaseAs and prerelease have conflicting prerelease identifiers/)
|
|
574
|
+
})
|
|
575
|
+
})
|
|
504
576
|
|
|
505
|
-
|
|
506
|
-
|
|
577
|
+
it('appends line feed at end of package.json', async function () {
|
|
578
|
+
mock({ bump: 'patch' })
|
|
579
|
+
await exec()
|
|
580
|
+
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
581
|
+
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
507
582
|
})
|
|
508
583
|
|
|
509
|
-
it('
|
|
510
|
-
mock({
|
|
584
|
+
it('preserves indentation of tabs in package.json', async function () {
|
|
585
|
+
mock({
|
|
586
|
+
bump: 'patch',
|
|
587
|
+
fs: { 'package.json': '{\n\t"version": "1.0.0"\n}\n' }
|
|
588
|
+
})
|
|
589
|
+
await exec()
|
|
590
|
+
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
591
|
+
pkgJson.should.equal('{\n\t"version": "1.0.1"\n}\n')
|
|
592
|
+
})
|
|
511
593
|
|
|
512
|
-
|
|
594
|
+
it('preserves indentation of spaces in package.json', async function () {
|
|
595
|
+
mock({
|
|
596
|
+
bump: 'patch',
|
|
597
|
+
fs: { 'package.json': '{\n "version": "1.0.0"\n}\n' }
|
|
598
|
+
})
|
|
599
|
+
await exec()
|
|
600
|
+
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
601
|
+
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
513
602
|
})
|
|
514
603
|
|
|
515
|
-
it('
|
|
516
|
-
mock({
|
|
604
|
+
it('preserves carriage return + line feed in package.json', async function () {
|
|
605
|
+
mock({
|
|
606
|
+
bump: 'patch',
|
|
607
|
+
fs: { 'package.json': '{\r\n "version": "1.0.0"\r\n}\r\n' }
|
|
608
|
+
})
|
|
609
|
+
await exec()
|
|
610
|
+
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
611
|
+
pkgJson.should.equal('{\r\n "version": "1.0.1"\r\n}\r\n')
|
|
612
|
+
})
|
|
517
613
|
|
|
518
|
-
|
|
519
|
-
|
|
614
|
+
it('does not print output when the --silent flag is passed', async function () {
|
|
615
|
+
const flush = mock()
|
|
616
|
+
await exec('--silent')
|
|
617
|
+
flush().should.eql({ stdout: [], stderr: [] })
|
|
520
618
|
})
|
|
521
619
|
})
|
|
522
620
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
await exec()
|
|
526
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
527
|
-
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
528
|
-
})
|
|
621
|
+
describe('commit-and-tag-version', function () {
|
|
622
|
+
afterEach(unmock)
|
|
529
623
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
bump: 'patch',
|
|
533
|
-
fs: { 'package.json': '{\n\t"version": "1.0.0"\n}\n' }
|
|
534
|
-
})
|
|
535
|
-
await exec()
|
|
536
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
537
|
-
pkgJson.should.equal('{\n\t"version": "1.0.1"\n}\n')
|
|
538
|
-
})
|
|
624
|
+
it('should exit on bump error', async function () {
|
|
625
|
+
mock({ bump: new Error('bump err') })
|
|
539
626
|
|
|
540
|
-
|
|
541
|
-
mock({
|
|
542
|
-
bump: 'patch',
|
|
543
|
-
fs: { 'package.json': '{\n "version": "1.0.0"\n}\n' }
|
|
627
|
+
await expect(exec()).to.be.rejectedWith(/bump err/)
|
|
544
628
|
})
|
|
545
|
-
await exec()
|
|
546
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
547
|
-
pkgJson.should.equal('{\n "version": "1.0.1"\n}\n')
|
|
548
|
-
})
|
|
549
629
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
630
|
+
it('should exit on changelog error', async function () {
|
|
631
|
+
mock({ bump: 'minor', changelog: new Error('changelog err') })
|
|
632
|
+
|
|
633
|
+
await expect(exec()).to.be.rejectedWith(/changelog err/)
|
|
554
634
|
})
|
|
555
|
-
await exec()
|
|
556
|
-
const pkgJson = fs.readFileSync('package.json', 'utf-8')
|
|
557
|
-
pkgJson.should.equal('{\r\n "version": "1.0.1"\r\n}\r\n')
|
|
558
|
-
})
|
|
559
635
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
await exec('--silent')
|
|
563
|
-
flush().should.eql({ stdout: [], stderr: [] })
|
|
564
|
-
})
|
|
565
|
-
})
|
|
636
|
+
it('should exit with error without a package file to bump', async function () {
|
|
637
|
+
mock({ bump: 'patch', pkg: false })
|
|
566
638
|
|
|
567
|
-
|
|
568
|
-
|
|
639
|
+
await expect(exec({ gitTagFallback: false })).to.be.rejectedWith('no package file found')
|
|
640
|
+
})
|
|
569
641
|
|
|
570
|
-
|
|
571
|
-
|
|
642
|
+
it('bumps version # in bower.json', async function () {
|
|
643
|
+
mock({
|
|
644
|
+
bump: 'minor',
|
|
645
|
+
fs: { 'bower.json': JSON.stringify({ version: '1.0.0' }) },
|
|
646
|
+
tags: ['v1.0.0']
|
|
647
|
+
})
|
|
648
|
+
await exec()
|
|
649
|
+
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal(
|
|
650
|
+
'1.1.0'
|
|
651
|
+
)
|
|
652
|
+
getPackageVersion().should.equal('1.1.0')
|
|
653
|
+
})
|
|
572
654
|
|
|
573
|
-
|
|
574
|
-
|
|
655
|
+
it('bumps version # in manifest.json', async function () {
|
|
656
|
+
mock({
|
|
657
|
+
bump: 'minor',
|
|
658
|
+
fs: { 'manifest.json': JSON.stringify({ version: '1.0.0' }) },
|
|
659
|
+
tags: ['v1.0.0']
|
|
660
|
+
})
|
|
661
|
+
await exec()
|
|
662
|
+
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal(
|
|
663
|
+
'1.1.0'
|
|
664
|
+
)
|
|
665
|
+
getPackageVersion().should.equal('1.1.0')
|
|
666
|
+
})
|
|
575
667
|
|
|
576
|
-
|
|
577
|
-
|
|
668
|
+
describe('custom `bumpFiles` support', function () {
|
|
669
|
+
it('mix.exs + version.txt', async function () {
|
|
670
|
+
const updater = 'custom-updater.js'
|
|
671
|
+
const updaterModule = require('./mocks/updater/customer-updater')
|
|
672
|
+
mock({
|
|
673
|
+
bump: 'minor',
|
|
674
|
+
fs: {
|
|
675
|
+
'mix.exs': fs.readFileSync('./test/mocks/mix.exs'),
|
|
676
|
+
'version.txt': fs.readFileSync('./test/mocks/version.txt')
|
|
677
|
+
},
|
|
678
|
+
tags: ['v1.0.0']
|
|
679
|
+
})
|
|
680
|
+
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
|
|
578
681
|
|
|
579
|
-
|
|
580
|
-
|
|
682
|
+
await exec({
|
|
683
|
+
bumpFiles: [
|
|
684
|
+
'version.txt',
|
|
685
|
+
{ filename: 'mix.exs', updater: 'custom-updater.js' }
|
|
686
|
+
]
|
|
687
|
+
})
|
|
688
|
+
fs.readFileSync('mix.exs', 'utf-8').should.contain('version: "1.1.0"')
|
|
689
|
+
fs.readFileSync('version.txt', 'utf-8').should.equal('1.1.0')
|
|
690
|
+
})
|
|
581
691
|
|
|
582
|
-
|
|
583
|
-
|
|
692
|
+
it('bumps a custom `plain-text` file', async function () {
|
|
693
|
+
mock({
|
|
694
|
+
bump: 'minor',
|
|
695
|
+
fs: {
|
|
696
|
+
'VERSION_TRACKER.txt': fs.readFileSync(
|
|
697
|
+
'./test/mocks/VERSION-1.0.0.txt'
|
|
698
|
+
)
|
|
699
|
+
}
|
|
700
|
+
})
|
|
701
|
+
await exec({
|
|
702
|
+
bumpFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }]
|
|
703
|
+
})
|
|
704
|
+
fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('1.1.0')
|
|
705
|
+
})
|
|
584
706
|
|
|
585
|
-
|
|
586
|
-
|
|
707
|
+
it('displays the new version from custom bumper with --dry-run', async function () {
|
|
708
|
+
const updater = 'increment-updater.js'
|
|
709
|
+
const updaterModule = require('./mocks/updater/increment-updater')
|
|
710
|
+
mock({
|
|
711
|
+
bump: 'minor',
|
|
712
|
+
fs: {
|
|
713
|
+
'increment-version.txt': fs.readFileSync(
|
|
714
|
+
'./test/mocks/increment-version.txt'
|
|
715
|
+
)
|
|
716
|
+
}
|
|
717
|
+
})
|
|
718
|
+
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
|
|
587
719
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
720
|
+
const origInfo = console.info
|
|
721
|
+
const capturedOutput = []
|
|
722
|
+
console.info = (...args) => {
|
|
723
|
+
capturedOutput.push(...args)
|
|
724
|
+
origInfo(...args)
|
|
725
|
+
}
|
|
726
|
+
try {
|
|
727
|
+
await exec({
|
|
728
|
+
bumpFiles: [{ filename: 'increment-version.txt', updater: 'increment-updater.js' }],
|
|
729
|
+
dryRun: true
|
|
730
|
+
})
|
|
731
|
+
const logOutput = capturedOutput.join(' ')
|
|
732
|
+
stripAnsi(logOutput).should.include('bumping version in increment-version.txt from 1 to 2')
|
|
733
|
+
} finally {
|
|
734
|
+
console.info = origInfo
|
|
735
|
+
}
|
|
736
|
+
})
|
|
593
737
|
})
|
|
594
|
-
await exec()
|
|
595
|
-
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal(
|
|
596
|
-
'1.1.0'
|
|
597
|
-
)
|
|
598
|
-
getPackageVersion().should.equal('1.1.0')
|
|
599
|
-
})
|
|
600
738
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
739
|
+
describe('custom `packageFiles` support', function () {
|
|
740
|
+
it('reads and writes to a custom `plain-text` file', async function () {
|
|
741
|
+
mock({
|
|
742
|
+
bump: 'minor',
|
|
743
|
+
fs: {
|
|
744
|
+
'VERSION_TRACKER.txt': fs.readFileSync(
|
|
745
|
+
'./test/mocks/VERSION-6.3.1.txt'
|
|
746
|
+
)
|
|
747
|
+
}
|
|
748
|
+
})
|
|
749
|
+
await exec({
|
|
750
|
+
packageFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }],
|
|
751
|
+
bumpFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }]
|
|
752
|
+
})
|
|
753
|
+
fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('6.4.0')
|
|
754
|
+
})
|
|
755
|
+
|
|
756
|
+
it('allows same object to be used in packageFiles and bumpFiles', async function () {
|
|
757
|
+
mock({
|
|
758
|
+
bump: 'minor',
|
|
759
|
+
fs: {
|
|
760
|
+
'VERSION_TRACKER.txt': fs.readFileSync(
|
|
761
|
+
'./test/mocks/VERSION-6.3.1.txt'
|
|
762
|
+
)
|
|
763
|
+
}
|
|
764
|
+
})
|
|
765
|
+
const origWarn = console.warn
|
|
766
|
+
console.warn = () => {
|
|
767
|
+
throw new Error('console.warn should not be called')
|
|
768
|
+
}
|
|
769
|
+
const filedesc = { filename: 'VERSION_TRACKER.txt', type: 'plain-text' }
|
|
770
|
+
try {
|
|
771
|
+
await exec({ packageFiles: [filedesc], bumpFiles: [filedesc] })
|
|
772
|
+
fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('6.4.0')
|
|
773
|
+
} finally {
|
|
774
|
+
console.warn = origWarn
|
|
775
|
+
}
|
|
776
|
+
})
|
|
606
777
|
})
|
|
607
|
-
await exec()
|
|
608
|
-
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal(
|
|
609
|
-
'1.1.0'
|
|
610
|
-
)
|
|
611
|
-
getPackageVersion().should.equal('1.1.0')
|
|
612
|
-
})
|
|
613
778
|
|
|
614
|
-
|
|
615
|
-
it('mix.exs + version.txt', async function () {
|
|
616
|
-
const updater = 'custom-updater.js'
|
|
617
|
-
const updaterModule = require('./mocks/updater/customer-updater')
|
|
779
|
+
it('`packageFiles` are bumped along with `bumpFiles` defaults [commit-and-tag-version#533]', async function () {
|
|
618
780
|
mock({
|
|
619
781
|
bump: 'minor',
|
|
620
782
|
fs: {
|
|
621
|
-
'
|
|
622
|
-
'
|
|
783
|
+
'.gitignore': '',
|
|
784
|
+
'package-lock.json': JSON.stringify({ version: '1.0.0' }),
|
|
785
|
+
'manifest.json': fs.readFileSync('./test/mocks/manifest-6.3.1.json')
|
|
623
786
|
},
|
|
624
787
|
tags: ['v1.0.0']
|
|
625
788
|
})
|
|
626
|
-
mockery.registerMock(resolve(process.cwd(), updater), updaterModule)
|
|
627
789
|
|
|
628
790
|
await exec({
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
{
|
|
791
|
+
silent: true,
|
|
792
|
+
packageFiles: [
|
|
793
|
+
{
|
|
794
|
+
filename: 'manifest.json',
|
|
795
|
+
type: 'json'
|
|
796
|
+
}
|
|
632
797
|
]
|
|
633
798
|
})
|
|
634
|
-
|
|
635
|
-
fs.readFileSync('
|
|
799
|
+
|
|
800
|
+
JSON.parse(fs.readFileSync('manifest.json', 'utf-8')).version.should.equal(
|
|
801
|
+
'6.4.0'
|
|
802
|
+
)
|
|
803
|
+
JSON.parse(fs.readFileSync('package.json', 'utf-8')).version.should.equal(
|
|
804
|
+
'6.4.0'
|
|
805
|
+
)
|
|
806
|
+
JSON.parse(
|
|
807
|
+
fs.readFileSync('package-lock.json', 'utf-8')
|
|
808
|
+
).version.should.equal('6.4.0')
|
|
636
809
|
})
|
|
637
810
|
|
|
638
|
-
it('bumps
|
|
811
|
+
it('bumps version in Gradle `build.gradle.kts` file', async function () {
|
|
812
|
+
const expected = fs.readFileSync('./test/mocks/build-6.4.0.gradle.kts', 'utf-8')
|
|
639
813
|
mock({
|
|
640
814
|
bump: 'minor',
|
|
641
815
|
fs: {
|
|
642
|
-
'
|
|
643
|
-
'./test/mocks/VERSION-1.0.0.txt'
|
|
644
|
-
)
|
|
816
|
+
'build.gradle.kts': fs.readFileSync('./test/mocks/build-6.3.1.gradle.kts')
|
|
645
817
|
}
|
|
646
818
|
})
|
|
647
819
|
await exec({
|
|
648
|
-
|
|
820
|
+
packageFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
|
|
821
|
+
bumpFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }]
|
|
649
822
|
})
|
|
650
|
-
fs.readFileSync('
|
|
823
|
+
fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
|
|
651
824
|
})
|
|
652
825
|
|
|
653
|
-
it('
|
|
654
|
-
const
|
|
655
|
-
const
|
|
826
|
+
it('bumps version in .NET `Project.csproj` file', async function () {
|
|
827
|
+
const expected = fs.readFileSync('./test/mocks/Project-6.4.0.csproj', 'utf-8')
|
|
828
|
+
const filename = 'Project.csproj'
|
|
656
829
|
mock({
|
|
657
830
|
bump: 'minor',
|
|
658
831
|
fs: {
|
|
659
|
-
|
|
660
|
-
'./test/mocks/increment-version.txt'
|
|
661
|
-
)
|
|
832
|
+
[filename]: fs.readFileSync('./test/mocks/Project-6.3.1.csproj')
|
|
662
833
|
}
|
|
663
834
|
})
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
capturedOutput.push(...args)
|
|
670
|
-
origInfo(...args)
|
|
671
|
-
}
|
|
672
|
-
try {
|
|
673
|
-
await exec({
|
|
674
|
-
bumpFiles: [{ filename: 'increment-version.txt', updater: 'increment-updater.js' }],
|
|
675
|
-
dryRun: true
|
|
676
|
-
})
|
|
677
|
-
const logOutput = capturedOutput.join(' ')
|
|
678
|
-
stripAnsi(logOutput).should.include('bumping version in increment-version.txt from 1 to 2')
|
|
679
|
-
} finally {
|
|
680
|
-
console.info = origInfo
|
|
681
|
-
}
|
|
835
|
+
await exec({
|
|
836
|
+
packageFiles: [{ filename, type: 'csproj' }],
|
|
837
|
+
bumpFiles: [{ filename, type: 'csproj' }]
|
|
838
|
+
})
|
|
839
|
+
fs.readFileSync(filename, 'utf-8').should.equal(expected)
|
|
682
840
|
})
|
|
683
|
-
})
|
|
684
841
|
|
|
685
|
-
|
|
686
|
-
it('reads and writes to a custom `plain-text` file', async function () {
|
|
842
|
+
it('bumps version # in npm-shrinkwrap.json', async function () {
|
|
687
843
|
mock({
|
|
688
844
|
bump: 'minor',
|
|
689
845
|
fs: {
|
|
690
|
-
'
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
})
|
|
695
|
-
await exec({
|
|
696
|
-
packageFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }],
|
|
697
|
-
bumpFiles: [{ filename: 'VERSION_TRACKER.txt', type: 'plain-text' }]
|
|
846
|
+
'npm-shrinkwrap.json': JSON.stringify({ version: '1.0.0' })
|
|
847
|
+
},
|
|
848
|
+
tags: ['v1.0.0']
|
|
698
849
|
})
|
|
699
|
-
|
|
850
|
+
await exec()
|
|
851
|
+
JSON.parse(
|
|
852
|
+
fs.readFileSync('npm-shrinkwrap.json', 'utf-8')
|
|
853
|
+
).version.should.equal('1.1.0')
|
|
854
|
+
getPackageVersion().should.equal('1.1.0')
|
|
700
855
|
})
|
|
701
856
|
|
|
702
|
-
it('
|
|
857
|
+
it('bumps version # in package-lock.json', async function () {
|
|
703
858
|
mock({
|
|
704
859
|
bump: 'minor',
|
|
705
860
|
fs: {
|
|
706
|
-
'
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
861
|
+
'.gitignore': '',
|
|
862
|
+
'package-lock.json': JSON.stringify({ version: '1.0.0' })
|
|
863
|
+
},
|
|
864
|
+
tags: ['v1.0.0']
|
|
710
865
|
})
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
try {
|
|
717
|
-
await exec({ packageFiles: [filedesc], bumpFiles: [filedesc] })
|
|
718
|
-
fs.readFileSync('VERSION_TRACKER.txt', 'utf-8').should.equal('6.4.0')
|
|
719
|
-
} finally {
|
|
720
|
-
console.warn = origWarn
|
|
721
|
-
}
|
|
722
|
-
})
|
|
723
|
-
})
|
|
724
|
-
|
|
725
|
-
it('`packageFiles` are bumped along with `bumpFiles` defaults [commit-and-tag-version#533]', async function () {
|
|
726
|
-
mock({
|
|
727
|
-
bump: 'minor',
|
|
728
|
-
fs: {
|
|
729
|
-
'.gitignore': '',
|
|
730
|
-
'package-lock.json': JSON.stringify({ version: '1.0.0' }),
|
|
731
|
-
'manifest.json': fs.readFileSync('./test/mocks/manifest-6.3.1.json')
|
|
732
|
-
},
|
|
733
|
-
tags: ['v1.0.0']
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
await exec({
|
|
737
|
-
silent: true,
|
|
738
|
-
packageFiles: [
|
|
739
|
-
{
|
|
740
|
-
filename: 'manifest.json',
|
|
741
|
-
type: 'json'
|
|
742
|
-
}
|
|
743
|
-
]
|
|
866
|
+
await exec()
|
|
867
|
+
JSON.parse(
|
|
868
|
+
fs.readFileSync('package-lock.json', 'utf-8')
|
|
869
|
+
).version.should.equal('1.1.0')
|
|
870
|
+
getPackageVersion().should.equal('1.1.0')
|
|
744
871
|
})
|
|
745
872
|
|
|
746
|
-
|
|
747
|
-
'
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
).version.should.equal('6.4.0')
|
|
755
|
-
})
|
|
873
|
+
describe('skip', function () {
|
|
874
|
+
it('allows bump and changelog generation to be skipped', async function () {
|
|
875
|
+
const changelogContent = 'legacy header format<a name="1.0.0">\n'
|
|
876
|
+
mock({
|
|
877
|
+
bump: 'minor',
|
|
878
|
+
changelog: 'foo\n',
|
|
879
|
+
fs: { 'CHANGELOG.md': changelogContent }
|
|
880
|
+
})
|
|
756
881
|
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
'build.gradle.kts': fs.readFileSync('./test/mocks/build-6.3.1.gradle.kts')
|
|
763
|
-
}
|
|
764
|
-
})
|
|
765
|
-
await exec({
|
|
766
|
-
packageFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }],
|
|
767
|
-
bumpFiles: [{ filename: 'build.gradle.kts', type: 'gradle' }]
|
|
882
|
+
await exec('--skip.bump true --skip.changelog true')
|
|
883
|
+
getPackageVersion().should.equal('1.0.0')
|
|
884
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
885
|
+
content.should.equal(changelogContent)
|
|
886
|
+
})
|
|
768
887
|
})
|
|
769
|
-
fs.readFileSync('build.gradle.kts', 'utf-8').should.equal(expected)
|
|
770
|
-
})
|
|
771
888
|
|
|
772
|
-
|
|
773
|
-
mock({
|
|
774
|
-
bump: 'minor',
|
|
775
|
-
fs: {
|
|
776
|
-
'npm-shrinkwrap.json': JSON.stringify({ version: '1.0.0' })
|
|
777
|
-
},
|
|
778
|
-
tags: ['v1.0.0']
|
|
779
|
-
})
|
|
780
|
-
await exec()
|
|
781
|
-
JSON.parse(
|
|
782
|
-
fs.readFileSync('npm-shrinkwrap.json', 'utf-8')
|
|
783
|
-
).version.should.equal('1.1.0')
|
|
784
|
-
getPackageVersion().should.equal('1.1.0')
|
|
785
|
-
})
|
|
786
|
-
|
|
787
|
-
it('bumps version # in package-lock.json', async function () {
|
|
788
|
-
mock({
|
|
789
|
-
bump: 'minor',
|
|
790
|
-
fs: {
|
|
791
|
-
'.gitignore': '',
|
|
792
|
-
'package-lock.json': JSON.stringify({ version: '1.0.0' })
|
|
793
|
-
},
|
|
794
|
-
tags: ['v1.0.0']
|
|
795
|
-
})
|
|
796
|
-
await exec()
|
|
797
|
-
JSON.parse(
|
|
798
|
-
fs.readFileSync('package-lock.json', 'utf-8')
|
|
799
|
-
).version.should.equal('1.1.0')
|
|
800
|
-
getPackageVersion().should.equal('1.1.0')
|
|
801
|
-
})
|
|
802
|
-
|
|
803
|
-
describe('skip', () => {
|
|
804
|
-
it('allows bump and changelog generation to be skipped', async function () {
|
|
805
|
-
const changelogContent = 'legacy header format<a name="1.0.0">\n'
|
|
889
|
+
it('does not update files present in .gitignore', async function () {
|
|
806
890
|
mock({
|
|
807
891
|
bump: 'minor',
|
|
808
|
-
|
|
809
|
-
|
|
892
|
+
fs: {
|
|
893
|
+
'.gitignore': 'package-lock.json\nbower.json',
|
|
894
|
+
// test a defaults.packageFiles
|
|
895
|
+
'bower.json': JSON.stringify({ version: '1.0.0' }),
|
|
896
|
+
// test a defaults.bumpFiles
|
|
897
|
+
'package-lock.json': JSON.stringify({
|
|
898
|
+
name: '@org/package',
|
|
899
|
+
version: '1.0.0',
|
|
900
|
+
lockfileVersion: 1
|
|
901
|
+
})
|
|
902
|
+
},
|
|
903
|
+
tags: ['v1.0.0']
|
|
810
904
|
})
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
905
|
+
await exec()
|
|
906
|
+
JSON.parse(
|
|
907
|
+
fs.readFileSync('package-lock.json', 'utf-8')
|
|
908
|
+
).version.should.equal('1.0.0')
|
|
909
|
+
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal(
|
|
910
|
+
'1.0.0'
|
|
911
|
+
)
|
|
912
|
+
getPackageVersion().should.equal('1.1.0')
|
|
816
913
|
})
|
|
817
|
-
})
|
|
818
|
-
|
|
819
|
-
it('does not update files present in .gitignore', async () => {
|
|
820
|
-
mock({
|
|
821
|
-
bump: 'minor',
|
|
822
|
-
fs: {
|
|
823
|
-
'.gitignore': 'package-lock.json\nbower.json',
|
|
824
|
-
// test a defaults.packageFiles
|
|
825
|
-
'bower.json': JSON.stringify({ version: '1.0.0' }),
|
|
826
|
-
// test a defaults.bumpFiles
|
|
827
|
-
'package-lock.json': JSON.stringify({
|
|
828
|
-
name: '@org/package',
|
|
829
|
-
version: '1.0.0',
|
|
830
|
-
lockfileVersion: 1
|
|
831
|
-
})
|
|
832
|
-
},
|
|
833
|
-
tags: ['v1.0.0']
|
|
834
|
-
})
|
|
835
|
-
await exec()
|
|
836
|
-
JSON.parse(
|
|
837
|
-
fs.readFileSync('package-lock.json', 'utf-8')
|
|
838
|
-
).version.should.equal('1.0.0')
|
|
839
|
-
JSON.parse(fs.readFileSync('bower.json', 'utf-8')).version.should.equal(
|
|
840
|
-
'1.0.0'
|
|
841
|
-
)
|
|
842
|
-
getPackageVersion().should.equal('1.1.0')
|
|
843
|
-
})
|
|
844
914
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
915
|
+
describe('configuration', function () {
|
|
916
|
+
it('--header', async function () {
|
|
917
|
+
mock({ bump: 'minor', fs: { 'CHANGELOG.md': '' } })
|
|
918
|
+
await exec('--header="# Welcome to our CHANGELOG.md"')
|
|
919
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
920
|
+
content.should.match(/# Welcome to our CHANGELOG.md/)
|
|
921
|
+
})
|
|
852
922
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
923
|
+
it('--issuePrefixes and --issueUrlFormat', async function () {
|
|
924
|
+
const format = 'http://www.foo.com/{{prefix}}{{id}}'
|
|
925
|
+
const prefix = 'ABC-'
|
|
926
|
+
const changelog = ({ preset }) =>
|
|
927
|
+
preset.issueUrlFormat + ':' + preset.issuePrefixes
|
|
928
|
+
mock({ bump: 'minor', changelog })
|
|
929
|
+
await exec(`--issuePrefixes="${prefix}" --issueUrlFormat="${format}"`)
|
|
930
|
+
const content = fs.readFileSync('CHANGELOG.md', 'utf-8')
|
|
931
|
+
content.should.include(`${format}:${prefix}`)
|
|
932
|
+
})
|
|
862
933
|
})
|
|
863
|
-
})
|
|
864
934
|
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
935
|
+
describe('pre-major', function () {
|
|
936
|
+
it('bumps the minor rather than major, if version < 1.0.0', async function () {
|
|
937
|
+
mock({
|
|
938
|
+
bump: 'minor',
|
|
939
|
+
pkg: {
|
|
940
|
+
version: '0.5.0',
|
|
941
|
+
repository: { url: 'https://github.com/yargs/yargs.git' }
|
|
942
|
+
}
|
|
943
|
+
})
|
|
944
|
+
await exec()
|
|
945
|
+
getPackageVersion().should.equal('0.6.0')
|
|
873
946
|
})
|
|
874
|
-
await exec()
|
|
875
|
-
getPackageVersion().should.equal('0.6.0')
|
|
876
|
-
})
|
|
877
947
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
948
|
+
it('bumps major if --release-as=major specified, if version < 1.0.0', async function () {
|
|
949
|
+
mock({
|
|
950
|
+
bump: 'major',
|
|
951
|
+
pkg: {
|
|
952
|
+
version: '0.5.0',
|
|
953
|
+
repository: { url: 'https://github.com/yargs/yargs.git' }
|
|
954
|
+
}
|
|
955
|
+
})
|
|
956
|
+
await exec('-r major')
|
|
957
|
+
getPackageVersion().should.equal('1.0.0')
|
|
885
958
|
})
|
|
886
|
-
await exec('-r major')
|
|
887
|
-
getPackageVersion().should.equal('1.0.0')
|
|
888
959
|
})
|
|
889
960
|
})
|
|
890
|
-
})
|
|
891
961
|
|
|
892
|
-
describe('GHSL-2020-111', function () {
|
|
893
|
-
|
|
962
|
+
describe('GHSL-2020-111', function () {
|
|
963
|
+
afterEach(unmock)
|
|
894
964
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
965
|
+
it('does not allow command injection via basic configuration', async function () {
|
|
966
|
+
mock({ bump: 'patch' })
|
|
967
|
+
await exec({
|
|
968
|
+
noVerify: true,
|
|
969
|
+
infile: 'foo.txt',
|
|
970
|
+
releaseCommitMessageFormat: 'bla `touch exploit`'
|
|
971
|
+
})
|
|
972
|
+
const stat = shell.test('-f', './exploit')
|
|
973
|
+
stat.should.equal(false)
|
|
901
974
|
})
|
|
902
|
-
const stat = shell.test('-f', './exploit')
|
|
903
|
-
stat.should.equal(false)
|
|
904
975
|
})
|
|
905
|
-
})
|
|
906
976
|
|
|
907
|
-
describe('with mocked git', function () {
|
|
908
|
-
|
|
977
|
+
describe('with mocked git', function () {
|
|
978
|
+
afterEach(unmock)
|
|
979
|
+
|
|
980
|
+
it('--sign signs the commit and tag', async function () {
|
|
981
|
+
const gitArgs = [
|
|
982
|
+
['add', 'CHANGELOG.md', 'package.json'],
|
|
983
|
+
[
|
|
984
|
+
'commit',
|
|
985
|
+
'-S',
|
|
986
|
+
'CHANGELOG.md',
|
|
987
|
+
'package.json',
|
|
988
|
+
'-m',
|
|
989
|
+
'chore(release): 1.0.1'
|
|
990
|
+
],
|
|
991
|
+
['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
992
|
+
['rev-parse', '--abbrev-ref', 'HEAD']
|
|
993
|
+
]
|
|
994
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
995
|
+
cmd.should.equal('git')
|
|
996
|
+
const expected = gitArgs.shift()
|
|
997
|
+
cmdArgs.should.deep.equal(expected)
|
|
998
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master')
|
|
999
|
+
return Promise.resolve('')
|
|
1000
|
+
}
|
|
1001
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
909
1002
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
[
|
|
914
|
-
'commit',
|
|
915
|
-
'-S',
|
|
916
|
-
'CHANGELOG.md',
|
|
917
|
-
'package.json',
|
|
918
|
-
'-m',
|
|
919
|
-
'chore(release): 1.0.1'
|
|
920
|
-
],
|
|
921
|
-
['tag', '-s', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
922
|
-
['rev-parse', '--abbrev-ref', 'HEAD']
|
|
923
|
-
]
|
|
924
|
-
const execFile = (_args, cmd, cmdArgs) => {
|
|
925
|
-
cmd.should.equal('git')
|
|
926
|
-
const expected = gitArgs.shift()
|
|
927
|
-
cmdArgs.should.deep.equal(expected)
|
|
928
|
-
if (expected[0] === 'rev-parse') return Promise.resolve('master')
|
|
929
|
-
return Promise.resolve('')
|
|
930
|
-
}
|
|
931
|
-
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
932
|
-
|
|
933
|
-
await exec('--sign', true)
|
|
934
|
-
gitArgs.should.have.lengthOf(0)
|
|
935
|
-
})
|
|
1003
|
+
await exec('--sign', true)
|
|
1004
|
+
gitArgs.should.have.lengthOf(0)
|
|
1005
|
+
})
|
|
936
1006
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1007
|
+
it('--tag-force forces tag replacement', async function () {
|
|
1008
|
+
const gitArgs = [
|
|
1009
|
+
['add', 'CHANGELOG.md', 'package.json'],
|
|
1010
|
+
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'],
|
|
1011
|
+
['tag', '-a', '-f', 'v1.0.1', '-m', 'chore(release): 1.0.1'],
|
|
1012
|
+
['rev-parse', '--abbrev-ref', 'HEAD']
|
|
1013
|
+
]
|
|
1014
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
1015
|
+
cmd.should.equal('git')
|
|
1016
|
+
const expected = gitArgs.shift()
|
|
1017
|
+
cmdArgs.should.deep.equal(expected)
|
|
1018
|
+
if (expected[0] === 'rev-parse') return Promise.resolve('master')
|
|
1019
|
+
return Promise.resolve('')
|
|
1020
|
+
}
|
|
1021
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1022
|
+
|
|
1023
|
+
await exec('--tag-force', true)
|
|
1024
|
+
gitArgs.should.have.lengthOf(0)
|
|
1025
|
+
})
|
|
956
1026
|
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1027
|
+
it('fails if git add fails', async function () {
|
|
1028
|
+
const gitArgs = [['add', 'CHANGELOG.md', 'package.json']]
|
|
1029
|
+
const gitError = new Error('Command failed: git\nfailed add')
|
|
1030
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
1031
|
+
cmd.should.equal('git')
|
|
1032
|
+
const expected = gitArgs.shift()
|
|
1033
|
+
cmdArgs.should.deep.equal(expected)
|
|
964
1034
|
|
|
965
|
-
|
|
966
|
-
|
|
1035
|
+
if (expected[0] === 'add') {
|
|
1036
|
+
return Promise.reject(gitError)
|
|
1037
|
+
}
|
|
1038
|
+
return Promise.resolve('')
|
|
967
1039
|
}
|
|
968
|
-
|
|
969
|
-
}
|
|
970
|
-
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1040
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
971
1041
|
|
|
972
|
-
|
|
973
|
-
|
|
1042
|
+
await expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
1043
|
+
})
|
|
974
1044
|
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1045
|
+
it('fails if git commit fails', async function () {
|
|
1046
|
+
const gitArgs = [
|
|
1047
|
+
['add', 'CHANGELOG.md', 'package.json'],
|
|
1048
|
+
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1']
|
|
1049
|
+
]
|
|
1050
|
+
const gitError = new Error('Command failed: git\nfailed commit')
|
|
1051
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
1052
|
+
cmd.should.equal('git')
|
|
1053
|
+
const expected = gitArgs.shift()
|
|
1054
|
+
cmdArgs.should.deep.equal(expected)
|
|
1055
|
+
if (expected[0] === 'commit') {
|
|
1056
|
+
return Promise.reject(gitError)
|
|
1057
|
+
}
|
|
1058
|
+
return Promise.resolve('')
|
|
987
1059
|
}
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1060
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
991
1061
|
|
|
992
|
-
|
|
993
|
-
|
|
1062
|
+
await expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
1063
|
+
})
|
|
994
1064
|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1065
|
+
it('fails if git tag fails', async function () {
|
|
1066
|
+
const gitArgs = [
|
|
1067
|
+
['add', 'CHANGELOG.md', 'package.json'],
|
|
1068
|
+
['commit', 'CHANGELOG.md', 'package.json', '-m', 'chore(release): 1.0.1'],
|
|
1069
|
+
['tag', '-a', 'v1.0.1', '-m', 'chore(release): 1.0.1']
|
|
1070
|
+
]
|
|
1071
|
+
const gitError = new Error('Command failed: git\nfailed tag')
|
|
1072
|
+
const execFile = (_args, cmd, cmdArgs) => {
|
|
1073
|
+
cmd.should.equal('git')
|
|
1074
|
+
const expected = gitArgs.shift()
|
|
1075
|
+
cmdArgs.should.deep.equal(expected)
|
|
1076
|
+
if (expected[0] === 'tag') {
|
|
1077
|
+
return Promise.reject(gitError)
|
|
1078
|
+
}
|
|
1079
|
+
return Promise.resolve('')
|
|
1008
1080
|
}
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1081
|
+
mock({ bump: 'patch', changelog: 'foo\n', execFile })
|
|
1012
1082
|
|
|
1013
|
-
|
|
1083
|
+
await expect(exec({}, true)).to.be.rejectedWith(gitError)
|
|
1084
|
+
})
|
|
1014
1085
|
})
|
|
1015
1086
|
})
|