Hex

v2.0.6

Hex.Solver

Anchor for this section Summary

Types

constraint()

dependency()

label()

locked()

optional()

package()

repo()

result()

Functions

parse_constraint(string)

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the Hex.Solver.Registry or passed to Hex.Solver.run/4.

parse_constraint!(string)

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the Hex.Solver.Registry or passed to Hex.Solver.run/4.

run(registry, dependencies, locked, overrides, opts \\ [])

Runs the version solver.

Anchor for this section Types

Link to this opaque

constraint()

View Source (opaque)

@opaque constraint()

Link to this type

dependency()

View Source

@type dependency() :: %{
  repo: repo(),
  name: package(),
  constraint: constraint(),
  optional: optional(),
  label: label()
}

Link to this type

label()

View Source

@type label() :: String.t()

Link to this type

locked()

View Source

@type locked() :: %{
  repo: repo(),
  name: package(),
  version: Version.t(),
  label: label()
}

Link to this type

optional()

View Source

@type optional() :: boolean()

Link to this type

package()

View Source

@type package() :: String.t()

Link to this type

repo()

View Source

@type repo() :: String.t() | nil

Link to this type

result()

View Source

@type result() :: %{required(package()) => {Version.t(), repo()}}

Anchor for this section Functions

Link to this function

parse_constraint(string)

View Source

@spec parse_constraint(String.t() | Version.t() | Version.Requirement.t()) ::
  {:ok, constraint()} | :error

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the Hex.Solver.Registry or passed to Hex.Solver.run/4.

Link to this function

parse_constraint!(string)

View Source

@spec parse_constraint!(String.t() | Version.t() | Version.Requirement.t()) ::
  constraint()

Parses or converts a SemVer version or Elixir version requirement to an internal solver constraint that can be returned by the Hex.Solver.Registry or passed to Hex.Solver.run/4.

Link to this function

run(registry, dependencies, locked, overrides, opts \\ [])

View Source

@spec run(module(), [dependency()], [locked()], [label()], [{:ansi, boolean()}]) ::
  {:ok, result()} | {:error, String.t()}

Runs the version solver.

Takes a Hex.Solver.Registry implementation, a list of root dependencies, a list of locked package versions, and a list of packages that are overridden by the root dependencies.

Locked dependencies are treated as optional dependencies with a single version as their constraint.

The overrides are a set of labels. If a dependency with a matching label is declared the solver will ignore that dependency unless it's a root dependency.

Returns a map of packages and their selected versions or a human readable explanation of why a solution could not be found.

options

Options

:ansi - If true adds ANSI formatting to the failure message (Default: false)

Hex.Solver.Registry behaviour

Anchor for this section Summary

Callbacks

dependencies(repo, package, t)

Returns all dependencies of the given package version or :error if the package or version does not exist.

prefetch(list)

Called when the solver first discovers a set of packages so that the registry can be lazily preloaded.

versions(repo, package)

Returns all versions of the given package sorted from lowest to highest or :error if the package does not exist.

Anchor for this section Callbacks

Link to this callback

dependencies(repo, package, t)

View Source

@callback dependencies(Hex.Solver.repo(), Hex.Solver.package(), Version.t()) ::
  {:ok, [Hex.Solver.dependency()]} | :error

Returns all dependencies of the given package version or :error if the package or version does not exist.

Link to this callback

prefetch(list)

View Source

@callback prefetch([{Hex.Solver.repo(), Hex.Solver.package()}]) :: :ok

Called when the solver first discovers a set of packages so that the registry can be lazily preloaded.

Link to this callback

versions(repo, package)

View Source

@callback versions(Hex.Solver.repo(), Hex.Solver.package()) ::
  {:ok, [Version.t()]} | :error

Returns all versions of the given package sorted from lowest to highest or :error if the package does not exist.

mix hex

Prints Hex tasks and their information.

$ mix hex

See mix help hex.config to see all available configuration options.

mix hex.audit

