themes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

KindOrder defines fallback transfer order when no more specific ordering is required.

Functions

func Delete

func Delete(ctx context.Context, client *api.Client, theme string, resource Resource) error

Delete removes one remote resource.

func DisplayPath

func DisplayPath(kind Kind, remoteName string) string

DisplayPath returns the stable CLI-facing path for a resource.

func FetchResource

func FetchResource(ctx context.Context, client *api.Client, theme string, kind Kind, remoteName string) (api.ThemeResource, error)

FetchResource returns one theme resource from its real collection endpoint.

func GroupByKind added in v0.1.3

func GroupByKind(resources []Resource) map[Kind][]Resource

GroupByKind groups resources by their Kind.

func ProjectPathForResource

func ProjectPathForResource(cfg Config, resource Resource) (string, bool)

ProjectPathForResource maps a remote resource back to a project-relative local path.

func ReadContent

func ReadContent(ctx context.Context, client *api.Client, theme string, kind Kind, remoteName string) ([]byte, error)

ReadContent fetches one theme resource body.

func RunBuild

func RunBuild(ctx context.Context, cfg Config) error

RunBuild executes the configured build command.

func Upsert

func Upsert(ctx context.Context, client *api.Client, theme string, resource Resource, force bool) error

Upsert uploads or updates one local resource.

func UpsertBytes

func UpsertBytes(ctx context.Context, client *api.Client, theme string, resource Resource, content []byte, force bool) error

UpsertBytes uploads or updates one resource from in-memory content.

Types

type Action

type Action struct {
	Kind        Kind   `json:"kind"`
	DisplayPath string `json:"path"`
	LocalPath   string `json:"local_path,omitempty"`
	RemoteName  string `json:"remote_name"`
}

Action records one upload or delete operation.

type BuildConfig

type BuildConfig struct {
	Args    []string
	CWD     string
	Command string
	Env     map[string]string
}

BuildConfig configures an optional pre-push/pre-sync build step.

type Config

type Config struct {
	Build       *BuildConfig
	Generated   []string
	Ignore      []string
	ProjectRoot string
	Roots       []RootSpec
	Theme       string
}

Config is the resolved theme sync configuration.

func ResolveConfig

func ResolveConfig(projectRoot string, project projectconfig.ProjectConfig, explicitTheme string) (Config, error)

ResolveConfig resolves theme sync configuration from project config and flags.

type CopyOptions

type CopyOptions struct {
	DryRun          bool
	Force           bool
	LiquidOnly      bool
	ContinueOnError bool
}

CopyOptions controls one copy run.

type CopyRef

type CopyRef struct {
	BaseURL string `json:"base_url"`
	Site    string `json:"site"`
	Theme   string `json:"theme"`
}

CopyRef identifies one site/theme/host tuple.

type CopyResult

