config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package config provides configuration parsing for Vango projects.

The configuration is stored in vango.json at the project root. This package handles loading, saving, and validating configuration.

Configuration File Structure

{
  "dev": {
    "port": 8000,
    "appPort": 8888,
    "host": "localhost",
    "openBrowser": true,
    "https": false,
    "proxy": {
      "/api/external": "https://api.example.com"
    }
  },
  "build": {
    "output": "dist",
    "minify": true,
    "sourceMaps": false
  },
  "tailwind": {
    "enabled": true,
    "config": "./tailwind.config.js"
  },
  "ui": {
    "version": "1.0.0",
    "registry": "https://vango.dev/registry.json",
    "installed": ["button", "card"]
  },
  "hooks": "./public/js/hooks.js"
}

Usage

cfg, err := config.Load(".")
if err != nil {
    log.Fatal(err)
}

fmt.Println("Port:", cfg.Dev.Port)

Index

Constants

View Source
const (
	// ConfigFileName is the name of the configuration file.
	ConfigFileName = "vango.json"

	// DefaultPort is the default development server port.
	DefaultPort = 8000

	// DefaultAppPort is the default backend app process port in dev mode.
	DefaultAppPort = 8888

	// DefaultHost is the default development server host.
	DefaultHost = "localhost"

	// DefaultOutput is the default build output directory.
	DefaultOutput = "dist"

	// DefaultRegistry is the default component registry URL.
	DefaultRegistry = "https://vango.dev/registry.json"
)
View Source
const (
	EnvSessionStoreURL           = "VANGO_SESSION_STORE_URL"
	EnvPubSubURL                 = "VANGO_PUBSUB_URL"
	EnvBlobsURL                  = "VANGO_BLOBS_URL"
	EnvCacheURL                  = "VANGO_CACHE_URL"
	EnvPersistenceSecret         = "VANGO_PERSISTENCE_SECRET"
	EnvPersistenceSecretPrevious = "VANGO_PERSISTENCE_SECRET_PREVIOUS"
	EnvPlatformSealed            = "VANGO_PLATFORM_SEALED"
	EnvEnvironment               = "VANGO_ENV"
	EnvStrict                    = "VANGO_STRICT"
)

Variables

This section is empty.

Functions

func Exists

func Exists(dir string) bool

Exists checks if a config file exists in the given directory.

func FindProjectRoot

func FindProjectRoot(startDir string) (string, error)

FindProjectRoot walks up directories to find the project root. Returns the directory containing vango.json, or an error if not found.

func LoadFromEnv

func LoadFromEnv(cfg *SessionConfig)

LoadFromEnv populates session config from environment variables. Invalid values are ignored to keep startup non-fatal.

func ParseSessionStoreURL

func ParseSessionStoreURL(raw string) (session.SessionStore, error)

ParseSessionStoreURL creates a SessionStore from a URL.

Types

type BlobConfig added in v0.0.2

type BlobConfig struct {
	Enabled bool `json:"enabled,omitempty"`

	// Provider is the scaffolded provider identifier ("r2" or "s3").
	Provider string `json:"provider,omitempty"`

	// TmpCleanupConfigured indicates a lifecycle rule exists that deletes objects under tmp/
	// after a short retention window (recommended: 24h). When false, `vango dev` may warn.
	TmpCleanupConfigured bool `json:"tmp_cleanup_configured,omitempty"`
}

BlobConfig configures optional blob storage scaffolding and CLI advisories.

type BuildConfig

type BuildConfig struct {
	// Output is the output directory for builds.
	Output string `json:"output,omitempty"`

	// Minify enables minification.
	Minify bool `json:"minify,omitempty"`

	// MinifyAssets enables minification of CSS and JS assets.
	MinifyAssets bool `json:"minifyAssets,omitempty"`

	// StripSymbols strips debug symbols from the binary (-ldflags="-s -w").
	StripSymbols bool `json:"stripSymbols,omitempty"`

	// SourceMaps enables source map generation.
	SourceMaps bool `json:"sourceMaps,omitempty"`

	// Target is the Go build target (e.g., "linux/amd64").
	Target string `json:"target,omitempty"`

	// LDFlags are additional linker flags for go build.
	LDFlags string `json:"ldflags,omitempty"`

	// Tags are build tags to pass to go build.
	Tags []string `json:"tags,omitempty"`

	// GeneratorInputs are inputs that affect generated code and build schema.
	GeneratorInputs []string `json:"generatorInputs,omitempty"`
}

