Documentation
¶
Index ¶
- Constants
- Variables
- func EnsureTinyGo(out io.Writer) error
- func RunAuth(envPath string, out io.Writer, check bool) error
- func RunBuild(envPath string, out io.Writer) error
- func RunDeploy(envPath string, out io.Writer) error
- func Usage() string
- type CfClient
- type Config
- type DeployResult
- type Goflare
- func (g *Goflare) Auth() error
- func (g *Goflare) Build() error
- func (h *Goflare) Change(newValue string, progress func(msgs ...any))
- func (g *Goflare) Deploy() error
- func (g *Goflare) DeployPages() error
- func (g *Goflare) DeployWorker() error
- func (g *Goflare) GeneratePagesFiles() error
- func (g *Goflare) GenerateWorkerFiles() error
- func (h *Goflare) Label() string
- func (g *Goflare) Logger(messages ...any)
- func (h *Goflare) MainInputFileRelativePath() string
- func (h *Goflare) Name() string
- func (h *Goflare) NewFileEvent(fileName, extension, filePath, event string) error
- func (g *Goflare) SetCompilerMode(newValue string)
- func (g *Goflare) SetLog(f func(message ...any))
- func (h *Goflare) Shortcuts() []map[string]string
- func (g *Goflare) StagingDir() string
- func (h *Goflare) SupportedExtensions() []string
- func (h *Goflare) UnobservedFiles() []string
- func (g *Goflare) ValidateDeployScopes(client *CfClient) error
- func (h *Goflare) Value() string
- func (g *Goflare) WriteSummary(out io.Writer, results []DeployResult)
- type MemoryStore
- type Mode
- type Store
Constants ¶
const ( EnvKeyProjectName = "PROJECT_NAME" EnvKeyAccountID = "CLOUDFLARE_ACCOUNT_ID" EnvKeyWorkerName = "WORKER_NAME" EnvKeyDomain = "DOMAIN" EnvKeyCompilerMode = "COMPILER_MODE" EnvKeyD1DatabaseID = "D1_DATABASE_ID" EnvKeyD1DatabaseName = "D1_DATABASE_NAME" )
Variables ¶
var ErrNotFound = errors.New("not found")
Functions ¶
func EnsureTinyGo ¶ added in v0.2.22
EnsureTinyGo installs TinyGo if absent and guarantees its bin dir is in PATH before any compilation attempt. Safe to call multiple times (idempotent).
Types ¶
type Config ¶
type Config struct {
// Project identity
ProjectName string // PROJECT_NAME
AccountID string // CLOUDFLARE_ACCOUNT_ID
WorkerName string // WORKER_NAME (default: ProjectName + "-worker")
// Routing
Domain string // DOMAIN (optional — custom domain for Pages)
// Build inputs (conventions, not configurable via .env)
Entry string // ENTRY (path to main Go file, empty = Pages only)
PublicDir string // PUBLIC_DIR (path to static assets, empty = Worker only)
// Build output (not in .env — always .build/)
OutputDir string // default: ".build/"
// Pages Functions output (sibling to web/public/, committed to git)
FunctionsDir string // default: "functions"
// Compiler
CompilerMode string // "S" | "M" | "L" default: "S"
D1DatabaseID string // D1_DATABASE_ID
D1DatabaseName string // D1_DATABASE_NAME — optional, default: ProjectName
}
func LoadConfigFromEnv ¶ added in v0.1.0
LoadConfigFromEnv reads a .env file and populates Config. Falls back to OS environment variables if .env path is empty or does not exist. Applies defaults after loading.
func (*Config) ValidateBuild ¶ added in v0.2.17
ValidateBuild checks only what goflare build requires. ProjectName and AccountID are deploy-only — never referenced by build.go.
func (*Config) ValidateDeploy ¶ added in v0.2.17
ValidateDeploy checks everything required for a Cloudflare API deploy.
type DeployResult ¶ added in v0.1.0
DeployResult represents the result of a deployment to a target.
type Goflare ¶
type Goflare struct {
Config *Config // exported so CLI can read it after LoadConfigFromEnv
BaseURL string
RetryBackoff time.Duration // base duration for retries (defaults to 1s)
// contains filtered or unexported fields
}
func (*Goflare) Build ¶ added in v0.1.0
Build orchestrates the build pipeline as a method.
Mode is inferred from edge/main.go imports (D11):
- pages-functions: edge/main.go imports github.com/tinywasm/goflare/pages → output functions/[path].mjs + functions/edge.wasm
- workers: edge/main.go imports github.com/tinywasm/goflare/workers → output .build/edge.js + .build/edge.wasm (legacy)
- pages (static): no edge/main.go but PublicDir exists → only static + optional frontend wasm
func (*Goflare) DeployPages ¶ added in v0.0.97
func (*Goflare) DeployWorker ¶ added in v0.0.99
func (*Goflare) GeneratePagesFiles ¶
func (*Goflare) GenerateWorkerFiles ¶
func (*Goflare) MainInputFileRelativePath ¶
MainInputFileRelativePath returns the relative path to the main input file This is used by devwatch to determine file ownership for Go files
func (*Goflare) NewFileEvent ¶
NewFileEvent handles file change events for goflare This method is called by devwatch when a relevant file changes
func (*Goflare) SetCompilerMode ¶
SetCompilerMode changes the compiler mode mode: "L" (Large fast/Go), "M" (Medium TinyGo debug), "S" (Small TinyGo production)
func (*Goflare) StagingDir ¶ added in v0.2.13
StagingDir returns the temporary directory used for intermediate build artifacts. Exposed for testing — verifies that staging is outside the project tree.
func (*Goflare) SupportedExtensions ¶
SupportedExtensions returns the file extensions that goflare monitors For edge workers, we primarily watch .go files
func (*Goflare) UnobservedFiles ¶
UnobservedFiles returns files that should be ignored by the file watcher These are output files generated by goflare that shouldn't trigger recompilation
func (*Goflare) ValidateDeployScopes ¶ added in v0.3.0
DeployPages uploads the Pages build output (from config.OutputDir) to Cloudflare Pages. validateDeployScopes confirms that the token has the necessary permissions to manage Pages projects and deployments.
func (*Goflare) WriteSummary ¶ added in v0.1.0
func (g *Goflare) WriteSummary(out io.Writer, results []DeployResult)
WriteSummary formats and writes the deploy summary to out.
type MemoryStore ¶ added in v0.1.0
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store exported for use by library consumers in tests. Safe for concurrent use.
func NewMemoryStore ¶ added in v0.1.0
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Set ¶ added in v0.1.0
func (s *MemoryStore) Set(key, value string) error