type CopyResult struct {
	From     CopyRef  `json:"from"`
	To       CopyRef  `json:"to"`
	Items    []Action `json:"items,omitempty"`
	Skipped  []Action `json:"skipped,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
}

CopyResult records copied resources.

func RunCopy

func RunCopy(ctx context.Context, fromClient *api.Client, from CopyRef, toClient *api.Client, to CopyRef, opts CopyOptions) (CopyResult, error)

RunCopy copies one theme between two clients.

type DiffEntry

type DiffEntry struct {
	Path   string `json:"path"`
	Status string `json:"status"`
}

DiffEntry reports one local-vs-remote mismatch.

type DiffResult

type DiffResult struct {
	Theme   string      `json:"theme"`
	Changes []DiffEntry `json:"changes,omitempty"`
	Entries []DiffEntry `json:"entries,omitempty"`
}

DiffResult reports all detected liquid mismatches.

func RunDiff

func RunDiff(ctx context.Context, client *api.Client, cfg Config) (DiffResult, error)

RunDiff compares managed local liquid files with the remote theme.

type GitChanges

type GitChanges struct {
	Changed     []string
	Deleted     []string
	FallbackAll bool
}

GitChanges captures project-relative file changes from git.

func CollectGitChanges

func CollectGitChanges(cfg Config, since string) (GitChanges, error)

CollectGitChanges returns git-based changed and deleted files for the project. When since is non-empty it is used as the diff ref instead of HEAD, allowing callers to detect committed-but-not-pushed changes (e.g. "origin/main").

type Kind

type Kind string

Kind identifies a remote theme resource collection.

const (
	KindAsset    Kind = "asset"
	KindLayout   Kind = "layout"
	KindSnippet  Kind = "snippet"
	KindTemplate Kind = "template"
)

func ParseCLIPath

func ParseCLIPath(raw string) (Kind, string)

ParseCLIPath maps a CLI file path onto a resource kind and remote name.

func (Kind) Collection

func (k Kind) Collection() string

func (Kind) DisplayRoot

func (k Kind) DisplayRoot() string

type Options

type Options struct {
	All        bool
	Build      bool
	DryRun     bool
	Force      bool
	Prune      bool
	Since      string
	Only       []string
	LiquidOnly bool
	CSSOnly    bool
	JSOnly     bool
	ImagesOnly bool
	FontsOnly  bool

	ConfirmOverwrite func(context.Context, Resource, error) (bool, error)
}

Options control one push/sync run.

type PullOptions

type PullOptions = Options

PullOptions narrows pull scope.

type PullResult

type PullResult struct {
	Theme            string   `json:"theme"`
	Written          []Action `json:"written,omitempty"`
	TimelineRendered bool     `json:"-"`
}

PullResult reports files written by a pull operation.

func RunPull

func RunPull(ctx context.Context, client *api.Client, cfg Config, opts Options) (PullResult, error)

RunPull downloads managed remote files into the local project.

type Resource

type Resource struct {
	Kind        Kind   `json:"kind"`
	DisplayPath string `json:"path"`
	LocalPath   string `json:"local_path,omitempty"`
	RemoteName  string `json:"remote_name"`
	PublicURL   string `json:"public_url,omitempty"`
	AbsPath     string `json:"-"`
}

Resource represents one managed local or remote theme file.

func ClassifyProjectPath

func ClassifyProjectPath(cfg Config, relPath string) (Resource, bool, error)

ClassifyProjectPath maps a project-relative path onto a configured resource kind.

func CollectAll

func CollectAll(cfg Config) ([]Resource, error)

CollectAll returns every managed local resource discovered under configured roots.

func CollectGenerated

func CollectGenerated(cfg Config) ([]Resource, error)

CollectGenerated returns generated resources that currently exist on disk.

func FetchRemoteResources

func FetchRemoteResources(ctx context.Context, client *api.Client, theme string) ([]Resource, error)

FetchRemoteResources returns the current remote theme resources exposed by the theme API.

func FilterResources

func FilterResources(cfg Config, resources []Resource, opts Options) ([]Resource, error)

FilterResources applies selection flags to resources.

func SortByKindOrder added in v0.1.3

func SortByKindOrder(resources []Resource) []Resource

SortByKindOrder returns a new slice sorted by KindOrder, then alphabetically by DisplayPath within each kind.

type ResourceContent added in v0.1.13

type ResourceContent struct {
	Resource Resource
	Content  []byte
}

ResourceContent pairs a theme resource with the bytes that will be uploaded.

func OrderResourceContentByLiquidDependencies added in v0.1.13

func OrderResourceContentByLiquidDependencies(items []ResourceContent) ([]ResourceContent, []string)

OrderResourceContentByLiquidDependencies returns resources ordered so Liquid dependencies are uploaded before the resources that reference them.

type Result

type Result struct {
	Built            bool     `json:"built,omitempty"`
	Deleted          []Action `json:"deleted,omitempty"`
	DryRun           bool     `json:"dry_run,omitempty"`
	Mode             string   `json:"mode"`
	Skipped          []Action `json:"skipped,omitempty"`
	Theme            string   `json:"theme"`
	Uploaded         []Action `json:"uploaded,omitempty"`
	Warnings         []string `json:"warnings,omitempty"`
	TimelineRendered bool     `json:"-"`
}

Result is emitted by push/sync commands.

func RunPush

func RunPush(ctx context.Context, client *api.Client, cfg Config, opts Options) (Result, error)

RunPush executes upload-only theme deployment.

func RunSync

func RunSync(ctx context.Context, client *api.Client, cfg Config, opts Options) (Result, error)

RunSync executes delete-aware theme synchronization.

type RootSpec

type RootSpec struct {
	AbsPath    string
	Kind       Kind
	LocalPath  string
	RemoteBase string
}

RootSpec maps a local root onto a remote theme resource kind.

Jump to

Keyboard shortcuts

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