@vltpkg/graph
Classes
Edge
Defined in: edge.ts:10
Implements
Constructors
new Edge()
Defined in: edge.ts:48
Parameters
type
spec
from
to?
Returns
Properties
from
Defined in: edge.ts:31
The Node this Edge is connecting from, this is usually the dependent.
Implementation of
spec
Defined in: edge.ts:46
The defined spec value for to
as parsed from the dependent metadata.
Implementation of
to?
Defined in: edge.ts:36
The node this Edge is connecting to, this is usually a direct dependency.
Implementation of
type
Defined in: edge.ts:41
What type of dependency relationship from
and to
nodes have.
Implementation of
Accessors
[toStringTag]
Get Signature
Defined in: edge.ts:11
Returns
string
dev
Get Signature
Defined in: edge.ts:70
This edge was defined as part of a devDependencies
in package.json
Returns
boolean
name
Get Signature
Defined in: edge.ts:63
The name of the dependency to
as defined in the dependent metadata.
Returns
string
Implementation of
optional
Get Signature
Defined in: edge.ts:74
Returns
boolean
peer
Get Signature
Defined in: edge.ts:78
Returns
boolean
peerOptional
Get Signature
Defined in: edge.ts:82
Returns
boolean
Methods
[kCustomInspect]()
Defined in: edge.ts:15
Parameters
_
number
options
InspectOptions
Returns
string
valid()
Defined in: edge.ts:86
Returns
boolean
Graph
Defined in: graph.ts:44
Implements
Constructors
new Graph()
Defined in: graph.ts:108
Parameters
options
Returns
Properties
edges
Defined in: graph.ts:66
A set of all edges in this graph.
Implementation of
extraneousDependencies
Defined in: graph.ts:101
A set of extraneous dependencies found when building the graph.
importers
Defined in: graph.ts:91
A set of importer nodes in this graph.
Implementation of
mainImporter
Defined in: graph.ts:96
The Node that represents the project root package.json
.
Implementation of
manifests
Defined in: graph.ts:61
An inventory with all manifests related to an install.
monorepo?
Defined in: graph.ts:56
A Monorepo instance, used for managing workspaces.
nodes
Defined in: graph.ts:71
Map registered dep ids to the node that represent them in the graph.
Implementation of
nodesByName
Defined in: graph.ts:76
Map of nodes by their name
projectRoot
Defined in: graph.ts:106
The root of the project this graph represents
Implementation of
resolutions
Defined in: graph.ts:81
Cached resolutions for spec lookups
resolutionsReverse
Defined in: graph.ts:86
Reverse map of resolutions
Accessors
[toStringTag]
Get Signature
Defined in: graph.ts:45
Returns
string
Methods
[kCustomInspect]()
Defined in: graph.ts:409
Parameters
_
number
options
InspectOptions
Returns
string
addEdge()
Defined in: graph.ts:190
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
spec
from
to?
Returns
Implementation of
addNode()
Defined in: graph.ts:263
Create a new node in the graph.
Parameters
id?
manifest?
spec?
name?
string
version?
string
Returns
Implementation of
findResolution()
Defined in: graph.ts:232
Find an existing node to satisfy a dependency
Parameters
spec
fromNode
Returns
undefined
| Node
gc()
Defined in: graph.ts:164
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
placePackage()
Defined in: graph.ts:307
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
depType
spec
manifest?
id?
Returns
undefined
| Node
removeNode()
Defined in: graph.ts:369
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
replacement?
Returns
void
toJSON()
Defined in: graph.ts:401
Returns
Node
Defined in: node.ts:23
Implements
Constructors
new Node()
Defined in: node.ts:204
Parameters
options
id?
manifest?
spec?
name?
string
version?
string
Returns
Properties
edgesIn
Defined in: node.ts:85
List of edges coming into this node.
Implementation of
edgesOut
Defined in: node.ts:91
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
graph
Defined in: node.ts:111
A reference to the graph this node is a part of.
Implementation of
id
Defined in: node.ts:96
A reference to the DepID this node represents in the graph.
Implementation of
importer
Defined in: node.ts:101
True if this node is an importer node.
Implementation of
integrity?
Defined in: node.ts:116
The manifest integrity value.
Implementation of
mainImporter
Defined in: node.ts:106
True if this node is the project root node.
Implementation of
manifest?
Defined in: node.ts:121
The manifest this node represents in the graph.
Implementation of
projectRoot
Defined in: node.ts:126
Project where this node resides
Implementation of
registry?
Defined in: node.ts:133
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.
resolved?
Defined in: node.ts:159
An address PackageInfoClient may use to extract this package.
Implementation of
version?
Defined in: node.ts:154
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
Accessors
[toStringTag]
Get Signature
Defined in: node.ts:24
Returns
string
dev
Get Signature
Defined in: node.ts:64
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.
Returns
boolean
Set Signature
Defined in: node.ts:67
Parameters
dev
boolean
Returns
void
Implementation of
location
Get Signature
Defined in: node.ts:164
The file system location for this node.
Returns
string
Set Signature
Defined in: node.ts:174
Parameters
location
string
Returns
void
Implementation of
name
Get Signature
Defined in: node.ts:142
Returns
string
Implementation of
optional
Get Signature
Defined in: node.ts:39
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.
Returns
boolean
Set Signature
Defined in: node.ts:42
Parameters
optional
boolean
Returns
void
Implementation of
Methods
addEdgesTo()
Defined in: node.ts:306
Add an edge from this node connecting it to a direct dependency.
Parameters
type
spec
node?
Returns
equals()
Defined in: node.ts:256
Parameters
other
Returns
boolean
inVltStore()
Defined in: node.ts:238
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
isDev()
Defined in: node.ts:78
Returns
this is Node & { dev: true }
isOptional()
Defined in: node.ts:53
Returns
this is Node & { optional: true }
nodeModules()
Defined in: node.ts:197
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.
Parameters
scurry
Returns
string
resolvedLocation()
Defined in: node.ts:185
The resolved location of the node in the file system.
Parameters
scurry
Returns
string
setDefaultLocation()
Defined in: node.ts:289
Returns
void
setImporterLocation()
Defined in: node.ts:263
Sets the node as an importer along with its location.
Parameters
location
string
Returns
void
setResolved()
Defined in: node.ts:273
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
Implementation of
toJSON()
Defined in: node.ts:313
Returns
object
dev
id
importer
integrity
location
manifest
name
optional
projectRoot
resolved
version
toString()
Defined in: node.ts:329
Returns
string
Implementation of
Type Aliases
ActualLoadOptions
Defined in: actual/load.ts:22
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
AddImportersDependenciesMap
Defined in: dependencies.ts:75
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.
The modifiedDependencies
property can be used to indicate that there
are added dependencies to any of the importer nodes.
Type declaration
modifiedDependencies
BuildIdealOptions
Defined in: ideal/build.ts:20
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.
Dependency
Defined in: dependencies.ts:55
Parsed dependency entries info.
Type declaration
spec
The parsed Spec object describing the dependency requirements.
type
The DependencyTypeShort, describing the type of dependency.
DependencyTypeLong
Defined in: dependencies.ts:9
Name of the package.json keys used to define different types of dependencies.
DependencyTypeShort
Defined in: dependencies.ts:18
Unique keys that define different types of dependencies relationship.
EdgeLike
Defined in: types.ts:6
Type declaration
from
name
spec
to?
type
EdgeMap
Defined in: visualization/human-readable-output.ts:34
GraphLike
Defined in: types.ts:14
Type declaration
addEdge()
Parameters
type
spec
from
to?
Returns
addNode()
Parameters
id?
manifest?
spec?
name?
string
version?
string
Returns
edges
importers
mainImporter
nodes
projectRoot
GraphOptions
Defined in: graph.ts:25
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
HumanReadableOutputGraph
Defined in: visualization/human-readable-output.ts:27
Type declaration
edges
highlightSelection?
importers
nodes
JSONOutputGraph
Defined in: visualization/json-output.ts:31
Type declaration
edges
nodes
JSONOutputItem
Defined in: visualization/json-output.ts:8
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.
LockfileData
Defined in: lockfile/types.ts:14
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
LockfileEdgeKey
Defined in: lockfile/types.ts:70
${from} ${dep name}
LockfileEdges
Defined in: lockfile/types.ts:65
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
LockfileEdgeValue
Defined in: lockfile/types.ts:73
${type} ${spec} ${to}
LockfileLoadOptions
Defined in: lockfile/load.ts:13
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
LockfileNode
Defined in: lockfile/types.ts:47
Lockfile representation of a node from the install graph.
LockfileNodeFlags
Defined in: lockfile/types.ts:42
Bit flags indicating whether a node is optional and/or dev.
ManifestInventory
Defined in: graph.ts:20
MermaidOutputGraph
Defined in: visualization/mermaid-output.ts:6
Type declaration
edges
importers
nodes
NodeLike
Defined in: types.ts:35
Type declaration
dev
edgesIn
edgesOut
graph
id
importer
integrity?
location?
mainImporter
manifest?
name?
optional
projectRoot
resolved?
version?
setResolved()
Returns
void
toString()
Returns
string
NodeOptions
Defined in: node.ts:18
Type declaration
graph
projectRoot
RawDependency
Defined in: dependencies.ts:45
Dependency entries info as defined in a package.json file.
Type declaration
bareSpec
name
registry?
type
ReifyOptions
Defined in: reify/index.ts:35
Type declaration
actual?
add?
graph
packageInfo
remove?
RemoveImportersDependenciesMap
Defined in: dependencies.ts:88
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.
The modifiedDependencies
property can be used to indicate that there
are added dependencies to any of the importer nodes.
Type declaration
modifiedDependencies
SaveOptions
Defined in: lockfile/save.ts:24
Type declaration
graph
The graph to be stored in the lockfile.
saveManifests?
Should it save manifest data in the lockfile?
TreeItem
Defined in: visualization/human-readable-output.ts:15
Type declaration
deduped
edge
hasSibling
include
name?
node
padding
parent
prefix
TreeMap
Defined in: visualization/human-readable-output.ts:36
Variables
actual
Defined in: index.ts:16
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
Returns
dependencyTypes
Defined in: dependencies.ts:137
Maps between long form names usually used in package.json
files
to a corresponding short form name, used in lockfiles.
ideal
Defined in: index.ts:37
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
Returns
Promise
<Graph
>
lockfile
Defined in: index.ts:25
Type declaration
load()
Parameters
options
Returns
loadEdges()
Parameters
graph
edges
options
Returns
void
loadNodes()
Parameters
graph
nodes
Record
<DepID
, LockfileNode
>
Returns
void
save()
Parameters
options
Returns
void
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
Defined in: dependencies.ts:115
A set of the possible long dependency type names,
as used in package.json
files.
shortDependencyTypes
Defined in: dependencies.ts:125
A set of the short type keys used to represent dependency relationships.
Functions
asDependency()
Defined in: dependencies.ts:104
Parameters
obj
unknown
Returns
asDependencyTypeShort()
Defined in: dependencies.ts:30
Parameters
obj
unknown
Returns
getBooleanFlagsFromNum()
Defined in: lockfile/types.ts:29
Parameters
flags
Returns
object
dev
optional
getFlagNumFromNode()
Defined in: lockfile/types.ts:20
Parameters
node
dev
boolean
optional
boolean
Returns
0
| 1
| 2
| 3
humanReadableOutput()
Defined in: visualization/human-readable-output.ts:98
Returns a human-readable output of the graph.
Parameters
options
__namedParameters
colors
ChalkInstance
Returns
undefined
| null
| string
isDependency()
Defined in: dependencies.ts:97
Parameters
o
unknown
Returns
o is Dependency
isDependencyTypeShort()
Defined in: dependencies.ts:25
Parameters
obj
unknown
Returns
obj is DependencyTypeShort
jsonOutput()
Defined in: visualization/json-output.ts:39
Returns a JSON string representation of the graph.
Parameters
__namedParameters
Returns
mermaidOutput()
Defined in: visualization/mermaid-output.ts:67
Returns a mermaid string representation of the graph.
Parameters
__namedParameters
Returns
string
reify()
Defined in: reify/index.ts:46
Make the current project match the supplied graph.
Parameters
options
Returns
Promise
<void
>
shorten()
Defined in: dependencies.ts:150
Get the DependencyTypeShort from a DependencyTypeLong.
Parameters
typeLong
name?
string
manifest?
Returns
stringifyNode()
Defined in: stringify-node.ts:4
Parameters
node?
Returns
string