-
Notifications
You must be signed in to change notification settings - Fork 0
/
boardToCsv.js
28 lines (21 loc) · 888 Bytes
/
boardToCsv.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const path = require('path');
const Trello = require('trello');
const BoardExtractor = require('./src/boardExtractor');
const ListToCsvWriter = require('./src/listToCsvWriter');
require('dotenv').config();
const key = process.env.TRELLO_KEY;
const token = process.env.TRELLO_TOKEN;
const daOrgId = process.env.ORG_ID;
async function writeBoardToCsv(boardName, filename) {
console.log('== Writing board to CSV ==');
const trello = new Trello(key, token);
try {
const boardId = await BoardExtractor.getBoardIdByName(trello, daOrgId, boardName);
const listsWithCards = await BoardExtractor.getBoardListsWithCardsById(trello, boardId);
const outputPath = path.resolve(process.cwd(), 'output', `${filename}.csv`);
new ListToCsvWriter(listsWithCards).writeToCsv(outputPath);
} catch (error) {
console.error(error);
}
}
module.exports = { writeBoardToCsv };