vlt / docs

  • PricingBenchmarks (opens in new window)Community (opens in new window)Feedback
  • Overview
    • Overview
    • browser
    • index
    • Reference
  • Classes
  • Diff
  • Edge
  • Graph
  • GraphModifier
  • Node
  • Interfaces
  • BuildOptions
  • Type Aliases
  • ActualLoadOptions
  • AddImportersDependenciesMap
  • BaseModifierEntry
  • BuildIdealOptions
  • BuildResult
  • Dependency
  • EdgeMap
  • EdgeModifierEntry
  • GraphModifierConfigObject
  • GraphModifierLoadedConfig
  • GraphOptions
  • HumanReadableOutputGraph
  • InstallOptions
  • JSONOutputGraph
  • JSONOutputItem
  • LockfileBuildState
  • LockfileData
  • LockfileEdgeKey
  • LockfileEdges
  • LockfileEdgeValue
  • LockfileLoadOptions
  • LockfileNode
  • LockfileNodeFlags
  • LockfilePlatform
  • ManifestInventory
  • MermaidOutputGraph
  • ModifierActiveEntry
  • ModifierEntry
  • NodeModifierEntry
  • NodeOptions
  • OptionsChange
  • RawDependency
  • ReifyOptions
  • RemoveImportersDependenciesMap
  • SaveOptions
  • SpecCache
  • TreeItem
  • TreeMap
  • UninstallOptions
  • UpdateOptions
  • Variables
  • actual
  • BuildStateBuilt
  • BuildStateFailed
  • BuildStateNeeded
  • BuildStateNone
  • ideal
  • lockfile
  • LOCKFILE_VERSION
  • LockfileNodeFlagDev
  • LockfileNodeFlagDevOptional
  • LockfileNodeFlagNone
  • LockfileNodeFlagOptional
  • VIRTUAL_ROOT_ID
  • Functions
  • addKey()
  • asDependency()
  • asDependencyTypeShort()
  • asNode()
  • build()
  • copyPackageMetadata()
  • createVirtualRoot()
  • fixupAddedNames()
  • generateShortId()
  • getBooleanFlagsFromNum()
  • getBuildStateFromNode()
  • getBuildStateFromNum()
  • getDependencies()
  • getFlagNumFromNode()
  • getRawDependencies()
  • humanReadableOutput()
  • install()
  • isDependency()
  • isDependencySaveType()
  • isDependencyTypeShort()
  • isNode()
  • jsonOutput()
  • mermaidOutput()
  • reify()
  • shorten()
  • shouldInstallDepType()
  • stringifyNode()
  • uninstall()
  • update()
  1. Client
  2. /
  3. API Reference
  4. /
  5. @vltpkg/graph
  6. /
  7. index

index

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()
TypeScript
new Diff(from, to): Diff

Defined in: graph/src/diff.ts:66

Parameters
ParameterType
fromGraph
toGraph
Returns

Diff

Properties

PropertyTypeDefault valueDescription
edgesobjectundefinedCollection of nodes to add and delete
edges.addSet<Edge>undefinedEdges in the to graph that are not found in the from graph
edges.deleteSet<Edge>undefinedEdges in the from graph that are not found in the to graph
fromGraphundefined-
hadOptionalFailuresbooleanfalseIf 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.
nodesobjectundefinedCollection of nodes to add and delete
nodes.addSet<Node>undefinedNodes in the to graph that are not in the from graph
nodes.deleteSet<Node>undefinedNodes in the from graph that are not in the to graph
optionalOnlybooleantrueTrue if every added node/edge is confined to an optional subtree
projectRootstringundefined-
toGraphundefined-

Accessors

[toStringTag]
Get Signature
TypeScript
get toStringTag: string

Defined in: graph/src/diff.ts:62

Returns

string

Methods

[kCustomInspect]()
TypeScript
kCustomInspect: string

Defined in: graph/src/diff.ts:117

Parameters
ParameterType
_number
options?InspectOptions
Returns

string

hasChanges()
TypeScript
hasChanges(): boolean

Defined in: graph/src/diff.ts:157

Returns

boolean

toJSON()
TypeScript
toJSON(): object

Defined in: graph/src/diff.ts:166

Returns

object

NameType
edgesobject
edges.addobject[]
edges.deleteobject[]
nodesobject
nodes.addobject[]
nodes.deleteobject[]

Edge

Defined in: graph/src/edge.ts:10

Implements

  • EdgeLike

Constructors

new Edge()
TypeScript
new Edge(
   type, 
   spec, 
   from, 
   to?): Edge

Defined in: graph/src/edge.ts:48

Parameters
ParameterType
typeDependencyTypeShort
specSpec
fromNode
to?Node
Returns

Edge

Properties

PropertyTypeDescription
fromNodeThe Node this Edge is connecting from, this is usually the dependent.
specSpecThe defined spec value for to as parsed from the dependent metadata.
to?NodeThe node this Edge is connecting to, this is usually a direct dependency.
typeDependencyTypeShortWhat type of dependency relationship from and to nodes have.

Accessors

[toStringTag]
Get Signature
TypeScript
get toStringTag: string

Defined in: graph/src/edge.ts:11

Returns

string

dev
Get Signature
TypeScript
get dev(): boolean

Defined in: graph/src/edge.ts:70

This edge was defined as part of a devDependencies in package.json

Returns

boolean

name
Get Signature
TypeScript
get name(): string

Defined in: graph/src/edge.ts:63

The name of the dependency to as defined in the dependent metadata.

Returns

string

Implementation of
TypeScript
EdgeLike.name
optional
Get Signature
TypeScript
get optional(): boolean

Defined in: graph/src/edge.ts:74

Returns

boolean

Implementation of
TypeScript
EdgeLike.optional
peer
Get Signature
TypeScript
get peer(): boolean

Defined in: graph/src/edge.ts:78

Returns

boolean

Implementation of
TypeScript
EdgeLike.peer
peerOptional
Get Signature
TypeScript
get peerOptional(): boolean

Defined in: graph/src/edge.ts:82

Returns

boolean

Methods

[kCustomInspect]()
TypeScript
kCustomInspect: string

Defined in: graph/src/edge.ts:15

Parameters
ParameterType
_number
optionsInspectOptions
Returns

string

toJSON()
TypeScript
toJSON(): object

Defined in: graph/src/edge.ts:97

Returns

object

NameType
fromDepID
specstring
toundefined | DepID
typeDependencyTypeShort
toString()
TypeScript
toString(): string

Defined in: graph/src/edge.ts:106

Returns a string representation of an object.

Returns

string

valid()
TypeScript
valid(): boolean

Defined in: graph/src/edge.ts:86

Returns

boolean


Graph

Defined in: graph/src/graph.ts:89

Implements

  • GraphLike

Constructors

new Graph()
TypeScript
new Graph(options): Graph

Defined in: graph/src/graph.ts:207

Parameters
ParameterType
optionsGraphOptions
Returns

Graph

Properties

