config

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateConfigFile

func ValidateConfigFile(path string) error

ValidateConfigFile validates a configuration file without loading it fully

Types

type APIClientConfig

type APIClientConfig struct {
	Generator   string            `yaml:"generator"`    // "basic", "axios", "trpc-like"
	ReactQuery  ReactQueryConfig  `yaml:"react_query"`  // React Query specific options
	Options     map[string]string `yaml:"options"`      // Additional generator options
	OutputFile  string            `yaml:"output_file"`  // Custom output file name
	TypesImport string            `yaml:"types_import"` // Custom types import path
}

func GetDefaultAPIClientConfig

func GetDefaultAPIClientConfig() APIClientConfig

GetDefaultAPIClientConfig returns the default API client configuration

type BackendConfig

type BackendConfig struct {
	Router   string `yaml:"router"`
	Template string `yaml:"template,omitempty"` // Backend template name
}

type BuildConfig

type BuildConfig struct {
	OutputDir   string `yaml:"output_dir"`
	BinaryName  string `yaml:"binary_name"`
	EmbedStatic bool   `yaml:"embed_static"`
	StaticDir   string `yaml:"static_dir"`
	BuildTags   string `yaml:"build_tags"`
	LDFlags     string `yaml:"ldflags"`
	CGOEnabled  bool   `yaml:"cgo_enabled"`
}

type ConfigInfo

type ConfigInfo struct {
	Path               string
	ProjectName        string
	Port               int
	BackendRouter      string
	FrontendFramework  string
	APIClientGenerator string
	ReactQueryEnabled  bool
	BuildOutputDir     string
	StaticDir          string
	EmbedStatic        bool
}

ConfigInfo contains summary information about a configuration

func GetConfigInfo

func GetConfigInfo(path string) (*ConfigInfo, error)

GetConfigInfo returns information about the current configuration

func (*ConfigInfo) String

func (info *ConfigInfo) String() string

String returns a formatted string representation of config info

type ConfigLoadOptions

type ConfigLoadOptions struct {
	Path              string
	AllowMissing      bool
	ValidateStructure bool
	ApplyDefaults     bool
	WarnOnDeprecated  bool
	Quiet             bool
}

ConfigLoadOptions provides options for loading configuration

func DefaultLoadOptions

func DefaultLoadOptions() ConfigLoadOptions

DefaultLoadOptions returns sensible defaults for config loading

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager handles configuration loading, validation, and management

func NewConfigManager

func NewConfigManager(options ConfigLoadOptions) *ConfigManager

NewConfigManager creates a new configuration manager

func (*ConfigManager) LoadConfig

func (cm *ConfigManager) LoadConfig() (*ProjectConfig, error)

LoadConfig loads and validates the configuration with comprehensive error handling

func (*ConfigManager) LoadConfigFromPath

func (cm *ConfigManager) LoadConfigFromPath(path string) (*ProjectConfig, error)

LoadConfigFromPath loads configuration from a specific path

type ExternalTemplateConfig

type ExternalTemplateConfig struct {
	Source      string `yaml:"source"`                // GitHub URL or local path
	Name        string `yaml:"name"`                  // Template name from template.yaml
	Description string `yaml:"description"`           // Template description
	CachedPath  string `yaml:"cached_path,omitempty"` // Local cache path
}

ExternalTemplateConfig holds information about external templates

type FrontendConfig

type FrontendConfig struct {
	Framework  string          `yaml:"framework"`
	InstallCmd string          `yaml:"install_cmd,omitempty"` // Legacy support
	DevCmd     string          `yaml:"dev_cmd"`
	BuildCmd   string          `yaml:"build_cmd"`
	TypesDir   string          `yaml:"types_dir"`
	LibDir     string          `yaml:"lib_dir"`
	StaticGen  StaticGenConfig `yaml:"static_gen"`
	Template   TemplateConfig  `yaml:"template,omitempty"` // New template configuration
}

type ProjectConfig

type ProjectConfig struct {
	Name             string                  `yaml:"name"`
	Port             int                     `yaml:"port"`
	Frontend         FrontendConfig          `yaml:"frontend"`
	Backend          BackendConfig           `yaml:"backend"`
	Build            BuildConfig             `yaml:"build"`
	APIClient        APIClientConfig         `yaml:"api_client"`
	ExternalTemplate *ExternalTemplateConfig `yaml:"external_template,omitempty"`
}

func LoadConfig

func LoadConfig() (*ProjectConfig, error)

LoadConfig loads configuration using default options

func LoadConfigQuiet

func LoadConfigQuiet() (*ProjectConfig, error)

LoadConfigQuiet loads configuration without warnings or messages

func LoadConfigWithDefaults

func LoadConfigWithDefaults() (*ProjectConfig, error)

LoadConfigWithDefaults loads configuration, creating defaults if missing

func ReadConfig

func ReadConfig(path string) (*ProjectConfig, error)

ReadConfig is kept for backward compatibility but now uses the enhanced system

type ReactQueryConfig

type ReactQueryConfig struct {
	Enabled       bool   `yaml:"enabled"`        // Enable React Query integration
	Version       string `yaml:"version"`        // React Query version (v4, v5)
	QueryOptions  bool   `yaml:"query_options"`  // Generate queryOptions functions
	QueryKeys     bool   `yaml:"query_keys"`     // Generate query key factories
	DevTools      bool   `yaml:"devtools"`       // Include devtools setup
	ErrorBoundary bool   `yaml:"error_boundary"` // Generate error boundary components
}

type StaticGenConfig

type StaticGenConfig struct {
	Enabled     bool     `yaml:"enabled"`
	BuildSSRCmd string   `yaml:"build_ssr_cmd"`
	GenerateCmd string   `yaml:"generate_cmd"`
	Routes      []string `yaml:"routes"`
	SPARouting  bool     `yaml:"spa_routing"`
}

type TemplateConfig

type TemplateConfig struct {
	Type   string `yaml:"type"`   // "hardcoded", "script", "custom", "remote"
	Source string `yaml:"source"` // template name, script command, or URL/path

	// For remote templates
	URL     string            `yaml:"url,omitempty"`     // GitHub URL or local path
	Version string            `yaml:"version,omitempty"` // Git tag, branch, or "latest"
	Cache   bool              `yaml:"cache,omitempty"`   // Whether to cache the template
	Vars    map[string]string `yaml:"vars,omitempty"`    // Template variables

	// For custom commands
	Command string `yaml:"command,omitempty"` // Custom installation command
	Dir     string `yaml:"dir,omitempty"`     // Working directory for command
}

TemplateConfig defines how the frontend should be generated

type ValidationError

type ValidationError struct {
	Field   string
	Value   interface{}
	Message string
}

ValidationError represents a configuration validation error

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

ValidationErrors represents multiple validation errors

func (ValidationErrors) Error

func (errs ValidationErrors) Error() string

func (ValidationErrors) HasErrors

func (errs ValidationErrors) HasErrors() bool

Jump to

Keyboard shortcuts

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