layout

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package layout provides functionality to scaffold a new Go web application project

Index

Constants

This section is empty.

Variables

View Source
var DefaultGoTools = []GoTool{
	{Name: "templ", Source: "github.com/a-h/templ/cmd/templ", Version: versions.Templ},
	{Name: "goose", Source: "github.com/pressly/goose/v3/cmd/goose", Version: versions.Goose},
	{Name: "mailpit", Source: "github.com/axllent/mailpit", Version: versions.Mailpit},
	{Name: "usql", Source: "github.com/xo/usql", Version: versions.Usql},
	{Name: "dblab", Source: "github.com/danvergara/dblab", Version: versions.Dblab},
	{Name: "shadowfax", Source: "github.com/mbvlabs/shadowfax", Version: versions.Shadowfax},
}

DefaultGoTools provides default go tools.

Functions

func ApplyExtension added in v1.0.0

func ApplyExtension(rootDir, extensionName string) ([]string, error)

ApplyExtension adds an extension to an existing project. It:

  1. Reconstructs the project context (TemplateData + lock) from disk.
  2. Re-applies all existing extensions to rebuild the full blueprint state.
  3. Applies the new extension (generates its code files + mutates the blueprint).
  4. Re-renders all blueprint-consuming templates (config.go, .env.example, main.go, etc.) with the updated blueprint.
  5. Runs post-steps and code generation tools (goose fix, templ generate, go mod tidy).
  6. Updates and writes andurel.lock.

Returns the names of all newly applied extensions (the requested extension plus any unsatisfied dependencies).

func AvailableExtensionNames added in v1.0.0

func AvailableExtensionNames() ([]string, error)

AvailableExtensionNames returns the sorted names of built-in extensions.

func GetExpectedTools added in v1.0.0

func GetExpectedTools(config *ScaffoldConfig) map[string]*Tool

GetExpectedTools returns the list of tools that should exist for a given scaffold config

func GetRunToolVersion added in v1.0.0

func GetRunToolVersion() string

GetRunToolVersion returns the version of the run tool

func IsSupportedInertiaAdapter added in v1.0.0

func IsSupportedInertiaAdapter(adapter string) bool

IsSupportedInertiaAdapter reports whether adapter names a frontend adapter Andurel knows how to scaffold.

func IsSupportedJavaScriptRuntime added in v1.0.0

func IsSupportedJavaScriptRuntime(runtime string) bool

IsSupportedJavaScriptRuntime reports whether runtime is a known JavaScript package manager.

func LoadProjectContext added in v1.0.0

func LoadProjectContext(rootDir string) (*TemplateData, *AndurelLock, error)

LoadProjectContext reconstructs TemplateData and AndurelLock from an existing project on disk. It reads the lock file for scaffold configuration, parses go.mod for the module path and Go version, and reads secrets from .env.example (or .env as fallback) so they are preserved when blueprint templates are re-rendered.

The blueprint is rebuilt from scratch by calling initializeBlueprint and then re-applying all existing extensions with a no-op ProcessTemplate. This restores the full blueprint state (config fields, env vars, imports, etc.) without overwriting any existing extension-generated files.

func Scaffold

func Scaffold(
	targetDir, projectName, database, version string,
	extensionNames []string,
	inertia, javascriptRuntime string,
) error

Scaffold creates a new Andurel project in the target directory.

Types

type AndurelLock added in v0.32.2

type AndurelLock struct {
	SchemaVersion  int                   `json:"schemaVersion"`
	Version        string                `json:"version"`
	Extensions     map[string]*Extension `json:"extensions,omitempty"`
	Tools          map[string]*Tool      `json:"tools"`
	ScaffoldConfig *ScaffoldConfig       `json:"scaffoldConfig,omitempty"`
	DatabaseConfig *DatabaseConfig       `json:"databaseConfig,omitempty"`
}

AndurelLock is the serialized project lock file for tools and extensions.

func NewAndurelLock added in v0.32.2

func NewAndurelLock(version string) *AndurelLock

NewAndurelLock creates an empty lock file model for a version.

func ReadLockFile added in v0.32.2

func ReadLockFile(targetDir string) (*AndurelLock, error)

ReadLockFile reads lock file.

func (*AndurelLock) AddExtension added in v0.37.2

func (l *AndurelLock) AddExtension(name, appliedAt string)

AddExtension records an applied extension in the lock file.

func (*AndurelLock) AddTool added in v0.37.2

func (l *AndurelLock) AddTool(name string, tool *Tool)

AddTool records a managed tool in the lock file.

func (*AndurelLock) ExtensionNames added in v1.0.0

func (l *AndurelLock) ExtensionNames() []string

ExtensionNames returns the names of all applied extensions in sorted order.

func (*AndurelLock) Sync added in v0.37.2

func (l *AndurelLock) Sync(targetDir string, silent bool) error

Sync downloads missing managed tools and rewrites the lock file.

func (*AndurelLock) WriteLockFile added in v0.32.2

func (l *AndurelLock) WriteLockFile(targetDir string) error

WriteLockFile writes andurel.lock into the target directory.

type DatabaseConfig added in v1.0.0

type DatabaseConfig struct {
	NullType string `json:"nullType"`
}

DatabaseConfig records database generation settings.

type Element

type Element struct {
	RootDir string
	SubDirs []Element
}

Element describes a directory tree node to create during scaffolding.

type Extension added in v0.37.2

type Extension struct {
	AppliedAt string `json:"appliedAt"`
}

Extension records when an extension was applied.

type FrameworkManagedFile added in v1.0.0

type FrameworkManagedFile struct {
	TemplateName string
	TargetPath   string
}

