internal

package
v0.0.0-...-6809f3c Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PromptFile           string = "prompts.toml"
	OverrideFile         string = ".override.toml"
	ReplacementDelimiter string = "{&{&"
)

Variables

View Source
var (
	ReservedPromptVariables = []string{}
	IgnoredNames            = []string{PromptFile, OverrideFile}
	IgnoredDirectories      = []string{".git", "node_modules"}
)

Functions

func Apply

func Apply(inputDir string, vars collections.IDictionary, outputDir string) error

func AskPrompts

func AskPrompts(prompts Prompts, overrides collections.IDictionary, input io.ReadCloser) (collections.IDictionary, error)

func AskQuestion

func AskQuestion(question string, choices []string, input io.ReadCloser) (string, error)

func Create

func Create(inputDir string, overrides map[string]string, targetDir string) error

func IsCollection

func IsCollection(dir string) (bool, []string)

If there is no top level prompts and some subdirectories contain prompts, then we're dealing with a collection. Otherwise it's scaffolding with no prompts

func PrepareChoices

func PrepareChoices(prompt Prompt, input io.ReadCloser) (promptui.Select, error)

func PreparePrompt

func PreparePrompt(prompt Prompt, input io.ReadCloser) (promptui.Prompt, error)

func ReadFile

func ReadFile(path string) (string, error)

func ReadOverrides

func ReadOverrides(overrideFile string) (collections.IDictionary, error)

func URLToFs

func URLToFs(url string, subPath string, tmpDir string) (string, error)

Present a local directory or a git repo as a Filesystem

Types

type Prompt

type Prompt struct {
	Name     string   `toml:"name" binding:"required"`
	Prompt   string   `toml:"prompt" binding:"required"`
	Required bool     `toml:"required"`
	Default  string   `toml:"default"`
	Choices  []string `toml:"choices,omitempty"`
}

type Prompts

type Prompts struct {
	Prompts []Prompt `toml:"prompt"`
}

func ReadPromptFile

func ReadPromptFile(promptFile string) (Prompts, error)

type SourceFile

type SourceFile struct {
	FilePath    string
	FileContent string
	FileMode    fs.FileMode
}

func Replace

func Replace(vars collections.IDictionary, file SourceFile) (SourceFile, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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