-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
49 lines (35 loc) · 1.2 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { AddUserToTeam, AddManagerToTeam } from "./helpers/graphql.js"
import fetch from "node-fetch" // Asco
import { readFileSync} from "fs"
globalThis.fetch = fetch
async function teamSync() {
console.log("Let's do it");
console.log(process.env.INPUT_FILE);
let rawdata = readFileSync(process.env.INPUT_FILE);
let userInfo = JSON.parse(rawdata);
console.log(userInfo);
const teamInfo = [];
const map = new Map();
userInfo.forEach(async (user) => {
// Debug
console.log(`Adding ${user.email} to team ${user.teamName}...`);
// Add the user to the team
AddUserToTeam(user.email, user.teamName, true);
// Compile a unique list of Team Managers + Team Names
if (!map.has(user.teamName)) {
map.set(user.teamName, true);
teamInfo.push({
name: user.teamName,
manager: user.manager
});
}
});
teamInfo.forEach(async (team) => {
// Debug
console.log(`Will add ${team.manager} as Manager of ${team.name}...`);
// Add the manager to the team
AddManagerToTeam(team.manager, team.name, true);
});
}
// And, hello.
teamSync();