Shows all Hex dependencies that have been marked as retired.

Retired packages are no longer recommended to be used by their maintainers. The task will display a message describing the reason for retirement and exit with a non-zero code if any retired dependencies are found.

mix hex.build

Builds a new local version of your package.

The package .tar file is created in the current directory, but is not pushed to the repository. An app named foo at version 1.2.3 will be built as foo-1.2.3.tar.

$ mix hex.build

Configuration

:app - Package name (required).

:version - Package version (required).

:deps - List of package dependencies (see Dependencies below).

:description - Short description of the project.

:package - Hex specific configuration (see Package configuration below).

Dependencies

Dependencies are defined in mix's dependency format. But instead of using :git or :path as the SCM :package is used.

defp deps() do
  [
    {:ecto, "~> 0.1.0"},
    {:postgrex, "~> 0.3.0"},
    {:cowboy, github: "extend/cowboy"}
  ]
end

As can be seen Hex package dependencies works alongside git dependencies. Important to note is that non-Hex dependencies will not be used during dependency resolution and neither will they be listed as dependencies of the package.

Package configuration

Additional metadata of the package can optionally be defined, but it is very recommended to do so.

:name - Set this if the package name is not the same as the application name.

:files - List of files and directories to include in the package, can include wildcards. Defaults to ["lib", "priv", ".formatter.exs", "mix.exs", "README*", "readme*", "LICENSE*", "license*", "CHANGELOG*", "changelog*", "src", "c_src", "Makefile*"].

:exclude_patterns - List of patterns matching files and directories to exclude from the package.

:licenses - List of licenses used by the package.

:links - Map of links relevant to the package.

:build_tools - List of build tools that can build the package. Hex will try to automatically detect the build tools based on the files in the package. If a rebar or rebar.config file is present Hex will mark it as able to build with rebar. This detection can be overridden by setting this field.

Command line options

--unpack - Builds the tarball and unpacks contents into a directory. Useful for making sure the tarball contains all needed files before publishing. See --output below for setting the output path.

-o, --output - Sets output path. When used with --unpack it means the directory (Default: <app>-<version>). Otherwise, it specifies tarball path (Default: <app>-<version>.tar)

mix hex.config

Reads, updates or deletes local Hex config.

List config keys and values

$ mix hex.config

Get or delete config value for KEY

$ mix hex.config KEY [--delete]

Set config KEY to VALUE

$ mix hex.config KEY VALUE

Config keys

api_key - Your API key. If you are authenticated this config will override the API key used for your authenticated user. Can be also be overridden by setting the environment variable HEX_API_KEY

api_url - Hex API URL. Can be overridden by setting the environment variable HEX_API_URL (Default: "https://hex.pm/api")

offline - If set to true Hex will not fetch the registry or packages and will instead use locally cached files if they are available. Can be overridden by setting the environment variable HEX_OFFLINE (Default: false)

unsafe_https - If set to true Hex will not verify HTTPS certificates. Can be overridden by setting the environment variable HEX_UNSAFE_HTTPS (Default: false)

unsafe_registry - If set to true Hex will not verify the registry signature against the repository's public key. Can be overridden by setting the environment variable HEX_UNSAFE_REGISTRY (Default: false)

no_verify_repo_origin - If set to true Hex will not verify the registry origin. Can be overridden by setting the environment variable HEX_NO_VERIFY_REPO_ORIGIN (Default: false)

http_proxy - HTTP proxy server. Can be overridden by setting the environment variable HTTP_PROXY

https_proxy - HTTPS proxy server. Can be overridden by setting the environment variable HTTPS_PROXY

no_proxy - A comma separated list of hostnames that will not be proxied, asterisks can be used as wildcards. Can be overridden by setting the environment variable no_proxy or NO_PROXY

http_concurrency - Limits the number of concurrent HTTP requests in flight. Can be overridden by setting the environment variable HEX_HTTP_CONCURRENCY (Default: 8)

