22
33'use strict' ;
44
5+ /**
6+ * What's this?? It will help you create release blog
7+ * posts so you wont have to do the tedious work
8+ * of stitching together data from changelog, shasums etc,
9+ * but get a more or less complete release blog ready to go.
10+ *
11+ * Usage: $ node release-post.js [version]
12+ *
13+ * If the version argument is omitted, the latest version number
14+ * will be picked from https://nodejs.org/dist/index.json.
15+ *
16+ * It'll create a file with the blog post content
17+ * into ../locale/en/blog/release/vX.md ready for you to commit
18+ * or possibly edit by hand before commiting.
19+ *
20+ * Happy releasing!
21+ */
22+
523const https = require ( 'https' ) ;
624const fs = require ( 'fs' ) ;
725const path = require ( 'path' ) ;
@@ -29,6 +47,11 @@ function download (url, cb) {
2947// ## 2015-08-04, Version 3.0.0, @rvagg
3048const rxReleaseSection = / # # \d { 4 } - \d { 2 } - \d { 2 } , V e r s i o n ( [ ^ , ( ] + ) [ \s \S ] * ?(? = # # \d { 4 } ) / g;
3149
50+ function explicitVersion ( ) {
51+ const versionArg = process . argv [ 2 ] ;
52+ return versionArg ? Promise . resolve ( versionArg ) : Promise . reject ( ) ;
53+ }
54+
3255function findLatestVersion ( cb ) {
3356 return download ( 'https://nodejs.org/dist/index.json' )
3457 . then ( JSON . parse )
@@ -51,7 +74,7 @@ function fetchDocs (version) {
5174}
5275
5376function fetchChangelog ( version ) {
54- return download ( ' https://raw.githubusercontent.com/nodejs/node/master /CHANGELOG.md' )
77+ return download ( ` https://raw.githubusercontent.com/nodejs/node/v ${ version } /CHANGELOG.md` )
5578 . then ( function ( data ) {
5679 let matches ;
5780
@@ -67,7 +90,8 @@ function fetchChangelog (version) {
6790}
6891
6992function fetchShasums ( version ) {
70- return download ( `https://nodejs.org/dist/v${ version } /SHASUMS256.txt.asc` ) ;
93+ return download ( `https://nodejs.org/dist/v${ version } /SHASUMS256.txt.asc` )
94+ . then ( null , ( ) => '[INSERT SHASUMS HERE]' ) ;
7195}
7296
7397function renderPost ( results ) {
@@ -98,7 +122,8 @@ function slugify (str) {
98122 return str . replace ( / \. / g, '-' ) ;
99123}
100124
101- findLatestVersion ( )
125+ explicitVersion ( )
126+ . then ( null , findLatestVersion )
102127 . then ( fetchDocs )
103128 . then ( renderPost )
104129 . then ( writeToFile )
0 commit comments