@vltpkg/cli-js 0.0.0-7

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 (128) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +10 -0
  3. package/cache-unzip-src-unzip.js +7896 -0
  4. package/cache-unzip-src-unzip.js.map +7 -0
  5. package/chunk-36Z4IEW5.js +1010 -0
  6. package/chunk-36Z4IEW5.js.map +7 -0
  7. package/chunk-433RK6QP.js +72 -0
  8. package/chunk-433RK6QP.js.map +7 -0
  9. package/chunk-457WPPV5.js +969 -0
  10. package/chunk-457WPPV5.js.map +7 -0
  11. package/chunk-66GJ6BNX.js +2666 -0
  12. package/chunk-66GJ6BNX.js.map +7 -0
  13. package/chunk-AYOLWFFJ.js +10972 -0
  14. package/chunk-AYOLWFFJ.js.map +7 -0
  15. package/chunk-GQLKOYXI.js +1451 -0
  16. package/chunk-GQLKOYXI.js.map +7 -0
  17. package/chunk-GU2E2KHZ.js +152 -0
  18. package/chunk-GU2E2KHZ.js.map +7 -0
  19. package/chunk-H75RQSUK.js +5413 -0
  20. package/chunk-H75RQSUK.js.map +7 -0
  21. package/chunk-LJEVKV7R.js +36 -0
  22. package/chunk-LJEVKV7R.js.map +7 -0
  23. package/chunk-MF4RCNHU.js +71 -0
  24. package/chunk-MF4RCNHU.js.map +7 -0
  25. package/chunk-NM754OFF.js +1104 -0
  26. package/chunk-NM754OFF.js.map +7 -0
  27. package/chunk-OGUMFXHI.js +1136 -0
  28. package/chunk-OGUMFXHI.js.map +7 -0
  29. package/chunk-OKDQY2GQ.js +1866 -0
  30. package/chunk-OKDQY2GQ.js.map +7 -0
  31. package/chunk-OOZN2US4.js +61 -0
  32. package/chunk-OOZN2US4.js.map +7 -0
  33. package/chunk-OSVOPGNL.js +782 -0
  34. package/chunk-OSVOPGNL.js.map +7 -0
  35. package/chunk-PKKWJ5FM.js +11836 -0
  36. package/chunk-PKKWJ5FM.js.map +7 -0
  37. package/chunk-PPTEV6PS.js +27 -0
  38. package/chunk-PPTEV6PS.js.map +7 -0
  39. package/chunk-S7LRSSDW.js +40 -0
  40. package/chunk-S7LRSSDW.js.map +7 -0
  41. package/chunk-SJZXAMQQ.js +5233 -0
  42. package/chunk-SJZXAMQQ.js.map +7 -0
  43. package/chunk-TV2RDGWY.js +181 -0
  44. package/chunk-TV2RDGWY.js.map +7 -0
  45. package/chunk-V4TLWRQW.js +34 -0
  46. package/chunk-V4TLWRQW.js.map +7 -0
  47. package/chunk-VIE5PVDF.js +21788 -0
  48. package/chunk-VIE5PVDF.js.map +7 -0
  49. package/chunk-VO2MAWDF.js +53 -0
  50. package/chunk-VO2MAWDF.js.map +7 -0
  51. package/chunk-XCC42LF5.js +511 -0
  52. package/chunk-XCC42LF5.js.map +7 -0
  53. package/chunk-YS3ZYKCN.js +6499 -0
  54. package/chunk-YS3ZYKCN.js.map +7 -0
  55. package/chunk-ZLP22ACI.js +65 -0
  56. package/chunk-ZLP22ACI.js.map +7 -0
  57. package/chunk-ZSTAQQQN.js +2070 -0
  58. package/chunk-ZSTAQQQN.js.map +7 -0
  59. package/cli-package.json +104 -0
  60. package/config-M6ZTMEJC.js +184 -0
  61. package/config-M6ZTMEJC.js.map +7 -0
  62. package/devtools-PSS6DSS6.js +16681 -0
  63. package/devtools-PSS6DSS6.js.map +7 -0
  64. package/exec-5Q6ZP6JI.js +48 -0
  65. package/exec-5Q6ZP6JI.js.map +7 -0
  66. package/gui-667EH2M7.js +44 -0
  67. package/gui-667EH2M7.js.map +7 -0
  68. package/gui-assets/favicon.ico +0 -0
  69. package/gui-assets/fonts/courier-bold-italic.ttf +0 -0
  70. package/gui-assets/fonts/courier-bold.ttf +0 -0
  71. package/gui-assets/fonts/courier-italic.ttf +0 -0
  72. package/gui-assets/fonts/courier-regular.ttf +0 -0
  73. package/gui-assets/fonts/geist-mono.ttf +0 -0
  74. package/gui-assets/fonts/inter.ttf +0 -0
  75. package/gui-assets/images/folder.png +0 -0
  76. package/gui-assets/index.html +34 -0
  77. package/gui-assets/index.js +1573 -0
  78. package/gui-assets/index.js.map +7 -0
  79. package/gui-assets/main.css +1 -0
  80. package/help-JZ3VD6MH.js +24 -0
  81. package/help-JZ3VD6MH.js.map +7 -0
  82. package/init-4JOBGJ4C.js +24 -0
  83. package/init-4JOBGJ4C.js.map +7 -0
  84. package/install-I6UDMAKJ.js +53 -0
  85. package/install-I6UDMAKJ.js.map +7 -0
  86. package/install-exec-BGKORQDZ.js +27 -0
  87. package/install-exec-BGKORQDZ.js.map +7 -0
  88. package/list-NKJNNDAV.js +138 -0
  89. package/list-NKJNNDAV.js.map +7 -0
  90. package/login-5X5JKFYS.js +35 -0
  91. package/login-5X5JKFYS.js.map +7 -0
  92. package/logout-5NO6B4BW.js +35 -0
  93. package/logout-5NO6B4BW.js.map +7 -0
  94. package/package.json +25 -0
  95. package/pkg-CUX23YND.js +363 -0
  96. package/pkg-CUX23YND.js.map +7 -0
  97. package/query-XWAQ6U4O.js +126 -0
  98. package/query-XWAQ6U4O.js.map +7 -0
  99. package/registry-client-package.json +84 -0
  100. package/reporter-GV7DMKAK.js +17 -0
  101. package/reporter-GV7DMKAK.js.map +7 -0
  102. package/rollback-remove-src-remove.js +7397 -0
  103. package/rollback-remove-src-remove.js.map +7 -0
  104. package/run-GJDCKL7X.js +66 -0
  105. package/run-GJDCKL7X.js.map +7 -0
  106. package/run-exec-L3RGBBPL.js +39 -0
  107. package/run-exec-L3RGBBPL.js.map +7 -0
  108. package/source-ALZ2QHEZ.js +32 -0
  109. package/source-ALZ2QHEZ.js.map +7 -0
  110. package/src-XRLOORCU.js +92 -0
  111. package/src-XRLOORCU.js.map +7 -0
  112. package/token-JLM4D6QR.js +85 -0
  113. package/token-JLM4D6QR.js.map +7 -0
  114. package/uninstall-X72YAQHZ.js +53 -0
  115. package/uninstall-X72YAQHZ.js.map +7 -0
  116. package/vlix.js +13 -0
  117. package/vlix.js.map +7 -0
  118. package/vlr.js +13 -0
  119. package/vlr.js.map +7 -0
  120. package/vlrx.js +13 -0
  121. package/vlrx.js.map +7 -0
  122. package/vlt.js +13 -0
  123. package/vlt.js.map +7 -0
  124. package/vlx.js +13 -0
  125. package/vlx.js.map +7 -0
  126. package/whoami-CMKBD6ZT.js +45 -0
  127. package/whoami-CMKBD6ZT.js.map +7 -0
  128. package/yoga.wasm +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/graph/src/visualization/json-output.ts", "../../../src/graph/src/visualization/human-readable-output.ts", "../../../src/satisfies/src/index.ts", "../../../src/graph/src/edge.ts", "../../../src/dep-id/src/browser.ts", "../../../src/graph/src/stringify-node.ts", "../../../src/graph/src/node.ts", "../../../src/graph/src/visualization/mermaid-output.ts", "../../../src/graph/src/dependencies.ts", "../../../src/graph/src/graph.ts", "../../../src/graph/src/lockfile/save.ts", "../../../src/graph/src/lockfile/types.ts", "../../../src/graph/src/lockfile/load.ts", "../../../src/graph/src/lockfile/load-edges.ts", "../../../src/graph/src/lockfile/load-nodes.ts", "../../../src/graph/src/actual/load.ts", "../../../src/graph/src/ideal/remove-satisfied-specs.ts", "../../../src/graph/src/ideal/get-importer-specs.ts", "../../../src/graph/src/remove-optional-subgraph.ts", "../../../src/graph/src/ideal/append-nodes.ts", "../../../src/graph/src/ideal/add-nodes.ts", "../../../src/graph/src/ideal/remove-nodes.ts", "../../../src/graph/src/ideal/build-ideal-from-starting-graph.ts", "../../../src/graph/src/ideal/build.ts", "../../../src/rollback-remove/src/index.ts", "../../../src/rollback-remove/src/remove.ts", "../../../src/graph/src/reify/index.ts", "../../../node_modules/.pnpm/promise-call-limit@3.0.2/node_modules/promise-call-limit/src/index.ts", "../../../src/graph/src/diff.ts", "../../../src/graph/src/uninstall.ts", "../../../src/graph/src/index.ts", "../../../src/graph/src/reify/add-edge.ts", "../../../src/graph/src/reify/bin-paths.ts", "../../../src/graph/src/reify/add-edges.ts", "../../../src/graph/src/reify/optional-fail.ts", "../../../src/graph/src/reify/add-nodes.ts", "../../../src/graph/src/reify/build.ts", "../../../src/graph/src/non-empty-list.ts", "../../../src/graph/src/reify/delete-edge.ts", "../../../src/graph/src/reify/delete-edges.ts", "../../../src/graph/src/reify/delete-nodes.ts", "../../../src/graph/src/reify/rollback.ts", "../../../src/graph/src/reify/update-importers-package-json.ts", "../../../src/graph/src/install.ts"],
