Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions scripts/release-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

'use strict';

/**
* What's this?? It will help you create release blog
* posts so you wont have to do the tedious work
* of stitching together data from changelog, shasums etc,
* but get a more or less complete release blog ready to go.
*
* Usage: $ node release-post.js [version]
*
* If the version argument is omitted, the latest version number
* will be picked from https://nodejs.org/dist/index.json.
*
* It'll create a file with the blog post content
* into ../locale/en/blog/release/vX.md ready for you to commit
* or possibly edit by hand before commiting.
*
* Happy releasing!
*/

const https = require('https');
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -29,6 +47,11 @@ function download (url, cb) {
// ## 2015-08-04, Version 3.0.0, @rvagg
const rxReleaseSection = /## \d{4}-\d{2}-\d{2}, Version ([^,( ]+)[\s\S]*?(?=## \d{4})/g;

function explicitVersion() {
const versionArg = process.argv[2];
return versionArg ? Promise.resolve(versionArg) : Promise.reject();
}

function findLatestVersion (cb) {
return download('https://nodejs.org/dist/index.json')
.then(JSON.parse)
Expand All @@ -51,7 +74,7 @@ function fetchDocs (version) {
}

function fetchChangelog (version) {
return download('https://raw.githubusercontent.com/nodejs/node/master/CHANGELOG.md')
return download(`https://raw.githubusercontent.com/nodejs/node/v${version}/CHANGELOG.md`)
.then(function (data) {
let matches;

Expand All @@ -67,7 +90,8 @@ function fetchChangelog (version) {
}

function fetchShasums (version) {
return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`);
return download(`https://nodejs.org/dist/v${version}/SHASUMS256.txt.asc`)
.then(null, () => '[INSERT SHASUMS HERE]');
}

function renderPost (results) {
Expand Down Expand Up @@ -98,7 +122,8 @@ function slugify (str) {
return str.replace(/\./g, '-');
}

findLatestVersion()
explicitVersion()
.then(null, findLatestVersion)
.then(fetchDocs)
.then(renderPost)
.then(writeToFile)
Expand Down