|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 | 3 | const path = require('path');
|
4 |
| -const fs = require('fs').promises; |
| 4 | +const { promises: fs } = require('fs'); |
5 | 5 | const semver = require('semver');
|
6 | 6 | const replace = require('replace-in-file');
|
7 | 7 |
|
8 | 8 | const { getMergedConfig } = require('./config');
|
9 | 9 | const { runAsync, runSync } = require('./run');
|
10 | 10 | const { writeJson, readJson } = require('./file');
|
| 11 | +const { |
| 12 | + getUnmarkedDeprecations, |
| 13 | + updateDeprecations |
| 14 | +} = require('./deprecations'); |
11 | 15 |
|
12 | 16 | const isWindows = process.platform === 'win32';
|
13 | 17 |
|
@@ -113,10 +117,22 @@ class ReleasePreparation {
|
113 | 117 | await this.updateREPLACEMEs();
|
114 | 118 | cli.stopSpinner('Updated REPLACEME items in docs');
|
115 | 119 |
|
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 | + // Check for any unmarked deprecations in the codebase. |
| 121 | + const unmarkedDepCount = await getUnmarkedDeprecations(); |
| 122 | + if (unmarkedDepCount > 0) { |
| 123 | + const mark = await cli.prompt( |
| 124 | + `Automatically mark ${unmarkedDepCount} deprecations?`); |
| 125 | + if (mark) { |
| 126 | + cli.startSpinner( |
| 127 | + `Marking ${unmarkedDepCount} unmarked DEPOXXX items in codebase`); |
| 128 | + const depCount = await updateDeprecations(); |
| 129 | + cli.stopSpinner(`Updated ${depCount} DEPOXXX items in codebase`); |
| 130 | + } else { |
| 131 | + await cli.prompt('Finished updating unmarked DEPOXXX item?', |
| 132 | + { defaultAnswer: false }); |
| 133 | + cli.stopSpinner('Finished updating DEPOXXX items in codebase'); |
| 134 | + } |
| 135 | + } |
120 | 136 |
|
121 | 137 | // Fetch date to use in release commit & changelogs.
|
122 | 138 | const todayDate = new Date().toISOString().split('T')[0];
|
@@ -230,45 +246,6 @@ class ReleasePreparation {
|
230 | 246 | ]).trim();
|
231 | 247 | }
|
232 | 248 |
|
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 |
| - |
272 | 249 | async updateREPLACEMEs() {
|
273 | 250 | const { newVersion } = this;
|
274 | 251 |
|
|
0 commit comments