core

package
v0.0.0-...-bc5243c Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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

settings const

Variables

View Source
var (
	// RPrefix tool name
	RPrefix = "fly"
	// RVersion current version
	RVersion = "1.0.0"
	// 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 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 "fly cli" and "web fly"

type Command

type Command struct {
	Cmd    string `yaml:"command" json:"command"`
	Type   string `yaml:"type" json:"type"`
	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() (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 fly

type Fly

type Fly struct {
	Settings Settings `yaml:"settings" json:"settings"`
	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:"-"`
}

Fly main struct

func (*Fly) Prefix

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

Prefix a given string with tool name

func (*Fly) Start

func (r *Fly) Start() error

Start fly workflow

func (*Fly) Stop

func (r *Fly) Stop() error

Stop fly workflow

type Func

type Func func(Context)

Func is used instead fly func

type Ignore

type Ignore struct {
	Exts  []string `yaml:"exts,omitempty" json:"exts,omitempty"`
	Paths []string `yaml:"paths,omitempty" json:"paths,omitempty"`
}

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"`
	Env        map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
	Args       []string          `yaml:"args,omitempty" json:"args,omitempty"`
	Tools      Tools             `yaml:"commands" json:"commands"`
	Watcher    Watch             `yaml:"watcher" json:"watcher"`
	Buffer     Buffer            `yaml:"-" json:"buffer"`
	ErrPattern string            `yaml:"pattern,omitempty" json:"pattern,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 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 Settings

type Settings struct {
	Files     `yaml:"files,omitempty" json:"files,omitempty"`
	FileLimit int32    `yaml:"flimit,omitempty" json:"flimit,omitempty"`
	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 fly 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"`
	Path   string   `yaml:"path,omitempty" json:"path,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 {
	Exts    []string  `yaml:"extensions" json:"extensions"`
	Paths   []string  `yaml:"paths" json:"paths"`
	Scripts []Command `yaml:"scripts,omitempty" json:"scripts,omitempty"`
	Hidden  bool      `yaml:"hidden,omitempty" json:"hidden,omitempty"`
	Ignore  []string  `yaml:"ignored_paths,omitempty" json:"ignored_paths,omitempty"`
}

Watch info

Jump to

Keyboard shortcuts

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