@@ -4,11 +4,11 @@ const { glob } = require('glob');
44const chalk = require ( 'chalk' ) ;
55
66/**
7- * Find files containing @since todo tags
7+ * Find files containing @since and deprecated version placeholder tags
88 */
99async function findSinceTodoFiles ( pattern = '**/*.php' ) {
1010 try {
11- console . log ( chalk . blue ( '\nScanning for @since placeholder tags...' ) ) ;
11+ console . log ( chalk . blue ( '\nScanning for ` @since` and deprecated version placeholder tags...' ) ) ;
1212
1313 // Define specific directories to scan
1414 const includePaths = [
@@ -67,7 +67,7 @@ async function findSinceTodoFiles(pattern = '**/*.php') {
6767}
6868
6969/**
70- * Get all @since placeholders from a file
70+ * Get all @since and deprecated version placeholders from a file
7171 */
7272function getSincePlaceholders ( content ) {
7373 // Look for both @since placeholders and standalone @next-version
@@ -81,9 +81,9 @@ function getSincePlaceholders(content) {
8181}
8282
8383/**
84- * Update @since placeholders in a file
84+ * Update @since and deprecated version placeholders in a file
8585 */
86- function updateSinceTags ( filePath , version ) {
86+ function updateSinceTags ( filePath , version , dryRun = false ) {
8787 try {
8888 let content = fs . readFileSync ( filePath , 'utf8' ) ;
8989 const originalContent = content ;
@@ -93,6 +93,11 @@ function updateSinceTags(filePath, version) {
9393 return { updated : false , count : 0 } ;
9494 }
9595
96+ if ( dryRun ) {
97+ // In dry run mode, just return what would be updated
98+ return { updated : true , count : placeholderCount } ;
99+ }
100+
96101 // First replace @since placeholders
97102 content = content . replace (
98103 / @ s i n c e \s + ( t o d o | t b d | n e x t - v e r s i o n ) / gi,
@@ -117,9 +122,9 @@ function updateSinceTags(filePath, version) {
117122}
118123
119124/**
120- * Update all @since todo tags in the project
125+ * Update all @since and deprecated version placeholder tags in the project
121126 */
122- async function updateAllSinceTags ( version , pattern = '**/*.php' ) {
127+ async function updateAllSinceTags ( version , pattern = '**/*.php' , dryRun = false ) {
123128 const results = {
124129 updated : [ ] ,
125130 errors : [ ] ,
@@ -143,36 +148,39 @@ async function updateAllSinceTags(version, pattern = '**/*.php') {
143148
144149 for ( const file of files ) {
145150 try {
146- const { updated, count } = updateSinceTags ( file , version ) ;
151+ const { updated, count } = updateSinceTags ( file , version , dryRun ) ;
147152 if ( updated ) {
148- console . log ( chalk . gray ( `File updated: ${ file } (${ count } updates )` ) ) ;
153+ console . log ( chalk . gray ( `${ dryRun ? 'Will update' : ' File updated' } : ${ file } (${ count } update ${ count === 1 ? '' : 's' } )` ) ) ;
149154 results . updated . push ( { file, count } ) ;
150155 results . totalUpdated += count ;
151156 }
152157 } catch ( error ) {
153- console . error ( chalk . red ( `Error updating ${ file } :` , error . message ) ) ;
158+ console . error ( chalk . red ( `Error ${ dryRun ? 'checking' : ' updating' } ${ file } :` , error . message ) ) ;
154159 results . errors . push ( { file, error : error . message } ) ;
155160 }
156161 }
157162
158163 return results ;
159164 } catch ( error ) {
160- throw new Error ( `Error updating @since tags : ${ error . message } ` ) ;
165+ throw new Error ( `Error ${ dryRun ? 'checking' : ' updating' } version placeholders : ${ error . message } ` ) ;
161166 }
162167}
163168
164169/**
165170 * Generate a summary for release notes
166171 */
167- function generateReleaseNotesSummary ( results ) {
172+ function generateReleaseNotesSummary ( results , isDryRun = false ) {
168173 if ( results . totalUpdated === 0 ) {
169174 return '' ;
170175 }
171176
172- let summary = '### `@since` Tag Updates\n\n' ;
173- summary += `Updated ${ results . totalUpdated } \`@since\` placeholder` ;
174- summary += results . totalUpdated === 1 ? '' : 's' ;
175- summary += ' in the following files:\n\n' ;
177+ let summary = isDryRun ?
178+ '### 🔄 Pending `@since` Tag / Deprecation Updates\n\n' :
179+ '### `@since` Tag / Deprecation Updates\n\n' ;
180+
181+ summary += isDryRun ?
182+ `The following ${ results . totalUpdated } version placeholder${ results . totalUpdated === 1 ? '' : 's' } will be updated during release:\n\n` :
183+ `Updated ${ results . totalUpdated } version placeholder${ results . totalUpdated === 1 ? '' : 's' } in the following files:\n\n` ;
176184
177185 // Debug logging
178186 console . log ( chalk . blue ( '\nGenerating summary for files:' ) ) ;
@@ -190,7 +198,7 @@ function generateReleaseNotesSummary(results) {
190198 summary += '\n#### Errors\n\n' ;
191199 results . errors . forEach ( ( { file, error } ) => {
192200 const relativePath = path . relative ( process . cwd ( ) , file ) ;
193- summary += `- Failed to update \`${ relativePath } \`: ${ error } \n` ;
201+ summary += `- Failed to ${ isDryRun ? 'check' : ' update' } \`${ relativePath } \`: ${ error } \n` ;
194202 } ) ;
195203 }
196204
@@ -202,26 +210,28 @@ function generateReleaseNotesSummary(results) {
202210}
203211
204212/**
205- * CLI command to update @since tags
213+ * CLI command to update @since and deprecated version placeholder tags
206214 */
207215async function main ( ) {
208216 try {
209217 const version = process . argv [ 2 ] ;
218+ const dryRun = process . argv . includes ( '--dry-run' ) ;
219+
210220 if ( ! version ) {
211221 throw new Error ( 'Version argument is required' ) ;
212222 }
213223
214- console . log ( chalk . blue ( '\nUpdating @since placeholder tags ...' ) ) ;
215- const results = await updateAllSinceTags ( version ) ;
224+ console . log ( chalk . blue ( `\n ${ dryRun ? 'Checking' : 'Updating' } @since and deprecated version placeholders ...` ) ) ;
225+ const results = await updateAllSinceTags ( version , '**/*.php' , dryRun ) ;
216226
217227 if ( results . updated . length > 0 ) {
218- console . log ( chalk . green ( ' \n✓ Updated files:' ) ) ;
228+ console . log ( chalk . green ( ` \n✓ ${ dryRun ? 'Files to update' : ' Updated files' } :` ) ) ;
219229 results . updated . forEach ( ( { file, count } ) => {
220230 console . log ( chalk . gray ( ` - ${ path . relative ( process . cwd ( ) , file ) } (${ count } update${ count === 1 ? '' : 's' } )` ) ) ;
221231 } ) ;
222- console . log ( chalk . green ( `\nTotal placeholders updated: ${ results . totalUpdated } ` ) ) ;
232+ console . log ( chalk . green ( `\nTotal placeholders ${ dryRun ? 'to update' : ' updated' } : ${ results . totalUpdated } ` ) ) ;
223233 } else {
224- console . log ( chalk . yellow ( '\nNo @since placeholder tags found' ) ) ;
234+ console . log ( chalk . yellow ( '\nNo @since or deprecated version placeholder tags found' ) ) ;
225235 }
226236
227237 if ( results . errors . length > 0 ) {
@@ -233,7 +243,7 @@ async function main() {
233243 }
234244
235245 // Generate release notes summary
236- const summary = generateReleaseNotesSummary ( results ) ;
246+ const summary = generateReleaseNotesSummary ( results , dryRun ) ;
237247 if ( summary ) {
238248 // Save summary to a temporary file for the workflow to use
239249 const summaryPath = '/tmp/since-tags-summary.md' ;
0 commit comments