@vltpkg/graph 0.0.0-3 → 0.0.0-30

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.
Files changed (157) hide show
  1. package/README.md +148 -12
  2. package/dist/esm/actual/load.d.ts +44 -3
  3. package/dist/esm/actual/load.d.ts.map +1 -1
  4. package/dist/esm/actual/load.js +123 -73
  5. package/dist/esm/actual/load.js.map +1 -1
  6. package/dist/esm/browser.d.ts +8 -4
  7. package/dist/esm/browser.d.ts.map +1 -1
  8. package/dist/esm/browser.js +6 -2
  9. package/dist/esm/browser.js.map +1 -1
  10. package/dist/esm/dependencies.d.ts +14 -5
  11. package/dist/esm/dependencies.d.ts.map +1 -1
  12. package/dist/esm/dependencies.js +67 -2
  13. package/dist/esm/dependencies.js.map +1 -1
  14. package/dist/esm/diff.d.ts +5 -0
  15. package/dist/esm/diff.d.ts.map +1 -1
  16. package/dist/esm/diff.js +13 -0
  17. package/dist/esm/diff.js.map +1 -1
  18. package/dist/esm/edge.d.ts +2 -3
  19. package/dist/esm/edge.d.ts.map +1 -1
  20. package/dist/esm/edge.js +1 -1
  21. package/dist/esm/edge.js.map +1 -1
  22. package/dist/esm/graph.d.ts +22 -12
  23. package/dist/esm/graph.d.ts.map +1 -1
  24. package/dist/esm/graph.js +122 -23
  25. package/dist/esm/graph.js.map +1 -1
  26. package/dist/esm/ideal/add-nodes.d.ts +6 -1
  27. package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
  28. package/dist/esm/ideal/add-nodes.js +9 -4
  29. package/dist/esm/ideal/add-nodes.js.map +1 -1
  30. package/dist/esm/ideal/append-nodes.d.ts +9 -1
  31. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  32. package/dist/esm/ideal/append-nodes.js +155 -31
  33. package/dist/esm/ideal/append-nodes.js.map +1 -1
  34. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
  35. package/dist/esm/ideal/build-ideal-from-starting-graph.js +9 -5
  36. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
  37. package/dist/esm/ideal/build.d.ts +4 -0
  38. package/dist/esm/ideal/build.d.ts.map +1 -1
  39. package/dist/esm/ideal/build.js +2 -0
  40. package/dist/esm/ideal/build.js.map +1 -1
  41. package/dist/esm/ideal/get-importer-specs.d.ts +3 -2
  42. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  43. package/dist/esm/ideal/get-importer-specs.js +7 -5
  44. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  45. package/dist/esm/index.d.ts +6 -4
  46. package/dist/esm/index.d.ts.map +1 -1
  47. package/dist/esm/index.js +3 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/install.d.ts +4 -5
  50. package/dist/esm/install.d.ts.map +1 -1
  51. package/dist/esm/install.js +143 -23
  52. package/dist/esm/install.js.map +1 -1
  53. package/dist/esm/lockfile/load-edges.d.ts +8 -1
  54. package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
  55. package/dist/esm/lockfile/load-edges.js +79 -15
  56. package/dist/esm/lockfile/load-edges.js.map +1 -1
  57. package/dist/esm/lockfile/load-nodes.d.ts +3 -2
  58. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  59. package/dist/esm/lockfile/load-nodes.js +64 -11
  60. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  61. package/dist/esm/lockfile/load.d.ts +18 -5
  62. package/dist/esm/lockfile/load.d.ts.map +1 -1
  63. package/dist/esm/lockfile/load.js +51 -22
  64. package/dist/esm/lockfile/load.js.map +1 -1
  65. package/dist/esm/lockfile/save.d.ts +8 -3
  66. package/dist/esm/lockfile/save.d.ts.map +1 -1
  67. package/dist/esm/lockfile/save.js +30 -12
  68. package/dist/esm/lockfile/save.js.map +1 -1
  69. package/dist/esm/lockfile/types.d.ts +17 -4
  70. package/dist/esm/lockfile/types.d.ts.map +1 -1
  71. package/dist/esm/lockfile/types.js.map +1 -1
  72. package/dist/esm/modifiers.d.ts +189 -0
  73. package/dist/esm/modifiers.d.ts.map +1 -0
  74. package/dist/esm/modifiers.js +330 -0
  75. package/dist/esm/modifiers.js.map +1 -0
  76. package/dist/esm/node.d.ts +54 -5
  77. package/dist/esm/node.d.ts.map +1 -1
  78. package/dist/esm/node.js +77 -2
  79. package/dist/esm/node.js.map +1 -1
  80. package/dist/esm/reify/add-edge.d.ts +1 -1
  81. package/dist/esm/reify/add-edge.d.ts.map +1 -1
  82. package/dist/esm/reify/add-edge.js +36 -14
  83. package/dist/esm/reify/add-edge.js.map +1 -1
  84. package/dist/esm/reify/add-nodes.d.ts.map +1 -1
  85. package/dist/esm/reify/add-nodes.js +4 -2
  86. package/dist/esm/reify/add-nodes.js.map +1 -1
  87. package/dist/esm/reify/bin-paths.d.ts +1 -1
  88. package/dist/esm/reify/bin-paths.d.ts.map +1 -1
  89. package/dist/esm/reify/bin-paths.js.map +1 -1
  90. package/dist/esm/reify/build.js +6 -3
  91. package/dist/esm/reify/build.js.map +1 -1
  92. package/dist/esm/reify/calculate-save-value.d.ts +3 -0
  93. package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
  94. package/dist/esm/reify/calculate-save-value.js +45 -0
  95. package/dist/esm/reify/calculate-save-value.js.map +1 -0
  96. package/dist/esm/reify/delete-edge.js +1 -1
  97. package/dist/esm/reify/delete-edge.js.map +1 -1
  98. package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
  99. package/dist/esm/reify/delete-nodes.js +4 -0
  100. package/dist/esm/reify/delete-nodes.js.map +1 -1
  101. package/dist/esm/reify/index.d.ts +2 -0
  102. package/dist/esm/reify/index.d.ts.map +1 -1
  103. package/dist/esm/reify/index.js +20 -2
  104. package/dist/esm/reify/index.js.map +1 -1
  105. package/dist/esm/reify/internal-hoist.d.ts +9 -0
  106. package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
  107. package/dist/esm/reify/internal-hoist.js +121 -0
  108. package/dist/esm/reify/internal-hoist.js.map +1 -0
  109. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  110. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  111. package/dist/esm/reify/update-importers-package-json.js +35 -12
  112. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  113. package/dist/esm/remove-optional-subgraph.js +1 -1
  114. package/dist/esm/remove-optional-subgraph.js.map +1 -1
  115. package/dist/esm/resolve-save-type.d.ts +6 -0
  116. package/dist/esm/resolve-save-type.d.ts.map +1 -0
  117. package/dist/esm/resolve-save-type.js +5 -0
  118. package/dist/esm/resolve-save-type.js.map +1 -0
  119. package/dist/esm/stringify-node.d.ts +1 -1
  120. package/dist/esm/stringify-node.d.ts.map +1 -1
  121. package/dist/esm/stringify-node.js.map +1 -1
  122. package/dist/esm/transfer-data/load.d.ts +44 -0
  123. package/dist/esm/transfer-data/load.d.ts.map +1 -0
  124. package/dist/esm/transfer-data/load.js +176 -0
  125. package/dist/esm/transfer-data/load.js.map +1 -0
  126. package/dist/esm/uninstall.d.ts +3 -5
  127. package/dist/esm/uninstall.d.ts.map +1 -1
  128. package/dist/esm/uninstall.js +0 -3
  129. package/dist/esm/uninstall.js.map +1 -1
  130. package/dist/esm/update.d.ts +11 -0
  131. package/dist/esm/update.d.ts.map +1 -0
  132. package/dist/esm/update.js +49 -0
  133. package/dist/esm/update.js.map +1 -0
  134. package/dist/esm/virtual-root.d.ts +16 -0
  135. package/dist/esm/virtual-root.d.ts.map +1 -0
  136. package/dist/esm/virtual-root.js +78 -0
  137. package/dist/esm/virtual-root.js.map +1 -0
  138. package/dist/esm/visualization/human-readable-output.d.ts +4 -5
  139. package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
  140. package/dist/esm/visualization/human-readable-output.js +51 -24
  141. package/dist/esm/visualization/human-readable-output.js.map +1 -1
  142. package/dist/esm/visualization/json-output.d.ts +7 -3
  143. package/dist/esm/visualization/json-output.d.ts.map +1 -1
  144. package/dist/esm/visualization/json-output.js +35 -12
  145. package/dist/esm/visualization/json-output.js.map +1 -1
  146. package/dist/esm/visualization/mermaid-output.d.ts +7 -1
  147. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  148. package/dist/esm/visualization/mermaid-output.js +64 -9
  149. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  150. package/dist/esm/visualization/object-like-output.d.ts +1 -1
  151. package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
  152. package/dist/esm/visualization/object-like-output.js.map +1 -1
  153. package/package.json +29 -25
  154. package/dist/esm/types.d.ts +0 -39
  155. package/dist/esm/types.d.ts.map +0 -1
  156. package/dist/esm/types.js +0 -2
  157. package/dist/esm/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA6C1C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AACpD,MAAM,eAAe,GAAG,CACtB,IAAY,EACkB,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1D,MAAM,cAAc,GAAG,CACrB,IAAU,EACV,IAAY,EACO,EAAE,CACrB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,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AG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;IACrD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IAEvC,uEAAuE;IACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;IACH,CAAC;IAED,qEAAqE;IACrE,sEAAsE;IACtE,0DAA0D;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type { Manifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport { shorten } from '../dependencies.ts'\nimport type { RawDependency } from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { Node } from '../node.ts'\nimport { graphStep } from '@vltpkg/output'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: Manifest\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\nconst getPathBasedId = (\n spec: Spec,\n path: string,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path])\n : undefined\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of the current node.\n */\nconst getDeps = (node: Node) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests } = options\n const dependencies = getDeps(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n const h = hydrate(depId, alias, {\n ...options,\n registry: fromNode.registry,\n })\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n ...(h.registrySpec ?\n { version: h.registrySpec } // adds version if available\n : null),\n },\n depId,\n )\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n const spec = Spec.parse(alias, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n const maybeId = getPathBasedId(spec, realpath.relativePosix())\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n )\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n graph.placePackage(fromNode, depType, spec)\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n // TODO: once hidden lockfile is more reliable, default to false here\n const {\n skipHiddenLockfile = true,\n projectRoot,\n packageJson,\n scurry,\n monorepo,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n // TODO: check mtime of lockfile vs .vlt folder\n return graph\n } catch {}\n }\n\n const graph = new Graph({ ...options, mainManifest })\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n done()\n\n return graph\n}\n"]}
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../../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AA2D;IAC3D,2EAA2E;IAC3E,IAAI,sBAAsB,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;QAEvC,uEAAuE;QACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YAChC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;QACH,CAAC;QAED,qEAAqE;QACrE,sEAAsE;QACtE,0DAA0D;QAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;QACH,CAAC;QAED,kEAAkE;QAClE,SAAS,EAAE,qBAAqB,EAAE,CAAA;IACpC,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport { graphStep } from '@vltpkg/output'\nimport { isObject } from '@vltpkg/types'\nimport {\n shorten,\n getRawDependencies,\n getDependencies,\n} from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport { readFileSync } from 'node:fs'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n /**\n * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of date.\n * Used by ci command to enforce lockfile integrity.\n */\n expectLockfile?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of sync with package.json.\n * Prevents any lockfile modifications and is stricter than expectLockfile.\n */\n frozenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\n/**\n * The configuration object type as it is saved in the `.vlt/vlt.json`\n */\nexport type StoreConfigObject = {\n modifiers: Record<string, string> | undefined\n}\n\n/**\n * Checks if a given object is a {@link StoreConfigObject}.\n */\nexport const isStoreConfigObject = (\n obj: unknown,\n): obj is StoreConfigObject =>\n isObject(obj) &&\n Object.prototype.hasOwnProperty.call(obj, 'modifiers') &&\n isObject(obj.modifiers)\n\n/**\n * Returns a {@link StoreConfigObject} from a given object.\n * Throws a TypeError if the object can't be converted.\n */\nexport const asStoreConfigObject = (\n obj: unknown,\n): StoreConfigObject => {\n if (!isStoreConfigObject(obj)) {\n throw new TypeError(`Expected a store config object, got ${obj}`)\n }\n return obj\n}\n\n// path-based refer to the types of dependencies that are directly linked to\n// their real location in the file system and thus will not have an entry\n// in the `node_modules/.vlt` store\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\n\n/**\n * Returns a {@link DepID} for a given spec and path, if the spec is\n * path-based or a registry spec, otherwise returns `undefined`.\n */\nexport const getPathBasedId = (\n spec: Spec,\n path: Path,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path.relativePosix()])\n : findDepID(path)\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\n/**\n * Helper function that gets a modified {@link Spec} when finding a modifier\n * that applies to a given dependency. Otherwise returns the original spec\n * value and no queryModifier.\n */\nconst maybeApplyModifierToSpec = (\n spec: Spec,\n depName: string,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n): { spec: Spec; queryModifier?: string } => {\n const activeModifier = modifierRefs?.get(depName)\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n const modifiedSpec = activeModifier.modifier.spec\n modifiedSpec.overridden = true\n return { spec: modifiedSpec, queryModifier }\n }\n\n return { spec, queryModifier }\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests, modifiers } = options\n const dependencies = getRawDependencies(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n // Get modifier references for this node's dependencies\n const modifierRefs = modifiers?.tryDependencies(fromNode, [\n ...getDependencies(fromNode, options).values(),\n ])\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n let h = hydrate(depId, alias, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n h.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec even when not loading manifests\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(h, alias, modifierRefs)\n h = modifiedSpec\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n },\n depId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n let spec = Spec.parse(alias, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec if a modifier is complete\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, alias, modifierRefs)\n spec = modifiedSpec\n\n const maybeId = getPathBasedId(spec, realpath)\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n let spec = Spec.parse(name, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec for missing dependencies\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, name, modifierRefs)\n spec = modifiedSpec\n\n graph.placePackage(\n fromNode,\n depType,\n spec,\n undefined,\n undefined,\n queryModifier,\n )\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n const {\n modifiers,\n monorepo,\n projectRoot,\n packageJson,\n scurry,\n skipHiddenLockfile = false,\n skipLoadingNodesOnModifiersChange = false,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n // if we reach here, the hidden lockfile is valid\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n done()\n return graph\n } catch {\n // if validation fails or any other error occurs,\n // fall back to filesystem traversal\n }\n }\n\n const graph = new Graph({ ...options, mainManifest })\n\n // retrieve the configuration object from the store\n let storeConfig: StoreConfigObject = { modifiers: undefined }\n try {\n storeConfig = asStoreConfigObject(\n JSON.parse(\n readFileSync(\n scurry.resolve('node_modules/.vlt/vlt.json'),\n 'utf8',\n ),\n ),\n )\n } catch {}\n const storeModifiers = JSON.stringify(storeConfig.modifiers ?? {})\n const optionsModifiers = JSON.stringify(modifiers?.config)\n const modifiersChanged = storeModifiers !== optionsModifiers\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n\n // will only skip loading dependencies if the\n // skipLoadingNodesOnModifiersChange option is set to true\n // and the current modifiers have not changed when compared\n // to the modifiers stored in the `node_modules/.vlt/vlt.json` store config\n if (shouldLoadDependencies) {\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n modifiers?.tryImporter(importer)\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n // Clean up any pending modifier entries that were never completed\n modifiers?.rollbackActiveEntries()\n }\n\n done()\n\n return graph\n}\n"]}
@@ -2,10 +2,14 @@ import { longDependencyTypes } from '@vltpkg/types';
2
2
  import { asDependencyTypeShort, shorten } from './dependencies.ts';
3
3
  import { getBooleanFlagsFromNum } from './lockfile/types.ts';
4
4
  import { stringifyNode } from './stringify-node.ts';
5
- export * from './types.ts';
5
+ export type { LoadResult, TransferData, } from './transfer-data/load.ts';
6
+ export * from './virtual-root.ts';
6
7
  declare const lockfile: {
7
- loadEdges: (graph: import("./types.ts").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
8
- loadNodes: (graph: import("./types.ts").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"]) => void;
8
+ loadEdges: (graph: import("@vltpkg/types").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
9
+ loadNodes: (graph: import("@vltpkg/types").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"], options: import("@vltpkg/spec").SpecOptions, actual?: import("@vltpkg/types").GraphLike) => void;
9
10
  };
10
- export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, };
11
+ declare const transfer: {
12
+ load: (transfered: import("./transfer-data/load.ts").TransferData) => import("./transfer-data/load.ts").LoadResult;
13
+ };
14
+ export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, transfer, };
11
15
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,cAAc,YAAY,CAAA;AAE1B,QAAA,MAAM,QAAQ;;;CAGb,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,GACd,CAAA"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAInD,YAAY,EACV,UAAU,EACV,YAAY,GACb,MAAM,yBAAyB,CAAA;AAEhC,cAAc,mBAAmB,CAAA;AAEjC,QAAA,MAAM,QAAQ;;;CAGb,CAAA;AAED,QAAA,MAAM,QAAQ;;CAEb,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,QAAQ,GACT,CAAA"}
@@ -4,10 +4,14 @@ import { getBooleanFlagsFromNum } from "./lockfile/types.js";
4
4
  import { stringifyNode } from "./stringify-node.js";
5
5
  import { loadEdges } from "./lockfile/load-edges.js";
6
6
  import { loadNodes } from "./lockfile/load-nodes.js";
7
- export * from "./types.js";
7
+ import { load } from "./transfer-data/load.js";
8
+ export * from "./virtual-root.js";
8
9
  const lockfile = {
9
10
  loadEdges,
10
11
  loadNodes,
11
12
  };
12
- export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, };
13
+ const transfer = {
14
+ load,
15
+ };
16
+ export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, transfer, };
13
17
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,cAAc,YAAY,CAAA;AAE1B,MAAM,QAAQ,GAAG;IACf,SAAS;IACT,SAAS;CACV,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,GACd,CAAA","sourcesContent":["import { longDependencyTypes } from '@vltpkg/types'\nimport { asDependencyTypeShort, shorten } from './dependencies.ts'\nimport { getBooleanFlagsFromNum } from './lockfile/types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nexport * from './types.ts'\n\nconst lockfile = {\n loadEdges,\n loadNodes,\n}\n\nexport {\n asDependencyTypeShort,\n getBooleanFlagsFromNum,\n lockfile,\n longDependencyTypes,\n shorten,\n stringifyNode,\n}\n"]}
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAM9C,cAAc,mBAAmB,CAAA;AAEjC,MAAM,QAAQ,GAAG;IACf,SAAS;IACT,SAAS;CACV,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,IAAI;CACL,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,QAAQ,GACT,CAAA","sourcesContent":["import { longDependencyTypes } from '@vltpkg/types'\nimport { asDependencyTypeShort, shorten } from './dependencies.ts'\nimport { getBooleanFlagsFromNum } from './lockfile/types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { load } from './transfer-data/load.ts'\nexport type {\n LoadResult,\n TransferData,\n} from './transfer-data/load.ts'\n\nexport * from './virtual-root.ts'\n\nconst lockfile = {\n loadEdges,\n loadNodes,\n}\n\nconst transfer = {\n load,\n}\n\nexport {\n asDependencyTypeShort,\n getBooleanFlagsFromNum,\n lockfile,\n longDependencyTypes,\n shorten,\n stringifyNode,\n transfer,\n}\n"]}
@@ -1,7 +1,9 @@
1
1
  import type { DepID } from '@vltpkg/dep-id';
2
- import type { Spec } from '@vltpkg/spec';
3
- import type { Manifest, DependencyTypeLong, DependencyTypeShort } from '@vltpkg/types';
2
+ import { Spec } from '@vltpkg/spec/browser';
3
+ import type { SpecOptions } from '@vltpkg/spec';
4
+ import type { DependencySaveType, DependencyTypeLong, DependencyTypeShort, Manifest, NodeLike } from '@vltpkg/types';
4
5
  export declare const isDependencyTypeShort: (obj: unknown) => obj is DependencyTypeShort;
6
+ export declare const isDependencySaveType: (obj: unknown) => obj is DependencyTypeShort;
5
7
  export declare const asDependencyTypeShort: (obj: unknown) => DependencyTypeShort;
6
8
  /**
7
9
  * Dependency entries info as defined in a package.json file.
@@ -21,9 +23,10 @@ export type Dependency = {
21
23
  */
22
24
  spec: Spec;
23
25
  /**
24
- * The {@link DependencyTypeShort}, describing the type of dependency.
26
+ * The {@link DependencySaveType}, describing the way this dependency should
27
+ * be saved back to the manifest.
25
28
  */
26
- type: DependencyTypeShort;
29
+ type: DependencySaveType;
27
30
  };
