Documentation
¶
Overview ¶
Package projects manages the studio's per-user project registry.
On disk at <UserConfigDir>/Iterion/config.json — shared with the desktop (Wails) app's own config (cmd/iterion-desktop/config.go). We only own the `version`, `recent_projects` and `current_project_id` keys; every other top-level key (Window, Updater, Telemetry, FirstRunDone, …) is round-tripped opaquely so the server and desktop can read/write the same file without trampling each other's settings.
Schema v1 mirrors cmd/iterion-desktop/config.go so a project added in either app shows up in the other.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Version int `json:"version"`
RecentProjects []Project `json:"recent_projects"`
CurrentProjectID string `json:"current_project_id"`
// Extras holds the JSON-encoded value of every other top-level key
// observed at load time. Marshalled back verbatim on Save.
Extras map[string]json.RawMessage `json:"-"`
// contains filtered or unexported fields
}
Config is the subset of <UserConfigDir>/Iterion/config.json that the server reads and writes. Extras preserves every other top-level key untouched across save cycles so writing this struct to disk doesn't drop settings owned by the desktop app.
func Load ¶
Load reads the registry. Missing file → fresh Config; corrupt JSON → returns the error so the caller can decide whether to overwrite (callers typically log + start fresh to avoid wedging the studio).
func (*Config) AddOrTouch ¶
AddOrTouch returns the canonical Project for the given absolute directory. If already registered, refreshes LastOpened and flips CurrentProjectID; otherwise inserts a new entry (capped at 20 MRU). Callers must Save() to persist.
func (*Config) Current ¶
Current returns the active project (matching CurrentProjectID) or nil when none is selected.
func (*Config) Remove ¶
Remove drops the project with the given id. Returns true if it was present. If the removed project was current, the new MRU head (if any) becomes current; otherwise CurrentProjectID is cleared.
func (*Config) Save ¶
Save atomically writes the registry, preserving every Extras key untouched so desktop-owned settings (Window/Updater/Telemetry/…) survive the round-trip.
func (*Config) SetCurrent ¶
SetCurrent flips CurrentProjectID. Returns true if the id matches an existing entry; bumps its LastOpened so the MRU sort surfaces it.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
Dir string `json:"dir"`
StoreDir string `json:"store_dir,omitempty"`
LastOpened time.Time `json:"last_opened"`
Color string `json:"color,omitempty"`
}
Project is the registered iterion project. Field tags match cmd/iterion-desktop/config.go:Project exactly.