forked from nodejs/node-core-utils
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle unmarked DEP0XXX tags during landing and release (nodejs…
…#420) Adds an additional step in git node land to automatically update any DEP0XXX, DEP0XX1 etc tags in the codebase to incremented new numbers. The release preparation script will also check for unmarked numbers and optionally update them as well.
- Loading branch information
1 parent
5974797
commit 08bc3fc
Showing
3 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
const { promises: fs } = require('fs'); | ||
const path = require('path'); | ||
const replace = require('replace-in-file'); | ||
|
||
const newDeprecationPattern = | ||
/<\s*a id="DEP0([X]+[0-9]*)+"[^>]*><\s*\/\s*a>/g; | ||
|
||
async function getUnmarkedDeprecations() { | ||
const deprecationFilePath = path.resolve('doc', 'api', 'deprecations.md'); | ||
const deprecationFile = await fs.readFile(deprecationFilePath, 'utf8'); | ||
|
||
const unmarkedDeprecations = [ | ||
...deprecationFile.matchAll(newDeprecationPattern) | ||
].map(m => m[1]); | ||
|
||
return unmarkedDeprecations; | ||
} | ||
|
||
async function updateDeprecations(unmarkedDeprecations) { | ||
const deprecationPattern = | ||
/<\s*a id="DEP0([0-9]{3})+"[^>]*><\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(); | ||
|
||
// 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 unmarked of unmarkedDeprecations) { | ||
await replace({ | ||
files: [ | ||
'doc/api/*.md', | ||
'lib/**/*.js', | ||
'src/**/*.{h,cc}', | ||
'test/**/*.js' | ||
], | ||
ignore: 'test/common/README.md', | ||
from: new RegExp(`DEP0${unmarked}`, 'g'), | ||
to: `DEP0${depNumber}` | ||
}); | ||
|
||
depNumber++; | ||
} | ||
} | ||
|
||
module.exports = { | ||
updateDeprecations, | ||
getUnmarkedDeprecations | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters