Capstone.Plugin.Remote (Capstone v0.33.3)

Copy Markdown View Source

Downloads plugin archives from this repository's GitHub releases into a local cache directory, so priv/plugins/ is never committed to source control or shipped inside the hex package — see Capstone.Plugin.Registry.default_dir/0.

Uses :httpc/:ssl (OTP stdlib) and OTP 27's built-in :json module rather than a hex HTTP/JSON client: this module is reached from mix capstone.new/mix capstone.update, both of which run inside a consuming project, so Capstone.BoundaryGuard's ban on a runtime dependency applies here the same as everywhere else under lib/.

Archives are content-addressed (the sha in <type>-<elixir>-<capstone>- <sha>.tar.gz), so a file already present in the cache under its exact published name is never re-downloaded or re-verified — a name match already is a content match, the same assumption Capstone.Plugin.Registry.resolve!/4 makes about priv/plugins/ today.

A GITHUB_TOKEN/GH_TOKEN environment variable is used when present (better rate limits, and this keeps working if the repository is ever made private again), but is not required: the repository is public, and a release asset's browser_download_url needs no authentication to fetch.

Summary

Types

One release asset: its published filename and the URL to fetch its bytes from.

The injected HTTP seam every function here goes through — real by default, fake in tests.

Functions

Every asset attached to any release of this repository, across every page. Returned oldest-page-first; caller order does not depend on it.

Ensures every published type archive exists in dir, downloading whatever is missing. Files already present are left untouched — see the moduledoc for why that is safe rather than stale.

Types

asset()

@type asset() :: %{name: String.t(), url: String.t()}

One release asset: its published filename and the URL to fetch its bytes from.

fetch()

@type fetch() :: (String.t() -> {:ok, binary()} | {:error, term()})

The injected HTTP seam every function here goes through — real by default, fake in tests.

Functions

list_assets!(fetch \\ &http_get!/1)

@spec list_assets!(fetch()) :: [asset()]

Every asset attached to any release of this repository, across every page. Returned oldest-page-first; caller order does not depend on it.

sync!(type, dir, fetch \\ &http_get!/1)

@spec sync!(atom(), Path.t(), fetch()) :: :ok

Ensures every published type archive exists in dir, downloading whatever is missing. Files already present are left untouched — see the moduledoc for why that is safe rather than stale.