PropertyTypeDefault valueDescription
currentPeerContextIndexnumber0Tracks the current peer context index.
edgesSet<Edge>undefinedA set of all edges in this graph.
extraneousDependenciesSet<Edge>undefinedA set of extraneous dependencies found when building the graph.
importersSet<Node>undefinedA set of importer nodes in this graph.
lockedResolutions?Map<string, DepID>undefinedLockfile edge targets captured immediately before resetEdges(). Used by the ideal builder to reuse locked resolutions across a rebuild.
lockfileStalebooleanfalseWhether the lockfile on disk no longer matches this graph even though no node changed, e.g. an importer edge spec was rewritten to the value saved to package.json, or the config options the graph was built with differ from the ones stored in the lockfile. Reify saves the lockfiles from its no-diff early return when set.
mainImporterNodeundefinedThe Node that represents the project root package.json.
manifestsManifestInventoryundefinedAn inventory with all manifests related to an install.
monorepo?MonorepoundefinedA Monorepo instance, used for managing workspaces.
mutationsnumber0Count of structural writes: nodes placed or removed, edges reset, created or re-pointed. Never reset; callers snapshot it and compare, so the ideal builder can tell whether a rebuild touched anything the peer identities depend on.
nodesMap<DepID, Node>undefinedMap registered dep ids to the node that represent them in the graph.
nodesByNameMap<string, Set<Node>>undefinedMap of nodes by their name
optionsChangedbooleanfalseWhether the options used to create this graph differ from the options stored in the lockfile it was loaded from. When true, the ideal builder must reset edges and rebuild the graph.
optionsChangesOptionsChange[][]The individual differences behind optionsChanged, in the order they are reported to the user. Empty when nothing changed.
peerContextForkCacheMap<string, PeerContext>undefinedCache of forked peer contexts so identical fork operations can reuse previously created contexts instead of duplicating them. Key format is internal and constructed in ideal/peers.ts.
peerContextsPeerContext[]undefinedThe peer context sets used to resolve peer dependencies within this graph.
projectRootstringundefinedThe root of the project this graph represents
resolutionsMap<string, Node>undefinedCached resolutions for spec lookups
resolutionsReverseMap<Node, Set<string>>undefinedReverse map of resolutions

Accessors

[toStringTag]
Get Signature
TypeScript
get toStringTag: string

Defined in: graph/src/graph.ts:90

Returns

string

Methods

[kCustomInspect]()
TypeScript
kCustomInspect: string

Defined in: graph/src/graph.ts:742

Parameters
ParameterType
_number
optionsInspectOptions
Returns

string

addEdge()
TypeScript
addEdge(
   type, 
   spec, 
   from, 
   to?): Edge

Defined in: graph/src/graph.ts:379

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
ParameterType
typeDependencySaveType
specSpec
fromNodeLike
to?NodeLike
Returns

Edge

Implementation of
TypeScript
GraphLike.addEdge
addNode()
TypeScript
addNode(
   id?, 
   manifest?, 
   spec?, 
   name?, 
   version?): Node

Defined in: graph/src/graph.ts:475

Create a new node in the graph.

Parameters
ParameterType
id?DepID
manifest?Override<Manifest, NormalizedFields>
spec?Spec
name?string
version?string
Returns

Node

Implementation of
TypeScript
GraphLike.addNode
findResolution()
TypeScript
findResolution(
   spec, 
   fromNode, 
   extra): undefined | Node

Defined in: graph/src/graph.ts:436

Find an existing node to satisfy a dependency

Parameters
ParameterTypeDefault value
specSpecundefined
fromNodeNodeundefined
extrastring''
Returns

undefined | Node

gc()
TypeScript
gc(): Map<DepID, Node>

Defined in: graph/src/graph.ts:304

Delete all nodes and edges that are unreachable from the importers. The collection of deleted nodes is returned.

Marking is O(N+E) and always runs, but when nothing is unreachable and every reachable node is registered under its own id, nodes is left alone — no rebuild, no sort, and an empty map is returned. 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

Map<DepID, Node>

nextPeerContextIndex()
TypeScript
nextPeerContextIndex(): number

Defined in: graph/src/graph.ts:289

Get the next peer context index.

Returns

number

placePackage()
TypeScript
placePackage(
   fromNode, 
   depType, 
   spec, 
   manifest?, 
   id?, 
   extra?): undefined | Node

Defined in: graph/src/graph.ts:515

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
ParameterType
fromNodeNode
depTypeDependencySaveType
specSpec
manifest?Override<Manifest, NormalizedFields>
id?DepID
extra?string
Returns

undefined | Node

removeEdgeResolution()
TypeScript
removeEdgeResolution(edge, extra): void

Defined in: graph/src/graph.ts:690

Removes the resolved node of a given edge.

Parameters
ParameterTypeDefault value
edgeEdgeundefined
extrastring''
Returns

void

removeNode()
TypeScript
removeNode(
   node, 
   replacement?, 
   keepEdges?): void

Defined in: graph/src/graph.ts:651

Removes a node and its relevant edges from the graph.

Use the keepEdges option to keep the edges that were pointing to this node and only removes their to property value.

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
ParameterType
nodeNode
replacement?Node
keepEdges?boolean
Returns

void

Implementation of
TypeScript
GraphLike.removeNode
resetEdges()
TypeScript
resetEdges(): void

Defined in: graph/src/graph.ts:714

Remove all edges from the graph while preserving nodes and resolution caches. This allows the graph to be reconstructed efficiently using the existing nodes.

Returns

void

sortNodes()
TypeScript
sortNodes(): void

Defined in: graph/src/graph.ts:346

Rebuild nodes so importers come first, then remaining nodes in DepID order. Matches lockfile save so a built graph and a save→load round-trip iterate the same way.

A graph coming from the lockfile loader is already in that order, so the pass below detects it and keeps the map as-is.

Returns

void

toJSON()
TypeScript
toJSON(): LockfileData

Defined in: graph/src/graph.ts:734

Returns

LockfileData


GraphModifier

Defined in: graph/src/modifiers.ts:151

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.

Text
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 spec to the current traversed node has matching registered modifiers, e.g: const entries = modifier.tryNewDependency(fromNode, depSpec)

Use updateActiveEntry to update a given active modifier entry state with the current node of the graph being traversed. e.g:

Text
for (const entry of entries)
  modifier.updateActiveEntry(fromNode, entry)

Constructors

new GraphModifier()
TypeScript
new GraphModifier(options): GraphModifier

Defined in: graph/src/modifiers.ts:185

Parameters
ParameterType
optionsSpecOptions
Returns

GraphModifier

Properties

PropertyTypeDescription
activeModifiersSet<ModifierActiveEntry>A set of currently active modifiers, which are being parsed.
modifierNamesSet<string>A set of all modifier string values loaded from vlt.json

Accessors

config
Get Signature
TypeScript
get config(): GraphModifierConfigObject

Defined in: graph/src/modifiers.ts:193

Load the modifiers definitions from vlt.json, converting the result into a GraphModifierConfigObject

Returns

GraphModifierConfigObject

Methods

deregisterModifier()
TypeScript
deregisterModifier(modifier): void

Defined in: graph/src/modifiers.ts:453

Removes a previously registered modifier from the active entries.

