generator

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Same = 1 << iota
	Edited
	Deleted
	Info
)
View Source
const (
	Copy     = 1 << iota // Default content could work as is and could be edited.
	CorePart             // For the core of Vectra edit with caution.
	FullGen              // Don't be edited at all.
	Skeleton             // Stub content to be filled or edited later.
)

Variables

View Source
var (
	//go:embed all:template
	EmbedFS embed.FS

	FolderProject  = ".vectra"
	FolderReport   = filepath.Join(FolderProject, "report")
	FolderTemplate = "template"
)

Functions

func CreateDockerContainer

func CreateDockerContainer(containerName, projectPath, imageName string) error

func CreateDockerImage

func CreateDockerImage(dockerfileFileName string, imageName string) error

func ExecuteCommand

func ExecuteCommand(command string, printStandardOutput bool, printErrorOutput bool) error

func IsDockerInstalled

func IsDockerInstalled() bool

func IsNotPlural

func IsNotPlural(str string) bool

func KeyExist

func KeyExist(key string, m map[string]string) bool

func StartDockerContainer

func StartDockerContainer(containerName string) error

func TrimNewPrefix

func TrimNewPrefix(str string) string

func TrimPluralization

func TrimPluralization(str string) string

func Upper

func Upper(str string) string

func WatchFiles

func WatchFiles(rootFolder string, includePatterns, excludePatterns []string, delay int, task func(string)) error

WatchFiles watches recursively a root folder for file changes and triggers a task when a file that matches the include patterns and does not match the exclude patterns is written.

Parameters:

- rootFolder: The root folder to watch for file changes.

- includePatterns: The patterns for files to include in the watch. Only files that match any of the include patterns are considered.

- excludePatterns: The patterns for files to exclude from the watch. Files that match any of the exclude patterns are ignored.

- delay: The delay in milliseconds before triggering the task after a file is written.

- task: The task to be executed when a file that matches the include patterns and does not match the exclude patterns is written.

Returns:

- error: An error if any occurred, otherwise nil.

Types

type AttributeWithTag

type AttributeWithTag struct {
	SimpleAttribute `yaml:",inline"`
	ModTag          string `yaml:"mod"`
	ValidatorTag    string `yaml:"validator"`
}

type Base

type Base struct {
	*Generator
}

func (*Base) Generate

func (i *Base) Generate()

type ConfigurationAttribute added in v1.1.0

type ConfigurationAttribute struct {
	SimpleAttribute `yaml:",inline"`
	IsTransient     bool `yaml:"is_transient"`
}

type Controller

type Controller struct {
	Name   string            `yaml:"name"`
	IsView bool              `yaml:"is_view"`
	Routes []Route           `yaml:"routes"`
	Bodies map[string]string `yaml:"-"`
}

type Controllers

type Controllers struct {
	*Generator
}

func (*Controllers) Generate

func (i *Controllers) Generate()

type Field

type Field struct {
	Name        string
	IsDirectory bool
	Key         string
}

type Folder

type Folder struct {
	Name    string
	FullKey string
	Parent  *Folder
	Items   map[string]*Folder
}

type Generator

type Generator struct {
	IGenerator
	Name string
	// contains filtered or unexported fields
}

func NewAbstractGenerator

func NewAbstractGenerator(
	name string,
	configSelectors []string,
	report Report,
	vectra *Vectra,
) *Generator

func NewBase

func NewBase(cfg *Vectra) *Generator

func NewControllers

func NewControllers(cfg *Vectra) *Generator

func NewI18n

func NewI18n(cfg *Vectra) *Generator

func NewServices

func NewServices(cfg *Vectra) *Generator

func NewTypes

func NewTypes(cfg *Vectra) *Generator

func (*Generator) Generate

func (g *Generator) Generate(ctx any)

func (*Generator) PrintReport

func (g *Generator) PrintReport()

type I18n

type I18n struct {
	*Generator
	// contains filtered or unexported fields
}

func (*I18n) Generate

func (i *I18n) Generate()

type I18nConfig added in v1.1.0

type I18nConfig struct {
	Watcher `yaml:",inline"`
}

type I18nType

type I18nType struct {
	Name   string
	Fields []Field
}

type IGenerator

type IGenerator interface {
	Generate()
	PrintReport()
}

type JsConfig added in v1.1.0

type JsConfig struct {
	Watcher `yaml:",inline"`
}

type Method

type Method struct {
	Name    string            `yaml:"name"`
	Inputs  []SimpleAttribute `yaml:"inputs"`
	Outputs []string          `yaml:"outputs"`
}

type NetworkConfig added in v1.1.0

type NetworkConfig struct {
	Domain string `yaml:"domain"`
	Port   int    `yaml:"port"`
	IsIPv6 bool   `yaml:"isIPv6"`
}

type PugConfig added in v1.1.0

type PugConfig struct {
	Watcher            `yaml:",inline"`
	LayoutFilePattern  string `yaml:"layout_file_pattern"`
	IgnoredFilePattern string `yaml:"ignored_file_pattern"`
}

