realize

package
v2.0.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2018 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host = "localhost"
	Port = 5002
)

Dafault host and port

View Source
const (
	Permission = 0775
	File       = ".realize.yaml"
	FileOut    = ".r.outputs.log"
	FileErr    = ".r.errors.log"
	FileLog    = ".r.logs.log"
)

settings const

Variables

View Source
var (
	// RPrefix tool name
	RPrefix = "realize"
	// RVersion current version
	RVersion = "2.0.1"
	// RExt file extension
	RExt = ".yaml"
	// RFile config file name
	RFile = "." + RPrefix + RExt
	//RExtWin windows extension
	RExtWin = ".exe"
)
View Source
var (
	//Output writer
	Output = color.Output
	// Red color
	Red = colorBase(color.FgHiRed)
	// Blue color
	Blue = colorBase(color.FgHiBlue)
	// Green color
	Green = colorBase(color.FgHiGreen)
	// Yellow color
	Yellow = colorBase(color.FgHiYellow)
	// Magenta color
	Magenta = colorBase(color.FgHiMagenta)
)

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

func Wdir

func Wdir() string

Wdir return current working directory

Types

type Buffer

type Buffer struct {
	StdOut []BufferOut `json:"stdOut"`
	StdLog []BufferOut `json:"stdLog"`
	StdErr []BufferOut `json:"stdErr"`
}

Buffer define an array buffer for each log files

type BufferOut

type BufferOut struct {
	Time   time.Time `json:"time"`
	Text   string    `json:"text"`
	Path   string    `json:"path"`
	Type   string    `json:"type"`
	Stream string    `json:"stream"`
	Errors []string  `json:"errors"`
}

BufferOut is used for exchange information between "realize cli" and "web realize"

type Command

type Command struct {
	Type   string `yaml:"type" json:"type"`
	Cmd    string `yaml:"command" json:"command"`
	Path   string `yaml:"path,omitempty" json:"path,omitempty"`
	Global bool   `yaml:"global,omitempty" json:"global,omitempty"`
	Output bool   `yaml:"output,omitempty" json:"output,omitempty"`
}

Command fields

type Context

type Context struct {
	Path    string
	Project *Project
	Stop    <-chan bool
	Watcher FileWatcher
	Event   fsnotify.Event
}

Context is used as argument for func

type FileWatcher

type FileWatcher interface {
	Close() error
	Add(string) error
	Walk(string, bool) string
	Remove(string) error
	Errors() <-chan error
	Events() <-chan fsnotify.Event
}

FileWatcher is an interface for implementing file notification watchers

func EventWatcher

func EventWatcher() (FileWatcher, error)

EventWatcher returns an fs-event based file watcher

func NewFileWatcher

func NewFileWatcher(force bool, interval time.Duration) (FileWatcher, error)

NewFileWatcher tries to use an fs-event watcher, and falls back to the poller if there is an error

func PollingWatcher

func PollingWatcher(interval time.Duration) FileWatcher

PollingWatcher returns a poll-based file watcher

type Files

type Files struct {
	Clean   bool     `yaml:"clean,omitempty" json:"clean,omitempty"`
	Outputs Resource `yaml:"outputs,omitempty" json:"outputs,omitempty"`
	Logs    Resource `yaml:"logs,omitempty" json:"log,omitempty"`
	Errors  Resource `yaml:"errors,omitempty" json:"error,omitempty"`
}

Files defines the files generated by realize

type Func

type Func func(Context)

Func is used instead realize func

type Legacy

type Legacy struct {
	Force    bool          `yaml:"force" json:"force"`
	Interval time.Duration `yaml:"interval" json:"interval"`
}

Legacy is used to force polling and set a custom interval

type LogWriter

type LogWriter struct{}

LogWriter used for all log

func (LogWriter) Write

func (w LogWriter) Write(bytes []byte) (int, error)

Rewrite the layout of the log timestamp

type Project

type Project struct {
	Name               string            `yaml:"name" json:"name"`
	Path               string            `yaml:"path" json:"path"`
	Environment        map[string]string `yaml:"environment,omitempty" json:"environment,omitempty"`
	Tools              Tools             `yaml:"commands" json:"commands"`
	Args               []string          `yaml:"args,omitempty" json:"args,omitempty"`
	Watcher            Watch             `yaml:"watcher" json:"watcher"`
	Buffer             Buffer            `yaml:"-" json:"buffer"`
	ErrorOutputPattern string            `yaml:"errorOutputPattern,omitempty" json:"errorOutputPattern,omitempty"`
	// contains filtered or unexported fields
}

Project info

func (*Project) After

func (p *Project) After()

After stop watcher

func (*Project) Before

func (p *Project) Before()

Before start watcher

func (*Project) Change

func (p *Project) Change(event fsnotify.Event)

Change event message

func (*Project) Err

func (p *Project) Err(err error)

Err occurred

func (*Project) Reload

func (p *Project) Reload(path string, stop <-chan bool)

Reload launches the toolchain run, build, install

func (*Project) Validate

func (p *Project) Validate(path string, fcheck bool) bool

Validate a file path

func (*Project) Watch

func (p *Project) Watch(wg *sync.WaitGroup)

Watch a project

type Realize

