@@ -63,19 +63,24 @@ let jira;
63
63
username : credentials . username ,
64
64
password : credentials . token ,
65
65
apiVersion : "2" ,
66
- strictSSL : true
66
+ strictSSL : true ,
67
67
} ) ;
68
68
69
69
// A bit of a hack, but the endpoint isn't available in the SDK
70
70
jira . fetchUsers = function ( list ) {
71
- const names = Array . from ( list ) . join ( ',' )
72
- return this . doRequest ( this . makeRequestHeader ( this . makeUri ( {
73
- pathname : '/user/bulk/migration?username=' + names ,
74
- } ) , {
75
- method : 'GET' ,
76
- followAllRedirects : true ,
77
- } ) ) ;
78
- }
71
+ const names = Array . from ( list ) . join ( "," ) ;
72
+ return this . doRequest (
73
+ this . makeRequestHeader (
74
+ this . makeUri ( {
75
+ pathname : "/user/bulk/migration?username=" + names ,
76
+ } ) ,
77
+ {
78
+ method : "GET" ,
79
+ followAllRedirects : true ,
80
+ }
81
+ )
82
+ ) ;
83
+ } ;
79
84
80
85
let content = "" ;
81
86
@@ -101,7 +106,7 @@ let jira;
101
106
let tickets = InputParser ( content . toString ( ) ) ;
102
107
103
108
// Build a list of usernames encountered
104
- const userNames = new Set ;
109
+ const userNames = new Set ( ) ;
105
110
for ( t of tickets ) {
106
111
userNames . add ( t . assignee ) ;
107
112
for ( c of t . children ) {
@@ -118,36 +123,35 @@ let jira;
118
123
119
124
// Validate that all usernames provided were valid
120
125
// Parent tickets
121
- tickets = tickets . map ( t => {
126
+ tickets = tickets . map ( ( t ) => {
122
127
if ( ! userIds [ t . assignee ] ) {
123
128
throw new Error ( `Invalid assignee: ${ t . assignee } ` ) ;
124
129
}
125
130
t . assignee = {
126
131
name : t . assignee ,
127
- id : userIds [ t . assignee ]
128
- }
132
+ id : userIds [ t . assignee ] ,
133
+ } ;
129
134
130
135
// Child tickets
131
- t . children = t . children . map ( c => {
136
+ t . children = t . children . map ( ( c ) => {
132
137
if ( ! userIds [ c . assignee ] ) {
133
138
throw new Error ( `Invalid assignee: ${ c . assignee } ` ) ;
134
139
}
135
140
c . assignee = {
136
141
name : c . assignee ,
137
- id : userIds [ c . assignee ]
138
- }
142
+ id : userIds [ c . assignee ] ,
143
+ } ;
139
144
return c ;
140
- } )
145
+ } ) ;
141
146
142
147
return t ;
143
148
} ) ;
144
149
145
150
const table = new Table ( {
146
151
head : [ "Key" , "Title" , "Assignee" , "Components" , "Parent" ] ,
147
- colWidths : [ 15 , 30 , 20 , 15 , 15 ]
152
+ colWidths : [ 15 , 30 , 20 , 15 , 15 ] ,
148
153
} ) ;
149
154
150
-
151
155
for ( t of tickets ) {
152
156
let parent = await createIssue (
153
157
program . dry ,
@@ -157,7 +161,13 @@ let jira;
157
161
t . assignee . id ,
158
162
t . components
159
163
) ;
160
- table . push ( [ parent . key , t . title , t . assignee . name , t . components . join ( "\n" ) , "" ] ) ;
164
+ table . push ( [
165
+ parent . key ,
166
+ t . title ,
167
+ t . assignee . name ,
168
+ t . components . join ( "\n" ) ,
169
+ "" ,
170
+ ] ) ;
161
171
162
172
// If there are any children, create tickets using the parent key generated above
163
173
for ( c of t . children ) {
@@ -175,7 +185,7 @@ let jira;
175
185
c . title ,
176
186
c . assignee . name ,
177
187
c . components . join ( "\n" ) ,
178
- parent . key
188
+ parent . key ,
179
189
] ) ;
180
190
}
181
191
}
@@ -195,21 +205,21 @@ function createIssue(
195
205
let issueType = ! parentIssue ? "Task" : "Sub-task" ;
196
206
let request = {
197
207
fields : {
198
- components : components . map ( v => {
208
+ components : components . map ( ( v ) => {
199
209
return { name : v } ;
200
210
} ) ,
201
211
assignee : {
202
- id : assignee
212
+ id : assignee ,
203
213
} ,
204
214
project : {
205
- key : project
215
+ key : project ,
206
216
} ,
207
217
summary : title ,
208
218
description : description ,
209
219
issuetype : {
210
- name : issueType
211
- }
212
- }
220
+ name : issueType ,
221
+ } ,
222
+ } ,
213
223
} ;
214
224
215
225
if ( parentIssue ) {
@@ -228,4 +238,4 @@ function createIssue(
228
238
return Promise . resolve ( { key : generatedKey } ) ;
229
239
}
230
240
return jira . addNewIssue ( request ) ;
231
- }
241
+ }
0 commit comments