Skip to content

Commit 3a8e38c

Browse files
committed
feat: update DEP0XXX tags during release prep
1 parent f58051c commit 3a8e38c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/prepare_release.js

+44
Original file line numberDiff line numberDiff line change
@@ -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 id="DEP0([0-9]{3})+"[^>]*><\s*\/\s*a>/g;
236+
const newDeprecationPattern =
237+
/<\s*a id="DEP0([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

Comments
 (0)