logs and errors logic changed
This commit is contained in:
parent
838b68e84b
commit
d9b7435852
|
@ -15,8 +15,8 @@ const (
|
||||||
|
|
||||||
// Settings defines a group of general settings
|
// Settings defines a group of general settings
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
Config `yaml:",inline" json:"config"`
|
Config `yaml:"config" json:"config"`
|
||||||
Resources `yaml:"resources" json:"resources"`
|
Resources `yaml:"resources,omitempty" json:"resources,omitempty"`
|
||||||
Server `yaml:"server,omitempty" json:"server,omitempty"`
|
Server `yaml:"server,omitempty" json:"server,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +44,15 @@ type Server struct {
|
||||||
// Resources defines the files generated by realize
|
// Resources defines the files generated by realize
|
||||||
type Resources struct {
|
type Resources struct {
|
||||||
Config string `yaml:"-" json:"-"`
|
Config string `yaml:"-" json:"-"`
|
||||||
Outputs string `yaml:"outputs" json:"outputs"`
|
Outputs Resource `yaml:"outputs,omitempty" json:"outputs,omitempty"`
|
||||||
Logs string `yaml:"logs" json:"log"`
|
Logs Resource `yaml:"logs,omitempty" json:"log,omitempty"`
|
||||||
Errors string `yaml:"errors" json:"error"`
|
Errors Resource `yaml:"errors,omitempty" json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resource status and file name
|
||||||
|
type Resource struct {
|
||||||
|
Status bool
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read from config file
|
// Read from config file
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package watcher
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"github.com/tockins/realize/settings"
|
||||||
|
cli "gopkg.in/urfave/cli.v2"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestBlueprint_Run(t *testing.T) {
|
||||||
|
set := flag.NewFlagSet("test", 0)
|
||||||
|
params := cli.NewContext(nil, set, nil)
|
||||||
|
projects := Blueprint{}
|
||||||
|
projects.Settings = &settings.Settings{}
|
||||||
|
projects.Projects = []Project{
|
||||||
|
{
|
||||||
|
Name: "test1",
|
||||||
|
Path: ".",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "test1",
|
||||||
|
Path: ".",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "test2",
|
||||||
|
Path: ".",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
go projects.Run(params)
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBlueprint_Add(t *testing.T) {
|
||||||
|
projects := Blueprint{}
|
||||||
|
projects.Settings = &settings.Settings{}
|
||||||
|
// add all flags, test with expected
|
||||||
|
set := flag.NewFlagSet("test", 0)
|
||||||
|
set.String("name", "default_name", "doc")
|
||||||
|
set.String("path", "default_path", "doc")
|
||||||
|
params := cli.NewContext(nil, set, nil)
|
||||||
|
set.Parse([]string{"--name", "name", "name"})
|
||||||
|
set.Parse([]string{"--path", "path", "path"})
|
||||||
|
projects.Add(params)
|
||||||
|
}
|
|
@ -162,7 +162,7 @@ func (p *Project) goTools(dir string, name string, cmd ...string) (string, error
|
||||||
build.Stdout = &out
|
build.Stdout = &out
|
||||||
build.Stderr = &stderr
|
build.Stderr = &stderr
|
||||||
if err := build.Run(); err != nil {
|
if err := build.Run(); err != nil {
|
||||||
return stderr.String(), err
|
return stderr.String() + out.String(), err
|
||||||
}
|
}
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ type Project struct {
|
||||||
Cmds Cmds `yaml:"commands" json:"commands"`
|
Cmds Cmds `yaml:"commands" json:"commands"`
|
||||||
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
||||||
Watcher Watcher `yaml:"watcher" json:"watcher"`
|
Watcher Watcher `yaml:"watcher" json:"watcher"`
|
||||||
Streams Streams `yaml:"streams,omitempty" json:"streams,omitempty"`
|
|
||||||
Buffer Buffer `yaml:"-" json:"buffer"`
|
Buffer Buffer `yaml:"-" json:"buffer"`
|
||||||
ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"`
|
ErrorOutputPattern string `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"`
|
||||||
parent *Blueprint
|
parent *Blueprint
|
||||||
|
@ -61,26 +60,26 @@ type tool struct {
|
||||||
|
|
||||||
// Cmds go supported
|
// Cmds go supported
|
||||||
type Cmds struct {
|
type Cmds struct {
|
||||||
Vet bool `yaml:"vet" json:"vet"`
|
Vet bool `yaml:"vet,omitempty" json:"vet,omitempty"`
|
||||||
Fmt bool `yaml:"fmt" json:"fmt"`
|
Fmt bool `yaml:"fmt,omitempty" json:"fmt,omitempty"`
|
||||||
Test bool `yaml:"test" json:"test"`
|
Test bool `yaml:"test,omitempty" json:"test,omitempty"`
|
||||||
Generate bool `yaml:"generate" json:"generate"`
|
Generate bool `yaml:"generate,omitempty" json:"generate,omitempty"`
|
||||||
Bin Cmd `yaml:"bin" json:"bin"`
|
Bin Cmd `yaml:"bin" json:"bin"`
|
||||||
Build Cmd `yaml:"build" json:"build"`
|
Build Cmd `yaml:"build,omitempty" json:"build,omitempty"`
|
||||||
Run bool `yaml:"run" json:"run"`
|
Run bool `yaml:"run,omitempty" json:"run,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cmd buildmode options
|
// Cmd buildmode options
|
||||||
type Cmd struct {
|
type Cmd struct {
|
||||||
Status bool `yaml:"status" json:"status"`
|
Status bool `yaml:"status,omitempty" json:"status,omitempty"`
|
||||||
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
Args []string `yaml:"args,omitempty" json:"args,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watcher struct defines the livereload's logic
|
// Watcher struct defines the livereload's logic
|
||||||
type Watcher struct {
|
type Watcher struct {
|
||||||
Preview bool `yaml:"preview" json:"preview"`
|
Preview bool `yaml:"preview,omitempty" json:"preview,omitempty"`
|
||||||
Paths []string `yaml:"paths" json:"paths"`
|
Paths []string `yaml:"paths" json:"paths"`
|
||||||
Ignore []string `yaml:"ignore_paths" json:"ignore"`
|
Ignore []string `yaml:"ignore_paths,omitempty" json:"ignore_paths,omitempty"`
|
||||||
Exts []string `yaml:"exts" json:"exts"`
|
Exts []string `yaml:"exts" json:"exts"`
|
||||||
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
|
Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -90,14 +89,7 @@ type Command struct {
|
||||||
Type string `yaml:"type" json:"type"`
|
Type string `yaml:"type" json:"type"`
|
||||||
Command string `yaml:"command" json:"command"`
|
Command string `yaml:"command" json:"command"`
|
||||||
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
Path string `yaml:"path,omitempty" json:"path,omitempty"`
|
||||||
Global bool `yaml:"global,omitempty" json:"changed,global"`
|
Global bool `yaml:"global,omitempty" json:"global,omitempty"`
|
||||||
}
|
|
||||||
|
|
||||||
// Streams is a collection of names and values for the logs functionality
|
|
||||||
type Streams struct {
|
|
||||||
FileOut bool `yaml:"file_out" json:"file_out"`
|
|
||||||
FileLog bool `yaml:"file_log" json:"file_log"`
|
|
||||||
FileErr bool `yaml:"file_err" json:"file_err"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer define an array buffer for each log files
|
// Buffer define an array buffer for each log files
|
||||||
|
|
Loading…
Reference in New Issue