From d142b60d655106c203e9f67cff45af54a938afcb Mon Sep 17 00:00:00 2001 From: fu351 Date: Wed, 13 Dec 2023 01:50:36 -0500 Subject: [PATCH] . --- logger.js | 2 +- logile.log | 14 ++++++++++++++ npm-github-netscore.js | 18 ++++++++++++++---- npm-github-netscore.ts | 19 +++++++++++++++---- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/logger.js b/logger.js index 14c76ea86..7b03b5def 100644 --- a/logger.js +++ b/logger.js @@ -14,7 +14,7 @@ var createCustomLogger = function (labelStr, level) { transports: [ new winston_1.transports.Console(), new winston_1.transports.File({ - filename: "logile.log" + filename: process.env.LOG_FILE }), ] }); diff --git a/logile.log b/logile.log index 46192ccb7..8acccde5c 100644 --- a/logile.log +++ b/logile.log @@ -40,3 +40,17 @@ at IncomingMessage.emit (node:domain:489:12) at endReadableNT (node:internal/streams/readable:1359:12) at processTicksAndRejections (node:internal/process/task_queues:82:21) +2023-12-13T06:50:15.294Z [DEBUG] debug: Error: AxiosError: Request failed with status code 401 + at settle (/home/shay/a/fu351/Desktop/Team-17-/node_modules/axios/lib/core/settle.js:19:12) + at IncomingMessage.handleStreamEnd (/home/shay/a/fu351/Desktop/Team-17-/node_modules/axios/lib/adapters/http.js:585:11) + at IncomingMessage.emit (node:events:526:35) + at IncomingMessage.emit (node:domain:489:12) + at endReadableNT (node:internal/streams/readable:1359:12) + at processTicksAndRejections (node:internal/process/task_queues:82:21) +2023-12-13T06:50:33.089Z [DEBUG] debug: Error: AxiosError: Request failed with status code 401 + at settle (/home/shay/a/fu351/Desktop/Team-17-/node_modules/axios/lib/core/settle.js:19:12) + at IncomingMessage.handleStreamEnd (/home/shay/a/fu351/Desktop/Team-17-/node_modules/axios/lib/adapters/http.js:585:11) + at IncomingMessage.emit (node:events:526:35) + at IncomingMessage.emit (node:domain:489:12) + at endReadableNT (node:internal/streams/readable:1359:12) + at processTicksAndRejections (node:internal/process/task_queues:82:21) diff --git a/npm-github-netscore.js b/npm-github-netscore.js index e1ff459c7..627416946 100644 --- a/npm-github-netscore.js +++ b/npm-github-netscore.js @@ -283,8 +283,9 @@ function extractGitHubInfo(npmPackageUrl) { case 4: error_4 = _c.sent(); logBasedOnVerbosity("Error extracting GitHub info: ".concat(error_4.message), 2); - process.exit(1); - return [3 /*break*/, 5]; + console.log(error_4); + //process.exit(1); + return [2 /*return*/, null]; case 5: return [2 /*return*/]; } }); @@ -307,7 +308,7 @@ function cloneREPO(username, repository) { case 2: error_5 = _b.sent(); logBasedOnVerbosity("Error cloning repository: ".concat(error_5.message), 2); - process.exit(1); + console.log(error_5); //process.exit(1); return [3 /*break*/, 3]; case 3: return [2 /*return*/]; } @@ -375,7 +376,8 @@ function countLines(filePath) { } catch (error) { logBasedOnVerbosity("Error reading file: ".concat(filePath), 2); - process.exit(1); + console.log(error); //process.exit(1); + return 0; } } function getDependencyData(getUsername, repositoryName, personalAccessToken) { @@ -480,6 +482,7 @@ function fetchGitHubInfo(npmPackageUrl, personalAccessToken) { case 1: return [4 /*yield*/, extractGitHubInfo(npmPackageUrl)]; case 2: githubInfo = _b.sent(); + console.log("extracted github info", githubInfo); if (!githubInfo) return [3 /*break*/, 13]; headers = { Authorization: "Bearer ".concat(personalAccessToken) @@ -496,7 +499,9 @@ function fetchGitHubInfo(npmPackageUrl, personalAccessToken) { case 4: //gather info _b.sent(); + console.log("cloned repo"); issue_count = response.data.open_issues_count; + console.log("issue count", issue_count); return [4 /*yield*/, getCommitsPerContributor(githubInfo.username, githubInfo.repository, personalAccessToken)]; case 5: contributor_commits = _b.sent(); @@ -504,17 +509,21 @@ function fetchGitHubInfo(npmPackageUrl, personalAccessToken) { return [4 /*yield*/, getTimeSinceLastCommit(githubInfo.username, githubInfo.repository)]; case 6: days_since_last_commit = _b.sent(); + console.log("days since last commit", days_since_last_commit); return [4 /*yield*/, getRepoLicense(response.data.license)]; case 7: repoLicense = _b.sent(); + console.log("repo license", repoLicense); return [4 /*yield*/, getReviewedLines(githubInfo.username, githubInfo.repository, personalAccessToken)]; case 8: code_review_score = _b.sent(); + console.log("code review score", code_review_score); rootDirectory = "./cli_storage/".concat(githubInfo.repository); return [4 /*yield*/, traverseDirectory(rootDirectory)]; case 9: totalLines = _b.sent(); total_lines = totalLines[1] - totalLines[0]; + console.log("total lines", total_lines); return [4 /*yield*/, getDependencyData(githubInfo.username, githubInfo.repository, personalAccessToken)]; case 10: _a = _b.sent(), assigned_dependencies = _a[0], unassigned_dependencies = _a[1]; @@ -542,6 +551,7 @@ function fetchGitHubInfo(npmPackageUrl, personalAccessToken) { //fs.writeFileSync(`./cli_storage/${githubInfo.repository}/popularity.json`, JSON.stringify(popularity, null, 2)); //Reverted back to returning as array of variables instead of JSON files, planning to save netscore as attribute instead of saving json file //Scores also contains the popularity score. + console.log("completed"); return [2 /*return*/, scores]; case 13: return [4 /*yield*/, (0, metrics_1.calculate_net_score)([0], 0, 0, 0, 'unlicense', 0, 0, 0, 0, npmPackageUrl)]; case 14: diff --git a/npm-github-netscore.ts b/npm-github-netscore.ts index 452cd9ec0..ae3ee61e6 100644 --- a/npm-github-netscore.ts +++ b/npm-github-netscore.ts @@ -243,7 +243,9 @@ async function extractGitHubInfo(npmPackageUrl: string): Promise<{ username: str } } catch (error) { logBasedOnVerbosity(`Error extracting GitHub info: ${error.message}`, 2); - process.exit(1); + console.log(error); + //process.exit(1); + return null } } async function cloneREPO(username: string, repository: string) { @@ -256,7 +258,7 @@ async function cloneREPO(username: string, repository: string) { } catch (error) { logBasedOnVerbosity(`Error cloning repository: ${error.message}`, 2); - process.exit(1); + console.log(error);//process.exit(1); } } @@ -307,7 +309,8 @@ try { return lines.length; } catch (error) { logBasedOnVerbosity(`Error reading file: ${filePath}`, 2); - process.exit(1); + console.log(error);//process.exit(1); + return 0; } } async function getDependencyData(getUsername: string, repositoryName: string, personalAccessToken: string) { @@ -383,6 +386,7 @@ async function fetchGitHubInfo(npmPackageUrl: string, personalAccessToken: strin } else { const githubInfo = await extractGitHubInfo(npmPackageUrl); + console.log("extracted github info", githubInfo); if (githubInfo) { //console.log(githubInfo); @@ -399,16 +403,22 @@ async function fetchGitHubInfo(npmPackageUrl: string, personalAccessToken: strin const response = await axios.get(url, axiosConfig); //gather info await cloneREPO(githubInfo.username, githubInfo.repository); - + console.log("cloned repo") const issue_count: number = response.data.open_issues_count; + console.log("issue count",issue_count); const contributor_commits: number[] = await getCommitsPerContributor(githubInfo.username, githubInfo.repository, personalAccessToken) as number[]; + console.log(";emngth",contributor_commits.length); const days_since_last_commit: number = await getTimeSinceLastCommit(githubInfo.username, githubInfo.repository) as number; + console.log("days since last commit",days_since_last_commit); const repoLicense = await getRepoLicense(response.data.license); + console.log("repo license",repoLicense); const code_review_score = await getReviewedLines(githubInfo.username, githubInfo.repository, personalAccessToken); + console.log("code review score",code_review_score); const rootDirectory = `./cli_storage/${githubInfo.repository}`; const totalLines = await traverseDirectory(rootDirectory); const total_lines = totalLines[1] - totalLines[0]; + console.log("total lines",total_lines); //console.log(githubInfo); const [assigned_dependencies, unassigned_dependencies] = await getDependencyData(githubInfo.username, githubInfo.repository, personalAccessToken) as [number,number]; @@ -434,6 +444,7 @@ async function fetchGitHubInfo(npmPackageUrl: string, personalAccessToken: strin //Reverted back to returning as array of variables instead of JSON files, planning to save netscore as attribute instead of saving json file //Scores also contains the popularity score. + console.log("completed"); return scores } else {