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 1
1
import { Octokit } from "@octokit/core" ;
2
+ import { Deprecation } from "deprecation" ;
2
3
3
4
import endpointsByScope from "./generated/endpoints" ;
4
5
import { VERSION } from "./version" ;
@@ -19,17 +20,28 @@ export function restEndpointMethods(octokit: Octokit): Api {
19
20
// @ts -ignore
20
21
octokit . registerEndpoints = registerEndpoints . bind ( null , octokit ) ;
21
22
23
+ registerEndpoints ( octokit , endpointsByScope ) ;
24
+
22
25
// Aliasing scopes for backward compatibility
23
26
// 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
+ } ) ;
33
45
34
46
return { } as Api ;
35
47
}
You can’t perform that action at this time.
0 commit comments