templates

package
v0.0.45 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidRuntimeTemplateName added in v0.0.39

func IsValidRuntimeTemplateName(runtime string, name string) bool

Types

type AppendFileStep

type AppendFileStep struct {
	Filename string
	Content  string
}

func (*AppendFileStep) Run

func (s *AppendFileStep) Run(ctx TemplateContext) error

type Bundle

type Bundle struct {
	Enabled bool     `yaml:"enabled"`
	Ignore  []string `yaml:"ignore"`
}

type CommandStep

type CommandStep struct {
	Command string   `yaml:"command"`
	Args    []string `yaml:"args"`
}

func (*CommandStep) Run

func (s *CommandStep) Run(ctx TemplateContext) error

type CopyDirAction

type CopyDirAction struct {
	From string
	To   string
}

func (*CopyDirAction) Run

func (s *CopyDirAction) Run(ctx TemplateContext) error

type CopyFileAction

type CopyFileAction struct {
	From string
	To   string
}

func (*CopyFileAction) Run

func (s *CopyFileAction) Run(ctx TemplateContext) error

type CreateFileAction

type CreateFileAction struct {
	Filename string
	Content  string
	Template string
	From     string
}

func (*CreateFileAction) Run

type DeleteFileActionStep

type DeleteFileActionStep struct {
	Files []string `yaml:"files"`
}

func (*DeleteFileActionStep) Run

type Deployment

type Deployment struct {
	Resources Resources `yaml:"resources"`
	Command   string    `yaml:"command"`
	Args      []string  `yaml:"args"`
}

type Development added in v0.0.32

type Development struct {
	Port    int      `yaml:"port"`
	Watch   Watch    `yaml:"watch"`
	Command string   `yaml:"command"`
	Args    []string `yaml:"args"`
}

type LanguageTemplates added in v0.0.39

type LanguageTemplates []ProjectTemplate

func LoadLanguageTemplates added in v0.0.39

func LoadLanguageTemplates(runtime string) (LanguageTemplates, error)

type ModifyPackageJsonStep

type ModifyPackageJsonStep struct {
	Script      []nameValue
	Main        string
	Type        string
	Name        string
	Version     string
	Description string
	Keywords    []string
}

func (*ModifyPackageJsonStep) Run

type ModifyTsConfigStep

type ModifyTsConfigStep struct {
	Types           []string
	CompilerOptions []nameValue
}

func (*ModifyTsConfigStep) Run

type NewAgentSteps

type NewAgentSteps struct {
	Steps []any `yaml:"steps"`
}

type NewProjectSteps

type NewProjectSteps struct {
	Steps []any `yaml:"steps"`
}

type ProjectTemplate added in v0.0.39

type ProjectTemplate struct {
	Name         string   `yaml:"name"`
	Description  string   `yaml:"description"`
	Dependencies []string `yaml:"dependencies"`
	Steps        []any    `yaml:"steps"`
}

type Requirement

type Requirement struct {
	Command    string   `yaml:"command"`
	Args       []string `yaml:"args"`
	Version    string   `yaml:"version"`
	Brew       string   `yaml:"brew"`
	URL        string   `yaml:"url"`
	Selfupdate *struct {
		Command string   `yaml:"command"`
		Args    []string `yaml:"args"`
	} `yaml:"selfupdate"`
}

func (*Requirement) Matches

func (r *Requirement) Matches(ctx TemplateContext) bool

func (*Requirement) TryInstall

func (r *Requirement) TryInstall(ctx TemplateContext) error

type Resources

type Resources struct {
	Memory string `yaml:"memory"`
	CPU    string `yaml:"cpu"`
}

type Step

type Step interface {
	Run(ctx TemplateContext) error
}

type Template

type Template struct {
	Name         string        `yaml:"name"`
	Description  string        `yaml:"description"`
	Identifier   string        `yaml:"identifier"`
	Language     string        `yaml:"language"`
	Requirements []Requirement `yaml:"requirements"`
}

func (*Template) Install

func (t *Template) Install(ctx TemplateContext) error

Install installs the requirements for the template

func (*Template) Matches

func (t *Template) Matches(ctx TemplateContext) bool

Matches returns true if the template matches the requirements

func (*Template) NewProject

func (t *Template) NewProject(ctx TemplateContext) (*TemplateRules, error)

type TemplateContext

type TemplateContext struct {
	Context          context.Context
	Logger           logger.Logger
	Name             string
	Description      string
	AgentName        string
	AgentDescription string
	ProjectDir       string
	Template         *Template
	TemplateName     string
}

func (*TemplateContext) Interpolate

func (t *TemplateContext) Interpolate(val any) any

type TemplateRules

type TemplateRules struct {
	Identifier      string          `yaml:"identifier"`
	Runtime         string          `yaml:"runtime"`
	Language        string          `yaml:"language"`
	Framework       string          `yaml:"framework"`
	SrcDir          string          `yaml:"src_dir"`
	Filename        string          `yaml:"filename"`
	Bundle          Bundle          `yaml:"bundle"`
	Development     Development     `yaml:"development"`
	Deployment      Deployment      `yaml:"deployment"`
	NewProjectSteps NewProjectSteps `yaml:"new_project"`
	NewAgentSteps   NewAgentSteps   `yaml:"new_agent"`
}

func LoadTemplateRuleForIdentifier

func LoadTemplateRuleForIdentifier(identifier string) (*TemplateRules, error)

func (*TemplateRules) NewAgent

func (t *TemplateRules) NewAgent(ctx TemplateContext) error

func (*TemplateRules) NewProject

func (t *TemplateRules) NewProject(ctx TemplateContext) error

type Templates

type Templates []Template

func LoadTemplates

func LoadTemplates() (Templates, error)

LoadTemplates returns all the templates available

type Watch added in v0.0.32

type Watch struct {
	Enabled bool     `yaml:"enabled"`
	Files   []string `yaml:"files"`
}

Jump to

Keyboard shortcuts

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