@vltpkg/graph 0.0.0-3 → 0.0.0-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +148 -12
- package/dist/esm/actual/load.d.ts +49 -3
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +124 -73
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +8 -4
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +6 -2
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/build.d.ts +29 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +79 -0
- package/dist/esm/build.js.map +1 -0
- package/dist/esm/dependencies.d.ts +14 -5
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +67 -2
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/diff.d.ts +67 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js +25 -0
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +8 -3
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +9 -1
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +22 -12
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +122 -23
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/add-nodes.d.ts +17 -2
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/add-nodes.js +15 -4
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +11 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +176 -31
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +9 -5
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +9 -0
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +4 -1
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +3 -2
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js +7 -5
- package/dist/esm/ideal/get-importer-specs.js.map +1 -1
- package/dist/esm/index.d.ts +8 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +11 -5
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +167 -23
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-edges.d.ts +8 -1
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +79 -15
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +3 -2
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +69 -12
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +18 -5
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +53 -22
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +12 -3
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +45 -16
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +33 -4
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js +31 -0
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/modifiers.d.ts +189 -0
- package/dist/esm/modifiers.d.ts.map +1 -0
- package/dist/esm/modifiers.js +330 -0
- package/dist/esm/modifiers.js.map +1 -0
- package/dist/esm/node.d.ts +73 -6
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +94 -2
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.d.ts +1 -1
- package/dist/esm/reify/add-edge.d.ts.map +1 -1
- package/dist/esm/reify/add-edge.js +36 -14
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +4 -27
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/bin-paths.d.ts +1 -1
- package/dist/esm/reify/bin-paths.d.ts.map +1 -1
- package/dist/esm/reify/bin-paths.js.map +1 -1
- package/dist/esm/reify/build.d.ts +10 -1
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +36 -7
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/calculate-save-value.d.ts +3 -0
- package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
- package/dist/esm/reify/calculate-save-value.js +45 -0
- package/dist/esm/reify/calculate-save-value.js.map +1 -0
- package/dist/esm/reify/check-needed-build.d.ts +25 -0
- package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
- package/dist/esm/reify/check-needed-build.js +50 -0
- package/dist/esm/reify/check-needed-build.js.map +1 -0
- package/dist/esm/reify/delete-edge.js +1 -1
- package/dist/esm/reify/delete-edge.js.map +1 -1
- package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
- package/dist/esm/reify/delete-nodes.js +4 -0
- package/dist/esm/reify/delete-nodes.js.map +1 -1
- package/dist/esm/reify/extract-node.d.ts +24 -0
- package/dist/esm/reify/extract-node.d.ts.map +1 -0
- package/dist/esm/reify/extract-node.js +76 -0
- package/dist/esm/reify/extract-node.js.map +1 -0
- package/dist/esm/reify/index.d.ts +18 -1
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +78 -13
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/internal-hoist.d.ts +9 -0
- package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
- package/dist/esm/reify/internal-hoist.js +121 -0
- package/dist/esm/reify/internal-hoist.js.map +1 -0
- package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js +35 -12
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/remove-optional-subgraph.js +1 -1
- package/dist/esm/remove-optional-subgraph.js.map +1 -1
- package/dist/esm/resolve-save-type.d.ts +6 -0
- package/dist/esm/resolve-save-type.d.ts.map +1 -0
- package/dist/esm/resolve-save-type.js +5 -0
- package/dist/esm/resolve-save-type.js.map +1 -0
- package/dist/esm/stringify-node.d.ts +1 -1
- package/dist/esm/stringify-node.d.ts.map +1 -1
- package/dist/esm/stringify-node.js.map +1 -1
- package/dist/esm/transfer-data/load.d.ts +44 -0
- package/dist/esm/transfer-data/load.d.ts.map +1 -0
- package/dist/esm/transfer-data/load.js +176 -0
- package/dist/esm/transfer-data/load.js.map +1 -0
- package/dist/esm/uninstall.d.ts +8 -6
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +51 -22
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts +13 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +63 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/virtual-root.d.ts +16 -0
- package/dist/esm/virtual-root.d.ts.map +1 -0
- package/dist/esm/virtual-root.js +79 -0
- package/dist/esm/virtual-root.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +4 -5
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +51 -24
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +7 -3
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +35 -12
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +7 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +64 -9
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/dist/esm/visualization/object-like-output.d.ts +1 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
- package/dist/esm/visualization/object-like-output.js.map +1 -1
- package/package.json +30 -25
- package/dist/esm/types.d.ts +0 -39
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../../src/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAyFvC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,aAAa;IACxB,yCAAyC;IACzC,OAAO,CAA4B;IACnC,kDAAkD;IAClD,UAAU,GAAG,IAAI,GAAG,EAAiB,CAAA;IACrC,uDAAuD;IACvD,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAA;IAC7C,uDAAuD;IACvD,cAAc,GAAG,IAAI,GAAG,EAAqB,CAAA;IAC7C;;;;OAIG;IACH,eAAe,GAAG,IAAI,GAAG,EAA8B,CAAA;IACvD;;;;;;;OAOG;IACH,cAAc,GAAG,IAAI,GAAG,EAGrB,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E,CAAC;gBAC1B,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAChC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAC/B,QAAQ,CAAC,YAAY,CACtB,CAAA;YACH,CAAC;YACD,kCAAkC;YAClC,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,OAAoB;QACnC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAA;QAC1D,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,OAAoB;QAC9B,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;CACF","sourcesContent":["import {\n parseBreadcrumb,\n specificitySort,\n} from '@vltpkg/dss-breadcrumb'\nimport { error } from '@vltpkg/error-cause'\nimport { Spec } from '@vltpkg/spec'\nimport {\n asNormalizedManifest,\n assertRecordStringString,\n normalizeManifest,\n} from '@vltpkg/types'\nimport { load } from '@vltpkg/vlt-json'\nimport type {\n ModifierBreadcrumb,\n ModifierInteractiveBreadcrumb,\n} from '@vltpkg/dss-breadcrumb'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Edge } from './edge.ts'\nimport type { Node } from './node.ts'\nimport type { Dependency } from './dependencies.ts'\n\n/**\n * Loaded modifiers configuration as described in the `vlt.json` file.\n */\nexport type GraphModifierLoadedConfig = {\n modifiers: GraphModifierConfigObject\n}\n\n/**\n * Type definition for the modifiers configuration object\n */\n// TODO: subtype string into a more specific type for Queries\nexport type GraphModifierConfigObject = Record<string, string>\n\n/**\n * Info needed to define a graph modifier.\n */\nexport type BaseModifierEntry = {\n type: 'edge' | 'node'\n query: string\n breadcrumb: ModifierBreadcrumb\n value: string | NormalizedManifest\n refs: Set<{\n name: string\n from: Node\n }>\n}\n\n/**\n * Extra info to define specifically a graph edge modifier.\n */\nexport type EdgeModifierEntry = BaseModifierEntry & {\n type: 'edge'\n spec: Spec\n value: string\n}\n\n/**\n * Extra info to define the graph node modifier.\n */\nexport type NodeModifierEntry = BaseModifierEntry & {\n type: 'node'\n manifest: NormalizedManifest\n}\n\n/**\n * A graph modifier entry, which can be either an edge or a node modifier.\n */\nexport type ModifierEntry = EdgeModifierEntry | NodeModifierEntry\n\n/**\n * An object to track modifiers that have matched an initial part of the\n * breadcrumb. It holds pointers to both nodes and edges matched in the\n * current traversed graph on top of the modifier info and the breadcrumb\n * state that is used to track the current state of the parsing.\n */\nexport type ModifierActiveEntry = {\n /**\n * The modifier this active entry is working with.\n */\n modifier: ModifierEntry\n /**\n * The breadcrumb that is used to track the current state of the parsing.\n */\n interactiveBreadcrumb: ModifierInteractiveBreadcrumb\n /**\n * The first node to be affected by this modifier.\n */\n originalFrom: Node\n /**\n * The original edge that is being replaced with this entry.\n */\n originalEdge?: Edge\n /**\n * The modified edge that is being used to replace the original edge.\n */\n modifiedEdge?: Edge\n}\n\n/**\n * Class representing loaded modifiers configuration for a project.\n *\n * Instances of this class can be used as a helper to modify the graph\n * during the graph build ideal traversal time.\n *\n * ```\n * const modifier = new GraphModifier(options)\n * modifier.load(options)\n * ```\n *\n * The `tryImporter` method can be used to register the initial importer\n * node along with any modifier that includes an importer selector, e.g:\n * `modifier.tryImporter(graph.mainImporter)`\n *\n * When traversing the graph, use the `tryNewDependency` method to check\n * if a given dependency spec to the current traversed node has matching\n * registered modifiers, e.g:\n * `const entries = modifier.tryNewDependency(fromNode, depSpec)`\n *\n * Use `updateActiveEntry` to update a given active modifier entry state\n * with the current node of the graph being traversed. e.g:\n * ```\n * for (const entry of entries)\n * modifier.updateActiveEntry(fromNode, entry)\n * ```\n */\nexport class GraphModifier {\n /** The loaded modifiers configuration */\n #config?: GraphModifierConfigObject\n /** A set of all modifiers loaded from vlt.json */\n #modifiers = new Set<ModifierEntry>()\n /** A set of all edge modifiers loaded from vlt.json */\n #edgeModifiers = new Set<EdgeModifierEntry>()\n /** A set of all node modifiers loaded from vlt.json */\n #nodeModifiers = new Set<NodeModifierEntry>()\n /**\n * A map of initial entries, keyed by the name of the first breadcrumb\n * item to its modifier entry. Useful for checking for non-importer\n * starting breadcrumbs, e.g: `#a > #b`\n */\n #initialEntries = new Map<string, Set<ModifierEntry>>()\n /**\n * A multi-level map of active entries, keyed by:\n * - modifiers\n * - edge name\n * - from node\n * that allows for retrieving seen {@link ModifierActiveEntry} instances\n * in constant time.\n */\n #activeEntries = new Map<\n ModifierEntry,\n Map<string, Map<Node, ModifierActiveEntry>>\n >()\n /**\n * A set of currently active modifiers, which are being parsed.\n */\n activeModifiers = new Set<ModifierActiveEntry>()\n /** A set of all modifier string values loaded from vlt.json */\n modifierNames = new Set<string>()\n\n constructor(options: SpecOptions) {\n this.load(options)\n }\n\n /**\n * Load the modifiers definitions from vlt.json,\n * converting the result into a GraphModifierConfigObject\n */\n get config(): GraphModifierConfigObject {\n if (this.#config) return this.#config\n return (this.#config =\n load('modifiers', assertRecordStringString) ?? {})\n }\n\n /**\n * Loads the modifiers defined in `vlt.json` into memory.\n */\n load(options: SpecOptions) {\n for (const [key, value] of Object.entries(this.config)) {\n this.modifierNames.add(key)\n const breadcrumb = parseBreadcrumb(key)\n /* c8 ignore start - should not be possible */\n if (!breadcrumb.last.name) {\n throw error('Could not find name in breadcrumb', {\n found: key,\n })\n }\n /* c8 ignore stop */\n let mod: ModifierEntry\n if (typeof value === 'string') {\n mod = {\n breadcrumb,\n query: key,\n refs: new Set(),\n spec: Spec.parse(breadcrumb.last.name, value, options),\n type: 'edge',\n value,\n } satisfies EdgeModifierEntry\n this.#edgeModifiers.add(mod)\n /* c8 ignore start - TODO */\n } else {\n const manifest = asNormalizedManifest(\n normalizeManifest(value),\n )\n mod = {\n breadcrumb,\n query: key,\n manifest,\n refs: new Set(),\n type: 'node',\n value: manifest,\n } satisfies NodeModifierEntry\n this.#nodeModifiers.add(mod)\n }\n /* c8 ignore end */\n this.#modifiers.add(mod)\n // if the breadcrumb starts with an id, then add it to the\n // map of initial entries, so that we can use it to match\n if (breadcrumb.first.name) {\n const initialSet =\n this.#initialEntries.get(breadcrumb.first.name) ?? new Set()\n initialSet.add(mod)\n this.#initialEntries.set(breadcrumb.first.name, initialSet)\n }\n }\n }\n\n /**\n * Try matching the provided node against the top-level selectors. In case\n * a match is found it will also register the active entry modifier and\n * update the active entry to the current importer node.\n */\n tryImporter(importer: Node) {\n for (const modifier of this.#modifiers) {\n // if the first item in the breadcrumb is an importer and it matches\n // any of the valid top-level selectors, then register the modifier\n const { first } = modifier.breadcrumb\n const matchRoot =\n first.value === ':root' && importer.mainImporter\n const matchWorkspace =\n first.value === ':workspace' && importer.importer\n const matchAny =\n first.value === ':project' || matchRoot || matchWorkspace\n if (first.importer && matchAny) {\n const active = this.newModifier(importer, modifier)\n const single = active.modifier.breadcrumb.single\n // only the importers will update the active entry right after\n // registering it since tryImporter doesn't try to match from\n // active dependencies\n if (!single) {\n this.updateActiveEntry(importer, active)\n }\n }\n }\n }\n\n /**\n * Try matching the provided node and spec to the current\n * active parsing modifier entries along with possible starting-level\n * modifiers.\n *\n * Any entries in which the breachcrumb have already reached its last\n * element will be prioritized, along with checking for specificity,\n * the complete entry with the highest specificity will be returned or just\n * the entry with the highest specificity if no complete entry is found.\n * Returns `undefined` if no matching entry is found.\n *\n * This method works with the assumption that it's going to be called\n * during a graph traversal, such that any ascendent has been checked\n * and the active modifier entry state has been updated in the previous\n * iteration.\n */\n tryNewDependency(\n from: Node,\n spec: Spec,\n ): ModifierActiveEntry | undefined {\n const { name, semver } = spec\n // here we use a map instead of a set so that we can associate each\n // modifier active entry with its breadcrumb so that it's easier to\n // pick the correct entry when we sort breadcrbumbs by specificity\n const all = new Map<\n ModifierBreadcrumb | undefined,\n ModifierActiveEntry\n >()\n for (const modifier of this.#modifiers) {\n // if an active entry is found then returns that\n const entry = this.#activeEntries\n .get(modifier)\n ?.get(name)\n ?.get(from)\n if (entry) {\n all.set(entry.modifier.breadcrumb, entry)\n }\n }\n // matches the name against the initial entries, this will make it so\n // that modifier queries that start with a name (e.g: #a > #b) can\n // match at any point of the graph traversal\n const initialSet =\n this.#initialEntries.get(name) ?? new Set<ModifierEntry>()\n for (const initial of initialSet) {\n const initialEntry =\n /* c8 ignore next - difficult to test branch */\n this.#activeEntries.get(initial)?.get(name)?.get(from) ??\n this.newModifier(from, initial)\n all.set(initialEntry.modifier.breadcrumb, initialEntry)\n }\n // selects the active entry that should apply to this dependency,\n // any active entry that is done parsing has the priority, if we\n // find multiple entries then we use css specificity to pick a winner\n // if we have multiple matches but no active entry is complete, then\n // we pick the one with the highest specificity breadcrumb\n const arr = [...all.values()]\n const completeEntries = arr.filter(\n active =>\n active.interactiveBreadcrumb.current ===\n active.modifier.breadcrumb.last,\n )\n // deregister completed entries\n for (const entry of completeEntries) {\n this.deregisterModifier(entry.modifier)\n }\n // returns the highest specificity entry from either the complete entries\n // if any were found or from any of the entries if available, otherwise\n // it will return undefined as no entry is found in the `all` map\n const entries = completeEntries.length ? completeEntries : arr\n return all.get(\n specificitySort(\n entries\n // here we filter out any entries that do not match the\n // pseudo selector comparators used in the breadcrumb item\n .filter(i =>\n i.interactiveBreadcrumb.current?.comparator({\n semver,\n }),\n )\n .map(i => i.modifier.breadcrumb),\n )[0],\n )\n }\n\n /**\n * Returns the set of {@link ModifierActiveEntry} instances that matches\n * the provided {@link Dependency} specs for a given node.\n *\n * This method is mostly a helper to {@link GraphModifier.tryNewDependency}\n * that handles the registered modifiers traversal lookup.\n */\n tryDependencies(\n from: Node,\n dependencies: Dependency[] | Edge[],\n ): Map<string, ModifierActiveEntry> {\n const modifierRefs = new Map<string, ModifierActiveEntry>()\n for (const { spec } of dependencies) {\n const active = this.tryNewDependency(from, spec)\n if (active) {\n modifierRefs.set(spec.name, active)\n }\n }\n return modifierRefs\n }\n\n /**\n * Updates an active entry state keeping track of items in the multi-level\n * active entries map. If the current breadcrumb state shows there's no more\n * items left, then we deregister the modifier.\n */\n updateActiveEntry(from: Node, active: ModifierActiveEntry): void {\n const { modifier } = active\n const interactiveBreadcrumb = active.interactiveBreadcrumb.next()\n const name = interactiveBreadcrumb.current?.name\n\n // if there's no name, or we're done parsing then we\n // deregister the modifier instead of updating the entry\n if (interactiveBreadcrumb.done || !name) {\n this.deregisterModifier(modifier)\n return\n }\n\n // register the active modifier\n this.activeModifiers.add(active)\n active.modifier.refs.add({ from, name })\n\n // optionally read or create the nested maps\n const nameMap =\n this.#activeEntries.get(modifier) ??\n new Map<string, Map<Node, ModifierActiveEntry>>()\n this.#activeEntries.set(modifier, nameMap)\n const nodeMap =\n nameMap.get(name) ?? new Map<Node, ModifierActiveEntry>()\n nameMap.set(name, nodeMap)\n\n // sets the active entry in the map\n nodeMap.set(from, active)\n }\n\n /**\n * Creates a new active modifier.\n */\n newModifier(\n from: Node,\n modifier: ModifierEntry,\n ): ModifierActiveEntry {\n return {\n modifier,\n interactiveBreadcrumb: modifier.breadcrumb.interactive(),\n originalFrom: from,\n }\n }\n\n /**\n * Removes a previously registered modifier from the active entries.\n */\n deregisterModifier(modifier: ModifierEntry): void {\n for (const { from, name } of modifier.refs) {\n const nodeMap = this.#activeEntries.get(modifier)?.get(name)\n if (nodeMap) {\n // if an entry is found, we remove it from the active set\n const entry = nodeMap.get(from)\n if (entry) {\n this.activeModifiers.delete(entry)\n }\n // then we remove the entry from the map\n nodeMap.delete(from)\n // if the map is empty, we remove it from the active entries map\n if (!nodeMap.size) {\n this.#activeEntries.get(modifier)?.delete(name)\n }\n }\n }\n }\n\n /**\n * Operates in previously registered nodes and edges in order to put\n * back in place any of the original edges that were referenced to in\n * active (ongoing) breadcrumb parsing entries that were never completed.\n *\n * This method can be used to easily rollback any pending operations\n * once the graph traversal is done.\n */\n rollbackActiveEntries(): void {\n for (const modifier of this.activeModifiers) {\n // if the modifier has an original edge, we can put it back in place\n if (modifier.originalEdge) {\n modifier.originalFrom.edgesOut.set(\n modifier.originalEdge.spec.name,\n modifier.originalEdge,\n )\n }\n // then we deregister the modifier\n this.deregisterModifier(modifier.modifier)\n }\n }\n\n /**\n * Convenience method to instantiate and load in one call.\n * Returns undefined if the project does not have a vlt.json file,\n * otherwise returns the loaded Modifiers instance.\n */\n static maybeLoad(options: SpecOptions) {\n const config = load('modifiers', assertRecordStringString)\n if (!config) return\n return new GraphModifier(options)\n }\n\n /**\n * Convenience method to instantiate and load in one call.\n * Throws if called on a directory that does not have a vlt.json file.\n */\n static load(options: SpecOptions) {\n return new GraphModifier(options)\n }\n}\n"]}
|
package/dist/esm/node.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PathScurry } from 'path-scurry';
|
|
2
2
|
import type { DepID } from '@vltpkg/dep-id';
|
|
3
3
|
import type { Spec, SpecOptions } from '@vltpkg/spec';
|
|
4
|
-
import type { Integrity,
|
|
4
|
+
import type { Integrity, NormalizedManifest, DependencyTypeShort, GraphLike, NodeLike } from '@vltpkg/types';
|
|
5
5
|
import { Edge } from './edge.ts';
|
|
6
|
-
import type {
|
|
6
|
+
import type { Graph } from './graph.ts';
|
|
7
7
|
export type NodeOptions = SpecOptions & {
|
|
8
8
|
projectRoot: string;
|
|
9
9
|
graph: GraphLike;
|
|
@@ -34,6 +34,14 @@ export declare class Node implements NodeLike {
|
|
|
34
34
|
isDev(): this is Node & {
|
|
35
35
|
dev: true;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* True if there's a manifest-confused package name.
|
|
39
|
+
*/
|
|
40
|
+
confused: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* True if this node has been extracted to the file system.
|
|
43
|
+
*/
|
|
44
|
+
extracted: boolean;
|
|
37
45
|
/**
|
|
38
46
|
* List of edges coming into this node.
|
|
39
47
|
*/
|
|
@@ -43,6 +51,11 @@ export declare class Node implements NodeLike {
|
|
|
43
51
|
* that the connected node is a direct dependency of this node.
|
|
44
52
|
*/
|
|
45
53
|
edgesOut: Map<string, Edge>;
|
|
54
|
+
/**
|
|
55
|
+
* A `mainImporter` node may have workspace connected to it,
|
|
56
|
+
* equivalent to its `edgesOut` linked deps.
|
|
57
|
+
*/
|
|
58
|
+
workspaces: Map<string, Edge> | undefined;
|
|
46
59
|
/**
|
|
47
60
|
* A reference to the {@link DepID} this node represents in the graph.
|
|
48
61
|
*/
|
|
@@ -58,7 +71,7 @@ export declare class Node implements NodeLike {
|
|
|
58
71
|
/**
|
|
59
72
|
* A reference to the graph this node is a part of.
|
|
60
73
|
*/
|
|
61
|
-
graph:
|
|
74
|
+
graph: Graph;
|
|
62
75
|
/**
|
|
63
76
|
* The manifest integrity value.
|
|
64
77
|
*/
|
|
@@ -66,7 +79,7 @@ export declare class Node implements NodeLike {
|
|
|
66
79
|
/**
|
|
67
80
|
* The manifest this node represents in the graph.
|
|
68
81
|
*/
|
|
69
|
-
manifest?:
|
|
82
|
+
manifest?: NormalizedManifest;
|
|
70
83
|
/**
|
|
71
84
|
* Project where this node resides
|
|
72
85
|
*/
|
|
@@ -77,6 +90,12 @@ export declare class Node implements NodeLike {
|
|
|
77
90
|
* the same registry, if it's not the default.
|
|
78
91
|
*/
|
|
79
92
|
registry?: string;
|
|
93
|
+
/**
|
|
94
|
+
* If this node has been modified as part of applying a {@link GraphModifier}
|
|
95
|
+
* then this field will contain the modifier query that was applied.
|
|
96
|
+
* Otherwise, it will be `undefined`.
|
|
97
|
+
*/
|
|
98
|
+
modifier: string | undefined;
|
|
80
99
|
get name(): string;
|
|
81
100
|
/**
|
|
82
101
|
* The version of the package represented by this node, this is usually
|
|
@@ -89,6 +108,28 @@ export declare class Node implements NodeLike {
|
|
|
89
108
|
* An address {@link PackageInfoClient} may use to extract this package.
|
|
90
109
|
*/
|
|
91
110
|
resolved?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Platform requirements (engines, os, cpu) extracted from manifest.
|
|
113
|
+
* Stored separately for optional dependencies to enable platform checks
|
|
114
|
+
* when manifest is not loaded.
|
|
115
|
+
*/
|
|
116
|
+
platform?: {
|
|
117
|
+
engines?: Record<string, string>;
|
|
118
|
+
os?: string[] | string;
|
|
119
|
+
cpu?: string[] | string;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* True if this node has been built as part of the reify step.
|
|
123
|
+
*/
|
|
124
|
+
built: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Build state of this node - tracks whether it needs building, has been built, or failed.
|
|
127
|
+
* - 'none': No build state (default)
|
|
128
|
+
* - 'needed': Node needs to be built
|
|
129
|
+
* - 'built': Node has been successfully built
|
|
130
|
+
* - 'failed': Node build has failed
|
|
131
|
+
*/
|
|
132
|
+
buildState: 'none' | 'needed' | 'built' | 'failed';
|
|
92
133
|
/**
|
|
93
134
|
* The file system location for this node.
|
|
94
135
|
*/
|
|
@@ -107,13 +148,15 @@ export declare class Node implements NodeLike {
|
|
|
107
148
|
* directly inside the node's directory.
|
|
108
149
|
*/
|
|
109
150
|
nodeModules(scurry: PathScurry): string;
|
|
110
|
-
constructor(options: NodeOptions, id?: DepID, manifest?:
|
|
151
|
+
constructor(options: NodeOptions, id?: DepID, manifest?: NormalizedManifest, spec?: Spec, name?: string, version?: string);
|
|
111
152
|
/**
|
|
112
153
|
* return true if this node is located in the vlt store
|
|
113
154
|
* memoized the first time it's called, since the store location
|
|
114
155
|
* doesn't change within the context of a single operation.
|
|
115
156
|
*/
|
|
116
157
|
inVltStore(): boolean;
|
|
158
|
+
get options(): SpecOptions;
|
|
159
|
+
set options(_opts: SpecOptions);
|
|
117
160
|
equals(other: Node): boolean;
|
|
118
161
|
/**
|
|
119
162
|
* Sets the node as an importer along with its location.
|
|
@@ -130,19 +173,43 @@ export declare class Node implements NodeLike {
|
|
|
130
173
|
* Add an edge from this node connecting it to a direct dependency.
|
|
131
174
|
*/
|
|
132
175
|
addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node): Edge;
|
|
176
|
+
/**
|
|
177
|
+
* The raw manifest before any modifications.
|
|
178
|
+
* If not set, falls back to the current manifest.
|
|
179
|
+
*/
|
|
180
|
+
get rawManifest(): NormalizedManifest | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* Sets this node as having a manifest-confused manifest.
|
|
183
|
+
*/
|
|
184
|
+
setConfusedManifest(fixed: NormalizedManifest, confused?: NormalizedManifest): void;
|
|
185
|
+
/**
|
|
186
|
+
* Sets this node as having a manifest-confused manifest.
|
|
187
|
+
*/
|
|
188
|
+
maybeSetConfusedManifest(spec: Spec, confused?: NormalizedManifest): void;
|
|
133
189
|
toJSON(): {
|
|
190
|
+
rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
134
191
|
id: DepID;
|
|
135
192
|
name: string;
|
|
136
193
|
version: string | undefined;
|
|
137
194
|
location: string;
|
|
138
195
|
importer: boolean;
|
|
139
|
-
manifest: Manifest | undefined;
|
|
196
|
+
manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
140
197
|
projectRoot: string;
|
|
141
198
|
integrity: `sha512-${string}` | undefined;
|
|
142
199
|
resolved: string | undefined;
|
|
143
200
|
dev: boolean;
|
|
144
201
|
optional: boolean;
|
|
202
|
+
confused: boolean;
|
|
203
|
+
modifier: string | undefined;
|
|
204
|
+
platform: {
|
|
205
|
+
engines?: Record<string, string>;
|
|
206
|
+
os?: string[] | string;
|
|
207
|
+
cpu?: string[] | string;
|
|
208
|
+
} | undefined;
|
|
209
|
+
buildState: "none" | "needed" | "built" | "failed";
|
|
145
210
|
};
|
|
146
211
|
toString(): string;
|
|
147
212
|
}
|
|
213
|
+
export declare const isNode: (value: unknown) => value is Node;
|
|
214
|
+
export declare const asNode: (value: unknown) => Node;
|
|
148
215
|
//# sourceMappingURL=node.d.ts.map
|
package/dist/esm/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAO7C,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,qBAAa,IAAK,YAAW,QAAQ;;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAOD;;;;;;OAMG;IACH,IAAI,QAAQ,IAGW,OAAO,CAD7B;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAS7B;IAED,UAAU,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE;IAK/C;;;;;OAKG;IACH,IAAI,GAAG,IAGM,OAAO,CADnB;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,EASnB;IAED,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,GAAG,EAAE,IAAI,CAAA;KAAE;IAIrC;;OAEG;IACH,QAAQ,UAAQ;IAEhB;;O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
import { isPackageNameConfused, getId, hydrateTuple, splitDepID, } from '@vltpkg/dep-id';
|
|
2
2
|
import { typeError } from '@vltpkg/error-cause';
|
|
3
|
+
import { expandNormalizedManifestSymbols } from '@vltpkg/types';
|
|
3
4
|
import { Edge } from "./edge.js";
|
|
4
5
|
import { stringifyNode } from "./stringify-node.js";
|
|
5
6
|
export class Node {
|
|
@@ -8,6 +9,7 @@ export class Node {
|
|
|
8
9
|
}
|
|
9
10
|
#options;
|
|
10
11
|
#location;
|
|
12
|
+
#rawManifest;
|
|
11
13
|
#optional = false;
|
|
12
14
|
/**
|
|
13
15
|
* True if a node is only reachable via optional or peerOptional edges from
|
|
@@ -57,6 +59,14 @@ export class Node {
|
|
|
57
59
|
isDev() {
|
|
58
60
|
return this.#dev;
|
|
59
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* True if there's a manifest-confused package name.
|
|
64
|
+
*/
|
|
65
|
+
confused = false;
|
|
66
|
+
/**
|
|
67
|
+
* True if this node has been extracted to the file system.
|
|
68
|
+
*/
|
|
69
|
+
extracted = false;
|
|
60
70
|
/**
|
|
61
71
|
* List of edges coming into this node.
|
|
62
72
|
*/
|
|
@@ -66,6 +76,11 @@ export class Node {
|
|
|
66
76
|
* that the connected node is a direct dependency of this node.
|
|
67
77
|
*/
|
|
68
78
|
edgesOut = new Map();
|
|
79
|
+
/**
|
|
80
|
+
* A `mainImporter` node may have workspace connected to it,
|
|
81
|
+
* equivalent to its `edgesOut` linked deps.
|
|
82
|
+
*/
|
|
83
|
+
workspaces;
|
|
69
84
|
/**
|
|
70
85
|
* A reference to the {@link DepID} this node represents in the graph.
|
|
71
86
|
*/
|
|
@@ -100,6 +115,12 @@ export class Node {
|
|
|
100
115
|
* the same registry, if it's not the default.
|
|
101
116
|
*/
|
|
102
117
|
registry;
|
|
118
|
+
/**
|
|
119
|
+
* If this node has been modified as part of applying a {@link GraphModifier}
|
|
120
|
+
* then this field will contain the modifier query that was applied.
|
|
121
|
+
* Otherwise, it will be `undefined`.
|
|
122
|
+
*/
|
|
123
|
+
modifier;
|
|
103
124
|
/**
|
|
104
125
|
* The name of the package represented by this node, this is usually
|
|
105
126
|
* equivalent to `manifest.name` but in a few ways it may differ such as
|
|
@@ -124,6 +145,24 @@ export class Node {
|
|
|
124
145
|
* An address {@link PackageInfoClient} may use to extract this package.
|
|
125
146
|
*/
|
|
126
147
|
resolved;
|
|
148
|
+
/**
|
|
149
|
+
* Platform requirements (engines, os, cpu) extracted from manifest.
|
|
150
|
+
* Stored separately for optional dependencies to enable platform checks
|
|
151
|
+
* when manifest is not loaded.
|
|
152
|
+
*/
|
|
153
|
+
platform;
|
|
154
|
+
/**
|
|
155
|
+
* True if this node has been built as part of the reify step.
|
|
156
|
+
*/
|
|
157
|
+
built = false;
|
|
158
|
+
/**
|
|
159
|
+
* Build state of this node - tracks whether it needs building, has been built, or failed.
|
|
160
|
+
* - 'none': No build state (default)
|
|
161
|
+
* - 'needed': Node needs to be built
|
|
162
|
+
* - 'built': Node has been successfully built
|
|
163
|
+
* - 'failed': Node build has failed
|
|
164
|
+
*/
|
|
165
|
+
buildState = 'none';
|
|
127
166
|
/**
|
|
128
167
|
* The file system location for this node.
|
|
129
168
|
*/
|
|
@@ -201,6 +240,11 @@ export class Node {
|
|
|
201
240
|
this.manifest?.dist?.tarball || spec.conventionalRegistryTarball;
|
|
202
241
|
this.integrity ??= this.manifest?.dist?.integrity;
|
|
203
242
|
}
|
|
243
|
+
get options() {
|
|
244
|
+
return this.#options;
|
|
245
|
+
}
|
|
246
|
+
/* c8 ignore next */
|
|
247
|
+
set options(_opts) { }
|
|
204
248
|
equals(other) {
|
|
205
249
|
return this.id === other.id && this.location === other.location;
|
|
206
250
|
}
|
|
@@ -250,6 +294,33 @@ export class Node {
|
|
|
250
294
|
this.edgesOut.set(spec.name, edge);
|
|
251
295
|
return edge;
|
|
252
296
|
}
|
|
297
|
+
/**
|
|
298
|
+
* The raw manifest before any modifications.
|
|
299
|
+
* If not set, falls back to the current manifest.
|
|
300
|
+
*/
|
|
301
|
+
get rawManifest() {
|
|
302
|
+
return this.#rawManifest ?? this.manifest;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Sets this node as having a manifest-confused manifest.
|
|
306
|
+
*/
|
|
307
|
+
setConfusedManifest(fixed, confused) {
|
|
308
|
+
this.manifest = fixed;
|
|
309
|
+
this.#rawManifest = confused;
|
|
310
|
+
this.confused = true;
|
|
311
|
+
this.#name = this.manifest.name;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Sets this node as having a manifest-confused manifest.
|
|
315
|
+
*/
|
|
316
|
+
maybeSetConfusedManifest(spec, confused) {
|
|
317
|
+
if (isPackageNameConfused(spec, this.manifest?.name)) {
|
|
318
|
+
this.setConfusedManifest({
|
|
319
|
+
...this.manifest,
|
|
320
|
+
name: spec.name,
|
|
321
|
+
}, confused);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
253
324
|
toJSON() {
|
|
254
325
|
return {
|
|
255
326
|
id: this.id,
|
|
@@ -257,16 +328,37 @@ export class Node {
|
|
|
257
328
|
version: this.version,
|
|
258
329
|
location: this.location,
|
|
259
330
|
importer: this.importer,
|
|
260
|
-
manifest: this.manifest
|
|
331
|
+
manifest: this.manifest &&
|
|
332
|
+
expandNormalizedManifestSymbols(this.manifest),
|
|
261
333
|
projectRoot: this.projectRoot,
|
|
262
334
|
integrity: this.integrity,
|
|
263
335
|
resolved: this.resolved,
|
|
264
336
|
dev: this.dev,
|
|
265
337
|
optional: this.optional,
|
|
338
|
+
confused: this.confused,
|
|
339
|
+
modifier: this.modifier,
|
|
340
|
+
platform: this.platform,
|
|
341
|
+
buildState: this.buildState,
|
|
342
|
+
...(this.confused ?
|
|
343
|
+
{ rawManifest: this.#rawManifest }
|
|
344
|
+
: undefined),
|
|
266
345
|
};
|
|
267
346
|
}
|
|
268
347
|
toString() {
|
|
269
348
|
return stringifyNode(this);
|
|
270
349
|
}
|
|
271
350
|
}
|
|
351
|
+
export const isNode = (value) => {
|
|
352
|
+
return (typeof value === 'object' &&
|
|
353
|
+
value != null &&
|
|
354
|
+
'id' in value &&
|
|
355
|
+
'manifest' in value &&
|
|
356
|
+
value[Symbol.toStringTag] === '@vltpkg/graph.Node');
|
|
357
|
+
};
|
|
358
|
+
export const asNode = (value) => {
|
|
359
|
+
if (!isNode(value)) {
|
|
360
|
+
throw typeError('Expected a node', { found: value });
|
|
361
|
+
}
|
|
362
|
+
return value;
|
|
363
|
+
};
|
|
272
364
|
//# sourceMappingURL=node.js.map
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAElB,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,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,SAAS,GAAG,GAAG,CAAA;QACtB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAyB,EAAE,IAAU,EAAE,IAAW;QAC3D,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: Manifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,QAAQ;oBAAE,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAA;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU;Q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AAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * True if this node has been extracted to the file system.\n */\n extracted = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: Graph\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * True if this node has been built as part of the reify step.\n */\n built = false\n\n /**\n * Build state of this node - tracks whether it needs building, has been built, or failed.\n * - 'none': No build state (default)\n * - 'needed': Node needs to be built\n * - 'built': Node has been successfully built\n * - 'failed': Node build has failed\n */\n buildState: 'none' | 'needed' | 'built' | 'failed' = 'none'\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph as Graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n buildState: this.buildState,\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
@@ -7,5 +7,5 @@ import type { Edge } from '../edge.ts';
|
|
|
7
7
|
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
8
8
|
* until scripts are run, in the case of non-store deps like workspaces
|
|
9
9
|
*/
|
|
10
|
-
export declare const addEdge: (edge: Edge, manifest: Manifest, scurry: PathScurry, remover: RollbackRemove) => Promise<void>;
|
|
10
|
+
export declare const addEdge: (edge: Edge, manifest: Pick<Manifest, "bin">, scurry: PathScurry, remover: RollbackRemove) => Promise<void>;
|
|
11
11
|
//# sourceMappingURL=add-edge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAqCtC;;;;GAIG;AACH,eAAO,MAAM,OAAO,SACZ,IAAI,YACA,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,UACvB,UAAU,WACT,cAAc,kBAoCxB,CAAA"}
|
|
@@ -1,22 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { cmdShimIfExists } from '@vltpkg/cmd-shim';
|
|
2
|
+
import { mkdir, symlink } from 'node:fs/promises';
|
|
3
|
+
import { dirname, relative } from 'node:path';
|
|
3
4
|
import { binPaths } from "./bin-paths.js";
|
|
4
5
|
const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
5
6
|
await mkdir(dirname(link), { recursive: true });
|
|
6
7
|
try {
|
|
7
8
|
await symlink(target, link, type);
|
|
8
9
|
}
|
|
9
|
-
catch (
|
|
10
|
-
|
|
11
|
-
if (er.code
|
|
12
|
-
|
|
10
|
+
catch (er) {
|
|
11
|
+
/* c8 ignore start */
|
|
12
|
+
if (er.code !== 'EEXIST') {
|
|
13
|
+
throw er;
|
|
14
|
+
}
|
|
15
|
+
/* c8 ignore stop */
|
|
16
|
+
// if the symlink exists, remove it
|
|
17
|
+
await remover.rm(link);
|
|
18
|
+
try {
|
|
19
|
+
// then try to create it again
|
|
20
|
+
await symlink(target, link, type);
|
|
13
21
|
/* c8 ignore start */
|
|
14
22
|
}
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
catch (er) {
|
|
24
|
+
// if the symlink still exists, then multiple paths could be writing to it
|
|
25
|
+
// so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797
|
|
26
|
+
if (er.code !== 'EEXIST') {
|
|
27
|
+
throw er;
|
|
28
|
+
}
|
|
17
29
|
}
|
|
30
|
+
/* c8 ignore stop */
|
|
18
31
|
}
|
|
19
|
-
/* c8 ignore stop */
|
|
20
32
|
};
|
|
21
33
|
/**
|
|
22
34
|
* reify an edge into a node_modules folder, with bins linked
|
|
@@ -30,14 +42,24 @@ export const addEdge = async (edge, manifest, scurry, remover) => {
|
|
|
30
42
|
const path = scurry.resolve(edge.from.nodeModules(scurry), edge.spec.name);
|
|
31
43
|
const promises = [];
|
|
32
44
|
const target = relative(dirname(path), edge.to.resolvedLocation(scurry));
|
|
33
|
-
|
|
45
|
+
// can only parallelize this on posix, because the win32 shims
|
|
46
|
+
// need to know that they will exist before being created.
|
|
47
|
+
const p = clobberSymlink(target, path, remover, 'dir');
|
|
48
|
+
if (process.platform === 'win32')
|
|
49
|
+
await p;
|
|
50
|
+
else
|
|
51
|
+
promises.push(p);
|
|
34
52
|
const bp = binPaths(manifest);
|
|
35
53
|
for (const [key, val] of Object.entries(bp)) {
|
|
36
54
|
const link = scurry.resolve(binRoot, key);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
55
|
+
const absTarget = scurry.resolve(path, val);
|
|
56
|
+
const target = relative(binRoot, absTarget);
|
|
57
|
+
// TODO: bash/cmd/ps1 shims on Windows
|
|
58
|
+
promises.push(process.platform === 'win32' ?
|
|
59
|
+
cmdShimIfExists(absTarget, link, remover)
|
|
60
|
+
: clobberSymlink(target, link, remover));
|
|
40
61
|
}
|
|
41
|
-
|
|
62
|
+
if (promises.length)
|
|
63
|
+
await Promise.all(promises);
|
|
42
64
|
};
|
|
43
65
|
//# sourceMappingURL=add-edge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,IAAY,EACZ,OAAuB,EACvB,IAAI,GAAG,MAAM,EACb,EAAE;IACF,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,qBAAqB;QACrB,IAAK,EAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,EAAE,CAAA;QACV,CAAC;QACD,oBAAoB;QAEpB,mCAAmC;QACnC,MAAM,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;QAEtB,IAAI,CAAC;YACH,8BAA8B;YAC9B,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;YACjC,qBAAqB;QACvB,CAAC;QAAC,OAAO,EAAE,EAAE,C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EAAE,GAAG,CAAC,CAAA;QACzC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAC3C,sCAAsC;QACtC,QAAQ,CAAC,IAAI,CACX,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;YAC5B,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC;YAC3C,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CACxC,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAClD,CAAC,CAAA","sourcesContent":["import { cmdShimIfExists } from '@vltpkg/cmd-shim'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { Manifest } from '@vltpkg/types'\nimport { mkdir, symlink } from 'node:fs/promises'\nimport { dirname, relative } from 'node:path'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\nimport { binPaths } from './bin-paths.ts'\n\nconst clobberSymlink = async (\n target: string,\n link: string,\n remover: RollbackRemove,\n type = 'file',\n) => {\n await mkdir(dirname(link), { recursive: true })\n try {\n await symlink(target, link, type)\n } catch (er) {\n /* c8 ignore start */\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n /* c8 ignore stop */\n\n // if the symlink exists, remove it\n await remover.rm(link)\n\n try {\n // then try to create it again\n await symlink(target, link, type)\n /* c8 ignore start */\n } catch (er) {\n // if the symlink still exists, then multiple paths could be writing to it\n // so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n }\n /* c8 ignore stop */\n }\n}\n\n/**\n * reify an edge into a node_modules folder, with bins linked\n * this does NOT chmod the bins to 0o777, because they might not exist\n * until scripts are run, in the case of non-store deps like workspaces\n */\nexport const addEdge = async (\n edge: Edge,\n manifest: Pick<Manifest, 'bin'>,\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n if (!edge.to) return\n const binRoot = scurry.resolve(\n edge.from.nodeModules(scurry),\n '.bin',\n )\n const path = scurry.resolve(\n edge.from.nodeModules(scurry),\n edge.spec.name,\n )\n const promises: Promise<unknown>[] = []\n const target = relative(\n dirname(path),\n edge.to.resolvedLocation(scurry),\n )\n\n // can only parallelize this on posix, because the win32 shims\n // need to know that they will exist before being created.\n const p = clobberSymlink(target, path, remover, 'dir')\n if (process.platform === 'win32') await p\n else promises.push(p)\n\n const bp = binPaths(manifest)\n for (const [key, val] of Object.entries(bp)) {\n const link = scurry.resolve(binRoot, key)\n const absTarget = scurry.resolve(path, val)\n const target = relative(binRoot, absTarget)\n // TODO: bash/cmd/ps1 shims on Windows\n promises.push(\n process.platform === 'win32' ?\n cmdShimIfExists(absTarget, link, remover)\n : clobberSymlink(target, link, remover),\n )\n }\n if (promises.length) await Promise.all(promises)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,WACd,WAAW,eACP,iBAAiB,KAC7B,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAgB1B,CAAA"}
|