@@ -4,24 +4,17 @@ import _ from 'lodash';
4
4
import nv from '@pkgjs/nv' ;
5
5
import {
6
6
PLACEHOLDERS ,
7
- getVulnerabilitiesJSON ,
8
7
checkoutOnSecurityReleaseBranch ,
9
- NEXT_SECURITY_RELEASE_REPOSITORY ,
10
8
validateDate ,
11
- commitAndPushVulnerabilitiesJSON ,
12
- NEXT_SECURITY_RELEASE_FOLDER
9
+ SecurityRelease
13
10
} from './security-release/security-release.js' ;
14
11
import auth from './auth.js' ;
15
12
import Request from './request.js' ;
16
13
17
14
const kChanged = Symbol ( 'changed' ) ;
18
15
19
- export default class SecurityBlog {
20
- repository = NEXT_SECURITY_RELEASE_REPOSITORY ;
16
+ export default class SecurityBlog extends SecurityRelease {
21
17
req ;
22
- constructor ( cli ) {
23
- this . cli = cli ;
24
- }
25
18
26
19
async createPreRelease ( ) {
27
20
const { cli } = this ;
@@ -30,7 +23,7 @@ export default class SecurityBlog {
30
23
checkoutOnSecurityReleaseBranch ( cli , this . repository ) ;
31
24
32
25
// read vulnerabilities JSON file
33
- const content = getVulnerabilitiesJSON ( cli ) ;
26
+ const content = this . readVulnerabilitiesJSON ( ) ;
34
27
// validate the release date read from vulnerabilities JSON
35
28
if ( ! content . releaseDate ) {
36
29
cli . error ( 'Release date is not set in vulnerabilities.json,' +
@@ -72,7 +65,7 @@ export default class SecurityBlog {
72
65
checkoutOnSecurityReleaseBranch ( cli , this . repository ) ;
73
66
74
67
// read vulnerabilities JSON file
75
- const content = getVulnerabilitiesJSON ( cli ) ;
68
+ const content = this . readVulnerabilitiesJSON ( cli ) ;
76
69
if ( ! content . releaseDate ) {
77
70
cli . error ( 'Release date is not set in vulnerabilities.json,' +
78
71
' run `git node security --update-date=YYYY/MM/DD` to set the release date.' ) ;
@@ -113,22 +106,6 @@ export default class SecurityBlog {
113
106
this . updateVulnerabilitiesJSON ( content ) ;
114
107
}
115
108
116
- updateVulnerabilitiesJSON ( content ) {
117
- try {
118
- this . cli . info ( 'Updating vulnerabilities.json' ) ;
119
- const vulnerabilitiesJSONPath = path . join ( process . cwd ( ) ,
120
- NEXT_SECURITY_RELEASE_FOLDER , 'vulnerabilities.json' ) ;
121
- fs . writeFileSync ( vulnerabilitiesJSONPath , JSON . stringify ( content , null , 2 ) ) ;
122
- const commitMessage = 'chore: updated vulnerabilities.json' ;
123
- commitAndPushVulnerabilitiesJSON ( vulnerabilitiesJSONPath ,
124
- commitMessage ,
125
- { cli : this . cli , repository : this . repository } ) ;
126
- } catch ( error ) {
127
- this . cli . error ( 'Error updating vulnerabilities.json' ) ;
128
- this . cli . error ( error ) ;
129
- }
130
- }
131
-
132
109
async promptExistingPreRelease ( cli ) {
133
110
const pathPreRelease = await cli . prompt (
134
111
'Please provide the path of the existing pre-release announcement:' , {
@@ -324,21 +301,6 @@ export default class SecurityBlog {
324
301
return text . join ( '\n' ) ;
325
302
}
326
303
327
- getAffectedVersions ( content ) {
328
- const affectedVersions = new Set ( ) ;
329
- for ( const report of Object . values ( content . reports ) ) {
330
- for ( const affectedVersion of report . affectedVersions ) {
331
- affectedVersions . add ( affectedVersion ) ;
332
- }
333
- }
334
- const parseToNumber = str => + ( str . match ( / [ \d . ] + / g) [ 0 ] ) ;
335
- return Array . from ( affectedVersions )
336
- . sort ( ( a , b ) => {
337
- return parseToNumber ( a ) > parseToNumber ( b ) ? - 1 : 1 ;
338
- } )
339
- . join ( ', ' ) ;
340
- }
341
-
342
304
getSecurityPreReleaseTemplate ( ) {
343
305
return fs . readFileSync (
344
306
new URL (
0 commit comments