BuildConfig contains production build settings.

type Config

type Config struct {
	// Module is the Go module path (must match go.mod).
	Module string `json:"module,omitempty"`

	// Name is the project name.
	Name string `json:"name,omitempty"`

	// Version is the project version.
	Version string `json:"version,omitempty"`

	// Strict controls lint strict mode (default, ci).
	Strict string `json:"strict,omitempty"`

	// Platform contains platform-specific configuration.
	Platform PlatformConfig `json:"platform,omitempty"`

	// Neon contains Neon-specific configuration.
	Neon NeonConfig `json:"neon,omitempty"`

	// Blob contains blob storage scaffolding configuration (vango-s3 integration).
	// This is currently used for CLI advisory checks and template scaffolding only.
	Blob BlobConfig `json:"blob,omitempty"`

	// Port is the default server port (convenience field, also in Dev).
	Port int `json:"port,omitempty"`

	// Routes configures file-based routing generation.
	Routes RoutesConfig `json:"routes,omitempty"`

	// Paths contains path configuration for various directories.
	Paths PathsConfig `json:"paths,omitempty"`

	// Static contains static file serving configuration.
	Static StaticConfig `json:"static,omitempty"`

	// Dev contains development server configuration.
	Dev DevConfig `json:"dev,omitempty"`

	// Build contains production build configuration.
	Build BuildConfig `json:"build,omitempty"`

	// Tailwind contains Tailwind CSS configuration.
	Tailwind TailwindConfig `json:"tailwind,omitempty"`

	// Session contains session configuration.
	Session SessionConfig `json:"session,omitempty"`

	// UI contains VangoUI component configuration (legacy, use Paths.UI).
	UI UIConfig `json:"ui,omitempty"`

	// Hooks is the path to custom client hooks JavaScript file.
	Hooks string `json:"hooks,omitempty"`

	// Components is the path to the components directory (legacy, use Paths.Components).
	Components string `json:"components,omitempty"`

	// Public is the path to the public static files directory (legacy, use Static.Dir).
	Public string `json:"public,omitempty"`
	// contains filtered or unexported fields
}

Config represents the complete vango.json configuration. This is aligned with the v1 schema in DEVELOPER_GUIDE.md Appendix C.

func Load

func Load(dir string) (*Config, error)

Load reads configuration from the specified directory. It looks for vango.json in the directory.

func LoadFile

func LoadFile(path string) (*Config, error)

LoadFile reads configuration from the specified file path.

func LoadFromWorkingDir

func LoadFromWorkingDir() (*Config, error)

LoadFromWorkingDir loads configuration from the current working directory.

func New

func New() *Config

New creates a new Config with default values.

func (*Config) ComponentsPath

func (c *Config) ComponentsPath() string

ComponentsPath returns the absolute path to the components directory.

func (*Config) DevAddress

func (c *Config) DevAddress() string

DevAddress returns the address string for the dev server.

func (*Config) DevURL

func (c *Config) DevURL() string

DevURL returns the full URL for the dev server.

func (*Config) Dir

func (c *Config) Dir() string

Dir returns the directory containing the config file.

func (*Config) EffectiveNeonProjectID added in v0.0.2

func (c *Config) EffectiveNeonProjectID() string

EffectiveNeonProjectID returns the Neon project ID to use for CLI operations.

NEON_PROJECT_ID takes precedence over vango.json.

func (*Config) HasIOSTarget added in v0.0.3

func (c *Config) HasIOSTarget() bool

HasIOSTarget reports whether an iOS target is configured.

func (*Config) HasMacOSTarget added in v0.0.3

func (c *Config) HasMacOSTarget() bool

HasMacOSTarget reports whether a macOS desktop target is configured.

func (*Config) HasTailwind

func (c *Config) HasTailwind() bool

HasTailwind returns true if Tailwind CSS is enabled.

func (*Config) IsPlatformSealed

func (c *Config) IsPlatformSealed() bool

IsPlatformSealed returns true when platform config is sealed.

func (*Config) IsStrictCI

func (c *Config) IsStrictCI() bool

IsStrictCI returns true when strict mode is set to CI.

func (*Config) MiddlewarePath

func (c *Config) MiddlewarePath() string

MiddlewarePath returns the absolute path to the middleware directory.

