Documentation
¶
Index ¶
- Variables
- func IsGnomodRoot(dir string) bool
- func ModCachePath() string
- type File
- func MustParseBytes(fname string, data []byte) *File
- func MustParseMemPackage(mpkg *std.MemPackage) *File
- func ParseBytes(fpath string, data []byte) (*File, error)
- func ParseDir(dir string) (*File, error)
- func ParseFilepath(fpath string) (*File, error)
- func ParseMemPackage(mpkg *std.MemPackage) (*File, error)
- func (f *File) AddReplace(oldPath, newPath string)
- func (f *File) DropReplace(oldPath string)
- func (f *File) GetGno() (version string)
- func (f *File) HasReplaces() bool
- func (f *File) Resolve(target string) string
- func (f *File) Sanitize()
- func (f *File) SetGno(version string)
- func (f *File) Validate() error
- func (f *File) WriteFile(fpath string) error
- func (f *File) WriteString() string
- type Pkg
- type PkgList
- type Replace
- type SortedPkgList
- type SubPkg
- type UploadMetadata
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoModFile = errors.New("gnomod.toml doesn't exist")
)
Functions ¶
func IsGnomodRoot ¶
IsGnomodRoot returns true if the given directory contains a gnomod.toml or gno.mod file.
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 ¶
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 ¶
ParseBytes parses a gnomod.toml or gno.mod file from bytes.
func ParseDir ¶
ParseDir parses, validates and returns a gno.mod or gnomod.toml file located at dir (does not search parents).
func ParseFilepath ¶
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 ¶
AddReplace adds a replace directive or replaces an existing one.
func (*File) DropReplace ¶
DropReplace drops a replace directive.
func (*File) HasReplaces ¶
HasReplaces returns true if the module has any replace directives.
func (*File) Resolve ¶
Resolve takes a module path and returns any adequate replacement following the Replace directives.
func (*File) WriteString ¶
WriteTomlString writes the gnomod.toml file to a string.
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 ¶
SubPkgsFromPaths returns a list of subpackages from the given paths.