projects

package
v0.45.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 10 Imported by: 0

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

func Path

func Path() (string, error)

Path returns the canonical on-disk location, creating the parent directory if missing. Mirrors cmd/iterion-desktop/config.go:configPath so both apps target the same file.

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

func Load() (*Config, error)

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

func (c *Config) AddOrTouch(absDir string) Project

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) ByID

func (c *Config) ByID(id string) *Project

ByID looks up a project by id; returns a copy or nil.

func (*Config) Current

func (c *Config) Current() *Project

Current returns the active project (matching CurrentProjectID) or nil when none is selected.

func (*Config) Remove

func (c *Config) Remove(id string) bool

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

func (c *Config) Save() error

Save atomically writes the registry, preserving every Extras key untouched so desktop-owned settings (Window/Updater/Telemetry/…) survive the round-trip.

func (*Config) SetCurrent

func (c *Config) SetCurrent(id string) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL