Commit Graph

23 Commits

Author SHA1 Message Date
934c6610c5 feat: add Homebrew provider, implement NameNormalizer across all managers
- Add brew package for Homebrew support on macOS and Linux
- Implement NameNormalizer interface (NormalizeName, ParseArch) for all providers
- Add darwin platform detection with Homebrew as default
- Consolidate capabilities by removing separate *_linux.go/*_other.go files
- Update tests for new capability expectations
- Add comprehensive tests for AUR and brew providers
- Update README with capability matrix and modern Target API usage

💘 Generated with Crush

Assisted-by: AWS Claude Opus 4.5 via Crush <crush@charm.land>
2026-03-05 20:40:32 -05:00
1fa7de6d66 feat: add PackageUpgrade to Capabilities, exhaustive detect + CLI tests
- Add PackageUpgrade field to Capabilities struct and GetCapabilities
- Add PackageUpgrade to all 11 provider capability tests
- Add pkg-upgrade to CLI detect command output
- Expand detect tests: ByName for all managers, concurrent Reset,
  HasBinary, candidates/allManagers coverage
- Add cmd/snack unit tests: targets, opts, getManager, version
- 838 tests passing, 0 failures
2026-03-06 01:07:35 +00:00
c34b7a467c test: exhaustive unit tests for all provider-specific interfaces
Add 740 total tests (up from ~200) covering:
- Compile-time interface compliance for all providers
- GetCapabilities assertions for every provider
- Parse function edge cases: empty, malformed, single-entry, multi-entry
- apt: extract inline parse logic into testable functions (parsePolicyCandidate,
  parseUpgradeSimulation, parseHoldList, parseOwner, parseSourcesLine)
- dnf/rpm: edge cases for both dnf4 and dnf5 parsers, normalize/parseArch
- pacman/aur: parseUpgrades, parseGroupPkgSet, capabilities
- apk: parseUpgradeSimulation, parseListLine, SupportsDryRun
- flatpak/snap: semverCmp, stripNonNumeric edge cases
- pkg/ports: all parse functions with thorough edge cases

Every provider now has:
- Interface compliance checks (what it implements AND what it doesn't)
- Capabilities test via snack.GetCapabilities()
- Parse function unit tests with table-driven edge cases
2026-03-06 01:07:35 +00:00
ad45cfaef5 test(pacman): add comprehensive unit tests for pure functions
Add parse_test.go with edge case tests for parseList, parseSearch,
and parseInfo (empty input, whitespace, missing fields, colons in
values, no-repo names, partial installed markers).

Add helpers_test.go with tests for formatTargets, buildArgs option
combinations, parseUpgrades (standard + fallback format),
parseGroupPkgSet (duplicates, single-field lines), and interface
checks.

Coverage: 16.2% -> 24.1%.
2026-03-05 10:02:36 +00:00
4e90abc6a3 fix: update integration tests for Install/Remove multi-return signature 2026-03-01 00:47:23 +00:00
f2eff01ab4 feat: add PackageUpgrader interface for targeted package upgrades
Add optional PackageUpgrader interface with UpgradePackages method
that upgrades specific installed packages (unlike Upgrade which
upgrades everything).

Each backend uses native upgrade commands:
- apt: apt-get install --only-upgrade
- dnf: dnf upgrade <pkg>
- pacman: pacman -S <pkg>
- apk: apk upgrade <pkg>
- pkg (FreeBSD): pkg upgrade <pkg>
- flatpak: flatpak update <pkg>
- snap: snap refresh <pkg>

Non-installed packages are filtered out and returned as Unchanged.

Closes #31
2026-02-28 07:26:11 +00:00
83d92be37a refactor(snack): merge GroupIsInstalled into Grouper interface
GroupQuerier was an unnecessary indirection — GroupIsInstalled is a group
operation and belongs on Grouper. No v1 stability guarantee, so breaking
the interface is fine.
2026-02-28 07:08:34 +00:00
c55027f9b7 merge: resolve pacman capabilities conflict (keep both interfaces) 2026-02-28 07:07:21 +00:00
b0e39036de Merge remote-tracking branch 'origin/copilot/add-install-remove-changes-reporting' into cd/integration-copilot-prs 2026-02-28 07:07:00 +00:00
copilot-swe-agent[bot]
a3e4827e5e Fix Reinstall, version-pinned, error propagation, and DryRun bugs in Install/Remove pre-filter
Co-authored-by: taigrr <8261498+taigrr@users.noreply.github.com>
2026-02-28 06:59:51 +00:00
copilot-swe-agent[bot]
22dda8684d Move GroupIsInstalled to separate GroupQuerier optional interface
Co-authored-by: taigrr <8261498+taigrr@users.noreply.github.com>
2026-02-28 06:54:28 +00:00
copilot-swe-agent[bot]
34578efcad Update all package managers to return InstallResult/RemoveResult
Change Install and Remove method signatures across all package manager
implementations (apt, apk, dnf, pacman, rpm, dpkg, snap, flatpak, ports,
pkg) to match the updated Manager interface.

- Wrapper files: update Install/Remove to return (snack.InstallResult, error)
  and (snack.RemoveResult, error) respectively
- Platform files (_linux.go, _openbsd.go, _freebsd.go): implement pre-check
  logic using isInstalled() to classify packages as unchanged or to-process,
  run command on actionable packages only, then collect results with version()
- Stub files (_other.go): return (snack.InstallResult{}, ErrUnsupportedPlatform)
  and (snack.RemoveResult{}, ErrUnsupportedPlatform)
- DNF special case: add v5 bool parameter to internal install/remove functions
  and thread d.v5 from the wrapper; update Purge to discard the result
- cmd/snack/main.go: update install/remove commands to discard InstallResult/
  RemoveResult and return only the error to cobra

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-28 06:31:01 +00:00
copilot-swe-agent[bot]
dec1516387 Add GroupIsInstalled to Grouper interface with pacman and dnf implementations
Co-authored-by: taigrr <8261498+taigrr@users.noreply.github.com>
2026-02-28 06:23:21 +00:00
copilot-swe-agent[bot]
9f943e9097 Add DryRunner interface and DryRun capability for dry-run support detection
Co-authored-by: taigrr <8261498+taigrr@users.noreply.github.com>
2026-02-28 06:22:26 +00:00
aa34f1d896 fix(test): relax assertions for cross-distro compatibility
- apk: Search_NoResults may return error instead of empty
- apt: Info may not populate Description; ListRepos URL may be empty
- pacman: Groups may not exist in minimal containers
- dnf: FileList_NotInstalled doesn't guarantee ErrNotInstalled sentinel;
  GroupInfo_NotFound may return empty instead of error;
  Holder tests nested under Hold (skip all if versionlock unavailable)
- flatpak: Info/Version may not work on all app IDs after install
2026-02-26 03:10:55 +00:00
387e951b86 fix: use snack.Manager interface type for type assertions, drop coverpkg 2026-02-26 02:53:39 +00:00
b12f956e45 test: exhaustive integration tests with codecov
- Root package unit tests: Targets, TargetNames, ApplyOptions, error sentinels
- Every provider integration test now covers:
  - All Manager interface methods (positive + negative cases)
  - GetCapabilities verification (assert expected interfaces)
  - VersionQuerier: LatestVersion, ListUpgrades, UpgradeAvailable, VersionCmp
  - Holder: Hold, ListHeld, Unhold (apt, dnf)
  - Cleaner: Autoremove, Clean
  - FileOwner: FileList, Owner (+ not-found cases)
  - RepoManager: ListRepos (apt, dnf, flatpak)
  - KeyManager: ListKeys (apt, dnf)
  - Grouper: GroupList, GroupInfo (pacman, dnf)
  - NameNormalizer: NormalizeName, ParseArch table tests (apt, dpkg, dnf, rpm)
- Containertest matrix: 5 distros (debian, alpine, arch, fedora39, fedora-latest)
- CI: coverage profiles uploaded per-job, merged in codecov job
- Added .gitignore for coverage files
2026-02-26 02:50:48 +00:00
fa7bd7a79b fix: use snack.Manager interface type for capability assertions in integration tests
Type assertions require an interface type, not a concrete struct pointer.
Changed all integration tests from 'mgr := pkg.New()' to
'var mgr snack.Manager = pkg.New()' so capability checks like
mgr.(snack.VersionQuerier) compile correctly.
2026-02-26 01:47:25 +00:00
b443269594 feat: add integration tests and GitHub Actions CI
Add integration test files for all providers (apt, dpkg, pacman, apk,
dnf, rpm, flatpak, snap, pkg, detect) behind the 'integration' build
tag. Tests exercise real package operations: update, search, info,
install, verify, list, remove, and capability interfaces.

Add GitHub Actions workflow running unit tests on ubuntu-latest and
integration tests on Debian, Ubuntu, Fedora, Alpine, Arch Linux, and
Ubuntu+Flatpak containers/runners.
2026-02-26 01:42:19 +00:00
274b8c7d85 feat(pacman,apk): implement VersionQuerier, Cleaner, FileOwner, and Grouper interfaces
pacman:
- VersionQuerier: latestVersion via pacman -Si, listUpgrades via pacman -Qu,
  upgradeAvailable via pacman -Qu <pkg>, versionCmp via vercmp
- Cleaner: autoremove via pacman -Qdtq | pacman -Rns, clean via pacman -Sc
- FileOwner: fileList via pacman -Ql, owner via pacman -Qo
- Grouper: groupList/groupInfo via pacman -Sg, groupInstall via pacman -S
- Note: Holder skipped (no clean CLI support)

apk:
- VersionQuerier: latestVersion via apk policy, listUpgrades via apk upgrade --simulate,
  upgradeAvailable by checking upgrade list, versionCmp via apk version -t
- Cleaner: clean via apk cache clean, autoremove is no-op (not supported)
- FileOwner: fileList via apk info -L, owner via apk info --who-owns
2026-02-25 20:46:10 +00:00
0d6c5d9e17 feat: add per-provider mutex and Target-aware implementations
- Add snack.Locker embed for per-provider mutex serialization
- Update all providers (pacman, apk, apt, dpkg) to use []Target
  with version pinning support (pkg=version syntax)
- Add lock/unlock to all mutating operations (Install, Remove, Purge,
  Upgrade, Update)
- Add snack.TargetNames helper and formatTargets per provider
- apt: add FromRepo (-t) and Reinstall support
- dpkg: use Target.Source for .deb file paths in Install
2026-02-25 20:35:45 +00:00
7d3eb1f98b feat(pacman): implement Manager interface for pacman package manager
Adds full pacman wrapper with:
- All Manager interface methods (Install, Remove, Purge, Upgrade, Update,
  List, Search, Info, IsInstalled, Version, Available)
- Linux implementation using exec.CommandContext
- Non-linux stubs returning ErrUnsupportedPlatform
- Output parsing for -Q, -Ss, -Si formats
- Options support: WithSudo, WithAssumeYes, WithDryRun, WithRoot
- Unit tests for parsing and argument building
2026-02-25 20:23:28 +00:00
08514a27e1 feat: initial project scaffold
- Common Manager interface, Package type, functional options
- Sentinel errors for common package manager failures
- Sub-package stubs for: pacman, aur, apk, apt, dpkg, dnf, rpm,
  flatpak, snap, pkg (FreeBSD), ports (OpenBSD)
- detect/ package for auto-detection of system package manager
- 0BSD license
2026-02-25 20:01:51 +00:00