-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (37 loc) · 1.48 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
const puppeteer = require('puppeteer');
const jsyaml = require('js-yaml');
const path = require('path');
const fs = require('fs');
const { getPreviousWorkday } = require('./calendar');
const fetchAllGitLogs = require('./fetchAllGitLogs');
const configPath = path.join(__dirname, 'config.yaml');
const configDoc = fs.readFileSync(configPath);
const config = jsyaml.safeLoad(configDoc);
// TODO: Change to work span so that we can cover the weekend
const previousWorkday = getPreviousWorkday(new Date());
fetchAllGitLogs({
day: previousWorkday,
author: config.gitAuthor,
directories: config.gitDirectories,
})
.then(postLogsToStatusHero)
.then(() => process.exit());
async function postLogsToStatusHero(logs) {
/*eslint-env browser*/
const browser = await puppeteer.launch({ headless: config.willRunHeadless });
const page = await browser.newPage();
await page.goto('https://statushero.com/signin');
await page.focus('#user_email');
await page.keyboard.type(config.statusHeroUsername);
await page.focus('#user_password');
await page.keyboard.type(config.statusHeroPassword);
await page.click('button[type="submit"]');
await page.goto('https://statushero.com/teams/finance/statuses/current/edit');
await page.evaluate(() => {
document.getElementById('answer_set_previous').value = '';
});
await page.focus('#answer_set_previous');
await page.keyboard.type(logs);
await page.click('#answer_set_previous_completed');
if (config.willSubmit) await page.click('.btn-success');
}