config

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "nimbu"
View Source
const DefaultAPIHost = "api.nimbu.io"

DefaultAPIHost is the default API host, extracted from the default API URL.

View Source
const ProjectFileName = "nimbu.yml"

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the directory for configuration files. Uses ~/.config on macOS and Linux by default (or XDG_CONFIG_HOME on Linux), and %APPDATA% on Windows.

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the full path to the config file.

func DataDir

func DataDir() (string, error)

DataDir returns the directory for data files (like keyring fallback).

func EnsureConfigDir

func EnsureConfigDir() (string, error)

EnsureConfigDir creates the config directory if it doesn't exist.

func EnsureDataDir

func EnsureDataDir() (string, error)

EnsureDataDir creates the data directory if it doesn't exist.

func FindProjectFile

func FindProjectFile() (string, error)

FindProjectFile walks up from the current directory to find nimbu.yml.

func ParseRouteRule

func ParseRouteRule(raw string) (method string, pattern string)

ParseRouteRule parses either "<glob>" or "<METHOD> <glob>" route rules.

func ProjectRoot

func ProjectRoot() (string, error)

ProjectRoot returns the directory containing the nearest nimbu.yml.

func UpsertProjectApp

func UpsertProjectApp(path string, app AppProjectConfig) error

UpsertProjectApp inserts or replaces one app entry in nimbu.yml.

func ValidKeys

func ValidKeys() []string

ValidKeys returns all valid config keys.

func WarnUnknownAppsKeys

func WarnUnknownAppsKeys(path string) ([]string, error)

WarnUnknownAppsKeys returns warning strings for unknown keys in the `apps` block.

func WarnUnknownDevKeys

func WarnUnknownDevKeys(path string) ([]string, error)

WarnUnknownDevKeys returns warning strings for unknown keys in the `dev` block. Unknown keys are non-fatal and should be surfaced to users at startup.

func WarnUnknownSyncKeys

func WarnUnknownSyncKeys(path string) ([]string, error)

WarnUnknownSyncKeys returns warning strings for unknown keys in the `sync` block.

func Write

func Write(cfg Config) error

Write saves config to disk.

func WriteProjectConfig

func WriteProjectConfig(cfg ProjectConfig) error

WriteProjectConfig writes project config to nimbu.yml in the current directory.

func WriteProjectConfigTo

func WriteProjectConfigTo(path string, cfg ProjectConfig) error

WriteProjectConfigTo writes project config to a specific path.

Types

type AppProjectConfig

type AppProjectConfig struct {
	ID   string `json:"id,omitempty" yaml:"id,omitempty"`
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	Dir  string `json:"dir,omitempty" yaml:"dir,omitempty"`
	Glob string `json:"glob,omitempty" yaml:"glob,omitempty"`
	Host string `json:"host,omitempty" yaml:"host,omitempty"`
	Site string `json:"site,omitempty" yaml:"site,omitempty"`
}

AppProjectConfig configures one local cloud-code app mapping.

type Config

type Config struct {
	DefaultSite    string `json:"default_site,omitempty"`
	APIURL         string `json:"api_url,omitempty"`
	Timeout        string `json:"timeout,omitempty"`
	KeyringBackend string `json:"keyring_backend,omitempty"`
	BannerTheme    string `json:"banner_theme,omitempty"`
}

Config holds application configuration.

func Defaults

func Defaults() Config

Defaults returns config with default values.

func Read

func Read() (Config, error)

Read loads config from disk, merging with defaults.

func (*Config) Get

func (c *Config) Get(key string) (string, error)

Get retrieves a single config value by key.

func (*Config) Set

func (c *Config) Set(key, value string) error

Set updates a single config value by key.

func (*Config) TimeoutDuration

func (c *Config) TimeoutDuration() time.Duration

TimeoutDuration returns the timeout as a duration.

func (*Config) Unset

func (c *Config) Unset(key string) error

Unset removes a config value by key.

type DevConfig

