-
Notifications
You must be signed in to change notification settings - Fork 51
/
generate.js
87 lines (76 loc) · 2.59 KB
/
generate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
* Trello burndown chart generator
*
* Author: Norbert Eder <wpfnerd+nodejs@gmail.com>
*/
var options = require('optimist')
.usage('Generate burndown charts from Trello cards.\n\nUsage: $0 -l [lists] -d [days] -r [resources] -f [finishlist]')
.demand(['l','d','r','f','n'])
.alias('l', 'lists')
.describe('l', 'Included lists separated by comma')
.alias('d', 'days')
.describe('d', 'Days in sprint')
.alias('r', 'resources')
.describe('r', 'Count matching day')
.alias('f', 'finishlist')
.describe('f', 'Name(s) of the list all finished tasks are moved to')
.alias('t', 'standuptime')
.describe('t', 'Standup meeting time; if not defined, split time is midnight')
.alias('n', 'name')
.describe('n', 'Name of the sprint')
.alias('boardId', 'boardId')
.describe('boardId', 'ID of the board on trello (take from URL)')
.alias('s', 'save')
.describe('s', 'Save configuration')
.boolean('s');
var optionArgs = options.argv;
var path = require('path');
global.settings = require('./settings');
settings.root = __dirname.replace(/\/+$/, "");
settings.exportPath = path.join(settings.root, 'export');
settings.configPath = path.join(settings.root, 'config');
var Helper = require('./lib/helper');
var lists = optionArgs.l;
var days = optionArgs.d;
var resources = optionArgs.r;
var finishedLists = optionArgs.f;
var standupTime = optionArgs.t;
var name = optionArgs.n;
var save = optionArgs.s;
var boardId = optionArgs.boardId || settings.boardId;
if (!lists || !lists.length)
{
options.showHelp();
console.error('No Trello list names given');
console.info('Example: -l "Planned,In progress,Testing,Finished"');
return;
}
if (!days || !days.length) {
options.showHelp();
console.error('No days for sprint given');
console.info('Example: -d "2013-12-13,2013-12-14,2013-12-15"');
return;
}
if (!resources || !resources.length) {
options.showHelp();
console.error('No day/resource match given');
console.info('Example: -r "0,1,0"');
return;
}
if (!finishedLists || !finishedLists.length) {
options.showHelp();
console.error('No finished list name defined');
console.info('Example: -f "Finished"');
return;
}
days = days.split(',');
resources = resources.split(',');
finishedLists = finishedLists.split(',');
var helper = new Helper();
if (save) {
console.log("Generating configuration ...");
helper.saveConfiguration(lists, days, resources, finishedLists, standupTime, boardId, name);
} else {
console.log("Starting export ...");
helper.generateAndExport(lists, days, resources, finishedLists, standupTime, boardId, name);
}