Skip to content

Commit

Permalink
Periodical worker updated
Browse files Browse the repository at this point in the history
  • Loading branch information
darsan-in committed Jul 5, 2024
1 parent 670b30c commit 0745d0d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
27 changes: 20 additions & 7 deletions action/fetch-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadGithubMeta = void 0;
var fs_1 = require("fs");
var https_1 = require("https");
var path_1 = require("path");
var RequestOption = /** @class */ (function () {
function RequestOption(path) {
this.hostname = "api.github.com";
this.headers = {
Authorization: "token ".concat(process.env.GITHUB_TOKEN),
Accept: "application/vnd.github.v3+json",
"user-agent": "Node.js",
Authorization: "Bearer ".concat(process.env.GITHUB_TOKEN),
Accept: "application/json",
};
this.path = "";
this.path = path;
Expand Down Expand Up @@ -216,15 +216,26 @@ var loadGithubMeta = function () { return __awaiter(void 0, void 0, void 0, func
}
});
}); };
exports.loadGithubMeta = loadGithubMeta;
function main() {
return __awaiter(this, void 0, void 0, function () {
var rawGHMEta, mostUsedLanguages, groupedMeta;
var rawGHMEta, err_1, mostUsedLanguages, groupedMeta;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, (0, exports.loadGithubMeta)()];
case 0:
rawGHMEta = {};
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, loadGithubMeta()];
case 2:
rawGHMEta = _a.sent();
return [3 /*break*/, 4];
case 3:
err_1 = _a.sent();
console.log(err_1);
process.exit(1);
return [3 /*break*/, 4];
case 4:
mostUsedLanguages = getMostUsedLanguages(rawGHMEta);
groupedMeta = makeRepoGroups(mostUsedLanguages, rawGHMEta);
(0, fs_1.writeFileSync)((0, path_1.join)(process.cwd(), "ghmeta.json"), JSON.stringify(groupedMeta));
Expand All @@ -233,4 +244,6 @@ function main() {
});
});
}
main();
main().catch(function (err) {
console.log(err);
});
19 changes: 14 additions & 5 deletions action/fetch-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { GithubRepoMeta } from "./ds";
class RequestOption {
hostname: string = "api.github.com";
headers: Record<string, string> = {
Authorization: `token ${process.env.GITHUB_TOKEN}`,
Accept: "application/vnd.github.v3+json",
"user-agent": "Node.js",
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
Accept: "application/json",
};
path: string = ``;

Expand Down Expand Up @@ -147,7 +148,7 @@ function getLanguagesMeta(
});
}

export const loadGithubMeta = async () => {
const loadGithubMeta = async () => {
/* GitHub page owners whose projects you have worked on */
const workedOn: string[] = ["iamspdarsan", "cresteem"];

Expand All @@ -165,7 +166,13 @@ export const loadGithubMeta = async () => {
};

async function main(): Promise<void> {
let rawGHMEta = await loadGithubMeta();
let rawGHMEta = {};
try {
rawGHMEta = await loadGithubMeta();
} catch (err) {
console.log(err);
process.exit(1);
}
const mostUsedLanguages = getMostUsedLanguages(rawGHMEta);
const groupedMeta = makeRepoGroups(mostUsedLanguages, rawGHMEta);

Expand All @@ -175,4 +182,6 @@ async function main(): Promise<void> {
);
}

main();
main().catch((err) => {
console.log(err);
});

0 comments on commit 0745d0d

Please sign in to comment.