From 75b8aa4420f439d1fe809bd12790803b0ef0ffc0 Mon Sep 17 00:00:00 2001 From: Takanori Oishi Date: Mon, 17 Oct 2022 20:32:26 +0900 Subject: [PATCH 1/2] refactor: remove getMultilineInput --- dist/index.js | 37 ++-------------------- src/getConfigs.ts | 5 ++- src/getMultilineInput.ts | 26 --------------- test/getMultilineInput.spec.ts | 58 ---------------------------------- 4 files changed, 4 insertions(+), 122 deletions(-) delete mode 100644 src/getMultilineInput.ts delete mode 100644 test/getMultilineInput.spec.ts diff --git a/dist/index.js b/dist/index.js index 68a949e..3787daa 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10942,7 +10942,6 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getConfigs = void 0; const core = __importStar(__nccwpck_require__(2186)); -const getMultilineInput_1 = __nccwpck_require__(7243); /** * Parses and validations the action configuration * @returns Parsed the action configuration @@ -10955,12 +10954,12 @@ const getConfigs = () => { apiKey: getConfig("api_key", { required: true }), githubEventPath: getConfig("github_event_path", { required: true }), fixKeywords: core.getInput("fix_keywords") - ? (0, getMultilineInput_1.getMultilineInput)("fix_keywords", { + ? core.getMultilineInput("fix_keywords", { trimWhitespace: true, }) : ["#fix", "#fixes", "#fixed"], closeKeywords: core.getInput("close_keywords") - ? (0, getMultilineInput_1.getMultilineInput)("close_keywords", { + ? core.getMultilineInput("close_keywords", { trimWhitespace: true, }) : ["#close", "#closes", "#closed"], @@ -11003,38 +11002,6 @@ const getConfig = (name, options = {}) => { }; -/***/ }), - -/***/ 7243: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getMultilineInput = void 0; -const core_1 = __nccwpck_require__(2186); -/** - * Gets the values of an multiline input. Each value is also trimmed. - * copy from https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts - * MIT License - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string[] - * - */ -function getMultilineInput(name, options) { - const inputs = (0, core_1.getInput)(name, options) - .split("\n") - .filter((x) => x !== ""); - if (options && options.trimWhitespace === false) { - return inputs; - } - return inputs.map((input) => input.trim()); -} -exports.getMultilineInput = getMultilineInput; - - /***/ }), /***/ 399: diff --git a/src/getConfigs.ts b/src/getConfigs.ts index db28388..5e115b6 100644 --- a/src/getConfigs.ts +++ b/src/getConfigs.ts @@ -1,5 +1,4 @@ import * as core from "@actions/core" -import { getMultilineInput } from "./getMultilineInput" export type Configs = { projectKey: string @@ -27,12 +26,12 @@ export const getConfigs = (): Configs => { apiKey: getConfig("api_key", { required: true }), githubEventPath: getConfig("github_event_path", { required: true }), fixKeywords: core.getInput("fix_keywords") - ? getMultilineInput("fix_keywords", { + ? core.getMultilineInput("fix_keywords", { trimWhitespace: true, }) : ["#fix", "#fixes", "#fixed"], closeKeywords: core.getInput("close_keywords") - ? getMultilineInput("close_keywords", { + ? core.getMultilineInput("close_keywords", { trimWhitespace: true, }) : ["#close", "#closes", "#closed"], diff --git a/src/getMultilineInput.ts b/src/getMultilineInput.ts deleted file mode 100644 index d93ec72..0000000 --- a/src/getMultilineInput.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { getInput, InputOptions } from "@actions/core" - -/** - * Gets the values of an multiline input. Each value is also trimmed. - * copy from https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts - * MIT License - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string[] - * - */ -export function getMultilineInput( - name: string, - options?: InputOptions -): string[] { - const inputs: string[] = getInput(name, options) - .split("\n") - .filter((x) => x !== "") - - if (options && options.trimWhitespace === false) { - return inputs - } - - return inputs.map((input) => input.trim()) -} diff --git a/test/getMultilineInput.spec.ts b/test/getMultilineInput.spec.ts deleted file mode 100644 index 713cbf5..0000000 --- a/test/getMultilineInput.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -import * as fs from "fs" -import * as path from "path" -import { getMultilineInput } from "../src/getMultilineInput" - -/** - * copy from https://github.com/actions/toolkit/blob/main/packages/core/src/core.ts - * MIT License - */ - -const testEnvVars = { - // eslint-disable-next-line @typescript-eslint/naming-convention - INPUT_MY_INPUT_LIST: "val1\nval2\nval3", - // eslint-disable-next-line @typescript-eslint/naming-convention - INPUT_LIST_WITH_TRAILING_WHITESPACE: " val1 \n val2 \n ", -} - -describe("@actions/core", () => { - beforeAll(() => { - const filePath = path.join(__dirname, `test`) - if (!fs.existsSync(filePath)) { - fs.mkdirSync(filePath) - } - }) - - beforeEach(() => { - for (const key in testEnvVars) { - process.env[key] = testEnvVars[key as keyof typeof testEnvVars] - } - process.stdout.write = jest.fn() - }) - - it("getMultilineInput works", () => { - expect(getMultilineInput("my input list")).toEqual(["val1", "val2", "val3"]) - }) - - it("getMultilineInput trims whitespace by default", () => { - expect(getMultilineInput("list with trailing whitespace")).toEqual([ - "val1", - "val2", - ]) - }) - - it("getMultilineInput trims whitespace when option is explicitly true", () => { - expect( - getMultilineInput("list with trailing whitespace", { - trimWhitespace: true, - }) - ).toEqual(["val1", "val2"]) - }) - - it("getMultilineInput does not trim whitespace when option is false", () => { - expect( - getMultilineInput("list with trailing whitespace", { - trimWhitespace: false, - }) - ).toEqual([" val1 ", " val2 ", " "]) - }) -}) From 4771f70350e7459952943505094bd47c4ef943ca Mon Sep 17 00:00:00 2001 From: Takanori Oishi Date: Mon, 17 Oct 2022 20:43:14 +0900 Subject: [PATCH 2/2] remove lgtm --- README.md | 1 - lgtm.yml | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 lgtm.yml diff --git a/README.md b/README.md index b32ef44..93626ea 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ [![njsscan sarif](https://github.com/bicstone/backlog-notify/actions/workflows/njsscan-analysis.yml/badge.svg)](https://github.com/bicstone/backlog-notify/actions/workflows/njsscan-analysis.yml) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fbicstone%2Fbacklog-notify.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fbicstone%2Fbacklog-notify?ref=badge_shield) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=bicstone_backlog-notify&metric=alert_status)](https://sonarcloud.io/dashboard?id=bicstone_backlog-notify) -[![Total alerts](https://img.shields.io/lgtm/alerts/g/bicstone/backlog-notify.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/bicstone/backlog-notify/alerts/) [![DeepSource](https://deepsource.io/gh/bicstone/backlog-notify.svg/?label=active+issues&token=iPw2LS4cY5EQQH_JiN72YOr2)](https://deepsource.io/gh/bicstone/backlog-notify/?ref=repository-badge) [![codecov](https://codecov.io/gh/bicstone/backlog-notify/branch/master/graph/badge.svg?token=QRLLFDZD15)](https://codecov.io/gh/bicstone/backlog-notify) diff --git a/lgtm.yml b/lgtm.yml deleted file mode 100644 index 83c3f1e..0000000 --- a/lgtm.yml +++ /dev/null @@ -1,3 +0,0 @@ -path_classifiers: - generated: - - "dist/*"