create

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package create orchestrates the forge create workflow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateConditions

func EvaluateConditions(
	conditions []config.Condition,
	ctyVars map[string]cty.Value,
	fileSet *defaults.FileSet,
	renderer tmpl.Renderer,
) error

EvaluateConditions processes blueprint conditions and removes excluded files from the FileSet. Each condition has a when expression that is evaluated as a bool against the variables; when true, files matching the exclude glob patterns are removed.

Types

type Opts

type Opts struct {
	// BlueprintRef is the user-provided blueprint reference (e.g., "go/api", "go/api@v1.0.0").
	BlueprintRef string

	// OutputDir is the target directory. If empty, derived from project_name variable.
	OutputDir string

	// Overrides are --set key=value pairs from the CLI. Mutually
	// exclusive with VarsFileValues at the CLI layer.
	Overrides map[string]string

	// VarsFiles is the ordered list of `--var-file` paths supplied at
	// the CLI (IMPL-0008). create.Run loads and merges them after the
	// blueprint is parsed, so the declared variable types are known
	// for type coercion. Mutually exclusive with Overrides at the CLI
	// layer; both can be empty (the no-CLI-input case).
	VarsFiles []string

	// UseDefaults skips interactive prompts and uses default values.
	UseDefaults bool

	// NoHooks skips post-create hook execution.
	NoHooks bool

	// ForceCreate allows overwriting a non-empty output directory.
	ForceCreate bool

	// DefaultRegistryURL is the default registry URL from global config.
	DefaultRegistryURL string

	// RegistryDir is a local path to a pre-fetched registry (bypasses remote fetch).
	// Used in tests and when working with local registries.
	RegistryDir string

	// RegistryURL is the canonical URL to store in the lockfile for sync.
	// For local registries, this is the absolute path. For remote registries,
	// this is the go-getter URL. If empty, falls back to RegistryDir.
	RegistryURL string

	// ForgeVersion is the current forge build version for lockfile recording.
	ForgeVersion string

	// PromptFn is the function used for interactive prompting.
	// If nil, prompting is skipped (variables must come from overrides or defaults).
	PromptFn prompt.PromptFn

	// Logger for debug output.
	Logger *slog.Logger
}

Opts holds the options for the create command.

type Result

type Result struct {
	OutputDir    string
	FilesCreated int
	Blueprint    string

	// UnknownVarsFileKeys lists keys declared in any --var-file input
	// that don't correspond to a declared blueprint variable. The CLI
	// surfaces these as a warning (per IMPL-0008 OQ-7 — no
	// --strict-vars flag in v1). Empty when no --var-file paths were
	// supplied or every key matched a declared variable.
	UnknownVarsFileKeys []string

	// Deprecations are non-fatal v0.7 transition notices produced by
	// the blueprint loader (today: the `int`-as-alias-for-`number`
	// warning). The CLI surfaces these via ui.Warningf before the
	// success line per IMPL-0009 OQ-3.
	Deprecations []config.Deprecation
}

Result holds the output of a successful create operation.

func Run

func Run(opts *Opts) (*Result, error)

Run executes the create workflow.

Jump to

Keyboard shortcuts

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