mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
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>
This commit is contained in:
@@ -11,6 +11,7 @@ var (
|
||||
_ snack.VersionQuerier = (*Pkg)(nil)
|
||||
_ snack.Cleaner = (*Pkg)(nil)
|
||||
_ snack.FileOwner = (*Pkg)(nil)
|
||||
_ snack.NameNormalizer = (*Pkg)(nil)
|
||||
)
|
||||
|
||||
// LatestVersion returns the latest available version from configured repositories.
|
||||
|
||||
17
pkg/normalize.go
Normal file
17
pkg/normalize.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package pkg
|
||||
|
||||
// normalizeName returns the canonical form of a package name.
|
||||
// FreeBSD pkg package names use "name-version" format. This function
|
||||
// strips the version portion if present, returning just the name.
|
||||
func normalizeName(name string) string {
|
||||
n, _ := splitNameVersion(name)
|
||||
return n
|
||||
}
|
||||
|
||||
// parseArchNormalize extracts the architecture from a package name if present.
|
||||
// FreeBSD pkg package names do not embed architecture in the name itself
|
||||
// (the arch is separate metadata), so this returns the name unchanged with
|
||||
// an empty architecture string.
|
||||
func parseArchNormalize(name string) (string, string) {
|
||||
return name, ""
|
||||
}
|
||||
10
pkg/pkg.go
10
pkg/pkg.go
@@ -83,6 +83,16 @@ func (p *Pkg) Version(ctx context.Context, pkg string) (string, error) {
|
||||
return version(ctx, pkg)
|
||||
}
|
||||
|
||||
// NormalizeName returns the canonical form of a package name.
|
||||
func (p *Pkg) NormalizeName(name string) string {
|
||||
return normalizeName(name)
|
||||
}
|
||||
|
||||
// ParseArch extracts the architecture from a package name if present.
|
||||
func (p *Pkg) ParseArch(name string) (string, string) {
|
||||
return parseArchNormalize(name)
|
||||
}
|
||||
|
||||
// Verify interface compliance at compile time.
|
||||
var _ snack.Manager = (*Pkg)(nil)
|
||||
var _ snack.PackageUpgrader = (*Pkg)(nil)
|
||||
|
||||
@@ -659,8 +659,8 @@ func TestCapabilities(t *testing.T) {
|
||||
if caps.Groups {
|
||||
t.Error("expected Groups=false")
|
||||
}
|
||||
if caps.NameNormalize {
|
||||
t.Error("expected NameNormalize=false")
|
||||
if !caps.NameNormalize {
|
||||
t.Error("expected NameNormalize=true")
|
||||
}
|
||||
if caps.DryRun {
|
||||
t.Error("expected DryRun=false")
|
||||
|
||||
Reference in New Issue
Block a user