ficsit-cli-flake/cli/lockfile.go
Vilsol 5f2e60a9e2
feat: multi targets (#44)
* feat: use mod version targets

* chore: lint

* chore: remove unused

* chore: target dev on ci

* fix: rename WindowsNoEditor target to Windows
fix: close file reader

* fix: ensure closure of downloaded mod

* fix: ensure all important events are sent

* fix: lock adding files to cache

---------

Co-authored-by: mircearoata <mircearoatapalade@gmail.com>
2023-12-07 18:57:31 +02:00

54 lines
1 KiB
Go

package cli
type LockfileVersion int
const (
InitialLockfileVersion = LockfileVersion(iota)
ModTargetsLockfileVersion
// Always last
nextLockfileVersion
CurrentLockfileVersion = nextLockfileVersion - 1
)
type LockFile struct {
Mods map[string]LockedMod `json:"mods"`
Version LockfileVersion `json:"version"`
}
type LockedMod struct {
Dependencies map[string]string `json:"dependencies"`
Targets map[string]LockedModTarget `json:"targets"`
Version string `json:"version"`
}
type LockedModTarget struct {
Hash string `json:"hash"`
Link string `json:"link"`
}
func MakeLockfile() *LockFile {
return &LockFile{
Mods: make(map[string]LockedMod),
Version: CurrentLockfileVersion,
}
}
func (l *LockFile) Clone() *LockFile {
lockFile := &LockFile{
Mods: make(map[string]LockedMod),
Version: l.Version,
}
for k, v := range l.Mods {
lockFile.Mods[k] = v
}
return lockFile
}
func (l *LockFile) Remove(modID ...string) *LockFile {
for _, s := range modID {
delete(l.Mods, s)
}
return l
}