File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Octokit as Core } from "@octokit/core" ;
2
2
import { createActionAuth } from "@octokit/auth-action" ;
3
+ import { paginateRest } from "@octokit/plugin-paginate-rest" ;
3
4
4
5
import { VERSION } from "./version" ;
5
6
6
- export const Octokit = Core . defaults ( {
7
+ const CoreWithPlugins = Core . plugin ( [ paginateRest ] ) ;
8
+
9
+ // Workaround for TypeScript bug, see https://github.com/octokit/core.js#a-note-on-typescript
10
+ import {
11
+ OctokitOptions ,
12
+ OctokitPlugin ,
13
+ ReturnTypeOf ,
14
+ Constructor
15
+ } from "@octokit/core" ;
16
+
17
+ class CoreWithPluginsWorkaround extends CoreWithPlugins {
18
+ static plugin < T extends OctokitPlugin | OctokitPlugin [ ] > ( pluginOrPlugins : T ) {
19
+ const currentPlugins = this . plugins ;
20
+ const newPlugins = Array . isArray ( pluginOrPlugins )
21
+ ? pluginOrPlugins
22
+ : [ pluginOrPlugins ] ;
23
+
24
+ const NewOctokit = class extends this {
25
+ static plugins = currentPlugins . concat (
26
+ newPlugins . filter ( plugin => ! currentPlugins . includes ( plugin ) )
27
+ ) ;
28
+ } ;
29
+
30
+ return NewOctokit as typeof NewOctokit & Constructor < ReturnTypeOf < T > > ;
31
+ }
32
+
33
+ static defaults ( defaults : OctokitOptions ) {
34
+ return class OctokitWithDefaults extends this {
35
+ constructor ( options : OctokitOptions = { } ) {
36
+ super ( Object . assign ( { } , defaults , options ) ) ;
37
+ }
38
+ } ;
39
+ }
40
+ }
41
+
42
+ export const Octokit = CoreWithPluginsWorkaround . defaults ( {
7
43
authStrategy : createActionAuth ,
8
44
userAgent : `octokit-action.js/${ VERSION } `
9
45
} ) ;
You can’t perform that action at this time.
0 commit comments