cli

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package cli provides command-line interface tools for GoSPA.

Package cli provides the state pruning functionality for GoSPA.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(config *BuildConfig)

Build builds the application for production.

func BuildAll

func BuildAll()

BuildAll builds for all platforms.

func BuildIslands added in v0.1.34

func BuildIslands(config *BuildConfig, summary *BuildSummary) error

BuildIslands builds the islands TypeScript bundle into a single JavaScript file.

func Clean

func Clean()

Clean removes build artifacts.

func CreateProject

func CreateProject(name string)

CreateProject creates a new GoSPA project with the given name.

func CreateProjectWithConfig

func CreateProjectWithConfig(config *ProjectConfig) error

CreateProjectWithConfig creates a new GoSPA project with custom configuration.

func CreateProjectWithOptions added in v0.1.33

func CreateProjectWithOptions(name string, template string, nonInteractive bool)

CreateProjectWithOptions creates a new GoSPA project with custom options.

func CreateProjectWithTemplate added in v0.1.33

func CreateProjectWithTemplate(name string, template string)

CreateProjectWithTemplate creates a new GoSPA project with the specified template.

func Dev

func Dev(config *DevConfig)

Dev starts the development server with hot reload.

func DevWithConfig

func DevWithConfig(config *DevConfig) error

DevWithConfig starts the development server with custom configuration.

func Doctor added in v0.1.30

func Doctor(config *DoctorConfig)

Doctor inspects the current project for common setup issues.

func Generate

func Generate(config *GenerateConfig)

Generate generates TypeScript types and routes from Go templates.

func GenerateWithConfig

func GenerateWithConfig(config *GenerateConfig) error

GenerateWithConfig generates code with custom configuration.

func GetBundlerCommand added in v0.1.36

func GetBundlerCommand(pm PackageManager) string

GetBundlerCommand returns the command to use for client-side bundling.

func GetExecuteCommand added in v0.1.36

func GetExecuteCommand(pm PackageManager) string

GetExecuteCommand returns the "execute" (dlx/x) equivalent for the package manager.

func GetRunCommand added in v0.1.36

func GetRunCommand(pm PackageManager) string

GetRunCommand returns the command to run a script.

func PrintBanner

func PrintBanner()

PrintBanner prints the GoSPA banner

func Prune

func Prune(config *PruneConfig)

Prune executes the state pruning command.

func StateAnalyze

func StateAnalyze(config *PruneConfig)

StateAnalyze executes the state analysis command.

func StateTree

func StateTree(stateFile string, usedPaths []string, jsonOut bool)

StateTree executes the state tree visualization command.

func ValidateProjectName

func ValidateProjectName(name string) error

ValidateProjectName checks if a project name is valid.

func Watch

func Watch()

Watch builds and watches for changes.

Types

type BuildConfig

type BuildConfig struct {
	OutputDir    string
	Platform     string
	Arch         string
	StaticAssets bool
	Minify       bool
	Compress     bool
	Env          string
	SourceMap    bool
	NoSourceMap  bool
	CGO          bool
}

BuildConfig holds configuration for the production build.

type BuildSummary added in v0.1.30

type BuildSummary struct {
	BunPath            string
	ClientRuntimeBuilt bool
	ClientRuntimePath  string
	GoBinaryPath       string
	StaticFilesCopied  int
	CompressedFiles    int
}

BuildSummary captures the important outputs from a production build.

func BuildWithConfig

func BuildWithConfig(config *BuildConfig) (*BuildSummary, error)

BuildWithConfig builds the application with custom configuration.

type ColorPrinter

type ColorPrinter struct {
	// contains filtered or unexported fields
}

ColorPrinter provides colored output utilities

func NewColorPrinter

func NewColorPrinter() *ColorPrinter

NewColorPrinter creates a new color printer

func (*ColorPrinter) Bold

func (p *ColorPrinter) Bold(text string) string

Bold returns bold text

func (*ColorPrinter) Cyan

func (p *ColorPrinter) Cyan(text string) string

Cyan returns cyan text

func (*ColorPrinter) Dim

func (p *ColorPrinter) Dim(text string) string

Dim returns dimmed text

func (*ColorPrinter) Error

func (p *ColorPrinter) Error(format string, args ...interface{})

Error prints a red error message with X mark

func (*ColorPrinter) Green

func (p *ColorPrinter) Green(text string) string

Green returns green text

func (*ColorPrinter) Info

func (p *ColorPrinter) Info(format string, args ...interface{})

Info prints a blue info message

func (*ColorPrinter) ProgressBar

func (p *ColorPrinter) ProgressBar(current, total int, label string)

ProgressBar displays a simple progress bar

func (*ColorPrinter) Red

func (p *ColorPrinter) Red(text string) string

Red returns red text

func (*ColorPrinter) Step

