Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build almost works
Browse files Browse the repository at this point in the history
hipstersmoothie committed Apr 13, 2020
1 parent 6be45cd commit d14d61f
Showing 7 changed files with 35 additions and 36 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@
"rimraf": "^3.0.0",
"title-case": "^3.0.2",
"ts-jest": "^25.0.0",
"type-fest": "^0.13.1",
"typescript": "~3.7.2"
},
"husky": {
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,6 @@
},
"dependencies": {
"@auto-it/bot-list": "link:../../packages/bot-list",
"@octokit/core": "2.4.2",
"@octokit/graphql": "4.3.1",
"@octokit/plugin-enterprise-compatibility": "1.2.2",
"@octokit/plugin-retry": "3.0.1",
@@ -74,6 +73,7 @@
"url-join": "^4.0.0"
},
"devDependencies": {
"@octokit/types": "^2.8.0-beta.3",
"@types/dotenv": "^8.2.0",
"@types/env-ci": "^3.1.0",
"@types/graphql": "^14.2.0",
7 changes: 2 additions & 5 deletions packages/core/src/__tests__/git.test.ts
Original file line number Diff line number Diff line change
@@ -672,8 +672,7 @@ describe("github", () => {

describe("error hook", () => {
test("strip authorization headers from error", () => {
type HookError = import("@octokit/rest").Octokit.HookError;
const error = (headers = {}): HookError => ({
const error = (headers = {}) => ({
name: "Request failed",
message: "The request has failed",
status: 404,
@@ -685,9 +684,7 @@ describe("github", () => {

expect(errorHook).toHaveBeenCalled();

const errorHandler = errorHook.mock.calls[0][1] as (
error: HookError
) => void;
const errorHandler = errorHook.mock.calls[0][1] as (error: Error) => void;

expect(
errorHandler.bind(undefined, error({ authorization: "token abc" }))
12 changes: 5 additions & 7 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Octokit } from "@octokit/rest";
import { GetResponseTypeFromEndpointMethod } from "@octokit/types";
import dotenv from "dotenv";
import envCi from "env-ci";
import fs from "fs";
@@ -115,6 +115,8 @@ interface BeforeShipitContext {
releaseType: ShipitRelease;
}

type PublishResponse = GetResponseTypeFromEndpointMethod<Git["publish"]>;

export interface IAutoHooks {
/** Modify what is in the config. You must return the config in this hook. */
modifyConfig: SyncWaterfallHook<[LoadedAutoRc]>;
@@ -152,9 +154,7 @@ export interface IAutoHooks {
/** The generated release notes for the commits */
releaseNotes: string;
/** The response from creating the new release. */
response?:
| Octokit.Response<Octokit.ReposCreateReleaseResponse>
| Array<Octokit.Response<Octokit.ReposCreateReleaseResponse>>;
response?: PublishResponse | PublishResponse[];
}
]
>;
@@ -176,9 +176,7 @@ export interface IAutoHooks {
commits: IExtendedCommit[];
}
],
| Octokit.Response<Octokit.ReposCreateReleaseResponse>
| Array<Octokit.Response<Octokit.ReposCreateReleaseResponse>>
| void
PublishResponse | PublishResponse[] | void
>;
/** Get git author. Typically from a package distribution description file. */
getAuthor: AsyncSeriesBailHook<[], Partial<AuthorInformation> | void>;
16 changes: 10 additions & 6 deletions packages/core/src/git.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import path from "path";
import { retry } from "@octokit/plugin-retry";
import { throttling } from "@octokit/plugin-throttling";
import { Octokit } from "@octokit/rest";
import * as OctokitTypes from "@octokit/plugin-rest-endpoint-methods/dist-types/generated/types";
import { gitlogPromise as gitlog } from "gitlog";
import { HttpsProxyAgent } from "https-proxy-agent";
import tinyColor from "tinycolor2";
@@ -23,7 +24,10 @@ import { buildSearchQuery, ISearchResult } from "./match-sha-to-pr";
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> &
Partial<Pick<T, K>>;

export type IPRInfo = Omit<Octokit.ReposCreateStatusParams, "owner" | "repo">;
export type IPRInfo = Omit<
OctokitTypes.ReposCreateStatusParams,
"owner" | "repo"
>;

export interface IGitOptions {
/** Github repo owner (user) */
@@ -218,7 +222,7 @@ export default class Git {
async getLabels(prNumber: number) {
this.logger.verbose.info(`Getting labels for PR: ${prNumber}`);

const args: Octokit.IssuesListLabelsOnIssueParams = {
const args: OctokitTypes.IssuesListLabelsOnIssueParams = {
owner: this.options.owner,
repo: this.options.repo,
issue_number: prNumber,
@@ -245,7 +249,7 @@ export default class Git {
async getPr(prNumber: number) {
this.logger.verbose.info(`Getting info for PR: ${prNumber}`);

const args: Octokit.IssuesListLabelsOnIssueParams = {
const args: OctokitTypes.IssuesListLabelsOnIssueParams = {
owner: this.options.owner,
repo: this.options.repo,
issue_number: prNumber,
@@ -440,7 +444,7 @@ export default class Git {
async getPullRequest(pr: number) {
this.logger.verbose.info(`Getting Pull Request: ${pr}`);

const args: Octokit.PullsGetParams = {
const args: OctokitTypes.PullsGetParams = {
owner: this.options.owner,
repo: this.options.repo,
pull_number: pr,
@@ -457,7 +461,7 @@ export default class Git {
}

/** Search to GitHub project's issue and pull requests */
async searchRepo(options: Octokit.SearchIssuesAndPullRequestsParams) {
async searchRepo(options: OctokitTypes.SearchIssuesAndPullRequestsParams) {
const repo = `repo:${this.options.owner}/${this.options.repo}`;
options.q = `${repo} ${options.q}`;

@@ -621,7 +625,7 @@ export default class Git {
}

/** Get all the pull requests for a project */
async getPullRequests(options?: Partial<Octokit.PullsListParams>) {
async getPullRequests(options?: Partial<OctokitTypes.PullsListParams>) {
this.logger.verbose.info("Getting pull requests...");

const result = (
6 changes: 3 additions & 3 deletions packages/core/src/release.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import {
GraphQlQueryResponse,
GraphQlQueryResponseData,
} from "@octokit/graphql/dist-types/types";
import { Octokit } from "@octokit/rest";
import { AsyncReturnType } from "type-fest";
import on from "await-to-js";
import * as fs from "fs";
import chunk from "lodash.chunk";
@@ -630,7 +630,7 @@ export default class Release {
*/
private getPRForRebasedCommits(
commit: IExtendedCommit,
pullRequests: Octokit.PullsGetResponse[]
pullRequests: Array<AsyncReturnType<Git["getPullRequest"]>["data"]>
) {
const matchPr = pullRequests.find(
(pr) => pr.merge_commit_sha === commit.hash
@@ -655,7 +655,7 @@ export default class Release {
/** The GitHub user name of the git committer */
login?: string;
})
| Partial<Octokit.UsersGetByUsernameResponse>
| Partial<AsyncReturnType<Git["getUserByUsername"]>>
> = [];

// If there is a pull request we will attempt to get the authors
27 changes: 13 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
version "9.26.8"
dependencies:
"@auto-it/bot-list" "link:packages/bot-list"
"@octokit/core" "2.4.2"
"@octokit/graphql" "4.3.1"
"@octokit/plugin-enterprise-compatibility" "1.2.2"
"@octokit/plugin-retry" "3.0.1"
@@ -2276,18 +2275,6 @@
dependencies:
"@octokit/types" "^2.0.0"

"@octokit/core@2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-2.4.2.tgz#c22e583afc97e74015ea5bfd3ffb3ffc56c186ed"
integrity sha512-fUx/Qt774cgiPhb3HRKfdl6iufVL/ltECkwkCg373I4lIPYvAPY4cbidVZqyVqHI+ThAIlFlTW8FT4QHChv3Sg==
dependencies:
"@octokit/auth-token" "^2.4.0"
"@octokit/graphql" "^4.3.1"
"@octokit/request" "^5.3.1"
"@octokit/types" "^2.0.0"
before-after-hook "^2.1.0"
universal-user-agent "^5.0.0"

"@octokit/core@^2.4.3":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-2.5.0.tgz#4706258893a7ac6ab35d58d2fb9f2d2ba19a41a5"
@@ -2400,7 +2387,7 @@
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.2.0", "@octokit/request@^5.3.0", "@octokit/request@^5.3.1", "@octokit/request@^5.4.0":
"@octokit/request@^5.2.0", "@octokit/request@^5.3.0", "@octokit/request@^5.4.0":
version "5.4.0"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.4.0.tgz#52382c830f0cf3295b5a03e308872ac0f5ccba9b"
integrity sha512-uAJO6GI8z8VHBqtY7VTL9iFy1Y+UTp5ShpI97tY5z0qBfYKE9rZCRsCm23VmF00x+IoNJ7a0nuVITs/+wS9/mg==
@@ -2453,6 +2440,13 @@
dependencies:
"@types/node" ">= 8"

"@octokit/types@^2.8.0-beta.3":
version "2.8.0-beta.3"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.8.0-beta.3.tgz#3e460b6293d6e206ca53fabdaa27d6ddfc31890c"
integrity sha512-PPad9g/oWAC5/ckTw11wOq3g5Su3tLOESHwqUTjOuXfkxC9NVvWF3Oq3oHTxU2TQpKho8gAnl0HMs0RwVI4YrA==
dependencies:
"@types/node" ">= 8"

"@octokit/types@^2.8.2":
version "2.8.2"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.8.2.tgz#08d1165354637ef32c3134b4b39b7f17bdc17aef"
@@ -14755,6 +14749,11 @@ type-detect@4.0.8:
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==

type-fest@^0.13.1:
version "0.13.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934"
integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg==

type-fest@^0.3.0:
version "0.3.1"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1"

0 comments on commit d14d61f

Please sign in to comment.