http_timeout - Sets the timeout for HTTP requests in seconds. Can be overridden by setting the environment variable HEX_HTTP_TIMEOUT

mirror_url - Hex mirror URL. Can be overridden by setting the environment variable HEX_TRUSTED_MIRROR

trusted_mirror_url - Hex mirror URL. Unlike mirror_url, this mirror is "trusted", secrets such as authentication information will be sent to the mirror. Can be overridden by setting the environment variable HEX_TRUSTED_MIRROR

cacerts_path - Path to the CA certificate store PEM file. If not set, a CA bundle that ships with Hex is used. Can be overridden by setting the environment variable HEX_CACERTS_PATH

no_short_urls - If set to true Hex will not shorten any links. Can be overridden by setting the environment variable HEX_NO_SHORT_URLS (Default: false)

Hex responds to these additional environment variables:

HEX_HOME - directory where Hex stores the cache and configuration (Default: ~/.hex)

MIX_XDG - asks Hex to follow the XDG Directory Specification for its home directory and configuration files. HEX_HOME has higher preference than MIX_XDG. If none of the variables are set, the default directory ~/.hex will be used.

Config overrides

All keys from the "Config keys" section above can be overridden.

Hex uses the following order of precedence when computing a value for a given key:

System environment

Setting for example HEX_API_URL environment variable has always the highest precedence for the api_url config key.

Project configuration

Hex allows an optional, per-project configuration in the mix.exs file. For example, to override api_url config key, add the following:

# mix.exs
defmodule MyApp.MixProject
  def project() do
    [
      # ...
      deps: deps(),
      hex: hex()
    ]
  end
  defp hex() do
    [
      api_url: "https://hex.myorg/api"
    ]
  end
end

Global configuration using mix hex.config KEY VALUE

Default value

Command line options

--delete - Remove a specific config key

mix hex.docs

Fetches or opens documentation of a package.

If no version is specified, defaults to version used in the current mix project. If called outside of a mix project or the dependency is not used in the current mix project, defaults to the latest version.

Fetch documentation for all dependencies in the current mix project

$ mix hex.docs fetch

Fetch documentation for offline use

Fetches documentation for the specified package that you can later open with mix hex.docs offline.

$ mix hex.docs fetch PACKAGE [VERSION]

Open a browser window with offline documentation

$ mix hex.docs offline PACKAGE [VERSION]

Open a browser window with online documentation

$ mix hex.docs online PACKAGE [VERSION]

Command line options

--module Some.Module - Open a specified module documentation page inside desired package

--organization ORGANIZATION - Set this for private packages belonging to an organization

--latest - Looks for the latest release of a package

--format epub - When opening documentation offline, use this flag to open the epub formatted version

mix hex.info

Prints Hex package or system information.

$ mix hex.info [PACKAGE [VERSION]]

If package is not given, print system information. This includes when registry was last updated and current system version.

If package is given, print information about the package. This includes all released versions and package metadata.

If package and version is given, print release information.

Command line options

--organization ORGANIZATION - Set this for private packages belonging to an organization

mix hex.organization

Manages the list of authorized Hex.pm organizations.

Organizations is a feature of Hex.pm to host and manage private packages. See https://hex.pm/docs/private for more information.

By default you will be authorized to all your applications when running mix hex.user auth and this is the recommended approach. This task is mainly provided for a CI and build systems where access to an organization is needed without authorizing a user.

By authorizing a new organization a new key is created for fetching packages from the organizations repository and the repository key is stored on the local machine.

To use a package from an organization add organization: "my_organization" to the dependency declaration in mix.exs:

{:plug, "~> 1.0", organization: "my_organization"}

Authorize an organization

This command will generate an API key used to authenticate access to the organization. See the hex.user tasks to list and control all your active API keys.

$ mix hex.organization auth ORGANIZATION  [--key KEY] [--key-name KEY_NAME]

Deauthorize and remove an organization

$ mix hex.organization deauth NAME

List all authorized organizations

