Skip to content

Commit

Permalink
feat: update DEP0XXX tags during release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed May 20, 2020
1 parent f58051c commit 2ce77f4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class ReleasePreparation {
await this.updateREPLACEMEs();
cli.stopSpinner('Updated REPLACEME items in docs');

// Update any new deprecations in the codebase.
cli.startSpinner('Updating DEPOXXX items in codebase');
const depCount = await this.updateDeprecations();
cli.stopSpinner(`Updated ${depCount} DEPOXXX items in codebase`);

// Fetch date to use in release commit & changelogs.
const todayDate = new Date().toISOString().split('T')[0];
this.date = await cli.prompt('Enter release date in YYYY-MM-DD format:',
Expand Down Expand Up @@ -225,6 +230,41 @@ class ReleasePreparation {
]).trim();
}

async updateDeprecations() {
const deprecationPattern = /<\s*a id="DEP0([0-9]{3})+"[^>]*><\s*\/\s*a>/g;
const newDeprecationPattern = /<\s*a id="DEP0([X]+[0-9]*)+"[^>]*><\s*\/\s*a>/g;

const deprecationFilePath = path.resolve('doc', 'api', 'deprecations.md');
const deprecationFile = await fs.readFile(deprecationFilePath, 'utf8');

const deprecationNumbers = [...deprecationFile.matchAll(deprecationPattern)]
.map(m => m[1]).reverse();
const newDeprecationNumbers = [...deprecationFile.matchAll(newDeprecationPattern)]
.map(m => m[1]);

// Pull the highest deprecation number off the list and increment from there.
let depNumber = parseInt(deprecationNumbers[0]) + 1;

// Loop through each new unmarked deprecation number and replace instances.
for (const newDep of newDeprecationNumbers) {
await replace({
files: [
'doc/api/*.md',
'lib/**/*.js',
'src/**/*.{h,cc}',
'test/**/*.js'
],
ignore: 'test/common/README.md',
from: new RegExp(`DEP0${newDep}`, 'g'),
to: `DEP0${depNumber}`
});

depNumber++;
}

return newDeprecationNumbers.length;
}

async updateREPLACEMEs() {
const { newVersion } = this;

Expand Down

0 comments on commit 2ce77f4

Please sign in to comment.