diff --git a/lib/release/release-manager.js b/lib/release/release-manager.js index 91b673a9..fb4ae84e 100644 --- a/lib/release/release-manager.js +++ b/lib/release/release-manager.js @@ -1,4 +1,3 @@ -const { Octokit } = require('@octokit/rest') const core = require('@actions/core') const { join } = require('path') const semver = require('semver') @@ -9,17 +8,16 @@ const { request: fetch } = require('undici') const { getPublishTag, block, noop } = require('./util') class ReleaseManager { - #octokit - #owner - #repo - #cwd - #pr #backport + #cwd #defaultTag + #info #lockfile + #owner + #pr #publish - - #info + #repo + #token constructor({ token, repo, cwd = process.cwd(), pr, backport, defaultTag, lockfile, publish, silent }) { assert(token, 'GITHUB_TOKEN is required') @@ -28,17 +26,16 @@ class ReleaseManager { assert(pr, 'pr is required') assert(defaultTag, 'defaultTag is required') - this.#octokit = new Octokit({ auth: token }) - this.#owner = repo.split('/')[0] - this.#repo = repo.split('/')[1] - this.#cwd = cwd - this.#pr = pr this.#backport = backport + this.#cwd = cwd this.#defaultTag = defaultTag + this.#info = silent ? noop : core.info this.#lockfile = lockfile + this.#owner = repo.split('/')[0] + this.#pr = pr this.#publish = publish - - this.#info = silent ? noop : core.info + this.#repo = repo.split('/')[1] + this.#token = token } static async run(options) { @@ -47,7 +44,9 @@ class ReleaseManager { } async run() { - const { data: pullRequest } = await this.#octokit.rest.pulls.get({ + const { Octokit } = await import('@octokit/rest') + const octokit = new Octokit({ auth: this.#token }) + const { data: pullRequest } = await octokit.rest.pulls.get({ owner: this.#owner, repo: this.#repo, pull_number: this.#pr, diff --git a/package.json b/package.json index 7e3d7467..228c2a07 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@npmcli/git": "^5.0.3", "@npmcli/map-workspaces": "^3.0.0", "@npmcli/package-json": "^5.0.0", - "@octokit/rest": "^19.0.4", + "@octokit/rest": "^21.0.0", "dedent": "^1.5.1", "diff": "^5.0.0", "glob": "^10.1.0", @@ -68,7 +68,7 @@ ], "devDependencies": { "@github/prettier-config": "0.0.6", - "@npmcli/eslint-config": "^4.0.0", + "@npmcli/eslint-config": "^4.0.5", "@npmcli/template-oss": "file:./", "eslint-config-prettier": "^9.1.0", "nock": "^13.3.8",