This command will only list organizations you have authorized with this task, it will not list organizations you have access to by having authorized with mix hex.user auth.

$ mix hex.organization list

Generate organization key

This command is useful to pre-generate keys for use with mix hex.organization auth ORGANIZATION --key KEY on CI servers or similar systems. It returns the hash of the generated key that you can pass to auth ORGANIZATION --key KEY. Unlike the hex.user key commands, a key generated with this command is owned by the organization directly, and not the user that generated it. This makes it ideal for shared environments such as CI where you don't want to give access to user-specific resources and the user's organization membership status won't affect key. By default this command sets the repository:organization_name permission which allows read-only access to the organization's repository, it can be overridden with the --permission flag.

$ mix hex.organization key ORGANIZATION generate [--key-name KEY_NAME] [--permission PERMISSION]

Revoke key

Removes given key from organization.

The key can no longer be used to authenticate API requests.

$ mix hex.organization key ORGANIZATION revoke KEY_NAME

Revoke all keys

Revoke all keys from the organization.

$ mix hex.organization key ORGANIZATION revoke --all

List keys

Lists all keys associated with the organization.

$ mix hex.organization key ORGANIZATION list

Command line options

--key KEY - Hash of key used to authenticate HTTP requests to repository, if omitted will generate a new key with your account credentials. This flag is useful if you have a key pre-generated with mix hex.organization key and want to authenticate on a CI server or similar system

--key-name KEY_NAME - By default Hex will base the key name on your machine's hostname and the organization name, use this option to give your own name.

--permission PERMISSION - Sets the permissions on the key, this option can be given multiple times, possibly values are:

api:read - API read access.

api:write - API write access.

repository:organization_name - Access to the organization's repository (this is the default permission).

mix hex.outdated

Shows all Hex dependencies that have newer versions in the registry.

$ mix hex.outdated [APP]

By default, it only shows top-level packages explicitly listed in the mix.exs file. All outdated packages can be displayed by using the --all command line option.

By default, hex.outdated will exit with a non-zero exit code (1) if there are any outdated dependencies. You can override this to respect the requirements as specified in your mix.exs file, with the --within-requirements command line option, so it only exits with non-zero exit code if the update is possible.

For example, if your version requirement is "~> 2.0" but the latest version is 3.0, with --within-requirements it will exit successfully, but if the latest version is 2.8, then --within-requirements will exit with non-zero exit code (1).

One scenario this could be useful is to ensure you always have the latest version of your dependencies, except for major version bumps.

If a dependency name is given all requirements on that dependency, from the entire dependency tree, are listed. This is useful if you are trying to figure why a package isn't updating when you run mix deps.update.

Note that when this task determines if a package is updatable it only looks at the project's current set of dependency requirements and what version they are locked to. When mix deps.update is called multiple packages may be updated that in turn update their own dependencies, which may cause the package you want to update to not be able to update.

Command line options

--all - shows all outdated packages, including children of packages defined in mix.exs

--pre - include pre-releases when checking for newer versions

--within-requirements - exit with non-zero code only if requirements specified in mix.exs is met.

mix hex.owner

Adds, removes or lists package owners.

Package owners have full permissions to the package. They can publish and revert releases and even remove other package owners.

Add owner

Adds an owner to package by specifying the package name and email or username of the new owner. This command also takes a --level option, see below for more details.

$ mix hex.owner add PACKAGE EMAIL_OR_USERNAME

Transfer ownership

Like mix hex.owner add but also removes all existing owners of the package. This task is required to use when transferring ownership of the package to an organization.

$ mix hex.owner transfer PACKAGE EMAIL_OR_USERNAME

Remove owner

Removes an owner to package by specifying the package name and email or username of the new owner.

$ mix hex.owner remove PACKAGE EMAIL_OR_USERNAME

List owners

Lists all owners of given package.

$ mix hex.owner list PACKAGE

List owned packages

Lists all packages owned by the current user.

$ mix hex.owner packages

Command line options

