Skip to content

Commit

Permalink
Merge pull request #164 from phillipj/blog-post-changelog
Browse files Browse the repository at this point in the history
Release blog post script improvements
  • Loading branch information
phillipj committed Sep 17, 2015
2 parents 372fd2e + 90283ca commit 7ae5aab
Showing 1 changed file with 28 additions and 3 deletions.
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

0 comments on commit 7ae5aab

Please sign in to comment.