Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: update DEP0XXX tags during release prep
  • Loading branch information
codebytere committed May 30, 2020
commit d97c294dd2024215acf88741263f6abbc29d6c31
44 changes: 44 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,45 @@ 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 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