@rocket.chat/houston 0.22.0 โ 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +47 -7
- package/package.json +9 -6
- package/src/logs.js +61 -63
- package/src/md.js +97 -231
- package/src/release-table.js +60 -0
- package/src/set-version.js +126 -46
- package/templates/_helpers.js +128 -0
- package/templates/changelog.hbs +3 -0
- package/templates/contributors.hbs +8 -0
- package/templates/header.hbs +3 -0
- package/templates/prs.hbs +18 -0
- package/templates/pull_requests.hbs +8 -0
- package/templates/rcs.hbs +5 -0
- package/templates/release.hbs +9 -0
- package/templates/summary.hbs +3 -0
package/bin/cli.js
CHANGED
|
@@ -1,33 +1,73 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const updateNotifier = require('update-notifier');
|
|
4
|
+
const program = require('commander');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const gitUrlParse = require('git-url-parse');
|
|
7
|
+
const git = require('simple-git/promise')(process.cwd());
|
|
8
|
+
|
|
4
9
|
const pkg = require('../package.json');
|
|
5
10
|
updateNotifier({pkg}).notify();
|
|
6
11
|
|
|
7
|
-
const program = require('commander');
|
|
8
12
|
const logs = require('../src/logs');
|
|
9
13
|
const md = require('../src/md');
|
|
14
|
+
const releaseTable = require('../src/release-table');
|
|
15
|
+
const setVersion = require('../src/set-version');
|
|
16
|
+
|
|
17
|
+
const getRepoInfo = async() => {
|
|
18
|
+
const remote = await git.listRemote(['--get-url', 'origin']);
|
|
19
|
+
|
|
20
|
+
const info = gitUrlParse(remote);
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
owner: info.organization,
|
|
24
|
+
repo: info.name
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let getMetadata = () => Promise.resolve({});
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
getMetadata = require(path.resolve(process.cwd(), '.houston/metadata.js'));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
//
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let repoPkg = {};
|
|
37
|
+
try {
|
|
38
|
+
repoPkg = require(path.resolve(process.cwd(), './package.json'));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
//
|
|
41
|
+
}
|
|
10
42
|
|
|
11
43
|
program
|
|
12
44
|
.command('logs')
|
|
13
45
|
.description('Generate history.json')
|
|
14
46
|
.option('-h, --head_name <name>', 'Name of the new release. Will rename the current HEAD section')
|
|
15
|
-
.
|
|
16
|
-
|
|
47
|
+
.option('-t, --min_tag <tag>', 'Minimum tag to scrap the history')
|
|
48
|
+
.action(async function({head_name, min_tag}) {
|
|
49
|
+
logs({headName: head_name, minTag: min_tag, ...await getRepoInfo(), ...repoPkg.houston, getMetadata });
|
|
17
50
|
});
|
|
18
51
|
|
|
19
52
|
program
|
|
20
53
|
.command('md')
|
|
21
54
|
.description('Generate History.md from History.json')
|
|
22
|
-
.action(function() {
|
|
23
|
-
md();
|
|
55
|
+
.action(async function() {
|
|
56
|
+
md({ ...await getRepoInfo() });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
program
|
|
60
|
+
.command('release-table')
|
|
61
|
+
.description('Generate a markdown table of supported versions')
|
|
62
|
+
.action(async function() {
|
|
63
|
+
releaseTable({ ...await getRepoInfo() });
|
|
24
64
|
});
|
|
25
65
|
|
|
26
66
|
program
|
|
27
67
|
.command('release')
|
|
28
68
|
.description('Release a new version')
|
|
29
|
-
.action(function() {
|
|
30
|
-
|
|
69
|
+
.action(async function() {
|
|
70
|
+
setVersion(await getRepoInfo(), getMetadata);
|
|
31
71
|
});
|
|
32
72
|
|
|
33
73
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocket.chat/houston",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Rocket.Chat Command Line Tools",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,14 +17,17 @@
|
|
|
17
17
|
"houston": "./bin/cli.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@octokit/rest": "^
|
|
20
|
+
"@octokit/rest": "^18.6.7",
|
|
21
21
|
"commander": "^2.19.0",
|
|
22
|
-
"eslint": "^
|
|
22
|
+
"eslint": "^7.30.0",
|
|
23
|
+
"git-url-parse": "^11.5.0",
|
|
24
|
+
"handlebars": "^4.7.7",
|
|
23
25
|
"inquirer": "^5.2.0",
|
|
26
|
+
"just-handlebars-helpers": "^1.0.18",
|
|
24
27
|
"progress": "^2.0.3",
|
|
25
|
-
"semver": "^
|
|
26
|
-
"simple-git": "^
|
|
27
|
-
"underscore": "^1.
|
|
28
|
+
"semver": "^7.3.5",
|
|
29
|
+
"simple-git": "^2.40.0",
|
|
30
|
+
"underscore": "^1.13.1",
|
|
28
31
|
"update-notifier": "^2.5.0"
|
|
29
32
|
},
|
|
30
33
|
"bugs": {
|
package/src/logs.js
CHANGED
|
@@ -4,10 +4,9 @@ const semver = require('semver');
|
|
|
4
4
|
const ProgressBar = require('progress');
|
|
5
5
|
const _ = require('underscore');
|
|
6
6
|
const git = require('simple-git/promise')(process.cwd());
|
|
7
|
-
const
|
|
7
|
+
const { Octokit } = require('@octokit/rest');
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
const commitRegexString = '(^Merge pull request #([0-9]+) from )|( \\(#([0-9]+)\\)$)';
|
|
9
|
+
const commitRegexString = '(^Merge pull request #([0-9]+) from )|( ?\\(?#([0-9]+)\\)?$)';
|
|
11
10
|
const commitRegex = new RegExp(commitRegexString);
|
|
12
11
|
|
|
13
12
|
const https = require('https');
|
|
@@ -50,12 +49,12 @@ if (!historyData.version) {
|
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
51
|
|
|
53
|
-
octokit
|
|
54
|
-
|
|
55
|
-
token: process.env.GITHUB_TOKEN
|
|
52
|
+
const octokit = new Octokit({
|
|
53
|
+
auth: process.env.GITHUB_TOKEN
|
|
56
54
|
});
|
|
57
|
-
|
|
58
|
-
let
|
|
55
|
+
|
|
56
|
+
let owner = '';
|
|
57
|
+
let repo = '';
|
|
59
58
|
|
|
60
59
|
function promiseRetryRateLimit(promiseFn, retryWait = 60000) {
|
|
61
60
|
return new Promise((resolve, reject) => {
|
|
@@ -63,7 +62,13 @@ function promiseRetryRateLimit(promiseFn, retryWait = 60000) {
|
|
|
63
62
|
promiseFn()
|
|
64
63
|
.then(data => resolve(data))
|
|
65
64
|
.catch(error => {
|
|
66
|
-
if (error.headers['
|
|
65
|
+
if (error.headers['status'] === '403 Forbidden' && error.headers['retry-after']) {
|
|
66
|
+
const reset = error.headers['retry-after'];
|
|
67
|
+
|
|
68
|
+
console.error('Retrying in', reset, 'seconds');
|
|
69
|
+
console.log('Retrying in', reset, 'seconds');
|
|
70
|
+
setTimeout(exec, reset * 1000);
|
|
71
|
+
} else if (error.headers['x-ratelimit-remaining'] === '0') {
|
|
67
72
|
let reset = error.headers['x-ratelimit-reset'];
|
|
68
73
|
if (reset) {
|
|
69
74
|
reset = parseInt(reset) * 1000 - Date.now();
|
|
@@ -80,16 +85,25 @@ function promiseRetryRateLimit(promiseFn, retryWait = 60000) {
|
|
|
80
85
|
});
|
|
81
86
|
}
|
|
82
87
|
|
|
88
|
+
function extractDescription(body) {
|
|
89
|
+
const match = body.match(/<!-- CHANGELOG -->\r?\n?(?<description>.*)\r?\n?<!-- END CHANGELOG -->/s);
|
|
90
|
+
if (!match || !match.groups || !match.groups.description) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return match.groups.description.replace(/<!--.*?-->\r?\n?/gs, '').replace(/(\r?\n)*$/gs, '').trim();
|
|
95
|
+
}
|
|
96
|
+
|
|
83
97
|
function getPRInfo(number, commit) {
|
|
84
98
|
function onError(error) {
|
|
85
|
-
if (error.
|
|
99
|
+
if (error.status === 404) {
|
|
86
100
|
return;
|
|
87
101
|
}
|
|
88
102
|
console.error(commit, error);
|
|
89
103
|
process.exit(1);
|
|
90
104
|
}
|
|
91
105
|
|
|
92
|
-
return promiseRetryRateLimit(() => octokit.
|
|
106
|
+
return promiseRetryRateLimit(() => octokit.pulls.get({owner, repo, pull_number: number}))
|
|
93
107
|
.catch(onError)
|
|
94
108
|
.then(pr => {
|
|
95
109
|
if (pr === undefined) {
|
|
@@ -101,13 +115,20 @@ function getPRInfo(number, commit) {
|
|
|
101
115
|
title: pr.data.title,
|
|
102
116
|
userLogin: pr.data.user.login
|
|
103
117
|
};
|
|
118
|
+
|
|
119
|
+
if (typeof pr.data.body === 'string') {
|
|
120
|
+
const description = extractDescription(pr.data.body);
|
|
121
|
+
if (description) {
|
|
122
|
+
info.description = description;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
104
125
|
// data.author_association: 'CONTRIBUTOR',
|
|
105
126
|
|
|
106
127
|
if (pr.data.milestone) {
|
|
107
128
|
info.milestone = pr.data.milestone.title;
|
|
108
129
|
}
|
|
109
130
|
|
|
110
|
-
return promiseRetryRateLimit(() => octokit.
|
|
131
|
+
return promiseRetryRateLimit(() => octokit.pulls.listCommits({owner, repo, pull_number: number}))
|
|
111
132
|
.catch(onError)
|
|
112
133
|
.then(commits => {
|
|
113
134
|
info.contributors = _.unique(_.flatten(commits.data.map(i => {
|
|
@@ -123,7 +144,7 @@ function getPRInfo(number, commit) {
|
|
|
123
144
|
});
|
|
124
145
|
}
|
|
125
146
|
|
|
126
|
-
function
|
|
147
|
+
function getPRNumberFromMessage(message, item) {
|
|
127
148
|
const match = message.match(commitRegex);
|
|
128
149
|
if (match == null) {
|
|
129
150
|
console.log(message, item);
|
|
@@ -138,8 +159,25 @@ function getPRNumeberFromMessage(message, item) {
|
|
|
138
159
|
return number;
|
|
139
160
|
}
|
|
140
161
|
|
|
162
|
+
function getCommitRange(from, to) {
|
|
163
|
+
if (!from && !to) {
|
|
164
|
+
console.error('Invalid commits for range');
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (from && to) {
|
|
169
|
+
return `${ from }...${ to }`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!from) {
|
|
173
|
+
return `${ to }^@`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return `${ from }...HEAD`;
|
|
177
|
+
}
|
|
178
|
+
|
|
141
179
|
async function getPullRequests(from, to) {
|
|
142
|
-
const logParams = ['--no-decorate', '--graph', '-E', `--grep=${ commitRegexString }`,
|
|
180
|
+
const logParams = ['--no-decorate', '--graph', '-E', `--grep=${ commitRegexString }`, getCommitRange(from, to)];
|
|
143
181
|
logParams.format = {
|
|
144
182
|
hash: '%H',
|
|
145
183
|
date: '%ai',
|
|
@@ -151,11 +189,6 @@ async function getPullRequests(from, to) {
|
|
|
151
189
|
const log = await git.log(logParams);
|
|
152
190
|
|
|
153
191
|
const items = log.all
|
|
154
|
-
.filter(item => /^(\*\s)[0-9a-z]+$/.test(item.hash))
|
|
155
|
-
.map(item => {
|
|
156
|
-
item.hash = item.hash.replace(/^(\*\s)/, '');
|
|
157
|
-
return item;
|
|
158
|
-
})
|
|
159
192
|
.filter(item => commitRegex.test(item.message));
|
|
160
193
|
|
|
161
194
|
const data = [];
|
|
@@ -176,7 +209,7 @@ async function getPullRequests(from, to) {
|
|
|
176
209
|
bar.tick(partItems.length);
|
|
177
210
|
|
|
178
211
|
const promises = partItems.map(item => {
|
|
179
|
-
return getPRInfo(
|
|
212
|
+
return getPRInfo(getPRNumberFromMessage(item.message, item), item);
|
|
180
213
|
});
|
|
181
214
|
|
|
182
215
|
return Promise.all(promises).then(result => {
|
|
@@ -197,7 +230,7 @@ async function getCurrentLatestTag() {
|
|
|
197
230
|
return (await git.raw(['describe', '--abbrev=0', '--tags'])).replace(/\n/, '');
|
|
198
231
|
}
|
|
199
232
|
|
|
200
|
-
async function getTags() {
|
|
233
|
+
async function getTags({ minTag }) {
|
|
201
234
|
let tags = await git.tags();
|
|
202
235
|
|
|
203
236
|
tags = tags.all.filter(tag => /^\d+\.\d+\.\d+(-rc\.\d+)?$/.test(tag));
|
|
@@ -224,15 +257,15 @@ async function getTags() {
|
|
|
224
257
|
before: index ? tags[--index] : null
|
|
225
258
|
};
|
|
226
259
|
})
|
|
227
|
-
.filter(item => item.tag === 'HEAD' || semver.gte(item.tag, minTag))
|
|
260
|
+
.filter(item => item.tag === 'HEAD' || !minTag || semver.gte(item.tag, minTag))
|
|
228
261
|
.reduce((value, item) => {
|
|
229
262
|
value[item.tag] = item;
|
|
230
263
|
return value;
|
|
231
264
|
}, {});
|
|
232
265
|
}
|
|
233
266
|
|
|
234
|
-
async function getMissingTags() {
|
|
235
|
-
const tags = await getTags();
|
|
267
|
+
async function getMissingTags({ minTag }) {
|
|
268
|
+
const tags = await getTags({ minTag });
|
|
236
269
|
const missingTags = _.difference(Object.keys(tags), Object.keys(historyData.releases));
|
|
237
270
|
|
|
238
271
|
missingTags.push('HEAD');
|
|
@@ -240,47 +273,12 @@ async function getMissingTags() {
|
|
|
240
273
|
return _.pick(tags, missingTags);
|
|
241
274
|
}
|
|
242
275
|
|
|
243
|
-
|
|
244
|
-
let circleConfig = '';
|
|
245
|
-
try {
|
|
246
|
-
circleConfig = await git.show([`${ version }:.circleci/config.yml`]);
|
|
247
|
-
} catch (e) {
|
|
248
|
-
console.error(e);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
let meteorRelease = '';
|
|
252
|
-
try {
|
|
253
|
-
meteorRelease = await git.show([`${ version }:.meteor/release`]);
|
|
254
|
-
} catch (e) {
|
|
255
|
-
console.error(e);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if (!/^METEOR@(\d+\.){1,2}\d/.test(meteorRelease)) {
|
|
259
|
-
return {};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const meteorVersion = meteorRelease.replace(/\n|\s/g, '');
|
|
263
|
-
|
|
264
|
-
try {
|
|
265
|
-
const requestResult = await request(`https://raw.githubusercontent.com/meteor/meteor/release/${ meteorVersion }/scripts/build-dev-bundle-common.sh`);
|
|
266
|
-
|
|
267
|
-
return {
|
|
268
|
-
node_version: requestResult.match(/NODE_VERSION=((?:\d+\.){2}\d)/m)[1],
|
|
269
|
-
npm_version: requestResult.match(/NPM_VERSION=((?:\d+\.){2}\d)/m)[1],
|
|
270
|
-
mongo_versions: _.uniq(circleConfig.match(/mongo:(\d.){1,2}\d/g)).map(i => i.replace('mongo:', ''))
|
|
271
|
-
};
|
|
272
|
-
} catch (error) {
|
|
273
|
-
console.log(error);
|
|
274
|
-
return {};
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
module.exports = function({headName = 'HEAD', owner:_owner = 'RocketChat', repo:_repo = 'Rocket.Chat'}) {
|
|
276
|
+
module.exports = function({headName = 'HEAD', owner:_owner = '', repo:_repo = '', minTag = '', getMetadata = () => Promise.resolve({}) }) {
|
|
279
277
|
owner = _owner;
|
|
280
278
|
repo = _repo;
|
|
281
279
|
|
|
282
280
|
return new Promise((resolve) => {
|
|
283
|
-
getMissingTags().then(missingTags => {
|
|
281
|
+
getMissingTags({ minTag }).then(missingTags => {
|
|
284
282
|
console.log('Missing tags:');
|
|
285
283
|
console.log(JSON.stringify(Object.keys(missingTags), null, 2));
|
|
286
284
|
missingTags = Object.values(missingTags);
|
|
@@ -303,12 +301,12 @@ module.exports = function({headName = 'HEAD', owner:_owner = 'RocketChat', repo:
|
|
|
303
301
|
const to = item.tag;
|
|
304
302
|
console.log('Fetching data for tag:', to, `(from ${ from })`);
|
|
305
303
|
getPullRequests(from, to).then(pull_requests => {
|
|
306
|
-
|
|
304
|
+
getMetadata({ version: to, git, request }).then(metadata => {
|
|
307
305
|
pull_requests = _.compact(pull_requests);
|
|
308
306
|
// console.log(' ', pull_requests.length, 'item(s) found');
|
|
309
307
|
historyData.releases = Object.assign(historyData.releases, {
|
|
310
308
|
[to]: {
|
|
311
|
-
...
|
|
309
|
+
...metadata,
|
|
312
310
|
pull_requests
|
|
313
311
|
}
|
|
314
312
|
});
|
package/src/md.js
CHANGED
|
@@ -1,162 +1,71 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const semver = require('semver');
|
|
4
|
-
const _ = require('underscore');
|
|
5
4
|
const execSync = require('child_process').execSync;
|
|
6
|
-
const
|
|
5
|
+
const { Octokit } = require('@octokit/rest');
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
const historyManualDataFile = path.join(process.cwd(), '.github/history-manual.json');
|
|
10
|
-
const historyFile = path.join(process.cwd(), 'HISTORY.md');
|
|
11
|
-
|
|
12
|
-
octokit.authenticate({
|
|
13
|
-
type: 'token',
|
|
14
|
-
token: process.env.GITHUB_TOKEN
|
|
15
|
-
});
|
|
7
|
+
const Handlebars = require('handlebars');
|
|
16
8
|
|
|
17
|
-
const
|
|
18
|
-
let nonContributors = [];
|
|
9
|
+
const H = require('just-handlebars-helpers');
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
IMPROVE: '### ๐ Improvements',
|
|
22
|
-
FIX: '### ๐ Bug fixes',
|
|
23
|
-
NEW: '### ๐ New features',
|
|
24
|
-
BREAK: '### โ ๏ธ BREAKING CHANGES',
|
|
25
|
-
MINOR: '๐ Minor changes'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const SummaryNameEmoticons = {
|
|
29
|
-
IMPROVE: '๐',
|
|
30
|
-
FIX: '๐',
|
|
31
|
-
NEW: '๐',
|
|
32
|
-
BREAK: '๏ธ๏ธ๏ธโ ๏ธ',
|
|
33
|
-
NOGROUP: '๐',
|
|
34
|
-
contributor: '๐ฉโ๐ป๐จโ๐ป'
|
|
35
|
-
};
|
|
11
|
+
H.registerHelpers(Handlebars);
|
|
36
12
|
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
IMPROVE: [],
|
|
42
|
-
FIX: [],
|
|
43
|
-
NOGROUP: []
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
prs.forEach(pr => {
|
|
47
|
-
const match = pr.title.match(/\[(FIX|IMPROVE|NEW|BREAK)\]\s*(.+)/);
|
|
48
|
-
if (match) {
|
|
49
|
-
pr.title = match[2];
|
|
50
|
-
groups[match[1]].push(pr);
|
|
51
|
-
} else {
|
|
52
|
-
groups.NOGROUP.push(pr);
|
|
13
|
+
function loadHelpers(helpers) {
|
|
14
|
+
Object.entries(helpers).forEach(([name, helper]) => {
|
|
15
|
+
if (Handlebars.helpers[name]) {
|
|
16
|
+
name = `_${ name }`;
|
|
53
17
|
}
|
|
18
|
+
Handlebars.registerHelper(name, helper);
|
|
54
19
|
});
|
|
55
|
-
|
|
56
|
-
return groups;
|
|
57
20
|
}
|
|
58
21
|
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function getSummary(contributors, teamContributors, groupedPRs) {
|
|
68
|
-
const summary = [];
|
|
69
|
-
|
|
70
|
-
Object.keys(groupedPRs).forEach(group => {
|
|
71
|
-
if (groupedPRs[group].length) {
|
|
72
|
-
summary.push(`${ groupedPRs[group].length } ${ SummaryNameEmoticons[group] }`);
|
|
22
|
+
function loadTemplatesFromDir(dir) {
|
|
23
|
+
fs.readdirSync(dir).forEach((file) => {
|
|
24
|
+
if (file.endsWith('.hbs')) {
|
|
25
|
+
let name = file.replace('.hbs', '');
|
|
26
|
+
if (Handlebars.partials[name]) {
|
|
27
|
+
name = `_${ name }`;
|
|
28
|
+
}
|
|
29
|
+
Handlebars.registerPartial(name, fs.readFileSync(path.join(dir, file)).toString());
|
|
73
30
|
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
if (contributors.length + teamContributors.length) {
|
|
77
|
-
summary.push(`${ contributors.length + teamContributors.length } ${ SummaryNameEmoticons.contributor }`);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (summary.length) {
|
|
81
|
-
return ` ยท ${ summary.join(' ยท ') }`;
|
|
82
|
-
}
|
|
83
31
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
32
|
+
if (file.endsWith('.js')) {
|
|
33
|
+
const helpers = require(path.join(dir, file));
|
|
34
|
+
if (typeof helpers === 'function') {
|
|
35
|
+
loadHelpers({
|
|
36
|
+
[file.replace('.js', '')]: helpers
|
|
37
|
+
});
|
|
38
|
+
} else if (typeof helpers === 'object') {
|
|
39
|
+
loadHelpers(helpers);
|
|
40
|
+
}
|
|
91
41
|
}
|
|
92
|
-
return k !== 'HEAD' && semver.lt(k, tag) && k.indexOf(tag) === -1;
|
|
93
42
|
});
|
|
43
|
+
}
|
|
94
44
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Object.keys(groupedPRs).forEach(group => {
|
|
102
|
-
const prs = groupedPRs[group];
|
|
103
|
-
if (!prs.length) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const groupName = GroupNames[group];
|
|
108
|
-
|
|
109
|
-
if (group === 'NOGROUP') {
|
|
110
|
-
data.push(`\n<details>\n<summary>${ GroupNames.MINOR }</summary>\n`);
|
|
111
|
-
} else {
|
|
112
|
-
data.push(`\n${ groupName }\n`);
|
|
113
|
-
}
|
|
114
|
-
prs.forEach(pr => {
|
|
115
|
-
let contributors = _.compact(_.difference(pr.contributors, nonContributors, systemUsers))
|
|
116
|
-
.sort()
|
|
117
|
-
.map(contributor => `[@${ contributor }](https://github.com/${ contributor })`)
|
|
118
|
-
.join(' & ');
|
|
119
|
-
|
|
120
|
-
if (contributors) {
|
|
121
|
-
contributors = ` by ${ contributors }`;
|
|
122
|
-
}
|
|
45
|
+
try {
|
|
46
|
+
loadTemplatesFromDir(path.resolve(process.cwd(), '.houston/templates'));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
//
|
|
49
|
+
}
|
|
123
50
|
|
|
124
|
-
|
|
125
|
-
data.push(`- ${ pr.title }${ prInfo }`);
|
|
126
|
-
});
|
|
127
|
-
if (group === 'NOGROUP') {
|
|
128
|
-
data.push('\n</details>');
|
|
129
|
-
}
|
|
130
|
-
});
|
|
51
|
+
loadTemplatesFromDir(path.resolve(__dirname, '../templates'));
|
|
131
52
|
|
|
132
|
-
|
|
133
|
-
return _._.unique(value.concat(pr.contributors));
|
|
134
|
-
}, []), nonContributors, systemUsers));
|
|
53
|
+
const template = Handlebars.compile('{{> changelog}}');
|
|
135
54
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
55
|
+
const historyDataFile = path.join(process.cwd(), '.github/history.json');
|
|
56
|
+
const historyManualDataFile = path.join(process.cwd(), '.github/history-manual.json');
|
|
57
|
+
const historyFile = path.join(process.cwd(), 'HISTORY.md');
|
|
139
58
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
contributors.sort().forEach(contributor => {
|
|
144
|
-
data.push(`- [@${ contributor }](https://github.com/${ contributor })`);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
59
|
+
const octokit = new Octokit({
|
|
60
|
+
auth: process.env.GITHUB_TOKEN
|
|
61
|
+
});
|
|
147
62
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
teamContributors.sort().forEach(contributor => {
|
|
152
|
-
data.push(`- [@${ contributor }](https://github.com/${ contributor })`);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
63
|
+
function getTagDate(tag) {
|
|
64
|
+
return execSync(`git tag -l --format="%(creatordate:short)" ${ tag }`).toString().replace(/\n/, '');
|
|
65
|
+
}
|
|
155
66
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
summary: getSummary(contributors, teamContributors, groupedPRs)
|
|
159
|
-
};
|
|
67
|
+
function getLatestCommitDate() {
|
|
68
|
+
return execSync('git log --date=short --format=\'%ad\' -1').toString().replace(/\n/, '');
|
|
160
69
|
}
|
|
161
70
|
|
|
162
71
|
function sort(a, b) {
|
|
@@ -176,32 +85,32 @@ function sort(a, b) {
|
|
|
176
85
|
return 0;
|
|
177
86
|
}
|
|
178
87
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
console.log('Need to implement pagination for members list');
|
|
88
|
+
const readHistoryFile = () => {
|
|
89
|
+
try {
|
|
90
|
+
return JSON.parse(fs.readFileSync(historyDataFile).toString()).releases;
|
|
91
|
+
} catch (error) {
|
|
92
|
+
throw new Error(`File ${ historyDataFile } not found`);
|
|
185
93
|
}
|
|
94
|
+
};
|
|
186
95
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
}
|
|
96
|
+
const readManualFile = () => {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.parse(fs.readFileSync(historyManualDataFile).toString());
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(`File ${ historyManualDataFile } not found, ignoring manual entries`);
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
194
104
|
|
|
195
|
-
|
|
105
|
+
module.exports = async function({tag, write = true, title = true, owner, repo} = {}) {
|
|
106
|
+
const data = await octokit.paginate(octokit.orgs.listMembers, {
|
|
107
|
+
org: owner,
|
|
108
|
+
});
|
|
109
|
+
const teamMembers = data.map(({ login }) => login);
|
|
196
110
|
|
|
197
|
-
let
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
} catch (error) {
|
|
201
|
-
console.error(`File ${ historyManualDataFile } not found, ignoring manual entries`);
|
|
202
|
-
return {};
|
|
203
|
-
}
|
|
204
|
-
})();
|
|
111
|
+
let historyDataReleases = readHistoryFile();
|
|
112
|
+
|
|
113
|
+
let historyManualData = readManualFile();
|
|
205
114
|
|
|
206
115
|
if (tag) {
|
|
207
116
|
historyDataReleases = Object.entries(historyDataReleases).filter(([key]) => key.indexOf(tag) === 0).reduce((v, [key, value]) => {
|
|
@@ -222,11 +131,12 @@ module.exports = async function({tag, write = true, title = true} = {}) {
|
|
|
222
131
|
historyDataReleases[tag] = historyDataReleases[tag] || {
|
|
223
132
|
pull_requests: []
|
|
224
133
|
};
|
|
225
|
-
historyDataReleases[tag].pull_requests.unshift(...historyManualData[tag]);
|
|
134
|
+
historyDataReleases[tag].pull_requests.unshift(...historyManualData[tag].map((pr) => ({ manual: true, ...pr })));
|
|
226
135
|
});
|
|
227
136
|
|
|
228
|
-
Object.
|
|
137
|
+
Object.entries(historyDataReleases).forEach(([tag, value]) => {
|
|
229
138
|
value.rcs = [];
|
|
139
|
+
value.tagDate = value.tagDate || getTagDate(tag);
|
|
230
140
|
});
|
|
231
141
|
|
|
232
142
|
Object.keys(historyDataReleases).forEach(tag => {
|
|
@@ -234,6 +144,7 @@ module.exports = async function({tag, write = true, title = true} = {}) {
|
|
|
234
144
|
const mainTag = tag.replace(/-rc.*/, '');
|
|
235
145
|
historyDataReleases[mainTag] = historyDataReleases[mainTag] || {
|
|
236
146
|
noMainRelease: true,
|
|
147
|
+
tagDate: getTagDate(mainTag),
|
|
237
148
|
pull_requests: [],
|
|
238
149
|
rcs: []
|
|
239
150
|
};
|
|
@@ -241,6 +152,7 @@ module.exports = async function({tag, write = true, title = true} = {}) {
|
|
|
241
152
|
if (historyDataReleases[mainTag].noMainRelease) {
|
|
242
153
|
historyDataReleases[mainTag].rcs.push({
|
|
243
154
|
tag,
|
|
155
|
+
tagDate: getTagDate(tag),
|
|
244
156
|
pull_requests: historyDataReleases[tag].pull_requests
|
|
245
157
|
});
|
|
246
158
|
} else {
|
|
@@ -251,75 +163,29 @@ module.exports = async function({tag, write = true, title = true} = {}) {
|
|
|
251
163
|
}
|
|
252
164
|
});
|
|
253
165
|
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
Object.keys(historyDataReleases)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (node_version || npm_version || mongo_versions) {
|
|
280
|
-
file.push('\n### Engine versions');
|
|
281
|
-
if (node_version) {
|
|
282
|
-
file.push(`- Node: \`${ node_version }\``);
|
|
283
|
-
}
|
|
284
|
-
if (npm_version) {
|
|
285
|
-
file.push(`- NPM: \`${ npm_version }\``);
|
|
286
|
-
}
|
|
287
|
-
if (mongo_versions) {
|
|
288
|
-
file.push(`- MongoDB: \`${ mongo_versions.join(', ') }\``);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
file.push(...data);
|
|
294
|
-
|
|
295
|
-
if (Array.isArray(rcs)) {
|
|
296
|
-
rcs.reverse().forEach(rc => {
|
|
297
|
-
const {data, summary} = renderPRs(rc.pull_requests, historyDataReleasesOriginal, rc.tag);
|
|
298
|
-
|
|
299
|
-
if (historyDataReleases[tag].noMainRelease) {
|
|
300
|
-
const tagDate = getTagDate(rc.tag) || getLatestCommitDate();
|
|
301
|
-
if (title) {
|
|
302
|
-
file.push(`\n## ${ rc.tag }`);
|
|
303
|
-
}
|
|
304
|
-
file.push(`\`${ tagDate }${ summary }\``);
|
|
305
|
-
|
|
306
|
-
if (node_version || npm_version) {
|
|
307
|
-
file.push('\n### Engine versions');
|
|
308
|
-
if (node_version) {
|
|
309
|
-
file.push(`- Node: \`${ node_version }\``);
|
|
310
|
-
}
|
|
311
|
-
if (npm_version) {
|
|
312
|
-
file.push(`- NPM: \`${ npm_version }\``);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
file.push(...data);
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
write && fs.writeFileSync(historyFile, file.join('\n'));
|
|
323
|
-
|
|
324
|
-
return file.join('\n');
|
|
166
|
+
const lastCommitDate = getLatestCommitDate();
|
|
167
|
+
|
|
168
|
+
const releases = await Promise.all(Object.keys(historyDataReleases)
|
|
169
|
+
.sort(sort)
|
|
170
|
+
.filter((tag) => {
|
|
171
|
+
const { pull_requests, rcs } = historyDataReleases[tag];
|
|
172
|
+
return pull_requests.length || rcs.length;
|
|
173
|
+
})
|
|
174
|
+
.map((tag) => ({
|
|
175
|
+
release: historyDataReleases[tag],
|
|
176
|
+
tag
|
|
177
|
+
})));
|
|
178
|
+
|
|
179
|
+
const file = template({
|
|
180
|
+
teamMembers,
|
|
181
|
+
releases,
|
|
182
|
+
owner,
|
|
183
|
+
repo,
|
|
184
|
+
showTitle: title,
|
|
185
|
+
lastCommitDate
|
|
186
|
+
}).replace(/\n$/, '');
|
|
187
|
+
|
|
188
|
+
write && fs.writeFileSync(historyFile, file);
|
|
189
|
+
|
|
190
|
+
return file;
|
|
325
191
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const { Octokit } = require('@octokit/rest');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
|
|
4
|
+
const octokit = new Octokit({
|
|
5
|
+
auth: process.env.GITHUB_TOKEN
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
module.exports = async function({owner, repo} = {}) {
|
|
9
|
+
const releasesResult = await octokit.paginate(octokit.repos.listReleases.endpoint.merge({owner, repo, per_page: 100}));
|
|
10
|
+
|
|
11
|
+
const releases = releasesResult.filter((release) => !release.tag_name.includes('-rc') && semver.gte(release.tag_name, '1.0.0')).sort((a, b) => semver.compare(b.tag_name, a.tag_name));
|
|
12
|
+
|
|
13
|
+
const releasesMap = {};
|
|
14
|
+
|
|
15
|
+
for (const release of releases) {
|
|
16
|
+
releasesMap[release.tag_name] = release;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let index = 0;
|
|
20
|
+
// eslint-disable-next-line no-constant-condition
|
|
21
|
+
while (true) {
|
|
22
|
+
const release = releases[index];
|
|
23
|
+
if (!releases[index + 1]) {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const currentVersion = semver.parse(release.tag_name);
|
|
28
|
+
const nextVersion = semver.parse(releases[index + 1].tag_name);
|
|
29
|
+
|
|
30
|
+
if (currentVersion.major === nextVersion.major && currentVersion.minor === nextVersion.minor) {
|
|
31
|
+
releases.splice(index + 1, 1);
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (currentVersion.major !== nextVersion.major) {
|
|
36
|
+
releases[index + 1].lts = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
index++;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
releases[0].last = true;
|
|
43
|
+
for (const {tag_name, html_url, lts, last} of releases.reverse()) {
|
|
44
|
+
const minor = tag_name.replace(/\.\d+$/, '');
|
|
45
|
+
const releaseDate = new Date(releasesMap[`${ minor }.0`].published_at);
|
|
46
|
+
if (releaseDate.getDate() < 20) {
|
|
47
|
+
releaseDate.setMonth(releaseDate.getMonth() - 1);
|
|
48
|
+
}
|
|
49
|
+
const supportDate = new Date(releaseDate);
|
|
50
|
+
supportDate.setMonth(supportDate.getMonth() + (lts ? 6 : 3));
|
|
51
|
+
|
|
52
|
+
const release = `${ lts ? '**' : '' }${ minor }${ lts ? ' \\(LTS\\)**' : '' }`;
|
|
53
|
+
const url = `[${ tag_name }](${ html_url })`;
|
|
54
|
+
const releasedAt = `${ lts ? '**' : '' }${ releaseDate.toLocaleString('en', { month: 'short' }) } ${ releaseDate.getFullYear() }${ lts ? '**' : '' }`;
|
|
55
|
+
const endOfLife = last ? 'TBD' : `${ lts ? '**' : '' }${ supportDate.toLocaleString('en', { month: 'short' }) } ${ supportDate.getFullYear() }${ lts ? '**' : '' }`;
|
|
56
|
+
|
|
57
|
+
console.log(`| ${ release } | ${ url } | ${ releasedAt } | ${ endOfLife } |`);
|
|
58
|
+
releaseDate.setMonth(releaseDate.getMonth() + 1);
|
|
59
|
+
}
|
|
60
|
+
};
|
package/src/set-version.js
CHANGED
|
@@ -5,37 +5,35 @@ const semver = require('semver');
|
|
|
5
5
|
const inquirer = require('inquirer');
|
|
6
6
|
const git = require('simple-git/promise')(process.cwd());
|
|
7
7
|
const logs = require('./logs');
|
|
8
|
-
const
|
|
8
|
+
const { Octokit } = require('@octokit/rest');
|
|
9
9
|
const md = require('../src/md');
|
|
10
10
|
|
|
11
|
-
octokit
|
|
12
|
-
|
|
13
|
-
token: process.env.GITHUB_TOKEN
|
|
11
|
+
const octokit = new Octokit({
|
|
12
|
+
auth: process.env.GITHUB_TOKEN
|
|
14
13
|
});
|
|
15
14
|
|
|
16
|
-
const files = [
|
|
17
|
-
'./package.json',
|
|
18
|
-
'./.sandstorm/sandstorm-pkgdef.capnp',
|
|
19
|
-
'./.travis/snap.sh',
|
|
20
|
-
'./.circleci/snap.sh',
|
|
21
|
-
'./.circleci/update-releases.sh',
|
|
22
|
-
'./.docker/Dockerfile',
|
|
23
|
-
'./.docker/Dockerfile.rhel',
|
|
24
|
-
'./packages/rocketchat-lib/rocketchat.info'
|
|
25
|
-
];
|
|
15
|
+
const files = [];
|
|
26
16
|
|
|
27
17
|
const readFile = promisify(fs.readFile);
|
|
28
18
|
const writeFile = promisify(fs.writeFile);
|
|
29
19
|
|
|
20
|
+
const {
|
|
21
|
+
PUSH_TAG_OPTIONS = '',
|
|
22
|
+
PUSH_CURRENT_BRANCH_OPTIONS = ''
|
|
23
|
+
} = process.env;
|
|
24
|
+
|
|
30
25
|
class Houston {
|
|
31
26
|
constructor({
|
|
32
27
|
owner,
|
|
33
28
|
repo,
|
|
34
|
-
version
|
|
29
|
+
version,
|
|
30
|
+
getMetadata
|
|
35
31
|
} = {}) {
|
|
36
32
|
this.owner = owner;
|
|
37
33
|
this.repo = repo;
|
|
38
34
|
this.version = version;
|
|
35
|
+
this.minTag = '';
|
|
36
|
+
this.getMetadata = getMetadata;
|
|
39
37
|
|
|
40
38
|
if (!this.version) {
|
|
41
39
|
this.readVersionFromPackageJson();
|
|
@@ -63,6 +61,25 @@ class Houston {
|
|
|
63
61
|
return files.length === 0 && ahead === 0 && behind === 0;
|
|
64
62
|
}
|
|
65
63
|
|
|
64
|
+
// read repo config
|
|
65
|
+
async readConfig() {
|
|
66
|
+
const filePath = path.resolve(process.cwd(), './package.json');
|
|
67
|
+
const file = JSON.parse(fs.readFileSync(filePath));
|
|
68
|
+
if (!file.houston) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { houston } = file;
|
|
72
|
+
if (houston.updateFiles) {
|
|
73
|
+
houston.updateFiles.forEach((file) => {
|
|
74
|
+
files.push(file);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (houston.minTag) {
|
|
79
|
+
this.minTag = houston.minTag;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
66
83
|
async getRemote() {
|
|
67
84
|
if (this.owner && this.repo) {
|
|
68
85
|
return;
|
|
@@ -118,6 +135,8 @@ class Houston {
|
|
|
118
135
|
name: 'answer',
|
|
119
136
|
default: defaultOption,
|
|
120
137
|
choices: [{
|
|
138
|
+
name: 'Beta Release', value: 'beta-release'
|
|
139
|
+
}, {
|
|
121
140
|
name: 'Release Candidate', value: 'release-candidate'
|
|
122
141
|
}, {
|
|
123
142
|
name: 'Final Release', value: 'release'
|
|
@@ -134,6 +153,10 @@ class Houston {
|
|
|
134
153
|
return await this.newReleaseCandidate();
|
|
135
154
|
}
|
|
136
155
|
|
|
156
|
+
if (answer === 'beta-release') {
|
|
157
|
+
return await this.newBetaRelease();
|
|
158
|
+
}
|
|
159
|
+
|
|
137
160
|
if (answer === 'release') {
|
|
138
161
|
return await this.newFinalRelease();
|
|
139
162
|
}
|
|
@@ -168,7 +191,19 @@ class Houston {
|
|
|
168
191
|
await this.updateHistory();
|
|
169
192
|
await this.shouldPushCurrentBranch();
|
|
170
193
|
await this.shouldAddTag();
|
|
171
|
-
await this.shouldSetHistoryToGithubRelease();
|
|
194
|
+
await this.shouldSetHistoryToGithubRelease(true);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async newBetaRelease() {
|
|
198
|
+
// TODO: Allow start from develop and ask for create the release-candidate branch
|
|
199
|
+
await this.goToBranch({branch: 'beta-release', readVersion: true});
|
|
200
|
+
await this.shouldMergeFromTo({from: 'origin/develop', to: 'beta-release'});
|
|
201
|
+
await this.selectVersionToUpdate({currentVersion: this.version, release: 'prerelease', identifier: 'beta'});
|
|
202
|
+
await this.updateVersionInFiles();
|
|
203
|
+
await this.updateHistory();
|
|
204
|
+
await this.shouldPushCurrentBranch();
|
|
205
|
+
await this.shouldAddTag();
|
|
206
|
+
await this.shouldSetHistoryToGithubRelease(true);
|
|
172
207
|
}
|
|
173
208
|
|
|
174
209
|
async newFinalRelease() {
|
|
@@ -189,6 +224,7 @@ class Houston {
|
|
|
189
224
|
await this.selectVersionToUpdate({currentVersion: this.version, release: 'patch'});
|
|
190
225
|
await this.createAndGoToBranch({branch: `release-${ this.version }`});
|
|
191
226
|
console.log('---\nExecute the cherry picks\n---');
|
|
227
|
+
await this.shouldContinue();
|
|
192
228
|
await this.updateVersionInFiles();
|
|
193
229
|
await this.updateHistory();
|
|
194
230
|
await this.shouldPushCurrentBranch();
|
|
@@ -237,7 +273,7 @@ class Houston {
|
|
|
237
273
|
name: 'pushTag'
|
|
238
274
|
}]);
|
|
239
275
|
|
|
240
|
-
return answers.pushTag && await git.push('origin', this.version);
|
|
276
|
+
return answers.pushTag && await git.push(['-u', 'origin', this.version, ...PUSH_TAG_OPTIONS.split(' ').filter(i => i)]);
|
|
241
277
|
}
|
|
242
278
|
|
|
243
279
|
async shouldPushCurrentBranch() {
|
|
@@ -249,7 +285,7 @@ class Houston {
|
|
|
249
285
|
name: 'pushBranch'
|
|
250
286
|
}]);
|
|
251
287
|
|
|
252
|
-
return answers.pushBranch && await git.push(['-u', 'origin', status.current]);
|
|
288
|
+
return answers.pushBranch && await git.push(['-u', 'origin', status.current, ...PUSH_CURRENT_BRANCH_OPTIONS.split(' ').filter(i => i)]);
|
|
253
289
|
}
|
|
254
290
|
|
|
255
291
|
async shouldAddTag() {
|
|
@@ -265,26 +301,65 @@ class Houston {
|
|
|
265
301
|
}
|
|
266
302
|
}
|
|
267
303
|
|
|
268
|
-
async
|
|
304
|
+
async checkoutBranch({branch, askToChange = true}) {
|
|
269
305
|
const currentBranch = await this.currentBranch();
|
|
270
|
-
if (currentBranch
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
306
|
+
if (currentBranch === branch) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (askToChange) {
|
|
311
|
+
const { answer } = await inquirer.prompt([{
|
|
312
|
+
type: 'list',
|
|
313
|
+
message: `You\'re not on branch ${ branch }. Would you?`,
|
|
314
|
+
name: 'answer',
|
|
315
|
+
default: 'change',
|
|
316
|
+
choices: [{
|
|
317
|
+
name: `Change to ${ branch }`,
|
|
318
|
+
value: 'change'
|
|
319
|
+
}, {
|
|
320
|
+
name: 'Continue from here',
|
|
321
|
+
value: 'continue'
|
|
322
|
+
}]
|
|
323
|
+
}]);
|
|
324
|
+
|
|
325
|
+
if (answer === 'continue') {
|
|
326
|
+
return;
|
|
283
327
|
}
|
|
284
328
|
}
|
|
329
|
+
|
|
330
|
+
console.log('Switching to branch', branch);
|
|
331
|
+
|
|
332
|
+
const localBranch = await git.branchLocal();
|
|
333
|
+
if (!localBranch.all.includes(branch)) {
|
|
334
|
+
return git.checkoutLocalBranch(branch);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
git.checkout(branch);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async goToBranch({branch, readVersion = false, pull = false, askToChange = true}) {
|
|
341
|
+
await this.checkoutBranch({branch, askToChange});
|
|
342
|
+
|
|
343
|
+
if (pull) {
|
|
344
|
+
await this.pull();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (readVersion) {
|
|
348
|
+
this.readVersionFromPackageJson();
|
|
349
|
+
}
|
|
285
350
|
}
|
|
286
351
|
|
|
287
352
|
async pull() {
|
|
353
|
+
const answers = await inquirer.prompt([{
|
|
354
|
+
type: 'confirm',
|
|
355
|
+
message: 'Pull from origin?',
|
|
356
|
+
name: 'pull'
|
|
357
|
+
}]);
|
|
358
|
+
|
|
359
|
+
if (!answers.pull) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
|
|
288
363
|
await git.pull();
|
|
289
364
|
}
|
|
290
365
|
|
|
@@ -365,8 +440,10 @@ class Houston {
|
|
|
365
440
|
}
|
|
366
441
|
|
|
367
442
|
async updateVersionInFiles() {
|
|
443
|
+
await this.readConfig();
|
|
444
|
+
|
|
368
445
|
await Promise.all(files.map(async(file) => {
|
|
369
|
-
let data = await readFile(file
|
|
446
|
+
let data = await readFile(`./${ file }`, 'utf8');
|
|
370
447
|
data = data.replace(this.oldVersion, this.version);
|
|
371
448
|
if (file.includes('sandstorm-pkgdef.capnp')) {
|
|
372
449
|
data = data.replace(/appVersion\s=\s(\d+),\s\s#\sIncrement/, (s, number) => {
|
|
@@ -381,8 +458,8 @@ class Houston {
|
|
|
381
458
|
}
|
|
382
459
|
|
|
383
460
|
async updateHistory() {
|
|
384
|
-
await logs({headName: this.version
|
|
385
|
-
await md();
|
|
461
|
+
await logs({headName: this.version, getMetadata: this.getMetadata, owner: this.owner, repo: this.repo, minTag: this.minTag });
|
|
462
|
+
await md({ owner: this.owner, repo: this.repo });
|
|
386
463
|
await this.shouldCommitFiles({amend: true});
|
|
387
464
|
}
|
|
388
465
|
|
|
@@ -419,14 +496,14 @@ class Houston {
|
|
|
419
496
|
}
|
|
420
497
|
}
|
|
421
498
|
|
|
422
|
-
async shouldSetHistoryToGithubRelease() {
|
|
499
|
+
async shouldSetHistoryToGithubRelease(prerelease = false) {
|
|
423
500
|
const answers = await inquirer.prompt([{
|
|
424
501
|
type: 'confirm',
|
|
425
502
|
message: 'Set history to tag?',
|
|
426
503
|
name: 'pushTag'
|
|
427
504
|
}]);
|
|
428
505
|
|
|
429
|
-
const body = await md({tag: this.version, write: false, title: false});
|
|
506
|
+
const body = await md({tag: this.version, write: false, title: false, owner: this.owner, repo: this.repo});
|
|
430
507
|
if (answers.pushTag) {
|
|
431
508
|
try {
|
|
432
509
|
const release = await octokit.repos.getReleaseByTag({owner: this.owner, repo: this.repo, tag: this.version});
|
|
@@ -438,10 +515,10 @@ class Houston {
|
|
|
438
515
|
tag_name: this.version,
|
|
439
516
|
body,
|
|
440
517
|
name: this.version,
|
|
441
|
-
prerelease
|
|
518
|
+
prerelease
|
|
442
519
|
});
|
|
443
520
|
} catch (error) {
|
|
444
|
-
if (error.
|
|
521
|
+
if (error.status === 404) {
|
|
445
522
|
console.log('Creating release');
|
|
446
523
|
await octokit.repos.createRelease({
|
|
447
524
|
owner: this.owner,
|
|
@@ -450,7 +527,7 @@ class Houston {
|
|
|
450
527
|
name: this.version,
|
|
451
528
|
body,
|
|
452
529
|
draft: false,
|
|
453
|
-
prerelease
|
|
530
|
+
prerelease
|
|
454
531
|
});
|
|
455
532
|
} else {
|
|
456
533
|
throw error;
|
|
@@ -466,7 +543,7 @@ class Houston {
|
|
|
466
543
|
name: 'create'
|
|
467
544
|
}]);
|
|
468
545
|
|
|
469
|
-
const body = await md({tag: this.version, write: false, title: false});
|
|
546
|
+
const body = await md({tag: this.version, write: false, title: false, owner: this.owner, repo: this.repo});
|
|
470
547
|
if (answers.create) {
|
|
471
548
|
console.log('Creating draft release');
|
|
472
549
|
await octokit.repos.createRelease({
|
|
@@ -489,10 +566,10 @@ class Houston {
|
|
|
489
566
|
name: 'create'
|
|
490
567
|
}]);
|
|
491
568
|
|
|
492
|
-
const body = await md({tag: this.version, write: false, title: false});
|
|
569
|
+
const body = await md({tag: this.version, write: false, title: false, owner: this.owner, repo: this.repo});
|
|
493
570
|
if (answers.create) {
|
|
494
571
|
console.log('Creating pull request');
|
|
495
|
-
const pr = await octokit.
|
|
572
|
+
const pr = await octokit.pulls.create({
|
|
496
573
|
owner: this.owner,
|
|
497
574
|
repo: this.repo,
|
|
498
575
|
title: `Release ${ this.version }`,
|
|
@@ -516,7 +593,7 @@ class Houston {
|
|
|
516
593
|
|
|
517
594
|
if (answers.create) {
|
|
518
595
|
console.log('Creating pull request');
|
|
519
|
-
const pr = await octokit.
|
|
596
|
+
const pr = await octokit.pulls.create({
|
|
520
597
|
owner: this.owner,
|
|
521
598
|
repo: this.repo,
|
|
522
599
|
title: `Merge master into develop & Set version to ${ this.version }`,
|
|
@@ -531,5 +608,8 @@ class Houston {
|
|
|
531
608
|
}
|
|
532
609
|
}
|
|
533
610
|
|
|
534
|
-
|
|
535
|
-
houston
|
|
611
|
+
module.exports = function({ owner, repo }, getMetadata) {
|
|
612
|
+
const houston = new Houston({ owner, repo, getMetadata });
|
|
613
|
+
houston.init().catch(error => console.error(error));
|
|
614
|
+
};
|
|
615
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const _ = require('underscore');
|
|
2
|
+
|
|
3
|
+
const systemUsers = ['web-flow'];
|
|
4
|
+
|
|
5
|
+
const SummaryNameEmoticons = {
|
|
6
|
+
IMPROVE: '๐',
|
|
7
|
+
FIX: '๐',
|
|
8
|
+
NEW: '๐',
|
|
9
|
+
BREAK: '๏ธ๏ธ๏ธโ ๏ธ',
|
|
10
|
+
NOGROUP: '๐',
|
|
11
|
+
contributor: '๐ฉโ๐ป๐จโ๐ป'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const GroupNames = {
|
|
15
|
+
IMPROVE: '### ๐ Improvements',
|
|
16
|
+
FIX: '### ๐ Bug fixes',
|
|
17
|
+
NEW: '### ๐ New features',
|
|
18
|
+
BREAK: '### โ ๏ธ BREAKING CHANGES',
|
|
19
|
+
MINOR: '๐ Minor changes',
|
|
20
|
+
NOGROUP: '๐ Minor changes'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function removeDuplicates(prs) {
|
|
24
|
+
return prs.filter((pr1, index1) => pr1.manual || !prs.some((pr2, index2) => pr1.pr === pr2.pr && index1 !== index2));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const sort = (a, b) => {
|
|
28
|
+
return a.title.localeCompare(b.title);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
module.exports = {
|
|
32
|
+
let(data, name, value) {
|
|
33
|
+
data[name] = value;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
groupedPRs(prs) {
|
|
37
|
+
const groups = {
|
|
38
|
+
BREAK: [],
|
|
39
|
+
NEW: [],
|
|
40
|
+
IMPROVE: [],
|
|
41
|
+
FIX: [],
|
|
42
|
+
NOGROUP: []
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
prs = removeDuplicates(prs);
|
|
46
|
+
|
|
47
|
+
prs.forEach(pr => {
|
|
48
|
+
const match = pr.title.match(/\[(FIX|IMPROVE|NEW|BREAK)\]\s*(.+)/);
|
|
49
|
+
if (match) {
|
|
50
|
+
pr.title = match[2];
|
|
51
|
+
pr.title = pr.title.replace(/^\[\s*(.+?)\s*\]/, '**$1:**');
|
|
52
|
+
groups[match[1]].push(pr);
|
|
53
|
+
} else {
|
|
54
|
+
groups.NOGROUP.push(pr);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return Object.entries(groups).map(([key, values]) => ({key, values: values.sort(sort)}));
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
groupTitle(group) {
|
|
62
|
+
return GroupNames[group];
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
getPRContributors(pr, {data}) {
|
|
66
|
+
const contributors = _.compact(_.difference(pr.contributors, data.root.teamMembers, systemUsers))
|
|
67
|
+
.sort()
|
|
68
|
+
.map(contributor => `[@${ contributor }](https://github.com/${ contributor })`)
|
|
69
|
+
.join(' & ');
|
|
70
|
+
|
|
71
|
+
if (contributors) {
|
|
72
|
+
return ` by ${ contributors }`;
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
prUrl(pr, {data}) {
|
|
77
|
+
return `https://github.com/${ data.root.owner }/${ data.root.repo }/pull/${ pr }`;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
description(pr) {
|
|
81
|
+
return pr.description.replace(/(?=(^|\s)([*-]\s|\d+\.\s))/gm, ' ').replace(/^(?=[^\s])/gm, ' ');
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
getSummary({groupedPRs, externalContributors, teamContributors}) {
|
|
85
|
+
const summary = [];
|
|
86
|
+
|
|
87
|
+
groupedPRs.forEach(({key, values}) => {
|
|
88
|
+
if (values.length) {
|
|
89
|
+
summary.push(`${ values.length } ${ SummaryNameEmoticons[key] }`);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (externalContributors.length + teamContributors.length) {
|
|
94
|
+
summary.push(`${ externalContributors.length + teamContributors.length } ${ SummaryNameEmoticons.contributor }`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (summary.length) {
|
|
98
|
+
return summary.join(' ยท ');
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
getExternalContributors(prs, {data}) {
|
|
103
|
+
prs = removeDuplicates(prs);
|
|
104
|
+
|
|
105
|
+
return _.compact(_.difference(prs.reduce((value, pr) => {
|
|
106
|
+
return _.unique(value.concat(pr.contributors));
|
|
107
|
+
}, []), data.root.teamMembers, systemUsers)).sort();
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
getTeamContributors(prs, {data}) {
|
|
111
|
+
prs = removeDuplicates(prs);
|
|
112
|
+
|
|
113
|
+
return _.compact(_.intersection(prs.reduce((value, pr) => {
|
|
114
|
+
return _.unique(value.concat(pr.contributors));
|
|
115
|
+
}, []), data.root.teamMembers)).sort();
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
getTagDate({tag, lastCommitDate, release}) {
|
|
119
|
+
return tag === 'HEAD' ? lastCommitDate : (release.tagDate || lastCommitDate);
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
reverse(arr) {
|
|
123
|
+
if (!Array.isArray(arr)) {
|
|
124
|
+
return arr;
|
|
125
|
+
}
|
|
126
|
+
return arr.reverse();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{{#each groupedPRs}}
|
|
2
|
+
{{#if values}}
|
|
3
|
+
|
|
4
|
+
{{#if (neq key 'NOGROUP')}}
|
|
5
|
+
{{ groupTitle key }}
|
|
6
|
+
|
|
7
|
+
{{> pull_requests}}
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if (eq key 'NOGROUP')}}
|
|
10
|
+
<details>
|
|
11
|
+
<summary>{{ groupTitle key }}</summary>
|
|
12
|
+
|
|
13
|
+
{{> pull_requests}}
|
|
14
|
+
|
|
15
|
+
</details>
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{/each}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{{~let . 'groupedPRs' (groupedPRs release.pull_requests)}}
|
|
2
|
+
{{~let . 'externalContributors' (getExternalContributors release.pull_requests)}}
|
|
3
|
+
{{~let . 'teamContributors' (getTeamContributors release.pull_requests)}}
|
|
4
|
+
{{> header}}
|
|
5
|
+
{{> summary}}
|
|
6
|
+
{{> prs}}
|
|
7
|
+
{{> contributors contributors=externalContributors title='### ๐ฉโ๐ป๐จโ๐ป Contributors ๐'}}
|
|
8
|
+
{{> contributors contributors=teamContributors title='### ๐ฉโ๐ป๐จโ๐ป Core Team ๐ค'}}
|
|
9
|
+
{{> rcs}}
|