diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dcda5386d4..70e8ff25df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -157,17 +157,17 @@ importers: src/api/dependency-discovery: specifiers: - '@octokit/request': 5.6.3 '@senecacdot/eslint-config-telescope': 1.1.0 '@senecacdot/satellite': ^1.27.0 env-cmd: 10.1.0 eslint: 7.32.0 nodemon: 2.0.15 + octokit: 1.7.1 query-registry: 2.2.0 supertest: 6.1.6 dependencies: - '@octokit/request': 5.6.3 '@senecacdot/satellite': 1.27.0 + octokit: 1.7.1 query-registry: 2.2.0 supertest: 6.1.6 devDependencies: @@ -365,9 +365,6 @@ importers: src/api/status: specifiers: - '@octokit/core': 3.5.1 - '@octokit/plugin-retry': 3.0.9 - '@octokit/plugin-throttling': 3.5.2 '@popperjs/core': 2.11.5 '@senecacdot/eslint-config-telescope': 1.1.0 '@senecacdot/satellite': ^1.27.0 @@ -378,6 +375,7 @@ importers: express-handlebars: 6.0.4 nodemon: 2.0.15 npm-run-all: 4.1.5 + octokit: 1.7.1 perfect-scrollbar: 1.5.5 sass: 1.49.9 vite: 2.8.6 @@ -386,15 +384,13 @@ importers: xterm-addon-web-links: 0.5.1 xterm-addon-webgl: 0.11.4 dependencies: - '@octokit/core': 3.5.1 - '@octokit/plugin-retry': 3.0.9 - '@octokit/plugin-throttling': 3.5.2_@octokit+core@3.5.1 '@popperjs/core': 2.11.5 '@senecacdot/satellite': 1.27.0 bootstrap: 5.1.3_@popperjs+core@2.11.5 express: 4.17.3 express-handlebars: 6.0.4 npm-run-all: 4.1.5 + octokit: 1.7.1 perfect-scrollbar: 1.5.5 sass: 1.49.9 vite: 2.8.6_sass@1.49.9 @@ -4935,12 +4931,88 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.13.0 + /@octokit/app/12.0.5: + resolution: {integrity: sha512-lM3pIfx2h+UbvsXHFVs1ApJ9Rmp8LO4ciFSr5q/9MdHmhsH6WtwayieUn875xwB77IoR9r8czxxxASu2WCtdeA==} + dependencies: + '@octokit/auth-app': 3.6.1 + '@octokit/auth-unauthenticated': 2.1.0 + '@octokit/core': 3.5.1 + '@octokit/oauth-app': 3.6.0 + '@octokit/plugin-paginate-rest': 2.17.0_@octokit+core@3.5.1 + '@octokit/types': 6.34.0 + '@octokit/webhooks': 9.15.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/auth-app/3.6.1: + resolution: {integrity: sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA==} + dependencies: + '@octokit/auth-oauth-app': 4.3.0 + '@octokit/auth-oauth-user': 1.3.0 + '@octokit/request': 5.6.3 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + '@types/lru-cache': 5.1.1 + deprecation: 2.3.1 + lru-cache: 6.0.0 + universal-github-app-jwt: 1.1.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/auth-oauth-app/4.3.0: + resolution: {integrity: sha512-cETmhmOQRHCz6cLP7StThlJROff3A/ln67Q961GuIr9zvyFXZ4lIJy9RE6Uw5O7D8IXWPU3jhDnG47FTSGQr8Q==} + dependencies: + '@octokit/auth-oauth-device': 3.1.2 + '@octokit/auth-oauth-user': 1.3.0 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + '@types/btoa-lite': 1.0.0 + btoa-lite: 1.0.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/auth-oauth-device/3.1.2: + resolution: {integrity: sha512-w7Po4Ck6N2aAn2VQyKLuojruiyKROTBv4qs6IwE5rbwF7HhBXXp4A/NKmkpoFIZkiXQtM+N8QtkSck4ApYWdGg==} + dependencies: + '@octokit/oauth-methods': 1.2.6 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/auth-oauth-user/1.3.0: + resolution: {integrity: sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ==} + dependencies: + '@octokit/auth-oauth-device': 3.1.2 + '@octokit/oauth-methods': 1.2.6 + '@octokit/request': 5.6.3 + '@octokit/types': 6.34.0 + btoa-lite: 1.0.0 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + /@octokit/auth-token/2.5.0: resolution: {integrity: sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==} dependencies: '@octokit/types': 6.34.0 dev: false + /@octokit/auth-unauthenticated/2.1.0: + resolution: {integrity: sha512-+baofLfSL0CAv3CfGQ9rxiZZQEX8VNJMGuuS4PgrMRBUL52Ho5+hQYb63UJQshw7EXYMPDZxbXznc0y33cbPqw==} + dependencies: + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + dev: false + /@octokit/core/3.5.1: resolution: {integrity: sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==} dependencies: @@ -4973,10 +5045,61 @@ packages: - encoding dev: false + /@octokit/oauth-app/3.6.0: + resolution: {integrity: sha512-OxPw4ItQXaC2GuEXyZB7EmZ2rHvNFX4y3yAsqdFIRW7qg2HyoEPxacxza6c8wqbEEvu84b98AJ5BXm+IjPWrww==} + dependencies: + '@octokit/auth-oauth-app': 4.3.0 + '@octokit/auth-oauth-user': 1.3.0 + '@octokit/auth-unauthenticated': 2.1.0 + '@octokit/core': 3.5.1 + '@octokit/oauth-authorization-url': 4.3.3 + '@octokit/oauth-methods': 1.2.6 + '@types/aws-lambda': 8.10.93 + fromentries: 1.3.2 + universal-user-agent: 6.0.0 + transitivePeerDependencies: + - encoding + dev: false + + /@octokit/oauth-authorization-url/4.3.3: + resolution: {integrity: sha512-lhP/t0i8EwTmayHG4dqLXgU+uPVys4WD/qUNvC+HfB1S1dyqULm5Yx9uKc1x79aP66U1Cb4OZeW8QU/RA9A4XA==} + dev: false + + /@octokit/oauth-methods/1.2.6: + resolution: {integrity: sha512-nImHQoOtKnSNn05uk2o76om1tJWiAo4lOu2xMAHYsNr0fwopP+Dv+2MlGvaMMlFjoqVd3fF3X5ZDTKCsqgmUaQ==} + dependencies: + '@octokit/oauth-authorization-url': 4.3.3 + '@octokit/request': 5.6.3 + '@octokit/request-error': 2.1.0 + '@octokit/types': 6.34.0 + btoa-lite: 1.0.0 + transitivePeerDependencies: + - encoding + dev: false + /@octokit/openapi-types/11.2.0: resolution: {integrity: sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==} dev: false + /@octokit/plugin-paginate-rest/2.17.0_@octokit+core@3.5.1: + resolution: {integrity: sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==} + peerDependencies: + '@octokit/core': '>=2' + dependencies: + '@octokit/core': 3.5.1 + '@octokit/types': 6.34.0 + dev: false + + /@octokit/plugin-rest-endpoint-methods/5.13.0_@octokit+core@3.5.1: + resolution: {integrity: sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==} + peerDependencies: + '@octokit/core': '>=3' + dependencies: + '@octokit/core': 3.5.1 + '@octokit/types': 6.34.0 + deprecation: 2.3.1 + dev: false + /@octokit/plugin-retry/3.0.9: resolution: {integrity: sha512-r+fArdP5+TG6l1Rv/C9hVoty6tldw6cE2pRHNGmFPdyfrc696R6JjrQ3d7HdVqGwuzfyrcaLAKD7K8TX8aehUQ==} dependencies: @@ -6333,6 +6456,10 @@ packages: resolution: {integrity: sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==} dev: false + /@types/aws-lambda/8.10.93: + resolution: {integrity: sha512-Vsyi9ogDAY3REZDjYnXMRJJa62SDvxHXxJI5nGDQdZW058dDE+av/anynN2rLKbCKXDRNw3D/sQmqxVflZFi4A==} + dev: false + /@types/babel__core/7.1.18: resolution: {integrity: sha512-S7unDjm/C7z2A2R9NzfKCK1I+BAALDtxEmsJBwlB3EzNfb929ykjL++1CK9LO++EIp2fQrC8O+BwjKvz6UeDyQ==} dependencies: @@ -6371,6 +6498,10 @@ packages: '@types/node': 17.0.12 dev: false + /@types/btoa-lite/1.0.0: + resolution: {integrity: sha512-wJsiX1tosQ+J5+bY5LrSahHxr2wT+uME5UDwdN1kg4frt40euqA+wzECkmq4t5QbveHiJepfdThgQrPw6KiSlg==} + dev: false + /@types/cacheable-request/6.0.2: resolution: {integrity: sha512-B3xVo+dlKM6nnKTcmm5ZtY/OL8bOAOd2Olee9M1zft65ox50OzjEHW91sDiU9j6cvW8Ejg1/Qkf4xd2kugApUA==} dependencies: @@ -6500,6 +6631,12 @@ packages: resolution: {integrity: sha1-7ihweulOEdK4J7y+UnC86n8+ce4=} dev: true + /@types/jsonwebtoken/8.5.8: + resolution: {integrity: sha512-zm6xBQpFDIDM6o9r6HSgDeIcLy82TKWctCXEPbJJcXb5AKmi5BNNdLXneixK4lplX3PqIVcwLBCGE/kAGnlD4A==} + dependencies: + '@types/node': 17.0.12 + dev: false + /@types/keyv/3.1.3: resolution: {integrity: sha512-FXCJgyyN3ivVgRoml4h94G/p3kY+u/B86La+QptcqJaWtBWtmc6TtkNfS40n9bIvyLteHh7zXOtgbobORKPbDg==} dependencies: @@ -6510,6 +6647,10 @@ packages: resolution: {integrity: sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw==} dev: false + /@types/lru-cache/5.1.1: + resolution: {integrity: sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==} + dev: false + /@types/mdast/3.0.10: resolution: {integrity: sha512-W864tg/Osz1+9f4lrGTZpCSO5/z4608eUp19tbozkq2HJK6i3z1kT0H9tlADXuYIb1YYOBByU4Jsqkk75q48qA==} dependencies: @@ -8001,6 +8142,10 @@ packages: dependencies: node-int64: 0.4.0 + /btoa-lite/1.0.0: + resolution: {integrity: sha1-M3dm2hWAEhD92VbCLpxokaudAzc=} + dev: false + /buffer-crc32/0.2.13: resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} dev: true @@ -11346,7 +11491,6 @@ packages: /fromentries/1.3.2: resolution: {integrity: sha512-cHEpEQHUg0f8XdtZCc2ZAhrHzKzT0MrFUTcvx+hfxYu7rGMDc5SKoXFh+n4YigxsHXRzc6OrCshdR1bWH6HHyg==} - dev: true /fs-constants/1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} @@ -14909,6 +15053,21 @@ packages: resolution: {integrity: sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==} dev: false + /octokit/1.7.1: + resolution: {integrity: sha512-1b7eRgU8uWetHOWr8f9ptnVo2EKbrkOfocMeQdpgCt7tl/LK67HptFsy2Xg4fMjsJ/+onoBJW0hy/fO0In3/uA==} + dependencies: + '@octokit/app': 12.0.5 + '@octokit/core': 3.5.1 + '@octokit/oauth-app': 3.6.0 + '@octokit/plugin-paginate-rest': 2.17.0_@octokit+core@3.5.1 + '@octokit/plugin-rest-endpoint-methods': 5.13.0_@octokit+core@3.5.1 + '@octokit/plugin-retry': 3.0.9 + '@octokit/plugin-throttling': 3.5.2_@octokit+core@3.5.1 + '@octokit/types': 6.34.0 + transitivePeerDependencies: + - encoding + dev: false + /on-exit-leak-free/0.2.0: resolution: {integrity: sha512-dqaz3u44QbRXQooZLTUKU41ZrzYrcvLISVgbrzbyCMxpmSLJvZ3ZamIJIZ29P6OhZIkNIQKosdeM6t1LYbA9hg==} dev: false @@ -19159,6 +19318,13 @@ packages: unist-util-visit-parents: 3.1.1 dev: false + /universal-github-app-jwt/1.1.0: + resolution: {integrity: sha512-3b+ocAjjz4JTyqaOT+NNBd5BtTuvJTxWElIoeHSVelUV9J3Jp7avmQTdLKCaoqi/5Ox2o/q+VK19TJ233rVXVQ==} + dependencies: + '@types/jsonwebtoken': 8.5.8 + jsonwebtoken: 8.5.1 + dev: false + /universal-user-agent/6.0.0: resolution: {integrity: sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==} dev: false diff --git a/src/api/dependency-discovery/package.json b/src/api/dependency-discovery/package.json index fe7cf1688f..ceeafe78b4 100644 --- a/src/api/dependency-discovery/package.json +++ b/src/api/dependency-discovery/package.json @@ -22,8 +22,8 @@ }, "homepage": "https://github.com/Seneca-CDOT/telescope#readme", "dependencies": { - "@octokit/request": "5.6.3", "@senecacdot/satellite": "^1.27.0", + "octokit": "1.7.1", "query-registry": "2.2.0", "supertest": "6.1.6" }, diff --git a/src/api/dependency-discovery/src/github.js b/src/api/dependency-discovery/src/github.js index fc27d8b78d..0c00c2f31b 100644 --- a/src/api/dependency-discovery/src/github.js +++ b/src/api/dependency-discovery/src/github.js @@ -1,5 +1,4 @@ -const { request } = require('@octokit/request'); - +const { Octokit } = require('octokit'); // Check whether a specific time has reached the GitHub time limit. // @param {Date} datetime - a Date object representing a moment in the past // @returns {Boolean} @@ -11,9 +10,33 @@ const labels = ['hacktoberfest', 'good first issue', 'help wanted']; async function constructGitHubRequest(gitHubUrl) { const [owner, repo] = new URL(gitHubUrl).pathname.substring(1).split('/'); + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + // options for throttling plugin https://github.com/octokit/plugin-throttling.js + throttle: { + onRateLimit: (retryAfter, options, octokitClient) => { + octokitClient.log.warn( + `Request quota exhausted for request ${options.method} ${options.url}` + ); + + if (options.request.retryCount === 0) { + // only retries once + octokitClient.log.info(`Retrying after ${retryAfter} seconds!`); + // Return true to automatically retry the request after retryAfter seconds. + return true; + } + + return false; + }, + onAbuseLimit: (retryAfter, options, octokitClient) => { + // does not retry, only logs a warning + octokitClient.log.warn(`Abuse detected for request ${options.method} ${options.url}`); + }, + }, + }); const requestPromises = labels.map((label) => { - return request('GET /repos/{owner}/{repo}/issues{?assignee,state,labels}', { + return octokit.request('GET /repos/{owner}/{repo}/issues{?assignee,state,labels}', { owner, repo, assignee: 'none', diff --git a/src/api/status/package.json b/src/api/status/package.json index f9c5e89375..692635eea3 100644 --- a/src/api/status/package.json +++ b/src/api/status/package.json @@ -22,15 +22,13 @@ }, "homepage": "https://github.com/Seneca-CDOT/telescope#readme", "dependencies": { - "@octokit/core": "3.5.1", - "@octokit/plugin-retry": "3.0.9", - "@octokit/plugin-throttling": "3.5.2", "@popperjs/core": "2.11.5", "@senecacdot/satellite": "^1.27.0", "bootstrap": "5.1.3", "express": "4.17.3", "express-handlebars": "6.0.4", "npm-run-all": "4.1.5", + "octokit": "1.7.1", "perfect-scrollbar": "1.5.5", "sass": "1.49.9", "vite": "2.8.6", diff --git a/src/api/status/src/js/octokit.js b/src/api/status/src/js/octokit.js index 7b3ce9e8f2..49fd7972ff 100644 --- a/src/api/status/src/js/octokit.js +++ b/src/api/status/src/js/octokit.js @@ -1,9 +1,6 @@ -const { Octokit } = require('@octokit/core'); -const { retry } = require('@octokit/plugin-retry'); -const { throttling } = require('@octokit/plugin-throttling'); +const { Octokit } = require('octokit'); -const MyOctokit = Octokit.plugin(retry, throttling); -const octokit = new MyOctokit({ +const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN, // options for throttling plugin https://github.com/octokit/plugin-throttling.js throttle: {