diff --git a/package.json b/package.json index 0620a07..23a2d74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-config-helper", - "version": "2.0.0", + "version": "2.0.1", "description": "Helper for GitHub Action to manage config.", "author": { "name": "Technote", @@ -28,10 +28,11 @@ "dependencies": { "@actions/github": "^3.0.0", "@octokit/plugin-rest-endpoint-methods": "^4.0.0", + "@technote-space/github-action-helper": "^3.0.1", "js-yaml": "^3.14.0" }, "devDependencies": { - "@technote-space/github-action-test-helper": "^0.4.0", + "@technote-space/github-action-test-helper": "^0.5.0", "@types/jest": "^26.0.3", "@types/node": "^14.0.14", "@typescript-eslint/eslint-plugin": "^3.4.0", diff --git a/src/utils.ts b/src/utils.ts index 47bd3ac..cb2728d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,11 +1,12 @@ import {join} from 'path'; -import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types'; import {Context} from '@actions/github/lib/context'; +import {Octokit} from '@technote-space/github-action-helper/dist/types'; +import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types'; import {parseConfig} from './misc'; import {NOT_FOUND_STATUS} from './constant'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const getConfig = async(fileName: string, octokit: RestEndpointMethods, context: Context, options: { configPath?: string; ref?: string } = {}): Promise<{ [key: string]: any } | false> | never => { +export const getConfig = async(fileName: string, octokit: Octokit, context: Context, options: { configPath?: string; ref?: string } = {}): Promise<{ [key: string]: any } | false> | never => { const {configPath = '.github', ref} = options; try { const params: { @@ -21,7 +22,7 @@ export const getConfig = async(fileName: string, octokit: RestEndpointMethods, c if (ref) { params.ref = ref; } - return parseConfig((await octokit.repos.getContent(params)).data['content']); + return parseConfig((await (octokit as RestEndpointMethods).repos.getContent(params)).data['content']); } catch (error) { if (error.status && NOT_FOUND_STATUS === error.status) { return false; diff --git a/yarn.lock b/yarn.lock index 139fc0b..a40450d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,11 @@ # yarn lockfile v1 +"@actions/core@^1.2.4": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.4.tgz#96179dbf9f8d951dd74b40a0dbd5c22555d186ab" + integrity sha512-YJCEq8BE3CdN8+7HPZ/4DxJjk/OkZV2FFIf+DlZTC/4iBlzYCD5yjRR6eiOS5llO11zbRltIRuKAjMKaWTE6cg== + "@actions/github@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@actions/github/-/github-3.0.0.tgz#ce1b721a266ad5ac522da0c9c013c999009604bf" @@ -500,18 +505,6 @@ before-after-hook "^2.1.0" universal-user-agent "^5.0.0" -"@octokit/core@^3.0.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.1.0.tgz#9c3c9b23f7504668cfa057f143ccbf0c645a0ac9" - integrity sha512-yPyQSmxIXLieEIRikk2w8AEtWkFdfG/LXcw1KvEtK3iP0ENZLW/WYQmdzOKqfSaLhooz4CJ9D+WY79C8ZliACw== - dependencies: - "@octokit/auth-token" "^2.4.0" - "@octokit/graphql" "^4.3.1" - "@octokit/request" "^5.4.0" - "@octokit/types" "^5.0.0" - before-after-hook "^2.1.0" - universal-user-agent "^5.0.0" - "@octokit/endpoint@^6.0.1": version "6.0.3" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.3.tgz#dd09b599662d7e1b66374a177ab620d8cdf73487" @@ -537,19 +530,6 @@ dependencies: "@octokit/types" "^5.0.0" -"@octokit/plugin-request-log@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" - integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== - -"@octokit/plugin-rest-endpoint-methods@4.0.0", "@octokit/plugin-rest-endpoint-methods@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.0.0.tgz#b02a2006dda8e908c3f8ab381dd5475ef5a810a8" - integrity sha512-emS6gysz4E9BNi9IrCl7Pm4kR+Az3MmVB0/DoDCmF4U48NbYG3weKyDlgkrz6Jbl4Mu4nDx8YWZwC4HjoTdcCA== - dependencies: - "@octokit/types" "^5.0.0" - deprecation "^2.3.1" - "@octokit/plugin-rest-endpoint-methods@^3.10.0": version "3.17.0" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-3.17.0.tgz#d8ba04eb883849dd98666c55bf49d8c9fe7be055" @@ -558,6 +538,14 @@ "@octokit/types" "^4.1.6" deprecation "^2.3.1" +"@octokit/plugin-rest-endpoint-methods@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-4.0.0.tgz#b02a2006dda8e908c3f8ab381dd5475ef5a810a8" + integrity sha512-emS6gysz4E9BNi9IrCl7Pm4kR+Az3MmVB0/DoDCmF4U48NbYG3weKyDlgkrz6Jbl4Mu4nDx8YWZwC4HjoTdcCA== + dependencies: + "@octokit/types" "^5.0.0" + deprecation "^2.3.1" + "@octokit/request-error@^2.0.0": version "2.0.2" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.0.2.tgz#0e76b83f5d8fdda1db99027ea5f617c2e6ba9ed0" @@ -581,16 +569,6 @@ once "^1.4.0" universal-user-agent "^5.0.0" -"@octokit/rest@^18.0.0": - version "18.0.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.0.0.tgz#7f401d9ce13530ad743dfd519ae62ce49bcc0358" - integrity sha512-4G/a42lry9NFGuuECnua1R1eoKkdBYJap97jYbWDNYBOUboWcM75GJ1VIcfvwDV/pW0lMPs7CEmhHoVrSV5shg== - dependencies: - "@octokit/core" "^3.0.0" - "@octokit/plugin-paginate-rest" "^2.2.0" - "@octokit/plugin-request-log" "^1.0.0" - "@octokit/plugin-rest-endpoint-methods" "4.0.0" - "@octokit/types@^4.1.6": version "4.1.10" resolved "https://registry.yarnpkg.com/@octokit/types/-/types-4.1.10.tgz#e4029c11e2cc1335051775bc1600e7e740e4aca4" @@ -619,14 +597,24 @@ dependencies: "@sinonjs/commons" "^1.7.0" -"@technote-space/github-action-test-helper@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.4.0.tgz#ad52697904c1a540fdbbc1241b1a1b6b6489d04e" - integrity sha512-xiaDI/f0fjM+n/lY8cYK7438bgc8fVpxieVghGDUiGX3WI9cRVaMc4S3oSGNvhx62vKPH4dVb2IVqjhsS1FjZg== +"@technote-space/github-action-helper@^3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-3.0.1.tgz#6a42b9b0ebb512661e0a9c7e0937fe35962e52f6" + integrity sha512-LQJZ6d5mLbuHt/DeuecY/EpHpmG+WrxwT0YgVmTz+TioAcihVUB0pipvuf9OITx4R4wrfEkrsGdzZzsf3oWNIw== + dependencies: + "@actions/core" "^1.2.4" + "@actions/github" "^3.0.0" + "@octokit/plugin-rest-endpoint-methods" "^4.0.0" + shell-escape "^0.2.0" + sprintf-js "^1.1.2" + +"@technote-space/github-action-test-helper@^0.5.0": + version "0.5.0" + resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.5.0.tgz#8a355a89d3b75237a6968ad55a3c51e767e89944" + integrity sha512-G84qLpP0R/ot2c+AiY5Xs5hsoW88gajnOfnsS+en9Fo1eZbFz7Ws19epL/zf/LMZptZjeqfzQwjJZxqqbVAsyg== dependencies: "@actions/github" "^3.0.0" "@octokit/plugin-rest-endpoint-methods" "^4.0.0" - "@octokit/rest" "^18.0.0" js-yaml "^3.14.0" "@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7": @@ -3577,6 +3565,11 @@ shebang-regex@^3.0.0: resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== +shell-escape@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133" + integrity sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM= + shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" @@ -3708,6 +3701,11 @@ split-string@^3.0.1, split-string@^3.0.2: dependencies: extend-shallow "^3.0.0" +sprintf-js@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.2.tgz#da1765262bf8c0f571749f2ad6c26300207ae673" + integrity sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"