Skip to content

Commit 121dfc8

Browse files
authored
feat: use nodejs.org folder a base for --pre-release (#874)
Fixes: nodejs-private/security-release#15 and nodejs-private/security-release#18
1 parent cc6f1d4 commit 121dfc8

File tree

3 files changed

+32
-12
lines changed

3 files changed

+32
-12
lines changed

components/git/security.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const securityOptions = {
2929
type: 'string'
3030
},
3131
'pre-release': {
32-
describe: 'Create the pre-release announcement',
33-
type: 'boolean'
32+
describe: 'Create the pre-release announcement to the given nodejs.org folder',
33+
type: 'string'
3434
},
3535
'notify-pre-release': {
3636
describe: 'Notify the community about the security release',
@@ -73,7 +73,7 @@ export function builder(yargs) {
7373
'git node security --remove-report=H1-ID',
7474
'Removes the Hackerone report based on ID provided from vulnerabilities.json'
7575
).example(
76-
'git node security --pre-release',
76+
'git node security --pre-release="../nodejs.org/"',
7777
'Create the pre-release announcement on the Nodejs.org repo'
7878
).example(
7979
'git node security --notify-pre-release',
@@ -149,11 +149,12 @@ async function updateReleaseDate(argv) {
149149
return update.updateReleaseDate(releaseDate);
150150
}
151151

152-
async function createPreRelease() {
152+
async function createPreRelease(argv) {
153+
const nodejsOrgFolder = argv['pre-release'];
153154
const logStream = process.stdout.isTTY ? process.stdout : process.stderr;
154155
const cli = new CLI(logStream);
155156
const preRelease = new SecurityBlog(cli);
156-
return preRelease.createPreRelease();
157+
return preRelease.createPreRelease(nodejsOrgFolder);
157158
}
158159

159160
async function requestCVEs() {

docs/git-node.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ ncu-config set waitTimeMultiApproval 48
339339

340340
## `git node v8`
341341

342-
Update or patch the V8 engine.
342+
Update or patch the V8 engine.
343343
This tool will maintain a clone of the V8 repository in `~/.update-v8/v8`
344344
if it's used without `--v8-dir`.
345345

@@ -376,7 +376,7 @@ Options:
376376
### `git node v8 minor`
377377

378378
Compare current V8 version with latest upstream of the same major. Applies a
379-
patch if necessary.
379+
patch if necessary.
380380
If the `git apply` command fails, a patch file will be written in the Node.js
381381
clone directory.
382382

@@ -476,7 +476,7 @@ This command creates a pre-release announcement for the security release.
476476
Example:
477477

478478
```sh
479-
git node security --pre-release
479+
git node security --pre-release="/path/to/nodejs.org"
480480
```
481481

482482
### `git node security --add-report=report-id`

lib/security_blog.js

+23-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const kChanged = Symbol('changed');
1616
export default class SecurityBlog extends SecurityRelease {
1717
req;
1818

19-
async createPreRelease() {
19+
async createPreRelease(nodejsOrgFolder) {
2020
const { cli } = this;
2121

2222
// checkout on security release branch
@@ -45,11 +45,30 @@ export default class SecurityBlog extends SecurityRelease {
4545
};
4646
const month = releaseDate.toLocaleString('en-US', { month: 'long' }).toLowerCase();
4747
const year = releaseDate.getFullYear();
48-
const fileName = `${month}-${year}-security-releases.md`;
48+
const fileName = `${month}-${year}-security-releases`;
49+
const fileNameExt = fileName + '.md';
4950
const preRelease = this.buildPreRelease(template, data);
50-
const file = path.join(process.cwd(), fileName);
51+
52+
const pathToBlogPosts = 'apps/site/pages/en/blog/release';
53+
const pathToBannerJson = 'apps/site/site.json';
54+
55+
const file = path.resolve(process.cwd(), nodejsOrgFolder, pathToBlogPosts, fileNameExt);
56+
const site = path.resolve(process.cwd(), nodejsOrgFolder, pathToBannerJson);
57+
const siteJson = JSON.parse(fs.readFileSync(site));
58+
59+
const endDate = new Date(data.annoucementDate);
60+
endDate.setDate(endDate.getDate() + 7);
61+
const capitalizedMonth = month[0].toUpperCase() + month.slice(1);
62+
siteJson.websiteBanners.index = {
63+
startDate: data.annoucementDate,
64+
endDate: endDate.toISOString(),
65+
text: `${capitalizedMonth} Security Release is available`,
66+
link: `https://nodejs.org/en/blog/vulnerability/${fileName}`,
67+
type: 'warning'
68+
};
5169
fs.writeFileSync(file, preRelease);
52-
cli.ok(`Pre-release announcement file created at ${file}`);
70+
fs.writeFileSync(site, JSON.stringify(siteJson, null, 2));
71+
cli.ok(`Announcement file created and banner has been updated. Folder: ${nodejsOrgFolder}`);
5372
}
5473

5574
async createPostRelease() {

0 commit comments

Comments
 (0)