-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
118 lines (99 loc) · 2.44 KB
/
common.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
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
const path = require('path')
const moment = require('moment')
const EPIC = 'epic'
function text(str) {
const val = (str || '')
.replace(/"/g, '""')
return val ? `"${val}"` : val
}
function date(str) {
return str ? moment(+str).format('MM/DD/YYYY') : ''
}
function convertTags(item, extra) {
if (item.tags.includes(EPIC))
return item.tags.filter(tag => tag != EPIC).join(',')
return item.tags
.concat(extra)
.filter(tag => tag != EPIC)
// .concat([item.id])
.join(',')
}
function convertType(item) {
if (item.tags.includes(EPIC))
return EPIC
switch (item.Type) {
case 'Bug' :
case 'Exception': return 'bug'
default : return 'feature'
}
}
function convertEstimate(item) {
if (convertType(item) == 'feature') {
return 1
}
return 0
}
function convertState(item) {
if (item.resolved)
return 'accepted'
switch (item.Stage) {
case 'Review' : return 'unstarted'
case 'Development': return 'started'
case 'QA' : return 'delivered'
case 'Complete' : return 'accepted'
}
return 'unscheduled'
}
function convertOwner(item) {
if (item.Assignee) {
return item.Assignee.$.fullName
}
return ''
}
function comment(cm, author, time) {
return text(`${cm} (${author} - ${time})`)
}
function convertComments(item) {
return item.comments
.map(x =>
comment(x.text, x.authorFullName, date(x.created))
)
.concat([
comment(
`Imported from https://crossix.myjetbrains.com/youtrack/issue/${item.id}`,
process.env.PT_DEFAULT_USER,
moment().format('MM/DD/YYYY')
)
])
}
// path relative to the project dir
function projPath(proj, rest) {
return path.join(`./data/proj-${proj}/`, rest)
}
const destCols = [
'Id',
'Title',
'Labels',
'Type', // Feature, bug, chore, epic, release (required if importing epics)
'Estimate',
'Current State', // Unscheduled, unstarted, started, finished, delivered, accepted, rejected
'Created at',
'Accepted at',
'Deadline',
'Requested By',
'Owned By',
'Description',
'Comment'
]
module.exports = {
text,
date,
convertTags,
convertType,
convertEstimate,
convertState,
convertOwner,
convertComments,
destCols,
projPath
}