--level maintainer - Maintainer level owners have all the powers of package ownership, except they cannot add or remove other package owners

--level full - Over the maintainer level, full owners can also add and remove other package owners (default)

--organization ORGANIZATION - Set this for private packages belonging to an organization

mix hex.package

Fetches or diffs packages.

Fetch package

Fetch a package tarball to the current directory.

$ mix hex.package fetch PACKAGE [VERSION] [--unpack] [--output PATH]

If version is not given, use the latest version.

You can pipe the fetched tarball to stdout by setting --output -.

Diff package versions

$ mix hex.package diff APP VERSION

This command compares the project's dependency APP against the target package version, unpacking the target version into temporary directory and running a diff command.

Fetch and diff package contents between versions

$ mix hex.package diff PACKAGE VERSION1 VERSION2
$ mix hex.package diff PACKAGE VERSION1..VERSION2

This command fetches package tarballs for both versions, unpacks them into temporary directories and runs a diff command. Afterwards, the temporary directories are automatically deleted.

Note, similarly to when tarballs are fetched with mix deps.get, a hex_metadata.config is placed in each unpacked directory. This file contains package's metadata as Erlang terms and so we can additionally see the diff of that.

The exit code of the task is that of the underlying diff command.

Diff command

The diff command can be customized by setting diff_command configuration option, see mix help hex.config for more information. The default diff command is:

$ git diff --no-index __PATH1__ __PATH2__

The __PATH1__ and __PATH2__ placeholders will be interpolated with paths to directories of unpacked tarballs for each version.

Many diff commands supports coloured output but because we execute the command in non-interactive mode, they'd usually be disabled.

On Unix systems you can pipe the output to more commands, for example:

$ mix hex.package diff decimal 1.0.0..1.1.0 | colordiff | less -R

Here, the output of mix hex.package diff is piped to the colordiff utility to adds colours, which in turn is piped to less -R which "pages" it. (-R preserves escape codes which allows colours to work.)

Another option is to configure the diff command itself. For example, to force Git to always colour the output we can set the --color=always option:

$ mix hex.config diff_command "git diff --color=always --no-index __PATH1__ __PATH2__"
$ mix hex.package diff decimal 1.0.0..1.1.0

Command line options

--unpack - Unpacks the tarball after fetching it

-o, --output - Sets output path. When used with --unpack it means the directory (Default: <app>-<version>). Otherwise, it specifies tarball path (Default: <app>-<version>.tar)

--organization ORGANIZATION - Set this for private packages belonging to an organization

--repo REPO - Set this for self-hosted Hex instances, default: hexpm

mix hex.publish

Publishes a new version of the package.

$ mix hex.publish

The current authenticated user will be the package owner. Only package owners can publish the package, new owners can be added with the mix hex.owner task.

Packages and documentation sizes are limited to 8mb compressed, and 64mb uncompressed.

Publishing documentation

Documentation will be generated by running the mix docs task. ex_doc provides this task by default, but any library can be used. Or an alias can be used to extend the documentation generation. The expected result of the task is the generated documentation located in the doc/ directory with an index.html file.

The documentation will be accessible at https://hexdocs.pm/my_package/1.0.0, https://hexdocs.pm/my_package will always redirect to the latest published version.

Documentation will be built and published automatically. To publish a package without documentation run mix hex.publish package or to only publish documentation run mix hex.publish docs.

Reverting a package

A new package can be reverted or updated within 24 hours of it's initial publish, a new version of an existing package can be reverted or updated within one hour. Documentation have no limitations on when it can be updated.

To update the package simply run the mix hex.publish task again. To revert run mix hex.publish --revert VERSION or to only revert the documentation run mix hex.publish docs --revert VERSION.

If the last version is reverted, the package is removed.

Command line options

--organization ORGANIZATION - Set this for private packages belonging to an organization

--yes - Publishes the package without any confirmation prompts

--dry-run - Builds package and performs local checks without publishing, use mix hex.build --unpack to inspect package contents before publishing

