@vltpkg/graph 0.0.0-2 → 0.0.0-20

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 (129) 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 +114 -70
  5. package/dist/esm/actual/load.js.map +1 -1
  6. package/dist/esm/browser.d.ts +1 -1
  7. package/dist/esm/dependencies.d.ts +15 -5
  8. package/dist/esm/dependencies.d.ts.map +1 -1
  9. package/dist/esm/dependencies.js +67 -2
  10. package/dist/esm/dependencies.js.map +1 -1
  11. package/dist/esm/diff.d.ts +1 -0
  12. package/dist/esm/diff.d.ts.map +1 -1
  13. package/dist/esm/diff.js +6 -0
  14. package/dist/esm/diff.js.map +1 -1
  15. package/dist/esm/edge.d.ts +1 -1
  16. package/dist/esm/edge.d.ts.map +1 -1
  17. package/dist/esm/edge.js +1 -1
  18. package/dist/esm/edge.js.map +1 -1
  19. package/dist/esm/graph.d.ts +17 -10
  20. package/dist/esm/graph.d.ts.map +1 -1
  21. package/dist/esm/graph.js +52 -12
  22. package/dist/esm/graph.js.map +1 -1
  23. package/dist/esm/ideal/add-nodes.d.ts +6 -1
  24. package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
  25. package/dist/esm/ideal/add-nodes.js +9 -4
  26. package/dist/esm/ideal/add-nodes.js.map +1 -1
  27. package/dist/esm/ideal/append-nodes.d.ts +2 -1
  28. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  29. package/dist/esm/ideal/append-nodes.js +22 -5
  30. package/dist/esm/ideal/append-nodes.js.map +1 -1
  31. package/dist/esm/ideal/build.d.ts +4 -0
  32. package/dist/esm/ideal/build.d.ts.map +1 -1
  33. package/dist/esm/ideal/build.js +2 -0
  34. package/dist/esm/ideal/build.js.map +1 -1
  35. package/dist/esm/ideal/get-importer-specs.d.ts +3 -2
  36. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  37. package/dist/esm/ideal/get-importer-specs.js +7 -5
  38. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  39. package/dist/esm/index.d.ts +4 -2
  40. package/dist/esm/index.d.ts.map +1 -1
  41. package/dist/esm/index.js +2 -0
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/install.d.ts +4 -5
  44. package/dist/esm/install.d.ts.map +1 -1
  45. package/dist/esm/install.js +143 -23
  46. package/dist/esm/install.js.map +1 -1
  47. package/dist/esm/lockfile/load-nodes.d.ts +1 -1
  48. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  49. package/dist/esm/lockfile/load-nodes.js +33 -10
  50. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  51. package/dist/esm/lockfile/load.d.ts +18 -5
  52. package/dist/esm/lockfile/load.d.ts.map +1 -1
  53. package/dist/esm/lockfile/load.js +23 -6
  54. package/dist/esm/lockfile/load.js.map +1 -1
  55. package/dist/esm/lockfile/save.d.ts +8 -3
  56. package/dist/esm/lockfile/save.d.ts.map +1 -1
  57. package/dist/esm/lockfile/save.js +26 -12
  58. package/dist/esm/lockfile/save.js.map +1 -1
  59. package/dist/esm/lockfile/types.d.ts +7 -3
  60. package/dist/esm/lockfile/types.d.ts.map +1 -1
  61. package/dist/esm/lockfile/types.js.map +1 -1
  62. package/dist/esm/modifiers.d.ts +189 -0
  63. package/dist/esm/modifiers.d.ts.map +1 -0
  64. package/dist/esm/modifiers.js +330 -0
  65. package/dist/esm/modifiers.js.map +1 -0
  66. package/dist/esm/node.d.ts +32 -4
  67. package/dist/esm/node.d.ts.map +1 -1
  68. package/dist/esm/node.js +60 -2
  69. package/dist/esm/node.js.map +1 -1
  70. package/dist/esm/reify/add-edge.d.ts +1 -1
  71. package/dist/esm/reify/add-edge.d.ts.map +1 -1
  72. package/dist/esm/reify/add-edge.js +36 -14
  73. package/dist/esm/reify/add-edge.js.map +1 -1
  74. package/dist/esm/reify/bin-paths.d.ts +1 -1
  75. package/dist/esm/reify/bin-paths.d.ts.map +1 -1
  76. package/dist/esm/reify/bin-paths.js.map +1 -1
  77. package/dist/esm/reify/build.js +6 -3
  78. package/dist/esm/reify/build.js.map +1 -1
  79. package/dist/esm/reify/calculate-save-value.d.ts +3 -0
  80. package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
  81. package/dist/esm/reify/calculate-save-value.js +45 -0
  82. package/dist/esm/reify/calculate-save-value.js.map +1 -0
  83. package/dist/esm/reify/delete-edge.js +1 -1
  84. package/dist/esm/reify/delete-edge.js.map +1 -1
  85. package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
  86. package/dist/esm/reify/delete-nodes.js +4 -0
  87. package/dist/esm/reify/delete-nodes.js.map +1 -1
  88. package/dist/esm/reify/index.d.ts +2 -0
  89. package/dist/esm/reify/index.d.ts.map +1 -1
  90. package/dist/esm/reify/index.js +13 -1
  91. package/dist/esm/reify/index.js.map +1 -1
  92. package/dist/esm/reify/internal-hoist.d.ts +9 -0
  93. package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
  94. package/dist/esm/reify/internal-hoist.js +121 -0
  95. package/dist/esm/reify/internal-hoist.js.map +1 -0
  96. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  97. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  98. package/dist/esm/reify/update-importers-package-json.js +35 -12
  99. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  100. package/dist/esm/remove-optional-subgraph.js +1 -1
  101. package/dist/esm/remove-optional-subgraph.js.map +1 -1
  102. package/dist/esm/resolve-save-type.d.ts +7 -0
  103. package/dist/esm/resolve-save-type.d.ts.map +1 -0
  104. package/dist/esm/resolve-save-type.js +5 -0
  105. package/dist/esm/resolve-save-type.js.map +1 -0
  106. package/dist/esm/types.d.ts +15 -3
  107. package/dist/esm/types.d.ts.map +1 -1
  108. package/dist/esm/types.js.map +1 -1
  109. package/dist/esm/uninstall.d.ts +3 -5
  110. package/dist/esm/uninstall.d.ts.map +1 -1
  111. package/dist/esm/uninstall.js +0 -3
  112. package/dist/esm/uninstall.js.map +1 -1
  113. package/dist/esm/update.d.ts +11 -0
  114. package/dist/esm/update.d.ts.map +1 -0
  115. package/dist/esm/update.js +49 -0
  116. package/dist/esm/update.js.map +1 -0
  117. package/dist/esm/visualization/human-readable-output.d.ts +3 -4
  118. package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
  119. package/dist/esm/visualization/human-readable-output.js +33 -19
  120. package/dist/esm/visualization/human-readable-output.js.map +1 -1
  121. package/dist/esm/visualization/json-output.d.ts +4 -0
  122. package/dist/esm/visualization/json-output.d.ts.map +1 -1
  123. package/dist/esm/visualization/json-output.js +2 -0
  124. package/dist/esm/visualization/json-output.js.map +1 -1
  125. package/dist/esm/visualization/mermaid-output.d.ts +6 -0
  126. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  127. package/dist/esm/visualization/mermaid-output.js +64 -9
  128. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  129. package/package.json +27 -25
@@ -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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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,kBAoChD,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,11 @@ export const reify = async (options) => {
26
28
  loadManifests: true,
27
29
  });
28
30
  const diff = new Diff(actual, graph);
31
+ if (!diff.hasChanges()) {
32
+ // nothing to do, so just return the diff
33
+ done();
34
+ return diff;
35
+ }
29
36
  const remover = new RollbackRemove();
30
37
  let success = false;
31
38
  try {
@@ -66,6 +73,7 @@ const reify_ = async (options, diff, remover) => {
66
73
  const edgeActions = addEdges(diff, packageJson, scurry, remover);
67
74
  if (edgeActions.length)
68
75
  await Promise.all(edgeActions);
76
+ await internalHoist(diff.to, options, remover);
69
77
  // run lifecycles and chmod bins
70
78
  await build(diff, packageJson, scurry);
71
79
  // save the lockfile
@@ -87,5 +95,9 @@ const reify_ = async (options, diff, remover) => {
87
95
  saveImportersPackageJson?.();
88
96
  // write the ideal graph data to the lockfile
89
97
  saveData(lfData, scurry.resolve('vlt-lock.json'), false);
98
+ // update the store config reference if a config file was used
99
+ if (scurry.lstatSync('vlt.json')) {
100
+ copyFileSync(scurry.resolve('vlt.json'), scurry.resolve('node_modules/.vlt/vlt.json'));
101
+ }
90
102
  };
91
103
  //# 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,CAAA;AAC9C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAMtD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,UAAU,GACX,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE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,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,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CA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AAsD;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;IAExD,8DAA8D;IAC9D,IAAI,MAAM,CAAC,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 if (!diff.hasChanges()) {\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 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 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 // 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"]}
@@ -0,0 +1,9 @@
1
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
2
+ import type { Graph } from '../graph.ts';
3
+ import type { Node } from '../node.ts';
4
+ import type { ReifyOptions } from './index.ts';
5
+ type InternalHoistOptions = Pick<ReifyOptions, 'projectRoot' | 'scurry'>;
6
+ export declare const pickNodeToHoist: (nodes: Set<Node>) => Node | undefined;
7
+ export declare const internalHoist: (graph: Graph, options: InternalHoistOptions, remover: RollbackRemove) => Promise<void>;
8
+ export {};
9
+ //# sourceMappingURL=internal-hoist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-hoist.d.ts","sourceRoot":"","sources":["../../../src/reify/internal-hoist.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,KAAK,oBAAoB,GAAG,IAAI,CAC9B,YAAY,EACZ,aAAa,GAAG,QAAQ,CACzB,CAAA;AAED,eAAO,MAAM,eAAe,UACnB,GAAG,CAAC,IAAI,CAAC,KACf,IAAI,GAAG,SAmET,CAAA;AAED,eAAO,MAAM,aAAa,UACjB,KAAK,WACH,oBAAoB,WACpB,cAAc,kBAkExB,CAAA"}
@@ -0,0 +1,121 @@
1
+ import { splitDepID } from '@vltpkg/dep-id';
2
+ import { Version } from '@vltpkg/semver';
3
+ import { mkdir, symlink } from 'node:fs/promises';
4
+ import { dirname, relative } from 'node:path';
5
+ export const pickNodeToHoist = (nodes) => {
6
+ let pick = undefined;
7
+ let pickNode = undefined;
8
+ for (const node of nodes) {
9
+ if (node.importer || !node.inVltStore()) {
10
+ continue;
11
+ }
12
+ const id = splitDepID(node.id);
13
+ if (!pick || !pickNode) {
14
+ pick = id;
15
+ pickNode = node;
16
+ continue;
17
+ }
18
+ // if one is a dep of an importer, privilege that one
19
+ const impDep = [...node.edgesIn].some(n => n.from.importer);
20
+ const pickImpDep = [...pickNode.edgesIn].some(n => n.from.importer);
21
+ if (impDep !== pickImpDep) {
22
+ if (!pickImpDep) {
23
+ pick = id;
24
+ pickNode = node;
25
+ }
26
+ continue;
27
+ }
28
+ if (id[0] === 'registry') {
29
+ if (pick[0] !== 'registry') {
30
+ pick = id;
31
+ pickNode = node;
32
+ continue;
33
+ }
34
+ // both registry.
35
+ // otherwise, privilege the higher-version dependency
36
+ const pickVersion = pickNode.version;
37
+ const nodeVersion = node.version;
38
+ if (pickVersion) {
39
+ if (!nodeVersion)
40
+ continue;
41
+ if (Version.parse(nodeVersion).greaterThan(Version.parse(pickVersion))) {
42
+ pick = id;
43
+ pickNode = node;
44
+ }
45
+ continue;
46
+ }
47
+ else if (nodeVersion) {
48
+ pick = id;
49
+ pickNode = node;
50
+ continue;
51
+ }
52
+ }
53
+ else {
54
+ // current node is not registry
55
+ if (pick[0] === 'registry')
56
+ continue;
57
+ // neither is pick node, select highest lexically sorted
58
+ if (pickNode.id.localeCompare(node.id, 'en') > 0) {
59
+ pick = id;
60
+ pickNode = node;
61
+ }
62
+ }
63
+ }
64
+ return pickNode;
65
+ };
66
+ export const internalHoist = async (graph, options, remover) => {
67
+ // create a list of all the nodes that we need to hoist.
68
+ // For each name, we prioritize registry deps over other types,
69
+ // and higher versions over lower ones. In the case of non-registry
70
+ // deps, we just pick the first item by sorting the DepIDs.
71
+ const links = new Map();
72
+ for (const [name, nodes] of graph.nodesByName) {
73
+ const pickNode = pickNodeToHoist(nodes);
74
+ if (pickNode)
75
+ links.set(name, pickNode.id);
76
+ }
77
+ // now we have a list of everything to hoist
78
+ // first, remove anything that is not what we want, and skip
79
+ // anything that would be linking what we already indend to link.
80
+ const { scurry } = options;
81
+ const hoistDir = scurry.cwd.resolve('node_modules/.vlt/node_modules');
82
+ await mkdir(hoistDir.fullpath(), { recursive: true });
83
+ const removes = [];
84
+ for (const entry of await hoistDir.readdir()) {
85
+ const name = entry.name;
86
+ // scoped package namespace
87
+ if (name.startsWith('@')) {
88
+ for (const pkg of await entry.readdir()) {
89
+ await checkExisting(`${name}/${pkg.name}`, pkg, links, removes, scurry, remover);
90
+ }
91
+ }
92
+ else {
93
+ await checkExisting(name, entry, links, removes, scurry, remover);
94
+ }
95
+ }
96
+ await Promise.all(removes);
97
+ const symlinks = [];
98
+ for (const [name, id] of links) {
99
+ const target = scurry.resolve(`node_modules/.vlt/${id}/node_modules/${name}`);
100
+ const path = scurry.resolve(`node_modules/.vlt/node_modules/${name}`);
101
+ if (name.includes('/')) {
102
+ await mkdir(dirname(path), { recursive: true });
103
+ }
104
+ symlinks.push(symlink(relative(dirname(path), target), path, 'dir'));
105
+ }
106
+ await Promise.all(symlinks);
107
+ };
108
+ const checkExisting = async (name, entry, links, removes, scurry, remover) => {
109
+ const target = await entry.readlink();
110
+ const id = links.get(name);
111
+ if (!target ||
112
+ !id ||
113
+ target !==
114
+ scurry.cwd.resolve(`node_modules/.vlt/${id}/node_modules/${name}`)) {
115
+ removes.push(remover.rm(entry.fullpath()));
116
+ }
117
+ else {
118
+ links.delete(name);
119
+ }
120
+ };
121
+ //# sourceMappingURL=internal-hoist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-hoist.js","sourceRoot":"","sources":["../../../src/reify/internal-hoist.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAW7C,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAgB,EACE,EAAE;IACpB,IAAI,IAAI,GAA2B,SAAS,CAAA;IAC5C,IAAI,QAAQ,GAAqB,SAAS,CAAA;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACxC,SAAQ;QACV,CAAC;QACD,MAAM,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACvB,IAAI,GAAG,EAAE,CAAA;YACT,QAAQ,GAAG,IAAI,CAAA;YACf,SAAQ;QACV,CAAC;QA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EACzB,OAAwB,EACxB,MAAkB,EAClB,OAAuB,EACvB,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACrC,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC1B,IACE,CAAC,MAAM;QACP,CAAC,EAAE;QACH,MAAM;YACJ,MAAM,CAAC,GAAG,CAAC,OAAO,CAChB,qBAAqB,EAAE,iBAAiB,IAAI,EAAE,CAC/C,EACH,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { splitDepID } from '@vltpkg/dep-id'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport { Version } from '@vltpkg/semver'\nimport { mkdir, symlink } from 'node:fs/promises'\nimport { dirname, relative } from 'node:path'\nimport type { PathBase, PathScurry } from 'path-scurry'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport type { ReifyOptions } from './index.ts'\n\ntype InternalHoistOptions = Pick<\n ReifyOptions,\n 'projectRoot' | 'scurry'\n>\n\nexport const pickNodeToHoist = (\n nodes: Set<Node>,\n): Node | undefined => {\n let pick: DepIDTuple | undefined = undefined\n let pickNode: Node | undefined = undefined\n for (const node of nodes) {\n if (node.importer || !node.inVltStore()) {\n continue\n }\n const id = splitDepID(node.id)\n if (!pick || !pickNode) {\n pick = id\n pickNode = node\n continue\n }\n\n // if one is a dep of an importer, privilege that one\n const impDep = [...node.edgesIn].some(n => n.from.importer)\n const pickImpDep = [...pickNode.edgesIn].some(\n n => n.from.importer,\n )\n if (impDep !== pickImpDep) {\n if (!pickImpDep) {\n pick = id\n pickNode = node\n }\n continue\n }\n\n if (id[0] === 'registry') {\n if (pick[0] !== 'registry') {\n pick = id\n pickNode = node\n continue\n }\n\n // both registry.\n\n // otherwise, privilege the higher-version dependency\n const pickVersion = pickNode.version\n const nodeVersion = node.version\n if (pickVersion) {\n if (!nodeVersion) continue\n if (\n Version.parse(nodeVersion).greaterThan(\n Version.parse(pickVersion),\n )\n ) {\n pick = id\n pickNode = node\n }\n continue\n } else if (nodeVersion) {\n pick = id\n pickNode = node\n continue\n }\n } else {\n // current node is not registry\n if (pick[0] === 'registry') continue\n // neither is pick node, select highest lexically sorted\n if (pickNode.id.localeCompare(node.id, 'en') > 0) {\n pick = id\n pickNode = node\n }\n }\n }\n\n return pickNode\n}\n\nexport const internalHoist = async (\n graph: Graph,\n options: InternalHoistOptions,\n remover: RollbackRemove,\n) => {\n // create a list of all the nodes that we need to hoist.\n // For each name, we prioritize registry deps over other types,\n // and higher versions over lower ones. In the case of non-registry\n // deps, we just pick the first item by sorting the DepIDs.\n const links = new Map<string, DepID>()\n for (const [name, nodes] of graph.nodesByName) {\n const pickNode = pickNodeToHoist(nodes)\n if (pickNode) links.set(name, pickNode.id)\n }\n\n // now we have a list of everything to hoist\n // first, remove anything that is not what we want, and skip\n // anything that would be linking what we already indend to link.\n const { scurry } = options\n\n const hoistDir = scurry.cwd.resolve(\n 'node_modules/.vlt/node_modules',\n )\n await mkdir(hoistDir.fullpath(), { recursive: true })\n\n const removes: Promise<void>[] = []\n for (const entry of await hoistDir.readdir()) {\n const name = entry.name\n // scoped package namespace\n if (name.startsWith('@')) {\n for (const pkg of await entry.readdir()) {\n await checkExisting(\n `${name}/${pkg.name}`,\n pkg,\n links,\n removes,\n scurry,\n remover,\n )\n }\n } else {\n await checkExisting(\n name,\n entry,\n links,\n removes,\n scurry,\n remover,\n )\n }\n }\n await Promise.all(removes)\n\n const symlinks: Promise<void>[] = []\n for (const [name, id] of links) {\n const target = scurry.resolve(\n `node_modules/.vlt/${id}/node_modules/${name}`,\n )\n const path = scurry.resolve(\n `node_modules/.vlt/node_modules/${name}`,\n )\n if (name.includes('/')) {\n await mkdir(dirname(path), { recursive: true })\n }\n symlinks.push(\n symlink(relative(dirname(path), target), path, 'dir'),\n )\n }\n await Promise.all(symlinks)\n}\n\nconst checkExisting = async (\n name: string,\n entry: PathBase,\n links: Map<string, DepID>,\n removes: Promise<void>[],\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n const target = await entry.readlink()\n const id = links.get(name)\n if (\n !target ||\n !id ||\n target !==\n scurry.cwd.resolve(\n `node_modules/.vlt/${id}/node_modules/${name}`,\n )\n ) {\n removes.push(remover.rm(entry.fullpath()))\n } else {\n links.delete(name)\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { PackageJson } from '@vltpkg/package-json';
2
- import type { Graph } from '../graph.ts';
3
2
  import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
3
+ import type { Graph } from '../graph.ts';
4
4
  export type UpdatePackageJsonOptions = {
5
5
  /**
6
6
  * A `Map` in which keys are {@link DepID} linking to another `Map` in which
@@ -1 +1 @@
1
- {"version":3,"file":"update-importers-package-json.d.ts","sourceRoot":"","sources":["../../../src/reify/update-importers-package-json.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAOvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAY3B,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAwED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,yCAK3B,wBAAwB,eAsB1B,CAAA"}
1
+ {"version":3,"file":"update-importers-package-json.d.ts","sourceRoot":"","sources":["../../../src/reify/update-importers-package-json.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAOvD,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAYxC,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;;;OAIG;IACH,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAiGD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,yCAK3B,wBAAwB,eAsB1B,CAAA"}
@@ -1,7 +1,8 @@
1
1
  import { splitDepID } from '@vltpkg/dep-id';
2
2
  import { error } from '@vltpkg/error-cause';
3
3
  import { longDependencyTypes } from '@vltpkg/types';
4
- const SAVE_PREFIX = '^';
4
+ import { resolveSaveType } from "../resolve-save-type.js";
5
+ import { calculateSaveValue } from "./calculate-save-value.js";
5
6
  const depTypesMap = new Map([
6
7
  ['prod', 'dependencies'],
7
8
  ['dev', 'devDependencies'],
@@ -34,18 +35,22 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
34
35
  for (const deleteNameOrAddItem of deps) {
35
36
  if (typeof deleteNameOrAddItem === 'string') {
36
37
  const name = deleteNameOrAddItem;
37
- // TODO: needs to also remove any possible peerDependenciesMeta
38
38
  for (const depType of longDependencyTypes) {
39
39
  if (manifest[depType]?.[name]) {
40
40
  delete manifest[depType][name];
41
41
  manifestChanged = true;
42
42
  }
43
43
  }
44
+ if (manifest.peerDependenciesMeta?.[name]) {
45
+ delete manifest.peerDependenciesMeta[name];
46
+ manifestChanged = true;
47
+ }
44
48
  }
45
49
  else {
46
50
  const [name, dep] = deleteNameOrAddItem;
47
- // TODO: peerOptional also needs to add peerDependenciesMeta entry
48
- const depType = depTypesMap.get(dep.type);
51
+ // peerOptional also needs to add peerDependenciesMeta entry
52
+ const depTypeShort = resolveSaveType(importer, name, dep.type);
53
+ const depType = depTypesMap.get(depTypeShort);
49
54
  if (!depType) {
50
55
  throw error('Failed to retrieve dependency type', {
51
56
  validOptions: [...depTypesMap.keys()],
@@ -57,15 +62,33 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
57
62
  throw error('Dependency node could not be found');
58
63
  }
59
64
  const [nodeType] = splitDepID(node.id);
65
+ for (const dtype of longDependencyTypes) {
66
+ if (dtype === depType || !manifest[dtype])
67
+ continue;
68
+ delete manifest[dtype][name];
69
+ }
70
+ if (depTypeShort === 'peerOptional') {
71
+ manifest.peerDependenciesMeta ??= {};
72
+ manifest.peerDependenciesMeta[name] = { optional: true };
73
+ }
74
+ else if (manifest.peerDependenciesMeta?.[name]) {
75
+ delete manifest.peerDependenciesMeta[name];
76
+ }
60
77
  const dependencies = manifest[depType] ?? (manifest[depType] = {});
61
- dependencies[name] =
62
- (nodeType === 'registry' &&
63
- (!dep.spec.final.semver || !dep.spec.final.range)) ?
64
- dep.spec.subspec && dep.spec.namedRegistry ?
65
- `${dep.spec.final.namedRegistry}:${dep.spec.final.name}@${SAVE_PREFIX}${node.version}`
66
- : `${SAVE_PREFIX}${node.version}`
67
- : dep.spec.bareSpec;
68
- manifestChanged = true;
78
+ // check to see if we need to save a different version
79
+ // - If you install a single specific version, that is deliberate,
80
+ // we save that exact version, no matter what.
81
+ // - If the requested spec matches the manifest, make no change
82
+ // If the requested spec had no bareSpec, and the manifest has
83
+ // a dependency entry, make no change.
84
+ // If the requested spec has a bareSpec that did NOT match the manifest,
85
+ // then update it.
86
+ // If the manifest does not contain anything, then update it.
87
+ // Only for registry dependencies
88
+ const existing = dependencies[name];
89
+ const saveValue = calculateSaveValue(nodeType, dep.spec, existing, node.version);
90
+ dependencies[name] = saveValue;
91
+ manifestChanged = manifestChanged || saveValue !== existing;
69
92
  }
70
93
  }
71
94
  return manifestChanged ? manifest : undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"update-importers-package-json.js","sourceRoot":"","sources":["../../../src/reify/update-importers-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAanD,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,MAAM,WAAW,GAAG,IAAI,GAAG,CAA0C;IACnE,CAAC,MAAM,EAAE,cAAc,CAAC;IACxB,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAC1B,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAC5B,CAAC,cAAc,EAAE,kBAAkB,CAAC;IACpC,CAAC,UAAU,EAAE,sBAAsB,CAAC;CACrC,CAAC,CAAA;AA8BF,MAAM,eAAe,GAAG,CACtB,UAAiB,EACjB,KAAY,EACZ,WAEkC,EACZ,EAAE;IACxB,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kCAAkC,EAAE;YAC9C,KAAK,EAAE,UAAU;SAClB,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;IAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,uCAAuC,EAAE;YACnD,KAAK,EAAE,UAAU;SAClB,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,WAAW,EAAE,GAAG,CAAC,UAAU,CAAC,C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GAAG,eAAe,CAAC,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;gBAC9D,IAAI,QAAQ,EAAE,CAAC;oBACb,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;gBACjC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,KAAK,MAAM,QAAQ,IAAI,iBAAiB,EAAE,CAAC;YACzC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC5B,CAAC;IACH,CAAC,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type {\n Manifest,\n DependencyTypeLong,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Graph } from '../graph.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\n\nconst SAVE_PREFIX = '^'\n\nconst depTypesMap = new Map<DependencyTypeShort, DependencyTypeLong>([\n ['prod', 'dependencies'],\n ['dev', 'devDependencies'],\n ['peer', 'peerDependencies'],\n ['peerOptional', 'peerDependencies'],\n ['optional', 'optionalDependencies'],\n])\n\nexport type UpdatePackageJsonOptions = {\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * The {@link Graph} instance that contain the importer nodes to which\n * the manifest data (and it's corresponding `package.json` file) are\n * going to be updated.\n */\n graph: Graph\n /**\n * An instance of {@link PackageJson} to use when writing updated manifest\n * data to `package.json` files. It's necessary that this is the same\n * instance used to load these `package.json` files previously.\n */\n packageJson: PackageJson\n}\n\nconst addOrRemoveDeps = (\n importerId: DepID,\n graph: Graph,\n addOrRemove?:\n | AddImportersDependenciesMap\n | RemoveImportersDependenciesMap,\n): Manifest | undefined => {\n const importer = graph.nodes.get(importerId)\n if (!importer) {\n throw error('Failed to retrieve importer node', {\n found: importerId,\n })\n }\n const manifest = importer.manifest\n if (!manifest) {\n throw error('Could not find manifest data for node', {\n found: importerId,\n })\n }\n const deps = addOrRemove?.get(importerId)\n /* c8 ignore start -- impossible but TS doesn't know that */\n if (!deps) {\n throw error('Failed to retrieve added deps info', {\n manifest,\n })\n }\n let manifestChanged = false\n /* c8 ignore stop */\n for (const deleteNameOrAddItem of deps) {\n if (typeof deleteNameOrAddItem === 'string') {\n const name = deleteNameOrAddItem\n // TODO: needs to also remove any possible peerDependenciesMeta\n for (const depType of longDependencyTypes) {\n if (manifest[depType]?.[name]) {\n delete manifest[depType][name]\n manifestChanged = true\n }\n }\n } else {\n const [name, dep] = deleteNameOrAddItem\n // TODO: peerOptional also needs to add peerDependenciesMeta entry\n const depType = depTypesMap.get(dep.type)\n if (!depType) {\n throw error('Failed to retrieve dependency type', {\n validOptions: [...depTypesMap.keys()],\n found: dep.type,\n })\n }\n const node = importer.edgesOut.get(name)?.to\n if (!node) {\n throw error('Dependency node could not be found')\n }\n const [nodeType] = splitDepID(node.id)\n const dependencies =\n manifest[depType] ?? (manifest[depType] = {})\n dependencies[name] =\n (\n nodeType === 'registry' &&\n (!dep.spec.final.semver || !dep.spec.final.range)\n ) ?\n dep.spec.subspec && dep.spec.namedRegistry ?\n `${dep.spec.final.namedRegistry}:${dep.spec.final.name}@${SAVE_PREFIX}${node.version}`\n : `${SAVE_PREFIX}${node.version}`\n : dep.spec.bareSpec\n manifestChanged = true\n }\n }\n return manifestChanged ? manifest : undefined\n}\n\n/**\n * Updates the importers of a provided {@link Graph} accordingly to the\n * provided add or remove arguments.\n */\nexport const updatePackageJson = ({\n add,\n graph,\n packageJson,\n remove,\n}: UpdatePackageJsonOptions) => {\n const manifestsToUpdate = new Set<Manifest>()\n const operations = new Set([add, remove])\n\n for (const operation of operations) {\n if (operation) {\n for (const importerId of operation.keys()) {\n const manifest = addOrRemoveDeps(importerId, graph, operation)\n if (manifest) {\n manifestsToUpdate.add(manifest)\n }\n }\n }\n }\n\n const commit = () => {\n for (const manifest of manifestsToUpdate) {\n packageJson.save(manifest)\n }\n }\n\n return commit\n}\n"]}
1
+ {"version":3,"file":"update-importers-package-json.js","sourceRoot":"","sources":["../../../src/reify/update-importers-package-json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAO3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAOnD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,MAAM,WAAW,GAAG,IAAI,GAAG,CAA0C;IACnE,CAAC,MAAM,EAAE,cAAc,CAAC;IACxB,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAC1B,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAC5B,CAAC,cAAc,EAAE,kBAAkB,CAAC;IACpC,CAAC,UAAU,EAAE,sBAAsB,CAAC;CACrC,CAAC,CAAA;AA8BF,MAAM,eAAe,GAAG,CACtB,UAAiB,EACjB,KAAY,EACZ,WAEkC,EACF,EAAE;IAClC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,KAAK,CAAC,kCAAkC,EAAE;YAC9C,KAAK,EAAE,UAAU;SAClB,CAAC,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AC,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { splitDepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type {\n DependencyTypeLong,\n DependencyTypeShort,\n NormalizedManifest,\n} from '@vltpkg/types'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport { resolveSaveType } from '../resolve-save-type.ts'\nimport { calculateSaveValue } from './calculate-save-value.ts'\n\nconst depTypesMap = new Map<DependencyTypeShort, DependencyTypeLong>([\n ['prod', 'dependencies'],\n ['dev', 'devDependencies'],\n ['peer', 'peerDependencies'],\n ['peerOptional', 'peerDependencies'],\n ['optional', 'optionalDependencies'],\n])\n\nexport type UpdatePackageJsonOptions = {\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * The {@link Graph} instance that contain the importer nodes to which\n * the manifest data (and it's corresponding `package.json` file) are\n * going to be updated.\n */\n graph: Graph\n /**\n * An instance of {@link PackageJson} to use when writing updated manifest\n * data to `package.json` files. It's necessary that this is the same\n * instance used to load these `package.json` files previously.\n */\n packageJson: PackageJson\n}\n\nconst addOrRemoveDeps = (\n importerId: DepID,\n graph: Graph,\n addOrRemove?:\n | AddImportersDependenciesMap\n | RemoveImportersDependenciesMap,\n): NormalizedManifest | undefined => {\n const importer = graph.nodes.get(importerId)\n if (!importer) {\n throw error('Failed to retrieve importer node', {\n found: importerId,\n })\n }\n const manifest = importer.manifest\n if (!manifest) {\n throw error('Could not find manifest data for node', {\n found: importerId,\n })\n }\n const deps = addOrRemove?.get(importerId)\n /* c8 ignore start -- impossible but TS doesn't know that */\n if (!deps) {\n throw error('Failed to retrieve added deps info', {\n manifest,\n })\n }\n let manifestChanged = false\n /* c8 ignore stop */\n for (const deleteNameOrAddItem of deps) {\n if (typeof deleteNameOrAddItem === 'string') {\n const name = deleteNameOrAddItem\n for (const depType of longDependencyTypes) {\n if (manifest[depType]?.[name]) {\n delete manifest[depType][name]\n manifestChanged = true\n }\n }\n if (manifest.peerDependenciesMeta?.[name]) {\n delete manifest.peerDependenciesMeta[name]\n manifestChanged = true\n }\n } else {\n const [name, dep] = deleteNameOrAddItem\n // peerOptional also needs to add peerDependenciesMeta entry\n const depTypeShort = resolveSaveType(importer, name, dep.type)\n const depType = depTypesMap.get(depTypeShort)\n if (!depType) {\n throw error('Failed to retrieve dependency type', {\n validOptions: [...depTypesMap.keys()],\n found: dep.type,\n })\n }\n const node = importer.edgesOut.get(name)?.to\n if (!node) {\n throw error('Dependency node could not be found')\n }\n const [nodeType] = splitDepID(node.id)\n\n for (const dtype of longDependencyTypes) {\n if (dtype === depType || !manifest[dtype]) continue\n delete manifest[dtype][name]\n }\n if (depTypeShort === 'peerOptional') {\n manifest.peerDependenciesMeta ??= {}\n manifest.peerDependenciesMeta[name] = { optional: true }\n } else if (manifest.peerDependenciesMeta?.[name]) {\n delete manifest.peerDependenciesMeta[name]\n }\n\n const dependencies =\n manifest[depType] ?? (manifest[depType] = {})\n // check to see if we need to save a different version\n // - If you install a single specific version, that is deliberate,\n // we save that exact version, no matter what.\n // - If the requested spec matches the manifest, make no change\n // If the requested spec had no bareSpec, and the manifest has\n // a dependency entry, make no change.\n // If the requested spec has a bareSpec that did NOT match the manifest,\n // then update it.\n // If the manifest does not contain anything, then update it.\n // Only for registry dependencies\n const existing = dependencies[name]\n const saveValue = calculateSaveValue(\n nodeType,\n dep.spec,\n existing,\n node.version,\n )\n dependencies[name] = saveValue\n manifestChanged = manifestChanged || saveValue !== existing\n }\n }\n return manifestChanged ? manifest : undefined\n}\n\n/**\n * Updates the importers of a provided {@link Graph} accordingly to the\n * provided add or remove arguments.\n */\nexport const updatePackageJson = ({\n add,\n graph,\n packageJson,\n remove,\n}: UpdatePackageJsonOptions) => {\n const manifestsToUpdate = new Set<NormalizedManifest>()\n const operations = new Set([add, remove])\n\n for (const operation of operations) {\n if (operation) {\n for (const importerId of operation.keys()) {\n const manifest = addOrRemoveDeps(importerId, graph, operation)\n if (manifest) {\n manifestsToUpdate.add(manifest)\n }\n }\n }\n }\n\n const commit = () => {\n for (const manifest of manifestsToUpdate) {\n packageJson.save(manifest)\n }\n }\n\n return commit\n}\n"]}
@@ -14,7 +14,7 @@
14
14
  export const removeOptionalSubgraph = (graph, startingNode) => {
15
15
  const removed = new Set();
16
16
  for (const node of findOptionalSubgraph(startingNode)) {
17
- graph.removeNode(node);
17
+ graph.removeNode(node, undefined, true);
18
18
  removed.add(node);
19
19
  }
20
20
  return removed;
@@ -1 +1 @@
1
- {"version":3,"file":"remove-optional-subgraph.js","sourceRoot":"","sources":["../../src/remove-optional-subgraph.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAY,EACZ,YAAuC,EACvC,EAAE;IACF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAQ,CAAA;IAC/B,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,YAAY,CAAC,EAAE,CAAC;QACtD,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QACtB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,SAAS,CAAC,CAAC,oBAAoB,CACnC,IAA+B,EAC/B,OAAO,IAAI,GAAG,EAA6B;IAE3C,mCAAmC;IACnC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAM;IAE1B,qDAAqD;IACrD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACd,MAAM,IAAI,CAAA;IAEV,mDAAmD;IACnD,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9C,qEAAqE;QACrE,oEAAoE;QACpE,2CAA2C;QAC3C,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,KAAK,MAAM,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;gBAAE,MAAM,GAAG,CAAA;QAC/D,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n/**\n * Remove the affected optional nodes starting from a given optional node\n * that failed to resolve/install.\n *\n * Removing these dependents will frequently leave optional *dependencies*\n * behind that are made unreachable from any project importer. For performance\n * reasons, `graph.gc()` is not called automatically by this method, since\n * multiple optional subgraphs may need to be removed in a single operation,\n * and the mark-and-sweep garbage collection (a) can be excessively expensive,\n * and (b) may need to communicate the set of garbage-collected nodes\n * for cleanup (as in the case of optional node build failures during\n * reification).\n */\nexport const removeOptionalSubgraph = (\n graph: Graph,\n startingNode: Node & { optional: true },\n) => {\n const removed = new Set<Node>()\n for (const node of findOptionalSubgraph(startingNode)) {\n graph.removeNode(node)\n removed.add(node)\n }\n return removed\n}\n\n/**\n * Given a starting node, this generator will walk back from the optional node\n * to all of its optional dependents, emitting each one, and skipping any\n * cycles.\n *\n * Note that when these are removed, it may create unreachable nodes in the\n * graph! Be sure to call `graph.gc()` if these are removed.\n */\nexport function* findOptionalSubgraph(\n node: Node & { optional: true },\n seen = new Set<Node & { optional: true }>(),\n): Generator<Node & { optional: true }, void> {\n // already visited, prevent looping\n if (seen.has(node)) return\n\n // the node itself is part of the subgraph, of course\n seen.add(node)\n yield node\n\n // and any of its dependents that are also optional\n for (const { from, optional } of node.edgesIn) {\n // if it's an optional *edge*, we don't need to remove it, because it\n // doesn't need the node anyway. But if the node is optional and the\n // dep isn't, then we do need to remove it.\n if (from.isOptional() && !optional) {\n for (const dep of findOptionalSubgraph(from, seen)) yield dep\n }\n }\n}\n"]}
1
+ {"version":3,"file":"remove-optional-subgraph.js","sourceRoot":"","sources":["../../src/remove-optional-subgraph.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAY,EACZ,YAAuC,EACvC,EAAE;IACF,MAAM,OAAO,GAAG,IAAI,GAAG,EAAQ,CAAA;IAC/B,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,YAAY,CAAC,EAAE,CAAC;QACtD,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QACvC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACnB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,SAAS,CAAC,CAAC,oBAAoB,CACnC,IAA+B,EAC/B,OAAO,IAAI,GAAG,EAA6B;IAE3C,mCAAmC;IACnC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAM;IAE1B,qDAAqD;IACrD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACd,MAAM,IAAI,CAAA;IAEV,mDAAmD;IACnD,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9C,qEAAqE;QACrE,oEAAoE;QACpE,2CAA2C;QAC3C,IAAI,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnC,KAAK,MAAM,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;gBAAE,MAAM,GAAG,CAAA;QAC/D,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n/**\n * Remove the affected optional nodes starting from a given optional node\n * that failed to resolve/install.\n *\n * Removing these dependents will frequently leave optional *dependencies*\n * behind that are made unreachable from any project importer. For performance\n * reasons, `graph.gc()` is not called automatically by this method, since\n * multiple optional subgraphs may need to be removed in a single operation,\n * and the mark-and-sweep garbage collection (a) can be excessively expensive,\n * and (b) may need to communicate the set of garbage-collected nodes\n * for cleanup (as in the case of optional node build failures during\n * reification).\n */\nexport const removeOptionalSubgraph = (\n graph: Graph,\n startingNode: Node & { optional: true },\n) => {\n const removed = new Set<Node>()\n for (const node of findOptionalSubgraph(startingNode)) {\n graph.removeNode(node, undefined, true)\n removed.add(node)\n }\n return removed\n}\n\n/**\n * Given a starting node, this generator will walk back from the optional node\n * to all of its optional dependents, emitting each one, and skipping any\n * cycles.\n *\n * Note that when these are removed, it may create unreachable nodes in the\n * graph! Be sure to call `graph.gc()` if these are removed.\n */\nexport function* findOptionalSubgraph(\n node: Node & { optional: true },\n seen = new Set<Node & { optional: true }>(),\n): Generator<Node & { optional: true }, void> {\n // already visited, prevent looping\n if (seen.has(node)) return\n\n // the node itself is part of the subgraph, of course\n seen.add(node)\n yield node\n\n // and any of its dependents that are also optional\n for (const { from, optional } of node.edgesIn) {\n // if it's an optional *edge*, we don't need to remove it, because it\n // doesn't need the node anyway. But if the node is optional and the\n // dep isn't, then we do need to remove it.\n if (from.isOptional() && !optional) {\n for (const dep of findOptionalSubgraph(from, seen)) yield dep\n }\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { DependencySaveType, DependencyTypeShort } from '@vltpkg/types';
2
+ import type { NodeLike } from './types.ts';
3
+ /**
4
+ * Resolve a {@link DependencySaveType} to a {@link DependencyTypeShort}
5
+ */
6
+ export declare const resolveSaveType: (node: NodeLike, name: string, saveType: DependencySaveType) => DependencyTypeShort;
7
+ //# sourceMappingURL=resolve-save-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-save-type.d.ts","sourceRoot":"","sources":["../../src/resolve-save-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;;GAEG;AACH,eAAO,MAAM,eAAe,SACpB,QAAQ,QACR,MAAM,YACF,kBAAkB,KAC3B,mBAGA,CAAA"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Resolve a {@link DependencySaveType} to a {@link DependencyTypeShort}
3
+ */
4
+ export const resolveSaveType = (node, name, saveType) => saveType !== 'implicit' ? saveType : ((node.edgesOut.get(name)?.type ?? 'prod'));
5
+ //# sourceMappingURL=resolve-save-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-save-type.js","sourceRoot":"","sources":["../../src/resolve-save-type.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,IAAc,EACd,IAAY,EACZ,QAA4B,EACP,EAAE,CACvB,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CACnC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,MAAM,CAAC,CAC1C,CAAA","sourcesContent":["import type {\n DependencySaveType,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { NodeLike } from './types.ts'\n\n/**\n * Resolve a {@link DependencySaveType} to a {@link DependencyTypeShort}\n */\nexport const resolveSaveType = (\n node: NodeLike,\n name: string,\n saveType: DependencySaveType,\n): DependencyTypeShort =>\n saveType !== 'implicit' ? saveType : (\n (node.edgesOut.get(name)?.type ?? 'prod')\n )\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { DepID } from '@vltpkg/dep-id';
2
- import type { Manifest, DependencyTypeShort } from '@vltpkg/types';
2
+ import type { NormalizedManifest, DependencyTypeShort } from '@vltpkg/types';
3
3
  import type { Spec, SpecLikeBase } from '@vltpkg/spec';
4
4
  export type EdgeLike = {
5
5
  name: string;
@@ -7,22 +7,27 @@ export type EdgeLike = {
7
7
  spec: SpecLikeBase;
8
8
  to?: NodeLike;
9
9
  type: DependencyTypeShort;
10
+ optional?: boolean;
11
+ peer?: boolean;
10
12
  };
11
13
  export type GraphLike = {
12
14
  importers: Set<NodeLike>;
13
15
  mainImporter: NodeLike;
14
16
  projectRoot: string;
15
17
  nodes: Map<DepID, NodeLike>;
18
+ nodesByName: Map<string, Set<NodeLike>>;
16
19
  edges: Set<EdgeLike>;
17
20
  addEdge: (type: DependencyTypeShort, spec: Spec, from: NodeLike, to?: NodeLike) => EdgeLike;
18
- addNode: (id?: DepID, manifest?: Manifest, spec?: Spec, name?: string, version?: string) => NodeLike;
21
+ addNode: (id?: DepID, manifest?: NormalizedManifest, spec?: Spec, name?: string, version?: string) => NodeLike;
19
22
  };
20
23
  export type NodeLike = {
21
24
  id: DepID;
25
+ confused: boolean;
22
26
  edgesIn: Set<EdgeLike>;
23
27
  edgesOut: Map<string, EdgeLike>;
24
28
  location?: string;
25
- manifest?: Manifest | null;
29
+ manifest?: NormalizedManifest | null;
30
+ rawManifest?: NormalizedManifest | null;
26
31
  name?: string | null;
27
32
  version?: string | null;
28
33
  integrity?: string | null;
@@ -33,7 +38,14 @@ export type NodeLike = {
33
38
  projectRoot: string;
34
39
  dev: boolean;
35
40
  optional: boolean;
41
+ modifier?: string | undefined;
42
+ registry?: string;
43
+ toJSON: () => Pick<NodeLike, 'id' | 'name' | 'version' | 'location' | 'importer' | 'manifest' | 'projectRoot' | 'integrity' | 'resolved' | 'dev' | 'optional' | 'confused'> & {
44
+ rawManifest?: NodeLike['manifest'];
45
+ };
36
46
  toString(): string;
37
47
  setResolved(): void;
48
+ setConfusedManifest(fixed: NormalizedManifest, confused?: NormalizedManifest): void;
49
+ maybeSetConfusedManifest(spec: Spec, confused?: NormalizedManifest): void;
38
50
  };
39
51
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEtD,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,YAAY,CAAA;IAClB,EAAE,CAAC,EAAE,QAAQ,CAAA;IACb,IAAI,EAAE,mBAAmB,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;IACxB,YAAY,EAAE,QAAQ,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IAC3B,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;IACpB,OAAO,EAAE,CACP,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,QAAQ,EACd,EAAE,CAAC,EAAE,QAAQ,KACV,QAAQ,CAAA;IACb,OAAO,EAAE,CACP,EAAE,CAAC,EAAE,KAAK,EACV,QAAQ,CAAC,EAAE,QAAQ,EACnB,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,KACb,QAAQ,CAAA;CACd,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,KAAK,CAAA;IAC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AAE,OAAO,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,OAAO,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,IAAI,CAChB,QAAQ,EACN,IAAI,GACJ,MAAM,GACN,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,aAAa,GACb,WAAW,GACX,UAAU,GACV,KAAK,GACL,UAAU,GACV,UAAU,CACb,GAAG;QACF,WAAW,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;KACnC,CAAA;IACD,QAAQ,IAAI,MAAM,CAAA;IAClB,WAAW,IAAI,IAAI,CAAA;IACnB,mBAAmB,CACjB,KAAK,EAAE,kBAAkB,EACzB,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,IAAI,CAAA;IACP,wBAAwB,CACtB,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,IAAI,CAAA;CACR,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { Manifest, DependencyTypeShort } from '@vltpkg/types'\nimport type { Spec, SpecLikeBase } from '@vltpkg/spec'\n\nexport type EdgeLike = {\n name: string\n from: NodeLike\n spec: SpecLikeBase\n to?: NodeLike\n type: DependencyTypeShort\n}\n\nexport type GraphLike = {\n importers: Set<NodeLike>\n mainImporter: NodeLike\n projectRoot: string\n nodes: Map<DepID, NodeLike>\n edges: Set<EdgeLike>\n addEdge: (\n type: DependencyTypeShort,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) => EdgeLike\n addNode: (\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) => NodeLike\n}\n\nexport type NodeLike = {\n id: DepID\n edgesIn: Set<EdgeLike>\n edgesOut: Map<string, EdgeLike>\n location?: string\n manifest?: Manifest | null\n name?: string | null\n version?: string | null\n integrity?: string | null\n resolved?: string | null\n importer: boolean\n graph: GraphLike\n mainImporter: boolean\n projectRoot: string\n dev: boolean\n optional: boolean\n toString(): string\n setResolved(): void\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type {\n NormalizedManifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Spec, SpecLikeBase } from '@vltpkg/spec'\n\nexport type EdgeLike = {\n name: string\n from: NodeLike\n spec: SpecLikeBase\n to?: NodeLike\n type: DependencyTypeShort\n optional?: boolean\n peer?: boolean\n}\n\nexport type GraphLike = {\n importers: Set<NodeLike>\n mainImporter: NodeLike\n projectRoot: string\n nodes: Map<DepID, NodeLike>\n nodesByName: Map<string, Set<NodeLike>>\n edges: Set<EdgeLike>\n addEdge: (\n type: DependencyTypeShort,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) => EdgeLike\n addNode: (\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) => NodeLike\n}\n\nexport type NodeLike = {\n id: DepID\n confused: boolean\n edgesIn: Set<EdgeLike>\n edgesOut: Map<string, EdgeLike>\n location?: string\n manifest?: NormalizedManifest | null\n rawManifest?: NormalizedManifest | null\n name?: string | null\n version?: string | null\n integrity?: string | null\n resolved?: string | null\n importer: boolean\n graph: GraphLike\n mainImporter: boolean\n projectRoot: string\n dev: boolean\n optional: boolean\n modifier?: string | undefined\n registry?: string\n toJSON: () => Pick<\n NodeLike,\n | 'id'\n | 'name'\n | 'version'\n | 'location'\n | 'importer'\n | 'manifest'\n | 'projectRoot'\n | 'integrity'\n | 'resolved'\n | 'dev'\n | 'optional'\n | 'confused'\n > & {\n rawManifest?: NodeLike['manifest']\n }\n toString(): string\n setResolved(): void\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ): void\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ): void\n}\n"]}
@@ -1,10 +1,8 @@
1
- import type { PackageInfoClientOptions } from '@vltpkg/package-info';
2
- import type { PackageJson } from '@vltpkg/package-json';
1
+ import type { PackageInfoClient } from '@vltpkg/package-info';
3
2
  import type { LoadOptions } from './actual/load.ts';
4
3
  import type { RemoveImportersDependenciesMap } from './dependencies.ts';
5
- export type UninstallOptions = PackageInfoClientOptions & LoadOptions & {
6
- projectRoot: string;
7
- packageJson: PackageJson;
4
+ export type UninstallOptions = LoadOptions & {
5
+ packageInfo: PackageInfoClient;
8
6
  };
9
7
  export declare const uninstall: (options: UninstallOptions, remove?: RemoveImportersDependenciesMap) => Promise<{
10
8
  graph: import("./graph.ts").Graph;