Documentation
¶
Overview ¶
Package scaffold provides a simple way to scaffold a project from a template
Index ¶
- Constants
- 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 Delimiters
- type Feature
- type Injectable
- type Messages
- type Metadata
- type Mode
- type Options
- type Project
- type ProjectScaffoldFile
- type Question
- type RWFSArgs
- type Rewrite
Constants ¶
const ( HooksDir = "hooks" PostScaffoldScripts = "post_scaffold" )
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"` Description *string `yaml:"description"` Default any `yaml:"default"` Confirm *string `yaml:"confirm"` Options *[]string `yaml:"options"` Loop bool `yaml:"loop"` Multi bool `yaml:"multi"` }
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 Delimiters ¶ added in v0.6.0
type Injectable ¶
type Metadata ¶ added in v0.4.0
type Metadata struct {
MinimumVersion string `yaml:"minimum_version"`
}
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 { Metadata Metadata `yaml:"metadata"` 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"` Delimiters []Delimiters `yaml:"delimiters"` }
func ReadScaffoldFile ¶
func ReadScaffoldFile(reader io.Reader) (*ProjectScaffoldFile, 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 |
Package scaffoldrc contains the runtime configuration for users
|
Package scaffoldrc contains the runtime configuration for users |