Documentation
¶
Index ¶
- Variables
- func DefaultNamespace(requirePath string) (string, error)
- func FindEntryPoint(cacheDir string, r *remotePath) (string, error)
- func IsRemoteRequire(path string) bool
- func SplitLockKey(key string) (module, version string)
- func WriteLockFile(path string, lf *LockFile) error
- type LockEntry
- type LockFile
- type Resolver
- func (r *Resolver) FetchRepo(requirePath string) (string, error)
- func (r *Resolver) InitLock(path string, lf *LockFile)
- func (r *Resolver) InitLockFromDir(dir string) error
- func (r *Resolver) LockDirty() bool
- func (r *Resolver) LockFile() *LockFile
- func (r *Resolver) ResolveModule(requirePath string) (string, error)
- func (r *Resolver) ResolveModuleOrDir(requirePath string) (entryPoint, cacheDir string, err error)
- func (r *Resolver) ResolvedKeys() map[string]bool
- func (r *Resolver) UpdateEntry(module string) error
- func (r *Resolver) WriteLock() error
- func (r *Resolver) WriteLockIfDirty() error
Constants ¶
This section is empty.
Variables ¶
var Sources embed.FS
Sources embeds all non-test Go source files needed to reconstruct the remote package in an external module cache.
Functions ¶
func DefaultNamespace ¶
DefaultNamespace returns the default namespace for a remote require path.
func FindEntryPoint ¶
FindEntryPoint locates the main Rugo file in a cloned module directory.
Resolution order (at root or subpath):
- <subpath>.rugo or <subpath>.rg at the repo root (flat-file subpath)
- <name>.rugo or <name>.rg in the subpath directory
- main.rugo or main.rg
- Exactly one Rugo source file
func IsRemoteRequire ¶
IsRemoteRequire returns true if the require path looks like a git URL (e.g. "github.com/user/repo"). Local paths like "helpers" or "lib/math" never have a dot in the first segment. Relative paths starting with "." or ".." are always local.
func SplitLockKey ¶ added in v0.13.1
SplitLockKey splits a lock key ("module@version") into module and version.
func WriteLockFile ¶
WriteLockFile writes the lock file to disk atomically. The content is written to a temp file first, then renamed over the target path to prevent corruption from concurrent writes.
Types ¶
type LockEntry ¶
type LockEntry struct {
// Module is the repo path without version (e.g. "github.com/user/repo").
Module string
// Version is the requested version label (e.g. "v1.0.0", "main", "_default").
Version string
// SHA is the resolved full commit SHA.
SHA string
}
LockEntry records the resolved commit SHA for a single remote module.
type LockFile ¶
type LockFile struct {
Entries []*LockEntry
// contains filtered or unexported fields
}
LockFile holds all lock entries for a project.
func ReadLockFile ¶
ReadLockFile reads a rugo.lock file. Returns an empty LockFile if the file does not exist.
func (*LockFile) Lookup ¶
Lookup finds the lock entry for a given module and version label. Returns nil if not found.
type Resolver ¶
type Resolver struct {
// ModuleDir overrides the default module cache directory (~/.rugo/modules).
ModuleDir string
// Frozen errors if the lock file is stale or a new dependency is resolved.
Frozen bool
// ReadOnly prevents writing the lock file to disk.
ReadOnly bool
// SuppressHint prevents the "run rugo mod tidy" hint from being printed.
SuppressHint bool
// contains filtered or unexported fields
}
Resolver manages remote module fetching, caching, and lock file state.
func (*Resolver) FetchRepo ¶
FetchRepo fetches a remote git repo and returns the cache directory. Unlike ResolveModule, it does not resolve an entry point.
func (*Resolver) InitLock ¶
InitLock sets the lock file and path for the resolver. Used by the update command to inject a pre-loaded lock file.
func (*Resolver) InitLockFromDir ¶
InitLockFromDir initializes the lock file from a rugo.lock in the given directory.
func (*Resolver) LockDirty ¶
LockDirty returns whether the lock file was modified during resolution.
func (*Resolver) ResolveModule ¶
ResolveModule fetches a remote git module and returns the local path to its entry point Rugo file.
func (*Resolver) ResolveModuleOrDir ¶ added in v0.20.0
ResolveModuleOrDir fetches a remote module and tries to find a Rugo entry point. If no entry point is found, returns the cache directory and a nil error with entryPoint set to "". This allows callers to fall back to Go module detection without a redundant fetch.
func (*Resolver) ResolvedKeys ¶ added in v0.13.0
ResolvedKeys returns the set of lock keys resolved during this session.
func (*Resolver) UpdateEntry ¶
UpdateEntry re-resolves a mutable dependency, ignoring the existing lock entry, and updates the lock file. If module is empty, all mutable entries are updated.
func (*Resolver) WriteLock ¶ added in v0.13.0
WriteLock writes the lock file to disk unconditionally.
func (*Resolver) WriteLockIfDirty ¶
WriteLockIfDirty writes the lock file to disk if it was modified.