--replace - Allows overwriting an existing package version if it exists. Private packages can always be overwritten, public packages can only be overwritten within one hour after they were initially published.

--revert VERSION - Revert given version. If the last version is reverted, the package is removed.

Configuration

:app - Package name (required).

:version - Package version (required).

:deps - List of package dependencies (see Dependencies below).

:description - Short description of the project.

:package - Hex specific configuration (see Package configuration below).

Dependencies

Dependencies are defined in mix's dependency format. But instead of using :git or :path as the SCM :package is used.

defp deps() do
  [
    {:ecto, "~> 0.1.0"},
    {:postgrex, "~> 0.3.0"},
    {:cowboy, github: "extend/cowboy"}
  ]
end

As can be seen Hex package dependencies works alongside git dependencies. Important to note is that non-Hex dependencies will not be used during dependency resolution and neither will they be listed as dependencies of the package.

Package configuration

Additional metadata of the package can optionally be defined, but it is very recommended to do so.

:name - Set this if the package name is not the same as the application name.

:files - List of files and directories to include in the package, can include wildcards. Defaults to ["lib", "priv", ".formatter.exs", "mix.exs", "README*", "readme*", "LICENSE*", "license*", "CHANGELOG*", "changelog*", "src", "c_src", "Makefile*"].

:exclude_patterns - List of patterns matching files and directories to exclude from the package.

:licenses - List of licenses used by the package.

:links - Map of links relevant to the package.

:build_tools - List of build tools that can build the package. Hex will try to automatically detect the build tools based on the files in the package. If a rebar or rebar.config file is present Hex will mark it as able to build with rebar. This detection can be overridden by setting this field.

mix hex.registry

Manages local Hex registries.

Build a local registry

$ mix hex.registry build PUBLIC_DIR

To build a registry you need a name, a directory that will be used to store public registry files, and a private key to sign the registry:

$ mix hex.registry build public --name=acme --private-key=private_key.pem
* creating public/public_key
* creating public/tarballs
* creating public/names
* creating public/versions

You can generate a random private key using the following command:

$ openssl genrsa -out private_key.pem

Let's say you have a package foo-1.0.0.tar. To publish it, simply copy it to the appropriate directory and re-build the registry:

$ cp foo-1.0.0.tar public/tarballs/
$ mix hex.registry build public --name=acme --private-key=private_key.pem
* creating public/packages/foo
* updating public/names
* updating public/versions

You can test the repository by starting the built-in Erlang/OTP HTTP server, adding the repository, and retrieving the package that you just published.

$ erl -s inets -eval 'inets:start(httpd,[{port,8000},{server_name,"localhost"},{server_root,"."},{document_root,"public"}]).'

# replace "acme" with the name of your repository
$ mix hex.repo add acme http://localhost:8000 --public-key=public/public_key
$ mix hex.package fetch foo 1.0.0 --repo=acme

To use the package in your Mix project, add it as a dependency and set the :repo option to your repository name:

defp deps() do
  {:decimal, "~> 2.0", repo: "acme"}
end

Command line options

--name - The name of the registry

--private-key - Path to the private key

mix hex.repo

Manages the list of available Hex repositories.

The repository is where packages and the registry of packages is stored. You can fetch packages from multiple different repositories and packages can depend on packages from other repositories. To use a package from another repository than the global default hexpm add repo: "my_repo" to the dependency declaration in mix.exs:

{:plug, "~> 1.0", repo: "my_repo"}

By default all dependencies of plug will also be fetched from my_repo unless plug has declared otherwise in its dependency definition.

To use packages from my_repo you need to add it to your configuration first. You do that by calling mix hex.repo add my_repo https://myrepo.example.com.

The default repo is called hexpm and points to https://repo.hex.pm. This can be overridden by using mix hex.repo set ....

A repository configured from an organization will have hexpm: prefixed to its name. To depend on packages from an organization add repo: "hexpm:my_organization" to the dependency declaration or simply organization: "my_organization".

