Skip to content

Commit e7b2bfd

Browse files
fix: adapt for latest @octokit/types (#199)
1 parent a35b02d commit e7b2bfd

File tree

6 files changed

+1944
-2645
lines changed

6 files changed

+1944
-2645
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const octokit = new MyOctokit({
5252
auth: "token123",
5353
});
5454

55-
octokit.request("POST /repos/:owner/:repo/issues/:issue_number/labels", {
55+
octokit.request("POST /repos/{owner}/{repo}/issues/{issue_number}/labels", {
5656
owner,
5757
repo,
5858
number,

package-lock.json

Lines changed: 1915 additions & 2360 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"license": "MIT",
2727
"dependencies": {
2828
"@octokit/request-error": "^2.0.4",
29-
"@octokit/types": "^6.0.0"
29+
"@octokit/types": "^6.0.3"
3030
},
3131
"devDependencies": {
3232
"@octokit/core": "^3.0.0",

src/index.ts

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ import { RequestError } from "@octokit/request-error";
55

66
import { VERSION } from "./version";
77
import { isIssueLabelsUpdateOrReplace } from "./is-issue-labels-update-or-replace";
8-
import {
9-
isGetReference,
10-
isListReferences,
11-
} from "./is-get-reference-or-list-references";
128

139
export function enterpriseCompatibility(octokit: Octokit) {
1410
octokit.hook.wrap(
@@ -27,50 +23,6 @@ export function enterpriseCompatibility(octokit: Octokit) {
2723
return request(options);
2824
}
2925

30-
const isGetReferenceRequest = isGetReference(options);
31-
const isListReferencesRequest = isListReferences(options);
32-
if (isGetReferenceRequest || isListReferencesRequest) {
33-
options.url = options.url.replace(
34-
/\/repos\/([^/]+)\/([^/]+)\/git\/(ref|matching-refs)\/(.*)$/,
35-
"/repos/$1/$2/git/refs/$4"
36-
);
37-
return request(options)
38-
.then((response: OctokitResponse<any>) => {
39-
if (isGetReferenceRequest) {
40-
if (Array.isArray(response.data)) {
41-
throw new RequestError(
42-
`More than one reference found at "${options.url}"`,
43-
404,
44-
{
45-
request: options,
46-
}
47-
);
48-
}
49-
50-
// ✅ received single reference
51-
return response;
52-
}
53-
54-
// make sure that
55-
if (!Array.isArray(response.data)) {
56-
response.data = [response.data];
57-
}
58-
59-
return response;
60-
})
61-
.catch((error: RequestError) => {
62-
if (isListReferencesRequest && error.status === 404) {
63-
return {
64-
status: 200,
65-
headers: error.headers,
66-
data: [],
67-
};
68-
}
69-
70-
throw error;
71-
});
72-
}
73-
7426
// TODO: implement fix for #62 here
7527

7628
// https://github.com/octokit/plugin-enterprise-compatibility.js/issues/60
@@ -88,7 +40,7 @@ export function enterpriseCompatibility(octokit: Octokit) {
8840

8941
const deprecatedUrl = options.url.replace(
9042
/\/orgs\/[^/]+\/teams\/[^/]+/,
91-
"/teams/:team_id"
43+
"/teams/{team_id}"
9244
);
9345

9446
throw new RequestError(

src/is-get-reference-or-list-references.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)