-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretrieveCards.js
More file actions
42 lines (39 loc) · 1.28 KB
/
Copy pathretrieveCards.js
File metadata and controls
42 lines (39 loc) · 1.28 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const Octokit = require('@octokit/rest');
const fs = require("fs");
const { apiKey } = require('./apikey');
const octokit = new Octokit({
auth: apiKey
});
const { owner, templateRepo } = JSON.parse(fs.readFileSync("projectConfig.json"));
octokit.projects.listForRepo({
// owner of repo (could be an organization)
owner: owner,
// the repo's name
repo: templateRepo
}).then(({ data }) => {
// downloads the first project cards, will have be tailored to which one to download
let project = data[0];
octokit.projects.listColumns({
project_id: project.id
}).then(({ data: columnData }) => {
// downloads all cards in the first column, normally to-do
let toDoColumn = columnData[0];
octokit.projects.listCards({
column_id: toDoColumn.id
}).then(({ data: cardData }) => {
let filteredData = [];
cardData.forEach(card => {
filteredData.push({
body: card.note
});
});
let fullCardObj = {
cards: filteredData
}
let cards = JSON.stringify(fullCardObj, null, "\t");
fs.writeFileSync('studentCards.json', cards);
});
});
}).catch((err) => {
console.log(err);
});