waveconfig

package
v0.85.0-pre.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package waveconfig provides JSON parsing with filesystem-path invariants that can be applied to typed configuration structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustReadFile

func MustReadFile(fileSystem fs.FS, filePath string) []byte

MustReadFile wraps fs.ReadFile and panics on error.

Types

type CoreConfig

type CoreConfig interface {
	// ProjectID returns Core.ProjectID exactly as configured (trimmed).
	ProjectID() string
	// ConfiguredResolveRoot returns Core.ResolveRoot exactly as configured in
	// JSON (unresolved), or empty when not set.
	ConfiguredResolveRoot() string
	// DevBuildHook returns Core.DevBuildHook exactly as configured (command
	// string; not path-resolved).
	DevBuildHook() string
	// DevBuildHookTimeoutMilliseconds returns the parsed Core
	// DevBuildHookTimeoutMilliseconds value.
	DevBuildHookTimeoutMilliseconds() int
	// ProdBuildHook returns Core.ProdBuildHook exactly as configured (command
	// string; not path-resolved).
	ProdBuildHook() string
	// ProdBuildHookTimeoutMilliseconds returns the parsed Core
	// ProdBuildHookTimeoutMilliseconds value.
	ProdBuildHookTimeoutMilliseconds() int
	// MainAppEntry is normalized relative to effective ResolveRoot (which itself
	// is relative to parser config-path basis).
	MainAppEntry() string
	// StaticAssetDirsPrivate is normalized relative to effective ResolveRoot.
	StaticAssetDirsPrivate() string
	// StaticAssetDirsPublic is normalized relative to effective ResolveRoot.
	StaticAssetDirsPublic() string
	// CriticalCSSEntryFile is normalized relative to effective ResolveRoot.
	CriticalCSSEntryFile() string
	// NonCriticalCSSEntryFile is normalized relative to effective ResolveRoot.
	NonCriticalCSSEntryFile() string
	// PublicPathPrefix returns Core.PublicPathPrefix exactly as configured.
	PublicPathPrefix() string
	// ServerOnlyMode returns the parsed Core.ServerOnlyMode value.
	ServerOnlyMode() bool
	// SequentialGoBuild returns the parsed Core.SequentialGoBuild value.
	SequentialGoBuild() bool
	// Clone returns a defensive copy of this parsed Core config.
	Clone() CoreConfig
	// contains filtered or unexported methods
}

CoreConfig is the parsed, normalized Core config section.

type DistLayout

type DistLayout interface {
	// Root returns the normalized dist root path relative to parser
	// config-path basis.
	Root() string
	// Binary returns the dist-relative path to the compiled app binary.
	Binary() string
	// Static returns the dist-relative static output root.
	Static() string
	// StaticPublic returns the dist-relative public static asset directory.
	StaticPublic() string
	// StaticPrivate returns the dist-relative private static asset directory.
	StaticPrivate() string
	// Internal returns the dist-relative internal artifact directory.
	Internal() string
	// CriticalCSS returns the dist-relative critical CSS artifact path.
	CriticalCSS() string
	// NormalCSSRef returns the dist-relative normal CSS reference artifact path.
	NormalCSSRef() string
	// PublicFileMapRef returns the dist-relative public file-map reference path.
	PublicFileMapRef() string
	// PublicFileMapGob returns the dist-relative public file-map gob path.
	PublicFileMapGob() string
	// PrivateFileMapGob returns the dist-relative private file-map gob path.
	PrivateFileMapGob() string
	// BuildOutputLedger returns the dist-relative build-output ledger path.
	BuildOutputLedger() string
	// KeepFile returns the dist-relative static keep-file path.
	KeepFile() string
	// Clone returns a defensive copy of this parsed dist layout.
	Clone() DistLayout
	// contains filtered or unexported methods
}

DistLayout provides parsed dist layout paths normalized to the parser config-path basis passed to ParseConfigJSONWithConfigPath.

type ParsedConfig

