From 6770a8c64a6fa7ee19c37efd0411f5f08dc3181c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 7 May 2019 18:48:40 -0700 Subject: [PATCH] build: remove deprecated octokit auth calls (#18205) --- script/find-release.js | 6 +++--- script/prepare-release.js | 6 +++--- script/release-artifact-cleanup.js | 13 +++++-------- script/release-notes/notes.js | 6 +++--- script/release.js | 6 ++---- script/upload-to-github.js | 5 +++-- 6 files changed, 19 insertions(+), 23 deletions(-) diff --git a/script/find-release.js b/script/find-release.js index 465021952bbb..4551133c1d69 100644 --- a/script/find-release.js +++ b/script/find-release.js @@ -1,6 +1,8 @@ if (!process.env.CI) require('dotenv-safe').load() -const octokit = require('@octokit/rest')() +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN +}) if (process.argv.length < 3) { console.log('Usage: find-release version') @@ -10,8 +12,6 @@ if (process.argv.length < 3) { const version = process.argv[2] async function findRelease () { - octokit.authenticate({ type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN }) - const releases = await octokit.repos.listReleases({ owner: 'electron', repo: version.indexOf('nightly') > 0 ? 'nightlies' : 'electron' diff --git a/script/prepare-release.js b/script/prepare-release.js index 7576a8aad7d6..453a7bb83a32 100755 --- a/script/prepare-release.js +++ b/script/prepare-release.js @@ -5,7 +5,9 @@ const args = require('minimist')(process.argv.slice(2), { boolean: ['automaticRelease', 'notesOnly', 'stable'] }) const ciReleaseBuild = require('./ci-release-build') -const octokit = require('@octokit/rest')() +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN +}) const { execSync } = require('child_process') const { GitProcess } = require('dugite') @@ -27,8 +29,6 @@ if (!bumpType && !args.notesOnly) { } const gitDir = path.resolve(__dirname, '..') -octokit.authenticate({ type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN }) - async function getNewVersion (dryRun) { if (!dryRun) { console.log(`Bumping for new "${bumpType}" version.`) diff --git a/script/release-artifact-cleanup.js b/script/release-artifact-cleanup.js index 5cd607f5e545..87111c9dd061 100755 --- a/script/release-artifact-cleanup.js +++ b/script/release-artifact-cleanup.js @@ -12,16 +12,13 @@ const { execSync } = require('child_process') const { GitProcess } = require('dugite') const { getCurrentBranch } = require('./lib/utils.js') -const octokit = require('@octokit/rest')() -const path = require('path') - -const gitDir = path.resolve(__dirname, '..') - -octokit.authenticate({ - type: 'token', - token: process.env.ELECTRON_GITHUB_TOKEN +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN }) +const path = require('path') +const gitDir = path.resolve(__dirname, '..') + function getLastBumpCommit (tag) { const data = execSync(`git log -n1 --grep "Bump ${tag}" --format='format:{"hash": "%H", "message": "%s"}'`).toString() return JSON.parse(data) diff --git a/script/release-notes/notes.js b/script/release-notes/notes.js index b71254711167..8b968cb22cc7 100644 --- a/script/release-notes/notes.js +++ b/script/release-notes/notes.js @@ -6,7 +6,9 @@ const os = require('os') const path = require('path') const { GitProcess } = require('dugite') -const octokit = require('@octokit/rest')() +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN +}) const semver = require('semver') const MAX_FAIL_COUNT = 3 @@ -17,8 +19,6 @@ const NO_NOTES = 'No notes' const FOLLOW_REPOS = [ 'electron/electron', 'electron/libchromiumcontent', 'electron/node' ] const gitDir = path.resolve(__dirname, '..', '..') -octokit.authenticate({ type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN }) - const breakTypes = new Set(['breaking-change']) const docTypes = new Set(['doc', 'docs']) const featTypes = new Set(['feat', 'feature']) diff --git a/script/release.js b/script/release.js index f77ba65b82e2..c7dbc74f7701 100755 --- a/script/release.js +++ b/script/release.js @@ -24,10 +24,8 @@ const sumchecker = require('sumchecker') const temp = require('temp').track() const { URL } = require('url') -const octokit = require('@octokit/rest')() -octokit.authenticate({ - type: 'token', - token: process.env.ELECTRON_GITHUB_TOKEN +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN }) const targetRepo = pkgVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron' diff --git a/script/upload-to-github.js b/script/upload-to-github.js index 6c517aa9d22c..121dd89a90ec 100644 --- a/script/upload-to-github.js +++ b/script/upload-to-github.js @@ -2,8 +2,9 @@ if (!process.env.CI) require('dotenv-safe').load() const fs = require('fs') -const octokit = require('@octokit/rest')() -octokit.authenticate({ type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN }) +const octokit = require('@octokit/rest')({ + auth: process.env.ELECTRON_GITHUB_TOKEN +}) if (process.argv.length < 6) { console.log('Usage: upload-to-github filePath fileName releaseId')