@@ -22,6 +22,9 @@ const opts = require('nomnom')
22
22
} ,
23
23
section : {
24
24
help : 'Section name'
25
+ } ,
26
+ start : {
27
+ help : 'Start task id'
25
28
}
26
29
} )
27
30
. parse ( ) ;
@@ -129,7 +132,7 @@ fs.readJson(opts.config).then(config => {
129
132
const createTask = function createTask ( data , parentTask ) {
130
133
const insertData = {
131
134
assignee : ! _ . isEmpty ( data . assignee ) ? data . assignee . id : null ,
132
- followers : ! _ . isEmpty ( data . followers ) ? _ . pluck ( data . followers , 'id' ) : null ,
135
+ followers : ! _ . isEmpty ( data . followers ) ? _ . pluck ( data . followers , 'id' ) : [ ] ,
133
136
name : data . name ,
134
137
notes : data . notes ,
135
138
tags : ! _ . isEmpty ( data . tags ) ? _ . pluck ( data . tags , 'id' ) : [ ]
@@ -196,96 +199,23 @@ fs.readJson(opts.config).then(config => {
196
199
} ) ;
197
200
} ;
198
201
202
+ if ( opts . start ) {
203
+ _ . some ( result , ( v , i ) => {
204
+ // type 비교를 안함
205
+ if ( v . id == opts . start ) {
206
+ result = result . slice ( i ) ;
207
+ console . log ( `${ v . id } 이후부터 시작합니다.` ) ;
208
+ return true ;
209
+ }
210
+ } ) ;
211
+ }
212
+
199
213
return Promise . mapSeries ( result , item => {
200
214
return createTask ( item ) . then ( ( ) => {
201
215
console . log ( `${ item . id } task copied.` ) ;
202
216
} ) ;
203
217
} ) ;
204
218
} ) ;
205
-
206
- // Prepare asana data to avoid duplicated
207
- // Executes in order
208
- // return Promise.mapSeries(files, function (file) {
209
- // // Creates tasks
210
- // return Promise.mapSeries(filteredCards, card => {
211
- // return client.tasks.create({
212
- // assignee: card.idMembers.length ? convertMap(_.first(card.idMembers), config.member) : null,
213
- // due_at: card.due,
214
- // followers: card.idMembers.length > 1 ? convertMap(card.idMembers, config.member) : [],
215
- // name: card.name,
216
- // notes: card.desc,
217
- // memberships: [{
218
- // project: projectData.id,
219
- // section: convertMap(card.idList, listToSectionMap)
220
- // }],
221
- // tags: card.idLabels.length ? convertMap(card.idLabels, labelToTagMap) : [],
222
- // projects: [ projectData.id ]
223
- // }).then(result => {
224
- // var promises = [];
225
- // var taskData = result;
226
- // cardToTaskMap[card.id] = result.id;
227
- // countTask++;
228
-
229
- // if (countTask % 10 === 0) {
230
- // console.log(`${countTask}...`);
231
- // }
232
-
233
- // if (card.idChecklists.length) {
234
- // promises.push(
235
- // Promise.mapSeries(convertMap(card.idChecklists.reverse(), checklistMap), checklist => {
236
- // return Promise.mapSeries(checklist.checkItems.reverse(), item => {
237
- // return client.tasks.addSubtask(taskData.id, {
238
- // name: item.name,
239
- // completed: item.state !== 'incomplete'
240
- // });
241
- // }).then(function () {
242
- // return client.tasks.addSubtask(taskData.id, {
243
- // name: `${checklist.name}:`
244
- // });
245
- // });
246
- // })
247
- // );
248
- // }
249
-
250
- // if (parseInt(card.badges.comments, 10) > 0) {
251
- // promises.push(
252
- // // Trello export has limitation for count of actions as 1000. so we need to request directly trello API.
253
- // trello.getAsync(`/1/cards/${card.id}/actions?limit=1000`).then(result => {
254
- // var comments = _.filter(result, action => {
255
- // return action.type === 'commentCard';
256
- // });
257
-
258
- // return Promise.mapSeries(comments.reverse(), comment => {
259
- // var member = convertMap(comment.idMemberCreator, config.member);
260
- // var text = comment.data.text;
261
- // var memberName = member ? convertMap(member, userMap) : comment.memberCreator.fullName;
262
-
263
- // text = `${memberName}: ${text} from Trello`;
264
-
265
- // return client.tasks.addComment(taskData.id, {
266
- // text: text
267
- // });
268
- // });
269
- // })
270
- // );
271
- // }
272
-
273
- // if (card.attachments.length) {
274
- // promises.push(
275
- // Promise.mapSeries(card.attachments, attachment => {
276
- // return fetchImage(attachment.url).then(image => {
277
- // return uploadImageToAsana(taskData.id, image, path.basename(attachment.url));
278
- // }).catch(reason => {
279
- // console.log('Failed to upload attachment', reason);
280
- // });
281
- // })
282
- // );
283
- // }
284
-
285
- // return Promise.all(promises);
286
- // });
287
- // });
288
- // });
289
219
} ) . catch ( reason => {
290
220
console . error ( util . inspect ( reason , null , 4 ) ) ;
291
221
} ) . catch ( Promise . CancellationError , function ( reason ) {
0 commit comments