28
31
  /**
29
32
  * A `Map` in which keys are {@link DepID} linking to another `Map` in which
@@ -53,5 +56,11 @@ export declare const asDependency: (obj: unknown) => Dependency;
53
56
  /**
54
57
  * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.
55
58
  */
56
- export declare const shorten: (typeLong: DependencyTypeLong, name?: string, manifest?: Manifest) => DependencyTypeShort;
59
+ export declare const shorten: (typeLong: DependencyTypeLong, name?: string, manifest?: Pick<Manifest, "peerDependenciesMeta"> | null) => DependencyTypeShort;
60
+ export declare const getRawDependencies: (node: NodeLike) => Map<string, RawDependency>;
61
+ /**
62
+ * Retrieves a map of all dependencies, of all types, that can be inferred
63
+ * from a given node manifest, including missing dependencies.
64
+ */
65
+ export declare const getDependencies: (node: NodeLike, options: SpecOptions) => Map<string, Dependency>;
57
66
  //# sourceMappingURL=dependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAMxC,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAEtB,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,GAAG,IAAI,mBAC4C,CAAA;AAEtD,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,mBAQF,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAC3C,KAAK,EACL,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CACxB,GAAG;IAAE,oBAAoB,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GG;IACH,IAAI,EAAE,kBAAkB,CAAA;CACzB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAC3C,KAAK,EACL,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CACxB,GAAG;IAAE,oBAAoB,EAAE,OAAO,CAAA;CAAE,CAAA;AAErC;;;;;;;GAOG;AACH,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAC9C,KAAK,EACL,GAAG,CAAC,MAAM,CAAC,CACZ,GAAG;IAAE,oBAAoB,EAAE,OAAO,CAAA;CAAE,CAAA;AAMrC,eAAO,MAAM,YAAY,MAAO,OAAO,KAAG,CAAC,IAAI,UAKjB,CAAA;AAE9B,eAAO,MAAM,YAAY,QAAS,OAAO,KAAG,UAK3C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,aACR,kBAAkB,SACrB,MAAM,aACF,IAAI,CAAC,QAAQ,EAAE,sBAAsB,CAAC,GAAG,IAAI,KACvD,mBAkBF,CAAA;AASD,eAAO,MAAM,kBAAkB,SAAU,QAAQ,+BAyChD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,SACpB,QAAQ,WACL,WAAW,KACnB,GAAG,CAAC,MAAM,EAAE,UAAU,CAexB,CAAA"}
