Documentation
¶
Index ¶
- Constants
- func IsGenerated(dest string) bool
- func ReservedNames() []string
- type DetectFunc
- type DirGenerate
- type DirGenerateBuilder
- func (b *DirGenerateBuilder) Build() (*DirGenerate, error)
- func (b *DirGenerateBuilder) Copy() *DirGenerateBuilder
- func (b *DirGenerateBuilder) SetConfig(config models.GenerateConfig) *DirGenerateBuilder
- func (b *DirGenerateBuilder) SetData(data any) *DirGenerateBuilder
- func (b *DirGenerateBuilder) SetFS(fs filesystem.FS) *DirGenerateBuilder
- func (b *DirGenerateBuilder) SetFileHandlers(fileHandlers []filehandler.Handler) *DirGenerateBuilder
- func (b *DirGenerateBuilder) SetName(name GenerateName) *DirGenerateBuilder
- type GenerateFunc
- type GenerateName
- type Gomod
- type PackageJSON
Constants ¶
const GitlabURL = "https://gitlab.com/api/v4"
GitlabURL is the default gitlab API URL.
Variables ¶
This section is empty.
Functions ¶
func IsGenerated ¶
IsGenerated returns truthy if input destination is a generated file.
func ReservedNames ¶
func ReservedNames() []string
ReservedNames returns the slice of string representing reserved folders name.
Types ¶
type DetectFunc ¶
type DetectFunc func(ctx context.Context, config *models.GenerateConfig) []GenerateFunc
DetectFunc is the signature function to implement to add a new language or framework detection in craft.
The input configuration can be altered in any way.
func AllDetectFuncs ¶
func AllDetectFuncs() []DetectFunc
AllDetectFuncs returns the slice of all detects options, each one returning a slice of GenerateFunc in case the detection is truthy.
type DirGenerate ¶
type DirGenerate struct { Config models.GenerateConfig `validate:"required"` Data any `validate:"required"` FileHandlers []filehandler.Handler `validate:"omitempty,dive,required"` FS filesystem.FS `validate:"required"` Name GenerateName `validate:"required"` }
DirGenerate represents the struct for basic dir generation.
It takes various inputs that will never change during recursive calls to avoid passing them as input arguments.
func (*DirGenerate) Generate ¶
func (d *DirGenerate) Generate(ctx context.Context, srcdir, destdir string) error
Generate walks over input srcdir and apply template of every src entry into destdir.
If src entry is a directory and this directory name is the same as generate struct name then it dives into and executes Execute inside.
func (*DirGenerate) Validate ¶
func (d *DirGenerate) Validate() error
Validate ensures the built d is valid.
type DirGenerateBuilder ¶
type DirGenerateBuilder struct {
// contains filtered or unexported fields
}
DirGenerateBuilder represents DirGenerate's builder.
func NewDirGenerateBuilder ¶
func NewDirGenerateBuilder() *DirGenerateBuilder
NewDirGenerateBuilder creates a new DirGenerateBuilder.
func (*DirGenerateBuilder) Build ¶
func (b *DirGenerateBuilder) Build() (*DirGenerate, error)
Build returns built DirGenerate.
func (*DirGenerateBuilder) Copy ¶
func (b *DirGenerateBuilder) Copy() *DirGenerateBuilder
Copy reassigns the builder struct (behind pointer) to a new pointer and returns it.
func (*DirGenerateBuilder) SetConfig ¶
func (b *DirGenerateBuilder) SetConfig(config models.GenerateConfig) *DirGenerateBuilder
SetConfig sets DirGenerate's Config.
func (*DirGenerateBuilder) SetData ¶
func (b *DirGenerateBuilder) SetData(data any) *DirGenerateBuilder
SetData sets DirGenerate's Data.
func (*DirGenerateBuilder) SetFS ¶
func (b *DirGenerateBuilder) SetFS(fs filesystem.FS) *DirGenerateBuilder
SetFS sets DirGenerate's FS.
func (*DirGenerateBuilder) SetFileHandlers ¶
func (b *DirGenerateBuilder) SetFileHandlers(fileHandlers []filehandler.Handler) *DirGenerateBuilder
SetFileHandlers sets DirGenerate's FileHandlers.
func (*DirGenerateBuilder) SetName ¶
func (b *DirGenerateBuilder) SetName(name GenerateName) *DirGenerateBuilder
SetName sets DirGenerate's Name.
type GenerateFunc ¶
type GenerateFunc func(ctx context.Context, config models.GenerateConfig, fsys filesystem.FS) error
GenerateFunc is the signature function to implement to add a new language of framework templatization in craft.
func GenericFunc ¶
func GenericFunc(ctx context.Context, config *models.GenerateConfig) []GenerateFunc
GenericFunc represents the detection for generic projects (those without any associated implemented language).
It returns one slice element to generic templates from generic template folder.
func GetGenerateFunc ¶
func GetGenerateFunc(name GenerateName) GenerateFunc
GetGenerateFunc is a simplified function returning a basic GenerateFunc for an input ExecName.
It uses behind the hood a private builder for dirGenerate which is the main function for all craft generations.
type GenerateName ¶
type GenerateName string
GenerateName represents a string alias for a generate reserved name.
const ( // NameGeneric is the reserved name for generic template folder. NameGeneric GenerateName = "generic" // NameGolang is the reserved name for golang template folder. NameGolang GenerateName = "golang" // NameHelm is the reserved name for helm chart template folder. NameHelm GenerateName = "helm" // NameHugo is the reserved name for hugo template folder. NameHugo GenerateName = "hugo" // NameLicense is the reserved name for license template folder. NameLicense GenerateName = "license" // NameNodejs is the reserved name for nodejs template folder. NameNodejs GenerateName = "nodejs" )
type Gomod ¶
type Gomod struct { LangVersion string Platform string ProjectHost string ProjectName string ProjectPath string }
Gomod represents the parsed struct for go.mod file
type PackageJSON ¶
type PackageJSON struct { Author *string `json:"author,omitempty"` Description *string `json:"description,omitempty"` Files []string `json:"files,omitempty"` Keywords []string `json:"keywords,omitempty"` License *string `json:"license,omitempty"` Main *string `json:"main,omitempty"` Module string `json:"module,omitempty"` Name string `json:"name,omitempty" validate:"required"` PackageManagerWithVersion string `json:"packageManager,omitempty"` Private bool `json:"private,omitempty"` Scripts map[string]string `json:"scripts,omitempty"` Version string `json:"version,omitempty"` PackageManagerName string `json:"-"` PackageManagerVersion string `json:"-"` }
PackageJSON represents the node package json descriptor.
func (*PackageJSON) Validate ¶
func (p *PackageJSON) Validate() error
Validate validates the given PackageJSON struct.