diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 63906bc..77f76a0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,11 +21,12 @@ jobs: run: | git config --global user.email "jdoe@example.com" git config --global user.name "J. Doe" - - name: Run install-dev-tools.sh + - name: Install mise run: | set -e - mkdir $HOME/bin - ./dev/bin/install-dev-tools.sh + set -x + curl https://mise.run | sh + mise install - name: Run precious run: | - PATH=$PATH:$HOME/bin precious lint -a + mise exec -- precious lint -a diff --git a/README.md b/README.md index a8c3d92..97e30dc 100644 --- a/README.md +++ b/README.md @@ -186,3 +186,29 @@ That's debatable. The big advantage of using `ubi` is that you can use the exact macOS, and Windows. The big disadvantage is that you don't get a full package that contains metadata (like a license file) or extras like shell completion files, nor can you easily uninstall it using a package manager. + +## Linting and Tidying this Code + +The code in this repo is linted and tidied with +[`precious`](https://github.com/houseabsolute/precious). This repo contains a `mise.toml` file. +[Mise](https://mise.jdx.dev/) is a tool for managing dev tools with per-repo configuration. You can +install `mise` and use it to run `precious` as follows: + +``` +# Installs mise +curl https://mise.run | sh +# Installs precious and other dev tools +mise install +``` + +Once this is done, you can run `precious` via `mise`: + +``` +# Lints all code +mise exec -- precious lint -a +# Tidies all code +mise exec -- precious tidy -a +``` + +If you want to use `mise` for other projects, see [its documentation](https://mise.jdx.dev/) for +more details on how you can configure your shell to always activate `mise`. diff --git a/dev/bin/install-dev-tools.sh b/dev/bin/install-dev-tools.sh deleted file mode 100755 index c88b8f8..0000000 --- a/dev/bin/install-dev-tools.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -set -eo pipefail - -function run() { - echo "$1" - eval "$1" -} - -function install_tools() { - curl --silent --location \ - https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh | - sh - run "rustup component add clippy" - run "ubi --project houseabsolute/precious --in ~/bin" - run "ubi --project houseabsolute/omegasort --in ~/bin" - run "ubi --project koalaman/shellcheck --in ~/bin" - run "ubi --project mvdan/sh --in ~/bin --exe shfmt" - run "ubi --project crate-ci/typos --in ~/bin" - run "ubi --project tamasfe/taplo --tag 0.8.1 --in ~/bin" - run "npm install prettier@2.7.1" -} - -if [ "$1" == "-v" ]; then - set -x -fi - -mkdir -p "$HOME/bin" - -set +e -if echo ":$PATH:" | grep --extended-regexp ":$HOME/bin:" >&/dev/null; then - path_has_home_bin=1 -fi -set -e - -if [ -z "$path_has_home_bin" ]; then - PATH=$HOME/bin:$PATH -fi - -install_tools - -echo "Tools were installed into $HOME/bin." -if [ -z "$path_has_home_bin" ]; then - echo "You should add $HOME/bin to your PATH." -fi - -exit 0 diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..db795b6 --- /dev/null +++ b/mise.toml @@ -0,0 +1,9 @@ +[tools] +node = "22.11.0" +"npm:prettier" = "3.4.1" +shellcheck = "v0.10.0" +shfmt = "v3.10.0" +taplo = "0.9.3" +typos = "1.28.1" +"ubi:houseabsolute/omegasort" = "v0.1.3" +"ubi:houseabsolute/precious" = "v0.7.3" diff --git a/precious.toml b/precious.toml index 18022dd..ccdf029 100644 --- a/precious.toml +++ b/precious.toml @@ -69,14 +69,7 @@ labels = ["default", "fast-tidy"] [commands.prettier] type = "both" include = ["**/*.md", "**/*.yml"] -cmd = [ - "./node_modules/.bin/prettier", - "--no-config", - "--prose-wrap", - "always", - "--print-width", - "100", -] +cmd = ["prettier", "--no-config", "--prose-wrap", "always", "--print-width", "100"] lint_flags = "--check" tidy_flags = "--write" ok_exit_codes = 0