bold-brew/internal/models/package.go
Vito Castellano 6c80585431
chore: release version 2.0.0 - Cask support and XDG compliance (#30)
* feat: add leaves filter to show explicitly installed packages (#25)

Add new filter [L] to display only "leaf" packages - those installed
explicitly by the user and not as dependencies of other packages.

* refactor: Migrate to Podman with OCI Containerfile and enhanced Makefile (#26)

* refactor: migrate from Docker to Podman with OCI Containerfile

Replace Docker with Podman for better security and OCI compliance.
Switch from Dockerfile to standard Containerfile format.

* chore: upgrade Go from 1.24 to 1.25

Update Go version to 1.25 to support latest goreleaser v2 and benefit from improved performance and language features.

* refactor: migrate to Podman and enhance Makefile

Replace Docker with Podman and upgrade Makefile with help system and new developer-friendly targets.

* chore: upgrade to Go 1.25 and golangci-lint v2.5.0

Update Go to 1.25 and golangci-lint to v2.5.0 for better tooling support.

* feat: add security scanning with govulncheck and gosec (#27)

Add comprehensive security scanning to the project with vulnerability checks and static analysis tools.

* feat: Add complete Casks support with unified UI (#28)

* feat(cask): add backend support for Homebrew casks

Implement complete backend infrastructure for managing Homebrew casks alongside formulae, preparing for unified UI.

* feat(cask): add complete Homebrew casks support with unified UI

Implement full backend and UI support for managing Homebrew casks alongside formulae in a unified interface.

* fix(cask): parse cask analytics correctly

Fix cask analytics not being displayed (showing 0 for all casks).

* feat(cask): add complete Homebrew casks support with unified UI

Implement full backend and UI support for managing Homebrew casks alongside formulae in a unified interface.

* fix: create copy to avoid implicit memory aliasing

* feat: implement XDG Base Directory Specification with github.com/adrg/xdg (#29)

Implement XDG Base Directory Specification using the github.com/adrg/xdg package for robust cross-platform support.
2025-10-13 21:26:18 +02:00

79 lines
2.5 KiB
Go

package models
// PackageType distinguishes between formulae and casks.
type PackageType string
const (
PackageTypeFormula PackageType = "formula"
PackageTypeCask PackageType = "cask"
)
// Package represents a unified view of both Formula and Cask for UI display.
type Package struct {
// Common fields
Name string // Formula.Name or Cask.Token
DisplayName string // Formula.FullName or Cask.Name[0]
Description string // desc
Homepage string // homepage
Version string // versions.stable or version
LocallyInstalled bool // Is installed locally
Outdated bool // Needs update
Type PackageType // formula or cask
Analytics90dRank int
Analytics90dDownloads int
// Original data (for operations)
Formula *Formula `json:"-"` // nil if Type == cask
Cask *Cask `json:"-"` // nil if Type == formula
// For leaves filter (only meaningful for formulae)
InstalledOnRequest bool
}
// NewPackageFromFormula creates a Package from a Formula.
func NewPackageFromFormula(f *Formula) Package {
installedOnRequest := false
if len(f.Installed) > 0 {
installedOnRequest = f.Installed[0].InstalledOnRequest
}
return Package{
Name: f.Name,
DisplayName: f.FullName,
Description: f.Description,
Homepage: f.Homepage,
Version: f.Versions.Stable,
LocallyInstalled: f.LocallyInstalled,
Outdated: f.Outdated,
Type: PackageTypeFormula,
Analytics90dRank: f.Analytics90dRank,
Analytics90dDownloads: f.Analytics90dDownloads,
Formula: f,
Cask: nil,
InstalledOnRequest: installedOnRequest,
}
}
// NewPackageFromCask creates a Package from a Cask.
func NewPackageFromCask(c *Cask) Package {
displayName := c.Token
if len(c.Name) > 0 {
displayName = c.Name[0]
}
return Package{
Name: c.Token,
DisplayName: displayName,
Description: c.Description,
Homepage: c.Homepage,
Version: c.Version,
LocallyInstalled: c.LocallyInstalled,
Outdated: c.Outdated,
Type: PackageTypeCask,
Analytics90dRank: c.Analytics90dRank,
Analytics90dDownloads: c.Analytics90dDownloads,
Formula: nil,
Cask: c,
InstalledOnRequest: true, // Casks are always explicitly installed
}
}