NPM.Registry (NPM v0.6.0)

Copy Markdown View Source

HTTP client for the npm registry.

Fetches abbreviated packuments (version list + deps + dist info) using the npm registry API.

Summary

Functions

URL-encode a package name (handles scoped packages).

Fetch the abbreviated packument for a package.

Get the configured registry URL.

Types

packument()

@type packument() :: %{
  name: String.t(),
  versions: %{required(String.t()) => version_info()}
}

version_info()

@type version_info() :: %{
  dependencies: %{required(String.t()) => String.t()},
  optional_dependencies: %{required(String.t()) => String.t()},
  peer_dependencies: %{required(String.t()) => String.t()},
  peer_dependencies_meta: %{required(String.t()) => map()},
  bin: %{optional(String.t()) => String.t()},
  engines: %{required(String.t()) => String.t()},
  os: [String.t()],
  cpu: [String.t()],
  has_install_script: boolean(),
  deprecated: String.t() | nil,
  dist: %{
    tarball: String.t(),
    integrity: String.t(),
    file_count: integer() | nil,
    unpacked_size: integer() | nil
  }
}

Functions

encode_package(package)

@spec encode_package(String.t()) :: String.t()

URL-encode a package name (handles scoped packages).

get_packument(package)

@spec get_packument(String.t()) :: {:ok, packument()} | {:error, term()}

Fetch the abbreviated packument for a package.

registry_url()

@spec registry_url() :: String.t()

Get the configured registry URL.