@@ -304,8 +304,8 @@ describe('create-release-branch (functional)', () => {
304
304
- Update "a"
305
305
- Initial commit
306
306
307
- [Unreleased]: https://github.com/example-org/example-repo/compare/v2 .0.0...HEAD
308
- [2.0.0]: https://github.com/example-org/example-repo/releases/tag/v2 .0.0
307
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/a@2 .0.0...HEAD
308
+ [2.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/a@2 .0.0
309
309
` ) ,
310
310
) ;
311
311
expect (
@@ -318,8 +318,227 @@ describe('create-release-branch (functional)', () => {
318
318
### Uncategorized
319
319
- Initial commit
320
320
321
- [Unreleased]: https://github.com/example-org/example-repo/compare/v2.0.0...HEAD
322
- [2.0.0]: https://github.com/example-org/example-repo/releases/tag/v2.0.0
321
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
322
+ [2.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
323
+ ` ) ,
324
+ ) ;
325
+ } ,
326
+ ) ;
327
+ } ) ;
328
+
329
+ it ( 'updates package changelogs with package changes since the last package release' , async ( ) => {
330
+ await withMonorepoProjectEnvironment (
331
+ {
332
+ packages : {
333
+ $root$ : {
334
+ name : '@scope/monorepo' ,
335
+ version : '1.0.0' ,
336
+ directoryPath : '.' ,
337
+ } ,
338
+ a : {
339
+ name : '@scope/a' ,
340
+ version : '1.0.0' ,
341
+ directoryPath : 'packages/a' ,
342
+ } ,
343
+ b : {
344
+ name : '@scope/b' ,
345
+ version : '1.0.0' ,
346
+ directoryPath : 'packages/b' ,
347
+ } ,
348
+ } ,
349
+ workspaces : {
350
+ '.' : [ 'packages/*' ] ,
351
+ } ,
352
+ createInitialCommit : false ,
353
+ } ,
354
+ async ( environment ) => {
355
+ // Create an initial commit
356
+ await environment . writeFileWithinPackage (
357
+ 'a' ,
358
+ 'CHANGELOG.md' ,
359
+ buildChangelog ( `
360
+ ## [Unreleased]
361
+
362
+ ## [1.0.0]
363
+ ### Added
364
+ - Initial release
365
+
366
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
367
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
368
+ ` ) ,
369
+ ) ;
370
+ await environment . writeFileWithinPackage (
371
+ 'b' ,
372
+ 'CHANGELOG.md' ,
373
+ buildChangelog ( `
374
+ ## [Unreleased]
375
+
376
+ ## [1.0.0]
377
+ ### Added
378
+ - Initial release
379
+
380
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
381
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
382
+ ` ) ,
383
+ ) ;
384
+ await environment . createCommit ( 'Initial commit' ) ;
385
+ await environment . runCommand ( 'git' , [ 'tag' , '@scope/[email protected] ' ] ) ;
386
+ await environment . runCommand ( 'git' , [ 'tag' , '@scope/[email protected] ' ] ) ;
387
+ await environment . runCommand ( 'git' , [ 'tag' , 'v1.0.0' ] ) ;
388
+
389
+ // Create another commit that only changes "a"
390
+ await environment . writeFileWithinPackage (
391
+ 'a' ,
392
+ 'dummy.txt' ,
393
+ 'Some content' ,
394
+ ) ;
395
+ await environment . createCommit ( 'Update "a"' ) ;
396
+
397
+ // Run the tool
398
+ await environment . runTool ( {
399
+ releaseSpecification : {
400
+ packages : {
401
+ a : 'major' ,
402
+ } ,
403
+ } ,
404
+ } ) ;
405
+
406
+ // Only "a" should be updated
407
+ expect (
408
+ await environment . readFileWithinPackage ( 'a' , 'CHANGELOG.md' ) ,
409
+ ) . toStrictEqual (
410
+ buildChangelog ( `
411
+ ## [Unreleased]
412
+
413
+ ## [2.0.0]
414
+ ### Uncategorized
415
+ - Update "a"
416
+
417
+ ## [1.0.0]
418
+ ### Added
419
+ - Initial release
420
+
421
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
422
+ [2.0.0]: https://github.com/example-org/example-repo/compare/@scope/[email protected] ...@scope/[email protected]
423
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
424
+ ` ) ,
425
+ ) ;
426
+ expect (
427
+ await environment . readFileWithinPackage ( 'b' , 'CHANGELOG.md' ) ,
428
+ ) . toStrictEqual (
429
+ buildChangelog ( `
430
+ ## [Unreleased]
431
+
432
+ ## [1.0.0]
433
+ ### Added
434
+ - Initial release
435
+
436
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
437
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
438
+ ` ) ,
439
+ ) ;
440
+ } ,
441
+ ) ;
442
+ } ) ;
443
+
444
+ it ( 'updates package changelogs with package changes since the last root release if this is the first package release' , async ( ) => {
445
+ await withMonorepoProjectEnvironment (
446
+ {
447
+ packages : {
448
+ $root$ : {
449
+ name : '@scope/monorepo' ,
450
+ version : '1.0.0' ,
451
+ directoryPath : '.' ,
452
+ } ,
453
+ a : {
454
+ name : '@scope/a' ,
455
+ version : '0.0.0' ,
456
+ directoryPath : 'packages/a' ,
457
+ } ,
458
+ b : {
459
+ name : '@scope/b' ,
460
+ version : '1.0.0' ,
461
+ directoryPath : 'packages/b' ,
462
+ } ,
463
+ } ,
464
+ workspaces : {
465
+ '.' : [ 'packages/*' ] ,
466
+ } ,
467
+ createInitialCommit : false ,
468
+ } ,
469
+ async ( environment ) => {
470
+ // Create an initial commit
471
+ await environment . writeFileWithinPackage (
472
+ 'a' ,
473
+ 'CHANGELOG.md' ,
474
+ buildChangelog ( `
475
+ ## [Unreleased]
476
+
477
+ [Unreleased]: https://github.com/example-org/example-repo
478
+ ` ) ,
479
+ ) ;
480
+ await environment . writeFileWithinPackage (
481
+ 'b' ,
482
+ 'CHANGELOG.md' ,
483
+ buildChangelog ( `
484
+ ## [Unreleased]
485
+
486
+ ## [1.0.0]
487
+ ### Added
488
+ - Initial release
489
+
490
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
491
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
492
+ ` ) ,
493
+ ) ;
494
+ await environment . createCommit ( 'Initial commit' ) ;
495
+ await environment . runCommand ( 'git' , [ 'tag' , '@scope/[email protected] ' ] ) ;
496
+ await environment . runCommand ( 'git' , [ 'tag' , 'v1.0.0' ] ) ;
497
+
498
+ // Create another commit that only changes "a"
499
+ await environment . writeFileWithinPackage (
500
+ 'a' ,
501
+ 'dummy.txt' ,
502
+ 'Some content' ,
503
+ ) ;
504
+ await environment . createCommit ( 'Update "a"' ) ;
505
+
506
+ // Run the tool
507
+ await environment . runTool ( {
508
+ releaseSpecification : {
509
+ packages : {
510
+ a : 'major' ,
511
+ } ,
512
+ } ,
513
+ } ) ;
514
+
515
+ // Only "a" should be updated
516
+ expect (
517
+ await environment . readFileWithinPackage ( 'a' , 'CHANGELOG.md' ) ,
518
+ ) . toStrictEqual (
519
+ buildChangelog ( `
520
+ ## [Unreleased]
521
+
522
+ ## [1.0.0]
523
+ ### Uncategorized
524
+ - Update "a"
525
+
526
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
527
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
528
+ ` ) ,
529
+ ) ;
530
+ expect (
531
+ await environment . readFileWithinPackage ( 'b' , 'CHANGELOG.md' ) ,
532
+ ) . toStrictEqual (
533
+ buildChangelog ( `
534
+ ## [Unreleased]
535
+
536
+ ## [1.0.0]
537
+ ### Added
538
+ - Initial release
539
+
540
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/[email protected]
541
+ [1.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/[email protected]
323
542
` ) ,
324
543
) ;
325
544
} ,
@@ -652,8 +871,8 @@ The release spec file has been retained for you to edit again and make the neces
652
871
- Update "a"
653
872
- Initial commit
654
873
655
- [Unreleased]: https://github.com/example-org/example-repo/compare/v2 .0.0...HEAD
656
- [2.0.0]: https://github.com/example-org/example-repo/releases/tag/v2 .0.0
874
+ [Unreleased]: https://github.com/example-org/example-repo/compare/@scope/a@2 .0.0...HEAD
875
+ [2.0.0]: https://github.com/example-org/example-repo/releases/tag/@scope/a@2 .0.0
657
876
` ) ,
658
877
) ;
659
878
expect (
0 commit comments