Documentation
¶
Overview ¶
Package scaffold provides a simple way to scaffold a project from a template
Index ¶
- Variables
- func BuildVars(eng *engine.Engine, project *Project, vars engine.Vars) (engine.Vars, error)
- func Inject(r io.Reader, data string, at string, mode Mode) ([]byte, error)
- func MergeMaps[T any](maps ...map[string]T) map[string]T
- func QuestionGroupBy(questions []Question) [][]Question
- func RenderRWFS(eng *engine.Engine, args *RWFSArgs, vars engine.Vars) error
- func TestparseDefaultBool(t *testing.T)
- func TestparseDefaultString(t *testing.T)
- func TestparseDefaultStrings(t *testing.T)
- type AnyPrompt
- type Askable
- type AuthEntry
- type BasicAuth
- type Feature
- type Injectable
- type Messages
- type Mode
- type Options
- type Project
- type ProjectScaffoldFile
- type Question
- type RCValidationError
- type RWFSArgs
- type RcValidationErrors
- type Rewrite
- type ScaffoldRC
- type Settings
Constants ¶
This section is empty.
Variables ¶
var ErrInjectMarkerNotFound = errors.New("inject marker not found")
Functions ¶
func BuildVars ¶
BuildVars builds the vars for the engine by setting the provided vars under the "Scaffold" key and adding the project name and computed vars.
func Inject ¶
Inject will read the reader line by line and find the line that contains the string "at". It will then insert the data before that line.
func MergeMaps ¶
MergeMaps merges multiple maps into a single map. If a key is present in multiple maps, the value from the last map will be used.
func QuestionGroupBy ¶ added in v0.0.93
func RenderRWFS ¶
RenderRWFS renders a rwfs.RFS to a rwfs.WriteFS by compiling all files in the rwfs.ReadFS and writing the compiled files to the WriteFS.
func TestparseDefaultBool ¶ added in v0.0.93
func TestparseDefaultString ¶ added in v0.0.93
func TestparseDefaultStrings ¶ added in v0.0.93
Types ¶
type AnyPrompt ¶
type AnyPrompt struct { Message *string `yaml:"message"` Desciption *string `yaml:"description"` Loop bool `yaml:"loop"` Default any `yaml:"default"` Confirm *string `yaml:"confirm"` Multi bool `yaml:"multi"` Options *[]string `yaml:"options"` }
func (AnyPrompt) IsInputLoop ¶ added in v0.0.93
func (AnyPrompt) IsMultiSelect ¶
func (AnyPrompt) IsTextInput ¶ added in v0.0.93
type Askable ¶ added in v0.0.93
func NewAskable ¶ added in v0.0.93
type Injectable ¶
type Project ¶
type Project struct { RootFS rwfs.ReadFS NameTemplate string Name string Conf *ProjectScaffoldFile Options Options }
Project structure hold the project templates file system and configuration for rendering the project.
type ProjectScaffoldFile ¶
type ProjectScaffoldFile struct { Skip []string `yaml:"skip"` Questions []Question `yaml:"questions"` Rewrites []Rewrite `yaml:"rewrites"` Computed map[string]string `yaml:"computed"` Messages Messages `yaml:"messages"` Inject []Injectable `yaml:"inject"` Features []Feature `yaml:"features"` Presets map[string]map[string]any `yaml:"presets"` }
func ReadScaffoldFile ¶
func ReadScaffoldFile(reader io.Reader) (*ProjectScaffoldFile, error)
type Question ¶
type Question struct { Name string `yaml:"name"` Group string `yaml:"group"` Prompt AnyPrompt `yaml:"prompt"` When string `yaml:"when"` Required bool `yaml:"required"` }
func (Question) Description ¶ added in v0.0.93
type RCValidationError ¶
type RcValidationErrors ¶
type RcValidationErrors []RCValidationError
func (RcValidationErrors) Error ¶
func (e RcValidationErrors) Error() string
type ScaffoldRC ¶
type ScaffoldRC struct { // Settings define the settings for the scaffold application. Settings Settings `yaml:"settings"` // Defaults define a default value for a variable. // name: myproject // git_user: hay-kot // // These are injected into the template as variables for // every scaffold. Defaults map[string]any `yaml:"defaults"` // Aliases define a alias for a repository. // or filepath. // // component: https://githublcom/hay-kot/scaffold-go-component // cli: https://github.com/hay-kot/scaffold-go-cli Aliases map[string]string `yaml:"aliases"` // Shorts define a short name for a repository. // the key will be expanded into the value. // gh: https://github.com // gt: https://gitea.com // // This will allow you to use the short name in the scaffold // gh:myorg/myrepo Shorts map[string]string `yaml:"shorts"` // Auth defines a list of auth entries that can be used to // authenticate with a remote SCM. Auth []AuthEntry `yaml:"auth"` }
func DefaultScaffoldRC ¶ added in v0.0.100
func DefaultScaffoldRC() *ScaffoldRC
DefaultScaffoldRC returns a default scaffold rc file.
func NewScaffoldRC ¶
func NewScaffoldRC(r io.Reader) (*ScaffoldRC, error)
NewScaffoldRC reads a scaffold rc file from the reader and returns a ScaffoldRC struct.
func (*ScaffoldRC) Authenticator ¶
func (rc *ScaffoldRC) Authenticator(pkgurl string) (transport.AuthMethod, bool)
func (*ScaffoldRC) Validate ¶ added in v0.0.100
func (rc *ScaffoldRC) Validate() error
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package pkgs contains functions for parsing remote urls and checking if a directory is a git repository.
|
Package pkgs contains functions for parsing remote urls and checking if a directory is a git repository. |
pkgurl
Package pkgurl contains functions for parsing remote urls
|
Package pkgurl contains functions for parsing remote urls |