@vltpkg/graph
Classes
Diff
Defined in: graph/src/diff.ts:25
A Diff object is a representation of a set of changes from one graph to another, typically from the actual graph as it is reified on disk, to an intended ideal graph.
The naming convention can get a bit confusing here, because it’s a set of directed changes from one set of directed objects to another.
Within the context the Diff object, from
is the Graph we’re coming
from, and to
is the Graph we’re trying to create.
Constructors
new Diff()
new Diff(from, to): Diff
Defined in: graph/src/diff.ts:61
Parameters
from
to
Returns
Properties
edges
edges: object
Defined in: graph/src/diff.ts:50
Collection of nodes to add and delete
add
add: Set<Edge>
Edges in the to
graph that are not found in the from
graph
delete
delete: Set<Edge>;
Edges in the from
graph that are not found in the to
graph
from
from: Graph
Defined in: graph/src/diff.ts:26
hadOptionalFailures
hadOptionalFailures: boolean = false
Defined in: graph/src/diff.ts:35
If changes need to be made later for failures of optional nodes, set this flag so that we know to call graph.gc() at the appropriate time.
nodes
nodes: object
Defined in: graph/src/diff.ts:40
Collection of nodes to add and delete
add
add: Set<Node>
Nodes in the to
graph that are not in the from
graph
delete
delete: Set<Node>;
Nodes in the from
graph that are not in the to
graph
projectRoot
projectRoot: string
Defined in: graph/src/diff.ts:29
to
to: Graph
Defined in: graph/src/diff.ts:27
Accessors
[toStringTag]
Get Signature
get toStringTag: string
Defined in: graph/src/diff.ts:57
Returns
string
Methods
[kCustomInspect]()
kCustomInspect: string
Defined in: graph/src/diff.ts:102
Parameters
_
number
options?
InspectOptions
Returns
string
Edge
Defined in: graph/src/edge.ts:11
Implements
Constructors
new Edge()
new Edge( type, spec, from, to?): Edge
Defined in: graph/src/edge.ts:49
Parameters
type
spec
from
to?
Returns
Properties
from
from: Node
Defined in: graph/src/edge.ts:32
The Node this Edge is connecting from, this is usually the dependent.
Implementation of
EdgeLike.from
spec
spec: Spec
Defined in: graph/src/edge.ts:47
The defined spec value for to
as parsed from the dependent metadata.
Implementation of
EdgeLike.spec
to?
optional to: Node;
Defined in: graph/src/edge.ts:37
The node this Edge is connecting to, this is usually a direct dependency.
Implementation of
EdgeLike.to
type
type: DependencyTypeShort
Defined in: graph/src/edge.ts:42
What type of dependency relationship from
and to
nodes have.
Implementation of
EdgeLike.type
Accessors
[toStringTag]
Get Signature
get toStringTag: string
Defined in: graph/src/edge.ts:12
Returns
string
dev
Get Signature
get dev(): boolean
Defined in: graph/src/edge.ts:71
This edge was defined as part of a devDependencies
in package.json
Returns
boolean
name
Get Signature
get name(): string
Defined in: graph/src/edge.ts:64
The name of the dependency to
as defined in the dependent metadata.
Returns
string
Implementation of
EdgeLike.name
optional
Get Signature
get optional(): boolean
Defined in: graph/src/edge.ts:75
Returns
boolean
Implementation of
EdgeLike.optional
peer
Get Signature
get peer(): boolean
Defined in: graph/src/edge.ts:79
Returns
boolean
Implementation of
EdgeLike.peer
peerOptional
Get Signature
get peerOptional(): boolean
Defined in: graph/src/edge.ts:83
Returns
boolean
Methods
[kCustomInspect]()
kCustomInspect: string
Defined in: graph/src/edge.ts:16
Parameters
_
number
options
InspectOptions
Returns
string
valid()
valid(): boolean
Defined in: graph/src/edge.ts:87
Returns
boolean
Graph
Defined in: graph/src/graph.ts:48
Implements
Constructors
new Graph()
new Graph(options): Graph
Defined in: graph/src/graph.ts:112
Parameters
options
Returns
Properties
edges
edges: Set<Edge>
Defined in: graph/src/graph.ts:70
A set of all edges in this graph.
Implementation of
GraphLike.edges
extraneousDependencies
extraneousDependencies: Set<Edge>
Defined in: graph/src/graph.ts:105
A set of extraneous dependencies found when building the graph.
importers
importers: Set<Node>
Defined in: graph/src/graph.ts:95
A set of importer nodes in this graph.
Implementation of
GraphLike.importers
mainImporter
mainImporter: Node
Defined in: graph/src/graph.ts:100
The Node that represents the project root package.json
.
Implementation of
GraphLike.mainImporter
manifests
manifests: ManifestInventory
Defined in: graph/src/graph.ts:65
An inventory with all manifests related to an install.
monorepo?
optional monorepo: Monorepo;
Defined in: graph/src/graph.ts:60
A Monorepo instance, used for managing workspaces.
nodes
nodes: Map<DepID, Node>
Defined in: graph/src/graph.ts:75
Map registered dep ids to the node that represent them in the graph.
Implementation of
GraphLike.nodes
nodesByName
nodesByName: Map<string, Set<Node>>
Defined in: graph/src/graph.ts:80
Map of nodes by their name
projectRoot
projectRoot: string
Defined in: graph/src/graph.ts:110
The root of the project this graph represents
Implementation of
GraphLike.projectRoot
resolutions
resolutions: Map<string, Node>
Defined in: graph/src/graph.ts:85
Cached resolutions for spec lookups
resolutionsReverse
resolutionsReverse: Map<Node, Set<string>>
Defined in: graph/src/graph.ts:90
Reverse map of resolutions
Accessors
[toStringTag]
Get Signature
get toStringTag: string
Defined in: graph/src/graph.ts:49
Returns
string
Methods
[kCustomInspect]()
kCustomInspect: string
Defined in: graph/src/graph.ts:426
Parameters
_
number
options
InspectOptions
Returns
string
addEdge()
addEdge( type, spec, from, to?): Edge
Defined in: graph/src/graph.ts:197
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
GraphLike.addEdge
addNode()
addNode( id?, manifest?, spec?, name?, version?): Node
Defined in: graph/src/graph.ts:277
Create a new node in the graph.
Parameters
id?
manifest?
spec?
name?
string
version?
string
Returns
Implementation of
GraphLike.addNode
findResolution()
findResolution(spec, fromNode): undefined | Node
Defined in: graph/src/graph.ts:246
Find an existing node to satisfy a dependency
Parameters
spec
fromNode
Returns
undefined
| Node
gc()
gc(): Map<DepID, Node>
Defined in: graph/src/graph.ts:168
Delete all nodes and edges 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()
placePackage( fromNode, depType, spec, manifest?, id?, extra?): undefined | Node
Defined in: graph/src/graph.ts:321
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?
extra?
string
Returns
undefined
| Node
removeNode()
removeNode(node, replacement?): void
Defined in: graph/src/graph.ts:385
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()
toJSON(): LockfileData
Defined in: graph/src/graph.ts:418
Returns
GraphModifier
Defined in: graph/src/modifiers.ts:124
Class representing loaded modifiers configuration for a project.
Instances of this class can be used as a helper to modify the graph during the graph build ideal traversal time.
const modifier = new GraphModifier(options)modifier.load(options)
The tryImporter
method can be used to register the initial importer
node along with any modifier that includes an importer selector, e.g:
modifier.tryImporter(graph.mainImporter)
When traversing the graph, use the tryNewDependency
method to check
if a given dependency name to the current traversed node has matching
registered modifiers, e.g:
const entries = modifier.tryNewDependency(fromNode, depName)
Use updateActiveEntry
to update a given active modifier entry state
with the current node of the graph being traversed. e.g:
for (const entry of entries) modifier.updateActiveEntry(fromNode, entry)
Constructors
new GraphModifier()
new GraphModifier(options): GraphModifier
Defined in: graph/src/modifiers.ts:156
Parameters
options
Returns
Properties
activeModifiers
activeModifiers: Set<ModifierActiveEntry>
Defined in: graph/src/modifiers.ts:154
A set of currently active modifiers, which are being parsed.
Accessors
config
Get Signature
get config(): GraphModifierConfigObject
Defined in: graph/src/modifiers.ts:164
Load the modifiers definitions from vlt.json, converting the result into a GraphModifierConfigObject
Returns
Methods
deregisterModifier()
deregisterModifier(modifier): void
Defined in: graph/src/modifiers.ts:418
Removes a previously registered modifier from the active entries.
Parameters
modifier
Returns
void
load()
load(options): void
Defined in: graph/src/modifiers.ts:173
Loads the modifiers defined in vlt.json
into memory.
Parameters
options
Returns
void
maybeHasModifier()
maybeHasModifier(depName): boolean
Defined in: graph/src/modifiers.ts:231
Check if a given importer dependency name has potentially a registered
modifier. In case of an ambiguous modifier, the method will always
return true
, it only returns false
in the case that only fully
qualified modifiers are registered and none are targeting the given
top-level dependency name.
This method is useful to help avoiding traversing the sub graph of a direct dependency when we know that it’s impossible to ever match beforehand.
Parameters
depName
string
Returns
boolean
newModifier()
newModifier(from, modifier): ModifierActiveEntry
Defined in: graph/src/modifiers.ts:404
Creates a new active modifier.
Parameters
from
modifier
Returns
rollbackActiveEntries()
rollbackActiveEntries(): void
Defined in: graph/src/modifiers.ts:445
Operates in previously registered nodes and edges in order to put back in place any of the original edges that were referenced to in active (ongoing) breadcrumb parsing entries that were never completed.
This method can be used to easily rollback any pending operations once the graph traversal is done.
Returns
void
tryDependencies()
tryDependencies(from, dependencies): Map<string, ModifierActiveEntry>
Defined in: graph/src/modifiers.ts:353
Returns the set of ModifierActiveEntry instances that matches the provided Dependency specs for a given node.
This method is mostly a helper to GraphModifier.tryNewDependency that handles the registered modifiers traversal lookup.
Parameters
from
dependencies
Returns
Map
<string
, ModifierActiveEntry
>
tryImporter()
tryImporter(importer): void
Defined in: graph/src/modifiers.ts:249
Try matching the provided node against the top-level selectors. In case a match is found it will also register the active entry modifier and update the active entry to the current importer node.
Parameters
importer
Returns
void
tryNewDependency()
tryNewDependency(from, name): | undefined | ModifierActiveEntry
Defined in: graph/src/modifiers.ts:289
Try matching the provided node and dependency name to the current active parsing modifier entries along with possible starting-level modifiers.
Any entries in which the breachcrumb have already reached its last
element will be prioritized, along with checking for specificity, the
complete entry with the highest specificity will be returned or just
the entry with the highest specificity if no complete entry is found.
Returns undefined
if no matching entry is found.
This method works with the assumption that it’s going to be called during a graph traversal, such that any ascendent has been checked and the active modifier entry state has been updated in the previous iteration.
Parameters
from
name
string
Returns
| undefined
| ModifierActiveEntry
updateActiveEntry()
updateActiveEntry(from, active): void
Defined in: graph/src/modifiers.ts:372
Updates an active entry state keeping track of items in the multi-level active entries map. If the current breadcrumb state shows there’s no more items left, then we deregister the modifier.
Parameters
from
active
Returns
void
load()
static load(options): GraphModifier
Defined in: graph/src/modifiers.ts:474
Convenience method to instantiate and load in one call. Throws if called on a directory that does not have a vlt.json file.
Parameters
options
Returns
maybeLoad()
static maybeLoad(options): undefined | GraphModifier
Defined in: graph/src/modifiers.ts:464
Convenience method to instantiate and load in one call. Returns undefined if the project does not have a vlt.json file, otherwise returns the loaded Modifiers instance.
Parameters
options
Returns
undefined
| GraphModifier
Node
Defined in: graph/src/node.ts:27
Implements
Constructors
new Node()
new Node( options, id?, manifest?, spec?, name?, version?): Node
Defined in: graph/src/node.ts:221
Parameters
options
id?
manifest?
spec?
name?
string
version?
string
Returns
Properties
confused
confused: boolean = false
Defined in: graph/src/node.ts:90
True if there’s a manifest-confused package name.
Implementation of
NodeLike.confused
edgesIn
edgesIn: Set<Edge>
Defined in: graph/src/node.ts:95
List of edges coming into this node.
Implementation of
NodeLike.edgesIn
edgesOut
edgesOut: Map<string, Edge>
Defined in: graph/src/node.ts:101
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
graph
graph: GraphLike
Defined in: graph/src/node.ts:121
A reference to the graph this node is a part of.
Implementation of
NodeLike.graph
id
id: DepID
Defined in: graph/src/node.ts:106
A reference to the DepID this node represents in the graph.
Implementation of
NodeLike.id
importer
importer: boolean = false
Defined in: graph/src/node.ts:111
True if this node is an importer node.
Implementation of
NodeLike.importer
integrity?
optional integrity: `sha512-${string}`;
Defined in: graph/src/node.ts:126
The manifest integrity value.
Implementation of
NodeLike.integrity
mainImporter
mainImporter: boolean = false
Defined in: graph/src/node.ts:116
True if this node is the project root node.
Implementation of
NodeLike.mainImporter
manifest?
optional manifest: Manifest;
Defined in: graph/src/node.ts:131
The manifest this node represents in the graph.
Implementation of
NodeLike.manifest
modifier
modifier: undefined | string
Defined in: graph/src/node.ts:150
If this node has been modified as part of applying a
GraphModifier then this field will contain the
modifier query that was applied. Otherwise, it will be undefined
.
projectRoot
projectRoot: string
Defined in: graph/src/node.ts:136
Project where this node resides
Implementation of
NodeLike.projectRoot
registry?
optional registry: string;
Defined in: graph/src/node.ts:143
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?
optional resolved: string;
Defined in: graph/src/node.ts:176
An address PackageInfoClient may use to extract this package.
Implementation of
NodeLike.resolved
version?
optional version: string;
Defined in: graph/src/node.ts:171
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
Accessors
[toStringTag]
Get Signature
get toStringTag: string
Defined in: graph/src/node.ts:28
Returns
string
dev
Get Signature
get dev(): boolean
Defined in: graph/src/node.ts:69
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
set dev(dev): void
Defined in: graph/src/node.ts:72
Parameters
dev
boolean
Returns
void
Implementation of
NodeLike.dev
location
Get Signature
get location(): string
Defined in: graph/src/node.ts:181
The file system location for this node.
Returns
string
Set Signature
set location(location): void
Defined in: graph/src/node.ts:191
Parameters
location
string
Returns
void
Implementation of
NodeLike.location
name
Get Signature
get name(): string
Defined in: graph/src/node.ts:159
Returns
string
Implementation of
NodeLike.name
optional
Get Signature
get optional(): boolean
Defined in: graph/src/node.ts:44
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
set optional(optional): void
Defined in: graph/src/node.ts:47
Parameters
optional
boolean
Returns
void
Implementation of
NodeLike.optional
rawManifest
Get Signature
get rawManifest(): undefined | Manifest
Defined in: graph/src/node.ts:348
The raw manifest before any modifications. If not set, falls back to the current manifest.
Returns
undefined
| Manifest
Implementation of
NodeLike.rawManifest
Methods
addEdgesTo()
addEdgesTo( type, spec, node?): Edge
Defined in: graph/src/node.ts:337
Add an edge from this node connecting it to a direct dependency.
Parameters
type
spec
node?
Returns
equals()
equals(other): boolean
Defined in: graph/src/node.ts:287
Parameters
other
Returns
boolean
inVltStore()
inVltStore(): boolean
Defined in: graph/src/node.ts:269
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()
isDev(): this is Node & { dev: true }
Defined in: graph/src/node.ts:83
Returns
this is Node & { dev: true }
isOptional()
isOptional(): this is Node & { optional: true }
Defined in: graph/src/node.ts:58
Returns
this is Node & { optional: true }
nodeModules()
nodeModules(scurry): string
Defined in: graph/src/node.ts:214
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()
resolvedLocation(scurry): string
Defined in: graph/src/node.ts:202
The resolved location of the node in the file system.
Parameters
scurry
Returns
string
setConfusedManifest()
setConfusedManifest(fixed, confused?): void
Defined in: graph/src/node.ts:355
Sets this node as having a manifest-confused manifest.
Parameters
fixed
confused?
Returns
void
Implementation of
NodeLike.setConfusedManifest
setDefaultLocation()
setDefaultLocation(): void
Defined in: graph/src/node.ts:320
Returns
void
setImporterLocation()
setImporterLocation(location): void
Defined in: graph/src/node.ts:294
Sets the node as an importer along with its location.
Parameters
location
string
Returns
void
setResolved()
setResolved(): void
Defined in: graph/src/node.ts:304
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
NodeLike.setResolved
toJSON()
toJSON(): object
Defined in: graph/src/node.ts:362
Returns
object
confused
confused: boolean
dev
dev: boolean
id
id: DepID
importer
importer: boolean
integrity
integrity: undefined | `sha512-${string}`
location
location: string
manifest
manifest: undefined | Manifest
modifier
modifier: undefined | string
name
name: string
optional
optional: boolean
projectRoot
projectRoot: string
rawManifest?
optional rawManifest: Manifest;
resolved
resolved: undefined | string
version
version: undefined | string
Implementation of
NodeLike.toJSON
toString()
toString(): string
Defined in: graph/src/node.ts:383
Returns
string
Implementation of
NodeLike.toString
Type Aliases
ActualLoadOptions
type ActualLoadOptions = SpecOptions & object
Defined in: graph/src/actual/load.ts:22
Type declaration
loadManifests?
optional loadManifests: boolean;
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?
optional mainManifest: Manifest;
The project root manifest.
monorepo?
optional monorepo: Monorepo;
A Monorepo object, for managing workspaces
packageJson
packageJson: PackageJson
A PackageJson object, for sharing manifest caches
projectRoot
projectRoot: string
The project root dirname.
scurry
scurry: PathScurry
A PathScurry object, for use in globs
skipHiddenLockfile?
optional skipHiddenLockfile: boolean;
If set to true
, then do not shortcut the process by reading the
hidden lockfile at node_modules/.vlt-lock.json
AddImportersDependenciesMap
type AddImportersDependenciesMap = Map< DepID, Map<string, Dependency>> & object
Defined in: graph/src/dependencies.ts:73
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
modifiedDependencies: boolean
BaseModifierEntry
type BaseModifierEntry = object
Defined in: graph/src/modifiers.ts:35
Info needed to define a graph modifier.
Type declaration
breadcrumb
breadcrumb: ModifierBreadcrumb
query
query: string
refs
refs: Set<{ from: Node name: string}>
type
type: 'edge' | 'node'
value
value: string | Manifest
BuildIdealOptions
type BuildIdealOptions = ActualLoadOptions & object
Defined in: graph/src/ideal/build.ts:19
Type declaration
add?
optional add: 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.
modifiers?
optional modifiers: GraphModifier;
The graph modifiers helper object.
packageInfo
packageInfo: PackageInfoClient
A PackageInfoClient instance to read manifest info from.
remove?
optional remove: 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.
Dependency
type Dependency = object
Defined in: graph/src/dependencies.ts:52
Parsed dependency entries info.
Type declaration
spec
spec: Spec
The parsed Spec object describing the dependency requirements.
type
type: DependencySaveType
The DependencySaveType, describing the way this dependency should be saved back to the manifest.
EdgeLike
type EdgeLike = object
Defined in: graph/src/types.ts:5
Type declaration
from
from: NodeLike
name
name: string
optional?
optional optional: boolean;
peer?
optional peer: boolean;
spec
spec: SpecLikeBase
to?
optional to: NodeLike;
type
type: DependencyTypeShort
EdgeMap
type EdgeMap = Map<NodeLike | undefined, TreeItem>
Defined in: graph/src/visualization/human-readable-output.ts:39
EdgeModifierEntry
type EdgeModifierEntry = BaseModifierEntry & object
Defined in: graph/src/modifiers.ts:49
Extra info to define specifically a graph edge modifier.
Type declaration
spec
spec: Spec
type
type: 'edge'
value
value: string
GraphLike
type GraphLike = object
Defined in: graph/src/types.ts:15
Type declaration
addEdge()
addEdge: (type, spec, from, to?) => EdgeLike
Parameters
type
spec
from
to?
Returns
addNode()
addNode: (id?, manifest?, spec?, name?, version?) => NodeLike
Parameters
id?
manifest?
spec?
name?
string
version?
string
Returns
edges
edges: Set<EdgeLike>
importers
importers: Set<NodeLike>
mainImporter
mainImporter: NodeLike
nodes
nodes: Map<DepID, NodeLike>
projectRoot
projectRoot: string
GraphModifierConfigObject
type GraphModifierConfigObject = Record<string, string>
Defined in: graph/src/modifiers.ts:30
Type definition for the modifiers configuration object
GraphModifierLoadedConfig
type GraphModifierLoadedConfig = object
Defined in: graph/src/modifiers.ts:22
Loaded modifiers configuration as described in the vlt.json
file.
Type declaration
modifiers
modifiers: GraphModifierConfigObject
GraphOptions
type GraphOptions = SpecOptions & object
Defined in: graph/src/graph.ts:29
Type declaration
mainManifest
mainManifest: Manifest
The main importer manifest info.
manifests?
optional manifests: ManifestInventory;
An inventory of seen manifests.
monorepo?
optional monorepo: Monorepo;
A Monorepo object, for managing workspaces
projectRoot
projectRoot: string
Root of the project this graph represents
HumanReadableOutputGraph
type HumanReadableOutputGraph = object
Defined in: graph/src/visualization/human-readable-output.ts:32
Type declaration
edges
edges: EdgeLike[];
highlightSelection?
optional highlightSelection: boolean;
importers
importers: Set<NodeLike>
nodes
nodes: NodeLike[];
InstallOptions
type InstallOptions = ActualLoadOptions & object
Defined in: graph/src/install.ts:9
Type declaration
packageInfo
packageInfo: PackageInfoClient
JSONOutputGraph
type JSONOutputGraph = object
Defined in: graph/src/visualization/json-output.ts:31
Type declaration
edges
edges: EdgeLike[];
nodes
nodes: NodeLike[];
JSONOutputItem
type JSONOutputItem = object
Defined in: graph/src/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?
optional fromID: DepID;
A reference to the id of the Node that this package is linked from.
name
name: string
The name of the package.
spec?
optional spec: string;
The dependency spec definition for this package.
to?
optional to: NodeLike;
A representation of the package object that fulfills this dependency.
type?
optional type: EdgeLike["type"];
The package type.
LockfileData
type LockfileData = object
Defined in: graph/src/lockfile/types.ts:17
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
edges: LockfileEdges
nodes
nodes: Record<DepID, LockfileNode>
options
options: SpecOptions
LockfileEdgeKey
type LockfileEdgeKey = `${DepID} ${string}`
Defined in: graph/src/lockfile/types.ts:74
${from} ${dep name}
LockfileEdges
type LockfileEdges = object
Defined in: graph/src/lockfile/types.ts:69
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: | `·${string}·${string}·${string} ${string}` | `git·${string}·${string}·${string} ${string}` | `·${string}·${string} ${string}` | `git·${string}·${string} ${string}` | `file·${string}·${string} ${string}` | `remote·${string}·${string} ${string}` | `workspace·${string}·${string} ${string}` | `file·${string} ${string}` | `remote·${string} ${string}` | `workspace·${string} ${string}`]: | `dev ${string} ·${string}·${string}·${string}` | `dev ${string} git·${string}·${string}·${string}` | `dev ${string} ·${string}·${string}` | `dev ${string} git·${string}·${string}` | `dev ${string} file·${string}·${string}` | `dev ${string} remote·${string}·${string}` | `dev ${string} workspace·${string}·${string}` | `dev ${string} file·${string}` | `dev ${string} remote·${string}` | `dev ${string} workspace·${string}` | `dev ${string} MISSING` | `optional ${string} ·${string}·${string}·${string}` | `optional ${string} git·${string}·${string}·${string}` | `optional ${string} ·${string}·${string}` | `optional ${string} git·${string}·${string}` | `optional ${string} file·${string}·${string}` | `optional ${string} remote·${string}·${string}` | `optional ${string} workspace·${string}·${string}` | `optional ${string} file·${string}` | `optional ${string} remote·${string}` | `optional ${string} workspace·${string}` | `optional ${string} MISSING` | `peer ${string} ·${string}·${string}·${string}` | `peer ${string} git·${string}·${string}·${string}` | `peer ${string} ·${string}·${string}` | `peer ${string} git·${string}·${string}` | `peer ${string} file·${string}·${string}` | `peer ${string} remote·${string}·${string}` | `peer ${string} workspace·${string}·${string}` | `peer ${string} file·${string}` | `peer ${string} remote·${string}` | `peer ${string} workspace·${string}` | `peer ${string} MISSING` | `peerOptional ${string} ·${string}·${string}·${string}` | `peerOptional ${string} git·${string}·${string}·${string}` | `peerOptional ${string} ·${string}·${string}` | `peerOptional ${string} git·${string}·${string}` | `peerOptional ${string} file·${string}·${string}` | `peerOptional ${string} remote·${string}·${string}` | `peerOptional ${string} workspace·${string}·${string}` | `peerOptional ${string} file·${string}` | `peerOptional ${string} remote·${string}` | `peerOptional ${string} workspace·${string}` | `peerOptional ${string} MISSING` | `prod ${string} ·${string}·${string}·${string}` | `prod ${string} git·${string}·${string}·${string}` | `prod ${string} ·${string}·${string}` | `prod ${string} git·${string}·${string}` | `prod ${string} file·${string}·${string}` | `prod ${string} remote·${string}·${string}` | `prod ${string} workspace·${string}·${string}` | `prod ${string} file·${string}` | `prod ${string} remote·${string}` | `prod ${string} workspace·${string}` | `prod ${string} MISSING`
LockfileEdgeValue
type LockfileEdgeValue = `${DependencyTypeShort} ${Spec['bareSpec']} ${DepID | 'MISSING'}`
Defined in: graph/src/lockfile/types.ts:77
${type} ${spec} ${to}
LockfileLoadOptions
type LockfileLoadOptions = SpecOptions & object
Defined in: graph/src/lockfile/load.ts:13
Type declaration
mainManifest
mainManifest: Manifest
The project root manifest.
monorepo?
optional monorepo: Monorepo;
A Monorepo object, for managing workspaces
packageJson?
optional packageJson: PackageJson;
A PackageJson object, for sharing manifest caches
projectRoot
projectRoot: string
The project root dirname.
scurry?
optional scurry: PathScurry;
A PathScurry object, for use in globs
LockfileNode
type LockfileNode = [ LockfileNodeFlags, string | null, Integrity | null, string | null, string | null, Manifest | null, Manifest | null,]
Defined in: graph/src/lockfile/types.ts:50
Lockfile representation of a node from the install graph.
LockfileNodeFlags
type LockfileNodeFlags = 0 | 1 | 2 | 3
Defined in: graph/src/lockfile/types.ts:45
Bit flags indicating whether a node is optional and/or dev.
ManifestInventory
type ManifestInventory = Map<DepID, Manifest>
Defined in: graph/src/graph.ts:24
MermaidOutputGraph
type MermaidOutputGraph = object
Defined in: graph/src/visualization/mermaid-output.ts:6
Type declaration
edges
edges: EdgeLike[];
importers
importers: Set<NodeLike>
nodes
nodes: NodeLike[];
ModifierActiveEntry
type ModifierActiveEntry = object
Defined in: graph/src/modifiers.ts:74
An object to track modifiers that have matched an initial part of the breadcrumb. It holds pointers to both nodes and edges matched in the current traversed graph on top of the modifier info and the breadcrumb state that is used to track the current state of the parsing.
Type declaration
interactiveBreadcrumb
interactiveBreadcrumb: ModifierInteractiveBreadcrumb
The breadcrumb that is used to track the current state of the parsing.
modifiedEdge?
optional modifiedEdge: Edge;
The modified edge that is being used to replace the original edge.
modifier
modifier: ModifierEntry
The modifier this active entry is working with.
originalEdge?
optional originalEdge: Edge;
The original edge that is being replaced with this entry.
originalFrom
originalFrom: Node
The first node to be affected by this modifier.
ModifierEntry
type ModifierEntry = EdgeModifierEntry | NodeModifierEntry
Defined in: graph/src/modifiers.ts:66
A graph modifier entry, which can be either an edge or a node modifier.
NodeLike
type NodeLike = object
Defined in: graph/src/types.ts:36
Type declaration
confused
confused: boolean
dev
dev: boolean
edgesIn
edgesIn: Set<EdgeLike>
edgesOut
edgesOut: Map<string, EdgeLike>
graph
graph: GraphLike
id
id: DepID
importer
importer: boolean
integrity?
optional integrity: string | null;
location?
optional location: string;
mainImporter
mainImporter: boolean
manifest?
optional manifest: Manifest | null;
name?
optional name: string | null;
optional
optional: boolean
projectRoot
projectRoot: string
rawManifest?
optional rawManifest: Manifest | null;
resolved?
optional resolved: string | null;
toJSON()
toJSON: () => Pick< NodeLike, | 'id' | 'name' | 'version' | 'location' | 'importer' | 'manifest' | 'projectRoot' | 'integrity' | 'resolved' | 'dev' | 'optional' | 'confused' > & object
Returns
Pick
<NodeLike
, | "id"
| "name"
| "version"
| "location"
| "importer"
| "manifest"
| "projectRoot"
|
"integrity"
| "resolved"
| "dev"
| "optional"
|
"confused"
> & object
version?
optional version: string | null;
setConfusedManifest()
Parameters
fixed
confused?
Returns
void
setResolved()
Returns
void
toString()
Returns
string
NodeModifierEntry
type NodeModifierEntry = BaseModifierEntry & object
Defined in: graph/src/modifiers.ts:58
Extra info to define the graph node modifier.
Type declaration
manifest
manifest: Manifest
type
type: 'node'
NodeOptions
type NodeOptions = SpecOptions & object
Defined in: graph/src/node.ts:22
Type declaration
graph
graph: GraphLike
projectRoot
projectRoot: string
RawDependency
type RawDependency = object
Defined in: graph/src/dependencies.ts:42
Dependency entries info as defined in a package.json file.
Type declaration
bareSpec
bareSpec: string
name
name: string
registry?
optional registry: string;
type
type: DependencyTypeLong
ReifyOptions
type ReifyOptions = ActualLoadOptions & object
Defined in: graph/src/reify/index.ts:34
Type declaration
actual?
optional actual: Graph;
add?
optional add: AddImportersDependenciesMap;
graph
graph: Graph
packageInfo
packageInfo: PackageInfoClient
remove?
optional remove: RemoveImportersDependenciesMap;
RemoveImportersDependenciesMap
type RemoveImportersDependenciesMap = Map<DepID, Set<string>> & object
Defined in: graph/src/dependencies.ts:86
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
modifiedDependencies: boolean
SaveOptions
type SaveOptions = SpecOptions & object
Defined in: graph/src/lockfile/save.ts:26
Type declaration
graph
graph: Graph
The graph to be stored in the lockfile.
saveManifests?
optional saveManifests: boolean;
Should it save manifest data in the lockfile?
TreeItem
type TreeItem = object
Defined in: graph/src/visualization/human-readable-output.ts:20
Type declaration
edge
edge: EdgeLike | undefined
hasSibling
hasSibling: boolean
include
include: boolean
name?
optional name: string | null;
node
node: NodeLike | undefined
padding
padding: string
parent
parent: TreeItem | undefined
prefix
prefix: string
seen
seen: boolean
TreeMap
type TreeMap = Map<EdgeLike | undefined, EdgeMap>
Defined in: graph/src/visualization/human-readable-output.ts:41
UninstallOptions
type UninstallOptions = ActualLoadOptions & object
Defined in: graph/src/uninstall.ts:8
Type declaration
packageInfo
packageInfo: PackageInfoClient
Variables
actual
const actual: object
Defined in: graph/src/index.ts:18
Type declaration
load()
load: options => (Graph = actualLoad)
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
ideal
const ideal: object
Defined in: graph/src/index.ts:38
Type declaration
build()
build: options => Promise<Graph>
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
const lockfile: object
Defined in: graph/src/index.ts:25
Type declaration
load()
load: options => (Graph = lockfileLoad)
Parameters
options
Returns
loadEdges()
loadEdges: (graph, edges, options) => void;
Parameters
graph
edges
options
Returns
void
loadNodes()
loadNodes: (graph, nodes) => void;
Parameters
graph
nodes
Record
<DepID
,
LockfileNode
>
Returns
void
save()
save: (options) => void;
Parameters
options
Omit
<SaveOptions
, "saveManifests"
>
Returns
void
LockfileNodeFlagDev
const LockfileNodeFlagDev: 2 = 2
Defined in: graph/src/lockfile/types.ts:39
LockfileNodeFlagDevOptional
const LockfileNodeFlagDevOptional: 3 = 3
Defined in: graph/src/lockfile/types.ts:40
LockfileNodeFlagNone
const LockfileNodeFlagNone: 0 = 0
Defined in: graph/src/lockfile/types.ts:37
LockfileNodeFlagOptional
const LockfileNodeFlagOptional: 1 = 1
Defined in: graph/src/lockfile/types.ts:38
Functions
asDependency()
function asDependency(obj): Dependency
Defined in: graph/src/dependencies.ts:102
Parameters
obj
unknown
Returns
asDependencyTypeShort()
function asDependencyTypeShort(obj): DependencyTypeShort
Defined in: graph/src/dependencies.ts:27
Parameters
obj
unknown
Returns
getBooleanFlagsFromNum()
function getBooleanFlagsFromNum(flags): object
Defined in: graph/src/lockfile/types.ts:32
Parameters
flags
Returns
object
dev
dev: boolean
optional
optional: boolean
getFlagNumFromNode()
function getFlagNumFromNode(node): 0 | 1 | 2 | 3
Defined in: graph/src/lockfile/types.ts:23
Parameters
node
dev?
boolean
optional?
boolean
Returns
0
| 1
| 2
| 3
humanReadableOutput()
function humanReadableOutput(options, __namedParameters): string
Defined in: graph/src/visualization/human-readable-output.ts:103
Returns a human-readable output of the graph.
Parameters
options
__namedParameters
colors?
boolean
Returns
string
install()
function install( options, add?,): Promise<{ diff: Diff graph: Graph}>
Defined in: graph/src/install.ts:13
Parameters
options
add?
Returns
Promise
<{ diff
: Diff
; graph
: Graph
; }>
isDependency()
function isDependency(o): o is Dependency
Defined in: graph/src/dependencies.ts:95
Parameters
o
unknown
Returns
o is Dependency
isDependencySaveType()
function isDependencySaveType(obj): obj is DependencyTypeShort
Defined in: graph/src/dependencies.ts:21
Parameters
obj
unknown
Returns
obj is DependencyTypeShort
isDependencyTypeShort()
function isDependencyTypeShort(obj): obj is DependencyTypeShort
Defined in: graph/src/dependencies.ts:16
Parameters
obj
unknown
Returns
obj is DependencyTypeShort
jsonOutput()
function jsonOutput(__namedParameters): JSONOutputItem[]
Defined in: graph/src/visualization/json-output.ts:39
Returns a JSON string representation of the graph.
Parameters
__namedParameters
Returns
mermaidOutput()
function mermaidOutput(__namedParameters): string
Defined in: graph/src/visualization/mermaid-output.ts:67
Returns a mermaid string representation of the graph.
Parameters
__namedParameters
Returns
string
reify()
function reify(options): Promise<Diff>
Defined in: graph/src/reify/index.ts:45
Make the current project match the supplied graph.
Parameters
options
Returns
Promise
<Diff
>
shorten()
function shorten(typeLong, name?, manifest?): DependencyTypeShort
Defined in: graph/src/dependencies.ts:112
Get the DependencyTypeShort from a DependencyTypeLong.
Parameters
typeLong
name?
string
manifest?
Returns
stringifyNode()
function stringifyNode(node?): string
Defined in: graph/src/stringify-node.ts:4
Parameters
node?
Returns
string
uninstall()
function uninstall( options, remove?,): Promise<{ diff: Diff graph: Graph}>
Defined in: graph/src/uninstall.ts:12
Parameters
options
remove?
RemoveImportersDependenciesMap