From bdb85a939f1d944f1174985e6dda2b7ecc20e9ad Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 24 Sep 2023 11:13:38 +0200 Subject: [PATCH] chore!: remove unmarked DEP0XXX handler (#685) The deprecation numbers are linted by the `test-doc` test suite, and using `DEP0XXX` would be flagged as invalid before the PR can land. --- lib/deprecations.js | 50 ------------------------------------------ lib/landing_session.js | 21 ------------------ lib/prepare_release.js | 24 -------------------- 3 files changed, 95 deletions(-) delete mode 100644 lib/deprecations.js diff --git a/lib/deprecations.js b/lib/deprecations.js deleted file mode 100644 index 0118762b..00000000 --- a/lib/deprecations.js +++ /dev/null @@ -1,50 +0,0 @@ -import { promises as fs } from 'node:fs'; -import path from 'node:path'; - -import replace from 'replace-in-file'; - -const newDeprecationPattern = -/<\s*a id="DEP0([X]+[0-9]*)+"[^>]*><\s*\/\s*a>/g; - -export 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; -} - -export 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++; - } -} diff --git a/lib/landing_session.js b/lib/landing_session.js index d0a6f1a0..9deb8cb9 100644 --- a/lib/landing_session.js +++ b/lib/landing_session.js @@ -1,9 +1,5 @@ import os from 'node:os'; -import { - getUnmarkedDeprecations, - updateDeprecations -} from './deprecations.js'; import { runAsync, runSync, forceRunAsync } from './run.js'; @@ -128,23 +124,6 @@ export default class LandingSession extends Session { process.exit(1); } - // Check for and maybe assign any unmarked deprecations in the codebase. - if (this.updateDeprecations !== 'yes') { - const unmarkedDeprecations = await getUnmarkedDeprecations(); - const unmarkedDepCount = unmarkedDeprecations.length; - if (unmarkedDepCount > 0) { - cli.startSpinner('Assigning deprecation numbers to DEPOXXX items'); - - // Update items then stage files and amend the last commit. - await updateDeprecations(unmarkedDeprecations); - await runAsync('git', ['add', 'doc', 'lib', 'src', 'test']); - await runAsync('git', ['commit', '--amend', '--no-edit', ...this.gpgSign]); - - cli - .stopSpinner(`Updated ${unmarkedDepCount} DEPOXXX items in codebase`); - } - } - cli.ok('Patches applied'); return commitInfo; } diff --git a/lib/prepare_release.js b/lib/prepare_release.js index abd8303f..2a54fcc1 100644 --- a/lib/prepare_release.js +++ b/lib/prepare_release.js @@ -9,10 +9,6 @@ import { runAsync, runSync } from './run.js'; import { writeJson, readJson } from './file.js'; import Request from './request.js'; import auth from './auth.js'; -import { - getUnmarkedDeprecations, - updateDeprecations -} from './deprecations.js'; import { getEOLDate, getStartLTSBlurb, @@ -279,26 +275,6 @@ export default class ReleasePreparation { await this.updateREPLACEMEs(); cli.stopSpinner('Updated REPLACEME items in docs'); - // Check for and maybe assign any unmarked deprecations in the codebase. - const unmarkedDeprecations = await getUnmarkedDeprecations(); - const unmarkedDepCount = unmarkedDeprecations.length; - if (unmarkedDepCount > 0) { - if (unmarkedDepCount === 1) { - cli.startSpinner( - 'Assigning deprecation number to DEPOXXX item'); - await updateDeprecations(unmarkedDeprecations); - cli.stopSpinner('Assigned deprecation numbers to DEPOXXX items'); - } else { - cli.warn( - 'More than one unmarked DEPOXXX item - manual resolution required.'); - - await cli.prompt( - `Finished updating ${unmarkedDepCount} unmarked DEPOXXX items?`, - { defaultAnswer: false }); - cli.stopSpinner(`Finished updating ${unmarkedDepCount} DEPOXXX items`); - } - } - // 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:',