1
- const { Octokit } = require ( '@octokit/rest' )
2
1
const core = require ( '@actions/core' )
3
2
const { join } = require ( 'path' )
4
3
const semver = require ( 'semver' )
@@ -9,17 +8,16 @@ const { request: fetch } = require('undici')
9
8
const { getPublishTag, block, noop } = require ( './util' )
10
9
11
10
class ReleaseManager {
12
- #octokit
13
- #owner
14
- #repo
15
- #cwd
16
- #pr
17
11
#backport
12
+ #cwd
18
13
#defaultTag
14
+ #info
19
15
#lockfile
16
+ #owner
17
+ #pr
20
18
#publish
21
-
22
- #info
19
+ #repo
20
+ #token
23
21
24
22
constructor ( { token, repo, cwd = process . cwd ( ) , pr, backport, defaultTag, lockfile, publish, silent } ) {
25
23
assert ( token , 'GITHUB_TOKEN is required' )
@@ -28,17 +26,16 @@ class ReleaseManager {
28
26
assert ( pr , 'pr is required' )
29
27
assert ( defaultTag , 'defaultTag is required' )
30
28
31
- this . #octokit = new Octokit ( { auth : token } )
32
- this . #owner = repo . split ( '/' ) [ 0 ]
33
- this . #repo = repo . split ( '/' ) [ 1 ]
34
- this . #cwd = cwd
35
- this . #pr = pr
36
29
this . #backport = backport
30
+ this . #cwd = cwd
37
31
this . #defaultTag = defaultTag
32
+ this . #info = silent ? noop : core . info
38
33
this . #lockfile = lockfile
34
+ this . #owner = repo . split ( '/' ) [ 0 ]
35
+ this . #pr = pr
39
36
this . #publish = publish
40
-
41
- this . #info = silent ? noop : core . info
37
+ this . #repo = repo . split ( '/' ) [ 1 ]
38
+ this . #token = token
42
39
}
43
40
44
41
static async run ( options ) {
@@ -47,7 +44,9 @@ class ReleaseManager {
47
44
}
48
45
49
46
async run ( ) {
50
- const { data : pullRequest } = await this . #octokit. rest . pulls . get ( {
47
+ const { Octokit } = await import ( '@octokit/rest' )
48
+ const octokit = new Octokit ( { auth : this . #token } )
49
+ const { data : pullRequest } = await octokit . rest . pulls . get ( {
51
50
owner : this . #owner,
52
51
repo : this . #repo,
53
52
pull_number : this . #pr,
0 commit comments