1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

feat: Trello board JSON import (#352)

Closes #27, closes #105
This commit is contained in:
Christoph Enne 2022-12-16 23:48:06 +01:00 committed by GitHub
parent c880a72f02
commit 948485c861
20 changed files with 537 additions and 89 deletions

View file

@ -0,0 +1,38 @@
const fs = require('fs').promises;
const rimraf = require('rimraf');
module.exports = {
inputs: {
file: {
type: 'json',
required: true,
},
},
exits: {
invalidFile: {},
},
async fn(inputs) {
const content = await fs.readFile(inputs.file.fd);
const trelloBoard = JSON.parse(content);
if (
!trelloBoard ||
!_.isArray(trelloBoard.lists) ||
!_.isArray(trelloBoard.cards) ||
!_.isArray(trelloBoard.checklists) ||
!_.isArray(trelloBoard.actions)
) {
throw 'invalidFile';
}
try {
rimraf.sync(inputs.file.fd);
} catch (error) {
console.warn(error.stack); // eslint-disable-line no-console
}
return trelloBoard;
},
};