const fs = require("fs");
function convert(trello) {
const now = Math.floor(Date.now() / 1000);
const boardId = 1;
let stackId = 1;
let cardId = 1;
const stacks = {};
const lists = trello.lists.filter(l => !l.closed);
const cards = trello.cards.filter(c => !c.closed);
lists.forEach(list => {
const currentStackId = stackId++;
const stackCards = cards
.filter(c => c.idList === list.id)
.map(card => {
const id = cardId++;
return {
id: id,
title: card.name,
description: card.desc || "",
descriptionPrev: null,
stackId: currentStackId,
type: "plain",
lastModified: now,
lastEditor: null,
createdAt: now,
labels: [],
assignedUsers: [],
attachments: null,
attachmentCount: null,
owner: null,
order: 999,
archived: false,
done: null,
duedate: card.due || null,
notified: false,
deletedAt: 0,
commentsUnread: 0,
commentsCount: 0,
relatedStack: null,
relatedBoard: null,
ETag: ""
};
});
stacks[currentStackId] = {
id: currentStackId,
title: list.name,
boardId: boardId,
deletedAt: 0,
lastModified: now,
cards: stackCards,
order: 999,
ETag: ""
};
});
return {
boards: [
{
id: boardId,
title: trello.name,
owner: "import",
color: "0082c9",
archived: false,
labels: [],
acl: [],
permissions: [],
users: [],
stacks: stacks,
activeSessions: [],
deletedAt: 0,
lastModified: now,
settings: [],
ETag: ""
}
]
};
}
function main() {
const input = process.argv[2];
const output = process.argv[3] || "deck-import.json";
if (!input) {
console.log("Usage: node convert.js trello.json output.json");
process.exit(1);
}
const trello = JSON.parse(fs.readFileSync(input, "utf8"));
const deck = convert(trello);
fs.writeFileSync(output, JSON.stringify(deck, null, 2));
console.log("✔ JSON compatible with Nextcloud Deck generated:", output);
}
main();
//
