@@ -6,32 +6,60 @@ const chalk = require('chalk');
66/**
77 * Find files containing @since todo tags
88 */
9- async function findSinceTodoFiles ( pattern ) {
9+ async function findSinceTodoFiles ( pattern = '**/*.php' ) {
1010 try {
1111 console . log ( chalk . blue ( '\nScanning for @since placeholder tags...' ) ) ;
12- console . log ( chalk . gray ( 'Looking for files matching pattern:' , pattern ) ) ;
13-
14- const files = glob . sync ( pattern , {
15- ignore : [
16- 'node_modules/**' ,
17- 'vendor/**' ,
18- 'phpcs/**' ,
19- '.github/**' ,
20- '.wordpress-org/**' ,
21- 'bin/**' ,
22- 'build/**' ,
23- 'docker/**' ,
24- 'img/**' ,
25- 'phpstan/**' ,
26- 'docs/**'
27- ] ,
28- dot : false ,
29- cwd : process . cwd ( ) ,
30- absolute : true // Get absolute paths
31- } ) ;
12+
13+ // Define specific directories to scan
14+ const includePaths = [
15+ '*.php' , // Root PHP files
16+ 'src/**/*.php' , // All PHP files in src directory
17+ 'tests/**/*.php' // All PHP files in tests directory
18+ ] ;
19+
20+ // Define directories to always ignore
21+ const ignorePaths = [
22+ 'vendor/**' , // Third-party dependencies
23+ 'node_modules/**' , // NPM dependencies
24+ 'wp-content/**' , // WordPress content directory
25+ '.wordpress-org/**' , // WordPress.org assets
26+ '.git/**' , // Git directory
27+ '.github/**' , // GitHub specific files
28+ 'bin/**' , // Binary files
29+ 'build/**' , // Build artifacts
30+ 'dist/**' , // Distribution files
31+ 'assets/**' , // Asset files
32+ 'docs/**' , // Documentation
33+ 'languages/**' , // Translation files
34+ 'logs/**' , // Log files
35+ 'temp/**' , // Temporary files
36+ 'tmp/**' , // Temporary files
37+ 'cache/**' // Cache files
38+ ] ;
39+
40+ console . log ( chalk . gray ( 'Scanning directories:' , includePaths . join ( ', ' ) ) ) ;
41+ console . log ( chalk . gray ( 'Ignoring directories:' , ignorePaths . join ( ', ' ) ) ) ;
42+
43+ // Get files from each include path
44+ const allFiles = [ ] ;
45+ for ( const includePath of includePaths ) {
46+ const files = glob . sync ( includePath , {
47+ ignore : ignorePaths ,
48+ dot : false ,
49+ cwd : process . cwd ( ) ,
50+ nodir : true , // Don't include directories in the results
51+ absolute : false // Get relative paths initially
52+ } ) ;
53+ allFiles . push ( ...files ) ;
54+ }
3255
33- console . log ( chalk . gray ( `Found ${ files . length } PHP files to scan` ) ) ;
34- return files || [ ] ;
56+ // Remove duplicates and convert to absolute paths
57+ const uniqueFiles = [ ...new Set ( allFiles ) ] . map ( file => path . resolve ( process . cwd ( ) , file ) ) ;
58+
59+ console . log ( chalk . gray ( `Found ${ uniqueFiles . length } PHP files to scan` ) ) ;
60+ console . log ( chalk . gray ( 'Files found:' , uniqueFiles ) ) ;
61+
62+ return uniqueFiles ;
3563 } catch ( error ) {
3664 console . error ( chalk . red ( 'Error finding files:' , error . message ) ) ;
3765 return [ ] ;
@@ -108,16 +136,21 @@ async function updateAllSinceTags(version, pattern = '**/*.php') {
108136 }
109137
110138 const files = await findSinceTodoFiles ( pattern ) ;
111- console . log ( chalk . gray ( 'Files to process:' , files ) ) ;
139+
140+ // Debug logging
141+ console . log ( chalk . blue ( '\nProcessing files:' ) ) ;
142+ console . log ( files ) ;
112143
113144 for ( const file of files ) {
114145 try {
115146 const { updated, count } = updateSinceTags ( file , version ) ;
116147 if ( updated ) {
148+ console . log ( chalk . gray ( `File updated: ${ file } (${ count } updates)` ) ) ;
117149 results . updated . push ( { file, count } ) ;
118150 results . totalUpdated += count ;
119151 }
120152 } catch ( error ) {
153+ console . error ( chalk . red ( `Error updating ${ file } :` , error . message ) ) ;
121154 results . errors . push ( { file, error : error . message } ) ;
122155 }
123156 }
@@ -136,14 +169,20 @@ function generateReleaseNotesSummary(results) {
136169 return '' ;
137170 }
138171
139- let summary = '### `@since` / deprecated version placeholder replacement \n\n' ;
140- summary += `Updated ${ results . totalUpdated } \`@since\` or deprecated version placeholder` ;
172+ let summary = '### `@since` Tag Updates \n\n' ;
173+ summary += `Updated ${ results . totalUpdated } \`@since\` placeholder` ;
141174 summary += results . totalUpdated === 1 ? '' : 's' ;
142175 summary += ' in the following files:\n\n' ;
143176
177+ // Debug logging
178+ console . log ( chalk . blue ( '\nGenerating summary for files:' ) ) ;
179+ console . log ( results . updated ) ;
180+
144181 results . updated . forEach ( ( { file, count } ) => {
145182 // Get the relative path from the project root
146183 const relativePath = path . relative ( process . cwd ( ) , file ) ;
184+ console . log ( chalk . gray ( `Processing file: ${ file } ` ) ) ;
185+ console . log ( chalk . gray ( `Relative path: ${ relativePath } ` ) ) ;
147186 summary += `- \`${ relativePath } \` (${ count } update${ count === 1 ? '' : 's' } )\n` ;
148187 } ) ;
149188
@@ -155,6 +194,10 @@ function generateReleaseNotesSummary(results) {
155194 } ) ;
156195 }
157196
197+ // Debug logging
198+ console . log ( chalk . blue ( '\nGenerated summary:' ) ) ;
199+ console . log ( summary ) ;
200+
158201 return summary ;
159202}
160203
0 commit comments