func (*Config) OutputPath

func (c *Config) OutputPath() string

OutputPath returns the absolute path to the build output directory.

func (*Config) Path

func (c *Config) Path() string

Path returns the path where the config was loaded from.

func (*Config) PublicPath

func (c *Config) PublicPath() string

PublicPath returns the absolute path to the public directory.

func (*Config) ResolveIOSTarget added in v0.0.3

func (c *Config) ResolveIOSTarget() ResolvedIOSTarget

ResolveIOSTarget returns the normalized iOS target configuration.

func (*Config) ResolveMacOSTarget added in v0.0.3

func (c *Config) ResolveMacOSTarget() ResolvedMacOSTarget

ResolveMacOSTarget returns the normalized macOS target configuration.

func (*Config) RoutesOutputPath

func (c *Config) RoutesOutputPath() string

RoutesOutputPath returns the absolute path to the generated routes file.

func (*Config) RoutesPath

func (c *Config) RoutesPath() string

RoutesPath returns the absolute path to the routes directory.

func (*Config) Save

func (c *Config) Save() error

Save writes the configuration to the file it was loaded from.

func (*Config) SaveTo

func (c *Config) SaveTo(path string) error

SaveTo writes the configuration to the specified path.

func (*Config) StaticPrefix

func (c *Config) StaticPrefix() string

StaticPrefix returns the URL prefix for static files.

func (*Config) StorePath

func (c *Config) StorePath() string

StorePath returns the absolute path to the store directory.

func (*Config) StrictMode

func (c *Config) StrictMode() string

StrictMode returns the effective strict mode (env overrides config).

func (*Config) TailwindConfigPath

func (c *Config) TailwindConfigPath() string

TailwindConfigPath returns the absolute path to the Tailwind config.

func (*Config) UIComponentsPath

func (c *Config) UIComponentsPath() string

UIComponentsPath returns the absolute path to the UI components directory.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid.

type DevConfig

type DevConfig struct {
	// Port is the port to run the dev server on.
	Port int `json:"port,omitempty"`

	// AppPort is the backend application process port used by the dev proxy.
	AppPort int `json:"appPort,omitempty"`

	// Host is the host to bind to.
	Host string `json:"host,omitempty"`

	// OpenBrowser opens the browser automatically on start.
	OpenBrowser bool `json:"openBrowser,omitempty"`

	// HTTPS enables HTTPS for the dev server.
	HTTPS bool `json:"https,omitempty"`

	// Proxy contains proxy rules for forwarding requests.
	Proxy map[string]string `json:"proxy,omitempty"`

	// Watch contains paths to watch for changes.
	Watch []string `json:"watch,omitempty"`

	// Ignore contains patterns to ignore during watch.
	Ignore []string `json:"ignore,omitempty"`

	// HotReload enables hot reload in development.
	HotReload bool `json:"hotReload,omitempty"`
}

DevConfig contains development server settings.

type IOSAppConfig added in v0.0.3

type IOSAppConfig struct {
	DisplayName    string   `json:"displayName,omitempty"`
	BundleID       string   `json:"bundleID,omitempty"`
	MinimumVersion string   `json:"minimumVersion,omitempty"`
	URLSchemes     []string `json:"urlSchemes,omitempty"`
}

IOSAppConfig configures bundle metadata for the iOS host.

type IOSConfig added in v0.0.3

type IOSConfig struct {
	Enabled bool             `json:"enabled,omitempty"`
	App     IOSAppConfig     `json:"app,omitempty"`
	Runtime IOSRuntimeConfig `json:"runtime,omitempty"`
	Release IOSReleaseConfig `json:"release,omitempty"`
}

IOSConfig configures the native iOS mobile target.

type IOSReleaseConfig added in v0.0.3

type IOSReleaseConfig struct {
	SigningIdentity     string `json:"signingIdentity,omitempty"`
	TeamID              string `json:"teamID,omitempty"`
	ProvisioningProfile string `json:"provisioningProfile,omitempty"`
	SigningStyle        string `json:"signingStyle,omitempty"`
}

IOSReleaseConfig configures code signing and archive behavior for the iOS host.

type IOSRuntimeConfig added in v0.0.3

type IOSRuntimeConfig struct {
	BridgePackage        string   `json:"bridgePackage,omitempty"`
	Topology             string   `json:"topology,omitempty"`
	HostedBaseURL        string   `json:"hostedBaseURL,omitempty"`
	HostedAllowedOrigins []string `json:"hostedAllowedOrigins,omitempty"`
}

