Skip to content

Commit 387a271

Browse files
committed
feat: store build and docker issues when --notify-pre-release
1 parent 0bafa24 commit 387a271

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lib/security-announcement.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
NEXT_SECURITY_RELEASE_REPOSITORY,
33
checkoutOnSecurityReleaseBranch,
44
getVulnerabilitiesJSON,
5+
getVulnerabilitiesJSONPath,
56
validateDate,
67
formatDateToYYYYMMDD,
78
createIssue
@@ -40,20 +41,30 @@ export default class SecurityAnnouncement {
4041
validateDate(content.releaseDate);
4142
const releaseDate = new Date(content.releaseDate);
4243

43-
await Promise.all([
44+
const [dockerIssue, buildIssue] = await Promise.all([
4445
this.createDockerNodeIssue(releaseDate),
4546
this.createBuildWGIssue(releaseDate)
4647
]);
47-
}
4848

49+
content.buildIssue = buildIssue;
50+
content.dockerIssue = dockerIssue;
51+
52+
const vulnerabilitiesJSONPath = getVulnerabilitiesJSONPath();
53+
fs.writeFileSync(vulnerabilitiesJSONPath, JSON.stringify(content, null, 2));
54+
const commitMessage = 'chore: add build and docker issue link';
55+
commitAndPushVulnerabilitiesJSON([vulnerabilitiesJSONPath],
56+
commitMessage, { cli: this.cli, repository: this.repository });
57+
58+
this.cli.ok('Added docker and build issue in vulnerabilities.json');
59+
}
4960
async createBuildWGIssue(releaseDate) {
5061
const repository = {
5162
owner: 'nodejs',
5263
repo: 'build'
5364
};
5465

5566
const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate, 'build');
56-
await createIssue(title, content, repository, { cli: this.cli, req: this.req });
67+
return createIssue(title, content, repository, { cli: this.cli, req: this.req });
5768
}
5869

5970
createPreleaseAnnouncementIssue(releaseDate, team) {
@@ -71,6 +82,6 @@ export default class SecurityAnnouncement {
7182
};
7283

7384
const { title, content } = this.createPreleaseAnnouncementIssue(releaseDate, 'docker');
74-
await createIssue(title, content, repository, { cli: this.cli, req: this.req });
85+
return createIssue(title, content, repository, { cli: this.cli, req: this.req });
7586
}
7687
}

lib/security-release/security-release.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ export function getVulnerabilitiesJSON(cli) {
107107
return file;
108108
}
109109

110+
export function getVulnerabilitiesPath() {
111+
const vulnerabilitiesJSONPath = path.join(process.cwd(),
112+
NEXT_SECURITY_RELEASE_FOLDER, 'vulnerabilities.json');
113+
return vulnerabilitiesJSONPath;
114+
}
115+
110116
export function validateDate(releaseDate) {
111117
const value = new Date(releaseDate).valueOf();
112118
if (Number.isNaN(value) || value < 0) {
@@ -135,6 +141,7 @@ export async function createIssue(title, content, repository, { cli, req }) {
135141
const data = await req.createIssue(title, content, repository);
136142
if (data.html_url) {
137143
cli.ok(`Created: ${data.html_url}`);
144+
return data.html_url;
138145
} else {
139146
cli.error(data);
140147
process.exit(1);

0 commit comments

Comments
 (0)