-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
40 lines (33 loc) · 1.56 KB
/
index.mjs
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
import * as utils from './util/utility-functions.mjs';
import * as dbUtils from './util/db-utils.mjs';
import * as octokitUtil from './util/octokit-utils.mjs';
import * as gotifyUtils from './util/gotify-utils.mjs';
import { software as softwareDeps } from './config/software-deps.mjs';
async function main() {
try {
if (process.env.NODE_ENV) {
console.info("NODE_ENV=" + process.env.NODE_ENV);
}
const oldData = dbUtils.getSoftwareJson();
const software = await utils.compareLastInfosWithCurrentSoftwareDepsList(oldData, softwareDeps);
const softwareAndReleaseInformation = await octokitUtil.retrieveLatestReleaseInformation(software);
const softwareToUpdate = utils.isUpdateAvailable(softwareAndReleaseInformation);
gotifyUtils.notifyUpdatesAvailable(utils.prepareDataForNotification(softwareToUpdate));
const updatedData = utils.updateData(softwareAndReleaseInformation);
await dbUtils.updateSoftwareUpdates(updatedData);
console.log("Script finished.");
} catch (err) {
console.error("Error occurred. Details:");
if (err.name === "HttpError") {
console.log(`${err.name} ${err.status}: '${err.message}'.`);
if (err.custom !== undefined && err.custom.component === "github-api") {
await gotifyUtils.notifyGithubApiError(err);
}
} else {
console.log(err);
await gotifyUtils.notifyGenericError(err);
}
console.error("Failure! Exiting!");
}
}
main();