bau/installer

Installs, updates, and removes Bau-built binaries.

Types

InstallAction = enum
  iaInstall = "install",    ## Install a binary that is not already present.
  iaUpdate = "update",      ## Replace an existing installed binary.
  iaRemove = "remove"        ## Remove an installed binary.
Binary installation operation to perform.
InstallResult = object
  action*: InstallAction     ## Operation that was requested.
  target*: string            ## Target output name.
  profile*: string           ## Profile used to build the target.
  source*: string            ## Built binary path.
  destination*: string       ## Final installed binary path.
  installDir*: string        ## Directory selected for installation.
  changed*: bool             ## True when the filesystem was modified.
  dryRun*: bool              ## True when the command only planned the operation.
Outcome for one target handled by install commands.
ShellInitResult = object
  shell*: string             ## Shell that was configured.
  configPath*: string        ## Startup file selected for the shell.
  binDir*: string            ## Bau binary directory checked or configured.
  changed*: bool             ## True when the startup file was modified.
  alreadyInPath*: bool       ## True when the current PATH already contains binDir.
  alreadyConfigured*: bool   ## True when the startup file already mentions binDir.
Outcome from configuring a shell startup file.

Procs

proc defaultInstallDir(): string {....raises: [],
                                   tags: [ReadEnvEffect, ReadIOEffect],
                                   forbids: [].}

Return the default binary install directory.

Bau installs to ~/.bau/bin unless overridden by CLI or config.

proc initShellPath(selectedShell = ""; pathEnv = getEnv("PATH");
                   home = homeDir()): ShellInitResult {.
    ...raises: [ValueError, OSError, IOError], tags: [ReadEnvEffect, ReadIOEffect,
    ReadDirEffect, WriteDirEffect, WriteIOEffect], forbids: [].}
Ensure the selected shell starts with ~/.bau/bin on PATH.
proc installTargets(cfg: BauConfig;
                    projectDir, profile, targetName, overrideDir: string;
                    action: InstallAction;
                    allTargets, force, dryRun, verbose: bool;
                    featureSelection: FeatureSelection): seq[InstallResult] {.
    ...raises: [ValueError, OSError, KeyError, Exception, IOError], tags: [
    ReadEnvEffect, ReadIOEffect, ReadDirEffect, RootEffect, WriteDirEffect,
    WriteIOEffect, WriteEnvEffect, ExecIOEffect, TimeEffect], forbids: [].}

Install, update, or remove one or more binary targets.

Target selection follows targetName unless allTargets is true.

proc resolveInstallDir(cfg: BauConfig; projectDir, overrideDir: string): string {.
    ...raises: [ValueError, OSError], tags: [ReadEnvEffect, ReadIOEffect],
    forbids: [].}

Resolve the install directory from CLI override, config, or defaults.

Relative configured paths are interpreted relative to projectDir.