IOSRuntimeConfig configures runtime behavior for the iOS host.

type MacOSAppConfig added in v0.0.3

type MacOSAppConfig struct {
	DisplayName    string   `json:"displayName,omitempty"`
	BundleID       string   `json:"bundleID,omitempty"`
	ExecutableName string   `json:"executableName,omitempty"`
	Category       string   `json:"category,omitempty"`
	MinimumVersion string   `json:"minimumVersion,omitempty"`
	URLSchemes     []string `json:"urlSchemes,omitempty"`
}

MacOSAppConfig configures bundle metadata for the macOS host.

type MacOSConfig added in v0.0.3

type MacOSConfig struct {
	Enabled bool               `json:"enabled,omitempty"`
	App     MacOSAppConfig     `json:"app,omitempty"`
	Runtime MacOSRuntimeConfig `json:"runtime,omitempty"`
	Release MacOSReleaseConfig `json:"release,omitempty"`
}

MacOSConfig configures the native macOS desktop target.

type MacOSReleaseConfig added in v0.0.3

type MacOSReleaseConfig struct {
	SigningIdentity string `json:"signingIdentity,omitempty"`
	TeamID          string `json:"teamID,omitempty"`
	NotaryProfile   string `json:"notaryProfile,omitempty"`
}

MacOSReleaseConfig configures release signing/notarization metadata.

type MacOSRuntimeConfig added in v0.0.3

type MacOSRuntimeConfig struct {
	BridgePackage        string   `json:"bridgePackage,omitempty"`
	Topology             string   `json:"topology,omitempty"`
	HostedBaseURL        string   `json:"hostedBaseURL,omitempty"`
	HostedAllowedOrigins []string `json:"hostedAllowedOrigins,omitempty"`
	RestorePolicy        string   `json:"restorePolicy,omitempty"`
}

MacOSRuntimeConfig configures runtime behavior for the macOS host.

type NeonConfig added in v0.0.2

type NeonConfig struct {
	// Enabled enables Neon-aware CLI features.
	Enabled bool `json:"enabled,omitempty"`

	// ProjectID is the Neon project ID. This value is overridden by the
	// NEON_PROJECT_ID environment variable when set.
	ProjectID string `json:"project_id,omitempty"`

	// BranchDetection enables the vango dev informational branch check. If unset,
	// the default is true.
	BranchDetection *bool `json:"branch_detection,omitempty"`
}

NeonConfig configures optional Neon-aware CLI behavior.

This configuration enables informational tooling in the vango CLI; it does not change runtime database connection behavior by itself.

func (NeonConfig) BranchDetectionEnabled added in v0.0.2

func (n NeonConfig) BranchDetectionEnabled() bool

BranchDetectionEnabled returns whether branch detection should run. The default is true when BranchDetection is unset.

type PathsConfig

type PathsConfig struct {
	// Components is the path to the components directory.
	Components string `json:"components,omitempty"`

	// UI is the path to the UI components directory.
	UI string `json:"ui,omitempty"`

	// Store is the path to the store directory.
	Store string `json:"store,omitempty"`

	// Middleware is the path to the middleware directory.
	Middleware string `json:"middleware,omitempty"`
}

PathsConfig contains path configuration for project directories.

type PlatformConfig

type PlatformConfig struct {
	// Sealed prevents app config from overriding platform settings.
	Sealed bool `json:"sealed,omitempty"`

	// Name is the platform identifier (for logging/display).
	Name string `json:"name,omitempty"`

	// MacOS configures the native macOS desktop target.
	MacOS MacOSConfig `json:"macos,omitempty"`

	// IOS configures the native iOS mobile target.
	IOS IOSConfig `json:"ios,omitempty"`
}

PlatformConfig contains platform-specific settings.

type ResolvedIOSTarget added in v0.0.3

type ResolvedIOSTarget struct {
	Enabled bool

	AppName             string
	BundleID            string
	MinimumSystem       string
	URLSchemes          []string
	BridgePackage       string
	Topology            string
	HostedBaseURL       string
	HostedOrigins       []string
	OutputDir           string
	AppVersion          string
	AppBuild            string
	BuildChannel        string
	SigningIdentity     string
	TeamID              string
	ProvisioningProfile string
	SigningStyle        string
	SchemeName          string
	ApplicationModule   string
}

