Skip to content

Commit

Permalink
feat: update next-security-release folder on cleanup (#840)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS authored Aug 14, 2024
1 parent 871a16f commit f420432
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/prepare_security.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ export default class PrepareSecurityRelease extends SecurityRelease {
this.cli.info('Closing pull requests');
// For now, close the ones with vN.x label
await this.closePRWithLabel(this.getAffectedVersions(vulnerabilityJSON));

const updateFolder = this.cli.prompt(
// eslint-disable-next-line max-len
`Would you like to update the next-security-release folder to ${vulnerabilityJSON.releaseDate}?`,
{ defaultAnswer: true });
if (updateFolder) {
const newFolder = this.updateReleaseFolder(vulnerabilityJSON.releaseDate);
commitAndPushVulnerabilitiesJSON(
newFolder,
'chore: change next-security-release folder',
{ cli: this.cli, repository: this.repository }
);
}
this.cli.info(`Merge pull request with:
- git checkout main
- git merge --squash ${NEXT_SECURITY_RELEASE_BRANCH}
Expand Down
8 changes: 8 additions & 0 deletions lib/security-release/security-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ export class SecurityRelease {
NEXT_SECURITY_RELEASE_FOLDER, 'vulnerabilities.json');
}

updateReleaseFolder(releaseDate) {
const folder = path.join(process.cwd(),
NEXT_SECURITY_RELEASE_FOLDER);
const newFolder = path.join(process.cwd(), releaseDate);
fs.renameSync(folder, newFolder);
return newFolder;
}

updateVulnerabilitiesJSON(content) {
try {
const vulnerabilitiesJSONPath = this.getVulnerabilitiesJSONPath();
Expand Down

0 comments on commit f420432

Please sign in to comment.