upgrade deps
This commit is contained in:
parent
fefcc6ab6f
commit
677200c340
8 changed files with 149 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ require (
|
|||
entgo.io/ent v0.14.1
|
||||
github.com/go-chi/chi/v5 v5.1.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,10 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
|
|||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f h1:A4MEslfWXKvqsZt1DbvZpguzVAbyjCRclEZNt6TjSRw=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286 h1:254AqceggeJ0yLXUud3IiYfNjRnetfgcyuCVIlDtgbc=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.1.0 h1:bWMPlCCuoW2Fa++YUk7yhpRLHyU3d5GcvQ0gp+bDO+g=
|
||||
github.com/maddalax/htmgo/framework v0.1.0/go.mod h1:TA7KCaKhurpXceQrzClJOHqRsUSd5NL64ZngSg+I3oc=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module github.com/maddalax/htmgo/framework-ui
|
|||
|
||||
go 1.23.0
|
||||
|
||||
require github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f
|
||||
require github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286
|
||||
|
||||
require (
|
||||
github.com/go-chi/chi/v5 v5.1.0 // indirect
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ go 1.23.0
|
|||
require (
|
||||
github.com/go-chi/chi/v5 v5.1.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286
|
||||
github.com/yuin/goldmark v1.7.4
|
||||
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
|
||||
)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f h1:A4MEslfWXKvqsZt1DbvZpguzVAbyjCRclEZNt6TjSRw=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286 h1:254AqceggeJ0yLXUud3IiYfNjRnetfgcyuCVIlDtgbc=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.1.0 h1:bWMPlCCuoW2Fa++YUk7yhpRLHyU3d5GcvQ0gp+bDO+g=
|
||||
github.com/maddalax/htmgo/framework v0.1.0/go.mod h1:TA7KCaKhurpXceQrzClJOHqRsUSd5NL64ZngSg+I3oc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ go 1.23.0
|
|||
|
||||
require (
|
||||
github.com/go-chi/chi/v5 v5.1.0
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286
|
||||
)
|
||||
|
||||
require github.com/google/uuid v1.6.0 // indirect
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
|||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f h1:A4MEslfWXKvqsZt1DbvZpguzVAbyjCRclEZNt6TjSRw=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926194146-5bbd35d2728f/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286 h1:254AqceggeJ0yLXUud3IiYfNjRnetfgcyuCVIlDtgbc=
|
||||
github.com/maddalax/htmgo/framework v0.0.0-20240926195523-4d003b6db286/go.mod h1:JBHqkKSv6frIsSlT1itIU0hUTW9NgDcyM6Cf6npK0bQ=
|
||||
github.com/maddalax/htmgo/framework v0.1.0 h1:bWMPlCCuoW2Fa++YUk7yhpRLHyU3d5GcvQ0gp+bDO+g=
|
||||
github.com/maddalax/htmgo/framework v0.1.0/go.mod h1:TA7KCaKhurpXceQrzClJOHqRsUSd5NL64ZngSg+I3oc=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
|
|
|
|||
133
tools/update-htmgo-dep.go
Normal file
133
tools/update-htmgo-dep.go
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const frameworkRepo = "github.com/maddalax/htmgo/framework"
|
||||
const githubAPIURL = "https://api.github.com/repos/maddalax/htmgo/commits"
|
||||
|
||||
// Commit represents the structure of a commit object returned by the GitHub API.
|
||||
type Commit struct {
|
||||
Sha string `json:"sha"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Get the latest commit hash from the remote repository.
|
||||
latestCommitHash, err := getLatestCommitHash()
|
||||
if err != nil {
|
||||
fmt.Println("Error getting latest commit hash:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Start from the current directory.
|
||||
rootDir, err := os.Getwd()
|
||||
if err != nil {
|
||||
fmt.Println("Error getting working directory:", err)
|
||||
return
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
// Walk through directories.
|
||||
err = filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if the directory contains a go.mod file.
|
||||
if info.IsDir() && fileExists(filepath.Join(path, "go.mod")) {
|
||||
// Check if the go.mod contains 'github.com/maddalax/htmgo/framework'.
|
||||
if containsFrameworkDependency(filepath.Join(path, "go.mod")) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
// Run go get github.com/maddalax/htmgo/framework@<latestCommitHash>.
|
||||
fmt.Printf("Running 'go get' with latest commit hash in %s\n", path)
|
||||
cmd := exec.Command("go", "get", fmt.Sprintf("%s@%s", frameworkRepo, latestCommitHash))
|
||||
cmd.Dir = path // Set the working directory to the current path.
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
fmt.Println("Error running go get:", err)
|
||||
} else {
|
||||
fmt.Println("Updated framework in", path)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
wg.Wait()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error walking through directories:", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// fileExists checks if a file exists at the given path.
|
||||
func fileExists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return !os.IsNotExist(err)
|
||||
}
|
||||
|
||||
// containsFrameworkDependency checks if 'github.com/maddalax/htmgo/framework' is in the go.mod file.
|
||||
func containsFrameworkDependency(goModPath string) bool {
|
||||
file, err := os.Open(goModPath)
|
||||
if err != nil {
|
||||
fmt.Println("Error opening go.mod file:", err)
|
||||
return false
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
if strings.Contains(scanner.Text(), frameworkRepo) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
fmt.Println("Error reading go.mod file:", err)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// getLatestCommitHash fetches the latest commit hash from the GitHub API for the framework repository.
|
||||
func getLatestCommitHash() (string, error) {
|
||||
// Create an HTTP request to the GitHub API to get the latest commit.
|
||||
resp, err := http.Get(githubAPIURL)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to fetch latest commit: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// Check if the response status is OK.
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return "", fmt.Errorf("failed to fetch latest commit: status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
// Parse the JSON response.
|
||||
var commits []Commit
|
||||
if err := json.NewDecoder(resp.Body).Decode(&commits); err != nil {
|
||||
return "", fmt.Errorf("failed to decode JSON response: %v", err)
|
||||
}
|
||||
|
||||
if len(commits) == 0 {
|
||||
return "", fmt.Errorf("no commits found in repository")
|
||||
}
|
||||
|
||||
// Return the SHA of the latest commit.
|
||||
return commits[0].Sha, nil
|
||||
}
|
||||
Loading…
Reference in a new issue