Trebejo.Packages (Trebejo v2.0.0)

Copy Markdown View Source

Package installation and querying — via Arrea.Command.

For package manager detection use Apero.Packages directly. All command execution is routed through Trebejo.Util with arg lists — never interpolated into shell strings — to prevent shell injection.

Usage

# Install packages using the preferred manager:
Trebejo.Packages.install("nodejs")

# Install using a specific manager:
Trebejo.Packages.install(:apt, ["nodejs", "npm"])

# Check if installed:
Trebejo.Packages.installed?(:brew, "node")

Summary

Functions

Installs packages using the preferred (auto-detected) package manager.

Installs one or more packages using the specified manager.

Convenience: checks if a package is installed using the preferred manager.

Checks if a package is installed via the given manager.

Types

manager()

@type manager() ::
  :apt
  | :apt_get
  | :brew
  | :pacman
  | :yum
  | :dnf
  | :apk
  | :zypper
  | :pkg
  | :winget
  | :choco
  | :port
  | :nix

package()

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

Functions

install(packages)

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

Installs packages using the preferred (auto-detected) package manager.

install(manager, packages, opts \\ [])

@spec install(manager(), [package()] | package(), keyword()) ::
  :ok | {:error, String.t()}

Installs one or more packages using the specified manager.

Returns :ok on success, {:error, reason} on failure.

installed?(package)

@spec installed?(package()) :: boolean() | {:error, String.t()}

Convenience: checks if a package is installed using the preferred manager.

installed?(manager, package)

@spec installed?(manager(), package()) :: boolean()

Checks if a package is installed via the given manager.

Returns true or false.