type ParsedConfig interface {
	// Core returns the parsed Core section.
	Core() CoreConfig
	// Vite returns the parsed Vite section, or nil when omitted.
	Vite() ViteConfig
	// Watch returns the parsed Watch section, or nil when omitted.
	Watch() WatchConfig
	// Dist returns parsed dist layout paths derived by parser from the
	// config-sibling `.wavedist` directory.
	Dist() DistLayout
	// ConfigFileDirectory returns effective ResolveRoot in parser config-path
	// basis.
	ConfigFileDirectory() string
	// SemanticConfigJSON returns canonical JSON bytes for semantic config
	// equality checks.
	SemanticConfigJSON() []byte
	// PublicPathPrefix returns the normalized effective public path prefix.
	PublicPathPrefix() string
	// ViteManifestPath returns the expected private static path of Vite's
	// manifest file.
	ViteManifestPath() string
	// ResolveRoot returns effective resolve root in parser config-path basis.
	ResolveRoot() string
	// HealthcheckEndpoint returns Watch.HealthcheckEndpoint with parser defaults
	// applied.
	HealthcheckEndpoint() string
	// UsingBrowser reports whether browser-mode runtime behavior is enabled.
	UsingBrowser() bool
	// UsingVite reports whether a parsed Vite section is present.
	UsingVite() bool
	// CriticalCSSEntry returns Core.CSSEntryFiles.Critical with parser
	// normalization applied.
	CriticalCSSEntry() string
	// NonCriticalCSSEntry returns Core.CSSEntryFiles.NonCritical with parser
	// normalization applied.
	NonCriticalCSSEntry() string
	// Clone returns a defensive copy of this parsed config snapshot.
	Clone() ParsedConfig
	// contains filtered or unexported methods
}

ParsedConfig is an opaque parsed Wave config handle. It is intentionally an interface so callers cannot construct config instances directly; parsing is the only supported construction path.

func ParseConfigFile

func ParseConfigFile(path string) (ParsedConfig, error)

func ParseConfigJSON

func ParseConfigJSON(data []byte) (ParsedConfig, error)

func ParseConfigJSONWithConfigPath

func ParseConfigJSONWithConfigPath(
	data []byte,
	configPath string,
) (ParsedConfig, error)

type ViteConfig

type ViteConfig interface {
	// JSPackageManagerBaseCmd returns Vite.JSPackageManagerBaseCmd exactly as
	// configured.
	JSPackageManagerBaseCmd() string
	// JSPackageManagerCmdDir is normalized relative to effective ResolveRoot.
	JSPackageManagerCmdDir() string
	// DefaultPort returns Vite.DefaultPort after parse normalization.
	DefaultPort() int
	// ViteConfigFile is normalized relative to effective ResolveRoot.
	ViteConfigFile() string
	// Clone returns a defensive copy of this parsed Vite config.
	Clone() ViteConfig
	// contains filtered or unexported methods
}

ViteConfig is the parsed, normalized Vite config section.

type WatchConfig

type WatchConfig interface {
	// HealthcheckEndpoint returns Watch.HealthcheckEndpoint after parse
	// defaulting/normalization.
	HealthcheckEndpoint() string
	// HookStageFailurePolicy returns Watch.HookStageFailurePolicy after parse
	// defaulting/normalization.
	HookStageFailurePolicy() string
	// PreCommandTimeoutMilliseconds returns the parsed pre-stage command timeout.
	PreCommandTimeoutMilliseconds() int
	// ConcurrentCommandTimeoutMilliseconds returns the parsed concurrent-stage
	// command timeout.
	ConcurrentCommandTimeoutMilliseconds() int
	// ConcurrentNoWaitCommandTimeoutMilliseconds returns the parsed
	// concurrent-no-wait-stage command timeout.
	ConcurrentNoWaitCommandTimeoutMilliseconds() int
	// PostCommandTimeoutMilliseconds returns the parsed post-stage command
	// timeout.
	PostCommandTimeoutMilliseconds() int
	// PreCallbackTimeoutMilliseconds returns the parsed pre-stage callback
	// timeout.
	PreCallbackTimeoutMilliseconds() int
	// ConcurrentCallbackTimeoutMilliseconds returns the parsed concurrent-stage
	// callback timeout.
	ConcurrentCallbackTimeoutMilliseconds() int
	// ConcurrentNoWaitCallbackTimeoutMilliseconds returns the parsed
	// concurrent-no-wait-stage callback timeout.
	ConcurrentNoWaitCallbackTimeoutMilliseconds() int
	// PostCallbackTimeoutMilliseconds returns the parsed post-stage callback
	// timeout.
	PostCallbackTimeoutMilliseconds() int
	// Include returns patterns normalized relative to effective ResolveRoot.
	Include() []wavewatch.WatchedFile
	// ExcludeDirs returns patterns normalized relative to effective ResolveRoot.
	ExcludeDirs() []string
	// ExcludeFiles returns patterns normalized relative to effective ResolveRoot.
	ExcludeFiles() []string
	// Clone returns a defensive copy of this parsed Watch config.
	Clone() WatchConfig
	// contains filtered or unexported methods
}

WatchConfig is the parsed, normalized Watch config section.

Jump to

Keyboard shortcuts

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