@@ -173,6 +173,14 @@ function apiMdRel(packageDir) {
173173 return `${ packageRelDir ( packageDir ) } /API.md` ;
174174}
175175
176+ function metadataPath ( packageDir ) {
177+ return path . join ( packageDir , "API.metadata.yml" ) ;
178+ }
179+
180+ function metadataRel ( packageDir ) {
181+ return `${ packageRelDir ( packageDir ) } /API.metadata.yml` ;
182+ }
183+
176184function findRealGitExe ( ) {
177185 if ( process . platform !== "win32" ) {
178186 return null ;
@@ -389,7 +397,14 @@ function generateApiBytesForPackage({
389397 throw new Error ( `ERROR: did not produce ${ outputPath } ` ) ;
390398 }
391399
392- return fs . readFileSync ( outputPath ) ;
400+ const result = { apiMd : fs . readFileSync ( outputPath ) , metadata : null } ;
401+
402+ const metaPath = metadataPath ( packageDir ) ;
403+ if ( fs . existsSync ( metaPath ) ) {
404+ result . metadata = fs . readFileSync ( metaPath ) ;
405+ }
406+
407+ return result ;
393408}
394409
395410function main ( ) {
@@ -415,11 +430,11 @@ function main() {
415430 const targetRef = args . target ? resolveTargetRef ( args . target ) : MAIN_REF ;
416431
417432 try {
418- let baseApiBytes = null ;
433+ let baseResult = null ;
419434 if ( args . base ) {
420435 logInfo ( `\n=== Capturing baseline API.md from tag ${ args . base } ===` ) ;
421436 git ( [ "checkout" , "--detach" , args . base ] ) ;
422- baseApiBytes = generateApiBytesForPackage ( {
437+ baseResult = generateApiBytesForPackage ( {
423438 adapter,
424439 repoRoot : REPO_ROOT ,
425440 packageName : args . packageName ,
@@ -434,7 +449,7 @@ function main() {
434449 logInfo ( `\n=== Capturing target API.md from ${ targetRef } ===` ) ;
435450 git ( [ "checkout" , "--detach" , targetRef ] ) ;
436451 const targetVersion = adapter . readVersion ( packageDir ) ;
437- const targetApiBytes = generateApiBytesForPackage ( {
452+ const targetResult = generateApiBytesForPackage ( {
438453 adapter,
439454 repoRoot : REPO_ROOT ,
440455 packageName : args . packageName ,
@@ -453,10 +468,16 @@ function main() {
453468
454469 const apiPath = apiMdPath ( packageDir ) ;
455470 const apiRelative = apiMdRel ( packageDir ) ;
471+ const metaFilePath = metadataPath ( packageDir ) ;
472+ const metaRelative = metadataRel ( packageDir ) ;
456473
457- if ( baseApiBytes !== null ) {
458- writeBytes ( apiPath , baseApiBytes ) ;
474+ if ( baseResult !== null ) {
475+ writeBytes ( apiPath , baseResult . apiMd ) ;
459476 git ( [ "add" , apiRelative ] ) ;
477+ if ( baseResult . metadata ) {
478+ writeBytes ( metaFilePath , baseResult . metadata ) ;
479+ git ( [ "add" , metaRelative ] ) ;
480+ }
460481 git ( [ "commit" , "-m" , `[API Review] Baseline API.md for ${ args . packageName } ${ baseVersion } ` ] ) ;
461482 } else {
462483 const tracked = git ( [ "ls-files" , "--error-unmatch" , apiRelative ] , {
@@ -466,11 +487,21 @@ function main() {
466487
467488 if ( tracked . status === 0 ) {
468489 git ( [ "rm" , apiRelative ] ) ;
490+ const metaTracked = git ( [ "ls-files" , "--error-unmatch" , metaRelative ] , {
491+ capture : true ,
492+ check : false ,
493+ } ) ;
494+ if ( metaTracked . status === 0 ) {
495+ git ( [ "rm" , metaRelative ] ) ;
496+ }
469497 git ( [ "commit" , "-m" , `[API Review] Remove API.md for ${ args . packageName } (empty baseline)` ] ) ;
470498 } else {
471499 if ( fs . existsSync ( apiPath ) ) {
472500 fs . unlinkSync ( apiPath ) ;
473501 }
502+ if ( fs . existsSync ( metaFilePath ) ) {
503+ fs . unlinkSync ( metaFilePath ) ;
504+ }
474505 git ( [ "commit" , "--allow-empty" , "-m" , `[API Review] Empty baseline for ${ args . packageName } ` ] ) ;
475506 }
476507 }
@@ -479,8 +510,12 @@ function main() {
479510
480511 logInfo ( `\n=== Creating review branch ${ reviewBranch } ===` ) ;
481512 git ( [ "checkout" , "-B" , reviewBranch , baseBranch ] ) ;
482- writeBytes ( apiPath , targetApiBytes ) ;
513+ writeBytes ( apiPath , targetResult . apiMd ) ;
483514 git ( [ "add" , apiRelative ] ) ;
515+ if ( targetResult . metadata ) {
516+ writeBytes ( metaFilePath , targetResult . metadata ) ;
517+ git ( [ "add" , metaRelative ] ) ;
518+ }
484519
485520 const diff = git ( [ "diff" , "--cached" , "--quiet" ] , {
486521 capture : true ,
0 commit comments