Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@ fs.readJson(opts.config).then(function (config) {
return project.name === file.name;
});

promise = client.tasks.findByProject(projectData.id).then(fetch).then(tasks => {
promise = client.tasks.findByProject(projectData.gid).then(fetch).then(tasks => {
console.log(`Loaded exists ${tasks.length} tasks.`);
asanaData.tasks = tasks;

return client.sections.findByProject(projectData.id);
return client.sections.findByProject(projectData.gid);
}).then(sections => {
console.log(`Loaded exists ${sections.length} sections.`);
asanaData.sections = sections;
Expand All @@ -283,7 +283,7 @@ fs.readJson(opts.config).then(function (config) {
});

if (matchedSection) {
listToSectionMap[list.id] = matchedSection.id;
listToSectionMap[list.id] = matchedSection.gid;
return false;
} else {
return true;
Expand All @@ -292,10 +292,10 @@ fs.readJson(opts.config).then(function (config) {

// Creates sections in order
return Promise.mapSeries(filteredList, list => {
return client.sections.createInProject(projectData.id, {
return client.sections.createInProject(projectData.gid, {
name: list.name
}).then(result => {
listToSectionMap[list.id] = result.id;
listToSectionMap[list.id] = result.gid;
console.log(`Created ${list.name} section.`);
});
});
Expand All @@ -307,7 +307,7 @@ fs.readJson(opts.config).then(function (config) {
});

if (matchedTag) {
labelToTagMap[label.id] = matchedTag.id;
labelToTagMap[label.id] = matchedTag.gid;
return false;
} else {
return true;
Expand All @@ -323,9 +323,9 @@ fs.readJson(opts.config).then(function (config) {
color: LABEL_COLOR[label.color],
notes: 'Created by Trello'
}).then(result => {
labelToTagMap[label.id] = result.id;
labelToTagMap[label.id] = result.gid;
asanaData.tags.push(result);
console.log(`Created ${result.name}(${result.id}) tag.`);
console.log(`Created ${result.name}(${result.gid}) tag.`);
});
}, {
concurrency: 3
Expand All @@ -337,7 +337,7 @@ fs.readJson(opts.config).then(function (config) {
});

if (matchedTask) {
cardToTaskMap[card.id] = matchedTask.id
cardToTaskMap[card.id] = matchedTask.gid
return false;
} else {
return true;
Expand All @@ -347,19 +347,19 @@ fs.readJson(opts.config).then(function (config) {
console.log(`Creating ${filteredCards.length} of ${file.cards.length} tasks...`);

// Creates tasks
return Promise.mapSeries(filteredCards, card => {
return Promise.mapSeries(filteredCards, card => {
return client.tasks.create({
assignee: card.idMembers.length ? convertMap(_.first(card.idMembers), config.member) : null,
due_at: card.due,
followers: card.idMembers.length > 1 ? convertMap(card.idMembers, config.member) : [],
name: card.name,
notes: card.desc,
memberships: [{
project: projectData.id,
project: projectData.gid,
section: convertMap(card.idList, listToSectionMap)
}],
tags: card.idLabels.length ? convertMap(card.idLabels, labelToTagMap) : [],
projects: [ projectData.id ]
projects: [ projectData.gid ]
}).then(result => {
var promises = [];
var taskData = result;
Expand All @@ -374,12 +374,12 @@ fs.readJson(opts.config).then(function (config) {
promises.push(
Promise.mapSeries(convertMap(card.idChecklists.reverse(), checklistMap), checklist => {
return Promise.mapSeries(checklist.checkItems.reverse(), item => {
return client.tasks.addSubtask(taskData.id, {
return client.tasks.addSubtask(taskData.gid, {
name: item.name,
completed: item.state !== 'incomplete'
});
}).then(function () {
return client.tasks.addSubtask(taskData.id, {
return client.tasks.addSubtask(taskData.gid, {
name: `${checklist.name}:`
});
});
Expand All @@ -388,6 +388,7 @@ fs.readJson(opts.config).then(function (config) {
}

if (parseInt(card.badges.comments, 10) > 0) {
console.log(`getting trello card actions for card ${card.id}`);
promises.push(
// Trello export has limitation for count of actions as 1000. so we need to request directly trello API.
trello.getAsync(`/1/cards/${card.id}/actions?limit=1000`).then(result => {
Expand All @@ -402,7 +403,7 @@ fs.readJson(opts.config).then(function (config) {

text = `${memberName}: ${text} from Trello`;

return client.tasks.addComment(taskData.id, {
return client.tasks.addComment(taskData.gid, {
text: text
});
});
Expand All @@ -414,7 +415,7 @@ fs.readJson(opts.config).then(function (config) {
promises.push(
Promise.mapSeries(card.attachments, attachment => {
return fetchImage(attachment.url).then(image => {
return uploadImageToAsana(taskData.id, image, path.basename(attachment.url));
return uploadImageToAsana(taskData.gid, image, path.basename(attachment.url));
}).catch(reason => {
console.log('Failed to upload attachment', reason);
});
Expand Down