gnomod

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoModFile = errors.New("gnomod.toml doesn't exist")
)

Functions

func IsGnomodRoot

func IsGnomodRoot(dir string) bool

IsGnomodRoot returns true if the given directory contains a gnomod.toml or gno.mod file.

func ModCachePath

func ModCachePath() string

ModCachePath returns the path for gno modules

Types

type File

type File struct {
	// Module is the path of the module.
	// Like `gno.land/r/path/to/module`.
	Module string `toml:"module" json:"module"`

	// Gno is the gno version string for compatibility within the gno toolchain.
	// It is intended to be set by the `gno` cli when initializing or upgrading a module.
	Gno string `toml:"gno" json:"gno"`

	// Ignore indicate that the module will be ignored by the gno toolchain but still usable in development environments.
	Ignore bool `toml:"ignore,omitempty" json:"ignore,omitempty"`

	// Draft indicates that the module isn't ready for production use.
	// Draft modules:
	// - are added to the chain at genesis time and cannot be added after.
	// - cannot be imported by other newly added modules.
	Draft bool `toml:"draft,omitempty" json:"draft,omitempty"`

	// Private indicates that the module is private.
	// Private modules:
	// - cannot be imported by other modules.
	Private bool `toml:"private,omitempty" json:"private,omitempty"`

	// Replace is a list of replace directives for the module's dependencies.
	// Each replace can link to a different online module path, or a local path.
	// If this value is set, the module cannot be added to the chain.
	Replace []Replace `toml:"replace,omitempty" json:"replace,omitempty"`

	// UploadMetadata is the upload metadata section of the gnomod.toml file.
	// It is filled by the vmkeeper when a module is added.
	// It is not intended to be used offchain.
	UploadMetadata UploadMetadata `toml:"upload_metadata,omitempty" json:"upload_metadata,omitempty"`
}

Parsed gnomod.toml file.

func MustParseBytes

func MustParseBytes(fname string, data []byte) *File

MustParseBytes parses a gnomod.toml or gno.mod file from bytes or panic.

func MustParseMemPackage

func MustParseMemPackage(mpkg *std.MemPackage) *File

MustParseMemPackage parses gno.mod or gnomod.toml from MemPackage, panicking on error.

func ParseBytes

func ParseBytes(fpath string, data []byte) (*File, error)

ParseBytes parses a gnomod.toml or gno.mod file from bytes.

func ParseDir

func ParseDir(dir string) (*File, error)

ParseDir parses, validates and returns a gno.mod or gnomod.toml file located at dir (does not search parents).

func ParseFilepath

func ParseFilepath(fpath string) (*File, error)

ParseFilepath tries to parse gno.mod or gnomod.toml file given the file path.

func ParseMemPackage

func ParseMemPackage(mpkg *std.MemPackage) (*File, error)

ParseMemPackage parses gnomod.toml or gno.mod from MemPackage.

func (*File) AddReplace

func (f *File) AddReplace(oldPath, newPath string)

AddReplace adds a replace directive or replaces an existing one.

func (*File) DropReplace

func (f *File) DropReplace(oldPath string)

DropReplace drops a replace directive.

func (*File) GetGno

func (f *File) GetGno() (version string)

GetGno returns the current gno version or the default one.

func (*File) HasReplaces

func (f *File) HasReplaces() bool

HasReplaces returns true if the module has any replace directives.

func (*File) Resolve

func (f *File) Resolve(target string) string

Resolve takes a module path and returns any adequate replacement following the Replace directives.

func (*File) Sanitize

func (f *File) Sanitize()

Sanitize sanitizes the gnomod.toml file.

func (*File) SetGno

func (f *File) SetGno(version string)

SetGno sets the gno version.

func (*File) Validate

func (f *File) Validate() error

Validate validates gnomod.toml.

func (*File) WriteFile

func (f *File) WriteFile(fpath string) error

WriteFile writes gnomod.toml to the given absolute file path.

func (*File) WriteString

func (f *File) WriteString() string

WriteTomlString writes the gnomod.toml file to a string.

type Pkg

type Pkg struct {
	Dir     string   // absolute path to package dir
	Name    string   // package name
	Imports []string // direct imports of this pkg
	Ignore  bool     // whether the package is a ignored package
}

type PkgList

type PkgList []Pkg

func (PkgList) Sort

func (pl PkgList) Sort() (SortedPkgList, error)

sortPkgs sorts the given packages by their dependencies.

type Replace

type Replace struct {
	// Old is the old module path of the dependency, i.e.,
	// `gno.land/r/path/to/module`.
	Old string `toml:"old" json:"old"`
	// New is the new module path of the dependency, i.e.,
	// `gno.land/r/path/to/module/v2` or a local path, i.e.,
	// `../path/to/module`.
	New string `toml:"new" json:"new"`
}

type SortedPkgList

type SortedPkgList []Pkg

func (SortedPkgList) GetNonIgnoredPkgs

func (sp SortedPkgList) GetNonIgnoredPkgs() SortedPkgList

GetNonIgnorePkgs returns packages that are not ignored and have no direct or indirect ignore dependencies.

type SubPkg

type SubPkg struct {
	Dir        string   // absolute path to package dir
	ImportPath string   // import path of package
	Root       string   // Root dir containing this package, i.e dir containing gno.mod file
	Imports    []string // imports used by this package

	GnoFiles         []string // .gno source files (excluding TestGnoFiles, FiletestGnoFiles)
	TestGnoFiles     []string // _test.gno source files
	FiletestGnoFiles []string // _filetest.gno source files
}

func SubPkgsFromPaths

func SubPkgsFromPaths(paths []string) ([]*SubPkg, error)

SubPkgsFromPaths returns a list of subpackages from the given paths.

type UploadMetadata

type UploadMetadata struct {
	// Uploader is the address of the uploader.
	Uploader string `toml:"uploader,omitempty" json:"uploader,omitempty"`
	// Height is the block height at which the module was uploaded.
	Height int `toml:"height,omitempty" json:"height,omitempty"`
}

Jump to

Keyboard shortcuts

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