mirror of
https://github.com/gogrlx/snack.git
synced 2026-04-02 05:08:42 -07:00
- 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>
60 lines
1.6 KiB
Go
60 lines
1.6 KiB
Go
package ports
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gogrlx/snack"
|
|
)
|
|
|
|
// Compile-time interface checks.
|
|
var (
|
|
_ snack.VersionQuerier = (*Ports)(nil)
|
|
_ snack.Cleaner = (*Ports)(nil)
|
|
_ snack.FileOwner = (*Ports)(nil)
|
|
_ snack.NameNormalizer = (*Ports)(nil)
|
|
)
|
|
|
|
// LatestVersion returns the latest available version from configured repositories.
|
|
func (p *Ports) LatestVersion(ctx context.Context, pkg string) (string, error) {
|
|
return latestVersion(ctx, pkg)
|
|
}
|
|
|
|
// ListUpgrades returns packages that have newer versions available.
|
|
func (p *Ports) ListUpgrades(ctx context.Context) ([]snack.Package, error) {
|
|
return listUpgrades(ctx)
|
|
}
|
|
|
|
// UpgradeAvailable reports whether a newer version is available.
|
|
func (p *Ports) UpgradeAvailable(ctx context.Context, pkg string) (bool, error) {
|
|
return upgradeAvailable(ctx, pkg)
|
|
}
|
|
|
|
// VersionCmp compares two version strings.
|
|
func (p *Ports) VersionCmp(ctx context.Context, ver1, ver2 string) (int, error) {
|
|
return versionCmp(ctx, ver1, ver2)
|
|
}
|
|
|
|
// Autoremove removes packages that are no longer needed.
|
|
func (p *Ports) Autoremove(ctx context.Context, opts ...snack.Option) error {
|
|
p.Lock()
|
|
defer p.Unlock()
|
|
return autoremove(ctx, opts...)
|
|
}
|
|
|
|
// Clean removes cached package files.
|
|
func (p *Ports) Clean(ctx context.Context) error {
|
|
p.Lock()
|
|
defer p.Unlock()
|
|
return clean(ctx)
|
|
}
|
|
|
|
// FileList returns all files installed by a package.
|
|
func (p *Ports) FileList(ctx context.Context, pkg string) ([]string, error) {
|
|
return fileList(ctx, pkg)
|
|
}
|
|
|
|
// Owner returns the package that owns a given file path.
|
|
func (p *Ports) Owner(ctx context.Context, path string) (string, error) {
|
|
return owner(ctx, path)
|
|
}
|