type Realize struct {
	Settings Settings `yaml:"settings" json:"settings"`
	Server   Server   `yaml:"server" json:"server"`
	Schema   `yaml:",inline" json:",inline"`
	Sync     chan string `yaml:"-" json:"-"`
	Err      Func        `yaml:"-" json:"-"`
	After    Func        `yaml:"-"  json:"-"`
	Before   Func        `yaml:"-"  json:"-"`
	Change   Func        `yaml:"-"  json:"-"`
	Reload   Func        `yaml:"-"  json:"-"`
}

Realize main struct

func (*Realize) Prefix

func (r *Realize) Prefix(input string) string

Prefix a given string with tool name

func (*Realize) Start

func (r *Realize) Start() error

Start realize workflow

func (*Realize) Stop

func (r *Realize) Stop() error

Stop realize workflow

type Recovery

type Recovery struct {
	Index  bool
	Events bool
	Tools  bool
}

type Resource

type Resource struct {
	Status bool
	Path   string
	Name   string
}

Resource status and file name

type Response

type Response struct {
	Name string
	Out  string
	Err  error
}

Response exec

type Schema

type Schema struct {
	Projects []Project `yaml:"schema" json:"schema"`
}

Schema projects list

func (*Schema) Add

func (s *Schema) Add(p Project)

Add a project if unique

func (*Schema) Filter

func (s *Schema) Filter(field string, value interface{}) []Project

Filter project list by field

func (*Schema) New

func (s *Schema) New(c *cli.Context) Project

New create a project using cli fields

func (*Schema) Remove

func (s *Schema) Remove(name string) error

Remove a project

type Server

type Server struct {
	Parent *Realize `yaml:"-" json:"-"`
	Status bool     `yaml:"status" json:"status"`
	Open   bool     `yaml:"open" json:"open"`
	Port   int      `yaml:"port" json:"port"`
	Host   string   `yaml:"host" json:"host"`
}

Server settings

func (*Server) OpenURL

func (s *Server) OpenURL() (io.Writer, error)

OpenURL in a new tab of default browser

func (*Server) Start

func (s *Server) Start() (err error)

Start the web server

type Settings

type Settings struct {
	Files     `yaml:"files,omitempty" json:"files,omitempty"`
	FileLimit int32    `yaml:"flimit,omitempty" json:"flimit,omitempty"`
	Legacy    Legacy   `yaml:"legacy" json:"legacy"`
	Recovery  Recovery `yaml:"recovery,omitempty" json:"recovery,omitempty"`
}

Settings defines a group of general settings and options

func (Settings) Create

func (s Settings) Create(path string, name string) *os.File

Create a new file and return its pointer

func (Settings) Fatal

func (s Settings) Fatal(err error, msg ...interface{})

Fatal prints a fatal error with its additional messages

func (*Settings) Flimit

func (s *Settings) Flimit() error

Flimit defines the max number of watched files

func (*Settings) Read

func (s *Settings) Read(out interface{}) error

Read config file

func (*Settings) Remove

func (s *Settings) Remove(d string) error

Remove realize folder

func (Settings) Stream

func (s Settings) Stream(file string) ([]byte, error)

Stream return a byte stream of a given file

func (*Settings) Write

func (s *Settings) Write(out interface{}) error

Write config file

type Tool

type Tool struct {
	Args   []string `yaml:"args,omitempty" json:"args,omitempty"`
	Method string   `yaml:"method,omitempty" json:"method,omitempty"`
	Dir    string   `yaml:"dir,omitempty" json:"dir,omitempty"` //wdir of the command
	Status bool     `yaml:"status,omitempty" json:"status,omitempty"`
	Output bool     `yaml:"output,omitempty" json:"output,omitempty"`
	// contains filtered or unexported fields
}

Tool info

func (*Tool) Compile

func (t *Tool) Compile(path string, stop <-chan bool) (response Response)

Compile is used for build and install

func (*Tool) Exec

func (t *Tool) Exec(path string, stop <-chan bool) (response Response)

Exec a go tool

type Tools

type Tools struct {
	Clean    Tool `yaml:"clean,omitempty" json:"clean,omitempty"`
	Vet      Tool `yaml:"vet,omitempty" json:"vet,omitempty"`
	Fmt      Tool `yaml:"fmt,omitempty" json:"fmt,omitempty"`
	Test     Tool `yaml:"test,omitempty" json:"test,omitempty"`
	Generate Tool `yaml:"generate,omitempty" json:"generate,omitempty"`
	Install  Tool `yaml:"install,omitempty" json:"install,omitempty"`
	Build    Tool `yaml:"build,omitempty" json:"build,omitempty"`
	Run      Tool `yaml:"run,omitempty" json:"run,omitempty"`
}

Tools go

func (*Tools) Setup

func (t *Tools) Setup()

Setup go tools

type Watch

type Watch struct {
	Paths   []string  `yaml:"paths" json:"paths"`
	Exts    []string  `yaml:"extensions" json:"extensions"`
	Ignore  []string  `yaml:"ignored_paths,omitempty" json:"ignored_paths,omitempty"`
	Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
	Hidden  bool      `yaml:"skip_hidden,omitempty" json:"skip_hidden,omitempty"`
}

Watch info

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL