@vltpkg/graph 0.0.0-3 → 0.0.0-30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +148 -12
  2. package/dist/esm/actual/load.d.ts +44 -3
  3. package/dist/esm/actual/load.d.ts.map +1 -1
  4. package/dist/esm/actual/load.js +123 -73
  5. package/dist/esm/actual/load.js.map +1 -1
  6. package/dist/esm/browser.d.ts +8 -4
  7. package/dist/esm/browser.d.ts.map +1 -1
  8. package/dist/esm/browser.js +6 -2
  9. package/dist/esm/browser.js.map +1 -1
  10. package/dist/esm/dependencies.d.ts +14 -5
  11. package/dist/esm/dependencies.d.ts.map +1 -1
  12. package/dist/esm/dependencies.js +67 -2
  13. package/dist/esm/dependencies.js.map +1 -1
  14. package/dist/esm/diff.d.ts +5 -0
  15. package/dist/esm/diff.d.ts.map +1 -1
  16. package/dist/esm/diff.js +13 -0
  17. package/dist/esm/diff.js.map +1 -1
  18. package/dist/esm/edge.d.ts +2 -3
  19. package/dist/esm/edge.d.ts.map +1 -1
  20. package/dist/esm/edge.js +1 -1
  21. package/dist/esm/edge.js.map +1 -1
  22. package/dist/esm/graph.d.ts +22 -12
  23. package/dist/esm/graph.d.ts.map +1 -1
  24. package/dist/esm/graph.js +122 -23
  25. package/dist/esm/graph.js.map +1 -1
  26. package/dist/esm/ideal/add-nodes.d.ts +6 -1
  27. package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
  28. package/dist/esm/ideal/add-nodes.js +9 -4
  29. package/dist/esm/ideal/add-nodes.js.map +1 -1
  30. package/dist/esm/ideal/append-nodes.d.ts +9 -1
  31. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  32. package/dist/esm/ideal/append-nodes.js +155 -31
  33. package/dist/esm/ideal/append-nodes.js.map +1 -1
  34. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
  35. package/dist/esm/ideal/build-ideal-from-starting-graph.js +9 -5
  36. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
  37. package/dist/esm/ideal/build.d.ts +4 -0
  38. package/dist/esm/ideal/build.d.ts.map +1 -1
  39. package/dist/esm/ideal/build.js +2 -0
  40. package/dist/esm/ideal/build.js.map +1 -1
  41. package/dist/esm/ideal/get-importer-specs.d.ts +3 -2
  42. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  43. package/dist/esm/ideal/get-importer-specs.js +7 -5
  44. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  45. package/dist/esm/index.d.ts +6 -4
  46. package/dist/esm/index.d.ts.map +1 -1
  47. package/dist/esm/index.js +3 -1
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/install.d.ts +4 -5
  50. package/dist/esm/install.d.ts.map +1 -1
  51. package/dist/esm/install.js +143 -23
  52. package/dist/esm/install.js.map +1 -1
  53. package/dist/esm/lockfile/load-edges.d.ts +8 -1
  54. package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
  55. package/dist/esm/lockfile/load-edges.js +79 -15
  56. package/dist/esm/lockfile/load-edges.js.map +1 -1
  57. package/dist/esm/lockfile/load-nodes.d.ts +3 -2
  58. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  59. package/dist/esm/lockfile/load-nodes.js +64 -11
  60. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  61. package/dist/esm/lockfile/load.d.ts +18 -5
  62. package/dist/esm/lockfile/load.d.ts.map +1 -1
  63. package/dist/esm/lockfile/load.js +51 -22
  64. package/dist/esm/lockfile/load.js.map +1 -1
  65. package/dist/esm/lockfile/save.d.ts +8 -3
  66. package/dist/esm/lockfile/save.d.ts.map +1 -1
  67. package/dist/esm/lockfile/save.js +30 -12
  68. package/dist/esm/lockfile/save.js.map +1 -1
  69. package/dist/esm/lockfile/types.d.ts +17 -4
  70. package/dist/esm/lockfile/types.d.ts.map +1 -1
  71. package/dist/esm/lockfile/types.js.map +1 -1
  72. package/dist/esm/modifiers.d.ts +189 -0
  73. package/dist/esm/modifiers.d.ts.map +1 -0
  74. package/dist/esm/modifiers.js +330 -0
  75. package/dist/esm/modifiers.js.map +1 -0
  76. package/dist/esm/node.d.ts +54 -5
  77. package/dist/esm/node.d.ts.map +1 -1
  78. package/dist/esm/node.js +77 -2
  79. package/dist/esm/node.js.map +1 -1
  80. package/dist/esm/reify/add-edge.d.ts +1 -1
  81. package/dist/esm/reify/add-edge.d.ts.map +1 -1
  82. package/dist/esm/reify/add-edge.js +36 -14
  83. package/dist/esm/reify/add-edge.js.map +1 -1
  84. package/dist/esm/reify/add-nodes.d.ts.map +1 -1
  85. package/dist/esm/reify/add-nodes.js +4 -2
  86. package/dist/esm/reify/add-nodes.js.map +1 -1
  87. package/dist/esm/reify/bin-paths.d.ts +1 -1
  88. package/dist/esm/reify/bin-paths.d.ts.map +1 -1
  89. package/dist/esm/reify/bin-paths.js.map +1 -1
  90. package/dist/esm/reify/build.js +6 -3
  91. package/dist/esm/reify/build.js.map +1 -1
  92. package/dist/esm/reify/calculate-save-value.d.ts +3 -0
  93. package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
  94. package/dist/esm/reify/calculate-save-value.js +45 -0
  95. package/dist/esm/reify/calculate-save-value.js.map +1 -0
  96. package/dist/esm/reify/delete-edge.js +1 -1
  97. package/dist/esm/reify/delete-edge.js.map +1 -1
  98. package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
  99. package/dist/esm/reify/delete-nodes.js +4 -0
  100. package/dist/esm/reify/delete-nodes.js.map +1 -1
  101. package/dist/esm/reify/index.d.ts +2 -0
  102. package/dist/esm/reify/index.d.ts.map +1 -1
  103. package/dist/esm/reify/index.js +20 -2
  104. package/dist/esm/reify/index.js.map +1 -1
  105. package/dist/esm/reify/internal-hoist.d.ts +9 -0
  106. package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
  107. package/dist/esm/reify/internal-hoist.js +121 -0
  108. package/dist/esm/reify/internal-hoist.js.map +1 -0
  109. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  110. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  111. package/dist/esm/reify/update-importers-package-json.js +35 -12
  112. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  113. package/dist/esm/remove-optional-subgraph.js +1 -1
  114. package/dist/esm/remove-optional-subgraph.js.map +1 -1
  115. package/dist/esm/resolve-save-type.d.ts +6 -0
  116. package/dist/esm/resolve-save-type.d.ts.map +1 -0
  117. package/dist/esm/resolve-save-type.js +5 -0
  118. package/dist/esm/resolve-save-type.js.map +1 -0
  119. package/dist/esm/stringify-node.d.ts +1 -1
  120. package/dist/esm/stringify-node.d.ts.map +1 -1
  121. package/dist/esm/stringify-node.js.map +1 -1
  122. package/dist/esm/transfer-data/load.d.ts +44 -0
  123. package/dist/esm/transfer-data/load.d.ts.map +1 -0
  124. package/dist/esm/transfer-data/load.js +176 -0
  125. package/dist/esm/transfer-data/load.js.map +1 -0
  126. package/dist/esm/uninstall.d.ts +3 -5
  127. package/dist/esm/uninstall.d.ts.map +1 -1
  128. package/dist/esm/uninstall.js +0 -3
  129. package/dist/esm/uninstall.js.map +1 -1
  130. package/dist/esm/update.d.ts +11 -0
  131. package/dist/esm/update.d.ts.map +1 -0
  132. package/dist/esm/update.js +49 -0
  133. package/dist/esm/update.js.map +1 -0
  134. package/dist/esm/virtual-root.d.ts +16 -0
  135. package/dist/esm/virtual-root.d.ts.map +1 -0
  136. package/dist/esm/virtual-root.js +78 -0
  137. package/dist/esm/virtual-root.js.map +1 -0
  138. package/dist/esm/visualization/human-readable-output.d.ts +4 -5
  139. package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
  140. package/dist/esm/visualization/human-readable-output.js +51 -24
  141. package/dist/esm/visualization/human-readable-output.js.map +1 -1
  142. package/dist/esm/visualization/json-output.d.ts +7 -3
  143. package/dist/esm/visualization/json-output.d.ts.map +1 -1
  144. package/dist/esm/visualization/json-output.js +35 -12
  145. package/dist/esm/visualization/json-output.js.map +1 -1
  146. package/dist/esm/visualization/mermaid-output.d.ts +7 -1
  147. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  148. package/dist/esm/visualization/mermaid-output.js +64 -9
  149. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  150. package/dist/esm/visualization/object-like-output.d.ts +1 -1
  151. package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
  152. package/dist/esm/visualization/object-like-output.js.map +1 -1
  153. package/package.json +29 -25
  154. package/dist/esm/types.d.ts +0 -39
  155. package/dist/esm/types.d.ts.map +0 -1
  156. package/dist/esm/types.js +0 -2
  157. package/dist/esm/types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAElB,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,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AC;YACD,IAAI,CAAC,SAAS,GAAG,GAAG,CAAA;QACtB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,IAAyB,EAAE,IAAU,EAAE,IAAW;QAC3D,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QAC7C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACvB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: Manifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,QAAQ;oBAAE,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAA;YACpD,CAAC;QACH,CAAC;IACH,CAAC;I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CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: 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?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
@@ -7,5 +7,5 @@ import type { Edge } from '../edge.ts';
7
7
  * this does NOT chmod the bins to 0o777, because they might not exist
8
8
  * until scripts are run, in the case of non-store deps like workspaces
9
9
  */
10
- export declare const addEdge: (edge: Edge, manifest: Manifest, scurry: PathScurry, remover: RollbackRemove) => Promise<void>;
10
+ export declare const addEdge: (edge: Edge, manifest: Pick<Manifest, "bin">, scurry: PathScurry, remover: RollbackRemove) => Promise<void>;
11
11
  //# sourceMappingURL=add-edge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAwBtC;;;;GAIG;AACH,eAAO,MAAM,OAAO,SACZ,IAAI,YACA,QAAQ,UACV,UAAU,WACT,cAAc,kBAyBxB,CAAA"}
1
+ {"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAqCtC;;;;GAIG;AACH,eAAO,MAAM,OAAO,SACZ,IAAI,YACA,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,UACvB,UAAU,WACT,cAAc,kBAoCxB,CAAA"}
@@ -1,22 +1,34 @@
1
- import { mkdir, symlink } from 'fs/promises';
2
- import { dirname, relative } from 'path';
1
+ import { cmdShimIfExists } from '@vltpkg/cmd-shim';
2
+ import { mkdir, symlink } from 'node:fs/promises';
3
+ import { dirname, relative } from 'node:path';
3
4
  import { binPaths } from "./bin-paths.js";
4
5
  const clobberSymlink = async (target, link, remover, type = 'file') => {
5
6
  await mkdir(dirname(link), { recursive: true });
6
7
  try {
7
8
  await symlink(target, link, type);
8
9
  }
9
- catch (e) {
10
- const er = e;
11
- if (er.code === 'EEXIST') {
12
- return remover.rm(link).then(() => symlink(target, link));
10
+ catch (er) {
11
+ /* c8 ignore start */
12
+ if (er.code !== 'EEXIST') {
13
+ throw er;
14
+ }
15
+ /* c8 ignore stop */
16
+ // if the symlink exists, remove it
17
+ await remover.rm(link);
18
+ try {
19
+ // then try to create it again
20
+ await symlink(target, link, type);
13
21
  /* c8 ignore start */
14
22
  }
15
- else {
16
- throw er;
23
+ catch (er) {
24
+ // if the symlink still exists, then multiple paths could be writing to it
25
+ // so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797
26
+ if (er.code !== 'EEXIST') {
27
+ throw er;
28
+ }
17
29
  }
30
+ /* c8 ignore stop */
18
31
  }
19
- /* c8 ignore stop */
20
32
  };
21
33
  /**
22
34
  * reify an edge into a node_modules folder, with bins linked
@@ -30,14 +42,24 @@ export const addEdge = async (edge, manifest, scurry, remover) => {
30
42
  const path = scurry.resolve(edge.from.nodeModules(scurry), edge.spec.name);
31
43
  const promises = [];
32
44
  const target = relative(dirname(path), edge.to.resolvedLocation(scurry));
33
- promises.push(clobberSymlink(target, path, remover, 'dir'));
45
+ // can only parallelize this on posix, because the win32 shims
46
+ // need to know that they will exist before being created.
47
+ const p = clobberSymlink(target, path, remover, 'dir');
48
+ if (process.platform === 'win32')
49
+ await p;
50
+ else
51
+ promises.push(p);
34
52
  const bp = binPaths(manifest);
35
53
  for (const [key, val] of Object.entries(bp)) {
36
54
  const link = scurry.resolve(binRoot, key);
37
- const target = relative(binRoot, scurry.resolve(path, val));
38
- // TODO: bash/cmd/pwsh shims on Windows
39
- promises.push(clobberSymlink(target, link, remover));
55
+ const absTarget = scurry.resolve(path, val);
56
+ const target = relative(binRoot, absTarget);
57
+ // TODO: bash/cmd/ps1 shims on Windows
58
+ promises.push(process.platform === 'win32' ?
59
+ cmdShimIfExists(absTarget, link, remover)
60
+ : clobberSymlink(target, link, remover));
40
61
  }
41
- await Promise.all(promises);
62
+ if (promises.length)
63
+ await Promise.all(promises);
42
64
  };
43
65
  //# sourceMappingURL=add-edge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,IAAY,EACZ,OAAu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AC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;QAC3D,uCAAuC;QACvC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { Manifest } from '@vltpkg/types'\nimport { mkdir, symlink } from 'fs/promises'\nimport { dirname, relative } from '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"]}
1
+ {"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,IAAY,EACZ,OAAuB,EACvB,IAAI,GAAG,MAAM,EACb,EAAE;IACF,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,qBAAqB;QACrB,IAAK,EAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,EAAE,CAAA;QACV,CAAC;QACD,oBAAoB;QAEpB,mCAAmC;QACnC,MAAM,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAA;QAEtB,IAAI,CAAC;YACH,8BAA8B;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AG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;QAC3C,sCAAsC;QACtC,QAAQ,CAAC,IAAI,CACX,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;YAC5B,eAAe,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC;YAC3C,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CACxC,CAAA;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAClD,CAAC,CAAA","sourcesContent":["import { cmdShimIfExists } from '@vltpkg/cmd-shim'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { Manifest } from '@vltpkg/types'\nimport { mkdir, symlink } from 'node:fs/promises'\nimport { dirname, relative } from 'node:path'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\nimport { binPaths } from './bin-paths.ts'\n\nconst clobberSymlink = async (\n target: string,\n link: string,\n remover: RollbackRemove,\n type = 'file',\n) => {\n await mkdir(dirname(link), { recursive: true })\n try {\n await symlink(target, link, type)\n } catch (er) {\n /* c8 ignore start */\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n /* c8 ignore stop */\n\n // if the symlink exists, remove it\n await remover.rm(link)\n\n try {\n // then try to create it again\n await symlink(target, link, type)\n /* c8 ignore start */\n } catch (er) {\n // if the symlink still exists, then multiple paths could be writing to it\n // so now just ignore that error. See https://github.com/vltpkg/vltpkg/issues/797\n if ((er as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw er\n }\n }\n /* c8 ignore stop */\n }\n}\n\n/**\n * reify an edge into a node_modules folder, with bins linked\n * this does NOT chmod the bins to 0o777, because they might not exist\n * until scripts are run, in the case of non-store deps like workspaces\n */\nexport const addEdge = async (\n edge: Edge,\n manifest: Pick<Manifest, 'bin'>,\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n if (!edge.to) return\n const binRoot = scurry.resolve(\n edge.from.nodeModules(scurry),\n '.bin',\n )\n const path = scurry.resolve(\n edge.from.nodeModules(scurry),\n edge.spec.name,\n )\n const promises: Promise<unknown>[] = []\n const target = relative(\n dirname(path),\n edge.to.resolvedLocation(scurry),\n )\n\n // can only parallelize this on posix, because the win32 shims\n // need to know that they will exist before being created.\n const p = clobberSymlink(target, path, remover, 'dir')\n if (process.platform === 'win32') await p\n else promises.push(p)\n\n const bp = binPaths(manifest)\n for (const [key, val] of Object.entries(bp)) {\n const link = scurry.resolve(binRoot, key)\n const absTarget = scurry.resolve(path, val)\n const target = relative(binRoot, absTarget)\n // TODO: bash/cmd/ps1 shims on Windows\n promises.push(\n process.platform === 'win32' ?\n cmdShimIfExists(absTarget, link, remover)\n : clobberSymlink(target, link, remover),\n )\n }\n if (promises.length) await Promise.all(promises)\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,WACd,WAAW,eACP,iBAAiB,KAC7B,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EA6C1B,CAAA"}
1
+ {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,WACd,WAAW,eACP,iBAAiB,KAC7B,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EA+C1B,CAAA"}
@@ -14,14 +14,16 @@ export const addNodes = (diff, scurry, remover, options, packageInfo) => {
14
14
  // remove anything already there
15
15
  const target = node.resolvedLocation(scurry);
16
16
  const from = scurry.resolve('');
17
- const spec = hydrate(node.id, manifest.name, options);
17
+ const spec = hydrate(node.id, node.name, options);
18
18
  const onErr = optionalFail(diff, node);
19
19
  const { integrity, resolved } = node;
20
20
  // if it's optional, and we know it isn't for this platform, or it's
21
21
  // deprecated, don't install it. if it's not optional, try our best.
22
+ // Use platform data from node if available (from lockfile), otherwise fall back to manifest
23
+ const platformData = node.platform ?? manifest;
22
24
  if (onErr &&
23
25
  (manifest.deprecated ||
24
- !platformCheck(manifest, process.version, process.platform, process.arch))) {
26
+ !platformCheck(platformData, process.version, process.platform, process.arch))) {
25
27
  onErr();
26
28
  continue;
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAA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AC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,KAAK,CAAC,CAAC;YACL,WAAW;iBACR,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;iBACpD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;YACxB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;gBAChC,IAAI;gBACJ,SAAS;gBACT,QAAQ;aACT,CAAC,CACL,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["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"]}
1
+ {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,MAAkB,EAClB,OAAuB,EACvB,OAAoB,EACpB,WAA8B,EACF,EAAE;IAC9B,MAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,2DAA2D;IAC3D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,6DAA6D;QAC7D,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;QAC9B,iEAAiE;QACjE,wDAAwD;QACxD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,SAAQ;QAChC,gCAAgC;QAChC,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACjD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACtC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;QACpC,oEAAoE;QACpE,oEAAoE;QACpE,4FAA4F;QAC5F,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAA;QAC9C,IACE,KAAK;YACL,CAAC,QAAQ,CAAC,UAAU;gBAClB,CAAC,aAAa,CACZ,YAAY,EACZ,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,IAAI,CACb,CAAC,EACJ,CAAC;YACD,KAAK,EAAE,CAAA;YACP,SAAQ;QACV,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,KAAK,CAAC,CAAC;YACL,WAAW;iBACR,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;iBACpD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;YACxB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;gBAChC,IAAI;gBACJ,SAAS;gBACT,QAAQ;aACT,CAAC,CACL,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["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, node.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 // Use platform data from node if available (from lockfile), otherwise fall back to manifest\n const platformData = node.platform ?? manifest\n if (\n onErr &&\n (manifest.deprecated ||\n !platformCheck(\n platformData,\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"]}
@@ -1,4 +1,4 @@
1
1
  import type { Manifest } from '@vltpkg/types';
2
2
  /** get the bin scripts for a package */
3
- export declare const binPaths: (manifest: Manifest) => Record<string, string>;
3
+ export declare const binPaths: (manifest: Pick<Manifest, "bin" | "name">) => Record<string, string>;
4
4
  //# sourceMappingURL=bin-paths.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bin-paths.d.ts","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAU7C,wCAAwC;AACxC,eAAO,MAAM,QAAQ,aACT,QAAQ,KACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAYvB,CAAA"}
1
+ {"version":3,"file":"bin-paths.d.ts","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAU7C,wCAAwC;AACxC,eAAO,MAAM,QAAQ,aACT,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,MAAM,CAAC,KACvC,MAAM,CAAC,MAAM,EAAE,MAAM,CAYvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"bin-paths.js","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAgC,EAAE;IAClE,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,QAAkB,EACM,EAAE;IAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAA;IAE9B,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YACtC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAA;QACvB,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA","sourcesContent":["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"]}
1
+ {"version":3,"file":"bin-paths.js","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAgC,EAAE;IAClE,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC9D,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,wCAAwC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,QAAwC,EAChB,EAAE;IAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAA;IAE9B,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YACtC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAA;QACvB,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA","sourcesContent":["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: Pick<Manifest, 'bin' | 'name'>,\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"]}
@@ -2,8 +2,8 @@
2
2
  // at the end, we get back to the importers, and run their prepare
3
3
  // script as well as install script.
4
4
  import { run } from '@vltpkg/run';
5
- import { statSync } from 'fs';
6
- import { chmod } from 'fs/promises';
5
+ import { statSync, existsSync } from 'node:fs';
6
+ import { chmod } from 'node:fs/promises';
7
7
  import { graphRun } from 'graph-run';
8
8
  import { nonEmptyList } from "../non-empty-list.js";
9
9
  import { binPaths } from "./bin-paths.js";
@@ -73,7 +73,10 @@ const visit = async (packageJson, scurry, node, signal, _path) => {
73
73
  const chmods = [];
74
74
  for (const bin of Object.values(binPaths(manifest))) {
75
75
  const path = scurry.resolve(`${node.resolvedLocation(scurry)}/${bin}`);
76
- chmods.push(makeExecutable(path));
76
+ // only try to make executable if the file exists
77
+ if (existsSync(path)) {
78
+ chmods.push(makeExecutable(path));
79
+ }
77
80
  }
78
81
  await Promise.all(chmods);
79
82
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAClE,oCAAoC;AAGpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAA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AAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAClC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,MAAM,GAAuB,EAAE,CAAA;IACrC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CACzB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,CAC1C,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;IACnC,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED,qBAAqB;AACrB,4DAA4D;AAC5D,oEAAoE;AACpE,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;IAClD,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// 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 'fs'\nimport { chmod } from '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"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAClE,oCAAoC;AAGpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAU,EACV,WAAwB,EACxB,MAAkB,EAClB,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAA;IACrB,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IAChD,4DAA4D;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,MAAM,QAAQ,CAAgB;QAC5B,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK,EAAE,IAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACxC,2DAA2D;YAC3D,mEAAmE;YACnE,iEAAiE;YACjE,qBAAqB;YACrB,6DAA6D;YAC7D,8BAA8B;YAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ,IAA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AM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;IAClD,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// 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, existsSync } 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 // only try to make executable if the file exists\n if (existsSync(path)) {\n chmods.push(makeExecutable(path))\n }\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"]}
@@ -0,0 +1,3 @@
1
+ import type { Spec } from '@vltpkg/spec';
2
+ export declare const calculateSaveValue: (nodeType: string, spec: Spec, existing: string | undefined, nodeVersion: string | undefined) => string;
3
+ //# sourceMappingURL=calculate-save-value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-save-value.d.ts","sourceRoot":"","sources":["../../../src/reify/calculate-save-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAGxC,eAAO,MAAM,kBAAkB,aACnB,MAAM,QACV,IAAI,YACA,MAAM,GAAG,SAAS,eACf,MAAM,GAAG,SAAS,KAC9B,MAoDF,CAAA"}
@@ -0,0 +1,45 @@
1
+ const SAVE_PREFIX = '^';
2
+ export const calculateSaveValue = (nodeType, spec, existing, nodeVersion) => {
3
+ if (
4
+ // if not from the registry, save whatever we requested
5
+ nodeType === 'registry' &&
6
+ // if we installed exactly what we already wanted, leave it untouched
7
+ spec.bareSpec !== existing &&
8
+ // if we installed a specific version, keep that specific version.
9
+ !spec.final.range?.isSingle) {
10
+ // if we had a single version, and got that version, then
11
+ // leave it as-is.
12
+ if (existing && existing === nodeVersion) {
13
+ // depend on 1.2.3, got 1.2.3, keep unchanged
14
+ return existing;
15
+ }
16
+ else if (existing && !spec.bareSpec) {
17
+ // if we had `"express": "5.1"` and did `vlt i express`,
18
+ // then leave it as-is, because we just installed our pj dep
19
+ return existing;
20
+ }
21
+ else {
22
+ const finalRange = (spec.final.semver && spec.final.bareSpec) ||
23
+ `${SAVE_PREFIX}${nodeVersion}`;
24
+ // didn't have dep previously, or depended on a different thing
25
+ // than what was requested. Update with the ^ range based on
26
+ // the node that landed in the graph, but preserve alias prefix
27
+ if (spec.subspec && spec.final.namedRegistry) {
28
+ return `${spec.final.namedRegistry}:${spec.final.name}@${finalRange}`;
29
+ }
30
+ if (spec.final.namedJsrRegistry) {
31
+ // if we were given an alternative name, preserve that
32
+ // do this with a regexp because the Spec objects get a little
33
+ // weird here, and the string is relatively straightforward.
34
+ return spec.bareSpec
35
+ .replace(new RegExp(`^(?:.*?@)?${spec.final.namedJsrRegistry}:(@[^/]+/[^@]+)(@.*?)?$`), `${spec.final.namedJsrRegistry}:$1@${finalRange}`)
36
+ .replace(
37
+ // otherwise, swap out the final version for the save range
38
+ new RegExp(`^(?:.*?@)?${spec.final.namedJsrRegistry}:([^@].*?)?$`), `${spec.final.namedJsrRegistry}:${finalRange}`);
39
+ }
40
+ return finalRange;
41
+ }
42
+ }
43
+ return spec.bareSpec;
44
+ };
45
+ //# sourceMappingURL=calculate-save-value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculate-save-value.js","sourceRoot":"","sources":["../../../src/reify/calculate-save-value.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,QAAgB,EAChB,IAAU,EACV,QAA4B,EAC5B,WAA+B,EACvB,EAAE;IACV;IACE,uDAAuD;IACvD,QAAQ,KAAK,UAAU;QACvB,qEAAqE;QACrE,IAAI,CAAC,QAAQ,KAAK,QAAQ;QAC1B,kEAAkE;QAClE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAC3B,CAAC;QACD,yDAAyD;QACzD,kBAAkB;QAClB,IAAI,QAAQ,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;YACzC,6CAA6C;YAC7C,OAAO,QAAQ,CAAA;QACjB,CAAC;aAAM,IAAI,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtC,wDAAwD;YACxD,4DAA4D;YAC5D,OAAO,QAAQ,CAAA;QACjB,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,GACd,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAC1C,GAAG,WAAW,GAAG,WAAW,EAAE,CAAA;YAChC,+DAA+D;YAC/D,4DAA4D;YAC5D,+DAA+D;YAC/D,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;gBAC7C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,UAAU,EAAE,CAAA;YACvE,CAAC;YAED,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;gBAChC,sDAAsD;gBACtD,8DAA8D;gBAC9D,4DAA4D;gBAC5D,OAAO,IAAI,CAAC,QAAQ;qBACjB,OAAO,CACN,IAAI,MAAM,CACR,aAAa,IAAI,CAAC,KAAK,CAAC,gBAAgB,yBAAyB,CAClE,EACD,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,OAAO,UAAU,EAAE,CAClD;qBACA,OAAO;gBACN,2DAA2D;gBAC3D,IAAI,MAAM,CACR,aAAa,IAAI,CAAC,KAAK,CAAC,gBAAgB,cAAc,CACvD,EACD,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,UAAU,EAAE,CAC/C,CAAA;YACL,CAAC;YACD,OAAO,UAAU,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAA;AACtB,CAAC,CAAA","sourcesContent":["import type { Spec } from '@vltpkg/spec'\nconst SAVE_PREFIX = '^'\n\nexport const calculateSaveValue = (\n nodeType: string,\n spec: Spec,\n existing: string | undefined,\n nodeVersion: string | undefined,\n): string => {\n if (\n // if not from the registry, save whatever we requested\n nodeType === 'registry' &&\n // if we installed exactly what we already wanted, leave it untouched\n spec.bareSpec !== existing &&\n // if we installed a specific version, keep that specific version.\n !spec.final.range?.isSingle\n ) {\n // if we had a single version, and got that version, then\n // leave it as-is.\n if (existing && existing === nodeVersion) {\n // depend on 1.2.3, got 1.2.3, keep unchanged\n return existing\n } else if (existing && !spec.bareSpec) {\n // if we had `\"express\": \"5.1\"` and did `vlt i express`,\n // then leave it as-is, because we just installed our pj dep\n return existing\n } else {\n const finalRange =\n (spec.final.semver && spec.final.bareSpec) ||\n `${SAVE_PREFIX}${nodeVersion}`\n // didn't have dep previously, or depended on a different thing\n // than what was requested. Update with the ^ range based on\n // the node that landed in the graph, but preserve alias prefix\n if (spec.subspec && spec.final.namedRegistry) {\n return `${spec.final.namedRegistry}:${spec.final.name}@${finalRange}`\n }\n\n if (spec.final.namedJsrRegistry) {\n // if we were given an alternative name, preserve that\n // do this with a regexp because the Spec objects get a little\n // weird here, and the string is relatively straightforward.\n return spec.bareSpec\n .replace(\n new RegExp(\n `^(?:.*?@)?${spec.final.namedJsrRegistry}:(@[^/]+/[^@]+)(@.*?)?$`,\n ),\n `${spec.final.namedJsrRegistry}:$1@${finalRange}`,\n )\n .replace(\n // otherwise, swap out the final version for the save range\n new RegExp(\n `^(?:.*?@)?${spec.final.namedJsrRegistry}:([^@].*?)?$`,\n ),\n `${spec.final.namedJsrRegistry}:${finalRange}`,\n )\n }\n return finalRange\n }\n }\n return spec.bareSpec\n}\n"]}
@@ -6,7 +6,7 @@ const rmBinWin32 = (remover, bin) => {
6
6
  return [
7
7
  remover.rm(bin),
8
8
  remover.rm(bin + '.cmd'),
9
- remover.rm(bin + '.pwsh'),
9
+ remover.rm(bin + '.ps1'),
10
10
  ];
11
11
  };
12
12
  const rmBin = process.platform === 'win32' ? rmBinWin32 : rmBinPosix;
@@ -1 +1 @@
1
- {"version":3,"file":"delete-edge.js","sourceRoot":"","sources":["../../../src/reify/delete-edge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,UAAU,GAAG,CAAC,OAAuB,EAAE,GAAW,EAAE,EAAE;IAC1D,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,OAAuB,EAAE,GAAW,EAAE,EAAE;IAC1D,OAAO;QACL,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC;QACf,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,OAAO,CAAC;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAA;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,IAAU,EACV,MAAkB,EAClB,OAAuB,EACvB,EAAE;IACF,MAAM,EACJ,IAAI,EAAE,EAAE,IAAI,EAAE,EACd,EAAE,GACH,GAAG,IAAI,CAAA;IACR,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChD,MAAM,QAAQ,GAAuB,EAAE,CAAA;IACvC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/B,MAAM,QAAQ,GAAG,EAAE,EAAE,QAAQ,CAAA;IAC7B,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAClD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;YAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["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"]}
1
+ {"version":3,"file":"delete-edge.js","sourceRoot":"","sources":["../../../src/reify/delete-edge.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,UAAU,GAAG,CAAC,OAAuB,EAAE,GAAW,EAAE,EAAE;IAC1D,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,OAAuB,EAAE,GAAW,EAAE,EAAE;IAC1D,OAAO;QACL,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC;QACf,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC;QACxB,OAAO,CAAC,EAAE,CAAC,GAAG,GAAG,MAAM,CAAC;KACzB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAA;AAEpE,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,IAAU,EACV,MAAkB,EAClB,OAAuB,EACvB,EAAE;IACF,MAAM,EACJ,IAAI,EAAE,EAAE,IAAI,EAAE,EACd,EAAE,GACH,GAAG,IAAI,CAAA;IACR,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IACxC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAChD,MAAM,QAAQ,GAAuB,EAAE,CAAA;IACvC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAC/B,MAAM,QAAQ,GAAG,EAAE,EAAE,QAAQ,CAAA;IAC7B,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;YAClD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;YAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["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 + '.ps1'),\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"delete-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/delete-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,eAAO,MAAM,WAAW,SAChB,IAAI,WACD,cAAc,UACf,UAAU,KACjB,OAAO,CAAC,OAAO,CAAC,EASlB,CAAA"}
1
+ {"version":3,"file":"delete-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/delete-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,WAAW,SAChB,IAAI,WACD,cAAc,UACf,UAAU,KACjB,OAAO,CAAC,OAAO,CAAC,EAYlB,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { deleteEdge } from "./delete-edge.js";
1
2
  export const deleteNodes = (diff, remover, scurry) => {
2
3
  const store = scurry.resolve('node_modules/.vlt');
3
4
  const rmActions = [];
@@ -6,6 +7,9 @@ export const deleteNodes = (diff, remover, scurry) => {
6
7
  if (!node.inVltStore())
7
8
  continue;
8
9
  rmActions.push(remover.rm(scurry.resolve(store, node.id)));
10
+ for (const edge of node.edgesIn) {
11
+ rmActions.push(deleteEdge(edge, scurry, remover));
12
+ }
9
13
  }
10
14
  return rmActions;
11
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"delete-nodes.js","sourceRoot":"","sources":["../../../src/reify/delete-nodes.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAU,EACV,OAAuB,EACvB,MAAkB,EACE,EAAE;IACtB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACjD,MAAM,SAAS,GAAuB,EAAE,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACrC,2CAA2C;QAC3C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,SAAQ;QAChC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC5D,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA","sourcesContent":["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"]}
1
+ {"version":3,"file":"delete-nodes.js","sourceRoot":"","sources":["../../../src/reify/delete-nodes.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAU,EACV,OAAuB,EACvB,MAAkB,EACE,EAAE;IACtB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACjD,MAAM,SAAS,GAAuB,EAAE,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACrC,2CAA2C;QAC3C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,SAAQ;QAChC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QAC1D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA","sourcesContent":["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 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 for (const edge of node.edgesIn) {\n rmActions.push(deleteEdge(edge, scurry, remover))\n }\n }\n return rmActions\n}\n"]}
@@ -3,12 +3,14 @@ import type { LoadOptions } from '../actual/load.ts';
3
3
  import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
4
4
  import { Diff } from '../diff.ts';
5
5
  import type { Graph } from '../graph.ts';
6
+ import type { GraphModifier } from '../modifiers.ts';
6
7
  export type ReifyOptions = LoadOptions & {
7
8
  add?: AddImportersDependenciesMap;
8
9
  remove?: RemoveImportersDependenciesMap;
9
10
  graph: Graph;
10
11
  actual?: Graph;
11
12
  packageInfo: PackageInfoClient;
13
+ modifiers?: GraphModifier;
12
14
  };
13
15
  /**
14
16
  * Make the current project match the supplied graph.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reify/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAK7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAqBxC,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,YAAmB,YAAY,kBA8BhD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/reify/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAqBpD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC,KAAK,EAAE,KAAK,CAAA;IACZ,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,WAAW,EAAE,iBAAiB,CAAA;IAC9B,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,KAAK,YAAmB,YAAY,kBAsChD,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { graphStep } from '@vltpkg/output';
1
2
  import { RollbackRemove } from '@vltpkg/rollback-remove';
2
3
  import { availableParallelism } from 'node:os';
3
4
  import { callLimit } from 'promise-call-limit';
@@ -10,9 +11,10 @@ import { addNodes } from "./add-nodes.js";
10
11
  import { build } from "./build.js";
11
12
  import { deleteEdges } from "./delete-edges.js";
12
13
  import { deleteNodes } from "./delete-nodes.js";
14
+ import { internalHoist } from "./internal-hoist.js";
13
15
  import { rollback } from "./rollback.js";
14
16
  import { updatePackageJson } from "./update-importers-package-json.js";
15
- import { graphStep } from '@vltpkg/output';
17
+ import { copyFileSync } from 'node:fs';
16
18
  const limit = Math.max(availableParallelism() - 1, 1) * 8;
17
19
  /**
18
20
  * Make the current project match the supplied graph.
@@ -26,6 +28,12 @@ export const reify = async (options) => {
26
28
  loadManifests: true,
27
29
  });
28
30
  const diff = new Diff(actual, graph);
31
+ const skipOptionalOnly = !options.add?.modifiedDependencies && diff.optionalOnly;
32
+ if (!diff.hasChanges() || skipOptionalOnly) {
33
+ // nothing to do, so just return the diff
34
+ done();
35
+ return diff;
36
+ }
29
37
  const remover = new RollbackRemove();
30
38
  let success = false;
31
39
  try {
@@ -45,7 +53,9 @@ export const reify = async (options) => {
45
53
  };
46
54
  const reify_ = async (options, diff, remover) => {
47
55
  const { add, remove, packageInfo, packageJson, scurry } = options;
48
- const saveImportersPackageJson = add?.modifiedDependencies || remove?.modifiedDependencies ?
56
+ const saveImportersPackageJson =
57
+ /* c8 ignore next */
58
+ add?.modifiedDependencies || remove?.modifiedDependencies ?
49
59
  updatePackageJson({
50
60
  add,
51
61
  remove,
@@ -66,18 +76,22 @@ const reify_ = async (options, diff, remover) => {
66
76
  const edgeActions = addEdges(diff, packageJson, scurry, remover);
67
77
  if (edgeActions.length)
68
78
  await Promise.all(edgeActions);
79
+ await internalHoist(diff.to, options, remover);
69
80
  // run lifecycles and chmod bins
70
81
  await build(diff, packageJson, scurry);
71
82
  // save the lockfile
72
83
  lockfile.save(options);
73
84
  // if we had to change the actual graph along the way,
74
85
  // make sure we do not leave behind any unreachable nodes
86
+ // TODO: add tests to cover this
87
+ /* c8 ignore start */
75
88
  if (diff.hadOptionalFailures) {
76
89
  for (const node of options.graph.gc().values()) {
77
90
  diff.nodes.add.delete(node);
78
91
  diff.nodes.delete.add(node);
79
92
  }
80
93
  }
94
+ /* c8 ignore stop */
81
95
  saveHidden(options);
82
96
  // delete garbage from the store.
83
97
  const rmActions = deleteNodes(diff, remover, scurry);
@@ -87,5 +101,9 @@ const reify_ = async (options, diff, remover) => {
87
101
  saveImportersPackageJson?.();
88
102
  // write the ideal graph data to the lockfile
89
103
  saveData(lfData, scurry.resolve('vlt-lock.json'), false);
104
+ // update the store config reference if a config file was used
105
+ if (scurry.lstatSync('vlt.json')) {
106
+ copyFileSync(scurry.resolve('vlt.json'), scurry.resolve('node_modules/.vlt/vlt.json'));
107
+ }
90
108
  };
91
109
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reify/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,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D,6DAA6D;IAC7D,MAAM,WAAW,GAAuB,QAAQ,CAC9C,IAAI,EACJ,WAAW,EACX,MAAM,EACN,OAAO,CACR,CAAA;IACD,IAAI,WAAW,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAEtD,gCAAgC;IAChC,MAAM,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;IAEtC,oBAAoB;IACpB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAEtB,sDAAsD;IACtD,yDAAyD;IACzD,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC7B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IACD,UAAU,CAAC,OAAO,CAAC,CAAA;IAEnB,iCAAiC;IACjC,MAAM,SAAS,GAAuB,WAAW,CAC/C,IAAI,EACJ,OAAO,EACP,MAAM,CACP,CAAA;IACD,IAAI,SAAS,CAAC,MAAM;QAAE,MAAM,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAElD,6DAA6D;IAC7D,wBAAwB,EAAE,EAAE,CAAA;IAE5B,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,CAAA;AAC1D,CAAC,CAAA","sourcesContent":["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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reify/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAKtD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,QAAQ,E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C,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,YAAY,CACV,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAC1B,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAC7C,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { graphStep } from '@vltpkg/output'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport { availableParallelism } from 'node:os'\nimport { callLimit } from 'promise-call-limit'\nimport type { LoadOptions } from '../actual/load.ts'\nimport { load as loadActual } 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 type { GraphModifier } from '../modifiers.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 { internalHoist } from './internal-hoist.ts'\nimport { rollback } from './rollback.ts'\nimport { updatePackageJson } from './update-importers-package-json.ts'\nimport { copyFileSync } from 'node:fs'\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 modifiers?: GraphModifier\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 skipOptionalOnly =\n !options.add?.modifiedDependencies && diff.optionalOnly\n if (!diff.hasChanges() || skipOptionalOnly) {\n // nothing to do, so just return the diff\n done()\n return diff\n }\n\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 /* c8 ignore next */\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 await internalHoist(diff.to, options, remover)\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 // TODO: add tests to cover this\n /* c8 ignore start */\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 /* c8 ignore stop */\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 // update the store config reference if a config file was used\n if (scurry.lstatSync('vlt.json')) {\n copyFileSync(\n scurry.resolve('vlt.json'),\n scurry.resolve('node_modules/.vlt/vlt.json'),\n )\n }\n}\n"]}