Documentation
¶
Index ¶
- Constants
- Variables
- func RunAuth(envPath string, in io.Reader, out io.Writer, reset bool, check bool) error
- func RunBuild(envPath string, out io.Writer) error
- func RunD1Init(envPath, dbName string, store Store, d1 D1Manager, gh GHRunner, w EnvWriter, ...) error
- func RunD1InitCmd(envPath, dbName string) error
- func RunDeploy(envPath string, in io.Reader, out io.Writer) error
- func RunInit(envPath string, in io.Reader, out io.Writer) error
- func UpdateGitignore(dir string) error
- func Usage() string
- func WriteEnvFile(cfg *Config, path string) error
- type Config
- type D1Database
- type D1Manager
- type DeployResult
- type EnvWriter
- type GHRunner
- type Goflare
- func (g *Goflare) Auth(store Store, in io.Reader) error
- func (g *Goflare) Build() error
- func (h *Goflare) Change(newValue string, progress func(msgs ...any))
- func (g *Goflare) Deploy(store Store) error
- func (g *Goflare) DeployPages(store Store) error
- func (g *Goflare) DeployWorker(store Store) error
- func (g *Goflare) GeneratePagesFiles() error
- func (g *Goflare) GenerateWorkerFiles() error
- func (g *Goflare) GetToken(store Store) (string, 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 (h *Goflare) SupportedExtensions() []string
- func (h *Goflare) UnobservedFiles() []string
- func (h *Goflare) Value() string
- func (g *Goflare) WriteSummary(out io.Writer, results []DeployResult)
- type KeyringStore
- type MemoryStore
- type Mode
- type Store
Constants ¶
const ( EnvKeyProjectName = "PROJECT_NAME" EnvKeyAccountID = "CLOUDFLARE_ACCOUNT_ID" EnvKeyWorkerName = "WORKER_NAME" EnvKeyDomain = "DOMAIN" EnvKeyEntry = "ENTRY" EnvKeyPublicDir = "PUBLIC_DIR" EnvKeyCompilerMode = "COMPILER_MODE" EnvKeyD1DatabaseID = "D1_DATABASE_ID" EnvKeyD1DatabaseName = "D1_DATABASE_NAME" )
const ( GHSecretToken = "CLOUDFLARE_API_TOKEN" GHVarAccountID = "CLOUDFLARE_ACCOUNT_ID" GHVarDatabaseID = "D1_DATABASE_ID" )
Variables ¶
var ( ErrNoToken = Err("not authenticated: run 'goflare auth' first") ErrNoAccountID = Err("CLOUDFLARE_ACCOUNT_ID missing: run 'goflare init' first") ErrNoDBName = Err("database name is required (set PROJECT_NAME in .env)") )
Functions ¶
func RunD1Init ¶ added in v0.2.12
func RunD1Init(envPath, dbName string, store Store, d1 D1Manager, gh GHRunner, w EnvWriter, out io.Writer) error
RunD1Init implements `goflare d1 init`.
func RunD1InitCmd ¶ added in v0.2.12
func UpdateGitignore ¶ added in v0.1.0
UpdateGitignore reads .gitignore in dir. Appends .env and .build/ if not already present. Creates .gitignore if it does not exist.
func WriteEnvFile ¶ added in v0.1.0
WriteEnvFile writes a .env file with all non-empty fields.
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
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 — set by `goflare d1 init`
D1DatabaseName string // D1_DATABASE_NAME — optional, default: ProjectName
}
func InitWithDir ¶ added in v0.2.6
InitWithDir runs the interactive wizard with a custom base directory.
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.
type D1Database ¶ added in v0.2.12
type D1Manager ¶ added in v0.2.12
type D1Manager interface {
ListD1Databases(accountID string) ([]D1Database, error)
CreateD1Database(accountID, name string) (D1Database, error)
}
D1Manager abstracts the Cloudflare D1 REST API for listing and creating databases.
type DeployResult ¶ added in v0.1.0
DeployResult represents the result of a deployment to a target.
type GHRunner ¶ added in v0.2.12
type GHRunner interface {
SetSecret(repo, name, value string) error
SetVariable(repo, name, value string) error
RemoteURL() (string, error)
Available() bool
}
GHRunner abstracts the gh CLI for setting GitHub secrets and variables.
type Goflare ¶
type Goflare struct {
Config *Config // exported so CLI can read it after LoadConfigFromEnv
BaseURL string
// contains filtered or unexported fields
}
func (*Goflare) Auth ¶ added in v0.0.97
Auth implements token validation and keyring storage as a method.
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
DeployPages uploads the Pages build output (from config.OutputDir) to Cloudflare Pages.
func (*Goflare) DeployWorker ¶ added in v0.0.99
func (*Goflare) GeneratePagesFiles ¶
func (*Goflare) GenerateWorkerFiles ¶
func (*Goflare) GetToken ¶ added in v0.1.0
GetToken reads the token from the store without prompting.
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) 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) 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 KeyringStore ¶ added in v0.1.0
type KeyringStore struct{}
KeyringStore is the real implementation using go-keyring.
func NewKeyringStore ¶ added in v0.1.0
func NewKeyringStore() *KeyringStore
func (*KeyringStore) Set ¶ added in v0.1.0
func (s *KeyringStore) Set(key, value string) error
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