Documentation ¶
Index ¶
- func AppendNpmCommand(npmArgs []string, command string) []string
- func CalculateDependenciesMap(executablePath, srcPath, moduleId string, npmListParams NpmTreeDepListParam, ...) (map[string]*dependencyInfo, error)
- func CalculateNpmDependenciesList(executablePath, srcPath, moduleId string, npmParams NpmTreeDepListParam, ...) ([]entities.Dependency, error)
- func GetNpmConfigCache(srcPath, executablePath string, npmArgs []string, log utils.Log) (string, error)
- func GetNpmVersion(executablePath string, log utils.Log) (*version.Version, error)
- func GetNpmVersionAndExecPath(log utils.Log) (*version.Version, string, error)
- func GetVersion(executablePath, srcPath string) (string, error)
- func GetYarnDependencyKeyFromLocator(yarnDepLocator string) string
- func GetYarnExecutable() (string, error)
- func NewNpmCacache(cachePath string) *cacache
- func RunNpmCmd(executablePath, srcPath string, npmArgs []string, log utils.Log) (stdResult, errResult []byte, err error)
- func TraverseDependencies(dependenciesMap map[string]*entities.Dependency, ...) (dependenciesList []entities.Dependency, err error)
- type NpmTreeDepListParam
- type PackageInfo
- type Yarn1Data
- type Yarn1DependencyDetails
- type Yarn1DependencyPointer
- type Yarn1DependencyTree
- type YarnDepDetails
- type YarnDependency
- type YarnDependencyPointer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendNpmCommand ¶ added in v1.9.6
This function appends the Npm command as the first element in npmArgs strings array. For example, if npmArgs equals {"--json", "--all"}, and we call appendNpmCommand(npmArgs, "ls"), we will get npmArgs = {"ls", "--json", "--all"}.
func CalculateDependenciesMap ¶
func CalculateDependenciesMap(executablePath, srcPath, moduleId string, npmListParams NpmTreeDepListParam, 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 CalculateNpmDependenciesList ¶ added in v1.2.0
func CalculateNpmDependenciesList(executablePath, srcPath, moduleId string, npmParams NpmTreeDepListParam, calculateChecksums bool, log utils.Log) ([]entities.Dependency, error)
CalculateNpmDependenciesList gets an npm project's dependencies.
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 GetVersion ¶ added in v1.9.7
GetVersion getVersion gets the current project's yarn version
func GetYarnDependencyKeyFromLocator ¶ added in v1.4.0
GetYarnDependencyKeyFromLocator gets a Yarn dependency locator and returns its key in the dependencies map. Yarn dependency locator usually looks like this: package-name@npm:1.2.3, which is used as the key in the dependencies map. But sometimes it points to a virtual package, so it looks different: package-name@virtual:[ID of virtual package]#npm:1.2.3. In this case we need to omit the part of the virtual package ID, to get the key as it is found in the dependencies map.
func GetYarnExecutable ¶ added in v1.4.0
func NewNpmCacache ¶
func NewNpmCacache(cachePath string) *cacache
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 NpmTreeDepListParam ¶ added in v1.9.12
type PackageInfo ¶
type PackageInfo struct { Name string `json:"name"` Version string `json:"version"` Dependencies map[string]string `json:"dependencies"` DevDependencies map[string]string `json:"devDependencies"` PeerDependencies map[string]string `json:"peerDependencies"` OptionalDependencies map[string]string `json:"optionalDependencies"` 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
type Yarn1Data ¶ added in v1.9.7
type Yarn1Data struct {
Data Yarn1DependencyTree `json:"data,omitempty"`
}
type Yarn1DependencyDetails ¶ added in v1.9.7
type Yarn1DependencyDetails struct { Name string `json:"name,omitempty"` Dependencies []Yarn1DependencyPointer `json:"children,omitempty"` }
type Yarn1DependencyPointer ¶ added in v1.9.7
type Yarn1DependencyTree ¶ added in v1.9.7
type Yarn1DependencyTree struct {
DepTree []Yarn1DependencyDetails `json:"trees,omitempty"`
}
type YarnDepDetails ¶ added in v1.4.0
type YarnDepDetails struct { Version string `json:"Version,omitempty"` Dependencies []YarnDependencyPointer `json:"Dependencies,omitempty"` }
type YarnDependency ¶ added in v1.4.0
type YarnDependency struct { // The value is usually in this structure: @scope/package-name@npm:1.0.0 Value string `json:"value,omitempty"` Details YarnDepDetails `json:"children,omitempty"` }
func GetYarnDependencies ¶ added in v1.4.0
func GetYarnDependencies(executablePath, srcPath string, packageInfo *PackageInfo, log utils.Log) (dependenciesMap map[string]*YarnDependency, root *YarnDependency, err error)
GetYarnDependencies returns a map of the dependencies of a Yarn project and the root package of the project. The keys are the packages' values (Yarn's full identifiers of the packages), for example: '@scope/package-name@1.0.0' (for yarn v < 2.0.0) or @scope/package-name@npm:1.0.0 (for yarn v >= 2.0.0). Pay attention that a package's value won't necessarily contain its version. Use the version in package's details instead.
func (*YarnDependency) Name ¶ added in v1.4.0
func (yd *YarnDependency) Name() string