From c361da759c233d58fb13689083beb7017b916536 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 17 Nov 2024 13:23:40 +0000 Subject: [PATCH] =?UTF-8?q?format=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/assign_a_user.js | 3 +- dist/close_pull_request.js | 64 ++++++++------------ dist/create_pull_request.js | 52 ++++++---------- dist/generate_title_description.js | 3 +- dist/get_number_of_pull_requests.js | 22 ++----- dist/get_pull_requests.js | 3 +- dist/update_pull_request.js | 46 ++++++-------- package-lock.json | 8 --- scripts/format/format/get_inputs_markdown.ts | 16 ++--- src/assign_a_user.ts | 19 +++--- src/close_pull_request.ts | 32 +++++----- src/create_pull_request.ts | 21 ++++--- src/generate_title_description.ts | 12 ++-- src/get_number_of_pull_requests.ts | 14 ++--- src/get_pull_requests.ts | 31 +++++----- src/update_pull_request.ts | 25 ++++---- 16 files changed, 158 insertions(+), 213 deletions(-) diff --git a/dist/assign_a_user.js b/dist/assign_a_user.js index 447c1979..f8941f74 100644 --- a/dist/assign_a_user.js +++ b/dist/assign_a_user.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; async function script(github, context) { const issuesAddAssigneesParams = { owner: context.repo.owner, @@ -12,4 +12,3 @@ async function script(github, context) { console.log(issuesAddAssigneesParams); await github.rest.issues.addAssignees(issuesAddAssigneesParams); } -exports.script = script; diff --git a/dist/close_pull_request.js b/dist/close_pull_request.js index 60581585..0e5ba307 100644 --- a/dist/close_pull_request.js +++ b/dist/close_pull_request.js @@ -1,42 +1,30 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF; - let headName = process.env.BRANCH_NAME_PREFIX; - if (HEAD_REF !== "") { - headName += "-" + HEAD_REF; - } - for (const pull of yield (0, get_pull_requests_1.getPullRequests)(github, context)) { - // 修正PRをcloseする (修正PRのstateをclosedに更新する) - const pullsUpdateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - state: "closed", - }; - console.log("call pulls.update:", pullsUpdateParams); - yield github.rest.pulls.update(pullsUpdateParams); - // 修正PRのブランチを削除する - const gitDeleteRefParams = { - owner: context.repo.owner, - repo: context.repo.repo, - ref: "heads/" + headName, - }; - console.log("call git.deleteRef:", gitDeleteRefParams); - yield github.rest.git.deleteRef(gitDeleteRefParams); - } - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF; + let headName = process.env.BRANCH_NAME_PREFIX; + if (HEAD_REF !== "") { + headName += "-" + HEAD_REF; + } + for (const pull of await (0, get_pull_requests_1.getPullRequests)(github, context)) { + // 修正PRをcloseする (修正PRのstateをclosedに更新する) + const pullsUpdateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + state: "closed", + }; + console.log("call pulls.update:", pullsUpdateParams); + await github.rest.pulls.update(pullsUpdateParams); + // 修正PRのブランチを削除する + const gitDeleteRefParams = { + owner: context.repo.owner, + repo: context.repo.repo, + ref: "heads/" + headName, + }; + console.log("call git.deleteRef:", gitDeleteRefParams); + await github.rest.git.deleteRef(gitDeleteRefParams); + } } -exports.script = script; diff --git a/dist/create_pull_request.js b/dist/create_pull_request.js index 5726d507..c5ca89df 100644 --- a/dist/create_pull_request.js +++ b/dist/create_pull_request.js @@ -1,36 +1,24 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const generate_title_description_1 = require("./generate_title_description"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF || ""; - let head = process.env.BRANCH_NAME_PREFIX; - if (HEAD_REF !== "") { - head += "-" + HEAD_REF; - } - const headWithRepo = context.repo.owner + ":" + head; - const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); - const pullsCreateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - head: headWithRepo, - base: HEAD_REF, - title, - body, - }; - console.log("call pulls.create:", pullsCreateParams); - const createPullRes = yield github.rest.pulls.create(pullsCreateParams); - return createPullRes.data.number; - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF || ""; + let head = process.env.BRANCH_NAME_PREFIX; + if (HEAD_REF !== "") { + head += "-" + HEAD_REF; + } + const headWithRepo = context.repo.owner + ":" + head; + const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); + const pullsCreateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + head: headWithRepo, + base: HEAD_REF, + title, + body, + }; + console.log("call pulls.create:", pullsCreateParams); + const createPullRes = await github.rest.pulls.create(pullsCreateParams); + return createPullRes.data.number; } -exports.script = script; diff --git a/dist/generate_title_description.js b/dist/generate_title_description.js index d16d42ed..3ec3e49f 100644 --- a/dist/generate_title_description.js +++ b/dist/generate_title_description.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.generateTitleDescription = void 0; +exports.generateTitleDescription = generateTitleDescription; function generateTitleDescription() { const HEAD_REF = process.env.HEAD_REF || ""; const escapedHeadRef = HEAD_REF.replace(/#/g, ""); @@ -48,4 +48,3 @@ function generateTitleDescription() { body, }; } -exports.generateTitleDescription = generateTitleDescription; diff --git a/dist/get_number_of_pull_requests.js b/dist/get_number_of_pull_requests.js index 27bde214..80e7c436 100644 --- a/dist/get_number_of_pull_requests.js +++ b/dist/get_number_of_pull_requests.js @@ -1,21 +1,9 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const HEAD_REF = process.env.HEAD_REF; - const pulls = yield (0, get_pull_requests_1.getPullRequests)(github, context, HEAD_REF); - return pulls.length; - }); +async function script(github, context) { + const HEAD_REF = process.env.HEAD_REF; + const pulls = await (0, get_pull_requests_1.getPullRequests)(github, context, HEAD_REF); + return pulls.length; } -exports.script = script; diff --git a/dist/get_pull_requests.js b/dist/get_pull_requests.js index 7faa002f..ce297f4d 100644 --- a/dist/get_pull_requests.js +++ b/dist/get_pull_requests.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.getPullRequests = void 0; +exports.getPullRequests = getPullRequests; async function getPullRequests(github, context, base) { const HEAD_REF = process.env.HEAD_REF; let head = context.repo.owner + ":" + process.env.BRANCH_NAME_PREFIX; @@ -17,4 +17,3 @@ async function getPullRequests(github, context, base) { console.log("call pulls.list:", pullsListParams); return await github.paginate(github.rest.pulls.list, pullsListParams); } -exports.getPullRequests = getPullRequests; diff --git a/dist/update_pull_request.js b/dist/update_pull_request.js index 149b6b0f..c03e39cb 100644 --- a/dist/update_pull_request.js +++ b/dist/update_pull_request.js @@ -1,35 +1,23 @@ "use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.script = void 0; +exports.script = script; const generate_title_description_1 = require("./generate_title_description"); const get_pull_requests_1 = require("./get_pull_requests"); -function script(github, context) { - return __awaiter(this, void 0, void 0, function* () { - const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); - for (const pull of yield (0, get_pull_requests_1.getPullRequests)(github, context)) { - if (pull.title === title && pull.body === body) { - continue; - } - // PRのタイトルやDescriptionを更新する - const pullsUpdateParams = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - title, - body, - }; - console.log("call pulls.update:", pullsUpdateParams); - yield github.rest.pulls.update(pullsUpdateParams); +async function script(github, context) { + const { title, body } = (0, generate_title_description_1.generateTitleDescription)(); + for (const pull of await (0, get_pull_requests_1.getPullRequests)(github, context)) { + if (pull.title === title && pull.body === body) { + continue; } - }); + // PRのタイトルやDescriptionを更新する + const pullsUpdateParams = { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + title, + body, + }; + console.log("call pulls.update:", pullsUpdateParams); + await github.rest.pulls.update(pullsUpdateParams); + } } -exports.script = script; diff --git a/package-lock.json b/package-lock.json index 3ca60ce1..da3fbf28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7564,14 +7564,6 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/try-resolve": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/try-resolve/-/try-resolve-1.0.1.tgz", - "integrity": "sha512-yHeaPjCBzVaXwWl5IMUapTaTC2rn/eBYg2fsG2L+CvJd+ttFbk0ylDnpTO3wVhosmE1tQEvcebbBeKLCwScQSQ==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, - "license": "MIT" - }, "node_modules/tsc": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz", diff --git a/scripts/format/format/get_inputs_markdown.ts b/scripts/format/format/get_inputs_markdown.ts index 972f197f..9ff331f3 100644 --- a/scripts/format/format/get_inputs_markdown.ts +++ b/scripts/format/format/get_inputs_markdown.ts @@ -1,15 +1,15 @@ -import {readFileSync} from "fs"; +import { readFileSync } from "fs"; import * as yaml from "js-yaml"; export function script(): string { const ymlFile = yaml.load(readFileSync("action.yml", "utf8")) as { - inputs: { - [p: string]: { - description: string - default: string - required: "true" | "false" - } - } + inputs: { + [p: string]: { + description: string; + default: string; + required: "true" | "false"; + }; + }; }; const inputs = ymlFile.inputs; const rows = [ diff --git a/src/assign_a_user.ts b/src/assign_a_user.ts index 7bc7d4b9..66edabfd 100644 --- a/src/assign_a_user.ts +++ b/src/assign_a_user.ts @@ -1,17 +1,18 @@ import type { Context } from "@actions/github/lib/context"; import type { GitHub } from "@actions/github/lib/utils"; -import type {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods"; +import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; export async function script( - github: InstanceType, - context: Context, + github: InstanceType, + context: Context, ) { - const issuesAddAssigneesParams:RestEndpointMethodTypes["issues"]["addAssignees"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: Number(process.env.PR_NUMBER), - assignees: [context.actor], - }; + const issuesAddAssigneesParams: RestEndpointMethodTypes["issues"]["addAssignees"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: Number(process.env.PR_NUMBER), + assignees: [context.actor], + }; console.log("call issues.addAssignees:"); console.log(issuesAddAssigneesParams); await github.rest.issues.addAssignees(issuesAddAssigneesParams); diff --git a/src/close_pull_request.ts b/src/close_pull_request.ts index 032d1c0f..35f1e5cb 100644 --- a/src/close_pull_request.ts +++ b/src/close_pull_request.ts @@ -1,11 +1,11 @@ import type { Context } from "@actions/github/lib/context"; import type { GitHub } from "@actions/github/lib/utils"; -import type {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods"; -import {getPullRequests} from "./get_pull_requests"; +import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; +import { getPullRequests } from "./get_pull_requests"; export async function script( - github: InstanceType, - context: Context, + github: InstanceType, + context: Context, ) { const HEAD_REF = process.env.HEAD_REF; let headName = process.env.BRANCH_NAME_PREFIX; @@ -16,21 +16,23 @@ export async function script( for (const pull of await getPullRequests(github, context)) { // 修正PRをcloseする (修正PRのstateをclosedに更新する) - const pullsUpdateParams:RestEndpointMethodTypes["pulls"]["update"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - state: "closed", - }; + const pullsUpdateParams: RestEndpointMethodTypes["pulls"]["update"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + state: "closed", + }; console.log("call pulls.update:", pullsUpdateParams); await github.rest.pulls.update(pullsUpdateParams); // 修正PRのブランチを削除する - const gitDeleteRefParams:RestEndpointMethodTypes["git"]["deleteRef"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - ref: "heads/" + headName, - }; + const gitDeleteRefParams: RestEndpointMethodTypes["git"]["deleteRef"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + ref: "heads/" + headName, + }; console.log("call git.deleteRef:", gitDeleteRefParams); await github.rest.git.deleteRef(gitDeleteRefParams); } diff --git a/src/create_pull_request.ts b/src/create_pull_request.ts index c2ca72ed..6239edd3 100644 --- a/src/create_pull_request.ts +++ b/src/create_pull_request.ts @@ -1,7 +1,7 @@ import type { Context } from "@actions/github/lib/context"; import type { GitHub } from "@actions/github/lib/utils"; -import type {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods"; -import {generateTitleDescription} from "./generate_title_description"; +import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; +import { generateTitleDescription } from "./generate_title_description"; export async function script( github: InstanceType, @@ -16,14 +16,15 @@ export async function script( const headWithRepo = context.repo.owner + ":" + head; const { title, body } = generateTitleDescription(); - const pullsCreateParams:RestEndpointMethodTypes["pulls"]["create"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - head: headWithRepo, - base: HEAD_REF, - title, - body, - }; + const pullsCreateParams: RestEndpointMethodTypes["pulls"]["create"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + head: headWithRepo, + base: HEAD_REF, + title, + body, + }; console.log("call pulls.create:", pullsCreateParams); const createPullRes = await github.rest.pulls.create(pullsCreateParams); return createPullRes.data.number; diff --git a/src/generate_title_description.ts b/src/generate_title_description.ts index 1b0261f1..ffa9b4d1 100644 --- a/src/generate_title_description.ts +++ b/src/generate_title_description.ts @@ -1,12 +1,12 @@ -export function generateTitleDescription():{ - title:string - body:string +export function generateTitleDescription(): { + title: string; + body: string; } { const HEAD_REF = process.env.HEAD_REF || ""; const escapedHeadRef = HEAD_REF.replace(/#/g, ""); const PR_NUMBER = process.env.PR_NUMBER; - const PR_TITLE_PREFIX = process.env.PR_TITLE_PREFIX||""; - let head = process.env.BRANCH_NAME_PREFIX||""; + const PR_TITLE_PREFIX = process.env.PR_TITLE_PREFIX || ""; + let head = process.env.BRANCH_NAME_PREFIX || ""; if (HEAD_REF !== "") { head += "-" + HEAD_REF; @@ -14,7 +14,7 @@ export function generateTitleDescription():{ const escapedHead = head.replace(/#/g, ""); let title = PR_TITLE_PREFIX; - let body = process.env.PR_DESCRIPTION_PREFIX||""; + let body = process.env.PR_DESCRIPTION_PREFIX || ""; body += `本PR ( \`${escapedHead}\` ) をマージすると差分が次のPRに反映されます。\n`; body += "* "; diff --git a/src/get_number_of_pull_requests.ts b/src/get_number_of_pull_requests.ts index dda0bc7c..801083e7 100644 --- a/src/get_number_of_pull_requests.ts +++ b/src/get_number_of_pull_requests.ts @@ -1,16 +1,12 @@ import type { Context } from "@actions/github/lib/context"; import type { GitHub } from "@actions/github/lib/utils"; -import {getPullRequests} from "./get_pull_requests"; +import { getPullRequests } from "./get_pull_requests"; export async function script( - github: InstanceType, - context: Context, -):Promise { + github: InstanceType, + context: Context, +): Promise { const HEAD_REF = process.env.HEAD_REF; - const pulls = await getPullRequests( - github, - context, - HEAD_REF, - ); + const pulls = await getPullRequests(github, context, HEAD_REF); return pulls.length; } diff --git a/src/get_pull_requests.ts b/src/get_pull_requests.ts index e790390b..a475cbc0 100644 --- a/src/get_pull_requests.ts +++ b/src/get_pull_requests.ts @@ -1,13 +1,15 @@ -import type {GitHub} from "@actions/github/lib/utils"; -import type {Context} from "@actions/github/lib/context"; +import type { GitHub } from "@actions/github/lib/utils"; +import type { Context } from "@actions/github/lib/context"; import type { PaginatingEndpoints } from "@octokit/plugin-paginate-rest"; -import type {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods"; +import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; export async function getPullRequests( - github: InstanceType, - context: Context, - base?: string -):Promise{ + github: InstanceType, + context: Context, + base?: string, +): Promise< + PaginatingEndpoints["GET /repos/{owner}/{repo}/pulls"]["response"]["data"] +> { const HEAD_REF = process.env.HEAD_REF; let head = context.repo.owner + ":" + process.env.BRANCH_NAME_PREFIX; @@ -15,13 +17,14 @@ export async function getPullRequests( head += "-" + HEAD_REF; } - const pullsListParams:RestEndpointMethodTypes["pulls"]["list"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - head, - state: "open", - base, - }; + const pullsListParams: RestEndpointMethodTypes["pulls"]["list"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + head, + state: "open", + base, + }; console.log("call pulls.list:", pullsListParams); return await github.paginate(github.rest.pulls.list, pullsListParams); } diff --git a/src/update_pull_request.ts b/src/update_pull_request.ts index 0d805811..acd05b9a 100644 --- a/src/update_pull_request.ts +++ b/src/update_pull_request.ts @@ -1,12 +1,12 @@ import type { Context } from "@actions/github/lib/context"; import type { GitHub } from "@actions/github/lib/utils"; -import type {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods"; -import {generateTitleDescription} from "./generate_title_description"; -import {getPullRequests} from "./get_pull_requests"; +import type { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods"; +import { generateTitleDescription } from "./generate_title_description"; +import { getPullRequests } from "./get_pull_requests"; export async function script( - github: InstanceType, - context: Context, + github: InstanceType, + context: Context, ) { const { title, body } = generateTitleDescription(); @@ -16,13 +16,14 @@ export async function script( } // PRのタイトルやDescriptionを更新する - const pullsUpdateParams:RestEndpointMethodTypes["pulls"]["update"]["parameters"] = { - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pull.number, - title, - body, - }; + const pullsUpdateParams: RestEndpointMethodTypes["pulls"]["update"]["parameters"] = + { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pull.number, + title, + body, + }; console.log("call pulls.update:", pullsUpdateParams); await github.rest.pulls.update(pullsUpdateParams); }