File tree Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Expand file tree Collapse file tree 1 file changed +21
-9
lines changed Original file line number Diff line number Diff line change 11import { Octokit } from "@octokit/core" ;
2+ import { Deprecation } from "deprecation" ;
23
34import endpointsByScope from "./generated/endpoints" ;
45import { VERSION } from "./version" ;
@@ -19,17 +20,28 @@ export function restEndpointMethods(octokit: Octokit): Api {
1920 // @ts -ignore
2021 octokit . registerEndpoints = registerEndpoints . bind ( null , octokit ) ;
2122
23+ registerEndpoints ( octokit , endpointsByScope ) ;
24+
2225 // Aliasing scopes for backward compatibility
2326 // See https://github.com/octokit/rest.js/pull/1134
24- // @ts -ignore
25- registerEndpoints (
26- octokit ,
27- Object . assign ( endpointsByScope , {
28- gitdata : endpointsByScope . git ,
29- authorization : endpointsByScope . oauthAuthorizations ,
30- pullRequests : endpointsByScope . pulls
31- } )
32- ) ;
27+ [
28+ [ "gitdata" , "git" ] ,
29+ [ "authorization" , "oauthAuthorizations" ] ,
30+ [ "pullRequests" , "pulls" ]
31+ ] . forEach ( ( [ deprecatedScope , scope ] ) => {
32+ Object . defineProperty ( octokit , deprecatedScope , {
33+ get ( ) {
34+ octokit . log . warn (
35+ // @ts -ignore
36+ new Deprecation (
37+ `[@octokit/plugin-rest-endpoint-methods] "octokit.${ deprecatedScope } .*" methods are deprecated, use "octokit.${ scope } .*" instead`
38+ )
39+ ) ;
40+ // @ts -ignore
41+ return octokit [ scope ] ;
42+ }
43+ } ) ;
44+ } ) ;
3345
3446 return { } as Api ;
3547}
You can’t perform that action at this time.
0 commit comments