@@ -1,6 +1,9 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
- import { longDependencyTypes, shortDependencyTypes, dependencyTypes, } from '@vltpkg/types';
2
+ import { Spec } from '@vltpkg/spec/browser';
3
+ import { dependencyTypes, longDependencyTypes, shortDependencyTypes, } from '@vltpkg/types';
3
4
  export const isDependencyTypeShort = (obj) => shortDependencyTypes.has(obj);
5
+ export const isDependencySaveType = (obj) => shortDependencyTypes.has(obj) ||
6
+ obj === 'implicit';
4
7
  export const asDependencyTypeShort = (obj) => {
5
8
  if (!isDependencyTypeShort(obj)) {
6
9
  throw error('Invalid dependency type', {
@@ -17,7 +20,7 @@ export const isDependency = (o) =>
17
20
  isObj(o) &&
18
21
  isObj(o.spec) &&
19
22
  !!o.spec.type &&
20
- isDependencyTypeShort(o.type);
23
+ isDependencySaveType(o.type);
21
24
  export const asDependency = (obj) => {
22
25
  if (!isDependency(obj)) {
23
26
  throw error('Invalid dependency', { found: obj });
@@ -44,4 +47,66 @@ export const shorten = (typeLong, name, manifest) => {
44
47
  }
45
48
  return 'peer';
46
49
  };
50
+ const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'string');
51
+ /*
52
+ * Retrieves a map of all dependencies, of all types, that can be iterated
53
+ * on and consulted when parsing the directory contents of a given node.
54
+ */
55
+ export const getRawDependencies = (node) => {
56
+ const dependencies = new Map();
57
+ const bundleDeps = node.manifest?.bundleDependencies ?? [];
58
+ // if it's an importer, bundleDeps are just normal. if it's a dep,
59
+ // then they're ignored entirely.
60
+ const bundled = (!node.importer &&
61
+ !node.id.startsWith('git') &&
62
+ isStringArray(bundleDeps)) ?
63
+ new Set(bundleDeps)
64
+ : new Set();
65
+ for (const depType of longDependencyTypes) {
66
+ const obj = node.manifest?.[depType];
67
+ // only care about devDeps for importers and git or symlink deps
68
+ // technically this will also include devDeps for tarball file: specs,
69
+ // but that is likely rare enough to not worry about too much.
70
+ if (depType === 'devDependencies' &&
71
+ !node.importer &&
72
+ !node.id.startsWith('git') &&
73
+ !node.id.startsWith('file')) {
74
+ continue;
75
+ }
76
+ if (obj) {
77
+ for (const [name, bareSpec] of Object.entries(obj)) {
78
+ // if it's a bundled dependency, we just ignore it entirely.
79
+ if (bundled.has(name))
80
+ continue;
81
+ dependencies.set(name, {
82
+ name,
83
+ type: depType,
84
+ bareSpec,
85
+ registry: node.registry,
86
+ });
87
+ }
88
+ }
89
+ }
90
+ return dependencies;
91
+ };
92
+ /**
93
+ * Retrieves a map of all dependencies, of all types, that can be inferred
94
+ * from a given node manifest, including missing dependencies.
95
+ */
96
+ export const getDependencies = (node, options) => {
97
+ const res = new Map();
98
+ const dependencies = getRawDependencies(node);
99
+ for (const { name, type, bareSpec } of dependencies.values()) {
100
+ const depType = shorten(type, name, node.manifest);
101
+ const spec = Spec.parse(name, bareSpec, {
102
+ ...options,
103
+ registry: node.registry,
104
+ });
105
+ res.set(name, {
106
+ spec,
107
+ type: depType,
108
+ });
109
+ }
110
+ return res;
111
+ };
47
112
  //# sourceMappingURL=dependencies.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAA;AAOtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACS,EAAE;IACvB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC,yBAAyB,EAAE;YACrC,KAAK,EAAE,GAAG;YACV,YAAY,EAAE,CAAC,GAAG,oBAAoB,CAAC;SACxC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAqDD,MAAM,KAAK,GAAG,CAAC,CAAU,EAAgC,EAAE,CACzD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAA;AAE9B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAAmB,EAAE;AAC1D,8DAA8D;AAC9D,KAAK,CAAC,CAAC,CAAC;IACR,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACb,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;IACb,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAE/B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,GAAY,EAAc,EAAE;IACvD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CACrB,QAA4B,EAC5B,IAAa,EACb,QAAmB,EACE,EAAE;IACvB,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC/C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,KAAK,CAAC,8BAA8B,EAAE;YAC1C,KAAK,EAAE,QAAQ;YACf,YAAY,EAAE,CAAC,GAAG,mBAAmB,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;QACzB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IACE,IAAI;QACJ,QAAQ,EAAE,oBAAoB,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,IAAI,EACzD,CAAC;QACD,OAAO,cAAc,CAAA;IACvB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { Spec } from '@vltpkg/spec'\nimport {\n longDependencyTypes,\n shortDependencyTypes,\n dependencyTypes,\n} from '@vltpkg/types'\nimport type {\n Manifest,\n DependencyTypeLong,\n DependencyTypeShort,\n} from '@vltpkg/types'\n\nexport const isDependencyTypeShort = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort)\n\nexport const asDependencyTypeShort = (\n obj: unknown,\n): DependencyTypeShort => {\n if (!isDependencyTypeShort(obj)) {\n throw error('Invalid dependency type', {\n found: obj,\n validOptions: [...shortDependencyTypes],\n })\n }\n return obj\n}\n\n/**\n * Dependency entries info as defined in a package.json file.\n */\nexport type RawDependency = {\n name: string\n bareSpec: string\n type: DependencyTypeLong\n registry?: string\n}\n\n/**\n * Parsed dependency entries info.\n */\nexport type Dependency = {\n /**\n * The parsed {@link Spec} object describing the dependency requirements.\n */\n spec: Spec\n /**\n * The {@link DependencyTypeShort}, describing the type of dependency.\n */\n type: DependencyTypeShort\n}\n\n/**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type AddImportersDependenciesMap = Map<\n DepID,\n Map<string, Dependency>\n> & { modifiedDependencies: boolean }\n\n/**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type RemoveImportersDependenciesMap = Map<\n DepID,\n Set<string>\n> & { modifiedDependencies: boolean }\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\n// TODO: it would be nice to have a @vltpkg/spec.isSpec method\nexport const isDependency = (o: unknown): o is Dependency =>\n // TODO: it would be nice to have a @vltpkg/spec.isSpec method\n isObj(o) &&\n isObj(o.spec) &&\n !!o.spec.type &&\n isDependencyTypeShort(o.type)\n\nexport const asDependency = (obj: unknown): Dependency => {\n if (!isDependency(obj)) {\n throw error('Invalid dependency', { found: obj })\n }\n return obj\n}\n\n/**\n * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.\n */\nexport const shorten = (\n typeLong: DependencyTypeLong,\n name?: string,\n manifest?: Manifest,\n): DependencyTypeShort => {\n const shortName = dependencyTypes.get(typeLong)\n if (!shortName) {\n throw error('Invalid dependency type name', {\n found: typeLong,\n validOptions: [...longDependencyTypes],\n })\n }\n if (shortName !== 'peer') {\n return shortName\n }\n if (\n name &&\n manifest?.peerDependenciesMeta?.[name]?.optional === true\n ) {\n return 'peerOptional'\n }\n return 'peer'\n}\n"]}
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAS3C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC;IACpD,GAAG,KAAK,UAAU,CAAA;AAEpB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACS,EAAE;IACvB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,KAAK,CAAC,yBAAyB,EAAE;YACrC,KAAK,EAAE,GAAG;YACV,YAAY,EAAE,CAAC,GAAG,oBAAoB,CAAC;SACxC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAsDD,MAAM,KAAK,GAAG,CAAC,CAAU,EAAgC,EAAE,CACzD,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAA;AAE9B,8DAA8D;AAC9D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAU,EAAmB,EAAE;AAC1D,8DAA8D;AAC9D,KAAK,CAAC,CAAC,CAAC;IACR,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IACb,CAAC,CAAC,CAAC,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Ac,EACd,OAAoB,EACK,EAAE;IAC3B,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAA;IACzC,MAAM,YAAY,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;IAC7C,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAClD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE;YACtC,GAAG,OAAO;YACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAA;QACF,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;YACZ,IAAI;YACJ,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { Spec } from '@vltpkg/spec/browser'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type {\n DependencySaveType,\n DependencyTypeLong,\n DependencyTypeShort,\n Manifest,\n NodeLike,\n} from '@vltpkg/types'\nimport {\n dependencyTypes,\n longDependencyTypes,\n shortDependencyTypes,\n} from '@vltpkg/types'\n\nexport const isDependencyTypeShort = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort)\n\nexport const isDependencySaveType = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort) ||\n obj === 'implicit'\n\nexport const asDependencyTypeShort = (\n obj: unknown,\n): DependencyTypeShort => {\n if (!isDependencyTypeShort(obj)) {\n throw error('Invalid dependency type', {\n found: obj,\n validOptions: [...shortDependencyTypes],\n })\n }\n return obj\n}\n\n/**\n * Dependency entries info as defined in a package.json file.\n */\nexport type RawDependency = {\n name: string\n bareSpec: string\n type: DependencyTypeLong\n registry?: string\n}\n\n/**\n * Parsed dependency entries info.\n */\nexport type Dependency = {\n /**\n * The parsed {@link Spec} object describing the dependency requirements.\n */\n spec: Spec\n /**\n * The {@link DependencySaveType}, describing the way this dependency should\n * be saved back to the manifest.\n */\n type: DependencySaveType\n}\n\n/**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type AddImportersDependenciesMap = Map<\n DepID,\n Map<string, Dependency>\n> & { modifiedDependencies: boolean }\n\n/**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type RemoveImportersDependenciesMap = Map<\n DepID,\n Set<string>\n> & { modifiedDependencies: boolean }\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\n// TODO: it would be nice to have a @vltpkg/spec.isSpec method\nexport const isDependency = (o: unknown): o is Dependency =>\n // TODO: it would be nice to have a @vltpkg/spec.isSpec method\n isObj(o) &&\n isObj(o.spec) &&\n !!o.spec.type &&\n isDependencySaveType(o.type)\n\nexport const asDependency = (obj: unknown): Dependency => {\n if (!isDependency(obj)) {\n throw error('Invalid dependency', { found: obj })\n }\n return obj\n}\n\n/**\n * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.\n */\nexport const shorten = (\n typeLong: DependencyTypeLong,\n name?: string,\n manifest?: Pick<Manifest, 'peerDependenciesMeta'> | null,\n): DependencyTypeShort => {\n const shortName = dependencyTypes.get(typeLong)\n if (!shortName) {\n throw error('Invalid dependency type name', {\n found: typeLong,\n validOptions: [...longDependencyTypes],\n })\n }\n if (shortName !== 'peer') {\n return shortName\n }\n if (\n name &&\n manifest?.peerDependenciesMeta?.[name]?.optional === true\n ) {\n return 'peerOptional'\n }\n return 'peer'\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of a given node.\n */\nexport const getRawDependencies = (node: NodeLike) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Retrieves a map of all dependencies, of all types, that can be inferred\n * from a given node manifest, including missing dependencies.\n */\nexport const getDependencies = (\n node: NodeLike,\n options: SpecOptions,\n): Map<string, Dependency> => {\n const res = new Map<string, Dependency>()\n const dependencies = getRawDependencies(node)\n for (const { name, type, bareSpec } of dependencies.values()) {\n const depType = shorten(type, name, node.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: node.registry,\n })\n res.set(name, {\n spec,\n type: depType,\n })\n }\n return res\n}\n"]}
@@ -41,9 +41,14 @@ export declare class Diff {
41
41
  /** Edges in the `from` graph that are not found in the `to` graph */
42
42
  delete: Set<Edge>;
43
43
  };
44
+ /**
45
+ * True if the diff only contains optional nodes (computed during construction)
46
+ */
47
+ optionalOnly: boolean;
44
48
  get [Symbol.toStringTag](): string;
45
49
  constructor(from: Graph, to: Graph);
46
50
  [kCustomInspect](_: number, options?: InspectOptions): string;
51
+ hasChanges(): boolean;
47
52
  }
48
53
  export {};
49
54
  //# sourceMappingURL=diff.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IAyClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;CAuC9D"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;CAQtB"}
package/dist/esm/diff.js CHANGED
@@ -42,6 +42,10 @@ export class Diff {
42
42
  /** Edges in the `from` graph that are not found in the `to` graph */
43
43
  delete: new Set(),
44
44
  };
45
+ /**
46
+ * True if the diff only contains optional nodes (computed during construction)
47
+ */
48
+ optionalOnly = true;
45
49
  get [Symbol.toStringTag]() {
46
50
  return '@vltpkg/graph.Diff';
47
51
  }
@@ -63,6 +67,9 @@ export class Diff {
63
67
  for (const [id, node] of this.to.nodes) {
64
68
  if (!this.from.nodes.get(id)?.equals(node)) {
65
69
  this.nodes.add.add(node);
70
+ if (!node.optional) {
71
+ this.optionalOnly = false;
72
+ }
66
73
  }
67
74
  }
68
75
  for (const edge of this.to.edges) {
@@ -119,5 +126,11 @@ ${lines
119
126
  .join('\n')}
120
127
  }`;
121
128
  }
129
+ hasChanges() {
130
+ return (this.nodes.add.size > 0 ||
131
+ this.nodes.delete.size > 0 ||
132
+ this.edges.add.size > 0 ||
133
+ this.edges.delete.size > 0);
134
+ }
122
135
  }
123
136
  //# sourceMappingURL=diff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;QAC/D,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,+DAA+D;QAC/D,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,KAAK,GAAG;QACN,qEAAqE;QACrE,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,qEAAqE;QACrE,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,YAAY,IAAW,EAAE,EAAS;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACnC,IAAI,EAAE,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,EAAE,CAAC;YACxC,MAAM,KAAK,CAAC,oCAAoC,EAAE;gBAChD,MAAM,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;QAEpB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;EACpC,KAAK;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC;EACX,CAAA;IACA,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n}\n"]}
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;QAC/D,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,+DAA+D;QAC/D,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,KAAK,GAAG;QACN,qEAAqE;QACrE,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,qEAAqE;QACrE,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,YAAY,GAAG,IAAI,CAAA;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,YAAY,IAAW,EAAE,EAAS;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACnC,IAAI,EAAE,CAAC,WAAW,KA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EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;YACzD,CAAC,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAA;QAEpB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;EACpC,KAAK;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC;EACX,CAAA;IACA,CAAC;IAED,UAAU;QACR,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAC3B,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import type { Spec } from '@vltpkg/spec';
2
- import type { InspectOptions } from 'util';
3
- import type { DependencyTypeShort } from '@vltpkg/types';
2
+ import type { InspectOptions } from 'node:util';
3
+ import type { DependencyTypeShort, EdgeLike } from '@vltpkg/types';
4
4
  import type { Node } from './node.ts';
5
- import type { EdgeLike } from './types.ts';
6
5
  declare const kCustomInspect: unique symbol;
7
6
  export declare class Edge implements EdgeLike {
8
7
  get [Symbol.toStringTag](): string;
@@ -1 +1 @@
1
- {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D,qBAAa,IAAK,YAAW,QAAQ;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;CAUjB"}
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D,qBAAa,IAAK,YAAW,QAAQ;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;CAUjB"}
package/dist/esm/edge.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { satisfies } from '@vltpkg/satisfies';
2
- import { inspect } from 'util';
2
+ import { inspect } from 'node:util';
3
3
  const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
4
4
  export class Edge {
5
5
  get [Symbol.toStringTag]() {
@@ -1 +1 @@
1
- {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAM9B,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AA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AC7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'util'\nimport type { InspectOptions } from 'util'\nimport type { DependencyTypeShort } from '@vltpkg/types'\nimport type { Node } from './node.ts'\nimport type { EdgeLike } from './types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;SAChB,EACD,OAAO,CACR,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,EAAE,CAAO;IAET;;OAEG;IACH,IAAI,CAAqB;IAEzB;;OAEG;IACH,IAAI,CAAM;IAEV,YACE,IAAyB,EACzB,IAAU,EACV,IAAU,EACV,EAAS;QAET,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IAC7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n}\n"]}
@@ -1,19 +1,18 @@
1
1
  import type { DepID } from '@vltpkg/dep-id';
2
2
  import { Spec } from '@vltpkg/spec';
3
3
  import type { SpecOptions } from '@vltpkg/spec';
4
- import type { Manifest, DependencyTypeShort } from '@vltpkg/types';
4
+ import type { GraphLike, NodeLike, NormalizedManifest, DependencySaveType } from '@vltpkg/types';
5
5
  import type { Monorepo } from '@vltpkg/workspaces';
6
- import type { InspectOptions } from 'util';
7
- import type { Edge } from './edge.ts';
6
+ import type { InspectOptions } from 'node:util';
7
+ import { Edge } from './edge.ts';
8
8
  import { Node } from './node.ts';
9
- import type { GraphLike, NodeLike } from './types.ts';
10
9
  declare const kCustomInspect: unique symbol;
11
- export type ManifestInventory = Map<DepID, Manifest>;
10
+ export type ManifestInventory = Map<DepID, NormalizedManifest>;
12
11
  export type GraphOptions = SpecOptions & {
13
12
  /**
14
13
  * The main importer manifest info.
15
14
  */
16
- mainManifest: Manifest;
15
+ mainManifest: NormalizedManifest;
17
16
  /**
18
17
  * An inventory of seen manifests.
19
18
  */
@@ -76,7 +75,7 @@ export declare class Graph implements GraphLike {
76
75
  projectRoot: string;
77
76
  constructor(options: GraphOptions);
78
77
  /**
79
- * Delete all nodes that are unreachable from the importers.
78
+ * Delete all nodes and edges that are unreachable from the importers.
80
79
  * The collection of deleted nodes is returned.
81
80
  *
82
81
  * NOTE: This can be extremely slow for large graphs, and is almost always
@@ -90,15 +89,15 @@ export declare class Graph implements GraphLike {
90
89
  * in case the destination node does not exists, then a dangling edge,
91
90
  * pointing to nothing will be created to represent that missing dependency.
92
91
  */
93
- addEdge(type: DependencyTypeShort, spec: Spec, from: NodeLike, to?: NodeLike): Edge;
92
+ addEdge(type: DependencySaveType, spec: Spec, from: NodeLike, to?: NodeLike): Edge;
94
93
  /**
95
94
  * Find an existing node to satisfy a dependency
96
95
  */
97
- findResolution(spec: Spec, fromNode: Node): Node | undefined;
96
+ findResolution(spec: Spec, fromNode: Node, queryModifier?: string): Node | undefined;
98
97
  /**
99
98
  * Create a new node in the graph.
100
99
  */
101
- addNode(id?: DepID, manifest?: Manifest, spec?: Spec, name?: string, version?: string): Node;
100
+ addNode(id?: DepID, manifest?: NormalizedManifest, spec?: Spec, name?: string, version?: string): Node;
102
101
  /**
103
102
  * Place a new package into the graph representation, creating the new
104
103
  * edges and possibly new nodes that are to be expected when traversing
@@ -107,15 +106,26 @@ export declare class Graph implements GraphLike {
107
106
  * For different uses that are not a direct top-down traversal of the graph
108
107
  * consider using `addNode()` and `addEdge()` instead.
109
108
  */
110
- placePackage(fromNode: Node, depType: DependencyTypeShort, spec: Spec, manifest?: Manifest, id?: DepID): Node | undefined;
109
+ placePackage(fromNode: Node, depType: DependencySaveType, spec: Spec, manifest?: NormalizedManifest, id?: DepID, extra?: string): Node | undefined;
111
110
  /**
112
111
  * Removes a node and its relevant edges from the graph.
113
112
  *
113
+ * Use the `keepEdges` option to keep the edges that were pointing to
114
+ * this node and only removes their `to` property value.
115
+ *
114
116
  * If a replacement is provided, then any edges that were previously
115
117
  * pointing to the removed node will be directed to the replacement,
116
118
  * if it is valid to do so.
117
119
  */
118
- removeNode(node: Node, replacement?: Node): void;
120
+ removeNode(node: Node, replacement?: Node, keepEdges?: boolean): void;
121
+ /**
122
+ * Removes the resolved node of a given edge.
123
+ */
124
+ removeEdgeResolution(edge: Edge, queryModifier?: string): void;
125
+ /**
126
+ * Reset resolution cache data.
127
+ */
128
+ resetResolution(): void;
119
129
  toJSON(): import("./index.ts").LockfileData;
120
130
  [kCustomInspect](_: number, options: InspectOptions): string;
121
131
  }
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErD,QAAA,MAAM,cAAc,eAA2C,CAAA;AAM/D,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AAKpD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC;;OAEG;IACH,YAAY,EAAE,QAAQ,CAAA;IACtB;;OAEG;IACH,SAAS,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