|
6 | 6 | PLACEHOLDERS,
|
7 | 7 | checkoutOnSecurityReleaseBranch,
|
8 | 8 | validateDate,
|
9 |
| - SecurityRelease |
| 9 | + SecurityRelease, |
| 10 | + commitAndPushVulnerabilitiesJSON, |
10 | 11 | } from './security-release/security-release.js';
|
11 | 12 | import auth from './auth.js';
|
12 | 13 | import Request from './request.js';
|
@@ -56,16 +57,41 @@ export default class SecurityBlog extends SecurityRelease {
|
56 | 57 | const endDate = new Date(data.annoucementDate);
|
57 | 58 | endDate.setDate(endDate.getDate() + 7);
|
58 | 59 |
|
| 60 | + const link = `https://nodejs.org/en/blog/vulnerability/${fileName}`; |
59 | 61 | this.updateWebsiteBanner(site, {
|
60 | 62 | startDate: data.annoucementDate,
|
61 | 63 | endDate: endDate.toISOString(),
|
62 | 64 | text: `New security releases to be made available ${data.releaseDate}`,
|
63 |
| - link: `https://nodejs.org/en/blog/vulnerability/${fileName}`, |
| 65 | + link, |
64 | 66 | type: 'warning'
|
65 | 67 | });
|
66 |
| - |
67 | 68 | fs.writeFileSync(file, preRelease);
|
| 69 | + |
68 | 70 | cli.ok(`Announcement file created and banner has been updated. Folder: ${nodejsOrgFolder}`);
|
| 71 | + await this.updateAnnouncementLink(link); |
| 72 | + } |
| 73 | + |
| 74 | + async updateAnnouncementLink(link) { |
| 75 | + const vulnerabilitiesJSONPath = this.getVulnerabilitiesJSONPath(); |
| 76 | + const content = this.readVulnerabilitiesJSON(vulnerabilitiesJSONPath); |
| 77 | + let shouldCommit = false; |
| 78 | + for (let i = 0; i < content.reports.length; ++i) { |
| 79 | + if (content.reports[i].announcement !== link) { |
| 80 | + content.reports[i].announcement = link; |
| 81 | + shouldCommit = true; |
| 82 | + } |
| 83 | + }; |
| 84 | + |
| 85 | + if (shouldCommit) { |
| 86 | + fs.writeFileSync(vulnerabilitiesJSONPath, JSON.stringify(content, null, 2)); |
| 87 | + const commitMessage = 'chore: add announcement link'; |
| 88 | + commitAndPushVulnerabilitiesJSON([vulnerabilitiesJSONPath], |
| 89 | + commitMessage, { cli: this.cli, repository: this.repository }); |
| 90 | + |
| 91 | + this.cli.ok('Updated the announcement link in vulnerabilities.json'); |
| 92 | + } |
| 93 | + |
| 94 | + return [vulnerabilitiesJSONPath]; |
69 | 95 | }
|
70 | 96 |
|
71 | 97 | async createPostRelease(nodejsOrgFolder) {
|
|
0 commit comments