ficsit-cli-flake/cli/lockfile.go

55 lines
1 KiB
Go
Raw Normal View History

2022-04-14 01:27:39 +00:00
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"`
}
2022-04-14 01:27:39 +00:00
type LockedMod struct {
Dependencies map[string]string `json:"dependencies"`
Targets map[string]LockedModTarget `json:"targets"`
Version string `json:"version"`
2022-04-14 01:27:39 +00:00
}
2022-05-02 20:07:15 +00:00
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
2022-05-02 20:07:15 +00:00
}
return lockFile
}
func (l *LockFile) Remove(modID ...string) *LockFile {
for _, s := range modID {
delete(l.Mods, s)
}
return l
}