config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package config loads puzzle.config.js — the app's optional configuration file (constellation/doc/DOC-DECISIONS.md D12). The Go side must never parse JavaScript (D3), so the config is read by executing node: it imports the ES module and prints its default export as JSON, which Go then unmarshals. No config file present means zero-config defaults and no node invocation at all.

v1 surface (SPEC §3, §11): styles.use accepts the single string entry "tailwindcss". The object form (`{ name: 'sass', ... }`) and any other string are parsed and rejected with a clear "not in v1" error — the grammar is recognized so the message can name what was deferred, not a generic failure.

Index

Constants

View Source
const ConfigFileName = "puzzle.config.js"

ConfigFileName is the app-root config file. Its absence is not an error.

Variables

This section is empty.

Functions

This section is empty.

Types

type Build

type Build struct {
	// DropConsole is the tri-state build.dropConsole setting: nil means the key
	// was absent (default behavior), a non-nil pointer is the explicit user
	// value. The pointer lets "unset" be distinguished from an explicit false.
	DropConsole *bool
}

Build mirrors the `build` block of puzzle.config.js.

type Config

type Config struct {
	Styles Styles
	Build  Build
	// Output is the resolved `output` key: "" (absent — the default SPA build)
	// or "static" (per-route static HTML, the SSG mode). Any other value is
	// rejected by validate with a message naming the allowed values.
	Output string
}

Config is the resolved, validated configuration. The zero value is the valid "no config file" state: no style pipelines declared, default build, SPA output.

func LoadConfig

func LoadConfig(appRoot string) (Config, error)

LoadConfig loads and validates puzzle.config.js from appRoot.

  • No config file: returns the zero Config and no error (no node needed).
  • Config present but node missing / unrunnable: a clear error.
  • Config present but malformed JS: node's syntax error, surfaced.
  • A deferred entry (object form, or a non-"tailwindcss" string): a "not in v1" error naming the entry.

func (Config) DropConsole

func (c Config) DropConsole() bool

DropConsole reports whether production builds should strip console.* calls. Unset (no config file, or build.dropConsole absent) defaults to true — the v1 behavior; build.dropConsole: false opts out.

func (Config) StaticOutput

func (c Config) StaticOutput() bool

StaticOutput reports whether the app declares the static (SSG) output mode via `output: 'static'`. Absent (or no config file) reports false — the default SPA build. The `puzzle build --static` flag enables the same step without touching the config.

func (Config) TailwindEnabled

func (c Config) TailwindEnabled() bool

TailwindEnabled reports whether the Tailwind pipeline is declared.

type Styles

type Styles struct {
	// Use lists the enabled style pipelines. In v1 the only accepted entry is
	// "tailwindcss"; the slice is therefore either empty or ["tailwindcss"].
	Use []string
}

Styles mirrors the `styles` block of puzzle.config.js.

Jump to

Keyboard shortcuts

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