Parameters
ParameterType
modifierModifierEntry
Returns

void

load()
TypeScript
load(options): void

Defined in: graph/src/modifiers.ts:227

Loads the modifiers defined in vlt.json into memory.

Parameters
ParameterType
optionsSpecOptions
Returns

void

newModifier()
TypeScript
newModifier(from, modifier): ModifierActiveEntry

Defined in: graph/src/modifiers.ts:439

Creates a new active modifier.

Parameters
ParameterType
fromNode
modifierModifierEntry
Returns

ModifierActiveEntry

rollbackActiveEntries()
TypeScript
rollbackActiveEntries(): void

Defined in: graph/src/modifiers.ts:480

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

targetsImporterEdge()
TypeScript
targetsImporterEdge(importer, spec): boolean

Defined in: graph/src/modifiers.ts:208

Whether a modifier governs the direct importer -> spec.name edge, i.e. whether its value comes from config rather than from the manifest that declares it. Only a breadcrumb whose whole scope is that edge counts, and only if its qualifier accepts the spec: :root > #a > #b names b but governs an edge under a, and #b:semver(^1) leaves a ^2 edge alone, so in both cases the root's own b edge is still the manifest's to validate and heal.

Parameters
ParameterType
importerNode
specSpec
Returns

boolean

tryDependencies()
TypeScript
tryDependencies(from, dependencies): Map<string, ModifierActiveEntry>

Defined in: graph/src/modifiers.ts:388

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
ParameterType
fromNode
dependencies| Edge[] | Dependency[]
Returns

Map<string, ModifierActiveEntry>

tryImporter()
TypeScript
tryImporter(importer): void

Defined in: graph/src/modifiers.ts:282

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
ParameterType
importerNode
Returns

void

tryNewDependency()
TypeScript
tryNewDependency(from, spec): 
  | undefined
  | ModifierActiveEntry

Defined in: graph/src/modifiers.ts:315

Try matching the provided node and spec 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
ParameterType
fromNode
specSpec
Returns

| undefined | ModifierActiveEntry

updateActiveEntry()
TypeScript
updateActiveEntry(from, active): void

Defined in: graph/src/modifiers.ts:407

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
ParameterType
fromNode
activeModifierActiveEntry
Returns

void

load()
TypeScript
static load(options): GraphModifier

Defined in: graph/src/modifiers.ts:509

Convenience method to instantiate and load in one call. Throws if called on a directory that does not have a vlt.json file.

Parameters
ParameterType
optionsSpecOptions
Returns

GraphModifier

maybeLoad()
TypeScript
static maybeLoad(options): undefined | GraphModifier

Defined in: graph/src/modifiers.ts:499

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
ParameterType
optionsSpecOptions
Returns

undefined | GraphModifier


Node

Defined in: graph/src/node.ts:30

Implements

  • NodeLike

Constructors

new Node()
TypeScript
new Node(
   options, 
   id?, 
   manifest?, 
   spec?, 
   name?, 
   version?): Node

Defined in: graph/src/node.ts:293

Parameters
ParameterType
optionsNodeOptions
id?DepID
manifest?Override<Manifest, NormalizedFields>
spec?Spec
name?string
version?string
Returns

Node

Properties

PropertyTypeDefault valueDescription
bindingGyp?booleanundefinedTrue if the package has a root binding.gyp, when known without a disk check (placed from the global store). Not persisted.
bins?Record<string, string>undefinedRecord of binary names to their paths in the package, if any.
buildState"none" | "needed" | "built" | "failed"'none'Build state of this node - tracks whether it needs building, has been built, or failed. - 'none': No build state (default) - 'needed': Node needs to be built - 'built': Node has been successfully built - 'failed': Node build has failed
builtbooleanfalseTrue if this node has been built as part of the reify step.
confusedbooleanfalseTrue if there's a manifest-confused package name.
detachedbooleanfalseTrue if this node is detached from the graph. This is used to indicate that the node is not part of the graph although the node is still available as part of the resolution process. Allows for skipping fetching manifests for detached nodes.
edgesInSet<Edge>undefinedList of edges coming into this node.
edgesOutMap<string, Edge>undefinedList of edges from this node into other nodes. This usually represents that the connected node is a direct dependency of this node.
extractedbooleanfalseTrue if this node has been extracted to the file system.
graphGraphundefinedA reference to the graph this node is a part of.
idDepIDundefinedA reference to the DepID this node represents in the graph.
importerbooleanfalseTrue if this node is an importer node.
integrity?`sha512-${string}`undefinedThe manifest integrity value.
mainImporterbooleanfalseTrue if this node is the project root node.
manifest?Override<Manifest, NormalizedFields>undefinedThe manifest this node represents in the graph.
modifierundefined | stringundefinedIf 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.
peerSetHash?stringundefinedDeterministic unique string used to identify (and ultimately duplicate) nodes that are affected by a peer context set modified resolution. These are appended to the node DepID as the extra suffix.
platform?objectundefinedPlatform requirements (engines, os, cpu) extracted from manifest. Stored separately for optional dependencies to enable platform checks when manifest is not loaded.
platform.cpu?string | string[]undefined-
platform.engines?Record<string, string>undefined-
platform.libc?string | string[]undefined-
platform.os?string | string[]undefined-
projectRootstringundefinedProject where this node resides
registry?stringundefinedFor 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?stringundefinedAn address PackageInfoClient may use to extract this package.
resolvedFromLockfilebooleanfalseTrue when integrity and resolved came from a lockfile, i.e. they were verified by the install that wrote them.
version?stringundefinedThe 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.
workspacesundefined | Map<string, Edge>undefinedA mainImporter node may have workspace connected to it, equivalent to its edgesOut linked deps.

Accessors

[toStringTag]
Get Signature
TypeScript
get toStringTag: string

Defined in: graph/src/node.ts:31

Returns

string

dev
Get Signature
TypeScript
get dev(): boolean

Defined in: graph/src/node.ts:72

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
TypeScript
set dev(dev): void

Defined in: graph/src/node.ts:75

Parameters
ParameterType
devboolean
Returns

void

Implementation of
TypeScript
NodeLike.dev
location
Get Signature
TypeScript
get location(): string

Defined in: graph/src/node.ts:253

The file system location for this node.

Returns

string

Set Signature
TypeScript
set location(location): void

Defined in: graph/src/node.ts:263

Parameters
ParameterType
locationstring
Returns

void

Implementation of
TypeScript
NodeLike.location
name
Get Signature
TypeScript
get name(): string

Defined in: graph/src/node.ts:179

Returns

string

Implementation of
TypeScript
NodeLike.name
optional
Get Signature
TypeScript
get optional(): boolean

Defined in: graph/src/node.ts:47

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
TypeScript
set optional(optional): void

Defined in: graph/src/node.ts:50

Parameters
ParameterType
optionalboolean
Returns

void

Implementation of
TypeScript
NodeLike.optional
options
Get Signature
TypeScript
get options(): SpecOptions

Defined in: graph/src/node.ts:346

Returns

SpecOptions

Set Signature
TypeScript
set options(_opts): void

Defined in: graph/src/node.ts:351

