From f420432c6cbdba51da734276d20f73c75728b409 Mon Sep 17 00:00:00 2001 From: Rafael Gonzaga Date: Wed, 14 Aug 2024 16:52:52 -0300 Subject: [PATCH] feat: update next-security-release folder on cleanup (#840) --- lib/prepare_security.js | 13 +++++++++++++ lib/security-release/security-release.js | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/prepare_security.js b/lib/prepare_security.js index 003c4840..8d4ba962 100644 --- a/lib/prepare_security.js +++ b/lib/prepare_security.js @@ -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} diff --git a/lib/security-release/security-release.js b/lib/security-release/security-release.js index d8308a71..3a4482a7 100644 --- a/lib/security-release/security-release.js +++ b/lib/security-release/security-release.js @@ -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();