Skip to content

Commit

Permalink
build(deps): bump @octokit/rest from 16.43.1 to 18.0.0 (#1813)
Browse files Browse the repository at this point in the history
* build(deps): bump @octokit/rest from 16.43.1 to 18.0.0

Bumps [@octokit/rest](https://github.com/octokit/rest.js) from 16.43.1 to 18.0.0.
- [Release notes](https://github.com/octokit/rest.js/releases)
- [Commits](octokit/rest.js@v16.43.1...v18.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Finish upgrading via bolt

* refactor(publisher-github): reference Octokit's options type correctly

* refactor(publisher-github): fix up release types for 18.0.0

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: malept <malept@users.noreply.github.com>
Co-authored-by: Mark Lee <electronjs@lazymalevolence.com>
  • Loading branch information
3 people authored Jul 4, 2020
1 parent d87635f commit 0a8d66e
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 121 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"dependencies": {
"@electron/get": "^1.9.0",
"@malept/cross-spawn-promise": "^1.1.0",
"@octokit/rest": "^16.43.1",
"@octokit/core": "^3.1.0",
"@octokit/rest": "^18.0.0",
"@octokit/types": "^5.0.1",
"@types/which": "^1.3.2",
"aws-sdk": "^2.472.0",
"colors": "^1.4.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/publisher/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"@electron-forge/async-ora": "6.0.0-beta.52",
"@electron-forge/publisher-base": "6.0.0-beta.52",
"@electron-forge/shared-types": "6.0.0-beta.52",
"@octokit/rest": "^16.43.1",
"@octokit/core": "^3.1.0",
"@octokit/rest": "^18.0.0",
"@octokit/types": "^5.0.1",
"fs-extra": "^9.0.1",
"lodash": "^4.17.15",
"mime-types": "^2.1.25"
Expand Down
4 changes: 2 additions & 2 deletions packages/publisher/github/src/Config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Octokit } from '@octokit/rest';
import { OctokitOptions } from './util/github';

export interface GitHubRepository {
/**
Expand Down Expand Up @@ -30,7 +30,7 @@ export interface PublisherGitHubConfig {
* customize any of the options that module uses. This is particularly
* helpful for publishing to GitHub Enterprise servers.
*/
octokitOptions?: Octokit.Options;
octokitOptions?: OctokitOptions;
/**
* Whether or not this release should be tagged as a prerelease
*/
Expand Down
22 changes: 15 additions & 7 deletions packages/publisher/github/src/PublisherGithub.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import PublisherBase, { PublisherOptions } from '@electron-forge/publisher-base';
import { asyncOra } from '@electron-forge/async-ora';

import { ForgeMakeResult } from '@electron-forge/shared-types';
import fs from 'fs-extra';
import mime from 'mime-types';
import path from 'path';
import PublisherBase, { PublisherOptions } from '@electron-forge/publisher-base';
import {
ReposCreateReleaseResponseData as OctokitRelease,
ReposGetReleaseAssetResponseData as OctokitReleaseAsset,
} from '@octokit/types/dist-types/generated/Endpoints.d';

import { ForgeMakeResult } from '@electron-forge/shared-types';
import { Octokit } from '@octokit/rest';
import GitHub from './util/github';
import { PublisherGitHubConfig } from './Config';

Expand Down Expand Up @@ -46,7 +48,7 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
const github = new GitHub(config.authToken, true, config.octokitOptions);

for (const releaseName of Object.keys(perReleaseArtifacts)) {
let release: Octokit.ReposListReleasesResponseItem | undefined;
let release: OctokitRelease | undefined;
const artifacts = perReleaseArtifacts[releaseName];

await asyncOra(`Searching for target release: ${releaseName}`, async () => {
Expand Down Expand Up @@ -94,12 +96,18 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
uploaded += 1;
updateSpinner();
};
if (release!.assets.find((asset) => asset.name === path.basename(artifactPath))) {
const artifactName = path.basename(artifactPath);
// eslint-disable-next-line max-len
if (release!.assets.find((asset) => (asset as OctokitReleaseAsset).name === artifactName)) {
return done();
}
await github.getGitHub().repos.uploadReleaseAsset({
owner: config.repository.owner,
repo: config.repository.name,
release_id: release!.id,
url: release!.upload_url,
file: fs.createReadStream(artifactPath),
// https://github.com/octokit/rest.js/issues/1645
data: ((await fs.readFile(artifactPath)) as unknown) as string,
headers: {
'content-type': mime.lookup(artifactPath) || 'application/octet-stream',
'content-length': (await fs.stat(artifactPath)).size,
Expand Down
7 changes: 5 additions & 2 deletions packages/publisher/github/src/util/github.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { Octokit } from '@octokit/rest';
import { OctokitOptions } from '@octokit/core/dist-types/types.d';
import { merge } from 'lodash';

export { OctokitOptions } from '@octokit/core/dist-types/types.d';

export default class GitHub {
private options: Octokit.Options;
private options: OctokitOptions;

token?: string;

constructor(
authToken: string | undefined = undefined,
requireAuth: boolean = false,
options: Octokit.Options = {},
options: OctokitOptions = {},
) {
this.options = merge(
options,
Expand Down
Loading

0 comments on commit 0a8d66e

Please sign in to comment.