apheleia/test/formatters/installers/prettier-ruby.bash
Ed Slocomb 54a192c345
Add support for formatters locally installed via yarn 2+ pnp mode (#200)
This adds support for formatters installed locally in project
directories via yarn 2's "zero install" [pnp
mode](https://yarnpkg.com/features/pnp).

It's quite similar to the support for formatters installed locally in a
project's `node_modules` via npm, and leverages the `npx` symbol, so
existing formatter definitions should work without modification.

This checks for a `.pnp.cjs` file (expected in the project root for yarn
pnp projects), then looks for a yarn executable, and checks the version
of yarn to make sure it supports pnp. If that works, we just push
`"yarn"` onto the front of `command`.

I've only tested this with a locally installed `prettier.js`. It's very
much a works-for-me draft, I'm putting in a PR to make sure this is a
workable approach before going any further with it.

---------

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
2023-11-05 12:08:58 -08:00

16 lines
661 B
Bash

# Need ruby for gem, need gcc and ruby headers for native gem deps
apt-get install -y ruby ruby-dev gcc
# Apparently rubygems does not know how to do dependency resolution.
# So we have to manually install an old version of this dependency to
# avoid the latest version getting installed and then failing to build
# because it does not support ruby 2.7 which is what we have.
gem install rbs -v 3.1.3
# These are required dependencies documented at
# https://www.npmjs.com/package/@prettier/plugin-ruby
gem install prettier_print syntax_tree syntax_tree-haml syntax_tree-rbs
# Install the plugin
cd /tmp
npm install --save-dev prettier @prettier/plugin-ruby