- Create CLAUDE.md with package-specific conventions and commands - Replace fmt.Errorf with coreerr.E() in test mock (updater_test.go) - Replace os.ReadFile/os.WriteFile with go-io in build/main.go - Add unit tests for filterReleases, determineChannel, GetDownloadURL, formatVersionForDisplay, formatVersionForComparison, and default cases in startGitHubCheck/startHTTPCheck - All targeted functions now at 100% coverage Co-Authored-By: Virgil <virgil@lethean.io>
36 lines
880 B
Go
36 lines
880 B
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
coreio "forge.lthn.ai/core/go-io"
|
|
)
|
|
|
|
func main() {
|
|
// Read package.json
|
|
data, err := coreio.Read(coreio.Local, "package.json")
|
|
if err != nil {
|
|
fmt.Println("Error reading package.json, skipping version file generation.")
|
|
return
|
|
}
|
|
|
|
// Parse package.json
|
|
var pkg struct {
|
|
Version string `json:"version"`
|
|
}
|
|
if err := json.Unmarshal([]byte(data), &pkg); err != nil {
|
|
fmt.Println("Error parsing package.json, skipping version file generation.")
|
|
return
|
|
}
|
|
|
|
// Create the version file
|
|
content := fmt.Sprintf("package updater\n\n// Generated by go:generate. DO NOT EDIT.\n\nconst PkgVersion = %q\n", pkg.Version)
|
|
err = coreio.Write(coreio.Local, "version.go", content)
|
|
if err != nil {
|
|
fmt.Printf("Error writing version file: %v\n", err)
|
|
return
|
|
}
|
|
|
|
fmt.Println("Generated version.go with version:", pkg.Version)
|
|
}
|