Skip to content

Commit 2e0912e

Browse files
committed
Add markdown output
1 parent 85bfad4 commit 2e0912e

File tree

5 files changed

+74
-3
lines changed

5 files changed

+74
-3
lines changed

gtt-report.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const Report = require('./models/report');
99

1010
const Output = {
1111
table: require('./output/table'),
12-
csv: require('./output/csv')
12+
csv: require('./output/csv'),
13+
markdown: require('./output/markdown')
1314
};
1415

1516
// this collects options

output/markdown.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const _ = require('underscore');
2+
3+
const Table = require('markdown-table');
4+
const Base = require('./base');
5+
6+
const format = {
7+
headline: h => `\n### ${h}\n`,
8+
warning: w => `> ${w}`
9+
};
10+
11+
/**
12+
* stdout table output
13+
*/
14+
class table extends Base {
15+
constructor(config, report) {
16+
super(config, report);
17+
this.format = format;
18+
}
19+
20+
makeStats() {
21+
this.headline('TIME STATS');
22+
23+
let stats = '';
24+
25+
_.each(this.stats, (time, name) => stats += `\n* **${name}**: ${time}`);
26+
_.each(this.users, (time, name) => stats += `\n* **${name}**: ${time}`);
27+
28+
this.write(stats.substr(1));
29+
}
30+
31+
makeIssues() {
32+
this.headline('ISSUES');
33+
34+
if (this.report.issues.length === 0)
35+
return this.warning('No issues found');
36+
37+
let issues = [this.config.get('issueColumns')];
38+
this.report.issues.forEach(issue => issues.push(this.prepare(issue, this.config.get('issueColumns'))));
39+
40+
this.write(Table(issues));
41+
}
42+
43+
makeMergeRequests() {
44+
this.headline('MERGE REQUESTS');
45+
46+
if (this.report.mergeRequests.length === 0)
47+
return this.warning('No merge requests found');
48+
49+
let mergeRequests = [this.config.get('mergeRequestColumns')];
50+
this.report.mergeRequests.forEach(mergeRequest => mergeRequests.push(this.prepare(mergeRequest, this.config.get('mergeRequestColumns'))));
51+
52+
this.write(Table(mergeRequests));
53+
}
54+
55+
makeRecords() {
56+
this.headline('TIME RECORDS');
57+
58+
let times = [this.config.get('recordColumns')];
59+
this.times.forEach(time => times.push(this.prepare(time, this.config.get('recordColumns'))));
60+
61+
this.write(Table(times));
62+
}
63+
}
64+
65+
module.exports = table;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"find-in-files": "^0.4.0",
2121
"got": "^6.7.1",
2222
"hashids": "^1.1.1",
23+
"markdown-table": "^1.1.0",
2324
"moment": "^2.18.1",
2425
"node-spinner": "^0.0.4",
2526
"open": "^0.0.5",

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ gtt report --exclude_labels=bug --exclude_labels=feature
172172
# include issues and merge requests in the report hat have no time records
173173
gtt report --show_without_times
174174
175-
# choose a different output than a stdout table (json coming soon)
175+
# choose a different output than a stdout table
176176
gtt report --output=markdown --file=filename.md
177177
gtt report --output=csv --file=filename.csv
178178
```
@@ -257,7 +257,7 @@ dateFormat: DD.MM.YYYY HH:mm:ss
257257
# -> use a comma instead of a dot for those float values
258258
timeFormat: "[%sign][%days>d ][%hours>h ][%minutes>m ][%seconds>s]"
259259
260-
# default output
260+
# default output, available: csv, table, markdown
261261
output: markdown
262262
263263
# exclude issues and merge requests that have the following labels

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ lowercase-keys@^1.0.0:
213213
version "1.0.0"
214214
resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.0.tgz#4e3366b39e7f5457e35f1324bdf6f88d0bfc7306"
215215

216+
markdown-table@^1.1.0:
217+
version "1.1.0"
218+
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.0.tgz#1f5ae61659ced8808d882554c32e8b3f38dd1143"
219+
216220
mimic-fn@^1.0.0:
217221
version "1.1.0"
218222
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"

0 commit comments

Comments
 (0)