FrameworkManagedFile identifies a template-backed file that Andurel owns.

func GetAllManagedInternalFrameworkFiles added in v1.0.0

func GetAllManagedInternalFrameworkFiles() []FrameworkManagedFile

GetAllManagedInternalFrameworkFiles returns every internal package file Andurel can manage.

func GetInternalFrameworkFiles added in v1.0.0

func GetInternalFrameworkFiles(config *ScaffoldConfig) []FrameworkManagedFile

GetInternalFrameworkFiles returns the internal package files expected for a project config.

type GoTool added in v0.37.2

type GoTool struct {
	Name    string
	Source  string
	Version string
}

GoTool represents go tool.

type ScaffoldConfig added in v0.38.9

type ScaffoldConfig struct {
	ProjectName       string `json:"projectName"`
	Database          string `json:"database"`
	Inertia           string `json:"inertia,omitempty"`
	JavaScriptRuntime string `json:"javascriptRuntime,omitempty"`
}

ScaffoldConfig records the options used to create a project.

type TemplateData

type TemplateData struct {
	AppName              string
	ProjectName          string
	ModuleName           string
	Database             string // Always "postgresql"
	GoVersion            string
	SessionKey           string
	SessionEncryptionKey string
	TokenSigningKey      string
	Pepper               string
	Extensions           []string
	RunToolVersion       string // Version of the run built tool
	FrameworkVersion     string // Version of the framework that generated managed files
	Inertia              string // "vue", "react", etc. Empty means templ-only
	// contains filtered or unexported fields
}

TemplateData carries the values available to base templates and extension contributions. It wraps a Blueprint for structured data alongside project-level metadata.

func (*TemplateData) Blueprint

func (td *TemplateData) Blueprint() *blueprint.Blueprint

Blueprint returns the underlying blueprint. If not yet initialized, creates a new one.

func (*TemplateData) Builder

func (td *TemplateData) Builder() *blueprint.Builder

Builder returns a builder adapter wrapping the template data's blueprint. The return type satisfies the extensions.Builder interface.

func (*TemplateData) DatabaseDialect

func (td *TemplateData) DatabaseDialect() string

DatabaseDialect returns the configured database, which is always PostgreSQL.

func (*TemplateData) GetInertia added in v1.0.0

func (td *TemplateData) GetInertia() string

GetInertia returns the inertia adapter for the project, if any.

func (*TemplateData) GetModuleName

func (td *TemplateData) GetModuleName() string

GetModuleName returns the module name for the project.

func (*TemplateData) SetBlueprint

func (td *TemplateData) SetBlueprint(bp *blueprint.Blueprint)

SetBlueprint sets the blueprint for this template data.

type TmplTarget

type TmplTarget string

TmplTarget represents tmpl target.

type TmplTargetPath

type TmplTargetPath string

TmplTargetPath represents tmpl target path.

type Tool added in v0.37.2

type Tool struct {
	Version      string        `json:"version,omitempty"`
	Source       string        `json:"source,omitempty"`
	Path         string        `json:"path,omitempty"`
	Download     *ToolDownload `json:"download,omitempty"`
	VersionCheck *VersionCheck `json:"versionCheck,omitempty"`
}

Tool records the desired version and source for a managed tool.

func NewBinaryTool added in v0.37.2

func NewBinaryTool(name, version string) *Tool

NewBinaryTool creates a managed downloaded binary tool entry.

func NewBuiltTool added in v0.37.2

func NewBuiltTool(path, version string) *Tool

NewBuiltTool creates a managed project-built tool entry.

func NewGoTool added in v0.37.2

func NewGoTool(name, source, version string) *Tool

NewGoTool creates a managed Go-installed tool entry.

type ToolDownload added in v1.0.0

type ToolDownload struct {
	URLTemplate string            `json:"urlTemplate"`
	Archive     string            `json:"archive,omitempty"`
	BinaryName  string            `json:"binaryName,omitempty"`
	SHA256      map[string]string `json:"sha256"`
}

ToolDownload describes how to download a managed tool binary.

func GetDefaultToolDownload added in v1.0.0

func GetDefaultToolDownload(name string) (*ToolDownload, bool)

GetDefaultToolDownload returns the built-in download spec for a tool.

type VersionCheck added in v1.0.0

type VersionCheck struct {
	Args []string `json:"args"`
	// Regexp extracts a version from command output. When omitted, Andurel uses
	// v?MAJOR.MINOR.PATCH with optional prerelease or build metadata.
	Regexp string `json:"regexp,omitempty"`
}

VersionCheck describes how to check an installed tool version.

func GetDefaultToolVersionCheck added in v1.0.0

func GetDefaultToolVersionCheck(name string) (*VersionCheck, bool)

GetDefaultToolVersionCheck returns the built-in version check for a tool.

Directories

Path Synopsis
Package blueprint provides structured types for scaffold configuration that support additive merges from multiple extensions without conflicts.
Package blueprint provides structured types for scaffold configuration that support additive merges from multiple extensions without conflicts.
Package cmds holds commands being used for scaffolding
Package cmds holds commands being used for scaffolding
Package extensions provides the framework for registering and applying extensions to the scaffold generation process.
Package extensions provides the framework for registering and applying extensions to the scaffold generation process.
Package templates exposes the embedded templates used to scaffold Andurel projects.
Package templates exposes the embedded templates used to scaffold Andurel projects.
Package upgrade plans and applies transactional upgrades to generated projects.
Package upgrade plans and applies transactional upgrades to generated projects.
Package versions defines default versions for tools installed in generated projects.
Package versions defines default versions for tools installed in generated projects.

Jump to

Keyboard shortcuts

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