@@ -18,7 +18,7 @@ export class OutputManager {
1818 outputModes : string [ ] ,
1919 octokit : Octokit | null ,
2020 context : ParsedGitHubContext ,
21- commitSha ?: string
21+ commitSha ?: string ,
2222 ) {
2323 // Create and validate strategies based on output modes
2424 for ( const mode of outputModes ) {
@@ -28,47 +28,61 @@ export class OutputManager {
2828 switch ( trimmedMode ) {
2929 case "pr_comment" :
3030 if ( ! octokit ) {
31- throw new Error ( "'pr_comment' output mode requires GitHub authentication (octokit instance)" ) ;
31+ throw new Error (
32+ "'pr_comment' output mode requires GitHub authentication (octokit instance)" ,
33+ ) ;
3234 }
3335 strategy = new PrCommentStrategy ( octokit ) ;
3436 break ;
3537 case "commit_comment" :
3638 if ( ! octokit ) {
37- throw new Error ( "'commit_comment' output mode requires GitHub authentication (octokit instance)" ) ;
39+ throw new Error (
40+ "'commit_comment' output mode requires GitHub authentication (octokit instance)" ,
41+ ) ;
3842 }
3943 strategy = new CommitCommentStrategy ( octokit , commitSha ) ;
4044 break ;
4145 case "stdout" :
4246 strategy = new StdoutStrategy ( ) ;
4347 break ;
4448 default :
45- throw new Error ( `Unknown output mode: ${ trimmedMode } . Valid options: pr_comment, commit_comment, stdout` ) ;
49+ throw new Error (
50+ `Unknown output mode: ${ trimmedMode } . Valid options: pr_comment, commit_comment, stdout` ,
51+ ) ;
4652 }
4753
4854 // Validate the strategy can work in this context
4955 try {
5056 strategy . validate ( context ) ;
5157 this . strategies . push ( strategy ) ;
5258 } catch ( error ) {
53- const errorMessage = error instanceof Error ? error . message : String ( error ) ;
54- throw new Error ( `Output mode '${ trimmedMode } ' validation failed: ${ errorMessage } ` ) ;
59+ const errorMessage =
60+ error instanceof Error ? error . message : String ( error ) ;
61+ throw new Error (
62+ `Output mode '${ trimmedMode } ' validation failed: ${ errorMessage } ` ,
63+ ) ;
5564 }
5665 }
5766
5867 if ( this . strategies . length === 0 ) {
5968 throw new Error ( "No valid output strategies configured" ) ;
6069 }
6170
62- console . log ( `📤 Configured output strategies: ${ this . strategies . map ( s => s . name ) . join ( ", " ) } ` ) ;
71+ console . log (
72+ `📤 Configured output strategies: ${ this . strategies . map ( ( s ) => s . name ) . join ( ", " ) } ` ,
73+ ) ;
6374 }
6475
6576 static parseOutputModes ( outputModeInput : string ) : string [ ] {
6677 if ( ! outputModeInput || outputModeInput . trim ( ) === "" ) {
6778 return [ "pr_comment" ] ; // Default
6879 }
6980
70- const modes = outputModeInput . split ( "," ) . map ( mode => mode . trim ( ) ) . filter ( mode => mode . length > 0 ) ;
71-
81+ const modes = outputModeInput
82+ . split ( "," )
83+ . map ( ( mode ) => mode . trim ( ) )
84+ . filter ( ( mode ) => mode . length > 0 ) ;
85+
7286 if ( modes . length === 0 ) {
7387 return [ "pr_comment" ] ; // Default
7488 }
@@ -77,7 +91,9 @@ export class OutputManager {
7791 return [ ...new Set ( modes ) ] ;
7892 }
7993
80- async createInitial ( context : ParsedGitHubContext ) : Promise < OutputIdentifiers > {
94+ async createInitial (
95+ context : ParsedGitHubContext ,
96+ ) : Promise < OutputIdentifiers > {
8197 const identifiers : OutputIdentifiers = { } ;
8298 const errors : Error [ ] = [ ] ;
8399
@@ -86,8 +102,12 @@ export class OutputManager {
86102 const identifier = await strategy . createInitial ( context ) ;
87103 identifiers [ strategy . name ] = identifier ;
88104 } catch ( error ) {
89- console . error ( `❌ Output strategy ${ strategy . name } failed during createInitial:` , error ) ;
90- const errorObj = error instanceof Error ? error : new Error ( String ( error ) ) ;
105+ console . error (
106+ `❌ Output strategy ${ strategy . name } failed during createInitial:` ,
107+ error ,
108+ ) ;
109+ const errorObj =
110+ error instanceof Error ? error : new Error ( String ( error ) ) ;
91111 errors . push ( errorObj ) ;
92112 identifiers [ strategy . name ] = null ;
93113 }
@@ -96,7 +116,9 @@ export class OutputManager {
96116 // If all strategies failed during initial creation, that's a problem
97117 if ( errors . length === this . strategies . length ) {
98118 const lastError = errors [ errors . length - 1 ] ;
99- throw new Error ( `All output strategies failed during initial creation. Last error: ${ lastError ?. message || 'Unknown error' } ` ) ;
119+ throw new Error (
120+ `All output strategies failed during initial creation. Last error: ${ lastError ?. message || "Unknown error" } ` ,
121+ ) ;
100122 }
101123
102124 return identifiers ;
@@ -105,7 +127,7 @@ export class OutputManager {
105127 async updateFinal (
106128 identifiers : OutputIdentifiers ,
107129 context : ParsedGitHubContext ,
108- content : ReviewContent
130+ content : ReviewContent ,
109131 ) : Promise < void > {
110132 const errors : Error [ ] = [ ] ;
111133
@@ -114,20 +136,28 @@ export class OutputManager {
114136 const identifier = identifiers [ strategy . name ] || null ;
115137 await strategy . updateFinal ( identifier , context , content ) ;
116138 } catch ( error ) {
117- console . error ( `❌ Output strategy ${ strategy . name } failed during updateFinal:` , error ) ;
118- const errorObj = error instanceof Error ? error : new Error ( String ( error ) ) ;
139+ console . error (
140+ `❌ Output strategy ${ strategy . name } failed during updateFinal:` ,
141+ error ,
142+ ) ;
143+ const errorObj =
144+ error instanceof Error ? error : new Error ( String ( error ) ) ;
119145 errors . push ( errorObj ) ;
120146 }
121147 }
122148
123149 // If all strategies failed, throw an error to mark the action as failed
124150 if ( errors . length === this . strategies . length ) {
125- throw new Error ( `All ${ this . strategies . length } output strategies failed. See logs for details.` ) ;
151+ throw new Error (
152+ `All ${ this . strategies . length } output strategies failed. See logs for details.` ,
153+ ) ;
126154 }
127155
128156 // If some strategies failed but others succeeded, log a warning
129157 if ( errors . length > 0 ) {
130- console . warn ( `⚠️ ${ errors . length } of ${ this . strategies . length } output strategies failed, but action completed partially.` ) ;
158+ console . warn (
159+ `⚠️ ${ errors . length } of ${ this . strategies . length } output strategies failed, but action completed partially.` ,
160+ ) ;
131161 }
132162 }
133163
@@ -169,8 +199,11 @@ export class OutputManager {
169199 try {
170200 return JSON . parse ( serialized ) ;
171201 } catch ( error ) {
172- console . warn ( "Failed to parse identifiers JSON, treating as empty:" , error ) ;
202+ console . warn (
203+ "Failed to parse identifiers JSON, treating as empty:" ,
204+ error ,
205+ ) ;
173206 return { } ;
174207 }
175208 }
176- }
209+ }
0 commit comments