node

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNodeIfMissing

func AddNodeIfMissing(depsGraph *sdk.Graph, node *sdk.Dependency) error

AddNodeIfMissing adds a package to a graph or merges scope into the existing package.

func AnnotateScopesFromPackageJSON

func AnnotateScopesFromPackageJSON(projectPath string, depsGraph *sdk.Graph) error

AnnotateScopesFromPackageJSON annotates graph packages using direct dependency scopes from package.json.

func ApplyDirectDependencyScopes

func ApplyDirectDependencyScopes(depsGraph *sdk.Graph, rootID string, directScopes map[string]sdk.Scope)

ApplyDirectDependencyScopes annotates direct root dependencies and their transitive dependencies with normalized scopes.

func DepGraphFromNPMJSON

func DepGraphFromNPMJSON(raw []byte) (*sdk.Graph, error)

DepGraphFromNPMJSON maps npm list JSON output into a dependency graph.

func DepGraphFromNPMNode

func DepGraphFromNPMNode(root *NPMListNode) (*sdk.Graph, error)

DepGraphFromNPMNode maps a npm dependency tree node into a dependency graph.

func DepGraphFromPNPMJSON

func DepGraphFromPNPMJSON(raw []byte) (*sdk.Graph, error)

DepGraphFromPNPMJSON maps pnpm list JSON output into a dependency graph.

func DepGraphFromYarnJSON

func DepGraphFromYarnJSON(raw []byte) (*sdk.Graph, error)

DepGraphFromYarnJSON maps Yarn list JSON output into a dependency graph.

func DirectDependencyScopes

func DirectDependencyScopes(manifest PackageJSONManifest) map[string]sdk.Scope

DirectDependencyScopes builds direct dependency scopes from package.json dependency maps.

func MergeStringMaps

func MergeStringMaps(left map[string]string, right map[string]string) map[string]string

MergeStringMaps returns a shallow merge of two string maps.

func NormalizeVersionToken

func NormalizeVersionToken(value string) string

NormalizeVersionToken removes common package-manager range and protocol markers from a version token.

func ParseIntegrityDigests

func ParseIntegrityDigests(integrity string) []sdk.Digest

ParseIntegrityDigests parses a space-separated integrity string (for example "sha512-abc sha1-xyz") into Digest values. Returns nil when the string is empty.

Types

type BaseDetector

type BaseDetector struct {
	Logger     *zap.Logger
	WorkingDir string
}

BaseDetector provides shared command execution behavior for Node package-manager detectors.

func (BaseDetector) Install

func (d BaseDetector) Install(ctx context.Context, req sdk.DetectionRequest, executable string, defaultArgs []string, detectorName string) error

Install runs a package-manager install command for detectors that support install-first.

func (BaseDetector) ProjectDir

func (d BaseDetector) ProjectDir(projectPath string) string

ProjectDir returns the configured working directory or falls back to the project path.

func (BaseDetector) ResolveGraph

func (d BaseDetector) ResolveGraph(stderr io.Writer, projectPath string, verbose bool, executable string, args []string, detectorName string, parse func([]byte) (*sdk.Graph, error)) (*sdk.Graph, error)

ResolveGraph runs a package-manager CLI command and maps its JSON output into a graph.

type NPMListNode

type NPMListNode struct {
	Name         string                  `json:"name"`
	Version      string                  `json:"version"`
	Dependencies map[string]*NPMListNode `json:"dependencies"`
}

NPMListNode is the npm list JSON node shape used by npm CLI and v1 package-lock parsing.

type PackageJSONManifest

type PackageJSONManifest struct {
	Name                 string            `json:"name"`
	Version              string            `json:"version"`
	Dependencies         map[string]string `json:"dependencies"`
	OptionalDependencies map[string]string `json:"optionalDependencies"`
	PeerDependencies     map[string]string `json:"peerDependencies"`
	DevDependencies      map[string]string `json:"devDependencies"`
}

PackageJSONManifest is the subset of package.json used by Node detectors.

func ReadPackageJSONManifest

func ReadPackageJSONManifest(projectPath string) (PackageJSONManifest, error)

ReadPackageJSONManifest reads the package.json manifest used by Node lockfile parsers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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