diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 249f87c..17577fd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,11 +2,7 @@ name: "CI" on: push: - branches: - - "main" pull_request: - branches: - - "main" jobs: lint: @@ -16,20 +12,11 @@ jobs: - name: "Checkout the repository" uses: actions/checkout@v4 - - name: "Setup pnpm" - uses: pnpm/action-setup@v2 - - - name: "Setup node" - uses: actions/setup-node@v4 - with: - node-version-file: package.json - cache: "pnpm" - - - name: "Install dependencies" - run: pnpm install + - name: "Setup Biome" + uses: biomejs/setup-biome@v2 - - name: "Check format" - run: pnpm run format:check + - name: "Run Biome" + run: biome ci build: name: "Build" @@ -39,7 +26,7 @@ jobs: uses: actions/checkout@v4 - name: "Setup pnpm" - uses: pnpm/action-setup@v2 + uses: pnpm/action-setup@v4 - name: "Setup node" uses: actions/setup-node@v4 diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index e1b68eb..0000000 --- a/.prettierignore +++ /dev/null @@ -1,3 +0,0 @@ -dist/ -coverage/ -pnpm-lock.yaml diff --git a/.vscode/settings.json b/.vscode/settings.json index fd211a5..4fc8cc6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,7 @@ "editor.linkedEditing": true, "editor.renderWhitespace": "trailing", "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "files.associations": { "**/.github/workflows/*.yaml": "github-actions-workflow" diff --git a/README.md b/README.md index 410d3e7..9dc10ec 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![License](https://img.shields.io/github/license/jcwillox/install-tool-action?style=flat-square)](https://github.com/jcwillox/install-tool-action/blob/main/LICENSE) [![Version](https://img.shields.io/github/v/release/jcwillox/install-tool-action?style=flat-square)](https://github.com/jcwillox/install-tool-action/releases) [![Size](https://img.shields.io/github/size/jcwillox/install-tool-action/dist%2Findex.js?branch=main&style=flat-square)](dist/index.js) -[![Code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) +[![Code style](https://img.shields.io/badge/code_style-biome-60a5fa?style=flat-square)](https://biomejs.dev) Install any tool or binary with full cache, dynamic latest version, easy to configure and has presets. diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..dfa9c8a --- /dev/null +++ b/biome.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "formatter": { + "enabled": true, + "ignore": ["**/pnpm-lock.yaml", "**/dist/**/*"], + "useEditorconfig": true + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "correctness": { + "noUnusedImports": "warn", + "noUnusedVariables": "warn" + }, + "style": { + "noParameterAssign": "off" + } + }, + "ignore": ["**/dist/**/*"] + } +} diff --git a/package.json b/package.json index 2e74477..6dfd4d0 100644 --- a/package.json +++ b/package.json @@ -5,28 +5,23 @@ "license": "MIT", "private": true, "repository": "jcwillox/install-tool-action", - "keywords": [ - "actions", - "install", - "setup", - "tool" - ], + "keywords": ["actions", "install", "setup", "tool"], "scripts": { "dev": "pnpm build --watch", "build": "tsup src/index.ts --treeshake --minify --clean", "typecheck": "tsc", - "lint": "eslint . --cache --max-warnings=0 --ext js,cjs,mjs,jsx,ts,tsx", - "lint:fix": "pnpm run lint --fix", - "format": "prettier --cache --write .", - "format:check": "prettier --cache --check ." + "lint": "biome lint", + "lint:fix": "biome lint -w", + "format": "biome format --write", + "format:check": "biome format" }, "devDependencies": { "@actions/core": "1.11.1", "@actions/exec": "1.1.1", "@actions/http-client": "2.2.3", "@actions/tool-cache": "2.0.1", + "@biomejs/biome": "1.9.4", "@types/node": "22.8.2", - "prettier": "3.3.3", "radash": "12.1.0", "tsup": "8.3.5", "typescript": "5.6.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a1ae36b..4cf3387 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,12 +20,12 @@ importers: '@actions/tool-cache': specifier: 2.0.1 version: 2.0.1 + '@biomejs/biome': + specifier: 1.9.4 + version: 1.9.4 '@types/node': specifier: 22.8.2 version: 22.8.2 - prettier: - specifier: 3.3.3 - version: 3.3.3 radash: specifier: 12.1.0 version: 12.1.0 @@ -56,6 +56,59 @@ packages: '@actions/tool-cache@2.0.1': resolution: {integrity: sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==} + '@biomejs/biome@1.9.4': + resolution: {integrity: sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==} + engines: {node: '>=14.21.3'} + hasBin: true + + '@biomejs/cli-darwin-arm64@1.9.4': + resolution: {integrity: sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [darwin] + + '@biomejs/cli-darwin-x64@1.9.4': + resolution: {integrity: sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [darwin] + + '@biomejs/cli-linux-arm64-musl@1.9.4': + resolution: {integrity: sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-arm64@1.9.4': + resolution: {integrity: sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + + '@biomejs/cli-linux-x64-musl@1.9.4': + resolution: {integrity: sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-linux-x64@1.9.4': + resolution: {integrity: sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + + '@biomejs/cli-win32-arm64@1.9.4': + resolution: {integrity: sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [win32] + + '@biomejs/cli-win32-x64@1.9.4': + resolution: {integrity: sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [win32] + '@esbuild/aix-ppc64@0.21.5': resolution: {integrity: sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==} engines: {node: '>=12'} @@ -734,11 +787,6 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} - prettier@3.3.3: - resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} - engines: {node: '>=14'} - hasBin: true - punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -1005,6 +1053,41 @@ snapshots: semver: 6.3.1 uuid: 3.4.0 + '@biomejs/biome@1.9.4': + optionalDependencies: + '@biomejs/cli-darwin-arm64': 1.9.4 + '@biomejs/cli-darwin-x64': 1.9.4 + '@biomejs/cli-linux-arm64': 1.9.4 + '@biomejs/cli-linux-arm64-musl': 1.9.4 + '@biomejs/cli-linux-x64': 1.9.4 + '@biomejs/cli-linux-x64-musl': 1.9.4 + '@biomejs/cli-win32-arm64': 1.9.4 + '@biomejs/cli-win32-x64': 1.9.4 + + '@biomejs/cli-darwin-arm64@1.9.4': + optional: true + + '@biomejs/cli-darwin-x64@1.9.4': + optional: true + + '@biomejs/cli-linux-arm64-musl@1.9.4': + optional: true + + '@biomejs/cli-linux-arm64@1.9.4': + optional: true + + '@biomejs/cli-linux-x64-musl@1.9.4': + optional: true + + '@biomejs/cli-linux-x64@1.9.4': + optional: true + + '@biomejs/cli-win32-arm64@1.9.4': + optional: true + + '@biomejs/cli-win32-x64@1.9.4': + optional: true + '@esbuild/aix-ppc64@0.21.5': optional: true @@ -1503,8 +1586,6 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 - prettier@3.3.3: {} - punycode@2.3.1: {} radash@12.1.0: {} diff --git a/src/index.ts b/src/index.ts index cd82d83..a285f01 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,8 +4,8 @@ import path from "node:path"; import * as core from "@actions/core"; import { shake, template } from "radash"; import { downloadTool, getVersion } from "./install"; -import { Config } from "./types"; import presets from "./presets"; +import type { Config } from "./types"; export async function main() { try { @@ -31,7 +31,7 @@ export async function main() { cache: core.getBooleanInput("cache"), }; - core.debug("loaded config: " + JSON.stringify(config)); + core.debug(`loaded config: ${JSON.stringify(config)}`); // if preset is set, load preset config if (config.preset) { @@ -50,10 +50,9 @@ export async function main() { if (!config.versionUrl && !config.versionPath && config.repo) config.versionPath = "tag_name"; if (!config.versionUrl && config.repo) - config.versionUrl = - "https://api.github.com/repos/" + config.repo + "/releases/latest"; + config.versionUrl = `https://api.github.com/repos/${config.repo}/releases/latest`; - core.debug("resolved config: " + JSON.stringify(config)); + core.debug(`resolved config: ${JSON.stringify(config)}`); if (!config.downloadUrl) { throw new Error("Download URL missing"); @@ -64,7 +63,7 @@ export async function main() { const version = await getVersion(config); if (!version) throw new Error("Version not found"); config.version = version; - core.debug("resolved version: " + config.version); + core.debug(`resolved version: ${config.version}`); } // template download url @@ -73,22 +72,21 @@ export async function main() { ...templateArgs, }); if (config.downloadUrl.startsWith("/") && config.repo) - config.downloadUrl = - "https://github.com/" + config.repo + config.downloadUrl; + config.downloadUrl = `https://github.com/${config.repo}${config.downloadUrl}`; - core.debug("templated download url: " + config.downloadUrl); + core.debug(`templated download url: ${config.downloadUrl}`); // download or pull from cache const toolPath = await downloadTool(config); - if (config.binPath != "") { + if (config.binPath !== "") { config.binPath = template(config.binPath, { ...config, ...templateArgs, }); } - core.debug("cached path: " + toolPath); + core.debug(`cached path: ${toolPath}`); core.addPath(path.join(toolPath, config.binPath)); core.info(`Successfully installed version ${config.version}`); diff --git a/src/install.ts b/src/install.ts index ee8ee6a..c1f3d87 100644 --- a/src/install.ts +++ b/src/install.ts @@ -1,9 +1,9 @@ -import { Config } from "./types"; -import { get } from "radash"; -import * as core from "@actions/core"; -import * as tc from "@actions/tool-cache"; import path from "node:path"; +import * as core from "@actions/core"; import { exec } from "@actions/exec"; +import * as tc from "@actions/tool-cache"; +import { get } from "radash"; +import type { Config } from "./types"; export async function getVersion(config: Config) { if (!config.versionUrl) throw new Error("Version URL missing"); @@ -47,20 +47,20 @@ export async function downloadTool(config: Config) { } // check cache - if (config.cache) { - const toolPath = tc.find(toolName!, config.version); + if (config.cache && toolName) { + const toolPath = tc.find(toolName, config.version); if (toolPath) { - core.debug("cache hit: " + toolName + "@" + config.version); + core.debug(`cache hit: ${toolName}@${config.version}`); return toolPath; } - core.debug("cache miss: " + toolName + "@" + config.version); - const versions = tc.findAllVersions(toolName!).join(", "); - if (versions) core.debug("available versions: " + versions); + core.debug(`cache miss: ${toolName}@${config.version}`); + const versions = tc.findAllVersions(toolName).join(", "); + if (versions) core.debug(`available versions: ${versions}`); } // download file - let downloadPath = await tc.downloadTool(config.downloadUrl); - core.debug("downloaded path: " + downloadPath); + const downloadPath = await tc.downloadTool(config.downloadUrl); + core.debug(`downloaded path: ${downloadPath}`); // handle extracting downloaded file let extractedPath: string | undefined; @@ -73,20 +73,20 @@ export async function downloadTool(config: Config) { } else if (config.downloadUrl.endsWith(".pkg")) { extractedPath = await tc.extractXar(downloadPath); } - core.debug("extracted path: " + extractedPath); + core.debug(`extracted path: ${extractedPath}`); // ensure binaries are executable if (!extractedPath && process.platform !== "win32") await exec("chmod", ["+x", downloadPath]); // cache downloaded or extracted path - if (config.cache) + if (config.cache && toolName) return extractedPath - ? await tc.cacheDir(extractedPath, toolName!, config.version) + ? await tc.cacheDir(extractedPath, toolName, config.version) : await tc.cacheFile( downloadPath, config.downloadName || path.basename(config.downloadUrl), - toolName!, + toolName, config.version, ); return extractedPath || downloadPath; diff --git a/src/presets/index.ts b/src/presets/index.ts index 37816a2..ed43907 100644 --- a/src/presets/index.ts +++ b/src/presets/index.ts @@ -1,4 +1,4 @@ -import { Config } from "../types"; +import type { Config } from "../types"; const presets: Record> = { "infisical-cli": {