Skip to content

Commit

Permalink
clone cmd implemented, merge utl/yagu, bugfixes, some other minor adds
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed May 24, 2020
1 parent 472129b commit 6512e9c
Show file tree
Hide file tree
Showing 45 changed files with 206 additions and 1,247 deletions.
3 changes: 1 addition & 2 deletions .hof/shadow/Config/gen/cuefig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadConfigConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Config file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions .hof/shadow/Context/gen/cuefig/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadContextConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Context file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions .hof/shadow/Secret/gen/cuefig/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadSecretConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Secret file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions .hof/shadow/UserConfig/gen/cuefig/hofcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofcfgConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofcfg file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions .hof/shadow/UserContext/gen/cuefig/hofctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofctxConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofctx file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions .hof/shadow/UserSecret/gen/cuefig/hofshh.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofshhConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofshh file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadConfigConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Config file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadContextConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Context file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/hofcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofcfgConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofcfg file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/hofctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofctxConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofctx file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/hofshh.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadHofshhConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Hofshh file: %q", fpath)
}
Expand Down
3 changes: 1 addition & 2 deletions gen/cuefig/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"cuelang.org/go/cue/load"
"github.com/kirsle/configdir"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

Expand Down Expand Up @@ -146,7 +145,7 @@ func LoadSecretConfig(workpath, entrypoint string) (val cue.Value, err error) {

if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return val, fmt.Errorf("Errors while reading Secret file: %q", fpath)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/kr/pretty v0.1.0
github.com/mattn/go-zglob v0.0.1
github.com/mholt/archiver v3.1.1+incompatible
github.com/mholt/archiver v3.1.1+incompatible // indirect
github.com/naoina/toml v0.1.1
github.com/parnurzeal/gorequest v0.2.16
github.com/sergi/go-diff v1.1.0
Expand All @@ -34,7 +34,7 @@ require (
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200428200454-593003d681fa // indirect
golang.org/x/text v0.3.2
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
)
Expand Down
10 changes: 5 additions & 5 deletions lib/extern/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"strings"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

func ImportAddBundle(bundle string) (string, error) {
Expand All @@ -25,24 +25,24 @@ func ImportAddBundle(bundle string) (string, error) {
}

func cloneAndRenderImport(srcUrl, srcVer, srcPath string) error {
_, appname := util.GetAcctAndName()
_, appname := yagu.GetAcctAndName()
data := map[string]interface{}{
"AppName": appname,
}

dir, err := util.CloneRepo(srcUrl, srcVer)
dir, err := yagu.CloneRepo(srcUrl, srcVer)
if err != nil {
return err
}

err = util.RenderDir(filepath.Join(dir, srcPath, "design"), "design-vendor", data)
err = yagu.RenderDir(filepath.Join(dir, srcPath, "design"), "design-vendor", data)
if err != nil {
return err
}

if _, err := os.Stat(filepath.Join(dir, srcPath, "design-vendor")); !os.IsNotExist(err) {
// path exists
err = util.RenderDir(filepath.Join(dir, srcPath, "design-vendor"), "design-vendor", data)
err = yagu.RenderDir(filepath.Join(dir, srcPath, "design-vendor"), "design-vendor", data)
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions lib/extern/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/hofstadter-io/data-utils/io"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

func NewEntry(what, name, template, strData string) (string, error) {
Expand Down Expand Up @@ -59,7 +59,7 @@ func NewEntry(what, name, template, strData string) (string, error) {
}

// Prep contextual data
_, appname := util.GetAcctAndName()
_, appname := yagu.GetAcctAndName()
data["AppName"] = appname

// A bit hacky
Expand Down Expand Up @@ -128,7 +128,7 @@ func cloneAndRenderNewThing(srcUrl, srcVer, srcSubpath, destBasePath, name strin
var dir string

if strings.HasPrefix(srcUrl, "https") {
dir, err = util.CloneRepo(srcUrl, srcVer)
dir, err = yagu.CloneRepo(srcUrl, srcVer)
if err != nil {
return err
}
Expand All @@ -137,13 +137,13 @@ func cloneAndRenderNewThing(srcUrl, srcVer, srcSubpath, destBasePath, name strin
dir = srcUrl
}

err = util.RenderDirNameSub(filepath.Join(dir, srcSubpath, "design"), destBasePath, data)
err = yagu.RenderDirNameSub(filepath.Join(dir, srcSubpath, "design"), destBasePath, data)
if err != nil {
return err
}
if _, err := os.Stat(filepath.Join(dir, srcSubpath, "design-vendor")); !os.IsNotExist(err) {
// path exists
err = util.RenderDirNameSub(filepath.Join(dir, srcSubpath, "design-vendor"), destBasePath, data)
err = yagu.RenderDirNameSub(filepath.Join(dir, srcSubpath, "design-vendor"), destBasePath, data)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions lib/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"time"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

func Gen(entrypoints, expressions []string, mode string) (error) {
Expand All @@ -17,15 +17,15 @@ func Gen(entrypoints, expressions []string, mode string) (error) {
errs = R.LoadCue()
if len(errs) > 0 {
for _, e := range errs {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return fmt.Errorf("\nErrors while loading cue files\n")
}

errsL := R.LoadGenerators()
if len(errsL) > 0 {
for _, e := range errsL {
util.PrintCueError(e)
yagu.PrintCueError(e)
}
return fmt.Errorf("\nErrors while loading generators\n")
}
Expand Down
6 changes: 3 additions & 3 deletions lib/gen/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"path"

"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

func (F *File) WriteOutput() error {
Expand All @@ -13,7 +13,7 @@ func (F *File) WriteOutput() error {
// fmt.Println("WriteFile:", F.Filepath)
// fmt.Printf("%#+v\n\n", F)

err = util.Mkdir(path.Join(F.Filepath))
err = yagu.Mkdir(path.Join(F.Filepath))
if err != nil {
return err
}
Expand All @@ -33,7 +33,7 @@ func (F *File) WriteShadow(basedir string) error {

fn := path.Join(basedir, F.Filepath)

err = util.Mkdir(fn)
err = yagu.Mkdir(fn)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions lib/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/mattn/go-zglob"

"github.com/hofstadter-io/hof/lib/gen"
"github.com/hofstadter-io/hof/lib/util"
"github.com/hofstadter-io/hof/lib/yagu"
)

type Runtime struct {
Expand Down Expand Up @@ -245,15 +245,15 @@ func (R *Runtime) WriteOutput() []error {
// TODO, make comparison and decide to write or not

// normal location
err := util.CopyFile(src, dst)
err := yagu.CopyFile(src, dst)
if err != nil {
err = fmt.Errorf("while copying static real file %q\n%w\n", match, err)
errs = append(errs, err)
continue
}

// shadow location
err = util.CopyFile(src, path.Join(".hof", G.Name, dst))
err = yagu.CopyFile(src, path.Join(".hof", G.Name, dst))
if err != nil {
err = fmt.Errorf("while copying static shadow file %q\n%w\n", match, err)
errs = append(errs, err)
Expand Down

0 comments on commit 6512e9c

Please sign in to comment.