Parameters
ParameterType
_optsSpecOptions
Returns

void

Implementation of
TypeScript
NodeLike.options
rawManifest
Get Signature
TypeScript
get rawManifest(): 
  | undefined
| Override<Manifest, NormalizedFields>

Defined in: graph/src/node.ts:450

The raw manifest before any modifications. If not set, falls back to the current manifest.

Returns

| undefined | Override<Manifest, NormalizedFields>

Implementation of
TypeScript
NodeLike.rawManifest

Methods

addEdgesTo()
TypeScript
addEdgesTo(
   type, 
   spec, 
   node?): Edge

Defined in: graph/src/node.ts:439

Add an edge from this node connecting it to a direct dependency.

Parameters
ParameterType
typeDependencyTypeShort
specSpec
node?Node
Returns

Edge

equals()
TypeScript
equals(other): boolean

Defined in: graph/src/node.ts:353

Parameters
ParameterType
otherNode
Returns

boolean

inVltStore()
TypeScript
inVltStore(): boolean

Defined in: graph/src/node.ts:328

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()
TypeScript
isDev(): this is Node & { dev: true }

Defined in: graph/src/node.ts:86

Returns

this is Node & { dev: true }

isOptional()
TypeScript
isOptional(): this is Node & { optional: true }

Defined in: graph/src/node.ts:61

Returns

this is Node & { optional: true }

maybeSetConfusedManifest()
TypeScript
maybeSetConfusedManifest(spec, confused?): void

Defined in: graph/src/node.ts:470

Sets this node as having a manifest-confused manifest.

Parameters
ParameterType
specSpec
confused?Override<Manifest, NormalizedFields>
Returns

void

Implementation of
TypeScript
NodeLike.maybeSetConfusedManifest
nodeModules()
TypeScript
nodeModules(scurry): string

Defined in: graph/src/node.ts:286

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
ParameterType
scurryPathScurry
Returns

string

resolvedLocation()
TypeScript
resolvedLocation(scurry): string

Defined in: graph/src/node.ts:274

The resolved location of the node in the file system.

Parameters
ParameterType
scurryPathScurry
Returns

string

setConfusedManifest()
TypeScript
setConfusedManifest(fixed, confused?): void

Defined in: graph/src/node.ts:457

Sets this node as having a manifest-confused manifest.

Parameters
ParameterType
fixedOverride
confused?Override<Manifest, NormalizedFields>
Returns

void

Implementation of
TypeScript
NodeLike.setConfusedManifest
setDefaultLocation()
TypeScript
setDefaultLocation(): void

Defined in: graph/src/node.ts:422

Returns

void

setImporterLocation()
TypeScript
setImporterLocation(location): void

Defined in: graph/src/node.ts:360

Sets the node as an importer along with its location.

Parameters
ParameterType
locationstring
Returns

void

setPeerIdentity()
TypeScript
setPeerIdentity(id, peerSetHash): void

Defined in: graph/src/node.ts:395

Update this node's DepID and peer suffix after canonicalization. Resets name/location memos that were derived from the previous id.

Parameters
ParameterType
idDepID
peerSetHashstring
Returns

void

setResolved()
TypeScript
setResolved(): void

Defined in: graph/src/node.ts:370

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
TypeScript
NodeLike.setResolved
toJSON()
TypeScript
toJSON(): object

Defined in: graph/src/node.ts:485

Returns

object

NameType
buildState"none" | "needed" | "built" | "failed"
confusedboolean
devboolean
idDepID
importerboolean
integrityundefined | `sha512-${string}`
locationstring
manifest| undefined | Override<Manifest, NormalizedFields>
modifierundefined | string
namestring
optionalboolean
peerSetHash?string
platform| undefined | { cpu: string | string[]; engines: Record<string, string>; libc: string | string[]; os: string | string[]; }
projectRootstring
rawManifest?Override<Manifest, NormalizedFields>
resolvedundefined | string
versionundefined | string
Implementation of
TypeScript
NodeLike.toJSON
toString()
TypeScript
toString(): string

Defined in: graph/src/node.ts:513

Returns

string

Implementation of
TypeScript
NodeLike.toString

Interfaces

BuildOptions

Defined in: graph/src/build.ts:17

Options for the build process

Extends

  • ActualLoadOptions

Properties

PropertyTypeDescriptionOverridesInherited from
catalog?Record<string, string>--LoadOptions.catalog
catalogs?Record<string, Record<string, string>>--LoadOptions.catalogs
default-registry-alias?stringThe name of the registry alias (a key in registries) that bare specs (e.g. foo@latest) and transitive deps without an explicit registry protocol resolve through, when no registry or scoped-registries entry applies. Defaults to 'npm'. The npm alias itself has no built-in URL -- it must be configured (e.g. via vlt setup), otherwise bare specs resolve with spec.registry === undefined.-LoadOptions.default-registry-alias
expectLockfile?booleanIf set to true, fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.-LoadOptions.expectLockfile
frozenLockfile?booleanIf set to true, fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications and is stricter than expectLockfile.-LoadOptions.frozenLockfile
git-host-archives?Record<string, string>tarball hosting services for hosts listed in git-hosts-LoadOptions.git-host-archives
git-hosts?Record<string, string>shorthand prefix names for known git hosts-LoadOptions.git-hosts
jsr-registries?Record<string, string>registries that work like https://npm.jsr.io-LoadOptions.jsr-registries
loadManifests?booleanIf 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.-LoadOptions.loadManifests
lockfileData?LockfileDataAlready-parsed main lockfile data. When set, ideal build skips re-reading vlt-lock.json.-LoadOptions.lockfileData
lockfileOnly?booleanIf set to true, only update the lockfile without performing any node_modules operations. Skips package extraction, filesystem operations, and hidden lockfile saves.-LoadOptions.lockfileOnly
mainManifest?Override<Manifest, NormalizedFields>The project root manifest.-LoadOptions.mainManifest
modifiers?GraphModifierThe graph modifiers helper object.-LoadOptions.modifiers
monorepo?MonorepoOptional monorepo configuration. If not provided, will attempt to load from project.LoadOptions.monorepo-
packageJsonPackageJsonA PackageJson object, for sharing manifest caches-LoadOptions.packageJson
projectRootstringThe project root dirname.-LoadOptions.projectRoot
registries?Record<string, string>shorthand prefix names for known registries-LoadOptions.registries
registry?stringThe registry where a spec should be resolved against. There is no default. If no registry is configured, registry-type specs parsed without one will have spec.registry === undefined, and anything that needs to build a registry URL will fail. Named registry aliases (gh:, jsr:) and scoped-registries are unaffected. For bare specs, this takes precedence over the default-registry-alias lookup but not over a matching scoped-registries entry.-LoadOptions.registry
scoped-registries?Record<`@${string}`, string>registries mapped to a @scope-LoadOptions.scoped-registries
scurryPathScurryA PathScurry object, for use in globs-LoadOptions.scurry
skipHiddenLockfile?booleanIf set to true, then do not shortcut the process by reading the hidden lockfile at node_modules/.vlt-lock.json-LoadOptions.skipHiddenLockfile
skipLoadingNodesOnModifiersChange?booleanLoad only importers into the graph if the modifiers have changed.-LoadOptions.skipLoadingNodesOnModifiersChange
specCache?SpecCacheShared intern cache for parsed lockfile specs.-LoadOptions.specCache
targetstringDSS query string to filter which nodes to build.--

