internal

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

Variables

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

Functions

func Apply

func Apply(inputDir string, vars map[string]string, outputDir string) error

func Create

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

Create a new source project in targetDir

func IsCollection

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

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

func NewQuestion

func NewQuestion(prompt Prompt) survey.Question

func ReadFile

func ReadFile(path string) (string, 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"`
}

type SourceFile

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

func (SourceFile) Replace

func (s SourceFile) Replace(vars map[string]string) (SourceFile, error)

func (SourceFile) Transform

func (s SourceFile) Transform(inputDir string, outputDir string, vars map[string]string) error

type Template

type Template interface {
	Arguments() []Prompt
	Ask(...survey.AskOpt) (map[string]string, error)
}

func NewTemplate

func NewTemplate(promptFile io.ReadCloser, arguments map[string]string) (Template, error)

type TemplateImpl

type TemplateImpl struct {
	TPrompts   Prompts
	TQuestions []*survey.Question
	TArguments map[string]string
}

func (TemplateImpl) Arguments

func (t TemplateImpl) Arguments() []Prompt

func (TemplateImpl) Ask

func (t TemplateImpl) Ask(opts ...survey.AskOpt) (map[string]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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