4
+ "sourcesContent": ["import type { DepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '../types.ts'\n\n/**\n * A JSON output item describes a package that is present in the install\n * graph. It represents an edge plus it's linking Node.\n */\nexport type JSONOutputItem = {\n /**\n * The name of the package.\n */\n name: string\n /**\n * A reference to the id of the Node that this package is linked from.\n */\n fromID?: DepID\n /**\n * The dependency spec definition for this package.\n */\n spec?: string\n /**\n * The package type.\n */\n type?: EdgeLike['type']\n /**\n * A representation of the package object that fulfills this dependency.\n */\n to?: NodeLike\n}\n\nexport type JSONOutputGraph = {\n edges: EdgeLike[]\n nodes: NodeLike[]\n}\n\n/**\n * Returns a JSON string representation of the graph.\n */\nexport function jsonOutput({ edges, nodes }: JSONOutputGraph) {\n const res: JSONOutputItem[] = []\n\n // Collects importer nodes as edgeless json output items\n for (const node of nodes) {\n if (node.importer) {\n res.push({\n /* c8 ignore next - name can't be missing but ts won't know */\n name: node.name || node.id,\n to: node,\n })\n }\n }\n\n // Collects edge & it's linked nodes as json output items\n for (const edge of edges) {\n res.push({\n name: edge.name,\n fromID: edge.from.id,\n spec: String(edge.spec),\n type: edge.type,\n to: edge.to,\n })\n }\n\n return res\n}\n", "import { splitDepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '../types.ts'\nimport type { ChalkInstance } from 'chalk'\n\nconst chars = new Map(\n Object.entries({\n connection: '\u2500',\n down: '\u2502',\n 'last-child': '\u2514',\n 'middle-child': '\u251C',\n t: '\u252C',\n }),\n)\n\nexport type TreeItem = {\n name?: string | null\n edge: EdgeLike | undefined\n node: NodeLike | undefined\n prefix: string\n padding: string\n hasSibling: boolean\n deduped: boolean\n include: boolean\n parent: TreeItem | undefined\n}\n\nexport type HumanReadableOutputGraph = {\n edges: EdgeLike[]\n importers: Set<NodeLike>\n nodes: NodeLike[]\n highlightSelection?: boolean\n}\n\nexport type EdgeMap = Map<NodeLike | undefined, TreeItem>\n\nexport type TreeMap = Map<EdgeLike | undefined, EdgeMap>\n\nconst isSelected = (\n options: HumanReadableOutputGraph,\n edge?: EdgeLike,\n node?: NodeLike,\n) =>\n !!(\n (!node || options.nodes.includes(node)) &&\n (!edge || options.edges.includes(edge))\n )\n\n/**\n * Returns a map of tree items to be printed.\n */\nconst getTreeItems = (\n initialItems: Set<TreeItem>,\n options: HumanReadableOutputGraph,\n) => {\n const seenNodes = new Set<NodeLike>()\n const treeItems: TreeMap = new Map()\n const traverse = new Set<TreeItem>(initialItems)\n for (const item of traverse) {\n if (item.node) {\n if (seenNodes.has(item.node)) {\n item.deduped = true\n continue\n }\n seenNodes.add(item.node)\n const edges = [...item.node.edgesOut.values()].sort(i =>\n Number(i.to?.importer),\n )\n for (const edge of edges) {\n const toItems: EdgeMap =\n treeItems.get(edge) ?? (new Map() as EdgeMap)\n const nextItem: TreeItem = {\n edge,\n node: edge.to,\n hasSibling: false,\n padding: '',\n prefix: '',\n deduped: false,\n include: isSelected(options, edge, edge.to),\n parent: item,\n }\n toItems.set(edge.to, nextItem)\n treeItems.set(edge, toItems)\n traverse.add(nextItem)\n }\n }\n }\n for (const item of [...traverse].reverse()) {\n if (item.include && item.parent) {\n item.parent.include = true\n }\n }\n return treeItems\n}\n\n/**\n * Returns a human-readable output of the graph.\n */\nexport function humanReadableOutput(\n options: HumanReadableOutputGraph,\n { colors }: { colors?: ChalkInstance },\n) {\n const { importers } = options\n const noop = (s?: string | null) => s\n const {\n dim = noop,\n red = noop,\n reset = noop,\n yellow = noop,\n } = colors ?? {}\n const initialItems = new Set<TreeItem>()\n for (const importer of importers) {\n initialItems.add({\n name: importer.name,\n edge: undefined,\n node: importer,\n prefix: '',\n padding: '',\n hasSibling: false,\n deduped: false,\n include: isSelected(options, undefined, importer),\n parent: undefined,\n })\n }\n const treeItems = getTreeItems(initialItems, options)\n\n let res = ''\n const traverse = (item: TreeItem) => {\n let header = ''\n let content = ''\n\n const depIdTuple = item.node?.id && splitDepID(item.node.id)\n const hasCustomReg =\n depIdTuple?.[0] === 'registry' && depIdTuple[1]\n const name =\n hasCustomReg ? `${depIdTuple[1]}:${item.name}` : item.name\n const decoratedName =\n (\n options.highlightSelection &&\n isSelected(options, item.edge, item.node)\n ) ?\n yellow(name)\n : name\n if (!item.node && item.include) {\n const missing =\n item.edge?.type.endsWith('ptional') ?\n dim('(missing optional)')\n : red('(missing)')\n return `${item.padding}${item.prefix}${decoratedName} ${missing}\\n`\n }\n\n const deduped = item.deduped ? ` ${dim('(deduped)')}` : ''\n header += `${item.padding}${item.prefix}${decoratedName}${deduped}\\n`\n\n // deduped items need not to be printed or traversed\n if (!item.deduped) {\n const edges = item.node ? [...item.node.edgesOut.values()] : []\n const nextItems = edges.map(i => treeItems.get(i)?.get(i.to))\n const includedItems = nextItems.filter(i => i?.include)\n\n for (const nextItem of nextItems) {\n /* c8 ignore next -- impossible but TS doesn't know that */\n if (!nextItem) continue\n\n const parent = item\n const isLast =\n includedItems.indexOf(nextItem) === includedItems.length - 1\n const toName =\n nextItem.node?.version ?\n `${nextItem.node.name}@${nextItem.node.version}`\n : nextItem.node?.name\n const nextChar = isLast ? 'last-child' : 'middle-child'\n\n nextItem.name =\n (\n nextItem.node?.name &&\n nextItem.edge?.name !== nextItem.edge?.to?.name\n ) ?\n `${nextItem.edge?.name} (${toName})`\n : `${nextItem.edge?.name}@${nextItem.node?.version || nextItem.edge?.spec.bareSpec}`\n nextItem.padding =\n parent.prefix.length ?\n `${parent.padding}${parent.hasSibling ? chars.get('down') : ' '} `\n : ''\n nextItem.prefix = `${chars.get(nextChar)}${chars.get('connection')}${chars.get('connection')} `\n nextItem.hasSibling = !isLast\n\n content += traverse(nextItem)\n }\n }\n\n const regularConnection = `${chars.get('connection')} `\n const parentConnection = `${chars.get('t')} `\n return item.include ?\n `${content ? header.replace(regularConnection, parentConnection) : header}${content}`\n : ''\n }\n\n for (const item of initialItems) {\n res += traverse(item)\n }\n return reset(res)\n}\n", "import { splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { parse, Version } from '@vltpkg/semver'\nimport { Spec } from '@vltpkg/spec'\nimport type { GitSelectorParsed } from '@vltpkg/spec'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { relative, resolve } from 'node:path'\n\n/**\n * Return true if the node referenced by this DepID would satisfy the\n * supplied Spec object.\n */\nexport const satisfies = (\n id: DepID | undefined,\n spec: Spec,\n fromLocation = process.cwd(),\n projectRoot = process.cwd(),\n monorepo?: Monorepo,\n): boolean =>\n !!id &&\n satisfiesTuple(\n splitDepID(id),\n spec,\n fromLocation,\n projectRoot,\n monorepo,\n )\n\nexport const satisfiesTuple = (\n tuple: DepIDTuple,\n spec: Spec,\n fromLocation = process.cwd(),\n projectRoot = process.cwd(),\n monorepo?: Monorepo,\n): boolean => {\n const { options } = spec\n spec = spec.final\n const [type, first, second] = tuple\n if (spec.type !== type) return false\n\n switch (spec.type) {\n case 'registry': {\n if (!first) {\n // must be from the default registry\n if (spec.registry !== options.registry) {\n return false\n }\n } else {\n const namedRegistry = options.registries[first]\n if (namedRegistry && namedRegistry !== spec.registry) {\n // we know the name, and it's not the registry being used\n return false\n } else if (!namedRegistry && first !== spec.registry) {\n // an explicit registry URL, but does not match\n return false\n }\n }\n /* c8 ignore next */\n if (!second) throw error('Invalid DepID', { found: tuple })\n const [name, version] = parseNameVer(second)\n return (\n // mismatched name always invalid\n name !== spec.name || !version ? false\n // if just a dist-tag, assume valid\n : !spec.range ? true\n : spec.range.test(Version.parse(version))\n )\n }\n\n case 'file': {\n /* c8 ignore next - should be impossible */\n if (spec.file === undefined) return false\n const resolvedSpec = resolve(\n projectRoot,\n fromLocation,\n spec.file,\n )\n const resolvedId = resolve(projectRoot, first)\n // valid if the relative path is '', refers to the same path\n return !relative(resolvedSpec, resolvedId)\n }\n\n case 'workspace': {\n monorepo ??= Monorepo.load(projectRoot)\n /* c8 ignore next */\n if (!spec.workspace) return false\n const fromID = monorepo.get(first)\n const fromSpec = monorepo.get(spec.workspace)\n if (fromID !== fromSpec || !fromSpec || !fromID) return false\n if (!spec.range) return true\n const v = parse(fromID.manifest.version ?? '')\n return !!v && spec.range.test(v)\n }\n\n case 'remote': {\n return spec.remoteURL === first\n }\n\n case 'git': {\n const {\n gitRemote,\n gitSelectorParsed = {},\n gitSelector,\n gitCommittish,\n namedGitHost,\n namedGitHostPath,\n } = spec\n if (gitRemote !== first) {\n if (namedGitHost && namedGitHostPath) {\n const ngh = `${namedGitHost}:`\n if (first.startsWith(ngh)) {\n if (first !== ngh + namedGitHostPath) return false\n } else return false\n } else return false\n }\n if (gitSelector && !second) return false\n /* c8 ignore next - always set to something, even if empty */\n const [parsed, committish] = Spec.parseGitSelector(second ?? '')\n if (gitCommittish && committish)\n return !!committish.startsWith(gitCommittish)\n for (const [k, v] of Object.entries(gitSelectorParsed)) {\n if (parsed[k as keyof GitSelectorParsed] !== v) return false\n }\n return true\n }\n\n /* c8 ignore start */\n default: {\n throw error('Invalid spec type', { spec })\n }\n }\n /* c8 ignore stop */\n}\n\nconst parseNameVer = (nv: string): [string, string] => {\n const at = nv.lastIndexOf('@')\n // if it's 0, means @scoped without a version\n return at <= 0 ?\n [nv, '']\n : [nv.substring(0, at), nv.substring(at + 1)]\n}\n", "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 } 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", "import { error } from '@vltpkg/error-cause'\nimport { Spec } from '@vltpkg/spec/browser'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\n\nexport const delimiter: Delimiter = '\u00B7'\nexport type Delimiter = '\u00B7'\n\n/**\n * Dependency IDs are a URI-encoded set of strings, separated\n * by the {@link Delimiter} character (`'\u00B7'`).\n *\n * The first entry is always the specifier type. The rest depend on the\n * type. `git`, `registry`, and `workspace` entries have 3 fields, the rest\n * have 2.\n *\n * - `registry`: `'registry\u00B7<registry>\u00B7name@specifier'`\n * The `<registry>` portion can be a known named registry name, or a\n * url to a registry. If empty, it is the default registry. Examples:\n * - `\u00B7\u00B7some-package@2.0.1`\n * - `\u00B7npm\u00B7whatever@1.2.3`\n * - `\u00B7http%3A%2F%2Fvlt.sh%2F\u00B7x@1.2.3`\n * - `git`: `'git\u00B7<git remote>\u00B7<git selector>'`. For example:\n * - `git\u00B7github:user/project\u00B7branchname`\n * - `git\u00B7git%2Bssh%3A%2F%2Fuser%40host%3Aproject.git\u00B7semver:1.x`\n * - `workspace`: `'workspace\u00B7<path>'`. For example:\n * - `workspace\u00B7src/mything`\n * - `remote`: `'remote\u00B7<url>'`\n * - `file`: `'file\u00B7<path>'`\n *\n * Lastly, the final portion can contain arbitrary string data, and is\n * used to store peer dep resolutions to maintain the peerDep contract.\n */\nexport type DepID =\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}${Delimiter}${string}`\n | `${'' | 'git'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}${Delimiter}${string}`\n | `${'file' | 'remote' | 'workspace'}${Delimiter}${string}`\n\n/**\n * A {@link DepID}, split apart and URI-decoded\n */\nexport type DepIDTuple =\n | [\n type: 'git',\n gitRemote: string,\n gitSelector: string,\n extra?: string,\n ]\n | [\n type: 'registry',\n registry: string,\n registrySpec: string,\n extra?: string,\n ]\n | [type: 'file', path: string, extra?: string]\n | [type: 'remote', url: string, extra?: string]\n | [type: 'workspace', workspace: string, extra?: string]\n\nconst depIDRegExp = new RegExp(\n `^((git)?${delimiter}[^${delimiter}]*${delimiter}[^${delimiter}]*(${\n delimiter\n }[^${delimiter}]*)?$` +\n `|` +\n `^(file|remote|workspace)${delimiter}[^${\n delimiter\n }]*)(${delimiter}[^${delimiter}]*)?$`,\n)\n\nexport const isDepID = (str: unknown): str is DepID =>\n typeof str === 'string' && depIDRegExp.test(str)\n\nexport const asDepID = (str: string): DepID => {\n if (!isDepID(str)) {\n throw error('Expected dep id', {\n found: str,\n })\n }\n return str\n}\n\n/**\n * turn a {@link DepIDTuple} into a {@link DepID}\n */\nexport const joinDepIDTuple = (list: DepIDTuple): DepID => {\n const [type, first, second, extra] = list\n const f = encode(first)\n switch (type) {\n case 'registry':\n return `${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n case 'git':\n return `${type}${delimiter}${f}${delimiter}${encode(second)}${extra ? `${delimiter}${encode(extra)}` : ''}`\n default:\n return `${type}${delimiter}${f}${second ? `${delimiter}${encode(second)}` : ''}`\n }\n}\n\n// allow @, but otherwise, escape everything urls do\nconst encode = (s: string): string =>\n encodeURIComponent(s)\n .replaceAll('%40', '@')\n .replaceAll('%2f', '\u00A7')\n .replaceAll('%2F', '\u00A7')\n\n/**\n * turn a {@link DepID} into a {@link DepIDTuple}\n */\nexport const splitDepID = (id: string): DepIDTuple => {\n const [type, first = '', second, extra] = id\n .replaceAll('\u00A7', '/')\n .split(delimiter, 4)\n const f = decodeURIComponent(first)\n switch (type) {\n case 'git':\n case '': {\n if (second === undefined) {\n throw error(`invalid ${type} id`, { found: id })\n }\n const t: DepIDTuple = [\n type || 'registry',\n f,\n decodeURIComponent(second),\n ]\n if (extra) t.push(decodeURIComponent(extra))\n return t\n }\n case 'file':\n case 'remote':\n case 'workspace': {\n const t: DepIDTuple = [type, f]\n if (second) t.push(decodeURIComponent(second))\n return t\n }\n default: {\n throw error('invalid DepID type', {\n found: type,\n validOptions: ['git', 'file', 'workspace', 'remote', ''],\n })\n }\n }\n}\n\n/**\n * Turn a {@link DepID} into a {@link Spec} object\n */\nexport const hydrate = (\n id: DepID,\n name?: string,\n options: SpecOptions = {},\n): Spec => hydrateTuple(splitDepID(id), name, options)\n\n/**\n * Turn a {@link DepIDTuple} into a {@link Spec} object\n */\nexport const hydrateTuple = (\n tuple: DepIDTuple,\n name?: string,\n options: SpecOptions = {},\n) => {\n const [type, first, second] = tuple\n switch (type) {\n case 'remote': {\n if (!first)\n throw error('no remoteURL found on remote id', {\n found: tuple,\n })\n return Spec.parse(name ?? '(unknown)', first)\n }\n case 'file': {\n if (!first) {\n throw error('no file path found on remote id', {\n found: tuple,\n })\n }\n return Spec.parse(name ?? '(unknown)', `file:${first}`, options)\n }\n case 'registry': {\n if (typeof first !== 'string') {\n throw error('no registry url or name in registry ID', {\n found: tuple,\n })\n }\n if (!second) {\n throw error('no name/specifier in registry ID', {\n found: tuple,\n })\n }\n if (!first) {\n // just a normal name@version on the default registry\n const s = Spec.parse(second)\n if (name && s.name !== name) {\n return Spec.parse(`${name}@npm:${second}`)\n } else {\n return s\n }\n }\n if (!/^https?:\\/\\//.test(first)) {\n const reg = options.registries?.[first]\n if (first !== 'npm' && !reg) {\n throw error('named registry not found in options', {\n name: first,\n found: tuple,\n })\n }\n return Spec.parse(\n name ?? '(unknown)',\n `${first}:${second}`,\n options,\n )\n }\n const s = Spec.parse(\n name ?? '(unknown)',\n `registry:${first}#${second}`,\n options,\n )\n return name && s.final.name !== name ?\n Spec.parse(s.final.name + '@' + s.bareSpec)\n : s\n }\n case 'git': {\n if (!first) {\n throw error('no git remote in git ID', {\n found: tuple,\n })\n }\n return Spec.parse(\n name ?? '(unknown)',\n first + '#' + second,\n options,\n )\n }\n case 'workspace': {\n if (!first) {\n throw error('no name/path on workspace id', { found: tuple })\n }\n return name && name !== first ?\n Spec.parse(name, `workspace:${first}@*`, options)\n : Spec.parse(first, `workspace:*`, options)\n }\n }\n}\n", "import { splitDepID } from '@vltpkg/dep-id/browser'\nimport type { NodeLike } from './types.ts'\n\nexport const stringifyNode = (node?: NodeLike) => {\n if (!node) return ''\n const version = node.version ? `@${node.version}` : ''\n const [type, ref, nameVersion] = splitDepID(node.id)\n\n if (type === 'registry') {\n const prefix = ref ? `${ref}:` : 'npm:'\n return `${prefix}${nameVersion}`\n } else if (type === 'workspace') {\n return `workspace:${node.name}`\n } else if (type === 'file' && node.mainImporter) {\n return `root:${node.name}`\n } else {\n // node.name getter will return the id if the package has no name\n // property so here we check for that in order to return `type(ref)` only\n const nameVersion =\n node.name !== node.id ? `:${node.name}${version}` : ''\n return `${type}(${ref})${nameVersion}`\n }\n}\n", "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\n this.version = version || this.manifest?.version\n if (this.version?.startsWith('v')) {\n this.version = this.version.slice(1)\n }\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", "import type { DepID } from '@vltpkg/dep-id'\nimport { Edge } from '../edge.ts'\nimport { Node } from '../node.ts'\nimport type { EdgeLike, NodeLike } from '../types.ts'\n\nexport type MermaidOutputGraph = {\n edges: EdgeLike[]\n importers: Set<NodeLike>\n nodes: NodeLike[]\n}\n\ntype TraverseItem = {\n self: EdgeLike | NodeLike\n parent: EdgeLike | NodeLike | undefined\n}\n\nlet missingCount = 0\n\nconst nodeLabel = (node: NodeLike) =>\n `\"${String(node).replaceAll('@', '#64;')}\"`\n\nfunction parseNode(\n seenNodes: Set<DepID>,\n includedItems: Map<EdgeLike | NodeLike, boolean>,\n node: NodeLike,\n) {\n if (seenNodes.has(node.id) || !includedItems.get(node)) {\n return ''\n }\n seenNodes.add(node.id)\n const edges: string = [...node.edgesOut.values()]\n .map(e => parseEdge(seenNodes, includedItems, e))\n .filter(Boolean)\n .join('\\n')\n return `${encodeURIComponent(node.id)}(${nodeLabel(node)})${edges.length ? '\\n' : ''}${edges}`\n}\n\nfunction parseEdge(\n seenNodes: Set<DepID>,\n includedItems: Map<EdgeLike | NodeLike, boolean>,\n edge: EdgeLike,\n) {\n if (!includedItems.get(edge)) {\n return ''\n }\n\n const edgeResult =\n `${encodeURIComponent(edge.from.id)}(${nodeLabel(edge.from)})` +\n ` -->|\"${String(edge.spec).replaceAll('@', '#64;')} (${edge.type})\"| `\n\n const missingLabel =\n edge.type.endsWith('ptional') ? 'Missing Optional' : 'Missing'\n if (!edge.to) {\n return edgeResult + `missing-${missingCount++}(${missingLabel})\\n`\n }\n\n return (\n edgeResult +\n `${encodeURIComponent(edge.to.id)}(${nodeLabel(edge.to)})\\n` +\n parseNode(seenNodes, includedItems, edge.to)\n )\n}\n\n/**\n * Returns a mermaid string representation of the graph.\n */\nexport function mermaidOutput({\n edges,\n importers,\n nodes,\n}: MermaidOutputGraph) {\n const seen = new Set<EdgeLike | NodeLike>()\n const includedItems = new Map<EdgeLike | NodeLike, boolean>()\n const traverse = new Set<TraverseItem>(\n [...importers].map(i => ({ self: i, parent: undefined })),\n )\n\n for (const item of traverse) {\n if (seen.has(item.self)) continue\n seen.add(item.self)\n\n if (item.self instanceof Edge) {\n if (edges.includes(item.self)) {\n includedItems.set(item.self, true)\n }\n if (item.self.to) {\n traverse.add({ self: item.self.to, parent: item.self })\n }\n }\n\n if (item.self instanceof Node) {\n if (nodes.includes(item.self)) {\n includedItems.set(item.self, true)\n }\n for (const edge of item.self.edgesOut.values()) {\n traverse.add({ self: edge, parent: item.self })\n }\n }\n }\n\n for (const item of [...traverse].reverse()) {\n if (includedItems.has(item.self) && item.parent) {\n includedItems.set(item.parent, true)\n }\n }\n\n return (\n 'flowchart TD\\n' +\n [...importers]\n .map(i => parseNode(new Set<DepID>(), includedItems, i))\n .join('\\n')\n )\n}\n", "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", "import { getId, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { Manifest, DependencyTypeShort } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n// this is always the same, but we don't hard code it as a string,\n// in case the DepID module needs to change its delimiter again ever.\nconst mainDepID = joinDepIDTuple(['file', '.'])\n\nexport type ManifestInventory = Map<DepID, Manifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: Manifest\n /**\n * An inventory of seen manifests.\n */\n manifests?: ManifestInventory\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * Root of the project this graph represents\n */\n projectRoot: string\n}\n\nexport class Graph implements GraphLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Graph'\n }\n\n #options: GraphOptions\n\n #nodeOptions: NodeOptions\n\n /**\n * A {@link Monorepo} instance, used for managing workspaces.\n */\n monorepo?: Monorepo\n\n /**\n * An inventory with all manifests related to an install.\n */\n manifests: ManifestInventory\n\n /**\n * A set of all edges in this graph.\n */\n edges = new Set<Edge>()\n\n /**\n * Map registered dep ids to the node that represent them in the graph.\n */\n nodes = new Map<DepID, Node>()\n\n /**\n * Map of nodes by their name\n */\n nodesByName = new Map<string, Set<Node>>()\n\n /**\n * Cached resolutions for spec lookups\n */\n resolutions = new Map<string, Node>()\n\n /**\n * Reverse map of resolutions\n */\n resolutionsReverse = new Map<Node, Set<string>>()\n\n /**\n * A set of importer nodes in this graph.\n */\n importers = new Set<Node>()\n\n /**\n * The {@link Node} that represents the project root `package.json`.\n */\n mainImporter: Node\n\n /**\n * A set of extraneous dependencies found when building the graph.\n */\n extraneousDependencies = new Set<Edge>()\n\n /**\n * The root of the project this graph represents\n */\n projectRoot: string\n\n constructor(options: GraphOptions) {\n const { mainManifest, monorepo } = options\n this.#options = options\n this.manifests = getMap(options.manifests)\n this.projectRoot = options.projectRoot\n this.#nodeOptions = {\n ...this.#options,\n graph: this,\n }\n\n // add the project root node\n const mainImporterLocation = '.'\n const mainImporterSpec = Spec.parse(\n mainManifest.name || '(root)',\n mainImporterLocation,\n )\n const mainImporter = this.addNode(\n mainDepID,\n mainManifest,\n mainImporterSpec,\n )\n mainImporter.setImporterLocation(mainImporterLocation)\n mainImporter.mainImporter = true\n this.mainImporter = mainImporter\n this.importers.add(mainImporter)\n this.manifests.set(mainImporter.id, mainManifest)\n\n // uses the monorepo instance in order to retrieve info on\n // workspaces and create importer nodes for each of them\n this.monorepo = monorepo\n if (this.monorepo) {\n for (const ws of this.monorepo) {\n const wsNode = this.addNode(\n ws.id,\n ws.manifest,\n undefined,\n ws.name,\n )\n wsNode.setImporterLocation(`./${ws.path}`)\n if (wsNode.manifest) {\n this.manifests.set(wsNode.id, wsNode.manifest)\n }\n this.importers.add(wsNode)\n }\n }\n }\n\n /**\n * Delete all nodes that are unreachable from the importers.\n * The collection of deleted nodes is returned.\n *\n * NOTE: This can be extremely slow for large graphs, and is almost always\n * unnecessary! Only call when it is known that some unreachable nodes may\n * have been created, for example when deleting the unneeded subgraph when an\n * optional node fails to resolve/install.\n */\n gc() {\n const { nodes } = this\n this.nodes = new Map()\n const marked = new Set(this.importers)\n for (const imp of marked) {\n // don't delete the importer!\n nodes.delete(imp.id)\n this.nodes.set(imp.id, imp)\n for (const { to } of imp.edgesOut.values()) {\n if (!to || marked.has(to)) continue\n marked.add(to)\n nodes.delete(to.id)\n this.nodes.set(to.id, to)\n }\n }\n for (const node of nodes.values()) {\n this.removeNode(node)\n }\n return nodes\n }\n\n /**\n * Create a new edge between two nodes of the graph in case both exist,\n * in case the destination node does not exists, then a dangling edge,\n * pointing to nothing will be created to represent that missing dependency.\n */\n addEdge(\n type: DependencyTypeShort,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) {\n // fix any nameless spec\n if (spec.name === '(unknown)') {\n if (to) {\n spec.name = to.name /* c8 ignore next */ || '(unknown)'\n spec.spec = `${to.name}@${spec.bareSpec}`\n } else {\n throw error(\n 'Impossible to place a missing, nameless dependency',\n { spec },\n )\n }\n }\n const existing = from.edgesOut.get(spec.name)\n if (existing) {\n const edge = existing as Edge\n if (\n edge.type === type &&\n edge.spec.bareSpec === spec.bareSpec\n ) {\n if (to && to !== edge.to) {\n edge.to = to as Node\n edge.to.edgesIn.add(edge)\n }\n return edge\n }\n this.edges.delete(edge)\n }\n const f = from as Node\n const edgeOut = f.addEdgesTo(type, spec, to as Node | undefined)\n this.edges.add(edgeOut)\n return edgeOut\n }\n\n /**\n * Find an existing node to satisfy a dependency\n */\n findResolution(spec: Spec, fromNode: Node) {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPref =\n f.type === 'file' ? fromNode.location + ' : ' : ''\n const sf = fromPref + String(f)\n const cached = this.resolutions.get(sf)\n if (cached) return cached\n const nbn = this.nodesByName.get(f.name)\n if (!nbn) return undefined\n for (const node of nbn) {\n if (\n satisfies(\n node.id,\n f,\n fromNode.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n this.resolutions.set(sf, node)\n // always set by now, because the node was added at some point\n this.resolutionsReverse.get(node)?.add(sf)\n return node\n }\n }\n }\n\n /**\n * Create a new node in the graph.\n */\n addNode(\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n const node = new Node(\n this.#nodeOptions,\n id,\n manifest,\n spec,\n name,\n version,\n )\n this.nodes.set(node.id, node)\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n this.nodesByName.set(node.name, nbn)\n if (spec) {\n const f = String(spec.final)\n // if it's a file: type, then that is fromNode-specific,\n // so we can't shortcut add it here.\n if (spec.final.type !== 'file') {\n this.resolutions.set(f, node)\n const rrev = this.resolutionsReverse.get(node) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(node, rrev)\n }\n }\n if (manifest) {\n this.manifests.set(node.id, manifest)\n }\n return node\n }\n\n /**\n * Place a new package into the graph representation, creating the new\n * edges and possibly new nodes that are to be expected when traversing\n * the graph in a top-down direction, e.g: from importers to leafs.\n *\n * For different uses that are not a direct top-down traversal of the graph\n * consider using `addNode()` and `addEdge()` instead.\n */\n placePackage(\n fromNode: Node,\n depType: DependencyTypeShort,\n spec: Spec,\n manifest?: Manifest,\n id?: DepID,\n ) {\n // if no manifest is available, then create an edge that has no\n // reference to any other node, representing a missing dependency\n if (!manifest && !id) {\n this.addEdge(depType, spec, fromNode)\n return\n }\n\n // flags set on the node we're about to create or find.\n const flags = {\n dev: fromNode.dev || depType === 'dev',\n optional:\n fromNode.optional ||\n depType === 'optional' ||\n depType === 'peerOptional',\n }\n\n const depId = id || (manifest && getId(spec, manifest))\n\n /* c8 ignore start - should not be possible */\n if (!depId) {\n throw error('Could not find dep id when placing package', {\n spec,\n manifest,\n })\n }\n /* c8 ignore stop */\n\n // if a node for this package is already represented by a node\n // in the graph, then just creates a new edge to that node\n const toFoundNode = this.nodes.get(depId)\n if (toFoundNode) {\n this.addEdge(depType, spec, fromNode, toFoundNode)\n // the current only stays dev/optional if this dep lets it remain so\n // if it's not already, we don't make it dev or optional.\n toFoundNode.dev &&= flags.dev\n toFoundNode.optional &&= flags.optional\n return toFoundNode\n }\n\n // creates a new node and edges to its parent\n const toNode = this.addNode(depId, manifest)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n this.addEdge(depType, spec, fromNode, toNode)\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * If a replacement is provided, then any edges that were previously\n * pointing to the removed node will be directed to the replacement,\n * if it is valid to do so.\n */\n removeNode(node: Node, replacement?: Node) {\n this.nodes.delete(node.id)\n const nbn = this.nodesByName.get(node.name)\n // if it's the last one, just remove the set\n if (nbn?.size === 1) this.nodesByName.delete(node.name)\n else nbn?.delete(node)\n for (const r of this.resolutionsReverse.get(node) ?? new Set()) {\n this.resolutions.delete(r)\n }\n this.resolutionsReverse.delete(node)\n this.manifests.delete(node.id)\n for (const edge of node.edgesOut.values()) {\n this.edges.delete(edge)\n }\n for (const edge of node.edgesIn) {\n if (\n replacement &&\n satisfies(\n replacement.id,\n edge.spec,\n edge.from.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n edge.to = replacement\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n toJSON() {\n return lockfileData({\n ...this.#options,\n graph: this,\n saveManifests: true,\n })\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const data = this.toJSON()\n return `${this[Symbol.toStringTag]} ${inspect(data, options)}`\n }\n}\n", "import type { DepID } from '@vltpkg/dep-id'\nimport {\n defaultRegistry,\n defaultRegistries,\n defaultGitHosts,\n defaultGitHostArchives,\n defaultScopeRegistries,\n} from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport type { Edge } from '../edge.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport { getFlagNumFromNode } from './types.ts'\nimport type {\n LockfileData,\n LockfileEdgeKey,\n LockfileEdges,\n LockfileEdgeValue,\n LockfileNode,\n} from './types.ts'\n\nexport type SaveOptions = SpecOptions & {\n /**\n * The graph to be stored in the lockfile.\n */\n graph: Graph\n /**\n * Should it save manifest data in the lockfile?\n */\n saveManifests?: boolean\n}\n\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n registry?: string,\n) => {\n // we do not store importers in the lockfile, though we do store\n // their edges. when we load, we always read workspaces/main fresh.\n const arr: Node[] = [...nodes].filter(node => !node.importer)\n // nodes are sorted in order to have a deterministic result\n const orderedNodes: Node[] = arr.sort((a, b) =>\n a.id.localeCompare(b.id, 'en'),\n )\n\n const res: Record<DepID, LockfileNode> = {}\n for (const node of orderedNodes) {\n const customRegistry =\n node.resolved && registry && !node.resolved.startsWith(registry)\n const resolved = customRegistry ? node.resolved : undefined\n // if it's in a location other than the default, stash that\n const location =\n (\n node.id.startsWith('file') ||\n node.location.endsWith(\n '/node_modules/.vlt/' +\n node.id +\n '/node_modules/' +\n node.name,\n )\n ) ?\n undefined\n : node.location\n\n const flags = getFlagNumFromNode(node)\n const lockfileNode: LockfileNode = [flags, node.name]\n\n if (node.integrity) {\n lockfileNode[2] = node.integrity\n }\n\n if (resolved) {\n lockfileNode[3] = resolved\n }\n\n if (location) {\n lockfileNode[4] = location\n }\n\n if (saveManifests) {\n lockfileNode[5] = node.manifest\n }\n\n res[node.id] = lockfileNode\n }\n return res\n}\n\nconst formatEdges = (edges: Set<Edge>): LockfileEdges =>\n Object.fromEntries(\n [...edges]\n .sort(\n (a, b) =>\n /* c8 ignore start - nondeterminstic and annoying to test */\n // sort importers to the top, then alphabetically by\n // id, type, target\n Number(b.from.importer) - Number(a.from.importer) ||\n a.from.id.localeCompare(b.from.id, 'en') ||\n a.type.localeCompare(b.type, 'en') ||\n (a.to?.id ?? '').localeCompare(b.to?.id ?? ''),\n /* c8 ignore stop */\n )\n .map((edge): [LockfileEdgeKey, LockfileEdgeValue] => [\n `${edge.from.id} ${edge.spec.name}`,\n `${edge.type} ${edge.spec.bareSpec || '*'} ${edge.to?.id ?? 'MISSING'}`,\n ]),\n )\n\nconst isRecordStringString = (\n registries: unknown,\n): registries is Record<string, string> =>\n !(!registries || typeof registries === 'string')\n\nconst removeDefaultItems = (\n defaultItems: Record<string, string>,\n items: Record<string, string>,\n) => {\n const res: Record<string, string> = {}\n for (const [key, value] of Object.entries(items)) {\n if (!defaultItems[key] || defaultItems[key] !== value) {\n res[key] = value\n }\n }\n return res\n}\n\nexport const lockfileData = ({\n graph,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n registry,\n registries,\n saveManifests,\n 'scope-registries': scopeRegistries,\n}: SaveOptions): LockfileData => {\n const cleanGitHosts =\n isRecordStringString(gitHosts) ?\n removeDefaultItems(defaultGitHosts, gitHosts)\n : undefined\n const cleanGitHostArchives =\n isRecordStringString(gitHostArchives) ?\n removeDefaultItems(defaultGitHostArchives, gitHostArchives)\n : undefined\n const cleanRegistries =\n isRecordStringString(registries) ?\n removeDefaultItems(defaultRegistries, registries)\n : undefined\n const cleanScopeRegistries =\n isRecordStringString(scopeRegistries) ?\n removeDefaultItems(defaultScopeRegistries, scopeRegistries)\n : undefined\n const hasItems = (clean: Record<string, string> | undefined) =>\n clean && Object.keys(clean).length\n return {\n options: {\n ...(hasItems(cleanScopeRegistries) ?\n { 'scope-registries': cleanScopeRegistries }\n : undefined),\n ...(registry !== undefined && registry !== defaultRegistry ?\n { registry }\n : undefined),\n ...(hasItems(registries) ?\n { registries: cleanRegistries }\n : undefined),\n ...(hasItems(cleanGitHosts) ?\n { 'git-hosts': cleanGitHosts }\n : undefined),\n ...(hasItems(cleanGitHostArchives) ?\n { 'git-host-archives': cleanGitHostArchives }\n : undefined),\n },\n nodes: formatNodes(graph.nodes.values(), saveManifests, registry),\n edges: formatEdges(graph.edges),\n }\n}\n\n// renders each node / edge as a single line entry\nconst extraFormat = (jsonString: string) => {\n const str = `${jsonString}\\n`\n const [init, ...parts] = str.split(' \"nodes\": {')\n const res = [init]\n for (const part of parts) {\n res.push(\n part.replaceAll('\\n ', '').replaceAll('\\n ]', ']'),\n )\n }\n return res.join(' \"nodes\": {')\n}\n\nexport const saveData = (\n data: LockfileData,\n fileName: string,\n saveManifests = false,\n) => {\n const json = JSON.stringify(data, null, 2)\n const content = saveManifests ? json : extraFormat(json)\n writeFileSync(fileName, content)\n}\n\nexport const save = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: false })\n const fileName = resolve(graph.projectRoot, 'vlt-lock.json')\n return saveData(data, fileName, false)\n}\n\nexport const saveHidden = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: true })\n const fileName = resolve(\n graph.projectRoot,\n 'node_modules/.vlt-lock.json',\n )\n mkdirSync(dirname(fileName), { recursive: true })\n return saveData(data, fileName, true)\n}\n", "import type { DepID } from '@vltpkg/dep-id'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Graph } from '../graph.ts'\n\n/**\n * This is the main type definition for the contents of the\n * `vlt-lock.json` file.\n *\n * The nodes and edges information from the lockfile are used to reconstruct\n * a {@link Graph} representing a previous install.\n */\nexport type LockfileData = {\n options: SpecOptions\n nodes: Record<DepID, LockfileNode>\n edges: LockfileEdges\n}\n\nexport const getFlagNumFromNode = (node: {\n optional?: boolean\n dev?: boolean\n}) =>\n node.optional && node.dev ? LockfileNodeFlagDevOptional\n : node.optional ? LockfileNodeFlagOptional\n : node.dev ? LockfileNodeFlagDev\n : LockfileNodeFlagNone\n\nexport const getBooleanFlagsFromNum = (flags: LockfileNodeFlags) => ({\n dev: !!(flags & LockfileNodeFlagDev),\n optional: !!(flags & LockfileNodeFlagOptional),\n})\n\nexport const LockfileNodeFlagNone = 0\nexport const LockfileNodeFlagOptional = 1\nexport const LockfileNodeFlagDev = 2\nexport const LockfileNodeFlagDevOptional = 3\n\n/**\n * Bit flags indicating whether a node is optional and/or dev.\n */\nexport type LockfileNodeFlags = 0 | 1 | 2 | 3\n\n/**\n * Lockfile representation of a node from the install graph.\n */\nexport type LockfileNode = [\n flags: LockfileNodeFlags,\n name?: string | null,\n integrity?: Integrity | null,\n resolved?: string | null,\n location?: string | null,\n manifest?: Manifest | null,\n]\n\n/**\n * Lockfile edges are stored as a record object where the key\n * is `${from.id} ${spec.name}` and the value is\n * `${type} ${spec.bareSpec} ${to.id | 'MISSING'}`\n *\n * Storing them in a record like this means that we are guaranteed to\n * never end up with duplicates, and a standard `JSON.stringify()`\n * will nicely print them out one line per edge.\n */\nexport type LockfileEdges = {\n [key: LockfileEdgeKey]: LockfileEdgeValue\n}\n\n/** `${from} ${dep name}` */\nexport type LockfileEdgeKey = `${DepID} ${string}`\n\n/** `${type} ${spec} ${to}` */\nexport type LockfileEdgeValue =\n `${DependencyTypeShort} ${Spec['bareSpec']} ${DepID | 'MISSING'}`\n", "import { PackageJson } from '@vltpkg/package-json'\nimport type { Manifest } from '@vltpkg/types'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport type { PathScurry } from 'path-scurry'\nimport { loadEdges } from './load-edges.ts'\nimport { loadNodes } from './load-nodes.ts'\nimport { Graph } from '../graph.ts'\nimport type { LockfileData } from './types.ts'\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\nconst loadLockfile = (projectRoot: string, lockfilePath: string) =>\n JSON.parse(\n readFileSync(resolve(projectRoot, lockfilePath), {\n encoding: 'utf8',\n }),\n ) as LockfileData\n\nexport const load = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'vlt-lock.json'),\n )\n}\n\nexport const loadHidden = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'),\n )\n}\n\nexport const loadObject = (\n options: LoadOptions,\n lockfileData: LockfileData,\n) => {\n const { mainManifest, scurry } = options\n const packageJson = options.packageJson ?? new PackageJson()\n const monorepo =\n options.monorepo ??\n Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry })\n const {\n 'scope-registries': scopeRegistries,\n registry,\n registries,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n } = lockfileData.options || {}\n const mergedOptions = {\n ...options,\n 'scope-registries': {\n ...options['scope-registries'],\n ...scopeRegistries,\n },\n registry: registry ?? options.registry,\n registries: {\n ...options.registries,\n ...registries,\n },\n 'git-hosts': {\n ...options['git-hosts'],\n ...gitHosts,\n },\n 'git-host-archives': {\n ...options['git-host-archives'],\n ...gitHostArchives,\n },\n }\n const graph = new Graph({\n ...mergedOptions,\n mainManifest,\n monorepo,\n })\n\n loadNodes(graph, lockfileData.nodes)\n loadEdges(graph, lockfileData.edges, mergedOptions)\n\n return graph\n}\n", "import { asDepID } from '@vltpkg/dep-id/browser'\nimport { error } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport { Spec } from '@vltpkg/spec/browser'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport { isDependencyTypeShort } from '../dependencies.ts'\nimport type { GraphLike } from '../types.ts'\nimport type {\n LockfileData,\n LockfileEdgeKey,\n LockfileEdgeValue,\n} from './types.ts'\n\nexport const loadEdges = (\n graph: GraphLike,\n edges: LockfileData['edges'],\n options: SpecOptions,\n) => {\n const entries = Object.entries(edges) as [\n LockfileEdgeKey,\n LockfileEdgeValue,\n ][]\n for (const [key, value] of entries) {\n const [fromId, specName] = fastSplit(key, ' ', 2)\n const [depType, valRest] = fastSplit(value, ' ', 2)\n const vrSplit = valRest?.lastIndexOf(' ') ?? -1\n // not a valid edge record\n /* c8 ignore start */\n if (!valRest || !depType || !fromId || !specName || vrSplit < 1) {\n continue\n }\n /* c8 ignore stop */\n const spec = Spec.parse(\n specName,\n valRest.substring(0, vrSplit),\n options,\n )\n const toId = valRest.substring(vrSplit + 1)\n const from = graph.nodes.get(asDepID(fromId))\n if (!from) {\n throw error('Edge info missing its `from` node', {\n found: {\n nodes: [...graph.nodes].map(([id]) => id),\n from,\n fromId,\n edge: { [key]: value },\n },\n })\n }\n const to =\n toId === 'MISSING' ? undefined : graph.nodes.get(asDepID(toId))\n if (!isDependencyTypeShort(depType)) {\n throw error('Found unsupported dependency type in lockfile', {\n validOptions: [...longDependencyTypes],\n })\n }\n graph.addEdge(depType, spec, from, to)\n }\n}\n", "import { splitDepID } from '@vltpkg/dep-id/browser'\nimport { getBooleanFlagsFromNum } from './types.ts'\nimport type { LockfileData, LockfileNode } from './types.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { GraphLike } from '../types.ts'\n\nexport const loadNodes = (\n graph: GraphLike,\n nodes: LockfileData['nodes'],\n) => {\n const entries = Object.entries(nodes) as [DepID, LockfileNode][]\n for (const [id, lockfileNode] of entries) {\n // workspace nodes and the project root node are already part of the\n // graph and it should not create new nodes if an existing one is there\n if (graph.nodes.has(id)) continue\n\n const [flags, name, integrity, resolved, location, manifest] =\n lockfileNode\n const [type, , spec] = splitDepID(id)\n\n // if the lockfile has manifest data then it should just use that\n // otherwise tries to infer name / version value from the lockfile node\n const node =\n manifest ?\n graph.addNode(id, manifest)\n : graph.addNode(\n id,\n undefined,\n undefined,\n name ?? undefined,\n type === 'registry' && spec.indexOf('@') > 0 ?\n spec.split('@').slice(-1)[0]\n : undefined,\n )\n\n const { dev, optional } = getBooleanFlagsFromNum(flags)\n node.dev = dev\n node.optional = optional\n node.integrity = integrity ?? undefined\n node.resolved = resolved ?? undefined\n if (!node.resolved) node.setResolved()\n if (location) node.location = location\n }\n}\n", "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", "import { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\n\nexport type RemoveSatisfiedSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions\n\n/**\n * Traverse the objects defined in `add` and removes any references to specs\n * that are already satisfied by the contents of the actual `graph`.\n */\nexport const removeSatisfiedSpecs = ({\n add,\n graph,\n}: RemoveSatisfiedSpecsOptions) => {\n for (const [depID, dependencies] of add.entries()) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Referred importer node id could not be found', {\n found: depID,\n })\n }\n for (const [name, dependency] of dependencies) {\n const edge = importer.edgesOut.get(name)\n if (!edge) {\n // brand new edge being added\n continue\n }\n\n // If the current graph edge is already valid, then we remove that\n // dependency item from the list of items to be added to the graph\n if (\n satisfies(\n edge.to?.id,\n dependency.spec,\n edge.from.location,\n graph.projectRoot,\n graph.monorepo,\n )\n ) {\n dependencies.delete(name)\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [depID, dependencies] of add.entries()) {\n if (dependencies.size === 0) {\n add.delete(depID)\n }\n }\n}\n", "import { error } from '@vltpkg/error-cause'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport { shorten, asDependency } from '../dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport type { Edge } from '../edge.ts'\nimport type { Node } from '../node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\n\nexport type GetImporterSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions\n\nconst hasDepName = (importer: Node, edge: Edge): boolean => {\n for (const depType of longDependencyTypes) {\n const listedDeps = importer.manifest?.[depType]\n if (listedDeps && Object.hasOwn(listedDeps, edge.name))\n return true\n }\n return false\n}\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\n/**\n * Given a {@link Graph} and a list of {@link Dependency}, merges the\n * dependencies info found in the graph importers and returns the add & remove\n * results as a Map in which keys are {@link DepID} of each importer node.\n */\nexport const getImporterSpecs = ({\n add,\n graph,\n remove,\n}: GetImporterSpecsOptions) => {\n const addResult: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const removeResult: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n\n // traverse the list of importers in the starting graph\n for (const importer of graph.importers) {\n // uses a Map keying to the spec.name in order to easily make sure there's\n // only a single dependency entry for a given dependency for each importer\n const addDeps = new Map<string, Dependency>()\n const removeDeps = new Set<string>()\n // if an edge from the graph is not listed in the manifest,\n // add that edge to the list of dependencies to be removed\n for (const edge of importer.edgesOut.values()) {\n if (\n !hasDepName(importer, edge) &&\n !add.get(importer.id)?.has(edge.name)\n ) {\n removeDeps.add(edge.name)\n removeResult.modifiedDependencies = true\n }\n }\n // if a dependency is listed in the manifest but not in the graph,\n // add that dependency to the list of dependencies to be added\n for (const depType of longDependencyTypes) {\n const deps = Object.entries(importer.manifest?.[depType] ?? {})\n for (const [depName, depSpec] of deps) {\n const edge = importer.edgesOut.get(depName)\n if (!edge?.to) {\n addDeps.set(\n depName,\n asDependency({\n spec: Spec.parse(depName, depSpec),\n type: shorten(depType, depName, importer.manifest),\n }),\n )\n }\n }\n }\n addResult.set(importer.id, addDeps)\n removeResult.set(importer.id, removeDeps)\n }\n\n // merges any provided specs to add to the current found results\n for (const [id, addDeps] of add.entries()) {\n const deps = addResult.get(id)\n if (!deps) {\n throw error('Not an importer', { found: id })\n }\n for (const [name, dep] of addDeps.entries()) {\n deps.set(name, dep)\n }\n }\n\n // Merges results from user-provided `remove` option with any remove\n // results found from comparing the manifest with the loaded graph\n for (const [key, removeSet] of remove) {\n const importerRemoveItem = removeResult.get(key)\n if (importerRemoveItem) {\n for (const depName of removeSet) {\n importerRemoveItem.add(depName)\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [key, removeItem] of removeResult) {\n if (removeItem.size === 0) {\n removeResult.delete(key)\n }\n }\n\n // removes already satisfied dependencies from the dependencies list\n removeSatisfiedSpecs({\n add: addResult,\n graph,\n })\n\n // set the modifiedDependencies flag if any\n // of the importers have modified dependencies\n for (const addDeps of addResult.values()) {\n if (addDeps.size > 0) {\n addResult.modifiedDependencies = true\n break\n }\n }\n\n return {\n add: addResult,\n remove: removeResult,\n }\n}\n", "import type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n/**\n * Remove the affected optional nodes starting from a given optional node\n * that failed to resolve/install.\n *\n * Removing these dependents will frequently leave optional *dependencies*\n * behind that are made unreachable from any project importer. For performance\n * reasons, `graph.gc()` is not called automatically by this method, since\n * multiple optional subgraphs may need to be removed in a single operation,\n * and the mark-and-sweep garbage collection (a) can be excessively expensive,\n * and (b) may need to communicate the set of garbage-collected nodes\n * for cleanup (as in the case of optional node build failures during\n * reification).\n */\nexport const removeOptionalSubgraph = (\n graph: Graph,\n startingNode: Node & { optional: true },\n) => {\n const removed = new Set<Node>()\n for (const node of findOptionalSubgraph(startingNode)) {\n graph.removeNode(node)\n removed.add(node)\n }\n return removed\n}\n\n/**\n * Given a starting node, this generator will walk back from the optional node\n * to all of its optional dependents, emitting each one, and skipping any\n * cycles.\n *\n * Note that when these are removed, it may create unreachable nodes in the\n * graph! Be sure to call `graph.gc()` if these are removed.\n */\nexport function* findOptionalSubgraph(\n node: Node & { optional: true },\n seen = new Set<Node & { optional: true }>(),\n): Generator<Node & { optional: true }, void> {\n // already visited, prevent looping\n if (seen.has(node)) return\n\n // the node itself is part of the subgraph, of course\n seen.add(node)\n yield node\n\n // and any of its dependents that are also optional\n for (const { from, optional } of node.edgesIn) {\n // if it's an optional *edge*, we don't need to remove it, because it\n // doesn't need the node anyway. But if the node is optional and the\n // dep isn't, then we do need to remove it.\n if (from.isOptional() && !optional) {\n for (const dep of findOptionalSubgraph(from, seen)) yield dep\n }\n }\n}\n", "import { joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type { DependencyTypeLong } from '@vltpkg/types'\nimport type { PathScurry } from 'path-scurry'\nimport { asDependency, shorten } from '../dependencies.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.ts'\n\ntype FileTypeInfo = {\n id: DepID\n path: string\n isDirectory: boolean\n}\n\n/**\n * Only install devDeps for git dependencies and importers\n * Everything else always gets installed\n */\nconst shouldInstallDepType = (\n node: Node,\n depType: DependencyTypeLong,\n) =>\n depType !== 'devDependencies' ||\n node.importer ||\n node.id.startsWith('git')\n\n/**\n * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.\n */\nconst getFileTypeInfo = (\n spec: Spec,\n fromNode: Node,\n scurry: PathScurry,\n): FileTypeInfo | undefined => {\n const f = spec.final\n if (f.type !== 'file') return\n\n /* c8 ignore start - should be impossible */\n if (!f.file) {\n throw error('no path on file specifier', { spec })\n }\n /* c8 ignore stop */\n\n // Given that both linked folders and local tarballs (both defined with\n // usage of the `file:` spec prefix) location needs to be relative to their\n // parents, build the expected path and use it for both location and id\n const target = scurry.cwd.resolve(fromNode.location).resolve(f.file)\n const path = target.relativePosix()\n const id = joinDepIDTuple(['file', path])\n\n return {\n path,\n id,\n isDirectory: !!target.lstatSync()?.isDirectory(),\n }\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\nexport const appendNodes = async (\n add: Map<string, Dependency>,\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n options: SpecOptions,\n seen: Set<DepID>,\n) => {\n /* c8 ignore next */\n if (seen.has(fromNode.id)) return\n seen.add(fromNode.id)\n\n await Promise.all(\n deps.map(async ({ spec, type }) => {\n // see if there's a satisfying node in the graph currently\n const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry)\n const existingNode = graph.findResolution(spec, fromNode)\n if (existingNode) {\n graph.addEdge(type, spec, fromNode, existingNode)\n return\n }\n const edgeOptional =\n type === 'optional' || type === 'peerOptional'\n const mani = await packageInfo\n .manifest(spec, { from: scurry.resolve(fromNode.location) })\n .catch((er: unknown) => {\n // optional deps ignored if inaccessible\n if (edgeOptional || fromNode.optional) {\n return undefined\n }\n throw er\n })\n\n // when an user is adding a nameless dependency, e.g: `github:foo/bar`,\n // `file:./foo/bar`, we need to update the `add` option value to set the\n // correct name once we have it, so that it can properly be stored in\n // the `package.json` file at the end of reify.\n if (mani?.name && spec.name === '(unknown)') {\n const s = add.get(String(spec))\n if (s) {\n // removes the previous, placeholder entry key\n add.delete(String(spec))\n // replaces spec with a version with the correct name\n spec = Spec.parse(mani.name, spec.bareSpec, options)\n // updates the add map with the fixed up spec\n const n = asDependency({\n ...s,\n spec,\n })\n add.set(mani.name, n)\n }\n }\n\n if (!mani) {\n if (!edgeOptional && fromNode.isOptional()) {\n // failed resolution of a non-optional dep of an optional node\n // have to clean up the dependents\n removeOptionalSubgraph(graph, fromNode)\n return\n } else if (edgeOptional) {\n // failed resolution of an optional dep, just ignore it,\n // nothing to prune because we never added it in the first place.\n return\n } else {\n throw error('failed to resolve dependency', {\n spec,\n from: fromNode.location,\n })\n }\n }\n\n const node = graph.placePackage(\n fromNode,\n type,\n spec,\n mani,\n fileTypeInfo?.id,\n )\n\n /* c8 ignore start - not possible, already ensured manifest */\n if (!node) {\n throw error('failed to place package', {\n from: fromNode.location,\n spec,\n })\n }\n /* c8 ignore stop */\n\n if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {\n node.location = fileTypeInfo.path\n }\n node.setResolved()\n const nestedAppends: Promise<unknown>[] = []\n\n const bundleDeps = node.manifest?.bundleDependencies\n const bundled = new Set<string>(\n (\n node.id.startsWith('git') ||\n node.importer ||\n !isStringArray(bundleDeps)\n ) ?\n []\n : bundleDeps,\n )\n\n const nextDeps: Dependency[] = []\n\n for (const depTypeName of longDependencyTypes) {\n const depRecord: Record<string, string> | undefined =\n mani[depTypeName]\n\n if (depRecord && shouldInstallDepType(node, depTypeName)) {\n for (const [name, bareSpec] of Object.entries(depRecord)) {\n if (bundled.has(name)) continue\n nextDeps.push({\n type: shorten(depTypeName, name, mani),\n spec: Spec.parse(name, bareSpec, {\n ...options,\n registry: spec.registry,\n }),\n })\n }\n }\n }\n\n if (nextDeps.length) {\n nestedAppends.push(\n appendNodes(\n add,\n packageInfo,\n graph,\n node,\n nextDeps,\n scurry,\n options,\n seen,\n ),\n )\n }\n await Promise.all(nestedAppends)\n }),\n )\n}\n", "import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport { appendNodes } from './append-nodes.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\n\nexport type AddNodesOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n }\n\n/**\n * Add new nodes in the given `graph` for dependencies specified at `add`.\n */\nexport const addNodes = async ({\n add,\n graph,\n packageInfo,\n scurry,\n ...specOptions\n}: AddNodesOptions) => {\n const seen = new Set<DepID>()\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const [depID, dependencies] of add) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n\n // Removes any edges and nodes that are currently part of the\n // graph but are also in the list of dependencies to be installed\n const deps = [...dependencies.values()]\n for (const { spec } of deps) {\n const node = importer.edgesOut.get(spec.name)?.to\n if (node) graph.removeNode(node)\n }\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n dependencies,\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n )\n }\n}\n", "import type {\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport { error } from '@vltpkg/error-cause'\n\nexport type RemoveNodesOptions = BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions\n\n/**\n * Remove nodes from the current `graph`.\n */\nexport const removeNodes = ({\n graph,\n remove,\n}: RemoveNodesOptions) => {\n for (const [depID, names] of remove) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n\n // Removes any edges / nodes pointing to the specified name\n for (const name of names) {\n const node = importer.edgesOut.get(name)?.to\n if (node) graph.removeNode(node)\n }\n }\n}\n", "import type { Graph } from '../graph.ts'\nimport { getImporterSpecs } from './get-importer-specs.ts'\nimport { addNodes } from './add-nodes.ts'\nimport type { AddNodesOptions } from './add-nodes.ts'\nimport { removeNodes } from './remove-nodes.ts'\nimport type { RemoveNodesOptions } from './remove-nodes.ts'\n\nexport type BuildIdealFromStartingGraphOptions = AddNodesOptions &\n RemoveNodesOptions & {\n projectRoot: string\n }\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using the `graph` set\n * in options as a starting point. Also add / remove any dependencies\n * listed in the `add` and `remove` properties.\n */\nexport const buildIdealFromStartingGraph = async (\n options: BuildIdealFromStartingGraphOptions,\n): Promise<Graph> => {\n // Gets a map of dependencies that are keyed to its importer node ids,\n // merging values already found in the graph with user specified values.\n // Any dependencies that are already satisfied in the starting `graph`\n // are going to be pruned from the resulting object.\n const importerSpecs = getImporterSpecs(options)\n\n // merge modifiedDependencies flags\n options.add.modifiedDependencies =\n options.add.modifiedDependencies ||\n importerSpecs.add.modifiedDependencies\n options.remove.modifiedDependencies =\n options.remove.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies\n\n // merge values found on importer specs with\n // user-provided values from `options.add`\n for (const [importerId, deps] of importerSpecs.add) {\n if (!options.add.has(importerId)) {\n options.add.set(importerId, deps)\n continue\n }\n\n // merge any deps found when reading the importers manifest\n // with the ones provided by the user in the `add` options,\n // user-provided deps should take precedence\n for (const [depName, dep] of deps) {\n if (!options.add.get(importerId)?.has(depName)) {\n options.add.get(importerId)?.set(depName, dep)\n }\n }\n }\n\n // add nodes, fetching remote manifests for each dependency to be added\n await addNodes(options)\n\n // move things into their default locations, if possible\n for (const node of options.graph.nodes.values()) {\n node.setDefaultLocation()\n }\n\n // removes any dependencies that are listed in the `remove` option\n removeNodes({ ...options, remove: importerSpecs.remove })\n\n options.graph.gc()\n\n return options.graph\n}\n", "import type { PackageInfoClient } from '@vltpkg/package-info'\nimport { load as loadActual } from '../actual/load.ts'\nimport type { LoadOptions as LoadActualOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport { load as loadVirtual } from '../lockfile/load.ts'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { graphStep } from '@vltpkg/output'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type BuildIdealOptions = LoadActualOptions & {\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 add?: AddImportersDependenciesMap\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 remove?: RemoveImportersDependenciesMap\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n const done = graphStep('build')\n\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n })\n }\n\n const res = await buildIdealFromStartingGraph({\n ...options,\n scurry,\n add: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n })\n done()\n return res\n}\n", "import { spawn } from 'node:child_process'\nimport { rename } from 'node:fs/promises'\nimport { basename, dirname } from 'node:path'\nimport { rimraf } from 'rimraf'\nimport { __CODE_SPLIT_SCRIPT_NAME } from './remove.ts'\n\nexport class RollbackRemove {\n #key = String(Math.random()).substring(2)\n #paths = new Map<string, string>()\n\n async rm(path: string) {\n const target = `${dirname(path)}/.VLT.DELETE.${this.#key}.${basename(path)}`\n this.#paths.set(path, target)\n await rename(path, target).catch((e: unknown) => {\n if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {\n this.#paths.delete(path)\n return\n }\n /* c8 ignore next */\n throw e\n })\n }\n\n confirm() {\n // nothing to confirm!\n if (!this.#paths.size) return\n\n const child = spawn(\n process.execPath,\n [__CODE_SPLIT_SCRIPT_NAME],\n {\n stdio: ['pipe', 'ignore', 'ignore'],\n detached: true,\n },\n )\n child.unref()\n for (const path of this.#paths.values()) {\n child.stdin.write(path + '\\u0000')\n }\n child.stdin.end()\n this.#paths.clear()\n }\n\n async rollback() {\n const promises: Promise<unknown>[] = []\n for (const [original, moved] of this.#paths) {\n promises.push(\n rimraf(original)\n /* c8 ignore next */\n .catch(() => {})\n .then(() => rename(moved, original)),\n )\n }\n await Promise.all(promises)\n this.#paths.clear()\n }\n}\n", "import {resolve} from \"node:path\";\nexport const __CODE_SPLIT_SCRIPT_NAME = resolve(import.meta.dirname, \"rollback-remove-src-remove.js\");", "import type { PackageInfoClient } from '@vltpkg/package-info'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport { availableParallelism } from 'node:os'\nimport { callLimit } from 'promise-call-limit'\nimport { load as loadActual } from '../actual/load.ts'\nimport type { LoadOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport { Diff } from '../diff.ts'\nimport type { Graph } from '../graph.ts'\nimport { lockfile } from '../index.ts'\nimport {\n lockfileData,\n saveData,\n saveHidden,\n} from '../lockfile/save.ts'\nimport { addEdges } from './add-edges.ts'\nimport { addNodes } from './add-nodes.ts'\nimport { build } from './build.ts'\nimport { deleteEdges } from './delete-edges.ts'\nimport { deleteNodes } from './delete-nodes.ts'\nimport { rollback } from './rollback.ts'\nimport { updatePackageJson } from './update-importers-package-json.ts'\nimport { graphStep } from '@vltpkg/output'\n\nconst limit = Math.max(availableParallelism() - 1, 1) * 8\n\n// - [ ] depid's with peer resolutions\n// - [ ] depid shortening\n\nexport type ReifyOptions = LoadOptions & {\n add?: AddImportersDependenciesMap\n remove?: RemoveImportersDependenciesMap\n graph: Graph\n actual?: Graph\n packageInfo: PackageInfoClient\n}\n\n/**\n * Make the current project match the supplied graph.\n */\nexport const reify = async (options: ReifyOptions) => {\n const done = graphStep('reify')\n\n const { graph, scurry } = options\n\n const actual =\n options.actual ??\n loadActual({\n ...options,\n loadManifests: true,\n })\n\n const diff = new Diff(actual, graph)\n const remover = new RollbackRemove()\n let success = false\n try {\n await reify_(options, diff, remover)\n remover.confirm()\n success = true\n } finally {\n /* c8 ignore start */\n if (!success) {\n await rollback(remover, diff, scurry).catch(() => {})\n }\n /* c8 ignore stop */\n }\n\n done()\n\n return diff\n}\n\nconst reify_ = async (\n options: ReifyOptions,\n diff: Diff,\n remover: RollbackRemove,\n) => {\n const { add, remove, packageInfo, packageJson, scurry } = options\n const saveImportersPackageJson =\n add?.modifiedDependencies || remove?.modifiedDependencies ?\n updatePackageJson({\n add,\n remove,\n graph: options.graph,\n packageJson,\n })\n : undefined\n\n // before anything else happens, grab the ideal tree as it was resolved\n // so that we can store it in the lockfile. We do this here so that\n // any failed/removed optional deps are not reflected in the lockfile\n // data as it is saved.\n const lfData = lockfileData(options)\n const actions: (() => Promise<unknown>)[] = addNodes(\n diff,\n scurry,\n remover,\n options,\n packageInfo,\n ).concat(deleteEdges(diff, scurry, remover))\n\n // need to wait, so that the nodes exist to link to\n if (actions.length) await callLimit(actions, { limit })\n\n // create all node_modules symlinks, and link bins to nm/.bin\n const edgeActions: Promise<unknown>[] = addEdges(\n diff,\n packageJson,\n scurry,\n remover,\n )\n if (edgeActions.length) await Promise.all(edgeActions)\n\n // run lifecycles and chmod bins\n await build(diff, packageJson, scurry)\n\n // save the lockfile\n lockfile.save(options)\n\n // if we had to change the actual graph along the way,\n // make sure we do not leave behind any unreachable nodes\n if (diff.hadOptionalFailures) {\n for (const node of options.graph.gc().values()) {\n diff.nodes.add.delete(node)\n diff.nodes.delete.add(node)\n }\n }\n saveHidden(options)\n\n // delete garbage from the store.\n const rmActions: Promise<unknown>[] = deleteNodes(\n diff,\n remover,\n scurry,\n )\n if (rmActions.length) await Promise.all(rmActions)\n\n // updates package.json files if anything was added / removed\n saveImportersPackageJson?.()\n\n // write the ideal graph data to the lockfile\n saveData(lfData, scurry.resolve('vlt-lock.json'), false)\n}\n", "import * as os from 'node:os'\n// availableParallelism available only since node v19, for older versions use\n// cpus() cpus() can return an empty list if /proc is not mounted, use 1 in\n// this case\n\n/* c8 ignore start */\nconst defLimit =\n 'availableParallelism' in os ?\n Math.max(1, os.availableParallelism() - 1)\n : Math.max(1, (os as typeof import('node:os')).cpus().length - 1)\n/* c8 ignore stop */\n\nexport type Step<T> = () => Promise<T>\n\nexport type Options = {\n limit?: number\n rejectLate?: boolean\n}\n\nexport const callLimit = <T extends any>(\n queue: Step<T>[],\n { limit = defLimit, rejectLate }: Options = {},\n) =>\n new Promise((res, rej) => {\n let active = 0\n let current = 0\n const results: (T | void | Promise<void | T>)[] = []\n\n // Whether or not we rejected, distinct from the rejection just in case the rejection itself is falsey\n let rejected = false\n let rejection: unknown\n const reject = (er?: unknown) => {\n if (rejected) return\n rejected = true\n rejection ??= er\n if (!rejectLate) rej(rejection)\n }\n\n let resolved = false\n const resolve = () => {\n if (resolved || active > 0) return\n resolved = true\n res(results)\n }\n\n const run = () => {\n const c = current++\n if (c >= queue.length) return rejected ? reject() : resolve()\n\n active++\n const step = queue[c]\n /* c8 ignore start */\n if (!step) throw new Error('walked off queue')\n /* c8 ignore stop */\n\n results[c] = step()\n .then(\n result => {\n active--\n results[c] = result\n return result\n },\n er => {\n active--\n reject(er)\n },\n )\n .then(result => {\n if (rejected && active === 0) return rej(rejection)\n run()\n return result\n })\n }\n\n for (let i = 0; i < limit; i++) run()\n })\n", "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", "import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { LoadOptions } from './actual/load.ts'\nimport { load as actualLoad } from './actual/load.ts'\nimport type { RemoveImportersDependenciesMap } from './dependencies.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\n\nexport type UninstallOptions = LoadOptions & {\n projectRoot: string\n packageJson: PackageJson\n packageInfo: PackageInfoClient\n}\n\nexport const uninstall = async (\n options: UninstallOptions,\n remove?: RemoveImportersDependenciesMap,\n) => {\n const mainManifest = options.packageJson.read(options.projectRoot)\n\n const graph = await idealBuild({\n ...options,\n remove,\n mainManifest,\n loadManifests: true,\n })\n const act = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n })\n const diff = await reify({\n ...options,\n remove,\n actual: act,\n graph,\n loadManifests: true,\n })\n\n return { graph, diff }\n}\n", "export * from './edge.ts'\nexport * from './graph.ts'\nexport * from './node.ts'\nexport * from './dependencies.ts'\nexport * from './lockfile/types.ts'\nexport * from './visualization/json-output.ts'\nexport * from './visualization/human-readable-output.ts'\nexport * from './visualization/mermaid-output.ts'\nexport * from './stringify-node.ts'\nexport * from './types.ts'\nexport * from './install.ts'\nexport * from './uninstall.ts'\nexport * from './diff.ts'\n\nimport { load as actualLoad } from './actual/load.ts'\nimport type { LoadOptions as ActualLoadOptions } from './actual/load.ts'\nexport const actual = { load: actualLoad }\n\nimport { load as lockfileLoad } from './lockfile/load.ts'\nimport type { LoadOptions as LockfileLoadOptions } from './lockfile/load.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { save } from './lockfile/save.ts'\nexport const lockfile = {\n load: lockfileLoad,\n loadEdges,\n loadNodes,\n save,\n}\n\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.ts'\n\nimport { build } from './ideal/build.ts'\nimport type { BuildIdealOptions } from './ideal/build.ts'\nexport type { BuildIdealOptions }\nexport const ideal = { build }\nexport { reify } from './reify/index.ts'\nexport type { ReifyOptions } from './reify/index.ts'\n", "import 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 (e) {\n const er = e as NodeJS.ErrnoException\n if (er.code === 'EEXIST') {\n return remover.rm(link).then(() => symlink(target, link))\n /* c8 ignore start */\n } else {\n throw er\n }\n }\n /* c8 ignore stop */\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: Manifest,\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 promises.push(clobberSymlink(target, path, remover, 'dir'))\n const bp = binPaths(manifest)\n for (const [key, val] of Object.entries(bp)) {\n const link = scurry.resolve(binRoot, key)\n const target = relative(binRoot, scurry.resolve(path, val))\n // TODO: bash/cmd/pwsh shims on Windows\n promises.push(clobberSymlink(target, link, remover))\n }\n await Promise.all(promises)\n}\n", "import type { Manifest } from '@vltpkg/types'\n\nconst parseScope = (scoped: string): [string | undefined, string] => {\n if (scoped.startsWith('@')) {\n const [scope, name, ...rest] = scoped.split('/')\n if (scope && name && rest.length === 0) return [scope, name]\n }\n return [undefined, scoped]\n}\n\n/** get the bin scripts for a package */\nexport const binPaths = (\n manifest: Manifest,\n): Record<string, string> => {\n const { name, bin } = manifest\n\n if (bin) {\n if (name && typeof bin === 'string') {\n const [_scope, pkg] = parseScope(name)\n return { [pkg]: bin }\n } else if (typeof bin === 'object') {\n return bin\n }\n }\n return {}\n}\n", "import type { PackageJson } from '@vltpkg/package-json'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { addEdge } from './add-edge.ts'\n\nexport const addEdges = (\n diff: Diff,\n packageJson: PackageJson,\n scurry: PathScurry,\n remover: RollbackRemove,\n): Promise<unknown>[] => {\n const actions: Promise<unknown>[] = []\n for (const edge of diff.edges.add) {\n const { to } = edge\n if (!to) continue\n const mani =\n to.manifest ?? packageJson.read(to.resolvedLocation(scurry))\n actions.push(addEdge(edge, mani, scurry, remover))\n }\n return actions\n}\n", "import type { Diff } from '../diff.ts'\nimport type { Node } from '../node.ts'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.ts'\n\n/**\n * If the node is optional, then returns an error handler that removes\n * the node and its connected optional subgraph, by moving them into the\n * \"deleted\" portion of the Diff object.\n * Otherwise, it returns `undefined` so that the promise will simply reject.\n */\nexport function optionalFail(\n diff: Diff,\n node: Node & { optional: true },\n): () => void\nexport function optionalFail(\n diff: Diff,\n node: Node & { optional: false },\n): undefined\nexport function optionalFail(\n diff: Diff,\n node: Node,\n): (() => void) | undefined\nexport function optionalFail(\n diff: Diff,\n node: Node,\n): (() => void) | undefined {\n return node.isOptional() ? () => del(diff, node) : undefined\n}\n\nconst del = (diff: Diff, node: Node & { optional: true }) => {\n diff.hadOptionalFailures = true\n for (const del of removeOptionalSubgraph(diff.to, node)) {\n // add it to the set of nodes being deleted\n diff.nodes.delete.add(del)\n // delete it from the set of nodes being added\n diff.nodes.add.delete(del)\n }\n diff.nodes.add.delete(node)\n diff.nodes.delete.add(node)\n}\n", "import { hydrate } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { platformCheck } from '@vltpkg/pick-manifest'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { optionalFail } from './optional-fail.ts'\n\nexport const addNodes = (\n diff: Diff,\n scurry: PathScurry,\n remover: RollbackRemove,\n options: SpecOptions,\n packageInfo: PackageInfoClient,\n): (() => Promise<unknown>)[] => {\n const actions: (() => Promise<unknown>)[] = []\n // fetch and extract all the nodes, removing any in the way\n for (const node of diff.nodes.add) {\n /* c8 ignore next - all nodes have manifests by this point */\n const { manifest = {} } = node\n // if it's not in the store, we don't have to extract it, because\n // we're just linking to a location that already exists.\n if (!node.inVltStore()) continue\n // remove anything already there\n const target = node.resolvedLocation(scurry)\n const from = scurry.resolve('')\n const spec = hydrate(node.id, manifest.name, options)\n const onErr = optionalFail(diff, node)\n const { integrity, resolved } = node\n // if it's optional, and we know it isn't for this platform, or it's\n // deprecated, don't install it. if it's not optional, try our best.\n if (\n onErr &&\n (manifest.deprecated ||\n !platformCheck(\n manifest,\n process.version,\n process.platform,\n process.arch,\n ))\n ) {\n onErr()\n continue\n }\n actions.push(() =>\n remover.rm(target).then(() =>\n onErr ?\n packageInfo\n .extract(spec, target, { from, integrity, resolved })\n .then(x => x, onErr)\n : packageInfo.extract(spec, target, {\n from,\n integrity,\n resolved,\n }),\n ),\n )\n }\n return actions\n}\n", "// walk the graph of added nodes, building and chmoding their bins\n// at the end, we get back to the importers, and run their prepare\n// script as well as install script.\n\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { run } from '@vltpkg/run'\nimport { statSync } from 'node:fs'\nimport { chmod } from 'node:fs/promises'\nimport { graphRun } from 'graph-run'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport type { Node } from '../node.ts'\nimport { nonEmptyList } from '../non-empty-list.ts'\nimport { binPaths } from './bin-paths.ts'\nimport { optionalFail } from './optional-fail.ts'\n\nexport const build = async (\n diff: Diff,\n packageJson: PackageJson,\n scurry: PathScurry,\n) => {\n const graph = diff.to\n const nodes = nonEmptyList([...graph.importers])\n /* c8 ignore next - all graphs have at least one importer */\n if (!nodes) return\n\n await graphRun<Node, unknown>({\n graph: nodes,\n visit: async (node: Node, signal, path) => {\n // if it's not an importer or an added node, nothing to do.\n // TODO: only build importers if it has changed deps, there's never\n // been a previous build, or it contains something newer than the\n // most recent build.\n // For now, just always build all importers, because we don't\n // track all that other stuff.\n if (!node.importer && !diff.nodes.add.has(node)) return\n\n await visit(packageJson, scurry, node, signal, path).then(\n x => x,\n optionalFail(diff, node),\n )\n },\n\n getDeps: node => {\n const deps: Node[] = []\n for (const { to } of node.edgesOut.values()) {\n /* c8 ignore next - vanishingly unlikely in practice */\n if (to) deps.push(to)\n }\n return deps\n },\n })\n}\n\nconst visit = async (\n packageJson: PackageJson,\n scurry: PathScurry,\n node: Node,\n signal: AbortSignal,\n _path: Node[],\n): Promise<void> => {\n node.manifest ??= packageJson.read(node.resolvedLocation(scurry))\n const { manifest } = node\n const { scripts = {} } = manifest\n\n const {\n install,\n preinstall,\n postinstall,\n prepare,\n preprepare,\n postprepare,\n } = scripts\n\n // if it has install script, run it\n const runInstall = !!(install || preinstall || postinstall)\n if (runInstall) {\n await run({\n signal,\n arg0: 'install',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n // if it's an importer or git, run prepare\n const prepable =\n node.id.startsWith('git') || node.importer || !node.inVltStore()\n const runPrepare =\n !!(prepare || preprepare || postprepare) && prepable\n\n if (runPrepare) {\n await run({\n signal,\n arg0: 'prepare',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n const chmods: Promise<unknown>[] = []\n for (const bin of Object.values(binPaths(manifest))) {\n const path = scurry.resolve(\n `${node.resolvedLocation(scurry)}/${bin}`,\n )\n chmods.push(makeExecutable(path))\n }\n await Promise.all(chmods)\n}\n\n// 0 is \"not yet set\"\n// This is defined by doing `0o111 | <mode>` so that systems\n// that create files group-writable result in 0o775 instead of 0o755\nlet execMode = 0\nconst makeExecutable = async (path: string) => {\n if (!execMode) {\n execMode = (statSync(path).mode & 0o777) | 0o111\n }\n await chmod(path, execMode)\n}\n", "export const isNonEmptyList = <T>(\n list: T[],\n): list is [first: T, ...rest: T[]] => !!list.length\n\nexport const nonEmptyList = <T>(nodes: T[]) =>\n isNonEmptyList(nodes) ? nodes : undefined\n", "import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\nimport { binPaths } from './bin-paths.ts'\n\nconst rmBinPosix = (remover: RollbackRemove, bin: string) => {\n return [remover.rm(bin)]\n}\n\nconst rmBinWin32 = (remover: RollbackRemove, bin: string) => {\n return [\n remover.rm(bin),\n remover.rm(bin + '.cmd'),\n remover.rm(bin + '.pwsh'),\n ]\n}\n\nconst rmBin = process.platform === 'win32' ? rmBinWin32 : rmBinPosix\n\nexport const deleteEdge = async (\n edge: Edge,\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n const {\n spec: { name },\n to,\n } = edge\n const nm = edge.from.nodeModules(scurry)\n const path = scurry.resolve(nm, name)\n const binRoot = scurry.cwd.resolve(`${nm}/.bin`)\n const promises: Promise<unknown>[] = []\n promises.push(remover.rm(path))\n const manifest = to?.manifest\n if (manifest) {\n for (const key of Object.keys(binPaths(manifest))) {\n const bin = binRoot.resolve(key).fullpath()\n promises.push(...rmBin(remover, bin))\n }\n }\n await Promise.all(promises)\n}\n", "import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { deleteEdge } from './delete-edge.ts'\n\nexport const deleteEdges = (\n diff: Diff,\n scurry: PathScurry,\n remover: RollbackRemove,\n): (() => Promise<unknown>)[] => {\n const promises: (() => Promise<unknown>)[] = []\n for (const edge of diff.edges.delete) {\n // if the edge.from is a deleted node in the store, no need\n // the entire dir will be removed in a later step.\n if (diff.nodes.delete.has(edge.from) && edge.from.inVltStore()) {\n continue\n }\n promises.push(() => deleteEdge(edge, scurry, remover))\n }\n return promises\n}\n", "import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\n\nexport const deleteNodes = (\n diff: Diff,\n remover: RollbackRemove,\n scurry: PathScurry,\n): Promise<unknown>[] => {\n const store = scurry.resolve('node_modules/.vlt')\n const rmActions: Promise<unknown>[] = []\n for (const node of diff.nodes.delete) {\n // do not delete workspaces or link targets\n if (!node.inVltStore()) continue\n rmActions.push(remover.rm(scurry.resolve(store, node.id)))\n }\n return rmActions\n}\n", "import { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { deleteEdge } from './delete-edge.ts'\n\nexport const rollback = async (\n remover: RollbackRemove,\n diff: Diff,\n scurry: PathScurry,\n) => {\n const promises: Promise<unknown>[] = []\n const store = scurry.resolve('node_modules/.vlt')\n\n // remove everything the diff tried to add\n const backRoller = new RollbackRemove()\n for (const node of diff.nodes.add) {\n if (!node.inVltStore()) continue\n const path = scurry.resolve(store, node.id)\n /* c8 ignore next */\n promises.push(backRoller.rm(path).catch(() => {}))\n }\n for (const edge of diff.edges.add) {\n promises.push(deleteEdge(edge, scurry, backRoller))\n }\n\n /* c8 ignore next */\n await Promise.all(promises).catch(() => {})\n\n backRoller.confirm()\n\n /* c8 ignore next */\n await remover.rollback().catch(() => {})\n}\n", "import { splitDepID } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type {\n Manifest,\n DependencyTypeLong,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Graph } from '../graph.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\n\nconst SAVE_PREFIX = '^'\n\nconst depTypesMap = new Map<DependencyTypeShort, DependencyTypeLong>([\n ['prod', 'dependencies'],\n ['dev', 'devDependencies'],\n ['peer', 'peerDependencies'],\n ['peerOptional', 'peerDependencies'],\n ['optional', 'optionalDependencies'],\n])\n\nexport type UpdatePackageJsonOptions = {\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 add?: AddImportersDependenciesMap\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 remove?: RemoveImportersDependenciesMap\n /**\n * The {@link Graph} instance that contain the importer nodes to which\n * the manifest data (and it's corresponding `package.json` file) are\n * going to be updated.\n */\n graph: Graph\n /**\n * An instance of {@link PackageJson} to use when writing updated manifest\n * data to `package.json` files. It's necessary that this is the same\n * instance used to load these `package.json` files previously.\n */\n packageJson: PackageJson\n}\n\nconst addOrRemoveDeps = (\n importerId: DepID,\n graph: Graph,\n addOrRemove?:\n | AddImportersDependenciesMap\n | RemoveImportersDependenciesMap,\n): Manifest | undefined => {\n const importer = graph.nodes.get(importerId)\n if (!importer) {\n throw error('Failed to retrieve importer node', {\n found: importerId,\n })\n }\n const manifest = importer.manifest\n if (!manifest) {\n throw error('Could not find manifest data for node', {\n found: importerId,\n })\n }\n const deps = addOrRemove?.get(importerId)\n /* c8 ignore start -- impossible but TS doesn't know that */\n if (!deps) {\n throw error('Failed to retrieve added deps info', {\n manifest,\n })\n }\n let manifestChanged = false\n /* c8 ignore stop */\n for (const deleteNameOrAddItem of deps) {\n if (typeof deleteNameOrAddItem === 'string') {\n const name = deleteNameOrAddItem\n // TODO: needs to also remove any possible peerDependenciesMeta\n for (const depType of longDependencyTypes) {\n if (manifest[depType]?.[name]) {\n delete manifest[depType][name]\n manifestChanged = true\n }\n }\n } else {\n const [name, dep] = deleteNameOrAddItem\n // TODO: peerOptional also needs to add peerDependenciesMeta entry\n const depType = depTypesMap.get(dep.type)\n if (!depType) {\n throw error('Failed to retrieve dependency type', {\n validOptions: [...depTypesMap.keys()],\n found: dep.type,\n })\n }\n const node = importer.edgesOut.get(name)?.to\n if (!node) {\n throw error('Dependency node could not be found')\n }\n const [nodeType] = splitDepID(node.id)\n const dependencies =\n manifest[depType] ?? (manifest[depType] = {})\n dependencies[name] =\n (\n nodeType === 'registry' &&\n (!dep.spec.final.semver || !dep.spec.final.range)\n ) ?\n dep.spec.subspec && dep.spec.namedRegistry ?\n `${dep.spec.final.namedRegistry}:${dep.spec.final.name}@${SAVE_PREFIX}${node.version}`\n : `${SAVE_PREFIX}${node.version}`\n : dep.spec.bareSpec\n manifestChanged = true\n }\n }\n return manifestChanged ? manifest : undefined\n}\n\n/**\n * Updates the importers of a provided {@link Graph} accordingly to the\n * provided add or remove arguments.\n */\nexport const updatePackageJson = ({\n add,\n graph,\n packageJson,\n remove,\n}: UpdatePackageJsonOptions) => {\n const manifestsToUpdate = new Set<Manifest>()\n const operations = new Set([add, remove])\n\n for (const operation of operations) {\n if (operation) {\n for (const importerId of operation.keys()) {\n const manifest = addOrRemoveDeps(importerId, graph, operation)\n if (manifest) {\n manifestsToUpdate.add(manifest)\n }\n }\n }\n }\n\n const commit = () => {\n for (const manifest of manifestsToUpdate) {\n packageJson.save(manifest)\n }\n }\n\n return commit\n}\n", "import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { LoadOptions } from './actual/load.ts'\nimport { load as actualLoad } from './actual/load.ts'\nimport type { AddImportersDependenciesMap } from './dependencies.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\n\nexport type InstallOptions = LoadOptions & {\n projectRoot: string\n packageJson: PackageJson\n packageInfo: PackageInfoClient\n}\n\nexport const install = async (\n options: InstallOptions,\n add?: AddImportersDependenciesMap,\n) => {\n const mainManifest = options.packageJson.read(options.projectRoot)\n\n const graph = await idealBuild({\n ...options,\n add,\n mainManifest,\n loadManifests: true,\n })\n const act = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n })\n const diff = await reify({\n ...options,\n add,\n actual: act,\n graph,\n loadManifests: true,\n })\n\n return { graph, diff }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCO,SAAS,WAAW,EAAE,OAAO,MAAM,GAAoB;AAC5D,QAAM,MAAwB,CAAC;AAG/B,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,UAAU;AACjB,UAAI,KAAK;AAAA;AAAA,QAEP,MAAM,KAAK,QAAQ,KAAK;AAAA,QACxB,IAAI;AAAA,MACN,CAAC;AAAA,IACH;AAAA,EACF;AAGA,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK;AAAA,MACP,MAAM,K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,OAAM,QAAQ,IAAI,SAAS;AAGjD,6BAA2B;AAG3B,WAAS,QAAQ,OAAO,QAAQ,eAAe,GAAG,KAAK;AACzD;;;AiBnIO,IAAM,UAAU,OACrB,SACA,QACG;AACH,QAAM,eAAe,QAAQ,YAAY,KAAK,QAAQ,WAAW;AAEjE,QAAM,QAAQ,MAAM,MAAW;AAAA,IAC7B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,eAAe;AAAA,EACjB,CAAC;AACD,QAAM,MAAMC,MAAW;AAAA,IACrB,GAAG;AAAA,IACH;AAAA,IACA,eAAe;AAAA,EACjB,CAAC;AACD,QAAM,OAAO,MAAM,MAAM;AAAA,IACvB,GAAG;AAAA,IACH;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,eAAe;AAAA,EACjB,CAAC;AAED,SAAO,EAAE,OAAO,KAAK;AACvB;",
6
+ "names": ["Spec", "asDepID", "splitDepID", "hydrate", "hydrateTuple", "s", "splitDepID", "nameVersion", "optional", "dev", "inspect", "resolve", "resolve", "kCustomInspect", "Spec", "inspect", "resolve", "asDepID", "splitDepID", "resolve", "lockfileData", "Spec", "load", "graph", "Spec", "isStringArray", "Spec", "getMap", "load", "dirname", "resolve", "dirname", "availableParallelism", "limit", "resolve", "run", "kCustomInspect", "load", "load", "dirname", "relative", "dirname", "relative", "target", "del", "addNodes", "build", "install", "availableParallelism", "actual", "load", "addNodes", "build", "load"]
7
+ }