Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace prettier with biome #20

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
lint:
Expand All @@ -16,20 +14,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"
Expand All @@ -39,7 +28,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
Expand Down
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 25 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -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/**/*"]
}
}
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
101 changes: 91 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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");
Expand All @@ -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
Expand All @@ -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}`);

Expand Down
Loading