Skip to content

Commit f420432

Browse files
authored
feat: update next-security-release folder on cleanup (#840)
1 parent 871a16f commit f420432

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/prepare_security.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ export default class PrepareSecurityRelease extends SecurityRelease {
5454
this.cli.info('Closing pull requests');
5555
// For now, close the ones with vN.x label
5656
await this.closePRWithLabel(this.getAffectedVersions(vulnerabilityJSON));
57+
58+
const updateFolder = this.cli.prompt(
59+
// eslint-disable-next-line max-len
60+
`Would you like to update the next-security-release folder to ${vulnerabilityJSON.releaseDate}?`,
61+
{ defaultAnswer: true });
62+
if (updateFolder) {
63+
const newFolder = this.updateReleaseFolder(vulnerabilityJSON.releaseDate);
64+
commitAndPushVulnerabilitiesJSON(
65+
newFolder,
66+
'chore: change next-security-release folder',
67+
{ cli: this.cli, repository: this.repository }
68+
);
69+
}
5770
this.cli.info(`Merge pull request with:
5871
- git checkout main
5972
- git merge --squash ${NEXT_SECURITY_RELEASE_BRANCH}

lib/security-release/security-release.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ export class SecurityRelease {
233233
NEXT_SECURITY_RELEASE_FOLDER, 'vulnerabilities.json');
234234
}
235235

236+
updateReleaseFolder(releaseDate) {
237+
const folder = path.join(process.cwd(),
238+
NEXT_SECURITY_RELEASE_FOLDER);
239+
const newFolder = path.join(process.cwd(), releaseDate);
240+
fs.renameSync(folder, newFolder);
241+
return newFolder;
242+
}
243+
236244
updateVulnerabilitiesJSON(content) {
237245
try {
238246
const vulnerabilitiesJSONPath = this.getVulnerabilitiesJSONPath();

0 commit comments

Comments
 (0)