type Report

type Report struct {
	Files   []SourceFile   `yaml:"files"`
	Config  map[string]any `yaml:"config"`
	Version int8           `yaml:"version"`
}

type Route

type Route struct {
	Kind   string `yaml:"kind"`
	Path   string `yaml:"path"`
	Target string `yaml:"target"`
}

type SassConfig added in v1.1.0

type SassConfig struct {
	Watcher `yaml:",inline"`
}

type Service

type Service struct {
	Name          string                         `yaml:"name"`
	Errors        []string                       `yaml:"errors"`
	Methods       []Method                       `yaml:"methods"`
	ExchangeTypes []VectraType[AttributeWithTag] `yaml:"exchange_types"`
	Bodies        map[string]string              `yaml:"-"`
}

type Services

type Services struct {
	*Generator
}

func (*Services) Generate

func (i *Services) Generate()

type SimpleAttribute

type SimpleAttribute struct {
	Name string `yaml:"name"`
	Type string `yaml:"type"`
}

type SourceFile

type SourceFile struct {
	RealPath string `yaml:"path"`
	Hash     string `yaml:"hash"`
	Kind     int8   `yaml:"kind"`
	// contains filtered or unexported fields
}

func NewDynSourceFile

func NewDynSourceFile(path string, realpath string, kind int8) SourceFile

func NewSourceFile

func NewSourceFile(path string, kind int8) SourceFile

type SpriteConfig added in v1.1.0

type SpriteConfig struct {
	SvgFolderPath   string `yaml:"svg_path"`
	OutputSpriteSvg string `yaml:"output_sprite_svg"`
}

type TemplateData

type TemplateData struct {
	PackageName string
	Types       []I18nType
}

type Types

type Types struct {
	*Generator
}

func (*Types) Generate

func (i *Types) Generate()

type Vectra

type Vectra struct {
	ProjectPath string `yaml:"-"`

	WatcherConfig        `yaml:"watcher_config"`
	SpriteConfig         `yaml:"sprite_config"`
	NetConfProd          NetworkConfig                 `yaml:"net_conf_prod"`
	NetConfDev           NetworkConfig                 `yaml:"net_conf_dev"`
	ProjectName          string                        `yaml:"project_name"`
	DefaultLang          string                        `yaml:"default_lang"`
	WithGitignore        bool                          `yaml:"with_gitignore"`
	WithDockerDeployment bool                          `yaml:"with_docker_deployment"`
	WithI18nExample      bool                          `yaml:"with_i18n_example"`
	WithSassExample      bool                          `yaml:"with_sass_example"`
	WithPugExample       bool                          `yaml:"with_pug_example"`
	StorageTypes         []VectraType[SimpleAttribute] `yaml:"storage_types"`
	ViewTypes            `yaml:"view_types"`
	Controllers          []Controller             `yaml:"controllers"`
	Services             []Service                `yaml:"services"`
	Configuration        []ConfigurationAttribute `yaml:"configuration"`
	// contains filtered or unexported fields
}

func NewVectra

func NewVectra(projectPath string) *Vectra

func (*Vectra) DeserializeFromMap

func (v *Vectra) DeserializeFromMap(data map[string]any) error

func (*Vectra) FullGenerate

func (v *Vectra) FullGenerate()

func (*Vectra) FullReport

func (v *Vectra) FullReport()

func (*Vectra) Generate

func (v *Vectra) Generate(key string)

func (*Vectra) GetFieldsAsMap

func (v *Vectra) GetFieldsAsMap(paths []string) map[string]any

func (*Vectra) Init

func (v *Vectra) Init()

func (*Vectra) Pack added in v1.1.0

func (v *Vectra) Pack()

func (*Vectra) Report

func (v *Vectra) Report(key string)

func (*Vectra) Run added in v1.1.0

func (v *Vectra) Run()

func (*Vectra) Watch

func (v *Vectra) Watch()

type VectraType

type VectraType[T any] struct {
	Name       string `yaml:"name"`
	Attributes []T    `yaml:"attributes"`
}

type ViewTypeConstructor added in v1.1.0

type ViewTypeConstructor struct {
	Name       string            `yaml:"name"`
	IsPageCtx  bool              `yaml:"is_page_ctx"`
	Attributes []SimpleAttribute `yaml:"attributes"`
}

type ViewTypes

type ViewTypes struct {
	Types        []VectraType[SimpleAttribute] `yaml:"types"`
	Constructors []ViewTypeConstructor         `yaml:"constructors"`
	Bodies       map[string]string             `yaml:"-"`
}

type Watcher added in v1.1.0

type Watcher struct {
	IsEnabled bool `yaml:"is_enabled"`
}

type WatcherConfig added in v1.1.0

type WatcherConfig struct {
	PugConfig  `yaml:"pug_config"`
	SassConfig `yaml:"sass_config"`
	JsConfig   `yaml:"js_config"`
	I18nConfig `yaml:"i18n_config"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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