Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # watcher/cmd.go
This commit is contained in:
commit
98b9680984
72
realize.go
72
realize.go
|
@ -118,7 +118,7 @@ func main() {
|
|||
if err := r.Record(r); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(prefix(style.Green.Bold("Your project was successfully added.")))
|
||||
fmt.Fprintln(style.Output,prefix(style.Green.Bold("Your project was successfully added.")))
|
||||
return nil
|
||||
},
|
||||
Before: before,
|
||||
|
@ -158,10 +158,7 @@ func main() {
|
|||
Create: true,
|
||||
},
|
||||
Resources: settings.Resources{
|
||||
Config: config,
|
||||
Outputs: outputs,
|
||||
Logs: logs,
|
||||
Errors: errs,
|
||||
Config: config,
|
||||
},
|
||||
Server: settings.Server{
|
||||
Status: false,
|
||||
|
@ -751,60 +748,6 @@ func main() {
|
|||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Before: func(d interact.Context) error {
|
||||
d.SetDef(false, style.Green.Regular("(n)"))
|
||||
return nil
|
||||
},
|
||||
Quest: interact.Quest{
|
||||
Options: style.Yellow.Regular("[y/n]"),
|
||||
Msg: "Enable file output history",
|
||||
},
|
||||
Action: func(d interact.Context) interface{} {
|
||||
val, err := d.Ans().Bool()
|
||||
if err != nil {
|
||||
return d.Err()
|
||||
}
|
||||
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Streams.FileOut = val
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Before: func(d interact.Context) error {
|
||||
d.SetDef(false, style.Green.Regular("(n)"))
|
||||
return nil
|
||||
},
|
||||
Quest: interact.Quest{
|
||||
Options: style.Yellow.Regular("[y/n]"),
|
||||
Msg: "Enable file logs history",
|
||||
},
|
||||
Action: func(d interact.Context) interface{} {
|
||||
val, err := d.Ans().Bool()
|
||||
if err != nil {
|
||||
return d.Err()
|
||||
}
|
||||
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Streams.FileLog = val
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Before: func(d interact.Context) error {
|
||||
d.SetDef(false, style.Green.Regular("(n)"))
|
||||
return nil
|
||||
},
|
||||
Quest: interact.Quest{
|
||||
Options: style.Yellow.Regular("[y/n]"),
|
||||
Msg: "Enable file errors history",
|
||||
},
|
||||
Action: func(d interact.Context) interface{} {
|
||||
val, err := d.Ans().Bool()
|
||||
if err != nil {
|
||||
return d.Err()
|
||||
}
|
||||
r.Blueprint.Projects[len(r.Blueprint.Projects)-1].Streams.FileErr = val
|
||||
return nil
|
||||
},
|
||||
},
|
||||
{
|
||||
Before: func(d interact.Context) error {
|
||||
d.SetDef("", style.Green.Regular("(none)"))
|
||||
|
@ -847,7 +790,7 @@ func main() {
|
|||
if err := r.Record(r); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(prefix(style.Green.Bold("Your configuration was successful.")))
|
||||
fmt.Fprintln(style.Output,prefix(style.Green.Bold("Your configuration was successful.")))
|
||||
return nil
|
||||
},
|
||||
Before: before,
|
||||
|
@ -867,7 +810,7 @@ func main() {
|
|||
if err := r.Record(r); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(prefix(style.Green.Bold("Your project was successfully removed.")))
|
||||
fmt.Fprintln(style.Output,prefix(style.Green.Bold("Your project was successfully removed.")))
|
||||
return nil
|
||||
},
|
||||
Before: before,
|
||||
|
@ -891,7 +834,7 @@ func main() {
|
|||
if err := r.Settings.Remove(directory); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(prefix(style.Green.Bold("Realize folder successfully removed.")))
|
||||
fmt.Fprintln(style.Output,prefix(style.Green.Bold("Realize folder successfully removed.")))
|
||||
return nil
|
||||
},
|
||||
Before: before,
|
||||
|
@ -926,10 +869,7 @@ func before(*cli.Context) error {
|
|||
Create: true,
|
||||
},
|
||||
Resources: settings.Resources{
|
||||
Config: config,
|
||||
Outputs: outputs,
|
||||
Logs: logs,
|
||||
Errors: errs,
|
||||
Config: config,
|
||||
},
|
||||
Server: settings.Server{
|
||||
Status: false,
|
||||
|
|
|
@ -22,3 +22,7 @@ var (
|
|||
Magenta = colorBase(color.FgMagenta)
|
||||
Green = colorBase(color.FgGreen)
|
||||
)
|
||||
|
||||
// Output defines the standard output of the print functions. By default, os.Stdout is used.
|
||||
// When invoked on Windows machines, this automatically handles escape sequences.
|
||||
var Output = color.Output
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Run launches the toolchain for each project
|
||||
|
@ -28,8 +27,8 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
|||
if element.Cmds.Fmt {
|
||||
h.Projects[k].tools.Fmt = tool{
|
||||
status: &h.Projects[k].Cmds.Fmt,
|
||||
cmd: "go",
|
||||
options: []string{"fmt"},
|
||||
cmd: "gofmt",
|
||||
options: []string{"-s", "-w", "-e"},
|
||||
name: "Go Fmt",
|
||||
}
|
||||
}
|
||||
|
@ -66,23 +65,6 @@ func (h *Blueprint) Run(p *cli.Context) error {
|
|||
h.Projects[k].Buffer.StdErr = append(h.Projects[k].Buffer.StdErr, BufferOut{Time: time.Now(), Text: err.Error(), Type: "Env error", Stream: ""})
|
||||
}
|
||||
}
|
||||
|
||||
// base path
|
||||
wd, err := os.Getwd()
|
||||
if err != nil{
|
||||
return err
|
||||
}
|
||||
if element.path == "." || element.path == "/" {
|
||||
h.Projects[k].base = wd
|
||||
h.Projects[k].path = element.Wdir()
|
||||
} else if filepath.IsAbs(element.path) {
|
||||
h.Projects[k].base = element.path
|
||||
} else {
|
||||
h.Projects[k].base = filepath.Join(wd, element.path)
|
||||
}
|
||||
|
||||
println(h.Projects[k].base)
|
||||
// watch
|
||||
if h.Legacy.Status {
|
||||
go h.Projects[k].watchByPolling()
|
||||
} else {
|
||||
|
@ -155,44 +137,48 @@ func (h *Blueprint) List() error {
|
|||
err := h.check()
|
||||
if err == nil {
|
||||
for _, val := range h.Projects {
|
||||
fmt.Println(style.Blue.Bold("[") + strings.ToUpper(val.Name) + style.Blue.Bold("]"))
|
||||
fmt.Fprintln(style.Output, style.Blue.Bold("[")+strings.ToUpper(val.Name)+style.Blue.Bold("]"))
|
||||
name := style.Magenta.Bold("[") + strings.ToUpper(val.Name) + style.Magenta.Bold("]")
|
||||
|
||||
fmt.Println(name, style.Yellow.Regular("Base Path"), ":", style.Magenta.Regular(val.Path))
|
||||
fmt.Println(name, style.Yellow.Regular("Fmt"), ":", style.Magenta.Regular(val.Cmds.Fmt))
|
||||
fmt.Println(name, style.Yellow.Regular("Generate"), ":", style.Magenta.Regular(val.Cmds.Generate))
|
||||
fmt.Println(name, style.Yellow.Regular("Test"), ":", style.Magenta.Regular(val.Cmds.Test))
|
||||
fmt.Println(name, style.Yellow.Regular("Install"), ":", style.Magenta.Regular(val.Cmds.Bin))
|
||||
fmt.Println(name, style.Yellow.Regular("Build"), ":", style.Magenta.Regular(val.Cmds.Build))
|
||||
fmt.Println(name, style.Yellow.Regular("Run"), ":", style.Magenta.Regular(val.Cmds.Run))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Base Path"), ":", style.Magenta.Regular(val.Path))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Fmt"), ":", style.Magenta.Regular(val.Cmds.Fmt))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Generate"), ":", style.Magenta.Regular(val.Cmds.Generate))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Test"), ":", style.Magenta.Regular(val.Cmds.Test))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Install"), ":", style.Magenta.Regular(val.Cmds.Bin))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Build"), ":", style.Magenta.Regular(val.Cmds.Build))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Run"), ":", style.Magenta.Regular(val.Cmds.Run))
|
||||
if len(val.Args) > 0 {
|
||||
fmt.Println(name, style.Yellow.Regular("Params"), ":", style.Magenta.Regular(val.Args))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Params"), ":", style.Magenta.Regular(val.Args))
|
||||
}
|
||||
fmt.Println(name, style.Yellow.Regular("Watcher"), ":")
|
||||
fmt.Println(name, "\t", style.Yellow.Regular("Preview"), ":", style.Magenta.Regular(val.Watcher.Preview))
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Watcher"), ":")
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("Preview"), ":", style.Magenta.Regular(val.Watcher.Preview))
|
||||
if len(val.Watcher.Exts) > 0 {
|
||||
fmt.Println(name, "\t", style.Yellow.Regular("Extensions"), ":", style.Magenta.Regular(val.Watcher.Exts))
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("Extensions"), ":", style.Magenta.Regular(val.Watcher.Exts))
|
||||
}
|
||||
if len(val.Watcher.Paths) > 0 {
|
||||
fmt.Println(name, "\t", style.Yellow.Regular("Paths"), ":", style.Magenta.Regular(val.Watcher.Paths))
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("Paths"), ":", style.Magenta.Regular(val.Watcher.Paths))
|
||||
}
|
||||
if len(val.Watcher.Ignore) > 0 {
|
||||
fmt.Println(name, "\t", style.Yellow.Regular("Ignored paths"), ":", style.Magenta.Regular(val.Watcher.Ignore))
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("Ignored paths"), ":", style.Magenta.Regular(val.Watcher.Ignore))
|
||||
}
|
||||
if len(val.Watcher.Scripts) > 0 {
|
||||
fmt.Println(name, "\t", style.Yellow.Regular("Scripts"), ":")
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("Scripts"), ":")
|
||||
for _, v := range val.Watcher.Scripts {
|
||||
if v.Command != "" {
|
||||
fmt.Println(name, "\t\t", style.Magenta.Regular("-"), style.Yellow.Regular("Command"), ":", style.Magenta.Regular(v.Command))
|
||||
fmt.Fprintln(style.Output, name, "\t\t", style.Magenta.Regular("-"), style.Yellow.Regular("Command"), ":", style.Magenta.Regular(v.Command))
|
||||
if v.Path != "" {
|
||||
fmt.Println(name, "\t\t", style.Yellow.Regular("Path"), ":", style.Magenta.Regular(v.Path))
|
||||
fmt.Fprintln(style.Output, name, "\t\t", style.Yellow.Regular("Path"), ":", style.Magenta.Regular(v.Path))
|
||||
}
|
||||
if v.Type != "" {
|
||||
fmt.Println(name, "\t\t", style.Yellow.Regular("Type"), ":", style.Magenta.Regular(v.Type))
|
||||
fmt.Fprintln(style.Output, name, "\t\t", style.Yellow.Regular("Type"), ":", style.Magenta.Regular(v.Type))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Fprintln(style.Output, name, style.Yellow.Regular("Streams"), ":")
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("File Out"), ":", style.Magenta.Regular(val.Streams.FileOut))
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("File Log"), ":", style.Magenta.Regular(val.Streams.FileLog))
|
||||
fmt.Fprintln(style.Output, name, "\t", style.Yellow.Regular("File Err"), ":", style.Magenta.Regular(val.Streams.FileErr))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func inArray(str string, list []string) bool {
|
|||
|
||||
// Rewrite the layout of the log timestamp
|
||||
func (w logWriter) Write(bytes []byte) (int, error) {
|
||||
return fmt.Print(style.Yellow.Regular("[") + time.Now().Format("15:04:05") + style.Yellow.Regular("]") + string(bytes))
|
||||
return fmt.Fprint(style.Output, style.Yellow.Regular("[")+time.Now().Format("15:04:05")+style.Yellow.Regular("]")+string(bytes))
|
||||
}
|
||||
|
||||
// getEnvPath returns the first path found in env or empty string
|
||||
|
|
|
@ -405,7 +405,7 @@ func (p *Project) stamp(t string, o BufferOut, msg string, stream string) {
|
|||
log.Print(msg)
|
||||
}
|
||||
if stream != "" {
|
||||
fmt.Print(stream)
|
||||
fmt.Fprint(style.Output, stream)
|
||||
}
|
||||
go func() {
|
||||
p.parent.Sync <- "sync"
|
||||
|
|
Loading…
Reference in New Issue