action

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeAudit    = Type{Key: "audit", Title: "Audit", Icon: "scale", Description: "Audits the project files, detecting invalid files and empty folders"}
	TypeBuild    = Type{Key: "build", Title: "Build", Icon: "hammer", Description: "Builds the project, many options available"}
	TypeCreate   = Type{Key: "create", Title: "Create", Icon: "folder-plus", Description: "Creates a new project"}
	TypeDebug    = Type{Key: "debug", Title: "Debug", Icon: "bug", Description: "Dumps a ton of information about the project"}
	TypeDoctor   = Type{Key: "doctor", Title: "Doctor", Icon: "first-aid", Description: "Makes sure your machine has the required dependencies"}
	TypeGenerate = Type{Key: "generate", Title: "Generate", Icon: "forward", Description: "Applies pending changes to files as required"}
	TypePreview  = Type{Key: "preview", Title: "Preview", Icon: "play", Description: "Show what would happen if you generate"}
	TypeRules    = Type{Key: "rules", Title: "Rules", Icon: "play", Description: "Apply export rules from json file located at ./rules.json"}
	TypeSVG      = Type{Key: "svg", Title: "SVG", Icon: "icons", Description: "Builds the project's SVG files"}
	TypeTest     = Type{Key: "test", Title: "Test", Icon: "wrench", Description: "Runs internal tests, you probably don't want this", Hidden: true}
)
View Source
var AllBuilds = Builds{
	{Key: "start", Title: "Start", Description: "Starts the prebuilt project binary", Run: onStart},
	{Key: "deps", Title: "Dependencies", Description: "Manages Go dependencies", Run: onDeps},
	{Key: "imports", Title: "Imports", Description: "Reorders the imports", Run: onImports},
	{Key: "ignored", Title: "Ignored", Description: "Shows files that are ignored by code generation", Run: onIgnored},
	{Key: "packages", Title: "Packages", Description: "Visualize your application's packages", Run: onPackages},
	{Key: "cleanup", Title: "Cleanup", Description: "Cleans up file permissions", Run: onCleanup},
	simpleBuild("build", "Build", "make build"),
	simpleBuild("clean", "Clean", "make clean"),
	simpleBuild("tidy", "Tidy", "go mod tidy"),
	simpleBuild("format", "Format", "bin/format.sh"),
	simpleBuild("lint", "Lint", "bin/check.sh"),
	{Key: "clientInstall", Title: "Client Install", Description: ciDesc, Run: func(ctx context.Context, pm *PrjAndMods, ret *Result) *Result {
		return simpleProc(ctx, "npm install", filepath.Join(pm.Prj.Path, "client"), ret, pm.Logger)
	}},
	simpleBuild("clientBuild", "Client Build", "bin/build/client.sh"),
	{Key: "deployments", Title: "Deployments", Description: "Manages deployments", Run: onDeployments},
	{Key: "test", Title: "Test", Description: "Does a test", Run: func(ctx context.Context, pm *PrjAndMods, ret *Result) *Result {
		return simpleProc(ctx, "bin/test.sh", pm.Prj.Path, ret, pm.Logger)
	}},
}

Functions

func ServiceDefinition added in v0.7.13

func ServiceDefinition(p *project.Project) util.ValueMap

Types

type Build

type Build struct {
	Key         string `json:"key"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`

	Run func(ctx context.Context, pm *PrjAndMods, ret *Result) *Result `json:"-"`
}

type Builds

type Builds []*Build

func (Builds) Get

func (b Builds) Get(key string) *Build

type Params

type Params struct {
	ProjectKey string
	T          Type
	Cfg        util.ValueMap
	RootFiles  filesystem.FileLoader
	MSvc       *module.Service
	PSvc       *project.Service
	XSvc       *exec.Service
	SSvc       *websocket.Service
	ESvc       *export.Service
	CLI        bool
	Logger     util.Logger
}

type PrjAndMods

type PrjAndMods struct {
	Cfg    util.ValueMap
	Prj    *project.Project
	File   json.RawMessage
	Mods   module.Modules
	MSvc   *module.Service
	PSvc   *project.Service
	XSvc   *exec.Service
	SSvc   *websocket.Service
	ESvc   *export.Service
	EArgs  *model.Args
	Logger util.Logger
}

type Result

type Result struct {
	Project  *project.Project `json:"project"`
	Action   Type             `json:"action"`
	Status   string           `json:"status"`
	Args     util.ValueMap    `json:"args,omitempty"`
	Data     any              `json:"data,omitempty"`
	Modules  module.Results   `json:"modules,omitempty"`
	Logs     []string         `json:"logs,omitempty"`
	Errors   []string         `json:"errors,omitempty"`
	Duration int              `json:"duration,omitempty"`
	// contains filtered or unexported fields
}

func Apply

func Apply(ctx context.Context, p *Params) (ret *Result)

func (*Result) AddDebug

func (r *Result) AddDebug(msg string, args ...any)

func (*Result) AddLog

func (r *Result) AddLog(msg string, args ...any)

func (*Result) AddWarn

func (r *Result) AddWarn(msg string, args ...any)

func (*Result) AsError added in v0.9.10

func (r *Result) AsError() error

func (*Result) HasErrors

func (r *Result) HasErrors() bool

func (*Result) Merge

func (r *Result) Merge(tgt *Result) *Result

func (*Result) StatusLog

func (r *Result) StatusLog() string

func (*Result) Title

func (r *Result) Title() string

func (*Result) WithError

func (r *Result) WithError(err error) *Result

type ResultContext

type ResultContext struct {
	Prj *project.Project `json:"prj,omitempty"`
	Cfg util.ValueMap    `json:"cfg,omitempty"`
	Res *Result          `json:"res,omitempty"`
}

func ApplyAll

func ApplyAll(ctx context.Context, prjs project.Projects, actT Type, cfg util.ValueMap, as *app.State, logger util.Logger) []*ResultContext

func (*ResultContext) Status

func (c *ResultContext) Status() string

func (*ResultContext) Title

func (c *ResultContext) Title() string

type ResultContexts

type ResultContexts []*ResultContext

func (ResultContexts) Errors

func (x ResultContexts) Errors() []string

func (ResultContexts) Title

func (x ResultContexts) Title() string

type Type

type Type struct {
	Key         string
	Title       string
	Icon        string
	Description string
	Hidden      bool
}

func TypeFromString

func TypeFromString(s string) Type

func (*Type) MarshalJSON

func (t *Type) MarshalJSON() ([]byte, error)

func (*Type) String

func (t *Type) String() string

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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