gxutil

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CfgFileName = ".gxrc"
View Source
const GxVersion = "0.14.2"
View Source
const LckFileName = "gx-lock.json"
View Source
const LockVersion = 1
View Source
const PkgFileName = "package.json"

Variables

View Source
var ErrNotFound = errors.New("cache miss")
View Source
var ErrUnrecognizedName = fmt.Errorf("unrecognized package name")
View Source
var UsingGateway bool

Functions

func CheckCacheFile

func CheckCacheFile(name string) (string, bool, error)

func CheckForHelperTools

func CheckForHelperTools(lang string)

func FindPackageInDir

func FindPackageInDir(pkg interface{}, dir string) error

func GetPackageRoot added in v0.9.1

func GetPackageRoot() (string, error)

func InstallPath

func InstallPath(env, relpath string, global bool) (string, error)

func IsErrAlreadyInstalled

func IsErrAlreadyInstalled(err error) bool

func IsHash

func IsHash(s string) bool

func IsSubtoolInstalled added in v0.11.0

func IsSubtoolInstalled(env string) (bool, error)

func LoadLockFile added in v0.14.0

func LoadLockFile(lck *LockFile, fname string) error

func LoadPackage

func LoadPackage(out interface{}, env, hash string) error

func LoadPackageFile

func LoadPackageFile(pkg interface{}, fname string) error

func LocalPackageByName

func LocalPackageByName(dir, name string, out interface{}) error

func NewShell

func NewShell() *sh.Shell

func PackageNameInDir

func PackageNameInDir(dir string) (string, error)

func SavePackageFile

func SavePackageFile(pkg interface{}, fname string) error

func TryRunHook

func TryRunHook(hook, env string, req bool, args ...string) error

func WriteConfig

func WriteConfig(cfg *Config, file string) error

Types

type BugsObj added in v0.6.0

type BugsObj struct {
	Url string `json:"url,omitempty"`
}

type Config

