/
base.ts
152 lines (146 loc) · 4.35 KB
/
base.ts
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import Command from '@oclif/command';
import * as fs from 'fs';
import * as fse from 'fs-extra';
import * as jsYaml from 'js-yaml';
import * as loadYamlFile from 'load-yaml-file';
import * as path from 'path';
import { UserConfig } from './global';
export default abstract class extends Command {
userConfig = {
jira: {
username: 'username',
password: 'password',
host: 'https://jira.myhost.org',
fields: {
points: 'customfield_10114',
originalPoints: 'customfield_11115',
parentInitiative: 'customfield_11112',
parentEpic: 'customfield_10314',
sprint: 'customfield_10313',
},
excludeDays: ['1900-01-01'],
resolutions: {
positive: ['Done'],
negative: ['Incomplete'],
ignore: ['Duplicate'],
},
},
versions: {
projectKeys: ['QA', 'BACKLOG'],
monthsToChart: 6,
from: '2019-01-01',
defaultFilters: {
name: '',
projectKey: '',
label: '',
issueType: '',
priority: '',
},
},
teams: [
{
name: 'Team A',
from: '2019-07-01',
excludeDays: ['1900-01-01'],
streams: [
{
name: 'Initiatives',
completion: {
jql:
'sprint = Team-A and status changed to Closed ON (##TRANSITION_DATE##)',
childOf: 'assignee = team-easy and type = initiative',
},
forecast: {
jql:
'assignee = team-easy and type = initiative and status != Closed',
fetchChild: true,
effortPct: 60,
},
},
{
name: 'Defects',
completion: {
jql:
'sprint = Team-A and type = Bug and status changed to Closed ON (##TRANSITION_DATE##)',
childOf: '',
},
forecast: {
jql:
'type = Bug and sprint = Team-A and (sprint in futureSprints() or sprint in openSprints()) and status != Closed',
fetchChild: false,
effortPct: 40,
},
},
],
},
{
name: 'Team B',
from: '2019-07-01',
excludeDays: ['1900-01-01'],
streams: [
{
name: 'Initiatives',
completion: {
jql:
'sprint = Team-B and status changed to Closed ON (##TRANSITION_DATE##)',
childOf: 'assignee = team-easy and type = initiative',
},
forecast: {
jql:
'assignee = team-easy and type = initiative and status != Closed',
fetchChild: true,
effortPct: 60,
},
},
{
name: 'Defects',
completion: {
jql:
'sprint = Team-B and type = Bug and status changed to Closed ON (##TRANSITION_DATE##)',
childOf: '',
},
forecast: {
jql:
'type = Bug and sprint = Team-B and (sprint in futureSprints() or sprint in openSprints()) and status != Closed',
fetchChild: false,
effortPct: 40,
},
},
],
},
],
};
setUserConfig(userConfig: UserConfig) {
this.userConfig = userConfig;
}
async init() {
if (process.env.CONFIG_DIR !== undefined) {
this.config.configDir = process.env.CONFIG_DIR;
}
// If config file does not exists, initialize it:
fse.ensureDirSync(this.config.configDir);
fse.ensureDirSync(this.config.configDir + '/cache/');
// eslint-disable-next-line no-negated-condition
if (!fs.existsSync(path.join(this.config.configDir, 'config.yml'))) {
fs.writeFileSync(
path.join(this.config.configDir, 'config.yml'),
jsYaml.safeDump(this.userConfig),
);
this.log(
'Initialized configuration file with defaults in: ' +
path.join(this.config.configDir, 'config.yml'),
);
this.log('Please EDIT the configuration file first');
this.exit();
} else {
this.log(
'Configuration file exists: ' +
path.join(this.config.configDir, 'config.yml'),
);
const userConfig = await loadYamlFile(
path.join(this.config.configDir, 'config.yml'),
);
this.setUserConfig(userConfig);
}
}
}