Type Aliases

ActualLoadOptions

TypeScript
type ActualLoadOptions = SpecOptions & object;

Defined in: graph/src/actual/load.ts:35

Type declaration

NameTypeDescription
expectLockfile?booleanIf set to true, fail if lockfile is missing or out of date. Used by ci command to enforce lockfile integrity.
frozenLockfile?booleanIf set to true, fail if lockfile is missing or out of sync with package.json. Prevents any lockfile modifications and is stricter than expectLockfile.
loadManifests?booleanIf 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.
lockfileData?LockfileDataAlready-parsed main lockfile data. When set, ideal build skips re-reading vlt-lock.json.
lockfileOnly?booleanIf set to true, only update the lockfile without performing any node_modules operations. Skips package extraction, filesystem operations, and hidden lockfile saves.
mainManifest?NormalizedManifestThe project root manifest.
modifiers?GraphModifierThe graph modifiers helper object.
monorepo?MonorepoA Monorepo object, for managing workspaces
packageJsonPackageJsonA PackageJson object, for sharing manifest caches
projectRootstringThe project root dirname.
scurryPathScurryA PathScurry object, for use in globs
skipHiddenLockfile?booleanIf set to true, then do not shortcut the process by reading the hidden lockfile at node_modules/.vlt-lock.json
skipLoadingNodesOnModifiersChange?booleanLoad only importers into the graph if the modifiers have changed.
specCache?SpecCacheShared intern cache for parsed lockfile specs.

AddImportersDependenciesMap

TypeScript
type AddImportersDependenciesMap = Map<DepID, Map<string, Dependency>> & object;

Defined in: graph/src/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

NameType
modifiedDependenciesboolean

BaseModifierEntry

TypeScript
type BaseModifierEntry = object;

Defined in: graph/src/modifiers.ts:40

Info needed to define a graph modifier.

Type declaration

NameType
breadcrumbModifierBreadcrumb
querystring
refsSet<{ from: Node; name: string; }>
type"edge" | "node"
value| string | NormalizedManifest

BuildIdealOptions

TypeScript
type BuildIdealOptions = ActualLoadOptions & object;

Defined in: graph/src/ideal/build.ts:22

Type declaration

NameTypeDescription
actual?GraphAn actual graph
add?AddImportersDependenciesMapA 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.
packageInfoPackageInfoClientA PackageInfoClient instance to read manifest info from.
remove?RemoveImportersDependenciesMapA 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.
removerRollbackRemoveA RollbackRemove instance to handle extraction rollbacks

BuildResult

TypeScript
type BuildResult = object;

Defined in: graph/src/reify/build.ts:21

Returns an object mapping registries to the names of the packages built.

Type declaration

NameType
failureNode[]
successNode[]

Dependency

TypeScript
type Dependency = object;

Defined in: graph/src/dependencies.ts:54

Parsed dependency entries info.

Type declaration

NameTypeDescription
specSpecThe parsed Spec object describing the dependency requirements.
typeDependencySaveTypeThe DependencySaveType, describing the way this dependency should be saved back to the manifest.

EdgeMap

TypeScript
type EdgeMap = Map<NodeLike | undefined, TreeItem>;

Defined in: graph/src/visualization/human-readable-output.ts:40


EdgeModifierEntry

TypeScript
type EdgeModifierEntry = BaseModifierEntry & object;

Defined in: graph/src/modifiers.ts:54

Extra info to define specifically a graph edge modifier.

Type declaration

NameType
specSpec
type"edge"
valuestring

GraphModifierConfigObject

TypeScript
type GraphModifierConfigObject = Record<string, string>;

Defined in: graph/src/modifiers.ts:35

Type definition for the modifiers configuration object


GraphModifierLoadedConfig

TypeScript
type GraphModifierLoadedConfig = object;

Defined in: graph/src/modifiers.ts:27

Loaded modifiers configuration as described in the vlt.json file.

Type declaration

NameType
modifiersGraphModifierConfigObject

GraphOptions

TypeScript
type GraphOptions = SpecOptions & object;

Defined in: graph/src/graph.ts:70

Type declaration

NameTypeDescription
mainManifestNormalizedManifestThe main importer manifest info.
manifests?ManifestInventoryAn inventory of seen manifests.
monorepo?MonorepoA Monorepo object, for managing workspaces
projectRootstringRoot of the project this graph represents

HumanReadableOutputGraph

TypeScript
type HumanReadableOutputGraph = object;

Defined in: graph/src/visualization/human-readable-output.ts:33

Type declaration

NameType
edgesEdgeLike[]
highlightSelection?boolean
importersSet<NodeLike>
nodesNodeLike[]

InstallOptions

TypeScript
type InstallOptions = ActualLoadOptions & object;

Defined in: graph/src/install.ts:29

Type declaration

NameType
allowScriptsstring
cleanInstall?boolean
packageInfoPackageInfoClient
saveExact?boolean
savePrefix?string

JSONOutputGraph

TypeScript
type JSONOutputGraph = object;

Defined in: graph/src/visualization/json-output.ts:35

Type declaration

NameType
edgesEdgeLike[]
importersSet<NodeLike>
nodesNodeLike[]

JSONOutputItem

TypeScript
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

NameTypeDescription
fromID?DepIDA reference to the id of the Node that this package is linked from.
namestringThe name of the package.
overriddenbooleanWhether this edge was overridden by a graph modifier.
spec?stringThe dependency spec definition for this package.
to?NodeLikeA representation of the package object that fulfills this dependency.
type?EdgeLike["type"]The package type.

LockfileBuildState

TypeScript
type LockfileBuildState = undefined | 1 | 2 | 3;

Defined in: graph/src/lockfile/types.ts:103

Build state for a node - tracks whether it needs building, has been built, or failed


LockfileData

TypeScript
type LockfileData = object;

Defined in: graph/src/lockfile/types.ts:27

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

NameType
edgesLockfileEdges
lockfileVersionnumber
nodesRecord<DepID, LockfileNode>
optionsSpecOptions & object

LockfileEdgeKey

TypeScript
type LockfileEdgeKey = `${DepID} ${string}`;

Defined in: graph/src/lockfile/types.ts:165

${from} ${dep name}


LockfileEdges

TypeScript
type LockfileEdges = object;

Defined in: graph/src/lockfile/types.ts:160

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

