Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigDir() (string, error)
- func ConfigPath() (string, error)
- func DataDir() (string, error)
- func EnsureConfigDir() (string, error)
- func EnsureDataDir() (string, error)
- func FindProjectFile() (string, error)
- func ParseRouteRule(raw string) (method string, pattern string)
- func ProjectRoot() (string, error)
- func UpsertProjectApp(path string, app AppProjectConfig) error
- func ValidKeys() []string
- func WarnUnknownAppsKeys(path string) ([]string, error)
- func WarnUnknownDevKeys(path string) ([]string, error)
- func WarnUnknownSyncKeys(path string) ([]string, error)
- func Write(cfg Config) error
- func WriteProjectConfig(cfg ProjectConfig) error
- func WriteProjectConfigTo(path string, cfg ProjectConfig) error
- type AppProjectConfig
- type Config
- type DevConfig
- type DevProxyConfig
- type DevRoutesConfig
- type DevServerConfig
- type ProjectConfig
- type SyncBuildConfig
- type SyncConfig
- type SyncRootsConfig
Constants ¶
const ( ProjectFileName = "nimbu.yml" ProjectDirEnv = "NIMBU_PROJECT_DIR" )
const AppName = "nimbu"
const DefaultAPIHost = "api.nimbu.io"
DefaultAPIHost is the default API host, extracted from the default API URL.
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func ConfigDir ¶
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 ¶
ConfigPath returns the full path to the config file.
func EnsureConfigDir ¶
EnsureConfigDir creates the config directory if it doesn't exist.
func EnsureDataDir ¶
EnsureDataDir creates the data directory if it doesn't exist.
func FindProjectFile ¶
FindProjectFile locates nimbu.yml. Precedence:
- Walk up from NIMBU_PROJECT_DIR, if set (error if nothing is found).
- Walk up from the current working directory.
- If still missing, try the git top-level directory as an extra candidate.
The CWD walk is unbounded (it continues until the filesystem root), so the git fallback only matters when that walk cannot see the repo root.
func ParseRouteRule ¶
ParseRouteRule parses either "<glob>" or "<METHOD> <glob>" route rules.
func ProjectRoot ¶
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 WarnUnknownAppsKeys ¶
WarnUnknownAppsKeys returns warning strings for unknown keys in the `apps` block.
func WarnUnknownDevKeys ¶
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 ¶
WarnUnknownSyncKeys returns warning strings for unknown keys in the `sync` block.
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 (*Config) TimeoutDuration ¶
TimeoutDuration returns the timeout as a duration.
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.