From 110022b156ac6f3c9c18c7b634eb85d07a18118b Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Tue, 26 May 2026 17:16:48 +0700 Subject: [PATCH] replace `gha-utils` with `ghakit` Signed-off-by: Alfi Maulana --- dist/main.bundle.mjs | 16 ++++++++++------ package.json | 2 +- pnpm-lock.yaml | 13 +++++++------ src/main.test.ts | 6 +++--- src/main.ts | 3 ++- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/dist/main.bundle.mjs b/dist/main.bundle.mjs index 3f5ac73..e8d9f1b 100644 --- a/dist/main.bundle.mjs +++ b/dist/main.bundle.mjs @@ -1,27 +1,31 @@ import 'node:fs'; import { mkdir } from 'node:fs/promises'; -import os from 'node:os'; +import { EOL } from 'node:os'; import 'node:path'; /** * Retrieves the value of a GitHub Actions input. * + * Input names are matched case-insensitively — `getInput("token")` and + * `getInput("TOKEN")` both read the same `INPUT_TOKEN` env var. + * * @param name - The name of the GitHub Actions input. - * @returns The value of the GitHub Actions input, or an empty string if not found. + * @returns The value of the GitHub Actions input, or an empty string if not set. */ function getInput(name) { - const value = process.env[`INPUT_${name.toUpperCase()}`] ?? ""; - return value.trim(); + return process.env[`INPUT_${name.toUpperCase()}`] ?? ""; } /** * Logs an error message in GitHub Actions. * * @param err - The error, which can be of any type. + * @param options - Optional annotation parameters to pin the message to a file location. */ -function logError(err) { +function logError(err, options) { const message = err instanceof Error ? err.message : String(err); - process.stdout.write(`::error::${message}${os.EOL}`); + const params = ""; + process.stdout.write(`::error${params}::${message}${EOL}`); } try { diff --git a/package.json b/package.json index b17afa6..2fbc90e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "test": "vitest run" }, "dependencies": { - "gha-utils": "^0.4.1" + "ghakit": "^1.0.0" }, "devDependencies": { "@eslint/js": "^10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e5dc62e..ed77666 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: dependencies: - gha-utils: - specifier: ^0.4.1 - version: 0.4.1 + ghakit: + specifier: ^1.0.0 + version: 1.0.0 devDependencies: '@eslint/js': specifier: ^10.0.1 @@ -759,8 +759,9 @@ packages: function-bind@1.1.2: resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} - gha-utils@0.4.1: - resolution: {integrity: sha512-KHWQj6SQWFfsTt4epwcyx/LfLUU/3bFFkGhfkzpFKV/77w46Nm5vt8O+3KVk10sfON+3Ca578RZk0hQnLMUtCw==} + ghakit@1.0.0: + resolution: {integrity: sha512-PrKZCYZDjnMKCudOlqTujzg+H/yLc9zjqenVxPqNTE3QDkIK5rpPeK2tjkzYkYYaj7Q9f7IuTtDggmpfmYCYmw==} + engines: {node: '>=24'} glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} @@ -1733,7 +1734,7 @@ snapshots: function-bind@1.1.2: {} - gha-utils@0.4.1: {} + ghakit@1.0.0: {} glob-parent@6.0.2: dependencies: diff --git a/src/main.test.ts b/src/main.test.ts index b8bc120..accf369 100644 --- a/src/main.test.ts +++ b/src/main.test.ts @@ -2,7 +2,7 @@ import { access, mkdir, rm, writeFile } from "node:fs/promises"; import path from "node:path"; import { afterAll, beforeEach, expect, test, vi } from "vitest"; -vi.mock("gha-utils"); +vi.mock("ghakit/io"); const tmpDir = path.resolve(import.meta.dirname, ".main.test.tmp"); @@ -16,7 +16,7 @@ beforeEach(async () => { afterAll(() => rm(tmpDir, { recursive: true, force: true })); test("create a directory recursively", async () => { - const { getInput } = await import("gha-utils"); + const { getInput } = await import("ghakit/io"); vi.mocked(getInput).mockReturnValue(path.join(tmpDir, "new/directory")); await import("./main.js"); @@ -28,7 +28,7 @@ test("create a directory recursively", async () => { test("fail to create a directory when a file already exists at the path", async () => { await writeFile(path.join(tmpDir, "file"), ""); - const { getInput } = await import("gha-utils"); + const { getInput } = await import("ghakit/io"); vi.mocked(getInput).mockReturnValue(path.join(tmpDir, "file/child")); await import("./main.js"); diff --git a/src/main.ts b/src/main.ts index 84ffed8..c7224b1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,5 @@ -import { getInput, logError } from "gha-utils"; +import { getInput } from "ghakit/io"; +import { logError } from "ghakit/log"; import { mkdir } from "node:fs/promises"; try {