@rocket.chat/houston 0.25.2 → 0.26.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 CHANGED
@@ -25,14 +25,6 @@ const getRepoInfo = async() => {
25
25
  };
26
26
  };
27
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
28
  let repoPkg = {};
37
29
  try {
38
30
  repoPkg = require(path.resolve(process.cwd(), './package.json'));
@@ -46,7 +38,7 @@ program
46
38
  .option('-h, --head_name <name>', 'Name of the new release. Will rename the current HEAD section')
47
39
  .option('-t, --min_tag <tag>', 'Minimum tag to scrap the history')
48
40
  .action(async function({head_name, min_tag}) {
49
- logs({headName: head_name, minTag: min_tag, ...await getRepoInfo(), ...repoPkg.houston, getMetadata });
41
+ logs({headName: head_name, minTag: min_tag, ...await getRepoInfo(), ...repoPkg.houston });
50
42
  });
51
43
 
52
44
  program
@@ -67,7 +59,7 @@ program
67
59
  .command('release')
68
60
  .description('Release a new version')
69
61
  .action(async function() {
70
- setVersion(await getRepoInfo(), getMetadata);
62
+ setVersion(await getRepoInfo());
71
63
  });
72
64
 
73
65
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocket.chat/houston",
3
- "version": "0.25.2",
3
+ "version": "0.26.0",
4
4
  "description": "Rocket.Chat Command Line Tools",
5
5
  "main": "index.js",
6
6
  "repository": {
package/src/logs.js CHANGED
@@ -5,6 +5,7 @@ const ProgressBar = require('progress');
5
5
  const _ = require('underscore');
6
6
  const git = require('simple-git/promise')(process.cwd());
7
7
  const { Octokit } = require('@octokit/rest');
8
+ const { getMetadata } = require('./utils');
8
9
 
9
10
  const commitRegexString = '(^Merge pull request #([0-9]+) from )|( ?\\(?#([0-9]+)\\)?$)';
10
11
  const commitRegex = new RegExp(commitRegexString);
@@ -62,14 +63,14 @@ function promiseRetryRateLimit(promiseFn, retryWait = 60000) {
62
63
  promiseFn()
63
64
  .then(data => resolve(data))
64
65
  .catch(error => {
65
- if (error.headers['status'] === '403 Forbidden' && error.headers['retry-after']) {
66
- const reset = error.headers['retry-after'];
66
+ if (error.response.headers['status'] === '403 Forbidden' && error.response.headers['retry-after']) {
67
+ const reset = error.response.headers['retry-after'];
67
68
 
68
69
  console.error('Retrying in', reset, 'seconds');
69
70
  console.log('Retrying in', reset, 'seconds');
70
71
  setTimeout(exec, reset * 1000);
71
- } else if (error.headers['x-ratelimit-remaining'] === '0') {
72
- let reset = error.headers['x-ratelimit-reset'];
72
+ } else if (error.response.headers['x-ratelimit-remaining'] === '0') {
73
+ let reset = error.response.headers['x-ratelimit-reset'];
73
74
  if (reset) {
74
75
  reset = parseInt(reset) * 1000 - Date.now();
75
76
  }
@@ -273,7 +274,7 @@ async function getMissingTags({ minTag }) {
273
274
  return _.pick(tags, missingTags);
274
275
  }
275
276
 
276
- module.exports = function({headName = 'HEAD', owner:_owner = '', repo:_repo = '', minTag = '', getMetadata = () => Promise.resolve({}) }) {
277
+ module.exports = function({headName = 'HEAD', owner:_owner = '', repo:_repo = '', minTag = '' }) {
277
278
  owner = _owner;
278
279
  repo = _repo;
279
280
 
@@ -301,7 +302,7 @@ module.exports = function({headName = 'HEAD', owner:_owner = '', repo:_repo = ''
301
302
  const to = item.tag;
302
303
  console.log('Fetching data for tag:', to, `(from ${ from })`);
303
304
  getPullRequests(from, to).then(pull_requests => {
304
- getMetadata({ version: to, git, request }).then(metadata => {
305
+ getMetadata()({ version: to, git, request }).then(metadata => {
305
306
  pull_requests = _.compact(pull_requests);
306
307
  // console.log(' ', pull_requests.length, 'item(s) found');
307
308
  historyData.releases = Object.assign(historyData.releases, {
@@ -7,6 +7,7 @@ const git = require('simple-git/promise')(process.cwd());
7
7
  const logs = require('./logs');
8
8
  const { Octokit } = require('@octokit/rest');
9
9
  const md = require('../src/md');
10
+ const { getMetadata } = require('./utils');
10
11
 
11
12
  const octokit = new Octokit({
12
13
  auth: process.env.GITHUB_TOKEN
@@ -26,14 +27,12 @@ class Houston {
26
27
  constructor({
27
28
  owner,
28
29
  repo,
29
- version,
30
- getMetadata
30
+ version
31
31
  } = {}) {
32
32
  this.owner = owner;
33
33
  this.repo = repo;
34
34
  this.version = version;
35
35
  this.minTag = '';
36
- this.getMetadata = getMetadata;
37
36
 
38
37
  if (!this.version) {
39
38
  this.readVersionFromPackageJson();
@@ -458,7 +457,7 @@ class Houston {
458
457
  }
459
458
 
460
459
  async updateHistory() {
461
- await logs({headName: this.version, getMetadata: this.getMetadata, owner: this.owner, repo: this.repo, minTag: this.minTag });
460
+ await logs({headName: this.version, getMetadata: getMetadata(), owner: this.owner, repo: this.repo, minTag: this.minTag });
462
461
  await md({ owner: this.owner, repo: this.repo });
463
462
  await this.shouldCommitFiles({amend: true});
464
463
  }
@@ -608,8 +607,8 @@ class Houston {
608
607
  }
609
608
  }
610
609
 
611
- module.exports = function({ owner, repo }, getMetadata) {
612
- const houston = new Houston({ owner, repo, getMetadata });
610
+ module.exports = function({ owner, repo }) {
611
+ const houston = new Houston({ owner, repo });
613
612
  houston.init().catch(error => console.error(error));
614
613
  };
615
614
 
package/src/utils.js ADDED
@@ -0,0 +1,15 @@
1
+ const path = require('path');
2
+
3
+ const getMetadata = () => {
4
+ try {
5
+ const fn = require(path.resolve(process.cwd(), '.houston/metadata.js'));
6
+ return fn;
7
+ } catch (e) {
8
+ //
9
+ }
10
+ return () => Promise.resolve({});
11
+ };
12
+
13
+ module.exports = {
14
+ getMetadata
15
+ };