config

package
v2.4.9 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: GPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QUICKGO_DIR         = ".quickgo"     // The directory for QuickGo files, resides in the executable directory.
	QUICKGO_LOG_NAME    = "quickgo.log"  // The log file name.
	QUICKGO_CONFIG_NAME = "quickgo.yaml" // Config file for QuickGo, resides in the executable directory.
	PROJECT_CONFIG_NAME = "quickgo.yaml" // Config file for the project, resides in the project (working) directory.
	PROJECT_ZIP_NAME    = "project.zip"  // The name of the project zip file.
	PROJECTS_DIR        = "projects"     // The directory for project files, resides in the executable directory.
	COMMANDS_DIR        = "commands"     // The directory for command javscript files, resides in the executable directory.
	LOCKFILE_NAME       = "quickgo.lock" // The lock file name.

	// Error messages.
	ErrCommandMissing = ErrorStr("command not found")
	ErrProjectMissing = ErrorStr("project config not found")
	ErrProjectExists  = ErrorStr("project config already exists")
	ErrProjectInvalid = ErrorStr("project config is invalid")
)

Variables

View Source
var (
	ErrProjectName = errors.Wrap(
		ErrProjectInvalid,
		"project name cannot be a blank string, period or filepath",
	)
)

Functions

func IsLocked

func IsLocked(path string) error

func LoadYaml

func LoadYaml[T any](path string) (*T, error)

func LoadYamlFS

func LoadYamlFS[T any](fileSys fs.FS, path string) (*T, error)

func LockProject added in v2.4.2

func LockProject(path string) error

Lock locks the project.

func ReadYaml added in v2.2.9

func ReadYaml[T any](r io.Reader) (*T, error)

func UnlockProject added in v2.4.2

func UnlockProject(path string) (err error)

Unlock unlocks the project.

func WriteYaml

func WriteYaml(data interface{}, path string) error

Types

type ErrorStr

type ErrorStr string

func (ErrorStr) Error

func (e ErrorStr) Error() string

type Project

type Project struct {
	// The name of the project.
	Name string `yaml:"name" json:"name"`

	// Optional context for project templates.
	Context map[string]any `yaml:"context" json:"context"`

	// List of commands to run
	BeforeCopy *command.StepList `yaml:"beforeCopy" json:"beforeCopy"`
	AfterCopy  *command.StepList `yaml:"afterCopy" json:"afterCopy"`
	Commands   ProjectCommandMap `yaml:"commands" json:"commands"` // [name] => [steps]

	// Variable delimiters for the project templates.
	DelimLeft  string `yaml:"delimLeft" json:"delimLeft"`
	DelimRight string `yaml:"delimRight" json:"delimRight"`

	// A list of files to exclude from the project in glob format.
	Exclude []string `yaml:"exclude" json:"exclude"` // (NYI)

	// The root directory.
	Root *quickfs.FSDirectory `yaml:"-"`
}

Project represents the configuration for an individual project.

func ExampleProjectConfig

func ExampleProjectConfig() *Project

ExampleProjectConfig returns an example project configuration.

func (*Project) Command

func (p *Project) Command(name string, context map[string]any) (*ProjectCommand, error)

func (*Project) ExecCommand

func (p *Project) ExecCommand(commandName string, env map[string]any) error

Execute executes the project commands.

func (*Project) IsExcluded

func (p *Project) IsExcluded(fl quickfs.FileLike) bool

func (*Project) Load

func (p *Project) Load(projectDirectory string) error

Load loads the project configuration.

func (*Project) Validate

func (p *Project) Validate() error

Validate validates the project configuration.

type ProjectCommand

type ProjectCommand struct {
	// The name of the command.
	// Only used internally for logging purposes.
	Name        string `yaml:"-" json:"-"`
	Description string `yaml:"description" json:"description"`
	// Args are the arguments to pass to the command.
	// These will be asked via stdin if not provided.
	Args map[string]any `yaml:"args" json:"args"`
	// The steps to run for the command.
	Steps *command.StepList `yaml:",inline" json:",inline"`
}

ProjectCommand represents a command for a project.

func (*ProjectCommand) Execute

func (c *ProjectCommand) Execute(env map[string]any) error

Execute executes the project command.

type ProjectCommandMap added in v2.3.3

type ProjectCommandMap map[string]*ProjectCommand

func (*ProjectCommandMap) UnmarshalYAML added in v2.3.3

func (p *ProjectCommandMap) UnmarshalYAML(value *yaml.Node) error

type QuickGo

type QuickGo struct {
	Host    string `yaml:"host"`        // The host to run the server on.
	Port    string `yaml:"port"`        // The port to run the server on.
	TLSKey  string `yaml:"privateKey"`  // The path to the TLS key.
	TLSCert string `yaml:"certificate"` // The path to the TLS certificate.
}

Config represents the configuration for QuickGo.

type Validator

type Validator interface {
	Validate() error
}

Jump to

Keyboard shortcuts

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