@@ -415,6 +415,11 @@ function getIDToken(aud) {
415415 } ) ;
416416}
417417exports . getIDToken = getIDToken ;
418+ /**
419+ * Markdown summary exports
420+ */
421+ var markdown_summary_1 = __nccwpck_require__ ( 42 ) ;
422+ Object . defineProperty ( exports , "markdownSummary" , ( { enumerable : true , get : function ( ) { return markdown_summary_1 . markdownSummary ; } } ) ) ;
418423//# sourceMappingURL=core.js.map
419424
420425/***/ } ) ,
@@ -468,6 +473,292 @@ exports.issueCommand = issueCommand;
468473
469474/***/ } ) ,
470475
476+ /***/ 42 :
477+ /***/ ( function ( __unused_webpack_module , exports , __nccwpck_require__ ) {
478+
479+ "use strict" ;
480+
481+ var __awaiter = ( this && this . __awaiter ) || function ( thisArg , _arguments , P , generator ) {
482+ function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
483+ return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
484+ function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
485+ function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
486+ function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
487+ step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
488+ } ) ;
489+ } ;
490+ Object . defineProperty ( exports , "__esModule" , ( { value : true } ) ) ;
491+ exports . markdownSummary = exports . SUMMARY_DOCS_URL = exports . SUMMARY_ENV_VAR = void 0 ;
492+ const os_1 = __nccwpck_require__ ( 37 ) ;
493+ const fs_1 = __nccwpck_require__ ( 147 ) ;
494+ const { access, appendFile, writeFile } = fs_1 . promises ;
495+ exports . SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY' ;
496+ exports . SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary' ;
497+ class MarkdownSummary {
498+ constructor ( ) {
499+ this . _buffer = '' ;
500+ }
501+ /**
502+ * Finds the summary file path from the environment, rejects if env var is not found or file does not exist
503+ * Also checks r/w permissions.
504+ *
505+ * @returns step summary file path
506+ */
507+ filePath ( ) {
508+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
509+ if ( this . _filePath ) {
510+ return this . _filePath ;
511+ }
512+ const pathFromEnv = process . env [ exports . SUMMARY_ENV_VAR ] ;
513+ if ( ! pathFromEnv ) {
514+ throw new Error ( `Unable to find environment variable for $${ exports . SUMMARY_ENV_VAR } . Check if your runtime environment supports markdown summaries.` ) ;
515+ }
516+ try {
517+ yield access ( pathFromEnv , fs_1 . constants . R_OK | fs_1 . constants . W_OK ) ;
518+ }
519+ catch ( _a ) {
520+ throw new Error ( `Unable to access summary file: '${ pathFromEnv } '. Check if the file has correct read/write permissions.` ) ;
521+ }
522+ this . _filePath = pathFromEnv ;
523+ return this . _filePath ;
524+ } ) ;
525+ }
526+ /**
527+ * Wraps content in an HTML tag, adding any HTML attributes
528+ *
529+ * @param {string } tag HTML tag to wrap
530+ * @param {string | null } content content within the tag
531+ * @param {[attribute: string]: string } attrs key-value list of HTML attributes to add
532+ *
533+ * @returns {string } content wrapped in HTML element
534+ */
535+ wrap ( tag , content , attrs = { } ) {
536+ const htmlAttrs = Object . entries ( attrs )
537+ . map ( ( [ key , value ] ) => ` ${ key } ="${ value } "` )
538+ . join ( '' ) ;
539+ if ( ! content ) {
540+ return `<${ tag } ${ htmlAttrs } >` ;
541+ }
542+ return `<${ tag } ${ htmlAttrs } >${ content } </${ tag } >` ;
543+ }
544+ /**
545+ * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
546+ *
547+ * @param {SummaryWriteOptions } [options] (optional) options for write operation
548+ *
549+ * @returns {Promise<MarkdownSummary> } markdown summary instance
550+ */
551+ write ( options ) {
552+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
553+ const overwrite = ! ! ( options === null || options === void 0 ? void 0 : options . overwrite ) ;
554+ const filePath = yield this . filePath ( ) ;
555+ const writeFunc = overwrite ? writeFile : appendFile ;
556+ yield writeFunc ( filePath , this . _buffer , { encoding : 'utf8' } ) ;
557+ return this . emptyBuffer ( ) ;
558+ } ) ;
559+ }
560+ /**
561+ * Clears the summary buffer and wipes the summary file
562+ *
563+ * @returns {MarkdownSummary } markdown summary instance
564+ */
565+ clear ( ) {
566+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
567+ return this . emptyBuffer ( ) . write ( { overwrite : true } ) ;
568+ } ) ;
569+ }
570+ /**
571+ * Returns the current summary buffer as a string
572+ *
573+ * @returns {string } string of summary buffer
574+ */
575+ stringify ( ) {
576+ return this . _buffer ;
577+ }
578+ /**
579+ * If the summary buffer is empty
580+ *
581+ * @returns {boolen } true if the buffer is empty
582+ */
583+ isEmptyBuffer ( ) {
584+ return this . _buffer . length === 0 ;
585+ }
586+ /**
587+ * Resets the summary buffer without writing to summary file
588+ *
589+ * @returns {MarkdownSummary } markdown summary instance
590+ */
591+ emptyBuffer ( ) {
592+ this . _buffer = '' ;
593+ return this ;
594+ }
595+ /**
596+ * Adds raw text to the summary buffer
597+ *
598+ * @param {string } text content to add
599+ * @param {boolean } [addEOL=false] (optional) append an EOL to the raw text (default: false)
600+ *
601+ * @returns {MarkdownSummary } markdown summary instance
602+ */
603+ addRaw ( text , addEOL = false ) {
604+ this . _buffer += text ;
605+ return addEOL ? this . addEOL ( ) : this ;
606+ }
607+ /**
608+ * Adds the operating system-specific end-of-line marker to the buffer
609+ *
610+ * @returns {MarkdownSummary } markdown summary instance
611+ */
612+ addEOL ( ) {
613+ return this . addRaw ( os_1 . EOL ) ;
614+ }
615+ /**
616+ * Adds an HTML codeblock to the summary buffer
617+ *
618+ * @param {string } code content to render within fenced code block
619+ * @param {string } lang (optional) language to syntax highlight code
620+ *
621+ * @returns {MarkdownSummary } markdown summary instance
622+ */
623+ addCodeBlock ( code , lang ) {
624+ const attrs = Object . assign ( { } , ( lang && { lang } ) ) ;
625+ const element = this . wrap ( 'pre' , this . wrap ( 'code' , code ) , attrs ) ;
626+ return this . addRaw ( element ) . addEOL ( ) ;
627+ }
628+ /**
629+ * Adds an HTML list to the summary buffer
630+ *
631+ * @param {string[] } items list of items to render
632+ * @param {boolean } [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
633+ *
634+ * @returns {MarkdownSummary } markdown summary instance
635+ */
636+ addList ( items , ordered = false ) {
637+ const tag = ordered ? 'ol' : 'ul' ;
638+ const listItems = items . map ( item => this . wrap ( 'li' , item ) ) . join ( '' ) ;
639+ const element = this . wrap ( tag , listItems ) ;
640+ return this . addRaw ( element ) . addEOL ( ) ;
641+ }
642+ /**
643+ * Adds an HTML table to the summary buffer
644+ *
645+ * @param {SummaryTableCell[] } rows table rows
646+ *
647+ * @returns {MarkdownSummary } markdown summary instance
648+ */
649+ addTable ( rows ) {
650+ const tableBody = rows
651+ . map ( row => {
652+ const cells = row
653+ . map ( cell => {
654+ if ( typeof cell === 'string' ) {
655+ return this . wrap ( 'td' , cell ) ;
656+ }
657+ const { header, data, colspan, rowspan } = cell ;
658+ const tag = header ? 'th' : 'td' ;
659+ const attrs = Object . assign ( Object . assign ( { } , ( colspan && { colspan } ) ) , ( rowspan && { rowspan } ) ) ;
660+ return this . wrap ( tag , data , attrs ) ;
661+ } )
662+ . join ( '' ) ;
663+ return this . wrap ( 'tr' , cells ) ;
664+ } )
665+ . join ( '' ) ;
666+ const element = this . wrap ( 'table' , tableBody ) ;
667+ return this . addRaw ( element ) . addEOL ( ) ;
668+ }
669+ /**
670+ * Adds a collapsable HTML details element to the summary buffer
671+ *
672+ * @param {string } label text for the closed state
673+ * @param {string } content collapsable content
674+ *
675+ * @returns {MarkdownSummary } markdown summary instance
676+ */
677+ addDetails ( label , content ) {
678+ const element = this . wrap ( 'details' , this . wrap ( 'summary' , label ) + content ) ;
679+ return this . addRaw ( element ) . addEOL ( ) ;
680+ }
681+ /**
682+ * Adds an HTML image tag to the summary buffer
683+ *
684+ * @param {string } src path to the image you to embed
685+ * @param {string } alt text description of the image
686+ * @param {SummaryImageOptions } options (optional) addition image attributes
687+ *
688+ * @returns {MarkdownSummary } markdown summary instance
689+ */
690+ addImage ( src , alt , options ) {
691+ const { width, height } = options || { } ;
692+ const attrs = Object . assign ( Object . assign ( { } , ( width && { width } ) ) , ( height && { height } ) ) ;
693+ const element = this . wrap ( 'img' , null , Object . assign ( { src, alt } , attrs ) ) ;
694+ return this . addRaw ( element ) . addEOL ( ) ;
695+ }
696+ /**
697+ * Adds an HTML section heading element
698+ *
699+ * @param {string } text heading text
700+ * @param {number | string } [level=1] (optional) the heading level, default: 1
701+ *
702+ * @returns {MarkdownSummary } markdown summary instance
703+ */
704+ addHeading ( text , level ) {
705+ const tag = `h${ level } ` ;
706+ const allowedTag = [ 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' ] . includes ( tag )
707+ ? tag
708+ : 'h1' ;
709+ const element = this . wrap ( allowedTag , text ) ;
710+ return this . addRaw ( element ) . addEOL ( ) ;
711+ }
712+ /**
713+ * Adds an HTML thematic break (<hr>) to the summary buffer
714+ *
715+ * @returns {MarkdownSummary } markdown summary instance
716+ */
717+ addSeparator ( ) {
718+ const element = this . wrap ( 'hr' , null ) ;
719+ return this . addRaw ( element ) . addEOL ( ) ;
720+ }
721+ /**
722+ * Adds an HTML line break (<br>) to the summary buffer
723+ *
724+ * @returns {MarkdownSummary } markdown summary instance
725+ */
726+ addBreak ( ) {
727+ const element = this . wrap ( 'br' , null ) ;
728+ return this . addRaw ( element ) . addEOL ( ) ;
729+ }
730+ /**
731+ * Adds an HTML blockquote to the summary buffer
732+ *
733+ * @param {string } text quote text
734+ * @param {string } cite (optional) citation url
735+ *
736+ * @returns {MarkdownSummary } markdown summary instance
737+ */
738+ addQuote ( text , cite ) {
739+ const attrs = Object . assign ( { } , ( cite && { cite } ) ) ;
740+ const element = this . wrap ( 'blockquote' , text , attrs ) ;
741+ return this . addRaw ( element ) . addEOL ( ) ;
742+ }
743+ /**
744+ * Adds an HTML anchor tag to the summary buffer
745+ *
746+ * @param {string } text link text/content
747+ * @param {string } href hyperlink
748+ *
749+ * @returns {MarkdownSummary } markdown summary instance
750+ */
751+ addLink ( text , href ) {
752+ const element = this . wrap ( 'a' , text , { href } ) ;
753+ return this . addRaw ( element ) . addEOL ( ) ;
754+ }
755+ }
756+ // singleton export
757+ exports . markdownSummary = new MarkdownSummary ( ) ;
758+ //# sourceMappingURL=markdown-summary.js.map
759+
760+ /***/ } ) ,
761+
471762/***/ 41 :
472763/***/ ( function ( __unused_webpack_module , exports , __nccwpck_require__ ) {
473764
0 commit comments