TypeScript
[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

TypeScript
type LockfileEdgeValue = `${DependencyTypeShort} ${Spec["bareSpec"]} ${DepID | "MISSING"}`;

Defined in: graph/src/lockfile/types.ts:168

${type} ${spec} ${to}


LockfileLoadOptions

TypeScript
type LockfileLoadOptions = SpecOptions & object;

Defined in: graph/src/lockfile/load.ts:29

Type declaration

NameTypeDescription
actual?GraphAn optional Graph object to hydrate extra data from.
lockfileData?LockfileDataAlready-parsed lockfile data. When set, skips the filesystem read.
mainManifestNormalizedManifestThe project root manifest.
modifiers?GraphModifierThe graph modifiers helper object.
monorepo?MonorepoA Monorepo object, for managing workspaces
packageJson?PackageJsonA PackageJson object, for sharing manifest caches
projectRootstringThe project root dirname.
scurry?PathScurryA PathScurry object, for use in globs
specCache?SpecCacheShared intern cache for parsed lockfile specs.
throwOnMissingManifest?booleanWhether to throw an error if a manifest is missing when loading nodes.

LockfileNode

TypeScript
type LockfileNode = [LockfileNodeFlags, string | null, Integrity | null, string | null, string | null, NormalizedManifest | null, NormalizedManifest | null, LockfilePlatform | null, Record<string, string> | null, LockfileBuildState | null];

Defined in: graph/src/lockfile/types.ts:138

Lockfile representation of a node from the install graph.


LockfileNodeFlags

TypeScript
type LockfileNodeFlags = 0 | 1 | 2 | 3;

Defined in: graph/src/lockfile/types.ts:90

Bit flags indicating whether a node is optional and/or dev.


LockfilePlatform

TypeScript
type LockfilePlatform = object;

Defined in: graph/src/lockfile/types.ts:13

Platform requirements for a lockfile node

Type declaration

NameType
cpu?string[] | string
engines?Record<string, string>
libc?string[] | string
os?string[] | string

ManifestInventory

TypeScript
type ManifestInventory = Map<DepID, NormalizedManifest>;

Defined in: graph/src/graph.ts:37


MermaidOutputGraph

TypeScript
type MermaidOutputGraph = object;

Defined in: graph/src/visualization/mermaid-output.ts:6

Type declaration

NameType
edgesEdgeLike[]
highlightSelection?boolean
importersSet<NodeLike>
nodesNodeLike[]

ModifierActiveEntry

TypeScript
type ModifierActiveEntry = object;

Defined in: graph/src/modifiers.ts:79

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

NameTypeDescription
interactiveBreadcrumbModifierInteractiveBreadcrumbThe breadcrumb that is used to track the current state of the parsing.
modifiedEdge?EdgeThe modified edge that is being used to replace the original edge.
modifierModifierEntryThe modifier this active entry is working with.
originalEdge?EdgeThe original edge that is being replaced with this entry.
originalFromNodeThe first node to be affected by this modifier.

ModifierEntry

TypeScript
type ModifierEntry = 
  | EdgeModifierEntry
  | NodeModifierEntry;

Defined in: graph/src/modifiers.ts:71

A graph modifier entry, which can be either an edge or a node modifier.


NodeModifierEntry

TypeScript
type NodeModifierEntry = BaseModifierEntry & object;

Defined in: graph/src/modifiers.ts:63

Extra info to define the graph node modifier.

Type declaration

NameType
manifestNormalizedManifest
type"node"

NodeOptions

TypeScript
type NodeOptions = SpecOptions & object;

Defined in: graph/src/node.ts:25

Type declaration

NameType
graphGraphLike
projectRootstring

OptionsChange

TypeScript
type OptionsChange = object;

Defined in: graph/src/lockfile/types.ts:40

A single difference between the config a graph was built with and the options block stored in the lockfile it was loaded from.

Type declaration

NameTypeDescription
from?stringthe value stored in the lockfile, absent when the entry is new
key?stringthe entry inside that section, e.g. the catalog name. Absent for scalar sections; <catalog> <dep> for catalogs.
sectionstringthe options key the difference was found in, e.g. catalog
to?stringthe current value, absent when the entry is gone

RawDependency

TypeScript
type RawDependency = object;

Defined in: graph/src/dependencies.ts:44

Dependency entries info as defined in a package.json file.

Type declaration

NameType
bareSpecstring
namestring
registry?string
typeDependencyTypeLong

ReifyOptions

TypeScript
type ReifyOptions = ActualLoadOptions & object;

Defined in: graph/src/reify/index.ts:89

Type declaration

NameType
actual?Graph
add?AddImportersDependenciesMap
allowScriptsstring
graphGraph
modifiers?GraphModifier
packageInfoPackageInfoClient
remove?RemoveImportersDependenciesMap
removerRollbackRemove
saveExact?boolean
savePrefix?string
update?boolean

RemoveImportersDependenciesMap

TypeScript
type RemoveImportersDependenciesMap = Map<DepID, Set<string>> & object;

Defined in: graph/src/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

NameType
modifiedDependenciesboolean

SaveOptions

TypeScript
type SaveOptions = SpecOptions & object;

Defined in: graph/src/lockfile/save.ts:35

Type declaration

NameTypeDescription
graphGraphThe graph to be stored in the lockfile.
modifiers?GraphModifierThe graph modifiers helper object.
saveBuildData?booleanShould it save build state data in the lockfile?
saveManifests?booleanShould it save manifest data in the lockfile?
throwOnMissingManifest?booleanShould it throw an error if a manifest is missing?

SpecCache

TypeScript
type SpecCache = Map<string, Spec>;

Defined in: graph/src/lockfile/types.ts:59

Per-install intern cache for parsed lockfile specs. Shared across hidden + main lockfile loads so identical (name, bareSpec) pairs reuse one Spec instance.


TreeItem

TypeScript
type TreeItem = object;

Defined in: graph/src/visualization/human-readable-output.ts:21

Type declaration

NameType
edgeEdgeLike | undefined
hasSiblingboolean
includeboolean
name?string | null
nodeNodeLike | undefined
paddingstring
parentTreeItem | undefined
prefixstring
seenboolean

TreeMap

TypeScript
type TreeMap = Map<EdgeLike | undefined, EdgeMap>;

Defined in: graph/src/visualization/human-readable-output.ts:42


UninstallOptions

TypeScript
type UninstallOptions = ActualLoadOptions & object;

Defined in: graph/src/uninstall.ts:14

Type declaration

NameType
allowScriptsstring
packageInfoPackageInfoClient

UpdateOptions

TypeScript
type UpdateOptions = ActualLoadOptions & object;

Defined in: graph/src/update.ts:16

Type declaration

NameType
allowScriptsstring
packageInfoPackageInfoClient

Variables

actual

TypeScript
const actual: object;

Defined in: graph/src/index.ts:21

Type declaration

NameTypeDefault value
load(options) => GraphactualLoad

BuildStateBuilt

TypeScript
const BuildStateBuilt: 2 = 2;

Defined in: graph/src/lockfile/types.ts:97


BuildStateFailed

TypeScript
const BuildStateFailed: 3 = 3;

Defined in: graph/src/lockfile/types.ts:98


BuildStateNeeded

TypeScript
const BuildStateNeeded: 1 = 1;

Defined in: graph/src/lockfile/types.ts:96


BuildStateNone

TypeScript
const BuildStateNone: undefined = undefined;

Defined in: graph/src/lockfile/types.ts:95

Build state constants for lockfile nodes


ideal

TypeScript
const ideal: object;

Defined in: graph/src/index.ts:45

Type declaration

NameType
build(options) => Promise<Graph>

lockfile

TypeScript
const lockfile: object;

Defined in: graph/src/index.ts:31

Type declaration

NameTypeDefault value
load(options) => GraphlockfileLoad
loadData(projectRoot, lockfilePath) => LockfileDatalockfileLoadData
loadEdges(graph, edges, options, cache?) => void-
loadNodes(graph, nodes, options, actual?, throwOnMissingManifest?) => void-
save(options) => void-

LOCKFILE_VERSION

TypeScript
const LOCKFILE_VERSION: 1 = 1;

Defined in: graph/src/lockfile/types.ts:66

Current lockfile format version. Only lockfiles with matching version are considered valid. Bump when making breaking format changes.


LockfileNodeFlagDev

TypeScript
const LockfileNodeFlagDev: 2 = 2;

Defined in: graph/src/lockfile/types.ts:84


LockfileNodeFlagDevOptional

TypeScript
const LockfileNodeFlagDevOptional: 3 = 3;

Defined in: graph/src/lockfile/types.ts:85


LockfileNodeFlagNone

TypeScript
const LockfileNodeFlagNone: 0 = 0;

Defined in: graph/src/lockfile/types.ts:82


LockfileNodeFlagOptional

TypeScript
const LockfileNodeFlagOptional: 1 = 1;

Defined in: graph/src/lockfile/types.ts:83


VIRTUAL_ROOT_ID

TypeScript
const VIRTUAL_ROOT_ID: DepID;

Defined in: graph/src/virtual-root.ts:9

An unique DepID to identify the virtual root node.

Functions

addKey()

TypeScript
function addKey(spec): string

Defined in: graph/src/dependencies.ts:117

The key an added dependency is filed under. A nameless spec (github:u/r, file:../x, a tarball url) has no name to key by, so the CLI uses its stringified form; every reader of an add map has to derive the key the same way.

Parameters

ParameterType
specSpec

Returns

string


asDependency()

TypeScript
function asDependency(obj): Dependency

Defined in: graph/src/dependencies.ts:104

Parameters

ParameterType
objunknown

Returns

Dependency


asDependencyTypeShort()

TypeScript
function asDependencyTypeShort(obj): DependencyTypeShort

Defined in: graph/src/dependencies.ts:29

Parameters

ParameterType
objunknown

Returns

DependencyTypeShort


asNode()

TypeScript
function asNode(value): Node

Defined in: graph/src/node.ts:542

Parameters

ParameterType
valueunknown

Returns

Node


build()

TypeScript
function build(options): Promise<BuildResult>

Defined in: graph/src/build.ts:73

Build the project based on actual graph state and build state from lockfile

This function:

  1. Loads the actual graph from node_modules
  2. Loads build data from lockfile and transfers it to the actual graph
  3. Constructs a Diff object representing what needs to be built
  4. Filters nodes based on buildState === 'needed'
  5. Calls the reify build process with the constructed diff
  6. Persists build results to the hidden lockfile, when the vlt store exists

Parameters

ParameterType
optionsBuildOptions

Returns

Promise<BuildResult>


copyPackageMetadata()

TypeScript
function copyPackageMetadata(to, from): void

Defined in: graph/src/node.ts:524

Copy the tarball metadata to is missing from another node for the same package version. Lockfile provenance only carries over once both integrity and resolved are set, since that pair is what makes it usable without refetching.

Parameters

ParameterType
toNode
fromNode

Returns

void


createVirtualRoot()

TypeScript
function createVirtualRoot(
   name, 
   options, 
   mainImporters): undefined | NodeLike

Defined in: graph/src/virtual-root.ts:22

A virtual root used to aggregate multiple importers into a single graph.

This is meant to be used with visual tools that want a single root node starting point to represent the graph.

Returns undefined if a virtual root is not needed.

Parameters

ParameterTypeDefault value
namestring'virtual-root'
optionsSpecOptionsundefined
mainImportersNodeLike[]undefined

Returns

undefined | NodeLike


fixupAddedNames()

TypeScript
function fixupAddedNames(
   add, 
   manifest, 
   options, 
   spec): Spec

Defined in: graph/src/fixup-added-names.ts:21

When adding new dependencies, it's very common to not have a dependency name directly available to reference, e.g: file:local/folder or remote:tarball-url.tgz. In these cases, a placeholder (unknown) name is used in the Spec object and the add Map structure that holds references to added dependencies will use the stringified spec as a key.

This helper function fixes unknown names in the add map by replacing placeholder specs with the correct names from the provided manifest.

It also fixes empty bareSpec values (from CLI args like vlt install foo) by calculating the proper semver range from the resolved manifest version.

Parameters

ParameterType
add| undefined | Map<string, Dependency>
manifest| undefined | Pick<Manifest, "name" | "version">
optionsSpecOptions
specSpec

Returns

Spec


generateShortId()

TypeScript
function generateShortId(index): string

Defined in: graph/src/visualization/mermaid-output.ts:33

Generates a short identifier for a given index following the pattern: 0 -> a, 1 -> b, ..., 25 -> z, 26 -> A, ..., 51 -> Z, 52 -> aa, 53 -> ab, etc. This implements a bijective base-52 numbering system where a-z = 0-25, A-Z = 26-51

Parameters

ParameterType
indexnumber

Returns

string


getBooleanFlagsFromNum()

TypeScript
function getBooleanFlagsFromNum(flags): object

Defined in: graph/src/lockfile/types.ts:77

Parameters

ParameterType
flagsLockfileNodeFlags

Returns

object

NameType
devboolean
optionalboolean

getBuildStateFromNode()

TypeScript
function getBuildStateFromNode(node): LockfileBuildState

Defined in: graph/src/lockfile/types.ts:105

Parameters

ParameterType
node{ buildState: "none" | "needed" | "built" | "failed"; }
node.buildState?"none" | "needed" | "built" | "failed"

Returns

LockfileBuildState


getBuildStateFromNum()

TypeScript
function getBuildStateFromNum(state): "none" | "needed" | "built" | "failed"

Defined in: graph/src/lockfile/types.ts:120

Parameters

ParameterType
stateLockfileBuildState

Returns

"none" | "needed" | "built" | "failed"


getDependencies()

TypeScript
function getDependencies(node, options): Map<string, Dependency>

Defined in: graph/src/dependencies.ts:225

Retrieves a map of all dependencies, of all types, that can be inferred from a given node manifest, including missing dependencies.

Parameters

ParameterType
nodeNodeLike
optionsSpecOptions

Returns

Map<string, Dependency>


getFlagNumFromNode()

TypeScript
function getFlagNumFromNode(node): 0 | 1 | 2 | 3

Defined in: graph/src/lockfile/types.ts:68

Parameters

ParameterType
node{ dev: boolean; optional: boolean; }
node.dev?boolean
node.optional?boolean

Returns

0 | 1 | 2 | 3


getRawDependencies()

TypeScript
function getRawDependencies(node): Map<string, RawDependency>

Defined in: graph/src/dependencies.ts:170

Parameters

ParameterType
nodeNodeLike

Returns

Map<string, RawDependency>


humanReadableOutput()

TypeScript
function humanReadableOutput(options, __namedParameters): string

Defined in: graph/src/visualization/human-readable-output.ts:113

Returns a human-readable output of the graph.

Parameters

ParameterType
optionsHumanReadableOutputGraph
__namedParameters{ colors: boolean; }
__namedParameters.colors?boolean

Returns

string


install()

TypeScript
function install(options, add?): Promise<
  | {
  buildQueue: undefined;
  diff: undefined;
  graph: Graph;
 }
  | {
  buildQueue: undefined | DepID[];
  diff: Diff;
  graph: Graph;
}>

Defined in: graph/src/install.ts:37

Parameters

ParameterType
optionsInstallOptions
add?AddImportersDependenciesMap

Returns

Promise< | { buildQueue: undefined; diff: undefined; graph: Graph; } | { buildQueue: undefined | DepID[]; diff: Diff; graph: Graph; }>


isDependency()

TypeScript
function isDependency(o): o is Dependency

Defined in: graph/src/dependencies.ts:97

Parameters

ParameterType
ounknown

Returns

o is Dependency


isDependencySaveType()

TypeScript
function isDependencySaveType(obj): obj is DependencyTypeShort

Defined in: graph/src/dependencies.ts:23

Parameters

ParameterType
objunknown

Returns

obj is DependencyTypeShort


isDependencyTypeShort()

TypeScript
function isDependencyTypeShort(obj): obj is DependencyTypeShort

Defined in: graph/src/dependencies.ts:18

Parameters

ParameterType
objunknown

Returns

obj is DependencyTypeShort


isNode()

TypeScript
function isNode(value): value is Node

Defined in: graph/src/node.ts:532

Parameters

ParameterType
valueunknown

Returns

value is Node


jsonOutput()

TypeScript
function jsonOutput(__namedParameters): JSONOutputItem[]

Defined in: graph/src/visualization/json-output.ts:44

Returns a JSON string representation of the graph.

Parameters

ParameterType
__namedParametersJSONOutputGraph

Returns

JSONOutputItem[]


mermaidOutput()

TypeScript
function mermaidOutput(options): string

Defined in: graph/src/visualization/mermaid-output.ts:204

Returns a mermaid string representation of the graph.

Parameters

ParameterType
optionsMermaidOutputGraph

Returns

string


reify()

TypeScript
function reify(options): Promise<ReifyResult>

Defined in: graph/src/reify/index.ts:118

Make the current project match the supplied graph.

Parameters

ParameterType
optionsReifyOptions

Returns

Promise<ReifyResult>


shorten()

TypeScript
function shorten(
   typeLong, 
   name?, 
   manifest?): DependencyTypeShort

Defined in: graph/src/dependencies.ts:123

Get the DependencyTypeShort from a DependencyTypeLong.

Parameters

ParameterType
typeLongDependencyTypeLong
name?string
manifest?| null | Pick<Manifest, "peerDependenciesMeta">

Returns

DependencyTypeShort


shouldInstallDepType()

TypeScript
function shouldInstallDepType(node, depType): boolean

Defined in: graph/src/dependencies.ts:158

Only install devDeps for git dependencies and importers Everything else always gets installed

Deliberately stricter than getRawDependencies, which also keeps devDeps of file: nodes: this is the rule the ideal build places with, so peer checks use it to match what actually lands in the graph.

Parameters

ParameterType
nodeNodeLike
depTypeDependencyTypeLong

Returns

boolean


stringifyNode()

TypeScript
function stringifyNode(node?): string

Defined in: graph/src/stringify-node.ts:5

Parameters

ParameterType
node?NodeLike

Returns

string


uninstall()

TypeScript
function uninstall(options, remove?): Promise<
  | {
  diff: undefined;
  graph: Graph;
 }
  | {
  diff: ReifyResult;
  graph: Graph;
}>

Defined in: graph/src/uninstall.ts:19

Parameters

ParameterType
optionsUninstallOptions
remove?RemoveImportersDependenciesMap

Returns

Promise< | { diff: undefined; graph: Graph; } | { diff: ReifyResult; graph: Graph; }>


update()

TypeScript
function update(options): Promise<{
  buildQueue: undefined | DepID[];
  diff: Diff;
  graph: Graph;
}>

Defined in: graph/src/update.ts:21

Parameters

ParameterType
optionsUpdateOptions

Returns

Promise<{ buildQueue: undefined | DepID[]; diff: Diff; graph: Graph; }>


PreviousbrowserNextReference

On this page

  • Classes
  • Diff
  • Edge
  • Graph
  • GraphModifier
  • Node
  • Interfaces
  • BuildOptions
  • Type Aliases
  • ActualLoadOptions
  • AddImportersDependenciesMap
  • BaseModifierEntry
  • BuildIdealOptions
  • BuildResult
  • Dependency
  • EdgeMap
  • EdgeModifierEntry
  • GraphModifierConfigObject
  • GraphModifierLoadedConfig
  • GraphOptions
  • HumanReadableOutputGraph
  • InstallOptions
  • JSONOutputGraph
  • JSONOutputItem
  • LockfileBuildState
  • LockfileData
  • LockfileEdgeKey
  • LockfileEdges
  • LockfileEdgeValue
  • LockfileLoadOptions
  • LockfileNode
  • LockfileNodeFlags
  • LockfilePlatform
  • ManifestInventory
  • MermaidOutputGraph
  • ModifierActiveEntry
  • ModifierEntry
  • NodeModifierEntry
  • NodeOptions
  • OptionsChange
  • RawDependency
  • ReifyOptions
  • RemoveImportersDependenciesMap
  • SaveOptions
  • SpecCache
  • TreeItem
  • TreeMap
  • UninstallOptions
  • UpdateOptions
  • Variables
  • actual
  • BuildStateBuilt
  • BuildStateFailed
  • BuildStateNeeded
  • BuildStateNone
  • ideal
  • lockfile
  • LOCKFILE_VERSION
  • LockfileNodeFlagDev
  • LockfileNodeFlagDevOptional
  • LockfileNodeFlagNone
  • LockfileNodeFlagOptional
  • VIRTUAL_ROOT_ID
  • Functions
  • addKey()
  • asDependency()
  • asDependencyTypeShort()
  • asNode()
  • build()
  • copyPackageMetadata()
  • createVirtualRoot()
  • fixupAddedNames()
  • generateShortId()
  • getBooleanFlagsFromNum()
  • getBuildStateFromNode()
  • getBuildStateFromNum()
  • getDependencies()
  • getFlagNumFromNode()
  • getRawDependencies()
  • humanReadableOutput()
  • install()
  • isDependency()
  • isDependencySaveType()
  • isDependencyTypeShort()
  • isNode()
  • jsonOutput()
  • mermaidOutput()
  • reify()
  • shorten()
  • shouldInstallDepType()
  • stringifyNode()
  • uninstall()
  • update()

Deploy your package on vlt.io

Publish scoped and private packages, manage organizations and access, and give every developer and CI environment a consistent source for public and private JavaScript dependencies.

Publish now