@@ -9,8 +9,10 @@ const { getMergedConfig } = require('./config');
99const { runAsync, runSync } = require ( './run' ) ;
1010const { writeJson, readJson } = require ( './file' ) ;
1111
12- class Release {
13- constructor ( state , argv , cli , req , dir ) {
12+ const isWindows = process . platform === 'win32' ;
13+
14+ class ReleasePreparation {
15+ constructor ( argv , cli , req , dir ) {
1416 this . cli = cli ;
1517 this . dir = dir ;
1618 this . newVersion = argv . newVersion ;
@@ -49,10 +51,9 @@ class Release {
4951 await this . createProposalBranch ( ) ;
5052
5153 // Update version and release info in src/node_version.h.
52- const shouldUpdateNodeVersion = await cli . prompt (
53- `Update 'src/node_version.h' for ${ newVersion } ?` , true ) ;
54- if ( ! shouldUpdateNodeVersion ) return this . abort ( ) ;
54+ cli . startSpinner ( `Updating 'src/node_version.h' for ${ newVersion } ` ) ;
5555 await this . updateNodeVersion ( ) ;
56+ cli . stopSpinner ( `Updating 'src/node_version.h' for ${ newVersion } ` ) ;
5657
5758 // Check whether to update NODE_MODULE_VERSION (default false).
5859 const shouldUpdateNodeModuleVersion = await cli . prompt (
@@ -71,19 +72,14 @@ class Release {
7172 }
7273
7374 // Update any REPLACEME tags in the docs.
74- const shouldUpdateREPLACEMEs = await cli . prompt (
75- 'Update REPLACEME items in docs?' , true ) ;
76- if ( ! shouldUpdateREPLACEMEs ) return this . abort ( ) ;
75+ cli . startSpinner ( 'Updating REPLACEME items in docs' ) ;
7776 await this . updateREPLACEMEs ( ) ;
77+ cli . stopSpinner ( 'Updated REPLACEME items in docs' ) ;
7878
79+ // Fetch date to use in release commit & changelogs.
7980 this . date = await cli . promptInput (
8081 'Enter release date in YYYY-MM-DD format:' ) ;
8182
82- // Update Changelogs
83- const shouldUpdateChangelogs = await cli . prompt (
84- 'Update changelogs?' , true ) ;
85- if ( ! shouldUpdateChangelogs ) return this . abort ( ) ;
86-
8783 cli . startSpinner ( 'Updating CHANGELOG.md' ) ;
8884 await this . updateMainChangelog ( ) ;
8985 cli . stopSpinner ( 'Updated CHANGELOG.md' ) ;
@@ -101,8 +97,8 @@ class Release {
10197
10298 // Proceed with release only after the releaser has amended
10399 // it to their liking.
104- const created = await this . createReleaseCommit ( ) ;
105- if ( ! created ) {
100+ const createDefaultCommit = await this . createReleaseCommit ( ) ;
101+ if ( ! createDefaultCommit ) {
106102 const lastCommitSha = runSync ( 'git' , [ 'rev-parse' , '--short' , 'HEAD' ] ) ;
107103 cli . warn ( `Please manually edit commit ${ lastCommitSha } by running ` +
108104 '`git commit --amend` before proceeding.' ) ;
@@ -130,10 +126,6 @@ class Release {
130126 ) ;
131127 }
132128
133- async promote ( ) {
134- // TODO(codebytere): implement.
135- }
136-
137129 get owner ( ) {
138130 return this . config . owner || 'nodejs' ;
139131 }
@@ -167,9 +159,14 @@ class Release {
167159 }
168160
169161 getChangelog ( ) {
170- return runSync ( 'npx' , [
171- 'changelog-maker' ,
162+ const changelogMaker = path . join (
163+ __dirname ,
164+ '../node_modules/.bin/changelog-maker' + ( isWindows ? '.cmd' : '' )
165+ ) ;
166+
167+ return runSync ( changelogMaker , [
172168 '--group' ,
169+ '--filter-release' ,
173170 '--start-ref' ,
174171 this . getLastRef ( )
175172 ] ) . trim ( ) ;
@@ -245,15 +242,8 @@ class Release {
245242 const data = await fs . readFile ( majorChangelogPath , 'utf8' ) ;
246243 const arr = data . split ( '\n' ) ;
247244
248- const allCommits = runSync ( 'npx' , [
249- 'changelog-maker' ,
250- '--group' ,
251- '--filter-release' ,
252- '--start-ref' ,
253- lastRef
254- ] ) ;
255-
256- const notableChanges = this . getBranchDiff ( true ) ;
245+ const allCommits = this . getChangelog ( ) ;
246+ const notableChanges = this . getBranchDiff ( { onlyNotableChanges : true } ) ;
257247 const releaseHeader = `## ${ date } , Version ${ newVersion } ` +
258248 ` ${ releaseInfo } , @${ username } \n` ;
259249
@@ -334,7 +324,7 @@ class Release {
334324 messageBody . push ( 'This is a security release.\n\n' ) ;
335325 }
336326
337- const notableChanges = this . getBranchDiff ( true ) ;
327+ const notableChanges = this . getBranchDiff ( { onlyNotableChanges : true } ) ;
338328 messageBody . push ( 'Notable changes:\n\n' ) ;
339329 messageBody . push ( notableChanges ) ;
340330
@@ -349,11 +339,12 @@ class Release {
349339 ] ) ;
350340
351341 cli . log ( `${ messageTitle } \n\n${ messageBody . join ( '' ) } ` ) ;
352- const useMessage = await cli . prompt ( 'Continue with this commit message?' , true ) ;
342+ const useMessage = await cli . prompt (
343+ 'Continue with this commit message?' , true ) ;
353344 return useMessage ;
354345 }
355346
356- getBranchDiff ( onlyNotableChanges = false ) {
347+ getBranchDiff ( opts ) {
357348 const {
358349 versionComponents,
359350 stagingBranch,
@@ -363,7 +354,7 @@ class Release {
363354 } = this ;
364355
365356 let branchDiffOptions ;
366- if ( onlyNotableChanges ) {
357+ if ( opts . onlyNotableChanges ) {
367358 const proposalBranch = `v${ newVersion } -proposal` ;
368359 const releaseBranch = `v${ versionComponents . major } .x` ;
369360
@@ -373,7 +364,6 @@ class Release {
373364 ] ;
374365
375366 branchDiffOptions = [
376- 'branch-diff' ,
377367 `${ upstream } /${ releaseBranch } ` ,
378368 proposalBranch ,
379369 `--require-label=${ notableLabels . join ( ',' ) } ` ,
@@ -388,12 +378,12 @@ class Release {
388378 `backport-blocked-v${ versionComponents . major } .x`
389379 ] ;
390380
391- if ( isLTS ) {
381+ const isSemverMinor = versionComponents . patch === 0 ;
382+ if ( isLTS && ! isSemverMinor ) {
392383 excludeLabels . push ( 'semver-minor' ) ;
393384 }
394385
395386 branchDiffOptions = [
396- 'branch-diff' ,
397387 stagingBranch ,
398388 // TODO(codebytere): use Current branch instead of master for LTS
399389 'master' ,
@@ -403,7 +393,12 @@ class Release {
403393 ] ;
404394 }
405395
406- return runSync ( 'npx' , branchDiffOptions ) ;
396+ const branchDiff = path . join (
397+ __dirname ,
398+ '../node_modules/.bin/branch-diff' + ( isWindows ? '.cmd' : '' )
399+ ) ;
400+
401+ return runSync ( branchDiff , branchDiffOptions ) ;
407402 }
408403
409404 warnForWrongBranch ( ) {
@@ -434,4 +429,4 @@ class Release {
434429 }
435430}
436431
437- module . exports = Release ;
432+ module . exports = ReleasePreparation ;
0 commit comments