ResolvedIOSTarget contains the normalized iOS target configuration consumed by the CLI, native host build scripts, and archive pipeline.

type ResolvedMacOSTarget added in v0.0.3

type ResolvedMacOSTarget struct {
	Enabled bool

	AppName           string
	ExecutableName    string
	BundleID          string
	AppCategory       string
	MinimumSystem     string
	URLSchemes        []string
	BridgePackage     string
	Topology          string
	HostedBaseURL     string
	HostedOrigins     []string
	RestorePolicy     string
	OutputDir         string
	AppVersion        string
	AppBuild          string
	BuildChannel      string
	SigningIdentity   string
	TeamID            string
	NotaryProfile     string
	ApplicationModule string
}

ResolvedMacOSTarget contains the normalized macOS target configuration that the CLI, host build scripts, and packaging pipeline consume.

type RoutesConfig

type RoutesConfig struct {
	// Dir is the path to the routes directory.
	Dir string `json:"dir,omitempty"`

	// Output is the output file path for generated routes glue.
	Output string `json:"output,omitempty"`

	// Package is the Go package name for generated routes glue.
	Package string `json:"package,omitempty"`
}

RoutesConfig contains file-based routing configuration.

type RuntimePlatform

type RuntimePlatform struct {
	// SessionStoreURL is the session persistence backend URL.
	SessionStoreURL string

	// PubSubURL is the broadcast/pubsub backend URL.
	PubSubURL string

	// BlobsURL is the blob storage backend URL.
	BlobsURL string

	// CacheURL is the cache backend URL.
	CacheURL string

	// PersistenceSecret is the HMAC secret for persistence blobs.
	PersistenceSecret string

	// PersistenceSecretPrevious is the previous HMAC secret for rotation.
	PersistenceSecretPrevious string

	// Environment is the runtime environment (dev/staging/production).
	Environment string

	// Name is the platform identifier (optional).
	Name string

	// Sealed prevents app overrides.
	Sealed bool
}

RuntimePlatform contains resolved platform configuration.

func ResolvePlatform

func ResolvePlatform(cfg *Config) *RuntimePlatform

ResolvePlatform resolves platform configuration from config and environment.

func (*RuntimePlatform) HasBroadcast

func (rp *RuntimePlatform) HasBroadcast() bool

HasBroadcast returns true if a pubsub backend is configured.

func (*RuntimePlatform) HasPersistence

func (rp *RuntimePlatform) HasPersistence() bool

HasPersistence returns true if a session store is configured.

type SessionConfig

type SessionConfig struct {
	// ResumeWindow is the duration for session resumption (e.g., "30s").
	ResumeWindow string `json:"resumeWindow,omitempty"`

	// Store is the session persistence backend (env-only).
	Store session.SessionStore `json:"-"`

	// PersistenceSecret signs persisted session blobs (env-only).
	PersistenceSecret []byte `json:"-"`

	// PersistenceSecretPrevious allows secret rotation (env-only).
	PersistenceSecretPrevious []byte `json:"-"`
}

SessionConfig contains session configuration.

type StaticConfig

type StaticConfig struct {
	// Dir is the directory containing static files.
	Dir string `json:"dir,omitempty"`

	// Prefix is the URL prefix for static files (default: "/").
	Prefix string `json:"prefix,omitempty"`
}

StaticConfig contains static file serving configuration.

type TailwindConfig

type TailwindConfig struct {
	// Enabled controls whether Tailwind CSS is used.
	Enabled bool `json:"enabled,omitempty"`

	// Config is the path to tailwind.config.js.
	Config string `json:"config,omitempty"`

	// Input is the input CSS file.
	Input string `json:"input,omitempty"`

	// Output is the output CSS file.
	Output string `json:"output,omitempty"`
}

TailwindConfig contains Tailwind CSS settings.

type UIConfig

type UIConfig struct {
	// Version is the pinned VangoUI version.
	Version string `json:"version,omitempty"`

	// Registry is the URL to the component registry.
	Registry string `json:"registry,omitempty"`

	// Installed is the list of installed components.
	Installed []string `json:"installed,omitempty"`

	// Path is the path where UI components are stored.
	Path string `json:"path,omitempty"`
}

UIConfig contains VangoUI component settings.

Jump to

Keyboard shortcuts

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