Expresso.Check.Tools (expresso v0.1.0)

Copy Markdown View Source

Installs the tools of the browser levels of --check into a directory of the user

mix expresso --install-check-tools and expresso --install-check-tools call install/2. The function installs the npm packages playwright and axe-core into directory/1, and the Chromium and the headless shell of Playwright into the cache of Playwright. The check then finds each tool there, so a project with no node_modules can run each level. The installation needs Node and npm on the PATH.

--check=browser in a Mix project also needs the Hex package playwright_ex in the deps of the project. The binary holds it.

Summary

Functions

Return the directory of the tools

Install the tools, write the progress, and return :ok or an error

Return the npm packages that install/2 installs, with their versions

Functions

directory(env \\ System.get_env())

@spec directory(%{required(String.t()) => String.t()}) :: Path.t()

Return the directory of the tools

The variable EXPRESSO_TOOLS in env gives the directory. Without it, the directory is expresso in the cache directory of the user, such as ~/.cache/expresso on Linux and ~/Library/Caches/expresso on macOS.

install(env \\ System.get_env(), run \\ &run/2)

@spec install(%{required(String.t()) => String.t()}, (String.t(), [String.t()] ->
                                                  non_neg_integer())) ::
  :ok | {:error, String.t()}

Install the tools, write the progress, and return :ok or an error

The function runs these commands, in sequence:

  1. npm install --prefix <directory> playwright axe-core, with the versions of packages/0.
  2. node <directory>/node_modules/playwright/cli.js install chromium, which installs the Chromium and the headless shell of Playwright.

run runs one command with its arguments, and returns its exit status. The default writes the output of the command to the standard output.

packages()

@spec packages() :: [String.t()]

Return the npm packages that install/2 installs, with their versions

Each version is the version of the package in package.json, so the list has the form ["playwright@<version>", "axe-core@<version>"].