To configure organizations, see the hex.organization task.

Add a repo

$ mix hex.repo add NAME URL

Command line options

--public-key PATH - Path to public key used to verify the registry (optional).

--auth-key KEY - Key used to authenticate HTTP requests to repository (optional).

--fetch-public-key FINGERPRINT - Download public key from the repository and verify against the fingerprint (optional).

Set config for repo

$ mix hex.repo set NAME --url URL
$ mix hex.repo set NAME --public-key PATH
$ mix hex.repo set NAME --auth-key KEY

Remove repo

$ mix hex.repo remove NAME

Show repo config

$ mix hex.repo show NAME
$ mix hex.repo show NAME --url

List all repos

$ mix hex.repo list

mix hex.retire

Retires a package version.

$ mix hex.retire PACKAGE VERSION REASON

$ mix hex.retire PACKAGE VERSION --unretire

Mark a package as retired when you no longer recommend its usage. A retired package is still resolvable and usable but it will be flagged as retired in the repository and a message will be displayed to users when they use the package.

Retirement reasons

renamed - The package has been renamed, including the new package name in the message

deprecated - The package has been deprecated, if there's a replacing package include it in the message

security - There are security issues with this package

invalid - The package is invalid, for example it does not compile correctly

other - Any other reason not included above, clarify the reason in the message

Command line options

--message "MESSAGE" - Required message (up to 140 characters) clarifying the retirement reason

--organization ORGANIZATION - Set this for private packages belonging to an organization

Example

$ mix hex.retire your_app 0.1.1 invalid --message "Package has a breaking bug"

mix hex.search

Displays packages matching the given search query.

If you are authenticated it will additionally search all organizations you are member of.

$ mix hex.search PACKAGE

Command line options

--organization ORGANIZATION - Set this for private packages belonging to an organization

mix hex.sponsor

Show Hex packages in your dependencies that accept sponsorships.

$ mix hex.sponsor

Sponsorship plays an important role to maintain some open source projects. This task will display all packages that are accepting sponsorship from the current project.

You can add sponsorship links to your projects by adding the following to your mix.exs:

links: %{
  "GitHub" => "[your-repo-link]",
  "Sponsor" => "[your-sponsorship-link]"
}

mix hex.user

Hex user tasks.

Register a new user

$ mix hex.user register

Print the current user

$ mix hex.user whoami

Authorize a new user

Authorizes a new user on the local machine by generating a new API key and storing it in the Hex config.

$ mix hex.user auth [--key-name KEY_NAME]

Command line options

--key-name KEY_NAME - By default Hex will base the key name on your machine's hostname, use this option to give your own name.

Deauthorize the user

Deauthorizes the user from the local machine by removing the API key from the Hex config.

$ mix hex.user deauth

Generate user key

Generates an unencrypted API key for your account. Keys generated by this command will be owned by you and will give access to your private resources, do not share this key with anyone. For keys that will be shared by organization members use mix hex.organization key instead. By default this command sets the api:write permission which allows write access to the API, it can be overridden with the --permission flag.

$ mix hex.user key generate

Command line options

--key-name KEY_NAME - By default Hex will base the key name on your machine's hostname, use this option to give your own name.

--permission PERMISSION - Sets the permissions on the key, this option can be given multiple times, possible values are:

api:read - API read access.

api:write - API write access.

repository:ORGANIZATION_NAME - Access to given organization repository.

repositories - Access to repositories for all organizations you are member of.

Revoke key

Removes given key from account.

The key can no longer be used to authenticate API requests.

$ mix hex.user key revoke KEY_NAME

Revoke all keys

Revoke all keys from your account.

$ mix hex.user key revoke --all

List keys

Lists all keys associated with your account.

$ mix hex.user key list

Reset user account password

Starts the process for resetting account password.

$ mix hex.user reset_password account

Reset local password

Updates the local password for your local authentication credentials.

$ mix hex.user reset_password local