projects

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareCommonContext

func PrepareCommonContext(ctx context.Context, projCtx *Context) context.Context

func RunProjectGoGenCommand

func RunProjectGoGenCommand(dir string) error

RunProjectGoGenCommand runs the go generate command for the project.

Types

type Context

type Context struct {
	ParentPackageName   string
	GeneratedFilePrefix string
	Projects            map[string]Project
}

Context is a context for Xgen it is used to pass data between generators

func GetContext

func GetContext(ctx context.Context) (*Context, error)

GetContext gets generator context from context it is used to pass data between generators

type ContextKey

type ContextKey int

ContextKey is a key for context

type Project

type Project interface {
	GetType() string
	TestsDirectory() string
	ModelMutationHook(b *modelgen.ModelBuild) *modelgen.ModelBuild
	ConstraintFieldHook(td *ast.Definition, fd *ast.FieldDefinition, f *modelgen.Field) (*modelgen.Field, error)
	SchemaHook(schema *ast.Schema) error
	SchemaDocumentHook(schemaDocument *ast.SchemaDocument) error
	ConfigOverride(cfg *config.Config) error
	Init(Name string, ParentPackageName string, GeneratedFilePrefix string) error
}

Project is a project configuration

type ProjectGenerator

type ProjectGenerator struct {
	Projects map[string]Project
}

ProjectGenerator is a wrapper for project configuration That takes context from xgen and generates code

func NewProjectGenerator

func NewProjectGenerator(projects map[string]Project) *ProjectGenerator

NewProjectGenerator creates a new ProjectGenerator instance

func (*ProjectGenerator) Generate

func (pg *ProjectGenerator) Generate(ctx context.Context) error

Generate generates projects

type ProjectGeneratorData

type ProjectGeneratorData struct {
	Name              string
	ParentPackageName string
}

ProjectGeneratorData is a template data for project

type ProjectOption

type ProjectOption = func(project Project) error

ProjectOption is a function that configures a Xgen

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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