diff --git a/development/metamaskbot-build-announce.js b/development/metamaskbot-build-announce.js index 2914ce3080ae..c45acda275e3 100755 --- a/development/metamaskbot-build-announce.js +++ b/development/metamaskbot-build-announce.js @@ -1,7 +1,7 @@ #!/usr/bin/env node const { promises: fs } = require('fs') const path = require('path') -const request = require('request-promise') +const fetch = require('node-fetch') const VERSION = require('../dist/chrome/manifest.json').version // eslint-disable-line import/no-unresolved start().catch(console.error) @@ -78,7 +78,11 @@ async function start () { const benchmarkResults = {} for (const platform of platforms) { - const benchmarkPath = path.resolve(__dirname, '..', path.join('test-artifacts', platform, 'benchmark', 'pageload.json')) + const benchmarkPath = path.resolve( + __dirname, + '..', + path.join('test-artifacts', platform, 'benchmark', 'pageload.json') + ) try { const data = await fs.readFile(benchmarkPath, 'utf8') const benchmark = JSON.parse(data) @@ -87,7 +91,9 @@ async function start () { if (error.code === 'ENOENT') { console.log(`No benchmark data found for ${platform}; skipping`) } else { - console.error(`Error encountered processing benchmark data for '${platform}': '${error}'`) + console.error( + `Error encountered processing benchmark data for '${platform}': '${error}'` + ) } } } @@ -98,8 +104,12 @@ async function start () { commentBody = artifactsBody } else { try { - const chromePageLoad = Math.round(parseFloat(benchmarkResults.chrome.notification.average.load)) - const chromePageLoadMarginOfError = Math.round(parseFloat(benchmarkResults.chrome.notification.marginOfError.load)) + const chromePageLoad = Math.round( + parseFloat(benchmarkResults.chrome.notification.average.load) + ) + const chromePageLoadMarginOfError = Math.round( + parseFloat(benchmarkResults.chrome.notification.marginOfError.load) + ) const benchmarkSummary = `Page Load Metrics (${chromePageLoad} ± ${chromePageLoadMarginOfError} ms)` const allPlatforms = new Set() @@ -133,14 +143,21 @@ async function start () { for (const metric of allMetrics) { let metricData = `${metric}` for (const measure of allMeasures) { - metricData += `${Math.round(parseFloat(benchmarkResults[platform][page][measure][metric]))}` + metricData += `${Math.round( + parseFloat(benchmarkResults[platform][page][measure][metric]) + )}` } metricRows.push(metricData) } - metricRows[0] = `${capitalizeFirstLetter(page)}${metricRows[0]}` + metricRows[0] = `${capitalizeFirstLetter(page)}${metricRows[0]}` pageRows.push(...metricRows) } - pageRows[0] = `${capitalizeFirstLetter(platform)}${pageRows[0]}` + pageRows[0] = `${capitalizeFirstLetter(platform)}${ + pageRows[0] + }` for (const row of pageRows) { tableRows.push(`${row}`) } @@ -150,7 +167,9 @@ async function start () { for (const measure of allMeasures) { benchmarkTableHeaders.push(`${capitalizeFirstLetter(measure)} (ms)`) } - const benchmarkTableHeader = `${benchmarkTableHeaders.map(header => `${header}`).join('')}` + const benchmarkTableHeader = `${benchmarkTableHeaders + .map(header => `${header}`) + .join('')}` const benchmarkTableBody = `${tableRows.join('')}` const benchmarkTable = `${benchmarkTableHeader}${benchmarkTableBody}
` const benchmarkBody = `
${benchmarkSummary}${benchmarkTable}
` @@ -166,9 +185,8 @@ async function start () { console.log(`Announcement:\n${commentBody}`) console.log(`Posting to: ${POST_COMMENT_URI}`) - await request({ + await fetch(POST_COMMENT_URI, { method: 'POST', - uri: POST_COMMENT_URI, body: JSON_PAYLOAD, headers: { 'User-Agent': 'confluxbot', diff --git a/package.json b/package.json index 6d7f59a16022..aeb4edbb5da8 100644 --- a/package.json +++ b/package.json @@ -190,7 +190,6 @@ "redux": "^3.0.5", "redux-logger": "^3.0.6", "redux-thunk": "^2.2.0", - "request-promise": "^4.2.1", "reselect": "^3.0.1", "rpc-cap": "^1.0.1", "safe-event-emitter": "^1.0.1", @@ -292,6 +291,7 @@ "mocha-jsdom": "^1.1.0", "mocha-sinon": "^2.0.0", "nock": "^9.0.14", + "node-fetch": "^2.6.0", "node-sass": "^4.12.0", "nodemon": "^2.0.2", "nyc": "^13.0.0", diff --git a/yarn.lock b/yarn.lock index 2edc645baaa4..c07ba0e48daf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24690,16 +24690,6 @@ request-promise-native@^1.0.3: stealthy-require "^1.1.0" tough-cookie ">=2.3.3" -request-promise@^4.2.1: - version "4.2.2" - resolved "https://registry.yarnpkg.com/request-promise/-/request-promise-4.2.2.tgz#d1ea46d654a6ee4f8ee6a4fea1018c22911904b4" - integrity sha1-0epG1lSm7k+O5qT+oQGMIpEZBLQ= - dependencies: - bluebird "^3.5.0" - request-promise-core "1.1.1" - stealthy-require "^1.1.0" - tough-cookie ">=2.3.3" - request@^2.45.0, request@^2.81.0, request@^2.83.0: version "2.87.0" resolved "https://registry.yarnpkg.com/request/-/request-2.87.0.tgz#32f00235cd08d482b4d0d68db93a829c0ed5756e"