Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
NEXT_SECURITY_RELEASE_BRANCH,
NEXT_SECURITY_RELEASE_FOLDER,
NEXT_SECURITY_RELEASE_REPOSITORY,
PLACEHOLDERS,
checkoutOnSecurityReleaseBranch,
commitAndPushVulnerabilitiesJSON,
validateDate,
Expand Down Expand Up @@ -37,22 +36,15 @@ export default class PrepareSecurityRelease {
const createVulnerabilitiesJSON = await this.promptVulnerabilitiesJSON();

let securityReleasePRUrl;
const content = await this.buildDescription(releaseDate, securityReleasePRUrl);
if (createVulnerabilitiesJSON) {
securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate);
securityReleasePRUrl = await this.startVulnerabilitiesJSONCreation(releaseDate, content);
}

const createIssue = await this.promptCreateRelaseIssue();

if (createIssue) {
const content = await this.buildIssue(releaseDate, securityReleasePRUrl);
await createIssue(
this.title, content, this.repository, { cli: this.cli, repository: this.repository });
};

this.cli.ok('Done!');
}

async startVulnerabilitiesJSONCreation(releaseDate) {
async startVulnerabilitiesJSONCreation(releaseDate, content) {
// checkout on the next-security-release branch
checkoutOnSecurityReleaseBranch(this.cli, this.repository);

Expand Down Expand Up @@ -87,7 +79,7 @@ export default class PrepareSecurityRelease {
if (!createPr) return;

// create pr on the security-release repo
return this.createPullRequest();
return this.createPullRequest(content);
}

promptCreatePR() {
Expand Down Expand Up @@ -143,11 +135,9 @@ export default class PrepareSecurityRelease {
{ defaultAnswer: true });
}

async buildIssue(releaseDate, securityReleasePRUrl = PLACEHOLDERS.vulnerabilitiesPRURL) {
async buildDescription() {
const template = await this.getSecurityIssueTemplate();
const content = template.replace(PLACEHOLDERS.releaseDate, releaseDate)
.replace(PLACEHOLDERS.vulnerabilitiesPRURL, securityReleasePRUrl);
return content;
return template;
}

async chooseReports() {
Expand Down Expand Up @@ -185,11 +175,11 @@ export default class PrepareSecurityRelease {
return fullPath;
}

async createPullRequest() {
async createPullRequest(content) {
const { owner, repo } = this.repository;
const response = await this.req.createPullRequest(
this.title,
'List of vulnerabilities to be included in the next security release',
content ?? 'List of vulnerabilities to be included in the next security release',
{
owner,
repo,
Expand Down