index | @vltpkg/graph
Classes
Edge
Implements
Constructors
new Edge()
Parameters
• type: DependencyTypeShort
• spec: Spec
• from: Node
• to?: Node
Returns
Defined in
edge.ts:48
Properties
from
The Node this Edge is connecting from, this is usually the dependent.
Implementation of
EdgeLike.from
Defined in
edge.ts:31
spec
The defined spec value for to
as parsed from the dependent metadata.
Implementation of
EdgeLike.spec
Defined in
edge.ts:46
to?
The node this Edge is connecting to, this is usually a direct dependency.
Implementation of
EdgeLike.to
Defined in
edge.ts:36
type
What type of dependency relationship from
and to
nodes have.
Implementation of
EdgeLike.type
Defined in
edge.ts:41
Accessors
[toStringTag]
Returns
string
Defined in
edge.ts:11
dev
This edge was defined as part of a devDependencies
in package.json
Returns
boolean
Defined in
edge.ts:70
name
The name of the dependency to
as defined in the dependent metadata.
Returns
string
Implementation of
EdgeLike.name
Defined in
edge.ts:63
optional
Returns
boolean
Defined in
edge.ts:74
peer
Returns
boolean
Defined in
edge.ts:78
peerOptional
Returns
boolean
Defined in
edge.ts:82
Methods
[kCustomInspect]()
Parameters
• _: number
• options: InspectOptions
Returns
string
Defined in
edge.ts:15
valid()
Returns
boolean
Defined in
edge.ts:86
Graph
Implements
Constructors
new Graph()
Parameters
• options: GraphOptions
Returns
Defined in
graph.ts:108
Properties
edges
A set of all edges in this graph.
Implementation of
GraphLike.edges
Defined in
graph.ts:66
extraneousDependencies
A set of extraneous dependencies found when building the graph.
Defined in
graph.ts:101
importers
A set of importer nodes in this graph.
Implementation of
GraphLike.importers
Defined in
graph.ts:91
mainImporter
The Node that represents the project root package.json
.
Implementation of
GraphLike.mainImporter
Defined in
graph.ts:96
manifests
An inventory with all manifests related to an install.
Defined in
graph.ts:61
monorepo?
A Monorepo instance, used for managing workspaces.
Defined in
graph.ts:56
nodes
Map registered dep ids to the node that represent them in the graph.
Implementation of
GraphLike.nodes
Defined in
graph.ts:71
nodesByName
Map of nodes by their name
Defined in
graph.ts:76
projectRoot
The root of the project this graph represents
Implementation of
GraphLike.projectRoot
Defined in
graph.ts:106
resolutions
Cached resolutions for spec lookups
Defined in
graph.ts:81
resolutionsReverse
Reverse map of resolutions
Defined in
graph.ts:86
Accessors
[toStringTag]
Returns
string
Defined in
graph.ts:45
Methods
[kCustomInspect]()
Parameters
• _: number
• options: InspectOptions
Returns
string
Defined in
graph.ts:409
addEdge()
Create a new edge between two nodes of the graph in case both exist, in case the destination node does not exists, then a dangling edge, pointing to nothing will be created to represent that missing dependency.
Parameters
• type: DependencyTypeShort
• spec: Spec
• from: NodeLike
• to?: NodeLike
Returns
Implementation of
GraphLike.addEdge
Defined in
graph.ts:190
addNode()
Create a new node in the graph.
Parameters
• id?: DepID
• manifest?: Manifest
• spec?: Spec
• name?: string
• version?: string
Returns
Implementation of
GraphLike.addNode
Defined in
graph.ts:263
findResolution()
Find an existing node to satisfy a dependency
Parameters
• spec: Spec
• fromNode: Node
Returns
undefined
| Node
Defined in
graph.ts:232
gc()
Delete all nodes that are unreachable from the importers. The collection of deleted nodes is returned.
NOTE: This can be extremely slow for large graphs, and is almost always unnecessary! Only call when it is known that some unreachable nodes may have been created, for example when deleting the unneeded subgraph when an optional node fails to resolve/install.
Returns
Defined in
graph.ts:164
placePackage()
Place a new package into the graph representation, creating the new edges and possibly new nodes that are to be expected when traversing the graph in a top-down direction, e.g: from importers to leafs.
For different uses that are not a direct top-down traversal of the graph
consider using addNode()
and addEdge()
instead.
Parameters
• fromNode: Node
• depType: DependencyTypeShort
• spec: Spec
• manifest?: Manifest
• id?: DepID
Returns
undefined
| Node
Defined in
graph.ts:307
removeNode()
Removes a node and its relevant edges from the graph.
If a replacement is provided, then any edges that were previously pointing to the removed node will be directed to the replacement, if it is valid to do so.
Parameters
• node: Node
• replacement?: Node
Returns
void
Defined in
graph.ts:369
toJSON()
Returns
Defined in
graph.ts:401
Node
Implements
Constructors
new Node()
Parameters
• options: NodeOptions
• id?: DepID
• manifest?: Manifest
• spec?: Spec
• name?: string
• version?: string
Returns
Defined in
node.ts:196
Properties
edgesIn
List of edges coming into this node.
Implementation of
NodeLike.edgesIn
Defined in
node.ts:84
edgesOut
List of edges from this node into other nodes. This usually represents that the connected node is a direct dependency of this node.
Implementation of
NodeLike.edgesOut
Defined in
node.ts:90
graph
A reference to the graph this node is a part of.
Implementation of
NodeLike.graph
Defined in
node.ts:110
id
A reference to the DepID this node represents in the graph.
Implementation of
NodeLike.id
Defined in
node.ts:95
importer
True if this node is an importer node.
Implementation of
NodeLike.importer
Defined in
node.ts:100
integrity?
The manifest integrity value.
Implementation of
NodeLike.integrity
Defined in
node.ts:115
mainImporter
True if this node is the project root node.
Implementation of
NodeLike.mainImporter
Defined in
node.ts:105
manifest?
The manifest this node represents in the graph.
Implementation of
NodeLike.manifest
Defined in
node.ts:120
projectRoot
Project where this node resides
Implementation of
NodeLike.projectRoot
Defined in
node.ts:125
registry?
For registry nodes, this is the registry we fetched them from. Needed because their un-prefixed dependencies need to come from the same registry, if it’s not the default.
Defined in
node.ts:132
resolved?
An address PackageInfoClient may use to extract this package.
Implementation of
NodeLike.resolved
Defined in
node.ts:173
version?
The version of the package represented by this node, this is usually
equivalent to manifest.version
but in a few ways it may differ such as
nodes loaded from a lockfile that lacks a loaded manifest.
This field should be used to retrieve package versions instead.
Implementation of
NodeLike.version
Defined in
node.ts:168
Accessors
[toStringTag]
Returns
string
Defined in
node.ts:23
dev
True if a node is only reachable via dev edges from any importer.
Setting this to false, if previously set to true, will also unset the flag on any dev-flagged non-dev dependencies.
Parameters
• dev: boolean
Returns
boolean
Implementation of
NodeLike.dev
Defined in
node.ts:63
location
The file system location for this node.
Parameters
• location: string
Returns
string
Implementation of
NodeLike.location
Defined in
node.ts:178
name
Returns
string
Implementation of
NodeLike.name
Defined in
node.ts:141
nodeModules
The location of the node_modules folder where this node’s edgesOut should be linked into. For nodes in the store, this is the parent directory, since they’re extracted into a node_modules folder side by side with links to their deps. For nodes outside of the store (ie, importers and arbitrary link deps) this is the node_modules folder directly inside the node’s directory.
Returns
string
Defined in
node.ts:155
optional
True if a node is only reachable via optional or peerOptional edges from any importer.
Setting this to false, if previously set to true, will also unset the flag on any optional-flagged non-optional dependencies.
Parameters
• optional: boolean
Returns
boolean
Implementation of
NodeLike.optional
Defined in
node.ts:38
Methods
addEdgesTo()
Add an edge from this node connecting it to a direct dependency.
Parameters
• type: DependencyTypeShort
• spec: Spec
• node?: Node
Returns
Defined in
node.ts:298
equals()
Parameters
• other: Node
Returns
boolean
Defined in
node.ts:248
inVltStore()
return true if this node is located in the vlt store memoized the first time it’s called, since the store location doesn’t change within the context of a single operation.
Returns
boolean
Defined in
node.ts:230
isDev()
Returns
this is Node & Object
Defined in
node.ts:77
isOptional()
Returns
this is Node & Object
Defined in
node.ts:52
setDefaultLocation()
Returns
void
Defined in
node.ts:281
setImporterLocation()
Sets the node as an importer along with its location.
Parameters
• location: string
Returns
void
Defined in
node.ts:255
setResolved()
Sets the appropriate resolve / integrity value for this node. Note that other places might also set these values, like for example the lockfile that might have already have this info.
Returns
void
Defined in
node.ts:265
toJSON()
Returns
object
dev
id
importer
integrity
location
manifest
name
optional
projectRoot
resolved
version
Defined in
node.ts:305
toString()
Returns a string representation of an object.
Returns
string
Defined in
node.ts:321
Type Aliases
ActualLoadOptions
Type declaration
loadManifests?
If set to false
, actual.load
will not load any package.json
files while traversing the file system.
The resulting Graph from loading with loadManifests=false
has no information on dependency types or the specs defined and
no information on missing and extraneous dependencies.
mainManifest?
The project root manifest.
monorepo?
A Monorepo object, for managing workspaces
packageJson
A PackageJson object, for sharing manifest caches
projectRoot
The project root dirname.
scurry
A PathScurry object, for use in globs
skipHiddenLockfile?
If set to true
, then do not shortcut the process by reading the
hidden lockfile at node_modules/.vlt-lock.json
Defined in
actual/load.ts:21
AddImportersDependenciesMap
A Map
in which keys are DepID linking to another Map
in which
keys are the dependency names and values are Dependency. This
structure represents dependencies that need to be added to the importer
represented by DepID.
Defined in
dependencies.ts:72
BuildIdealOptions
Type declaration
add?
A Map
in which keys are DepID linking to another Map
in which
keys are the dependency names and values are Dependency. This
structure represents dependencies that need to be added to the importer
represented by DepID.
packageInfo
A PackageInfoClient instance to read manifest info from.
remove?
A Map
object representing nodes to be removed from the ideal graph.
Each DepID key represents an importer node and the Set
of
dependency names to be removed from its dependency list.
Defined in
ideal/build.ts:19
Dependency
Parsed dependency entries info.
Type declaration
spec
The parsed Spec object describing the dependency requirements.
type
The DependencyTypeShort, describing the type of dependency.
Defined in
dependencies.ts:55
DependencyTypeLong
Name of the package.json keys used to define different types of dependencies.
Defined in
dependencies.ts:9
DependencyTypeShort
Unique keys that define different types of dependencies relationship.
Defined in
dependencies.ts:18
EdgeLike
Type declaration
from
name
spec
to?
type
Defined in
types.ts:6
EdgeMap
Defined in
visualization/human-readable-output.ts:35
GraphLike
Type declaration
addEdge()
Parameters
• type: DependencyTypeShort
• spec: Spec
• from: NodeLike
• to?: NodeLike
Returns
addNode()
Parameters
• id?: DepID
• manifest?: Manifest
• spec?: Spec
• name?: string
• version?: string
Returns
edges
importers
mainImporter
nodes
projectRoot
Defined in
types.ts:14
GraphOptions
Type declaration
mainManifest
The main importer manifest info.
manifests?
An inventory of seen manifests.
monorepo?
A Monorepo object, for managing workspaces
projectRoot
Root of the project this graph represents
Defined in
graph.ts:25
HumanReadableOutputOptions
Type declaration
colors?
edges
highlightSelection
importers
nodes
Defined in
visualization/human-readable-output.ts:27
JSONOutputItem
A JSON output item describes a package that is present in the install graph. It represents an edge plus it’s linking Node.
Type declaration
fromID?
A reference to the id of the Node that this package is linked from.
name
The name of the package.
spec?
The dependency spec definition for this package.
to?
A representation of the package object that fulfills this dependency.
type?
The package type.
Defined in
visualization/json-output.ts:8
JSONOutputOptions
Type declaration
edges
nodes
Defined in
visualization/json-output.ts:31
LockfileData
This is the main type definition for the contents of the
vlt-lock.json
file.
The nodes and edges information from the lockfile are used to reconstruct a Graph representing a previous install.
Type declaration
edges
nodes
options
Defined in
lockfile/types.ts:14
LockfileEdgeKey
${from} ${dep name}
Defined in
lockfile/types.ts:70
LockfileEdges
Lockfile edges are stored as a record object where the key
is ${from.id} ${spec.name}
and the value is
${type} ${spec.bareSpec} ${to.id | 'MISSING'}
Storing them in a record like this means that we are guaranteed to
never end up with duplicates, and a standard JSON.stringify()
will nicely print them out one line per edge.
Index Signature
[key
: LockfileEdgeKey
]: LockfileEdgeValue
Defined in
lockfile/types.ts:65
LockfileEdgeValue
${type} ${spec} ${to}
Defined in
lockfile/types.ts:73
LockfileLoadOptions
Type declaration
mainManifest
The project root manifest.
monorepo?
A Monorepo object, for managing workspaces
packageJson?
A PackageJson object, for sharing manifest caches
projectRoot
The project root dirname.
scurry?
A PathScurry object, for use in globs
Defined in
lockfile/load.ts:13
LockfileNode
Lockfile representation of a node from the install graph.
Defined in
lockfile/types.ts:47
LockfileNodeFlags
Bit flags indicating whether a node is optional and/or dev.
Defined in
lockfile/types.ts:42
ManifestInventory
Defined in
graph.ts:20
MermaidOutputOptions
Type declaration
edges
importers
nodes
Defined in
visualization/mermaid-output.ts:6
NodeLike
Type declaration
dev
edgesIn
edgesOut
graph
id
importer
integrity?
location?
mainImporter
manifest?
name?
optional
projectRoot
resolved?
version?
Defined in
types.ts:35
NodeOptions
Type declaration
graph
projectRoot
Defined in
node.ts:17
RawDependency
Dependency entries info as defined in a package.json file.
Type declaration
bareSpec
name
registry?
type
Defined in
dependencies.ts:45
ReifyOptions
Type declaration
actual?
add?
graph
packageInfo
remove?
Defined in
reify/index.ts:34
RemoveImportersDependenciesMap
A Map
object representing nodes to be removed from the ideal graph.
Each DepID key represents an importer node and the Set
of
dependency names to be removed from its dependency list.
Defined in
dependencies.ts:82
SaveOptions
Type declaration
graph
The graph to be stored in the lockfile.
saveManifests?
Should it save manifest data in the lockfile?
Defined in
lockfile/save.ts:24
TreeItem
Type declaration
deduped
edge
hasSibling
include
name?
node
padding
parent
prefix
Defined in
visualization/human-readable-output.ts:15
TreeMap
Defined in
visualization/human-readable-output.ts:37
Variables
actual
Type declaration
load()
Read the file system looking for node_modules
folders and
returns a new Graph that represents the relationship
between the dependencies found.
Parameters
• options: ActualLoadOptions
Returns
Defined in
index.ts:16
dependencyTypes
Maps between long form names usually used in package.json
files
to a corresponding short form name, used in lockfiles.
Defined in
dependencies.ts:128
ideal
Type declaration
build()
Builds an ideal Graph representing the dependencies that
should be present in order to fulfill the requirements defined
by the package.json
and vlt-lock.json
files using either the
virtual or actual graph as a starting point. Also add / remove any
dependencies listed in the add
and remove
properties.
Parameters
• options: BuildIdealOptions
Returns
Promise
<Graph
>
Defined in
index.ts:37
lockfile
Type declaration
load()
Parameters
• options: LockfileLoadOptions
Returns
loadEdges()
Parameters
• graph: GraphLike
• edges: LockfileEdges
• options: SpecOptions
Returns
void
loadNodes()
Parameters
• graph: GraphLike
• nodes: Record
<DepID
, LockfileNode
>
Returns
void
save()
Parameters
• options: SaveOptions
Returns
void
Defined in
index.ts:25
LockfileNodeFlagDev
Defined in
lockfile/types.ts:36
LockfileNodeFlagDevOptional
Defined in
lockfile/types.ts:37
LockfileNodeFlagNone
Defined in
lockfile/types.ts:34
LockfileNodeFlagOptional
Defined in
lockfile/types.ts:35
longDependencyTypes
A set of the possible long dependency type names,
as used in package.json
files.
Defined in
dependencies.ts:106
shortDependencyTypes
A set of the short type keys used to represent dependency relationships.
Defined in
dependencies.ts:116
Functions
asDependency()
Parameters
• obj: unknown
Returns
Defined in
dependencies.ts:95
asDependencyTypeShort()
Parameters
• obj: unknown
Returns
Defined in
dependencies.ts:30
getBooleanFlagsFromNum()
Parameters
• flags: LockfileNodeFlags
Returns
object
dev
optional
Defined in
lockfile/types.ts:29
getFlagNumFromNode()
Parameters
• node
• node.dev?: boolean
• node.optional?: boolean
Returns
0
| 1
| 2
| 3
Defined in
lockfile/types.ts:20
humanReadableOutput()
Returns a human-readable output of the graph.
Parameters
• options: HumanReadableOutputOptions
Returns
undefined
| null
| string
Defined in
visualization/human-readable-output.ts:99
isDependency()
Parameters
• o: unknown
Returns
o is Dependency
Defined in
dependencies.ts:88
isDependencyTypeShort()
Parameters
• obj: unknown
Returns
obj is DependencyTypeShort
Defined in
dependencies.ts:25
jsonOutput()
Returns a JSON string representation of the graph.
Parameters
• __namedParameters: JSONOutputOptions
Returns
string
Defined in
visualization/json-output.ts:39
mermaidOutput()
Returns a mermaid string representation of the graph.
Parameters
• __namedParameters: MermaidOutputOptions
Returns
string
Defined in
visualization/mermaid-output.ts:67
reify()
Make the current project match the supplied graph.
Parameters
• options: ReifyOptions
Returns
Promise
<void
>
Defined in
reify/index.ts:45
shorten()
Get the DependencyTypeShort from a DependencyTypeLong.
Parameters
• typeLong: DependencyTypeLong
• name?: string
• manifest?: Manifest
Returns
Defined in
dependencies.ts:141
stringifyNode()
Parameters
• node?: NodeLike
Returns
string
Defined in
stringify-node.ts:4