utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDependenciesList

func CalculateDependenciesList(executablePath, srcPath, moduleId string, npmArgs []string, log utils.Log) (dependenciesList []entities.Dependency, err error)

CalculateDependenciesList gets an npm project's dependencies.

func CalculateDependenciesMap

func CalculateDependenciesMap(executablePath, srcPath, moduleId string, npmArgs []string, log utils.Log) (map[string]*dependencyInfo, error)

Run 'npm list ...' command and parse the returned result to create a dependencies map of. The dependencies map looks like name:version -> entities.Dependency

func GetNpmConfigCache

func GetNpmConfigCache(srcPath, executablePath string, npmArgs []string, log utils.Log) (string, error)

Return the npm cache path. Default: Windows: %LocalAppData%\npm-cache, Posix: ~/.npm

func GetNpmVersion

func GetNpmVersion(executablePath string, log utils.Log) (*version.Version, error)

func GetNpmVersionAndExecPath

func GetNpmVersionAndExecPath(log utils.Log) (*version.Version, string, error)

func NewNpmCacache

func NewNpmCacache(cachePath string) *cacache

func RunNpmCmd

func RunNpmCmd(executablePath, srcPath string, npmCmd NpmCmd, npmArgs []string, log utils.Log) (stdResult, errResult []byte, err error)

func TraverseDependencies

func TraverseDependencies(dependenciesMap map[string]*entities.Dependency, traverseDependenciesFunc func(dependency *entities.Dependency) (bool, error), threads int) (dependenciesList []entities.Dependency, err error)

Executes traverseDependenciesFunc on all dependencies in dependenciesMap. Each dependency that gets true in return, is added to dependenciesList.

Types

type NpmCmd

type NpmCmd int
const (
	Ls NpmCmd = iota
	Config
	Install
	Ci
	Pack
	Version
)

func (NpmCmd) String

func (nc NpmCmd) String() string

type PackageInfo

type PackageInfo struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
	Scope   string
}

func ReadPackageInfo

func ReadPackageInfo(data []byte, npmVersion *version.Version) (*PackageInfo, error)

func ReadPackageInfoFromPackageJson

func ReadPackageInfoFromPackageJson(packageJsonDirectory string, npmVersion *version.Version) (*PackageInfo, error)

func (*PackageInfo) BuildInfoModuleId

func (pi *PackageInfo) BuildInfoModuleId() string

func (*PackageInfo) FullName

func (pi *PackageInfo) FullName() string

func (*PackageInfo) GetDeployPath

func (pi *PackageInfo) GetDeployPath() string

Jump to

Keyboard shortcuts

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