Skip to content

Replaced id with gid due to Asana api change #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
@@ -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;
@@ -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;
@@ -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.`);
});
});
@@ -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;
@@ -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
@@ -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;
@@ -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;
@@ -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}:`
});
});
@@ -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 => {
@@ -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
});
});
@@ -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);
});