2025-02-22 06:52:40 -06:00
|
|
|
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by the GPL 3.0
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
// An app to submit patches for the 30 GO GUI repos
|
|
|
|
|
|
|
|
import (
|
2025-02-22 09:42:49 -06:00
|
|
|
"os"
|
|
|
|
|
2025-02-22 06:52:40 -06:00
|
|
|
"go.wit.com/lib/fhelp"
|
|
|
|
"go.wit.com/lib/gui/shell"
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2025-02-23 18:55:55 -06:00
|
|
|
func makeHowtoWin() *GenericWindow {
|
|
|
|
howtoWin := NewGenericWindow("Howto", "forge -- a GUI tool for git repostories")
|
2025-02-22 06:52:40 -06:00
|
|
|
tmp := `A good way to see how forge works is to download forge
|
|
|
|
|
|
|
|
This will 'git clone' a few things (~50 repos):
|
|
|
|
`
|
2025-02-23 18:55:55 -06:00
|
|
|
howtoWin.Group.NewLabel(tmp)
|
|
|
|
grid := howtoWin.Group.RawGrid()
|
2025-02-22 06:52:40 -06:00
|
|
|
grid.NewLabel("forge")
|
|
|
|
grid.NewLabel("the sources for forge")
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewLabel("autogenpb")
|
|
|
|
grid.NewLabel("generates needed code for working with the protobuf files")
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewLabel("go-clone")
|
|
|
|
grid.NewLabel("recursively 'git clone' dependencies based on go.mod")
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewLabel("the GUI")
|
|
|
|
grid.NewLabel("GO plugins for libcurses and GTK")
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewLabel("") // a stupid way to add padding
|
|
|
|
grid.NextRow()
|
|
|
|
|
2025-02-23 18:55:55 -06:00
|
|
|
howtoWin.Group.NewLabel("Working dir: " + me.forge.GetGoSrc())
|
|
|
|
grid = howtoWin.Group.RawGrid()
|
2025-02-22 06:52:40 -06:00
|
|
|
grid.NewButton("Download", func() {
|
|
|
|
howtoWin.Disable()
|
|
|
|
defer howtoWin.Enable()
|
2025-02-22 09:42:49 -06:00
|
|
|
buildForge()
|
|
|
|
})
|
|
|
|
return howtoWin
|
|
|
|
}
|
2025-02-22 06:52:40 -06:00
|
|
|
|
2025-02-22 09:42:49 -06:00
|
|
|
func buildForge() {
|
|
|
|
log.Info("download here")
|
|
|
|
if path, err := fhelp.CheckCmd("go-clone"); err != nil {
|
|
|
|
log.Info("go-clone missing", path, err)
|
|
|
|
cmd := []string{"go", "install", "go.wit.com/apps/go-clone@latest"}
|
2025-02-22 06:52:40 -06:00
|
|
|
shell.RunRealtime(cmd)
|
2025-02-22 09:42:49 -06:00
|
|
|
}
|
|
|
|
if _, err := fhelp.CheckCmd("autogenpb"); err != nil {
|
|
|
|
cmd := []string{"go", "install", "go.wit.com/apps/autogenpb@latest"}
|
2025-02-22 06:52:40 -06:00
|
|
|
shell.RunRealtime(cmd)
|
2025-02-22 09:42:49 -06:00
|
|
|
}
|
|
|
|
if _, err := fhelp.CheckCmd("go-mod-clean"); err != nil {
|
|
|
|
cmd := []string{"go", "install", "go.wit.com/apps/go-mod-clean@latest"}
|
2025-02-22 06:52:40 -06:00
|
|
|
shell.RunRealtime(cmd)
|
2025-02-22 09:42:49 -06:00
|
|
|
}
|
|
|
|
if path, err := fhelp.CheckCmd("go-clone"); err != nil {
|
|
|
|
log.Info("can't prep build. you probably need ~/go/bin in your PATH", path, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var basecmd []string
|
|
|
|
var cmd []string
|
|
|
|
if me.forge.IsGoWork() {
|
|
|
|
log.Info("Using go.work directory")
|
|
|
|
basecmd = []string{"go-clone", "--work", "--recursive"}
|
|
|
|
} else {
|
|
|
|
basecmd = []string{"go-clone", "--recursive"}
|
|
|
|
}
|
|
|
|
// log.Info("Running:", cmd)
|
|
|
|
// shell.RunRealtime(cmd)
|
2025-02-22 06:52:40 -06:00
|
|
|
|
2025-02-22 09:42:49 -06:00
|
|
|
cmd = append(basecmd, "go.wit.com/apps/go-mod-clean")
|
|
|
|
log.Info("Running:", cmd)
|
|
|
|
shell.RunRealtime(cmd)
|
|
|
|
os.Exit(-1)
|
2025-02-22 07:59:19 -06:00
|
|
|
|
2025-02-22 09:42:49 -06:00
|
|
|
cmd = append(basecmd, "go.wit.com/apps/forge")
|
|
|
|
log.Info("Running:", cmd)
|
|
|
|
shell.RunRealtime(cmd)
|
|
|
|
|
|
|
|
cmd = append(basecmd, "go.wit.com/toolkits/gocui")
|
|
|
|
log.Info("Running:", cmd)
|
|
|
|
shell.RunRealtime(cmd)
|
|
|
|
|
|
|
|
cmd = append(basecmd, "go.wit.com/toolkits/andlabs")
|
|
|
|
log.Info("Running:", cmd)
|
|
|
|
shell.RunRealtime(cmd)
|
|
|
|
|
|
|
|
// should, after go-clone, be able to go build
|
|
|
|
/*
|
|
|
|
repo := me.forge.FindByGoPath("go.wit.com/lib/proto/forgepb")
|
|
|
|
if repo != nil {
|
|
|
|
repo.RunVerbose([]string{"autogenpb"})
|
|
|
|
}
|
|
|
|
*/
|
2025-02-22 06:52:40 -06:00
|
|
|
}
|