func (p *ColorPrinter) Step(step int, total int, format string, args ...interface{})

Step prints a step in a process

func (*ColorPrinter) Subtitle

func (p *ColorPrinter) Subtitle(format string, args ...interface{})

Subtitle prints a dimmed subtitle

func (*ColorPrinter) Success

func (p *ColorPrinter) Success(format string, args ...interface{})

Success prints a green success message with checkmark

func (*ColorPrinter) Title

func (p *ColorPrinter) Title(format string, args ...interface{})

Title prints a bold title

func (*ColorPrinter) Warning

func (p *ColorPrinter) Warning(format string, args ...interface{})

Warning prints a yellow warning message

func (*ColorPrinter) Yellow

func (p *ColorPrinter) Yellow(text string) string

Yellow returns yellow text

type DevConfig

type DevConfig struct {
	Port       int
	Host       string
	RoutesDir  string
	WatchPaths []string // extra directories to watch in addition to RoutesDir
	Open       bool     // open browser automatically
	Verbose    bool     // verbose logging
	NoRestart  bool     // disable automatic server restart on file changes
}

DevConfig holds configuration for the development server.

type DevWatcher

type DevWatcher struct {
	Events chan FileEvent
	Errors chan error
	// contains filtered or unexported fields
}

DevWatcher watches files for changes.

func NewDevWatcher

func NewDevWatcher(dirs ...string) *DevWatcher

NewDevWatcher creates a new file watcher.

func (*DevWatcher) Start

func (dw *DevWatcher) Start() error

Start begins watching the configured directories.

func (*DevWatcher) Stop

func (dw *DevWatcher) Stop()

Stop closes the watcher.

type DoctorConfig added in v0.1.30

type DoctorConfig struct {
	RoutesDir string
}

DoctorConfig controls CLI doctor checks.

type FileEvent

type FileEvent struct {
	File    string
	Op      FileOp
	ModTime time.Time
}

FileEvent represents a file change event.

type FileOp

type FileOp int

FileOp represents the type of file operation.

const (
	// FileOpCreate is a file creation event
	FileOpCreate FileOp = iota
	// FileOpModify is a file modification event
	FileOpModify
	// FileOpDelete is a file deletion event
	FileOpDelete
	// FileOpRename is a file rename event
	FileOpRename
)

type GenerateConfig

type GenerateConfig struct {
	InputDir      string
	OutputDir     string
	StateFiles    []string
	RouteFiles    []string
	ComponentType string
	DevMode       bool
}

GenerateConfig holds configuration for code generation.

type PackageManager added in v0.1.36

type PackageManager string

PackageManager represents a Node.js package manager.

const (
	// BunPM is the bun package manager.
	BunPM PackageManager = "bun"
	// PnpmPM is the pnpm package manager.
	PnpmPM PackageManager = "pnpm"
	// NpmPM is the npm package manager.
	NpmPM PackageManager = "npm"
	// NonePM is used when no package manager is found.
	NonePM PackageManager = ""
)

func GetPackageManager added in v0.1.36

func GetPackageManager() PackageManager

GetPackageManager returns the best available package manager in priority order: bun, pnpm, npm.

func (PackageManager) String added in v0.1.36

func (pm PackageManager) String() string

type ProjectConfig

type ProjectConfig struct {
	Name           string
	Module         string
	OutputDir      string
	WithGit        bool
	WithDocker     bool
	Template       string
	NonInteractive bool
}

ProjectConfig holds configuration for a new GoSPA project.

type PruneConfig

type PruneConfig struct {
	RootDir    string
	OutputDir  string
	ReportFile string
	KeepUnused bool
	Aggressive bool
	Exclude    []string
	Include    []string
	DryRun     bool
	Verbose    bool
	JSONOutput bool
}

PruneConfig holds configuration for the prune command.

type RemoteActionInfo added in v0.1.33

type RemoteActionInfo struct {
	Name         string
	InputType    string
	OutputType   string
	FunctionType string
}

RemoteActionInfo holds information about a registered remote action

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner shows a spinning animation

func NewSpinner

func NewSpinner(printer *ColorPrinter, message string) *Spinner

NewSpinner creates a new spinner

func (*Spinner) Done

func (s *Spinner) Done()

Done stops the spinner with success

func (*Spinner) Fail

func (s *Spinner) Fail()

Fail stops the spinner with failure

func (*Spinner) Tick

func (s *Spinner) Tick()

Tick advances the spinner

type TypeScriptField

type TypeScriptField struct {
	Name     string
	Type     string
	Optional bool
}

TypeScriptField represents a field in a TypeScript type.

type TypeScriptType

type TypeScriptType struct {
	Name   string
	Fields []TypeScriptField
}

TypeScriptType represents a TypeScript type definition.

Jump to

Keyboard shortcuts

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