@@ -113,6 +113,11 @@ class ReleasePreparation {
113113 await this . updateREPLACEMEs ( ) ;
114114 cli . stopSpinner ( 'Updated REPLACEME items in docs' ) ;
115115
116+ // Update any new deprecations in the codebase.
117+ cli . startSpinner ( 'Updating DEPOXXX items in codebase' ) ;
118+ const depCount = await this . updateDeprecations ( ) ;
119+ cli . stopSpinner ( `Updated ${ depCount } DEPOXXX items in codebase` ) ;
120+
116121 // Fetch date to use in release commit & changelogs.
117122 const todayDate = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
118123 this . date = await cli . prompt ( 'Enter release date in YYYY-MM-DD format:' ,
@@ -225,6 +230,45 @@ class ReleasePreparation {
225230 ] ) . trim ( ) ;
226231 }
227232
233+ async updateDeprecations ( ) {
234+ const deprecationPattern =
235+ / < \s * a i d = " D E P 0 ( [ 0 - 9 ] { 3 } ) + " [ ^ > ] * > < \s * \/ \s * a > / g;
236+ const newDeprecationPattern =
237+ / < \s * a i d = " D E P 0 ( [ X ] + [ 0 - 9 ] * ) + " [ ^ > ] * > < \s * \/ \s * a > / g;
238+
239+ const deprecationFilePath = path . resolve ( 'doc' , 'api' , 'deprecations.md' ) ;
240+ const deprecationFile = await fs . readFile ( deprecationFilePath , 'utf8' ) ;
241+
242+ const deprecationNumbers = [
243+ ...deprecationFile . matchAll ( deprecationPattern )
244+ ] . map ( m => m [ 1 ] ) . reverse ( ) ;
245+ const newDeprecationNumbers = [
246+ ...deprecationFile . matchAll ( newDeprecationPattern )
247+ ] . map ( m => m [ 1 ] ) ;
248+
249+ // Pull highest deprecation number off the list and increment from there.
250+ let depNumber = parseInt ( deprecationNumbers [ 0 ] ) + 1 ;
251+
252+ // Loop through each new unmarked deprecation number and replace instances.
253+ for ( const newDep of newDeprecationNumbers ) {
254+ await replace ( {
255+ files : [
256+ 'doc/api/*.md' ,
257+ 'lib/**/*.js' ,
258+ 'src/**/*.{h,cc}' ,
259+ 'test/**/*.js'
260+ ] ,
261+ ignore : 'test/common/README.md' ,
262+ from : new RegExp ( `DEP0${ newDep } ` , 'g' ) ,
263+ to : `DEP0${ depNumber } `
264+ } ) ;
265+
266+ depNumber ++ ;
267+ }
268+
269+ return newDeprecationNumbers . length ;
270+ }
271+
228272 async updateREPLACEMEs ( ) {
229273 const { newVersion } = this ;
230274
0 commit comments