bau/configedit

Updates dependency and patch entries in bau.toml.

Types

DependencyEdit = object
  name*: string              ## Dependency name.
  version*: string           ## Registry version requirement.
  git*: string               ## Git URL.
  tag*: string               ## Git tag.
  branch*: string            ## Git branch.
  rev*: string               ## Exact Git revision.
  path*: string              ## Local path dependency.
  registry*: string          ## Named registry source.
  optional*: bool            ## Whether the dependency is feature-gated.
Editable dependency specification for config updates.
DependencyEditResult = object
  content*: string           ## Updated TOML content.
  changed*: bool             ## True when content was modified.
Result of editing raw TOML content.
VersionBumpKind = enum
  vbMajor = "major",        ## Increment major and reset minor/patch.
  vbMinor = "minor",        ## Increment minor and reset patch.
  vbPatch = "patch"          ## Increment patch.
SemVer component to increment.
VersionBumpResult = object
  oldVersion*: string        ## Version before the bump.
  newVersion*: string        ## Version after the bump.
  nimblePath*: string        ## Updated `.nimble` file path, when one existed.
  configChanged*: bool       ## True when `bau.toml` content changed.
  nimbleChanged*: bool       ## True when `.nimble` content changed.
Result of bumping package version metadata.

Procs

proc addDependency(projectDir: string; edit: DependencyEdit) {.
    ...raises: [IOError, OSError, TomlError, ValueError, KeyError, Exception], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect, WriteDirEffect, ReadDirEffect],
    forbids: [].}
Add or update a dependency entry in a project's bau.toml.
proc bumpedSemVer(version: string; kind: VersionBumpKind): string {.
    ...raises: [ValueError], tags: [], forbids: [].}
Return version after incrementing the requested SemVer component.
proc bumpPackageVersion(projectDir: string; kind: VersionBumpKind;
                        dryRun = false): VersionBumpResult {.
    ...raises: [IOError, OSError, TomlError, ValueError, KeyError, Exception], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect, WriteDirEffect, ReadDirEffect],
    forbids: [].}
Bump [package].version and an existing generated Nimble file.
proc dependencyLine(edit: DependencyEdit): string {....raises: [ValueError],
    tags: [], forbids: [].}
Format a dependency edit as a single TOML assignment line.
proc initDependencyEdit(name: string): DependencyEdit {....raises: [], tags: [],
    forbids: [].}
Initialize an edit for a dependency name.
proc parseVersionBumpKind(value: string): VersionBumpKind {.
    ...raises: [ValueError], tags: [], forbids: [].}
Parse a version bump selector such as major or --patch.
proc removeDependency(projectDir, depName: string) {.
    ...raises: [IOError, OSError, TomlError, ValueError, KeyError, Exception], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect, WriteDirEffect, ReadDirEffect],
    forbids: [].}
Remove a dependency entry from a project's bau.toml.
proc removeDependencyFromSection(content, sectionName, depName: string): DependencyEditResult {.
    ...raises: [], tags: [], forbids: [].}
Remove a dependency assignment from a TOML section.
proc toDependencyEdit(name: string; dep: DepInfo): DependencyEdit {....raises: [],
    tags: [], forbids: [].}
Convert parsed dependency info into an editable dependency record.
proc updateNimbleVersionContent(content, newVersion: string): DependencyEditResult {.
    ...raises: [ValueError], tags: [], forbids: [].}
Replace the first top-level Nimble version = assignment.
proc updatePackageVersionContent(content, newVersion: string): DependencyEditResult {.
    ...raises: [ValueError], tags: [], forbids: [].}
Replace the [package] version assignment in raw bau.toml content.
proc upsertDependencyInSection(content, sectionName: string;
                               edit: DependencyEdit): DependencyEditResult {.
    ...raises: [ValueError], tags: [], forbids: [].}
Insert or replace a dependency assignment in a TOML section.
proc writePatchEntry(projectDir, depName, depPath: string) {.
    ...raises: [ValueError, IOError, OSError, TomlError, KeyError, Exception], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect, WriteDirEffect, ReadDirEffect],
    forbids: [].}
Add or update a [patch] entry in a project's bau.toml.