cli

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigParser func(projectRoot string) (*Config, error)

ConfigParser is the indirection that lets pkg/cli call into pkg/helpers/astconfig.Parse without creating an import cycle (astconfig imports cli for the Config type, so cli must not import astconfig directly). It is registered by astconfig's init() once that package is loaded by the command layer. astconfig.Parse(projectRoot) populates it.

View Source
var NewBinaryManager func(c *Config) BinaryManager

NewBinaryManager is registered by pkg/helpers/tofu's init() (loaded by the command layer). It builds a BinaryManager bound to the resolved Config.

View Source
var NewCDNEngine func(c *Config, awsCfg any) CDNEngine
View Source
var NewDeploymentEngine func(c *Config, awsCfg any) (DeploymentEngine, error)

NewDeploymentEngine and NewCDNEngine are registered by pkg/helpers/tofu's init(). They construct the AWS-backed engine and CDN from the resolved config and a loaded aws.Config. The aws.Config is passed as `any` to keep the aws-sdk type out of this interface boundary; the tofu package type-asserts it.

Functions

func ValidateBucketName

func ValidateBucketName(name string) error

func ValidateStageName

func ValidateStageName(name string) error

Types

type AWSProvider added in v3.0.1

type AWSProvider struct {
	ServerMemory  int                     `json:"serverMemory"`
	ServerTimeout int                     `json:"serverTimeout"`
	Region        string                  `json:"region"`
	Profile       string                  `json:"profile"`
	Stages        map[string]EnvVariables `json:"stages"`
}

AWSProvider mirrors config.AWSProvider: the AWS-specific deploy settings.

type BinaryManager

type BinaryManager interface {
	EnsureBinary(ctx context.Context) (string, error)
}

BinaryManager resolves the OpenTofu binary path (config override, on-disk cache, or download). The concrete implementation lives in pkg/helpers/tofu, which already imports pkg/cli for the Config type — so to avoid an import cycle the interface is declared here and the constructor is injected via NewBinaryManager below, mirroring the ConfigParser indirection.

type CDNEngine

type CDNEngine interface {
	SyncAssets(ctx context.Context, bucketName string, localDir string) error
	RemoveAssets(ctx context.Context, bucketName string) error
	InvalidateCache(ctx context.Context, distributionID string) error
}

CDNEngine mirrors tofu.CDNEngine (see DeploymentEngine for the cycle rationale).

type CliCommands

type CliCommands struct {
	Init            *bool
	Build           *string
	Deploy          *bool
	Help            *bool
	ImgOptimization *bool
	HotReload       *bool
	DeployAction    *string
	DeployStage     *string
}

type Config

type Config struct {
	ProjectName       string `json:"projectName"`
	GoModName         string `json:"goModuleName"`
	TofuBinaryPath    string `json:"tofuBinaryPath,omitempty"`
	DockerfilePath    string `json:"dockerfilePath,omitempty"`
	TailwindBinary    string `json:"tailwindBinary,omitempty"`
	WasmBinary        string `json:"wasmBinary,omitempty"`
	WasmTinyGoVersion string `json:"wasmTinyGoVersion,omitempty"`
	OptimizeImages    struct {
		LowResolutionRate int `json:"lowResolutionRate"`
	} `json:"optimizeImages"`
	Deploy *DeployConfig `json:"deploy"`
}

type DeployConfig

type DeployConfig struct {
	Provider  Provider  `json:"provider"`
	Providers Providers `json:"providers"`
}

DeployConfig mirrors config.DeployConfig: a provider selector plus per-provider settings. The AWS-specific fields moved under Providers.AWS.

type DeploymentEngine

type DeploymentEngine interface {
	Prepare(ctx context.Context, stage string) error
	Build(ctx context.Context, tag string) (string, error)
	Deploy(ctx context.Context) (map[string]string, error)
	Destroy(ctx context.Context) error
}

DeploymentEngine mirrors tofu.DeploymentEngine. It is declared here (rather than imported) so pkg/cli does not import pkg/helpers/tofu — which would be an import cycle, since tofu imports pkg/cli for the Config type. The concrete implementation is constructed via the injected NewDeploymentEngine below.

type EnvVariables

type EnvVariables struct {
	BucketName     string
	LambdaName     string
	HostedZoneId   *config.EnvValue           `json:"hostedZoneId"`
	CustomDomain   *config.EnvValue           `json:"customDomain"`
	CertificateArn *config.EnvValue           `json:"certificateArn"`
	WafArn         *config.EnvValue           `json:"wafArn"`
	ENV            map[string]config.EnvValue `json:"env,omitempty"`
}

type FrameworkModule

type FrameworkModule struct {
	Path    string
	Version string
}

FrameworkModule is a published Gothic library together with the version that `gothic init` pins it to in a freshly scaffolded project.

type GothicCli

type GothicCli struct {
	Runtime string

	Templates       helpers.TemplateHelper
	Tailwind        buildtools.TailwindHelper
	Templ           buildtools.TemplHelper
	Logger          *slog.Logger
	FileBasedRouter routes.FileBasedRouteHelper
	Proxy           proxy.ProxyHelper
	Wasm            wasmhelper.WasmHelper
	BinaryManager   BinaryManager
	Engine          DeploymentEngine
	CDN             CDNEngine
	// contains filtered or unexported fields
}

func NewCli

func NewCli() GothicCli

func (*GothicCli) GetConfig

func (cli *GothicCli) GetConfig() (Config, error)

func (*GothicCli) InitializeModule

func (cli *GothicCli) InitializeModule(goModuleName string, modules []FrameworkModule) error

InitializeModule runs `go mod init` for a new project and pins each framework library to the version the scaffolding CLI ships with.

Each pin is a per-module version (core / components / middlewares version independently), written with `go mod edit -require` — a purely textual, offline edit — so a fresh project records the intended versions even before those libraries are published to the module proxy.

It deliberately does NOT run `go mod tidy` here: at init time the generated sub-packages (src/layouts, src/pages, …) have no `.go` files yet (templ + route codegen runs afterwards), so a tidy would fail to resolve them and leave an empty go.sum. `gothic init` calls TidyModule AFTER all codegen instead.

This is the ONLY place the CLI writes framework versions into a user's go.mod. No other command rewrites them, so a project may bump any framework library independently after `init`.

func (*GothicCli) TidyModule

func (cli *GothicCli) TidyModule() error

TidyModule runs `go mod tidy` in the project root to resolve every dependency (framework libraries + templ/chi/godotenv) and populate go.sum. It MUST run AFTER the templ + route codegen so all generated sub-packages resolve; running it before (e.g. inside InitializeModule) fails and leaves an empty go.sum.

Best-effort: it warns rather than aborts when the framework versions aren't yet published to the registry (dev/pre-publish), so `gothic init` still completes.

type Provider added in v3.0.1

type Provider int

Provider mirrors config.Provider: the internal enum the AST parser produces to select a deploy provider. AWS is the zero value / only supported value in v3.

const (
	AWS Provider = iota
)

type Providers added in v3.0.1

type Providers struct {
	AWS AWSProvider `json:"aws"`
}

Providers mirrors config.Providers.

Jump to

Keyboard shortcuts

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