# Registry Health

How to check that a registry works with the CLI.

Source: https://webjs.dev/ui/docs/registry/health

Registries can change or go offline after they are added to the directory. Checking them keeps users from running an install command that fails.

Check a registry with the CLI.

A registry owner checks a registry in the [directory](https://webjs.dev/ui/docs/directory) with the CLI, which validates everything it fetches. The checks below cover the index, the items, an install and drift.

## What to check

| Check | Command | What it proves |
| --- | --- | --- |
| Registry index | `list --registry <url>` | `<url>/index.json` is online and every entry parses as a registry item. |
| Registry items | `view <name> --registry <url>` | `<url>/<name>.json` downloads and parses as a registry item, and prints the source of every file. |
| CLI install | `add <name> --registry <url>` | The item, its registry dependencies and its npm dependencies install into a project. |
| Drift | `diff --registry <url>` | The files a project installed still match what the registry serves. |

Each command fails with the HTTP status when a file is missing, and with the schema error when a file does not conform, so a non-zero exit is the signal.

```bash
npx @webjsdev/ui list --registry https://acme.com/r
```

```bash
npx @webjsdev/ui view brand-button --registry https://acme.com/r
```

## Checking in CI

To catch a broken registry before users do, run the same commands on a schedule. `list --json` prints one JSON array of `{ name, type, categories, description }`, which a script can loop over to view every item.

```bash title="check-registry.sh"
npx @webjsdev/ui list --registry https://acme.com/r --json > items.json

for name in $(node -e "for (const i of require('./items.json')) console.log(i.name)"); do
  npx @webjsdev/ui view "$name" --registry https://acme.com/r > /dev/null || exit 1
done
```

To test the install itself, run `add` in a throwaway app created with `webjs create`, then run its tests.

## Directory ranking

The directory lists registries in the order of `website/modules/ui/directory/registries.ts`, with the WebJs UI registry first. Its search filters by name and description, and entries change only when the file does.

## Directory data in the API

[/ui/r/registries.json](https://webjs.dev/ui/r/registries.json) serves each entry's `name`, `homepage`, `url`, `description` and `logo`.

## What happens next

If a listed registry stops working, open an issue or a pull request on [webjsdev/webjs](https://github.com/webjsdev/webjs) to fix or remove its entry. See [Registry Directory](https://webjs.dev/ui/docs/registry/registry-index) for how entries are added.
