Documentation
¶
Overview ¶
Package config provides configuration management for the Sanity CLI.
Index ¶
Constants ¶
const ( // DefaultAPIVersion is used when no version is provided. DefaultAPIVersion = "2024-10-01" // DefaultPerspective is used when no perspective is provided. DefaultPerspective = "published" // DefaultInstanceName is the name assigned during first-run setup. DefaultInstanceName = "default" )
Variables ¶
var GetConfigDir = func() (string, error) { configDir, err := os.UserConfigDir() if err != nil { return "", fmt.Errorf("failed to get user config directory: %w", err) } return filepath.Join(configDir, "sanity-cli"), nil }
GetConfigDir returns the platform-specific config directory for sanity-cli.
Functions ¶
func GetConfigPath ¶
GetConfigPath returns the full path to the config file.
func GetSchemasDir ¶
GetSchemasDir returns the directory used to cache introspected schemas.
func RedactToken ¶
RedactToken returns a redacted form of the token, suitable for display.
Types ¶
type Config ¶
type Config struct {
CurrentInstance string `json:"current_instance,omitempty"`
DefaultProjectID string `json:"default_project_id,omitempty"`
Instances map[string]*Instance `json:"instances,omitempty"`
}
Config holds the application configuration that is persisted to disk.
type Instance ¶
type Instance struct {
ProjectID string `json:"project_id"`
Dataset string `json:"dataset"`
Token string `json:"token"`
APIVersion string `json:"api_version,omitempty"`
UseCDN bool `json:"use_cdn,omitempty"`
Perspective string `json:"perspective,omitempty"`
}
Instance represents a single Sanity environment (project + dataset + token).
func PromptForInstance ¶
PromptForInstance interactively prompts for instance fields.
func (*Instance) EffectiveAPIVersion ¶
EffectiveAPIVersion returns the configured api_version or the default.
func (*Instance) EffectivePerspective ¶
EffectivePerspective returns the configured perspective or the default.