Depscheck.LicenseDetector (Depscheck v1.0.12)

View Source

Detects licenses for the project and its dependencies.

This module reads license information from:

  • Project's mix.exs for the project license
  • deps/*/hex_metadata.config for dependency licenses

Summary

Functions

Extracts all dependencies and their licenses from the deps directory.

Gets license information for a single dependency.

Detects the project's license from mix.exs configuration.

Detects the project's license with configuration override support.

Functions

get_all_dependency_licenses()

@spec get_all_dependency_licenses() :: [Depscheck.Types.dependency()]

Extracts all dependencies and their licenses from the deps directory.

Returns a list of dependency maps with name and licenses.

get_dependency_license(package_name)

@spec get_dependency_license(String.t()) :: {:ok, [String.t()]} | {:error, atom()}

Gets license information for a single dependency.

Returns {:ok, licenses} or {:error, reason}.

get_project_license()

@spec get_project_license() :: String.t() | nil

Detects the project's license from mix.exs configuration.

Returns the first license if multiple are declared, or nil if none found.

Examples

iex> Depscheck.LicenseDetector.get_project_license()
"MIT"

get_project_license_with_config(config)

@spec get_project_license_with_config(Depscheck.Types.config()) :: String.t() | nil

Detects the project's license with configuration override support.

First checks for project_license in .depscheck.exs config, then falls back to mix.exs detection.

Examples

iex> Depscheck.LicenseDetector.get_project_license_with_config(%{project_license: "All Rights Reserved"})
"All Rights Reserved"

iex> Depscheck.LicenseDetector.get_project_license_with_config(%{project_license: nil})
"MIT"