detectgen

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const GitlabURL = "https://gitlab.com/api/v4"

GitlabURL is the default gitlab API URL.

Variables

This section is empty.

Functions

func IsGenerated

func IsGenerated(dest string) bool

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

Copy reassigns the builder struct (behind pointer) to a new pointer and returns it.

func (*DirGenerateBuilder) SetConfig

SetConfig sets DirGenerate's Config.

func (*DirGenerateBuilder) SetData

func (b *DirGenerateBuilder) SetData(data any) *DirGenerateBuilder

SetData sets DirGenerate's Data.

func (*DirGenerateBuilder) SetFS

SetFS sets DirGenerate's FS.

func (*DirGenerateBuilder) SetFileHandlers

func (b *DirGenerateBuilder) SetFileHandlers(fileHandlers []filehandler.Handler) *DirGenerateBuilder

SetFileHandlers sets DirGenerate's FileHandlers.

func (*DirGenerateBuilder) SetName

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"
)

Jump to

Keyboard shortcuts

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