Documentation
¶
Overview ¶
Package config defines the schema for forge.contributor.yaml configuration files that declare dashboard contributor metadata, navigation, widgets, settings, and build configuration.
Index ¶
Constants ¶
const ConfigFileName = "forge.contributor.yaml"
ConfigFileName is the standard name for the contributor config file.
Variables ¶
var ValidBuildModes = map[string]bool{ "static": true, "ssr": true, }
ValidBuildModes is the set of supported build modes.
var ValidFrameworkTypes = map[string]bool{ "astro": true, "nextjs": true, "custom": true, }
ValidFrameworkTypes is the set of supported framework types.
Functions ¶
func FindConfig ¶
FindConfig searches for forge.contributor.yaml starting from dir and walking up to maxDepth parent directories. Returns the absolute path to the config file or an error if not found.
Types ¶
type BridgeFuncConfig ¶
type BridgeFuncConfig struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
}
BridgeFuncConfig declares a bridge function used by this contributor.
type BuildConfig ¶
type BuildConfig struct {
// Mode is the build mode: "static" (EmbeddedContributor) or "ssr" (SSRContributor).
Mode string `json:"mode" yaml:"mode"`
// UIDir is the path to the UI source project relative to the extension root.
// Default: "ui"
UIDir string `json:"ui_dir,omitempty" yaml:"ui_dir,omitempty"`
// DistDir is the build output directory relative to the UI project.
// Defaults: Astro static="dist", Next.js static="out", Next.js SSR=".next"
DistDir string `json:"dist_dir,omitempty" yaml:"dist_dir,omitempty"`
// EmbedPath is the go:embed path relative to the Go package root.
// Used in generated code for the //go:embed directive.
// Default: "{UIDir}/{DistDir}"
EmbedPath string `json:"embed_path,omitempty" yaml:"embed_path,omitempty"`
// SSREntry is the Node.js entry point for SSR mode.
// Default: Astro="dist/server/entry.mjs", Next.js=".next/standalone/server.js"
SSREntry string `json:"ssr_entry,omitempty" yaml:"ssr_entry,omitempty"`
// BuildCmd overrides the framework's default build command.
// Default: Astro="npx astro build", Next.js="npx next build"
BuildCmd string `json:"build_cmd,omitempty" yaml:"build_cmd,omitempty"`
// DevCmd overrides the framework's default dev command.
// Default: Astro="npx astro dev", Next.js="npx next dev"
DevCmd string `json:"dev_cmd,omitempty" yaml:"dev_cmd,omitempty"`
// PagesDir is the subdirectory within the dist that contains page HTML files.
// Default: "pages"
PagesDir string `json:"pages_dir,omitempty" yaml:"pages_dir,omitempty"`
// WidgetsDir is the subdirectory within the dist that contains widget fragments.
// Default: "widgets"
WidgetsDir string `json:"widgets_dir,omitempty" yaml:"widgets_dir,omitempty"`
// SettingsDir is the subdirectory within the dist that contains settings fragments.
// Default: "settings"
SettingsDir string `json:"settings_dir,omitempty" yaml:"settings_dir,omitempty"`
// AssetsDir is the subdirectory within the dist that contains static assets.
// Default: "assets"
AssetsDir string `json:"assets_dir,omitempty" yaml:"assets_dir,omitempty"`
}
BuildConfig contains framework-specific build configuration.
type ContributorConfig ¶
type ContributorConfig struct {
// Name is the unique identifier for this contributor (Go package name, no hyphens).
Name string `json:"name" yaml:"name"`
// DisplayName is the human-readable display name shown in the dashboard.
DisplayName string `json:"display_name" yaml:"display_name"`
// Icon is the icon name used in the dashboard sidebar.
Icon string `json:"icon,omitempty" yaml:"icon,omitempty"`
// Version is the semantic version of this contributor.
Version string `json:"version" yaml:"version"`
// Type is the UI framework used: "astro", "nextjs", or "custom".
Type string `json:"type" yaml:"type"`
// Build contains build-related configuration.
Build BuildConfig `json:"build" yaml:"build"`
Nav []NavItemConfig `json:"nav,omitempty" yaml:"nav,omitempty"`
// Widgets defines widget descriptors for the dashboard overview.
Widgets []WidgetConfig `json:"widgets,omitempty" yaml:"widgets,omitempty"`
// Settings defines settings panel descriptors.
Settings []SettingConfig `json:"settings,omitempty" yaml:"settings,omitempty"`
// BridgeFunctions declares Go↔JS bridge functions this contributor uses.
BridgeFunctions []BridgeFuncConfig `json:"bridge_functions,omitempty" yaml:"bridge_functions,omitempty"`
// Searchable enables search support for this contributor's pages.
Searchable bool `json:"searchable,omitempty" yaml:"searchable,omitempty"`
}
ContributorConfig is the top-level schema for forge.contributor.yaml.
func LoadConfig ¶
func LoadConfig(path string) (*ContributorConfig, error)
LoadConfig reads and validates a forge.contributor.yaml file.
func ParseConfig ¶
func ParseConfig(data []byte) (*ContributorConfig, error)
ParseConfig parses and validates contributor config from raw YAML bytes.
func (*ContributorConfig) ApplyDefaults ¶
func (c *ContributorConfig) ApplyDefaults()
ApplyDefaults fills in default values for optional fields based on the framework type and build mode.
func (*ContributorConfig) DistPath ¶
func (c *ContributorConfig) DistPath(extRoot string) string
DistPath returns the absolute path to the build output directory given the extension root directory.
func (*ContributorConfig) UIPath ¶
func (c *ContributorConfig) UIPath(extRoot string) string
UIPath returns the absolute path to the UI source directory given the extension root directory.
func (*ContributorConfig) Validate ¶
func (c *ContributorConfig) Validate() error
Validate checks the contributor config for required fields and valid values.
type NavItemConfig ¶
type NavItemConfig struct {
}
NavItemConfig defines a navigation entry in forge.contributor.yaml.
type SettingConfig ¶
type SettingConfig struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Group string `json:"group,omitempty" yaml:"group,omitempty"`
Icon string `json:"icon,omitempty" yaml:"icon,omitempty"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
}
SettingConfig defines a settings panel descriptor in forge.contributor.yaml.
type WidgetConfig ¶
type WidgetConfig struct {
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Size string `json:"size" yaml:"size"`
RefreshSec int `json:"refresh_sec,omitempty" yaml:"refresh_sec,omitempty"`
Group string `json:"group,omitempty" yaml:"group,omitempty"`
Priority int `json:"priority,omitempty" yaml:"priority,omitempty"`
}
WidgetConfig defines a widget descriptor in forge.contributor.yaml.