Documentation
¶
Overview ¶
Package fuigo wraps "go install" with optional pre-build steps. It reads a fuigo.yaml from the target module (fetched from the Go module proxy), runs the declared steps, then delegates to go install. Without a fuigo.yaml it behaves exactly like go install.
Index ¶
- Constants
- func Build(dir, relPkg string) error
- func Check(opts Options) error
- func ExecuteSteps(root string, steps []Step, builtins Builtins) error
- func Install(dir, relPkg string) error
- func InstallDir() string
- func ResolveModule(pkg, version string) (srcDir string, resolved string, cleanup func(), err error)
- func Run(opts Options) error
- func SplitModulePath(pkg string) (module, relPkg string)
- func ValidateConfig(dir string) (found bool, steps int, problems []string)
- type Builtins
- type Config
- type Options
- type Step
Constants ¶
const ConfigFile = "fuigo.yaml"
ConfigFile is the name of the per-module configuration file fuigo looks for.
Variables ¶
This section is empty.
Functions ¶
func Build ¶ added in v0.2.2
Build compiles the package at relPkg within the module source rooted at dir without producing a binary (output is discarded via os.DevNull), to verify the code compiles. It is used by dry-run mode in place of go install. relPkg follows the same convention as Install: an empty relPkg builds the module root package. Output is streamed live.
func Check ¶ added in v0.2.0
Check validates the target's fuigo.yaml without executing anything. For a remote target it fetches the module zip, validates, and cleans up. It returns a non-nil error when validation fails (problems are reported via Logf).
func ExecuteSteps ¶
ExecuteSteps runs each step with root as the module root. A step is dispatched by its first token: "go" runs the external go tool; "npmgo" and "esbuild" invoke the built-in libraries. Any other command is rejected. When a step sets a Workdir it runs in root/Workdir, which must stay within root. Execution stops at the first failing step, returning an error that names it.
func Install ¶
Install delegates to "go install" for the package at relPkg within the module source rooted at dir. relPkg is the package path relative to the module root (e.g. "cmd/shoka"); an empty relPkg installs the module root package. Output is streamed live.
func InstallDir ¶
func InstallDir() string
InstallDir reports the directory go install writes binaries to: GOBIN if set, otherwise GOPATH/bin.
func ResolveModule ¶
ResolveModule fetches the source of the module containing pkg at the given version and extracts it to a temporary directory. version may be "", "latest" or an explicit "vX.Y.Z". It returns the extracted source directory, a cleanup function that removes it, and the resolved concrete version.
The primary path downloads a zip from the Go module proxy (no git). If the module is not available on the proxy (e.g. GOPRIVATE repositories) it falls back to a shallow git clone via go-git.
func Run ¶
Run runs any pre-build steps for the target and installs it. The target is either a remote module (fetched from the proxy) or a local directory. It is the entry point used by the CLI.
func SplitModulePath ¶
SplitModulePath splits a full package import path into its module root and the package path relative to that root. For the common VCS hosts the module root is host/owner/repo; e.g. "github.com/sopranoworks/shoka/cmd/shoka" becomes module "github.com/sopranoworks/shoka" and relPkg "cmd/shoka".
func ValidateConfig ¶ added in v0.2.0
ValidateConfig checks the fuigo.yaml in dir without executing anything. It reports whether a config is present, the step count, and every problem found (not just the first). A missing fuigo.yaml is reported as found=false with no problems — that is a valid state (plain go install).
Types ¶
type Builtins ¶
type Builtins struct {
Npmgo func(dir string, args []string) error
Esbuild func(dir string, args []string) error
Logf func(format string, args ...any)
}
Builtins holds the implementations fuigo dispatches built-in steps to. They are injectable so tests can substitute fakes. Logf, when set, receives progress messages; a nil Logf discards them.
func DefaultBuiltins ¶
DefaultBuiltins returns Builtins wired to the compiled-in npmgo and esbuild libraries, logging progress through logf.
type Config ¶
type Config struct {
Steps []Step `yaml:"steps"`
}
Config is the parsed contents of a module's fuigo.yaml.
func LoadConfig ¶
LoadConfig reads fuigo.yaml from dir. If the file does not exist it returns (nil, nil): a module without a fuigo.yaml is valid and means "plain go install". Any present config is validated: steps must be non-empty and every step must start with one of the allowed commands.
type Options ¶
type Options struct {
// Package is the target: a remote module path (optionally with an
// "@version" suffix, e.g. "github.com/sopranoworks/shoka/cmd/shoka@latest")
// or a local directory (".", "./path", "/abs/path").
Package string
// Subpkg optionally names the package to install for a local target, e.g.
// "./cmd/shoka". When empty, local installs auto-detect ./cmd/*.
Subpkg string
// Yes skips the confirmation prompt before executing steps.
Yes bool
// List prints the pre-build steps without executing anything.
List bool
// DryRun executes all pre-build steps but skips the final go install.
DryRun bool
// Logf receives progress messages (without a trailing newline). If nil,
// messages are discarded.
Logf func(format string, args ...any)
// In is the source of the confirmation answer; defaults handled by caller.
In io.Reader
// Out is where the confirmation prompt is written.
Out io.Writer
}
Options configures a Run or Check.
type Step ¶ added in v0.1.1
Step is a single pre-build step. It is either a bare command (string form) or a command plus a workdir (map form). Workdir is a path relative to the module root; an empty Workdir means the module root itself.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
fuigo
command
Command fuigo is a drop-in "go install" replacement that runs a module's declared pre-build steps (from fuigo.yaml) before installing.
|
Command fuigo is a drop-in "go install" replacement that runs a module's declared pre-build steps (from fuigo.yaml) before installing. |