@@ -55,9 +55,9 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
5555 async generateSection ( { formatterAdapter, manifest, repositoryProvider, destination } : SectionGenerationPayload < GitHubActionsManifest > ) : Promise < Buffer > {
5656 const version = await this . versionService . getVersion ( this . version , repositoryProvider ) ;
5757 const repositoryInfo = await repositoryProvider . getRepositoryInfo ( ) ;
58-
59- const examples = await this . findExamples ( repositoryInfo . rootDir , manifest , version , destination ) ;
60-
58+
59+ const examples = await this . findExamples ( repositoryInfo . rootDir , destination ) ;
60+
6161 if ( examples . length === 0 ) {
6262 return Buffer . alloc ( 0 ) ;
6363 }
@@ -93,24 +93,24 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
9393 /**
9494 * Find examples from various sources
9595 */
96- private async findExamples ( rootDir : string , manifest : GitHubActionsManifest , version ?: ManifestVersion , destination ?: string ) : Promise < Example [ ] > {
96+ private async findExamples ( rootDir : string , destination ?: string ) : Promise < Example [ ] > {
9797 const examples : Example [ ] = [ ] ;
98-
98+
9999 // Strategy 1: Look for examples/ directory
100100 const examplesDir = join ( rootDir , 'examples' ) ;
101101 if ( existsSync ( examplesDir ) && statSync ( examplesDir ) . isDirectory ( ) ) {
102- examples . push ( ...this . findExamplesFromDirectory ( examplesDir , manifest , version ) ) ;
102+ examples . push ( ...this . findExamplesFromDirectory ( examplesDir ) ) ;
103103 }
104104
105105 // Strategy 2: Look for .github/examples/ directory
106106 const githubExamplesDir = join ( rootDir , '.github' , 'examples' ) ;
107107 if ( existsSync ( githubExamplesDir ) && statSync ( githubExamplesDir ) . isDirectory ( ) ) {
108- examples . push ( ...this . findExamplesFromDirectory ( githubExamplesDir , manifest , version ) ) ;
108+ examples . push ( ...this . findExamplesFromDirectory ( githubExamplesDir ) ) ;
109109 }
110110
111111 // Strategy 3: Look for examples in destination file (if it exists)
112112 if ( destination && existsSync ( destination ) ) {
113- examples . push ( ...this . findExamplesFromReadme ( destination , manifest , version ) ) ;
113+ examples . push ( ...this . findExamplesFromDestination ( destination ) ) ;
114114 }
115115
116116 return examples ;
@@ -119,16 +119,16 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
119119 /**
120120 * Find examples from a directory containing example files
121121 */
122- private findExamplesFromDirectory ( dirPath : string , manifest : GitHubActionsManifest , version ?: ManifestVersion ) : Example [ ] {
122+ private findExamplesFromDirectory ( dirPath : string ) : Example [ ] {
123123 const examples : Example [ ] = [ ] ;
124-
124+
125125 try {
126126 const files = readdirSync ( dirPath ) ;
127-
127+
128128 for ( const file of files ) {
129129 const filePath = join ( dirPath , file ) ;
130130 const stat = statSync ( filePath ) ;
131-
131+
132132 if ( stat . isFile ( ) ) {
133133 const ext = extname ( file ) . toLowerCase ( ) ;
134134 if ( [ '.yml' , '.yaml' ] . includes ( ext ) ) {
@@ -151,39 +151,39 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
151151 } catch ( error ) {
152152 // Silently handle directory read errors
153153 }
154-
154+
155155 return examples ;
156156 }
157157
158158 /**
159159 * Extract examples from README.md or destination file
160160 */
161- private findExamplesFromReadme ( readmePath : string , manifest : GitHubActionsManifest , version ?: ManifestVersion ) : Example [ ] {
161+ private findExamplesFromDestination ( destination : string ) : Example [ ] {
162162 const examples : Example [ ] = [ ] ;
163-
163+
164164 try {
165- const content = readFileSync ( readmePath , 'utf8' ) ;
165+ const content = readFileSync ( destination , 'utf8' ) ;
166166 const lines = content . split ( '\n' ) ;
167-
167+
168168 let inExamplesSection = false ;
169169 let inCodeBlock = false ;
170170 let codeBlockLanguage = '' ;
171171 let codeBlockContent = '' ;
172-
172+
173173 for ( let i = 0 ; i < lines . length ; i ++ ) {
174174 const line = lines [ i ] ;
175-
175+
176176 // Check if we've entered an examples section
177177 if ( line . match ( / ^ # + \s * e x a m p l e s ? / i) ) {
178178 inExamplesSection = true ;
179179 continue ;
180180 }
181-
181+
182182 // Check if we've left the examples section (next major heading)
183183 if ( inExamplesSection && line . match ( / ^ # [ ^ # ] / ) ) {
184184 break ;
185185 }
186-
186+
187187 if ( inExamplesSection ) {
188188 // Handle code blocks
189189 if ( line . startsWith ( '```' ) ) {
@@ -224,7 +224,7 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
224224 } catch ( error ) {
225225 // Silently handle file read errors
226226 }
227-
227+
228228 return examples ;
229229 }
230230
@@ -233,15 +233,15 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
233233 */
234234 private parseMarkdownExamples ( filePath : string ) : Example [ ] {
235235 const examples : Example [ ] = [ ] ;
236-
236+
237237 try {
238238 const content = readFileSync ( filePath , 'utf8' ) ;
239239 const lines = content . split ( '\n' ) ;
240-
240+
241241 let inCodeBlock = false ;
242242 let codeBlockLanguage = '' ;
243243 let codeBlockContent = '' ;
244-
244+
245245 for ( const line of lines ) {
246246 if ( line . startsWith ( '```' ) ) {
247247 if ( ! inCodeBlock ) {
@@ -278,7 +278,7 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
278278 } catch ( error ) {
279279 // Silently handle file read errors
280280 }
281-
281+
282282 return examples ;
283283 }
284284
@@ -296,7 +296,7 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
296296 const usesMatch = line . match ( / ^ ( \s * - ? \s * u s e s : \s * ) ( .+ ) $ / ) ;
297297 if ( usesMatch ) {
298298 const [ , prefix , actionRef ] = usesMatch ;
299-
299+
300300 // Check if this is referencing the current action
301301 if ( actionRef . includes ( usesName ) || actionRef === './' || actionRef === '.' ) {
302302 // Replace or add version information
@@ -305,10 +305,10 @@ export class ExamplesSectionGenerator extends GitHubActionsSectionGeneratorAdapt
305305 return `${ prefix } ${ baseActionRef } @${ version . sha } ${ versionComment } ` ;
306306 }
307307 }
308-
308+
309309 return line ;
310310 } ) ;
311-
311+
312312 return processedLines . join ( '\n' ) ;
313313 }
314314}
0 commit comments