shared

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectModule

func DetectModule() (string, error)

DetectModule reads go.mod from the current directory and returns the module path.

func EnabledFeatures

func EnabledFeatures(features map[string]bool) []string

EnabledFeatures returns a sorted list of enabled feature names.

func FeaturesListString

func FeaturesListString(features map[string]bool) string

FeaturesListString returns a comma-separated string of enabled features.

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier checks whether s is a valid Go-style identifier (lowercase alpha + digits).

func IsValidSnakeCase

func IsValidSnakeCase(s string) bool

IsValidSnakeCase checks whether s is a valid snake_case identifier.

func ParseFeatures

func ParseFeatures(featureStr, templateType string) map[string]bool

ParseFeatures parses a comma-separated feature string and applies template defaults.

func ResolveFeatureDependencies

func ResolveFeatureDependencies(features map[string]bool) map[string]bool

ResolveFeatureDependencies ensures all required feature dependencies are satisfied.

func ResolveModule

func ResolveModule(moduleName string) (string, error)

ResolveModule returns moduleName if non-empty, otherwise auto-detects from go.mod.

Types

type GeneratorConfig

type GeneratorConfig struct {
	// Directory conventions (relative to project root)
	MicroserviceDir string `yaml:"microservice_dir"` // e.g. "internal/ms"
	DomainDir       string `yaml:"domain_dir"`       // e.g. "internal/domain"
	ModelsDir       string `yaml:"models_dir"`       // e.g. "pkg/models"
	ConfigsDir      string `yaml:"configs_dir"`      // e.g. "misc/configs"
	CmdDir          string `yaml:"cmd_dir"`          // e.g. "cmd/ms"

	// Naming conventions
	MicroservicePrefix  string `yaml:"microservice_prefix"`   // e.g. "ms_"
	BusinessLayerSuffix string `yaml:"business_layer_suffix"` // e.g. "_business_layer"

	// OpenAPI defaults
	OpenAPITitle   string   `yaml:"openapi_title"`   // default title for OpenAPI spec
	OpenAPIServers []string `yaml:"openapi_servers"` // default server URLs
	OAuthAuthorize string   `yaml:"oauth_authorize"` // OAuth authorize URL
	OAuthToken     string   `yaml:"oauth_token"`     // OAuth token URL

	// Module name (auto-detected from go.mod if empty)
	ModuleName string `yaml:"module_name"`
}

GeneratorConfig holds all configurable paths and conventions for code generation. Paths are relative to the project root. Loaded from .pixie.yaml or pixie.yaml if present, otherwise sensible defaults are used.

func DefaultConfig

func DefaultConfig() GeneratorConfig

DefaultConfig returns a GeneratorConfig with sensible defaults.

func LoadConfig

func LoadConfig() (GeneratorConfig, error)

LoadConfig loads configuration from .pixie.yaml or pixie.yaml in the current directory. If no config file is found, returns DefaultConfig with no error.

type TemplateData

type TemplateData struct {
	// Basic information
	ServiceName         string // user_management (for microservices) or custom service name
	ServiceNameCamel    string // UserManagement (for microservices) or custom service name
	DomainName          string // users
	DomainNameCamel     string // Users
	ModuleName          string // github.com/company/my-project
	RepositoryName      string // For repositories: custom name or domain name
	RepositoryNameCamel string // CamelCase version of RepositoryName
	EntityName          string // For entities: custom name or domain name
	EntityNameCamel     string // CamelCase version of EntityName

	// Features
	Features map[string]bool // Feature flags

	// Configuration
	Port               int    // HTTP server port
	MetricsPort        int    // Metrics server port
	Timestamp          string // Generation timestamp
	MigrationTimestamp string // Migration timestamp for DB migrations

	// Database configuration (with defaults)
	DatabaseHost                  string
	DatabasePort                  int
	DatabaseName                  string
	DatabaseUsername              string
	DatabasePassword              string
	DatabaseSSLMode               string
	DatabaseMaxOpenConnections    int
	DatabaseMaxIdleConnections    int
	DatabaseConnectionMaxLifetime string

	// Redis configuration (with defaults)
	RedisHost     string
	RedisPort     int
	RedisPassword string
	RedisDatabase int

	// Security configuration (with defaults)
	JWTSecretKey string
	AdminAPIKey  string
}

TemplateData holds the data passed to scaffold templates.

func NewTemplateData

func NewTemplateData() TemplateData

NewTemplateData creates a TemplateData with timestamp defaults populated.

Jump to

Keyboard shortcuts

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