type Config struct {
	Repos      map[string]string `json:"repos,omitempty"`
	ExtraRepos map[string]string `json:"extra_repos,omitempty"`
	User       User              `json:"user,omitempty"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func LoadConfigFrom

func LoadConfigFrom(paths ...string) (*Config, error)

func (*Config) GetRepos

func (c *Config) GetRepos() map[string]string

type DepStats added in v0.10.0

type DepStats struct {
	TotalCount  int
	TotalUnique int

	AverageDepth float64

	Packages map[string]*PkgStats
	// contains filtered or unexported fields
}

func GetDepStats added in v0.10.0

func GetDepStats(pkg *Package) (*DepStats, error)

func (*DepStats) Finalize added in v0.10.0

func (ds *DepStats) Finalize()

type DepWork added in v0.14.0

type DepWork struct {
	CacheDir string
	LinkDir  string
	Dep      string
	Ref      string
}

type Dependency

type Dependency struct {
	Author  string `json:"author,omitempty"`
	Name    string `json:"name,omitempty"`
	Hash    string `json:"hash"`
	Version string `json:"version,omitempty"`
}

Dependency represents a dependency of a package

type DependencyQueue added in v0.14.0

type DependencyQueue struct {
	// contains filtered or unexported fields
}

Queue of dependency packages to install. Supported by a slice, it's not very performant but the main bottleneck here is the fetch operation (`GetPackageTo`).

func NewDependencyQueue added in v0.14.0

func NewDependencyQueue(initialCapacity int) *DependencyQueue

NewDependencyQueue creates a new `DependencyQueue` with the specified `initialCapacity` for the slice.

func (*DependencyQueue) AddPackageDependencies added in v0.14.0

func (dq *DependencyQueue) AddPackageDependencies(pkg *Package) int

AddPackageDependencies adds all of the dependencies of `pkg` to the queue that had not been already added. Return the actual number of dependencies added to the queue.

func (*DependencyQueue) Len added in v0.14.0

func (dq *DependencyQueue) Len() int

Len returns the number of dependencies currently stored in the queue.

func (*DependencyQueue) Pop added in v0.14.0

func (dq *DependencyQueue) Pop() *Dependency

Pop the first dependency in the queue and return it (or `nil` if the queue is empty).

type ErrAlreadyInstalled

type ErrAlreadyInstalled struct {
	// contains filtered or unexported fields
}

func (ErrAlreadyInstalled) Error

func (eai ErrAlreadyInstalled) Error() string

type Lock added in v0.14.0

type Lock struct {
	Language string `json:"language,omitempty"`

	Ref  string                     `json:"ref,omitempty"`
	Deps map[string]map[string]Lock `json:"deps,omitempty"`
}

type LockFile added in v0.14.0

type LockFile struct {
	Lock
	LockVersion int `json:"lockVersion"`
}

type PM

type PM struct {
	ProgMeter *prog.ProgMeter
	// contains filtered or unexported fields
}

func NewPM

func NewPM(cfg *Config) (*PM, error)

func (*PM) CacheAndLinkPackage added in v0.14.0

func (pm *PM) CacheAndLinkPackage(ref, cacheloc, out string) error

func (*PM) EnumerateDependencies

func (pm *PM) EnumerateDependencies(pkg *Package) (map[string]string, error)

func (*PM) FetchRepo

func (pm *PM) FetchRepo(rpath string, usecache bool) (map[string]string, error)

func (*PM) GetPackageTo

func (pm *PM) GetPackageTo(hash, out string) (*Package, error)

func (*PM) ImportPackage

func (pm *PM) ImportPackage(dir, dephash string) (*Dependency, error)

ImportPackage downloads the package specified by dephash into the package in the directory 'dir'

func (*PM) InitPkg

func (pm *PM) InitPkg(dir, name, lang string, setup func(*Package)) error

func (*PM) InstallDeps

func (pm *PM) InstallDeps(pkg *Package, location string) error

InstallDeps fetches all dependencies for the given package (in parallel) and then calls the `post-install` hook on each one. Those two processes are not combined because the rewrite process in the `post-install` hook needs all of the dependencies (directs and transitives) of a package to compute the rewrite map which enforces a particular order in the traversal of the dependency graph and that constraint invalidates the parallel fetch in `fetchDependencies` (where the dependencies are processes in the random order they are fetched, without consideration for their order in the dependency graph).

func (*PM) InstallLock added in v0.14.0

func (pm *PM) InstallLock(lck Lock, cwd string) error

InstallLock recursively installs all dependencies for the given lockfile

func (*PM) InstallPackage

func (pm *PM) InstallPackage(hash, ipath string) (*Package, error)

func (*PM) PublishPackage

func (pm *PM) PublishPackage(dir string, pkg *PackageBase) (string, error)

func (*PM) QueryRepos

func (pm *PM) QueryRepos(query string) (map[string]string, error)

func (*PM) ResolveDepName

func (pm *PM) ResolveDepName(name string) (string, error)

ResolveDepName resolves a given package name to a hash using configured repos as a mapping.

func (*PM) ResolveRepoName added in v0.8.0

func (pm *PM) ResolveRepoName(name string, usecache bool) (string, error)

TODO: once on ipfs 0.4.0, use the files api

func (*PM) SetGlobal added in v0.6.0

func (pm *PM) SetGlobal(g bool)

func (*PM) SetProgMeter added in v0.12.0

func (pm *PM) SetProgMeter(meter *prog.ProgMeter)

func (*PM) Shell

func (pm *PM) Shell() *sh.Shell

func (*PM) ShellOnline added in v0.12.0

func (pm *PM) ShellOnline() bool

type Package

type Package struct {
	PackageBase

	Gx json.RawMessage `json:"gx,omitempty"`
}

type PackageBase

type PackageBase struct {
	Name            string        `json:"name,omitempty"`
	Author          string        `json:"author,omitempty"`
	Description     string        `json:"description,omitempty"`
	Keywords        []string      `json:"keywords,omitempty"`
	Version         string        `json:"version,omitempty"`
	Dependencies    []*Dependency `json:"gxDependencies,omitempty"`
	Bin             string        `json:"bin,omitempty"`
	Build           string        `json:"build,omitempty"`
	Test            string        `json:"test,omitempty"`
	ReleaseCmd      string        `json:"releaseCmd,omitempty"`
	SubtoolRequired bool          `json:"subtoolRequired,omitempty"`
	Language        string        `json:"language,omitempty"`
	License         string        `json:"license"`
	Bugs            BugsObj       `json:"bugs"`
	GxVersion       string        `json:"gxVersion"`
}

func (*PackageBase) FindDep

func (pkg *PackageBase) FindDep(ref string) *Dependency

FindDep returns a reference to the named dependency in this package file

func (*PackageBase) ForEachDep

func (pkg *PackageBase) ForEachDep(cb func(dep *Dependency, pkg *Package) error) error

type PkgStats added in v0.10.0

type PkgStats struct {
	AverageDepth float64

	TotalImports int
	// contains filtered or unexported fields
}

type User

type User struct {
	Name  string `json:"name,omitempty"`
	Email string `json:"email,omitempty"`
}

Jump to

Keyboard shortcuts

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