From 585007a651984ca446e580f65fff04bd2e9a60da Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Fri, 19 Apr 2024 11:56:25 +0200 Subject: [PATCH] fix: download section --- lib/github/templates/security-post-release.md | 3 +-- lib/security-release/security-release.js | 9 ++------- lib/security_blog.js | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/github/templates/security-post-release.md b/lib/github/templates/security-post-release.md index e7a04016..39b15008 100644 --- a/lib/github/templates/security-post-release.md +++ b/lib/github/templates/security-post-release.md @@ -1,7 +1,7 @@ --- date: %ANNOUNCEMENT_DATE% category: vulnerability -title: %RELEASE_DATE% Security Releases +title: %RELEASE_DATE% Security Releases slug: %SLUG% layout: blog-post author: %AUTHOR% @@ -13,7 +13,6 @@ Updates are now available for the %AFFECTED_VERSIONS% Node.js release lines for following issues. %DEPENDENCY_UPDATES% %REPORTS% - ## Downloads and release details %DOWNLOADS% diff --git a/lib/security-release/security-release.js b/lib/security-release/security-release.js index 570d8fb5..dddec4f9 100644 --- a/lib/security-release/security-release.js +++ b/lib/security-release/security-release.js @@ -6,14 +6,9 @@ import path from 'node:path'; export const NEXT_SECURITY_RELEASE_BRANCH = 'next-security-release'; export const NEXT_SECURITY_RELEASE_FOLDER = 'security-release/next-security-release'; -// export const NEXT_SECURITY_RELEASE_REPOSITORY = { -// owner: 'nodejs-private', -// repo: 'security-release' -// }; - export const NEXT_SECURITY_RELEASE_REPOSITORY = { - owner: 'marco-ippolito', - repo: 'test-repo-security-release' + owner: 'nodejs-private', + repo: 'security-release' }; export const PLACEHOLDERS = { diff --git a/lib/security_blog.js b/lib/security_blog.js index d952fdba..217778a2 100644 --- a/lib/security_blog.js +++ b/lib/security_blog.js @@ -1,6 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; import _ from 'lodash'; +import nv from '@pkgjs/nv'; import { PLACEHOLDERS, getVulnerabilitiesJSON, @@ -197,7 +198,7 @@ export default class SecurityBlog { .replaceAll(PLACEHOLDERS.reports, await this.getReportsTemplate(content)) .replaceAll(PLACEHOLDERS.dependencyUpdates, this.getDependencyUpdatesTemplate(dependencyUpdates)) - .replaceAll(PLACEHOLDERS.downloads, this.getDownloadsTemplate()); + .replaceAll(PLACEHOLDERS.downloads, await this.getDownloadsTemplate(affectedVersions)); } async getReportsTemplate(content) { @@ -265,8 +266,17 @@ export default class SecurityBlog { return template; } - getDownloadsTemplate() { - return ''; + async getDownloadsTemplate(affectedVersions) { + let template = ''; + const versionsToBeReleased = (await nv('supported')).filter( + (v) => affectedVersions.split(', ').includes(`${v.major}.x`) + ); + for (const version of versionsToBeReleased) { + const v = `v${version.major}.${version.minor}.${Number(version.patch) + 1}`; + template += `- [Node.js ${v}](/blog/release/${v}/)\n`; + } + + return template; } getSlug(releaseDate) {