type DevConfig struct {
	Proxy  DevProxyConfig  `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	Routes DevRoutesConfig `json:"routes,omitempty" yaml:"routes,omitempty"`
	Server DevServerConfig `json:"server,omitempty" yaml:"server,omitempty"`
}

DevConfig holds local development server configuration.

type DevProxyConfig

type DevProxyConfig struct {
	Host              string `json:"host,omitempty" yaml:"host,omitempty"`
	MaxBodyMB         int    `json:"max_body_mb,omitempty" yaml:"max_body_mb,omitempty"`
	Port              int    `json:"port,omitempty" yaml:"port,omitempty"`
	TemplateRoot      string `json:"template_root,omitempty" yaml:"template_root,omitempty"`
	Watch             *bool  `json:"watch,omitempty" yaml:"watch,omitempty"`
	WatchScanInterval string `json:"watch_scan_interval,omitempty" yaml:"watch_scan_interval,omitempty"`
}

DevProxyConfig configures the local Nimbu proxy runtime.

type DevRoutesConfig

type DevRoutesConfig struct {
	Exclude []string `json:"exclude,omitempty" yaml:"exclude,omitempty"`
	Include []string `json:"include,omitempty" yaml:"include,omitempty"`
}

DevRoutesConfig configures include/exclude path rules for proxy routing.

Each rule accepts either: - "<glob>", e.g. "/**", "/account/*" - "<METHOD> <glob>", e.g. "POST /.well-known/*"

type DevServerConfig

type DevServerConfig struct {
	Args     []string          `json:"args,omitempty" yaml:"args,omitempty"`
	CWD      string            `json:"cwd,omitempty" yaml:"cwd,omitempty"`
	Command  string            `json:"command,omitempty" yaml:"command,omitempty"`
	Env      map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
	ReadyURL string            `json:"ready_url,omitempty" yaml:"ready_url,omitempty"`
}

DevServerConfig configures the child development server process.

type ProjectConfig

type ProjectConfig struct {
	Apps  []AppProjectConfig `json:"apps,omitempty" yaml:"apps,omitempty"`
	Site  string             `json:"site,omitempty" yaml:"site,omitempty"`
	Theme string             `json:"theme,omitempty" yaml:"theme,omitempty"`
	Dev   *DevConfig         `json:"dev,omitempty" yaml:"dev,omitempty"`
	Sync  *SyncConfig        `json:"sync,omitempty" yaml:"sync,omitempty"`
}

ProjectConfig holds project-specific configuration.

func ReadProjectConfig

func ReadProjectConfig() (ProjectConfig, error)

ReadProjectConfig reads the project config from nimbu.yml.

func ReadProjectConfigFrom

func ReadProjectConfigFrom(path string) (ProjectConfig, error)

ReadProjectConfigFrom reads project config from a specific path.

type SyncBuildConfig

type SyncBuildConfig struct {
	Args    []string          `json:"args,omitempty" yaml:"args,omitempty"`
	CWD     string            `json:"cwd,omitempty" yaml:"cwd,omitempty"`
	Command string            `json:"command,omitempty" yaml:"command,omitempty"`
	Env     map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
}

SyncBuildConfig configures the optional build step for theme push/sync.

type SyncConfig

type SyncConfig struct {
	Build     SyncBuildConfig `json:"build,omitempty" yaml:"build,omitempty"`
	Generated []string        `json:"generated,omitempty" yaml:"generated,omitempty"`
	Ignore    []string        `json:"ignore,omitempty" yaml:"ignore,omitempty"`
	Roots     SyncRootsConfig `json:"roots,omitempty" yaml:"roots,omitempty"`
}

SyncConfig configures theme push/sync behavior.

type SyncRootsConfig

type SyncRootsConfig struct {
	Assets    []string `json:"assets,omitempty" yaml:"assets,omitempty"`
	Layouts   []string `json:"layouts,omitempty" yaml:"layouts,omitempty"`
	Snippets  []string `json:"snippets,omitempty" yaml:"snippets,omitempty"`
	Templates []string `json:"templates,omitempty" yaml:"templates,omitempty"`
}

SyncRootsConfig groups local directories by remote theme resource kind.

Jump to

Keyboard shortcuts

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