@vltpkg/graph 1.0.0-rc.6 → 1.0.0-rc.8

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 (58) hide show
  1. package/dist/esm/actual/load.js +8 -10
  2. package/dist/esm/actual/load.js.map +1 -1
  3. package/dist/esm/fixup-added-names.d.ts +16 -0
  4. package/dist/esm/fixup-added-names.d.ts.map +1 -0
  5. package/dist/esm/fixup-added-names.js +31 -0
  6. package/dist/esm/fixup-added-names.js.map +1 -0
  7. package/dist/esm/ideal/append-nodes.d.ts +2 -1
  8. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  9. package/dist/esm/ideal/append-nodes.js +42 -20
  10. package/dist/esm/ideal/append-nodes.js.map +1 -1
  11. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +4 -1
  12. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
  13. package/dist/esm/ideal/build-ideal-from-starting-graph.js +21 -17
  14. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
  15. package/dist/esm/ideal/build.d.ts.map +1 -1
  16. package/dist/esm/ideal/build.js +29 -0
  17. package/dist/esm/ideal/build.js.map +1 -1
  18. package/dist/esm/ideal/get-importer-specs.d.ts +9 -2
  19. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  20. package/dist/esm/ideal/get-importer-specs.js +80 -5
  21. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  22. package/dist/esm/ideal/refresh-ideal-graph.d.ts +12 -2
  23. package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -1
  24. package/dist/esm/ideal/refresh-ideal-graph.js +2 -2
  25. package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -1
  26. package/dist/esm/ideal/types.d.ts +13 -0
  27. package/dist/esm/ideal/types.d.ts.map +1 -1
  28. package/dist/esm/ideal/types.js.map +1 -1
  29. package/dist/esm/index.d.ts +1 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/install.d.ts.map +1 -1
  34. package/dist/esm/install.js +9 -1
  35. package/dist/esm/install.js.map +1 -1
  36. package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
  37. package/dist/esm/lockfile/load-edges.js +4 -3
  38. package/dist/esm/lockfile/load-edges.js.map +1 -1
  39. package/dist/esm/reify/add-edges.d.ts +1 -1
  40. package/dist/esm/reify/add-edges.d.ts.map +1 -1
  41. package/dist/esm/reify/add-edges.js +2 -1
  42. package/dist/esm/reify/add-edges.js.map +1 -1
  43. package/dist/esm/reify/index.js +1 -1
  44. package/dist/esm/reify/index.js.map +1 -1
  45. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  46. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  47. package/dist/esm/reify/update-importers-package-json.js +18 -15
  48. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  49. package/dist/esm/uninstall.d.ts.map +1 -1
  50. package/dist/esm/uninstall.js +10 -0
  51. package/dist/esm/uninstall.js.map +1 -1
  52. package/dist/esm/update.d.ts.map +1 -1
  53. package/dist/esm/update.js +10 -0
  54. package/dist/esm/update.js.map +1 -1
  55. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  56. package/dist/esm/visualization/mermaid-output.js +57 -16
  57. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  58. package/package.json +21 -21
@@ -1 +1 @@
1
- {"version":3,"file":"build-ideal-from-starting-graph.js","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAOzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,K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AAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,6CAA6C;IAC7C,KAAK,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;YACpC,SAAQ;QACV,CAAC;QAED,2DAA2D;QAC3D,6DAA6D;QAC7D,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,qEAAqE;IACrE,0CAA0C;IAC1C,MAAM,iBAAiB,CAAC,OAAO,CAAC,CAAA;IAEhC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;IAElB,OAAO,OAAO,CAAC,KAAK,CAAA;AACtB,CAAC,CAAA","sourcesContent":["import { getImporterSpecs } from './get-importer-specs.ts'\nimport { refreshIdealGraph } from './refresh-ideal-graph.ts'\nimport { resolveSaveType } from '../resolve-save-type.ts'\nimport type { RefreshIdealGraphOptions } from './refresh-ideal-graph.ts'\nimport type { Graph } from '../graph.ts'\n\nexport type BuildIdealFromStartingGraphOptions =\n RefreshIdealGraphOptions\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using the `graph` set\n * in options as a starting point. Also add / remove any dependencies\n * listed in the `add` and `remove` properties.\n */\nexport const buildIdealFromStartingGraph = async (\n options: BuildIdealFromStartingGraphOptions,\n): Promise<Graph> => {\n // Gets a map of dependencies that are keyed to its importer node ids,\n // merging values already found in the graph with user specified values.\n // Any dependencies that are already satisfied in the starting `graph`\n // are going to be pruned from the resulting object.\n const importerSpecs = getImporterSpecs(options)\n\n // merge modifiedDependencies flags\n options.add.modifiedDependencies =\n options.add.modifiedDependencies ||\n importerSpecs.add.modifiedDependencies\n options.remove.modifiedDependencies =\n options.remove.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies\n\n // merge values found on importer specs with\n // user-provided values from `options.add`\n for (const [importerId, deps] of importerSpecs.add) {\n const importer = options.graph.nodes.get(importerId)\n /* c8 ignore next - impossible */\n if (!importer) continue\n\n if (!options.add.has(importerId)) {\n options.add.set(importerId, deps)\n continue\n }\n\n // merge any deps found when reading the importers manifest\n // with the ones provided by the user in the `add` options,\n // user-provided deps should take precedence\n for (const [depName, dep] of deps) {\n if (!options.add.get(importerId)?.has(depName)) {\n options.add.get(importerId)?.set(depName, dep)\n }\n\n // update the save type for deps when using an implicit type\n dep.type = resolveSaveType(importer, depName, dep.type)\n }\n }\n\n // merge values found on importer specs with\n // user-provided values from `options.remove`\n for (const [importerId, deps] of importerSpecs.remove) {\n if (!options.remove.has(importerId)) {\n options.remove.set(importerId, deps)\n continue\n }\n\n // merge any deps found when reading the importers manifest\n // with the ones provided by the user in the `remove` options\n for (const depName of deps) {\n options.remove.get(importerId)?.add(depName)\n }\n }\n\n // refreshs the current graph adding the nodes marked for addition\n // and removing the ones marked for removal, while also recalculating\n // peer dependencies and default locations\n await refreshIdealGraph(options)\n\n options.graph.gc()\n\n return options.graph\n}\n"]}
1
+ {"version":3,"file":"build-ideal-from-starting-graph.js","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAUzD;;;;;;GAMG;AACH,MAAM,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5D,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,wCAAwC;IACxC,6CAA6C;IAC7C,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,aAAa,CAAC,MAAM,EAAE,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAChC,SAAQ;QACV,CAAC;QAED,uDAAuD;QACvD,6DAA6D;QAC7D,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QAC1C,CAAC;IACH,CAAC;IAED,kEAAkE;IAClE,qEAAqE;IACrE,0CAA0C;IAC1C,MAAM,iBAAiB,CAAC;QACtB,GAAG,OAAO;QACV,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,eAAe,EAAE,aAAa,CAAC,eAAe;KAC/C,CAAC,CAAA;IAEF,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;IAElB,OAAO,OAAO,CAAC,KAAK,CAAA;AACtB,CAAC,CAAA","sourcesContent":["import { getImporterSpecs } from './get-importer-specs.ts'\nimport { refreshIdealGraph } from './refresh-ideal-graph.ts'\nimport { resolveSaveType } from '../resolve-save-type.ts'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { RefreshIdealGraphOptions } from './refresh-ideal-graph.ts'\nimport type { Graph } from '../graph.ts'\n\nexport type BuildIdealFromStartingGraphOptions =\n RefreshIdealGraphOptions & {\n packageJson: PackageJson\n }\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using the `graph` set\n * in options as a starting point. Also add / remove any dependencies\n * listed in the `add` and `remove` properties.\n */\nexport const buildIdealFromStartingGraph = async (\n options: BuildIdealFromStartingGraphOptions,\n): Promise<Graph> => {\n // Gets a map of dependencies that are keyed to its importer node ids,\n // merging values already found in the graph with user specified values.\n // Any dependencies that are already satisfied in the starting `graph`\n // are going to be pruned from the resulting object.\n const importerSpecs = getImporterSpecs(options)\n\n // merge modifiedDependencies flags\n options.add.modifiedDependencies =\n options.add.modifiedDependencies ||\n importerSpecs.add.modifiedDependencies\n options.remove.modifiedDependencies =\n options.remove.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies\n\n // merge values found on node specs with\n // user-provided values from `options.add`\n for (const [nodeId, deps] of importerSpecs.add) {\n const node = options.graph.nodes.get(nodeId)\n /* c8 ignore next - impossible */\n if (!node) continue\n\n if (!options.add.has(nodeId)) {\n options.add.set(nodeId, deps)\n continue\n }\n\n // merge any deps found when reading the nodes manifest\n // with the ones provided by the user in the `add` options,\n // user-provided deps should take precedence\n for (const [depName, dep] of deps) {\n if (!options.add.get(nodeId)?.has(depName)) {\n options.add.get(nodeId)?.set(depName, dep)\n }\n\n // update the save type for deps when using an implicit type\n dep.type = resolveSaveType(node, depName, dep.type)\n }\n }\n\n // merge values found on node specs with\n // user-provided values from `options.remove`\n for (const [nodeId, deps] of importerSpecs.remove) {\n if (!options.remove.has(nodeId)) {\n options.remove.set(nodeId, deps)\n continue\n }\n\n // merge any deps found when reading the nodes manifest\n // with the ones provided by the user in the `remove` options\n for (const depName of deps) {\n options.remove.get(nodeId)?.add(depName)\n }\n }\n\n // refreshs the current graph adding the nodes marked for addition\n // and removing the ones marked for removal, while also recalculating\n // peer dependencies and default locations\n await refreshIdealGraph({\n ...options,\n transientAdd: importerSpecs.transientAdd,\n transientRemove: importerSpecs.transientRemove,\n })\n\n options.graph.gc()\n\n return options.graph\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP,iBAAiB,KACzB,OAAO,CAAC,KAAK,CAkCf,CAAA"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAmBD;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP,iBAAiB,KACzB,OAAO,CAAC,KAAK,CAgDf,CAAA"}
@@ -1,8 +1,23 @@
1
+ import { error } from '@vltpkg/error-cause';
1
2
  import { graphStep } from '@vltpkg/output';
2
3
  import { load as loadActual } from "../actual/load.js";
3
4
  import { load as loadVirtual } from "../lockfile/load.js";
4
5
  import { buildIdealFromStartingGraph } from "./build-ideal-from-starting-graph.js";
6
+ import { splitDepID } from '@vltpkg/dep-id';
5
7
  const getMap = (m) => m ?? new Map();
8
+ /**
9
+ * Validates that a file dependency node exists in the graph after
10
+ * a successful graph build. This helps providing an actionable error
11
+ * message in case the current working directory is a linked nested
12
+ * folder that hasn't yet been added as a dependency to an importer
13
+ * in the project.
14
+ */
15
+ const validateFileDepNode = (graph, id) => {
16
+ const [type, path] = splitDepID(id);
17
+ if (type === 'file' && !graph.nodes.get(id)) {
18
+ throw error('The current working dir is not a dependency of this project', { path });
19
+ }
20
+ };
6
21
  /**
7
22
  * Builds an ideal {@link Graph} representing the dependencies that
8
23
  * should be present in order to fulfill the requirements defined
@@ -41,6 +56,20 @@ export const build = async (options) => {
41
56
  actual: options.actual,
42
57
  });
43
58
  done();
59
+ // when adding or removing a new dependency from a file dep,
60
+ // validate the receiver node was present in the graph
61
+ if (options.add) {
62
+ for (const [addKey, value] of options.add.entries()) {
63
+ if (value.size)
64
+ validateFileDepNode(res, addKey);
65
+ }
66
+ }
67
+ if (options.remove) {
68
+ for (const [removeKey, value] of options.remove.entries()) {
69
+ if (value.size)
70
+ validateFileDepNode(res, removeKey);
71
+ }
72
+ }
44
73
  return res;
45
74
  };
46
75
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AC,MAAM,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IACF,IAAI,EAAE,CAAA;IACN,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { graphStep } from '@vltpkg/output'\nimport { load as loadActual } from '../actual/load.ts'\nimport { load as loadVirtual } from '../lockfile/load.ts'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions as LoadActualOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type BuildIdealOptions = LoadActualOptions & {\n /**\n * An actual graph\n */\n actual?: Graph\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n const done = graphStep('build')\n\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n })\n }\n\n const res = await buildIdealFromStartingGraph({\n ...options,\n scurry,\n add: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n actual: options.actual,\n })\n done()\n return res\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AASlF,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAI3C,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AA8BvB;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,CAAC,KAAY,EAAE,EAAS,EAAE,EAAE;IACtD,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IACnC,IAAI,IAAI,KAAK,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5C,MAAM,KAAK,CACT,6DAA6D,EAC7D,EAAE,IAAI,EAAE,CACT,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,OAA0B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AE,EAAE,CAAC;YAC1D,IAAI,KAAK,CAAC,IAAI;gBAAE,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { graphStep } from '@vltpkg/output'\nimport { load as loadActual } from '../actual/load.ts'\nimport { load as loadVirtual } from '../lockfile/load.ts'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions as LoadActualOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport { splitDepID } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type BuildIdealOptions = LoadActualOptions & {\n /**\n * An actual graph\n */\n actual?: Graph\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Validates that a file dependency node exists in the graph after\n * a successful graph build. This helps providing an actionable error\n * message in case the current working directory is a linked nested\n * folder that hasn't yet been added as a dependency to an importer\n * in the project.\n */\nconst validateFileDepNode = (graph: Graph, id: DepID) => {\n const [type, path] = splitDepID(id)\n if (type === 'file' && !graph.nodes.get(id)) {\n throw error(\n 'The current working dir is not a dependency of this project',\n { path },\n )\n }\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n const done = graphStep('build')\n\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n })\n }\n\n const res = await buildIdealFromStartingGraph({\n ...options,\n scurry,\n add: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n actual: options.actual,\n })\n done()\n\n // when adding or removing a new dependency from a file dep,\n // validate the receiver node was present in the graph\n if (options.add) {\n for (const [addKey, value] of options.add.entries()) {\n if (value.size) validateFileDepNode(res, addKey)\n }\n }\n if (options.remove) {\n for (const [removeKey, value] of options.remove.entries()) {\n if (value.size) validateFileDepNode(res, removeKey)\n }\n }\n\n return res\n}\n"]}
@@ -1,7 +1,12 @@
1
1
  import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
2
- import type { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.ts';
2
+ import type { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions, TransientAddMap, TransientRemoveMap } from './types.ts';
3
3
  import type { SpecOptions } from '@vltpkg/spec';
4
- export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & BuildIdealRemoveOptions & SpecOptions;
4
+ import type { PackageJson } from '@vltpkg/package-json';
5
+ import type { PathScurry } from 'path-scurry';
6
+ export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & BuildIdealRemoveOptions & SpecOptions & {
7
+ scurry: PathScurry;
8
+ packageJson: PackageJson;
9
+ };
5
10
  /**
6
11
  * Given a {@link Graph} and a list of {@link Dependency}, merges the
7
12
  * dependencies info found in the graph importers and returns the add & remove
@@ -10,5 +15,7 @@ export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraph
10
15
  export declare const getImporterSpecs: (options: GetImporterSpecsOptions) => {
11
16
  add: AddImportersDependenciesMap;
12
17
  remove: RemoveImportersDependenciesMap;
18
+ transientAdd: TransientAddMap;
19
+ transientRemove: TransientRemoveMap;
13
20
  };
14
21
  //# sourceMappingURL=get-importer-specs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAMnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GACxD,0BAA0B,GAC1B,uBAAuB,GACvB,WAAW,CAAA;AAyBb;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAClB,uBAAuB;;;CA4FjC,CAAA"}
1
+ {"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAMnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GACxD,0BAA0B,GAC1B,uBAAuB,GACvB,WAAW,GAAG;IACZ,MAAM,EAAE,UAAU,CAAA;IAClB,WAAW,EAAE,WAAW,CAAA;CACzB,CAAA;AAyBH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAClB,uBAAuB;;;;;CAoLjC,CAAA"}
@@ -1,4 +1,3 @@
1
- import { error } from '@vltpkg/error-cause';
2
1
  import { longDependencyTypes } from '@vltpkg/types';
3
2
  import { shorten, asDependency } from "../dependencies.js";
4
3
  import { removeSatisfiedSpecs } from "./remove-satisfied-specs.js";
@@ -47,23 +46,85 @@ export const getImporterSpecs = (options) => {
47
46
  const deps = Object.entries(importer.manifest?.[depType] ?? {});
48
47
  for (const [depName, depSpec] of deps) {
49
48
  const edge = importer.edgesOut.get(depName);
49
+ // skip if the edge exists and already uses the same spec
50
+ if (edge?.to && depSpec === edge.spec.bareSpec)
51
+ continue;
50
52
  const dependency = asDependency({
51
53
  spec: Spec.parse(depName, depSpec, options),
52
54
  type: shorten(depType, depName, importer.manifest),
53
55
  });
54
- if (!edge?.to) {
55
- addDeps.set(depName, dependency);
56
- }
56
+ addDeps.set(depName, dependency);
57
57
  }
58
58
  }
59
59
  addResult.set(importer.id, addDeps);
60
60
  removeResult.set(importer.id, removeDeps);
61
61
  }
62
+ // Maps to store dependencies targeting non-importer nodes (e.g., nested folders)
63
+ // These will be injected when the target node is placed in the graph
64
+ const transientAdd = new Map();
65
+ const transientRemove = new Map();
66
+ // Traverse all nodes in the graph to find file type dependencies that are directories
67
+ // and populate transientAdd/transientRemove with their manifest dependencies
68
+ // Only process when scurry and packageJson are available
69
+ for (const node of graph.nodes.values()) {
70
+ // Skip importers as they're already handled above and also skip
71
+ // any non-file type dependencies
72
+ if (graph.importers.has(node) || !node.id.startsWith('file'))
73
+ continue;
74
+ // check if this is a file type dependency that is a directory
75
+ const nodePath = options.scurry.cwd.resolve(node.location);
76
+ const stat = nodePath.lstatSync();
77
+ if (stat?.isDirectory()) {
78
+ // load the manifest for this directory (throw if it does not exist)
79
+ const manifest = options.packageJson.read(nodePath.fullpath());
80
+ // should always set the manifest to the read manifest
81
+ node.manifest = manifest;
82
+ // create a map of dependencies from the manifest
83
+ const addDeps = new Map();
84
+ // check for edges not in manifest (should be removed)
85
+ const removeDeps = new Set();
86
+ for (const edge of node.edgesOut.values()) {
87
+ if (!hasDepName(node, edge) &&
88
+ !add.get(node.id)?.has(edge.name)) {
89
+ removeDeps.add(edge.name);
90
+ }
91
+ }
92
+ // iterate over manifest dependencies to add them if
93
+ // they're missing from the graph
94
+ for (const depType of longDependencyTypes) {
95
+ const deps = Object.entries(manifest[depType] ?? {});
96
+ for (const [depName, depSpec] of deps) {
97
+ const edge = node.edgesOut.get(depName);
98
+ // skip if the edge exists and already uses the same spec
99
+ if (edge?.to && depSpec === edge.spec.bareSpec)
100
+ continue;
101
+ // add the dependency to the addDeps map
102
+ const dependency = asDependency({
103
+ spec: Spec.parse(depName, depSpec, options),
104
+ type: shorten(depType, depName, manifest),
105
+ });
106
+ addDeps.set(depName, dependency);
107
+ }
108
+ }
109
+ // store in transientAdd if there are any dependencies
110
+ if (addDeps.size > 0) {
111
+ transientAdd.set(node.id, addDeps);
112
+ }
113
+ // store in transientRemove if there are any to remove
114
+ if (removeDeps.size > 0) {
115
+ transientRemove.set(node.id, removeDeps);
116
+ }
117
+ }
118
+ }
62
119
  // merges any provided specs to add to the current found results
63
120
  for (const [id, addDeps] of add.entries()) {
64
121
  const deps = addResult.get(id);
65
122
  if (!deps) {
66
- throw error('Not an importer', { found: id });
123
+ // Not an importer - only store file-type deps for later injection
124
+ if (id.startsWith('file')) {
125
+ transientAdd.set(id, addDeps);
126
+ }
127
+ continue;
67
128
  }
68
129
  for (const [name, dep] of addDeps.entries()) {
69
130
  deps.set(name, dep);
@@ -78,6 +139,18 @@ export const getImporterSpecs = (options) => {
78
139
  importerRemoveItem.add(depName);
79
140
  }
80
141
  }
142
+ else if (key.startsWith('file')) {
143
+ // Not an importer - only store file-type deps in transientRemove
144
+ const existing = transientRemove.get(key);
145
+ if (existing) {
146
+ for (const depName of removeSet) {
147
+ existing.add(depName);
148
+ }
149
+ }
150
+ else {
151
+ transientRemove.set(key, new Set(removeSet));
152
+ }
153
+ }
81
154
  }
82
155
  // Removes any references to an importer that no longer has specs
83
156
  for (const [key, removeItem] of removeResult) {
@@ -101,6 +174,8 @@ export const getImporterSpecs = (options) => {
101
174
  return {
102
175
  add: addResult,
103
176
  remove: removeResult,
177
+ transientAdd,
178
+ transientRemove,
104
179
  };
105
180
  };
106
181
  //# sourceMappingURL=get-importer-specs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-importer-specs.js","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAM1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAUlE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAQnC,MAAM,UAAU,GAAG,CAAC,QAAc,EAAE,IAAU,EAAW,EAAE;IACzD,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;YACpD,OA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AAK,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,MAAM,EAAE,CAAC;QACtC,MAAM,kBAAkB,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,kBAAkB,EAAE,CAAC;YACvB,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;gBAChC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAED,iEAAiE;IACjE,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,YAAY,EAAE,CAAC;QAC7C,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC1B,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,oBAAoB,CAAC;QACnB,GAAG,EAAE,SAAS;QACd,KAAK;KACN,CAAC,CAAA;IAEF,2CAA2C;IAC3C,8CAA8C;IAC9C,KAAK,MAAM,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACrB,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAA;YACrC,MAAK;QACP,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport { shorten, asDependency } from '../dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport type { Edge } from '../edge.ts'\nimport type { Node } from '../node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\n\nexport type GetImporterSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions &\n SpecOptions\n\nconst hasDepName = (importer: Node, edge: Edge): boolean => {\n for (const depType of longDependencyTypes) {\n const listedDeps = importer.manifest?.[depType]\n if (listedDeps && Object.hasOwn(listedDeps, edge.name))\n return true\n }\n return false\n}\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\n/**\n * Given a {@link Graph} and a list of {@link Dependency}, merges the\n * dependencies info found in the graph importers and returns the add & remove\n * results as a Map in which keys are {@link DepID} of each importer node.\n */\nexport const getImporterSpecs = (\n options: GetImporterSpecsOptions,\n) => {\n const { add, graph, remove } = options\n const addResult: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const removeResult: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n\n // traverse the list of importers in the starting graph\n for (const importer of graph.importers) {\n // uses a Map keying to the spec.name in order to easily make sure there's\n // only a single dependency entry for a given dependency for each importer\n const addDeps = new Map<string, Dependency>()\n const removeDeps = new Set<string>()\n // if an edge from the graph is not listed in the manifest,\n // add that edge to the list of dependencies to be removed\n for (const edge of importer.edgesOut.values()) {\n if (\n !hasDepName(importer, edge) &&\n !add.get(importer.id)?.has(edge.name)\n ) {\n removeDeps.add(edge.name)\n removeResult.modifiedDependencies = true\n }\n }\n // if a dependency is listed in the manifest but not in the graph,\n // add that dependency to the list of dependencies to be added\n for (const depType of longDependencyTypes) {\n const deps = Object.entries(importer.manifest?.[depType] ?? {})\n for (const [depName, depSpec] of deps) {\n const edge = importer.edgesOut.get(depName)\n const dependency = asDependency({\n spec: Spec.parse(depName, depSpec, options),\n type: shorten(depType, depName, importer.manifest),\n })\n if (!edge?.to) {\n addDeps.set(depName, dependency)\n }\n }\n }\n addResult.set(importer.id, addDeps)\n removeResult.set(importer.id, removeDeps)\n }\n\n // merges any provided specs to add to the current found results\n for (const [id, addDeps] of add.entries()) {\n const deps = addResult.get(id)\n if (!deps) {\n throw error('Not an importer', { found: id })\n }\n for (const [name, dep] of addDeps.entries()) {\n deps.set(name, dep)\n }\n }\n\n // Merges results from user-provided `remove` option with any remove\n // results found from comparing the manifest with the loaded graph\n for (const [key, removeSet] of remove) {\n const importerRemoveItem = removeResult.get(key)\n if (importerRemoveItem) {\n for (const depName of removeSet) {\n importerRemoveItem.add(depName)\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [key, removeItem] of removeResult) {\n if (removeItem.size === 0) {\n removeResult.delete(key)\n }\n }\n\n // removes already satisfied dependencies from the dependencies list\n removeSatisfiedSpecs({\n add: addResult,\n graph,\n })\n\n // set the modifiedDependencies flag if any\n // of the importers have modified dependencies\n for (const addDeps of addResult.values()) {\n if (addDeps.size > 0) {\n addResult.modifiedDependencies = true\n break\n }\n }\n\n return {\n add: addResult,\n remove: removeResult,\n }\n}\n"]}
1
+ {"version":3,"file":"get-importer-specs.js","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAM1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAYlE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAanC,MAAM,UAAU,GAAG,CAAC,QAAc,EAAE,IAAU,EAAW,EAAE;IACzD,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,EA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AC,MAAM,EAAE,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YACrB,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAA;YACrC,MAAK;QACP,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,YAAY;QACpB,YAAY;QACZ,eAAe;KAChB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { longDependencyTypes } from '@vltpkg/types'\nimport { shorten, asDependency } from '../dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n TransientAddMap,\n TransientRemoveMap,\n} from './types.ts'\nimport type { Edge } from '../edge.ts'\nimport type { Node } from '../node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { PathScurry } from 'path-scurry'\n\nexport type GetImporterSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions &\n SpecOptions & {\n scurry: PathScurry\n packageJson: PackageJson\n }\n\nconst hasDepName = (importer: Node, edge: Edge): boolean => {\n for (const depType of longDependencyTypes) {\n const listedDeps = importer.manifest?.[depType]\n if (listedDeps && Object.hasOwn(listedDeps, edge.name))\n return true\n }\n return false\n}\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\n/**\n * Given a {@link Graph} and a list of {@link Dependency}, merges the\n * dependencies info found in the graph importers and returns the add & remove\n * results as a Map in which keys are {@link DepID} of each importer node.\n */\nexport const getImporterSpecs = (\n options: GetImporterSpecsOptions,\n) => {\n const { add, graph, remove } = options\n const addResult: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const removeResult: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n\n // traverse the list of importers in the starting graph\n for (const importer of graph.importers) {\n // uses a Map keying to the spec.name in order to easily make sure there's\n // only a single dependency entry for a given dependency for each importer\n const addDeps = new Map<string, Dependency>()\n const removeDeps = new Set<string>()\n // if an edge from the graph is not listed in the manifest,\n // add that edge to the list of dependencies to be removed\n for (const edge of importer.edgesOut.values()) {\n if (\n !hasDepName(importer, edge) &&\n !add.get(importer.id)?.has(edge.name)\n ) {\n removeDeps.add(edge.name)\n removeResult.modifiedDependencies = true\n }\n }\n // if a dependency is listed in the manifest but not in the graph,\n // add that dependency to the list of dependencies to be added\n for (const depType of longDependencyTypes) {\n const deps = Object.entries(importer.manifest?.[depType] ?? {})\n for (const [depName, depSpec] of deps) {\n const edge = importer.edgesOut.get(depName)\n\n // skip if the edge exists and already uses the same spec\n if (edge?.to && depSpec === edge.spec.bareSpec) continue\n\n const dependency = asDependency({\n spec: Spec.parse(depName, depSpec, options),\n type: shorten(depType, depName, importer.manifest),\n })\n addDeps.set(depName, dependency)\n }\n }\n addResult.set(importer.id, addDeps)\n removeResult.set(importer.id, removeDeps)\n }\n\n // Maps to store dependencies targeting non-importer nodes (e.g., nested folders)\n // These will be injected when the target node is placed in the graph\n const transientAdd = new Map() as TransientAddMap\n const transientRemove = new Map() as TransientRemoveMap\n\n // Traverse all nodes in the graph to find file type dependencies that are directories\n // and populate transientAdd/transientRemove with their manifest dependencies\n // Only process when scurry and packageJson are available\n for (const node of graph.nodes.values()) {\n // Skip importers as they're already handled above and also skip\n // any non-file type dependencies\n if (graph.importers.has(node) || !node.id.startsWith('file'))\n continue\n\n // check if this is a file type dependency that is a directory\n const nodePath = options.scurry.cwd.resolve(node.location)\n const stat = nodePath.lstatSync()\n\n if (stat?.isDirectory()) {\n // load the manifest for this directory (throw if it does not exist)\n const manifest = options.packageJson.read(nodePath.fullpath())\n\n // should always set the manifest to the read manifest\n node.manifest = manifest\n\n // create a map of dependencies from the manifest\n const addDeps = new Map<string, Dependency>()\n\n // check for edges not in manifest (should be removed)\n const removeDeps = new Set<string>()\n for (const edge of node.edgesOut.values()) {\n if (\n !hasDepName(node, edge) &&\n !add.get(node.id)?.has(edge.name)\n ) {\n removeDeps.add(edge.name)\n }\n }\n\n // iterate over manifest dependencies to add them if\n // they're missing from the graph\n for (const depType of longDependencyTypes) {\n const deps = Object.entries(manifest[depType] ?? {})\n for (const [depName, depSpec] of deps) {\n const edge = node.edgesOut.get(depName)\n\n // skip if the edge exists and already uses the same spec\n if (edge?.to && depSpec === edge.spec.bareSpec) continue\n\n // add the dependency to the addDeps map\n const dependency = asDependency({\n spec: Spec.parse(depName, depSpec, options),\n type: shorten(depType, depName, manifest),\n })\n addDeps.set(depName, dependency)\n }\n }\n\n // store in transientAdd if there are any dependencies\n if (addDeps.size > 0) {\n transientAdd.set(node.id, addDeps)\n }\n\n // store in transientRemove if there are any to remove\n if (removeDeps.size > 0) {\n transientRemove.set(node.id, removeDeps)\n }\n }\n }\n\n // merges any provided specs to add to the current found results\n for (const [id, addDeps] of add.entries()) {\n const deps = addResult.get(id)\n if (!deps) {\n // Not an importer - only store file-type deps for later injection\n if (id.startsWith('file')) {\n transientAdd.set(id, addDeps)\n }\n continue\n }\n for (const [name, dep] of addDeps.entries()) {\n deps.set(name, dep)\n }\n }\n\n // Merges results from user-provided `remove` option with any remove\n // results found from comparing the manifest with the loaded graph\n for (const [key, removeSet] of remove) {\n const importerRemoveItem = removeResult.get(key)\n if (importerRemoveItem) {\n for (const depName of removeSet) {\n importerRemoveItem.add(depName)\n }\n } else if (key.startsWith('file')) {\n // Not an importer - only store file-type deps in transientRemove\n const existing = transientRemove.get(key)\n if (existing) {\n for (const depName of removeSet) {\n existing.add(depName)\n }\n } else {\n transientRemove.set(key, new Set(removeSet))\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [key, removeItem] of removeResult) {\n if (removeItem.size === 0) {\n removeResult.delete(key)\n }\n }\n\n // removes already satisfied dependencies from the dependencies list\n removeSatisfiedSpecs({\n add: addResult,\n graph,\n })\n\n // set the modifiedDependencies flag if any\n // of the importers have modified dependencies\n for (const addDeps of addResult.values()) {\n if (addDeps.size > 0) {\n addResult.modifiedDependencies = true\n break\n }\n }\n\n return {\n add: addResult,\n remove: removeResult,\n transientAdd,\n transientRemove,\n }\n}\n"]}
@@ -2,7 +2,7 @@ import type { PathScurry } from 'path-scurry';
2
2
  import type { PackageInfoClient } from '@vltpkg/package-info';
3
3
  import type { SpecOptions } from '@vltpkg/spec';
4
4
  import type { RollbackRemove } from '@vltpkg/rollback-remove';
5
- import type { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.ts';
5
+ import type { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions, TransientAddMap, TransientRemoveMap } from './types.ts';
6
6
  import type { GraphModifier } from '../modifiers.ts';
7
7
  import type { Graph } from '../graph.ts';
8
8
  export type RefreshIdealGraphOptions = BuildIdealAddOptions & BuildIdealRemoveOptions & BuildIdealFromGraphOptions & SpecOptions & {
@@ -26,11 +26,21 @@ export type RefreshIdealGraphOptions = BuildIdealAddOptions & BuildIdealRemoveOp
26
26
  * A {@link RollbackRemove} instance to handle extraction rollbacks
27
27
  */
28
28
  remover: RollbackRemove;
29
+ /**
30
+ * Dependencies to be added to non-importer nodes when they are placed.
31
+ * Used for nested folder dependencies that are not importers.
32
+ */
33
+ transientAdd?: TransientAddMap;
34
+ /**
35
+ * Dependencies to be removed from non-importer nodes when they are placed.
36
+ * Used for nested folder dependencies that are not importers.
37
+ */
38
+ transientRemove?: TransientRemoveMap;
29
39
  };
30
40
  /**
31
41
  * Rebuilds the provided ideal graph.
32
42
  */
33
- export declare const refreshIdealGraph: ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, ...specOptions }: RefreshIdealGraphOptions) => Promise<void>;
43
+ export declare const refreshIdealGraph: ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, transientAdd, transientRemove, ...specOptions }: RefreshIdealGraphOptions) => Promise<void>;
34
44
  /**
35
45
  * Retrieve the next unique index for a peer context set.
36
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-ideal-graph.d.ts","sourceRoot":"","sources":["../../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,GACzD,uBAAuB,GACvB,0BAA0B,GAC1B,WAAW,GAAG;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IAEd;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;CACxB,CAAA;AAkCH;;GAEG;AACH,eAAO,MAAM,iBAAiB,4FAU3B,wBAAwB,kBAgE1B,CAAA;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB,cAA2B,CAAA"}
1
+ {"version":3,"file":"refresh-ideal-graph.d.ts","sourceRoot":"","sources":["../../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,kBAAkB,EACnB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,GACzD,uBAAuB,GACvB,0BAA0B,GAC1B,WAAW,GAAG;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IAEd;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IAEvB;;;OAGG;IACH,YAAY,CAAC,EAAE,eAAe,CAAA;IAE9B;;;OAGG;IACH,eAAe,CAAC,EAAE,kBAAkB,CAAA;CACrC,CAAA;AAkCH;;GAEG;AACH,eAAO,MAAM,iBAAiB,2HAY3B,wBAAwB,kBAkE1B,CAAA;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB,cAA2B,CAAA"}
@@ -26,7 +26,7 @@ const getOrderedImporters = (graph) => {
26
26
  /**
27
27
  * Rebuilds the provided ideal graph.
28
28
  */
29
- export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, ...specOptions }) => {
29
+ export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, transientAdd, transientRemove, ...specOptions }) => {
30
30
  const seen = new Set();
31
31
  const extractPromises = [];
32
32
  const seenExtracted = new Set();
@@ -57,7 +57,7 @@ export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, sc
57
57
  const modifierRefs = modifiers?.tryDependencies(importer, deps);
58
58
  // Add new nodes for packages defined in the dependencies list fetching
59
59
  // metadata from the registry manifests and updating the graph
60
- await appendNodes(packageInfo, graph, importer, deps, scurry, specOptions, seen, addedDeps, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover);
60
+ await appendNodes(packageInfo, graph, importer, deps, scurry, specOptions, seen, addedDeps, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover, transientAdd, transientRemove);
61
61
  }
62
62
  // set default node locations, if possible
63
63
  for (const node of graph.nodes.values()) {
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-ideal-graph.js","sourceRoot":"","sources":["../../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAA;AA8C1E;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAC,KAAY,EAAU,EAAE;IACnD,MAAM,gBAAgB,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1D,8CAA8C;QAC9C,MAAM,OAAO,GACX,CACE,CAAC,CAAC,QAAQ,EAAE,gBAAgB;YAC5B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,MAAM,GAAG,CAAC,CACpD,CAAC,CAAC;YACD,CAAC;YACH,CAAC,CAAC,CAAC,CAAA;QACL,MAAM,OAAO,GACX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dependencies.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\nexport type RefreshIdealGraphOptions = BuildIdealAddOptions &\n BuildIdealRemoveOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n\n /**\n * The actual graph to compare against for early extraction\n */\n actual?: Graph\n\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n }\n\n/**\n * Returns an ordered list of importer nodes.\n */\nconst getOrderedImporters = (graph: Graph): Node[] => {\n const orderedImporters = [...graph.importers].sort((a, b) => {\n // sorts importers first by usage of peer deps\n const aIsPeer =\n (\n a.manifest?.peerDependencies &&\n Object.keys(a.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n const bIsPeer =\n (\n b.manifest?.peerDependencies &&\n Object.keys(b.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n\n // importers with regular deps only first, with peer deps last\n if (aIsPeer !== bIsPeer) {\n return aIsPeer - bIsPeer\n }\n\n // if both are in the same group, sort alphabetically by manifest name\n return a.name.localeCompare(b.name, 'en')\n })\n return orderedImporters\n}\n\n/**\n * Rebuilds the provided ideal graph.\n */\nexport const refreshIdealGraph = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n actual,\n remove,\n remover,\n ...specOptions\n}: RefreshIdealGraphOptions) => {\n const seen = new Set<DepID>()\n const extractPromises: Promise<ExtractResult>[] = []\n const seenExtracted = new Set<DepID>()\n\n // gets an ordered list of importers to ensure deterministic processing\n const orderedImporters = getOrderedImporters(graph)\n const depsPerImporter = new Map<Node, Dependency[]>()\n for (const importer of orderedImporters) {\n // gets an ordered list of dependencies for this importer\n // while also taking into account additions and removals\n const deps = getNodeOrderedDependencies(importer, { add, remove })\n depsPerImporter.set(importer, deps)\n }\n\n // removes all edges to start recalculating the graph\n if (add.modifiedDependencies || remove.modifiedDependencies) {\n graph.resetEdges()\n }\n\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const importer of orderedImporters) {\n modifiers?.tryImporter(importer)\n\n // gets a ref to the map of dependencies being added to this importer\n const addedDeps = add.get(importer.id)\n\n const deps = depsPerImporter.get(importer)\n /* c8 ignore next */\n if (!deps) continue\n\n // gets a ref to the list of modifier functions for this set of deps\n const modifierRefs = modifiers?.tryDependencies(importer, deps)\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n addedDeps,\n modifiers,\n modifierRefs,\n extractPromises,\n actual,\n seenExtracted,\n remover,\n )\n }\n\n // set default node locations, if possible\n for (const node of graph.nodes.values()) {\n node.setDefaultLocation()\n }\n\n // Wait for all extraction promises to complete\n if (extractPromises.length > 0) {\n await Promise.all(extractPromises)\n }\n}\n\n/**\n * Global index to assign unique ids used to track peer context sets.\n */\nlet peerContextIndex = 0\n/**\n * Retrieve the next unique index for a peer context set.\n */\nexport const nextPeerContextIndex = () => peerContextIndex++\n"]}
1
+ {"version":3,"file":"refresh-ideal-graph.js","sourceRoot":"","sources":["../../../src/ideal/refresh-ideal-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mB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,EACP,YAAY,EACZ,eAAe,CAChB,CAAA;IACH,CAAC;IAED,0CAA0C;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAED,+CAA+C;IAC/C,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACpC,CAAC;AACH,CAAC,CAAA;AAED;;GAEG;AACH,IAAI,gBAAgB,GAAG,CAAC,CAAA;AACxB;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,gBAAgB,EAAE,CAAA","sourcesContent":["import { appendNodes } from './append-nodes.ts'\nimport { getNodeOrderedDependencies } from './get-ordered-dependencies.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n TransientAddMap,\n TransientRemoveMap,\n} from './types.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\nexport type RefreshIdealGraphOptions = BuildIdealAddOptions &\n BuildIdealRemoveOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n\n /**\n * The actual graph to compare against for early extraction\n */\n actual?: Graph\n\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n\n /**\n * Dependencies to be added to non-importer nodes when they are placed.\n * Used for nested folder dependencies that are not importers.\n */\n transientAdd?: TransientAddMap\n\n /**\n * Dependencies to be removed from non-importer nodes when they are placed.\n * Used for nested folder dependencies that are not importers.\n */\n transientRemove?: TransientRemoveMap\n }\n\n/**\n * Returns an ordered list of importer nodes.\n */\nconst getOrderedImporters = (graph: Graph): Node[] => {\n const orderedImporters = [...graph.importers].sort((a, b) => {\n // sorts importers first by usage of peer deps\n const aIsPeer =\n (\n a.manifest?.peerDependencies &&\n Object.keys(a.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n const bIsPeer =\n (\n b.manifest?.peerDependencies &&\n Object.keys(b.manifest.peerDependencies).length > 0\n ) ?\n 1\n : 0\n\n // importers with regular deps only first, with peer deps last\n if (aIsPeer !== bIsPeer) {\n return aIsPeer - bIsPeer\n }\n\n // if both are in the same group, sort alphabetically by manifest name\n return a.name.localeCompare(b.name, 'en')\n })\n return orderedImporters\n}\n\n/**\n * Rebuilds the provided ideal graph.\n */\nexport const refreshIdealGraph = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n actual,\n remove,\n remover,\n transientAdd,\n transientRemove,\n ...specOptions\n}: RefreshIdealGraphOptions) => {\n const seen = new Set<DepID>()\n const extractPromises: Promise<ExtractResult>[] = []\n const seenExtracted = new Set<DepID>()\n\n // gets an ordered list of importers to ensure deterministic processing\n const orderedImporters = getOrderedImporters(graph)\n const depsPerImporter = new Map<Node, Dependency[]>()\n for (const importer of orderedImporters) {\n // gets an ordered list of dependencies for this importer\n // while also taking into account additions and removals\n const deps = getNodeOrderedDependencies(importer, { add, remove })\n depsPerImporter.set(importer, deps)\n }\n\n // removes all edges to start recalculating the graph\n if (add.modifiedDependencies || remove.modifiedDependencies) {\n graph.resetEdges()\n }\n\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const importer of orderedImporters) {\n modifiers?.tryImporter(importer)\n\n // gets a ref to the map of dependencies being added to this importer\n const addedDeps = add.get(importer.id)\n\n const deps = depsPerImporter.get(importer)\n /* c8 ignore next */\n if (!deps) continue\n\n // gets a ref to the list of modifier functions for this set of deps\n const modifierRefs = modifiers?.tryDependencies(importer, deps)\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n addedDeps,\n modifiers,\n modifierRefs,\n extractPromises,\n actual,\n seenExtracted,\n remover,\n transientAdd,\n transientRemove,\n )\n }\n\n // set default node locations, if possible\n for (const node of graph.nodes.values()) {\n node.setDefaultLocation()\n }\n\n // Wait for all extraction promises to complete\n if (extractPromises.length > 0) {\n await Promise.all(extractPromises)\n }\n}\n\n/**\n * Global index to assign unique ids used to track peer context sets.\n */\nlet peerContextIndex = 0\n/**\n * Retrieve the next unique index for a peer context set.\n */\nexport const nextPeerContextIndex = () => peerContextIndex++\n"]}
@@ -5,6 +5,19 @@ import type { AddImportersDependenciesMap, Dependency, RemoveImportersDependenci
5
5
  import type { ModifierActiveEntry } from '../modifiers.ts';
6
6
  import type { Graph } from '../graph.ts';
7
7
  import type { Node } from '../node.ts';
8
+ /**
9
+ * A map of dependencies to be added to non-importer nodes.
10
+ * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).
11
+ * When these nodes are resolved and placed in the graph, their dependencies
12
+ * from this map are injected into the processing queue.
13
+ */
14
+ export type TransientAddMap = Omit<AddImportersDependenciesMap, 'modifiedDependencies'>;
15
+ /**
16
+ * A map of dependency names to be removed from non-importer nodes.
17
+ * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).
18
+ * When these nodes are processed, their dependencies in this map are excluded.
19
+ */
20
+ export type TransientRemoveMap = Omit<RemoveImportersDependenciesMap, 'modifiedDependencies'>;
8
21
  export type BuildIdealAddOptions = {
9
22
  /**
10
23
  * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EACV,2BAA2B,EAC3B,UAAU,EACV,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;OAKG;IACH,GAAG,EAAE,2BAA2B,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,MAAM,EAAE,8BAA8B,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,IAAI,CAAA;IACV,IAAI,EAAE,UAAU,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE;QACb,UAAU,EAAE,MACR;YACE,SAAS,EAAE,IAAI,CAAA;YACf,IAAI,EAAE,IAAI,CAAA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e,EACf,OAAO,CACR,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,2BAA2B,EAAE,CAAA;AAElE;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,MAAM,EAAE,OAAO,CAAA;IACf,yEAAyE;IACzE,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IAChB,2EAA2E;IAC3E,MAAM,EAAE,IAAI,GAAG,SAAS,CAAA;IACxB,mDAAmD;IACnD,IAAI,EAAE,kBAAkB,CAAA;IACxB,2EAA2E;IAC3E,iBAAiB,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;CAC7B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,gEAAgE;IAChE,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,+CAA+C;IAC/C,MAAM,CAAC,EAAE,IAAI,CAAA;CACd,GAAG,UAAU,CAAA;AAEd;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { Spec } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { ModifierActiveEntry } from '../modifiers.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\nexport type AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n peerContext: PeerContext\n updateContext: {\n putEntries: () =>\n | {\n dependent: Node\n spec: Spec\n type: DependencySaveType\n }[]\n | undefined\n resolvePeerDeps: () => void\n }\n}\n\n/**\n * The result of processing a given placed node in the graph.\n */\nexport type ProcessPlacementResultEntry = Omit<\n AppendNodeEntry,\n 'depth'\n>\n\n/**\n * The result of processing placement for nodes to be added to the graph.\n */\nexport type ProcessPlacementResult = ProcessPlacementResultEntry[]\n\n/**\n * Entry in a peer context representing a resolved peer dependency.\n */\nexport type PeerContextEntry = {\n /**\n * True if this entry is currently being resolved and track by this\n * peer context set, false in case this entry was inherit from a previous\n * peer context set and should not be considered for resolution.\n */\n active: boolean\n /** List of full Spec objects that are part of this peer context entry */\n specs: Set<Spec>\n /** The target Node that satisfies all specs for this peer context entry */\n target: Node | undefined\n /** The type of dependency this entry represents */\n type: DependencySaveType\n /** Context dependent nodes that had dependencies resolved to this entry */\n contextDependents: Set<Node>\n}\n\n/**\n * Input for adding an entry to peer contexts.\n */\nexport type PeerContextEntryInput = {\n /** Node that depends on this resolved peer context set entry */\n dependent?: Node\n /** Node this peer context entry resolves to */\n target?: Node\n} & Dependency\n\n/**\n * Represents resolved peer dependencies in a given append-nodes context.\n */\nexport type PeerContext = Map<string, PeerContextEntry> & {\n index?: number\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { Spec } from '@vltpkg/spec'\nimport type { DependencySaveType } from '@vltpkg/types'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { ModifierActiveEntry } from '../modifiers.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\n\n/**\n * A map of dependencies to be added to non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are resolved and placed in the graph, their dependencies\n * from this map are injected into the processing queue.\n */\nexport type TransientAddMap = Omit<\n AddImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\n/**\n * A map of dependency names to be removed from non-importer nodes.\n * Keys are {@link DepID} of nodes that are not importers (e.g., nested folders).\n * When these nodes are processed, their dependencies in this map are excluded.\n */\nexport type TransientRemoveMap = Omit<\n RemoveImportersDependenciesMap,\n 'modifiedDependencies'\n>\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\nexport type AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n peerContext: PeerContext\n updateContext: {\n putEntries: () =>\n | {\n dependent: Node\n spec: Spec\n type: DependencySaveType\n }[]\n | undefined\n resolvePeerDeps: () => void\n }\n}\n\n/**\n * The result of processing a given placed node in the graph.\n */\nexport type ProcessPlacementResultEntry = Omit<\n AppendNodeEntry,\n 'depth'\n>\n\n/**\n * The result of processing placement for nodes to be added to the graph.\n */\nexport type ProcessPlacementResult = ProcessPlacementResultEntry[]\n\n/**\n * Entry in a peer context representing a resolved peer dependency.\n */\nexport type PeerContextEntry = {\n /**\n * True if this entry is currently being resolved and track by this\n * peer context set, false in case this entry was inherit from a previous\n * peer context set and should not be considered for resolution.\n */\n active: boolean\n /** List of full Spec objects that are part of this peer context entry */\n specs: Set<Spec>\n /** The target Node that satisfies all specs for this peer context entry */\n target: Node | undefined\n /** The type of dependency this entry represents */\n type: DependencySaveType\n /** Context dependent nodes that had dependencies resolved to this entry */\n contextDependents: Set<Node>\n}\n\n/**\n * Input for adding an entry to peer contexts.\n */\nexport type PeerContextEntryInput = {\n /** Node that depends on this resolved peer context set entry */\n dependent?: Node\n /** Node this peer context entry resolves to */\n target?: Node\n} & Dependency\n\n/**\n * Represents resolved peer dependencies in a given append-nodes context.\n */\nexport type PeerContext = Map<string, PeerContextEntry> & {\n index?: number\n}\n"]}
@@ -3,6 +3,7 @@ export * from './edge.ts';
3
3
  export * from './graph.ts';
4
4
  export * from './node.ts';
5
5
  export * from './dependencies.ts';
6
+ export * from './fixup-added-names.ts';
6
7
  export * from './lockfile/types.ts';
7
8
  export * from './visualization/json-output.ts';
8
9
  export * from './visualization/human-readable-output.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAGjC,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAG1C,OAAO,KAAK,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAI5E,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,eAAO,MAAM,KAAK;;CAAY,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAGjC,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAG1C,OAAO,KAAK,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAI5E,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,eAAO,MAAM,KAAK;;CAAY,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/esm/index.js CHANGED
@@ -3,6 +3,7 @@ export * from "./edge.js";
3
3
  export * from "./graph.js";
4
4
  export * from "./node.js";
5
5
  export * from "./dependencies.js";
6
+ export * from "./fixup-added-names.js";
6
7
  export * from "./lockfile/types.js";
7
8
  export * from "./visualization/json-output.js";
8
9
  export * from "./visualization/human-readable-output.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAE1C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,YAAY;IAClB,SAAS;IACT,SAAS;IACT,IAAI;CACL,CAAA;AAKD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGxC,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export * from './build.ts'\nexport * from './edge.ts'\nexport * from './graph.ts'\nexport * from './node.ts'\nexport * from './dependencies.ts'\nexport * from './lockfile/types.ts'\nexport * from './visualization/json-output.ts'\nexport * from './visualization/human-readable-output.ts'\nexport * from './visualization/mermaid-output.ts'\nexport * from './stringify-node.ts'\nexport * from './install.ts'\nexport * from './uninstall.ts'\nexport * from './update.ts'\nexport * from './diff.ts'\nexport * from './modifiers.ts'\nexport * from './virtual-root.ts'\n\nimport { load as actualLoad } from './actual/load.ts'\nimport type { LoadOptions as ActualLoadOptions } from './actual/load.ts'\nexport const actual = { load: actualLoad }\n\nimport { load as lockfileLoad } from './lockfile/load.ts'\nimport type { LoadOptions as LockfileLoadOptions } from './lockfile/load.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { save } from './lockfile/save.ts'\nexport const lockfile = {\n load: lockfileLoad,\n loadEdges,\n loadNodes,\n save,\n}\n\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.ts'\n\nimport { build } from './ideal/build.ts'\nimport type { BuildIdealOptions } from './ideal/build.ts'\nexport type { BuildIdealOptions }\nexport const ideal = { build }\n\nexport { reify } from './reify/index.ts'\nexport type { ReifyOptions } from './reify/index.ts'\nexport type { BuildResult } from './reify/build.ts'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAE1C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,YAAY;IAClB,SAAS;IACT,SAAS;IACT,IAAI;CACL,CAAA;AAKD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGxC,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export * from './build.ts'\nexport * from './edge.ts'\nexport * from './graph.ts'\nexport * from './node.ts'\nexport * from './dependencies.ts'\nexport * from './fixup-added-names.ts'\nexport * from './lockfile/types.ts'\nexport * from './visualization/json-output.ts'\nexport * from './visualization/human-readable-output.ts'\nexport * from './visualization/mermaid-output.ts'\nexport * from './stringify-node.ts'\nexport * from './install.ts'\nexport * from './uninstall.ts'\nexport * from './update.ts'\nexport * from './diff.ts'\nexport * from './modifiers.ts'\nexport * from './virtual-root.ts'\n\nimport { load as actualLoad } from './actual/load.ts'\nimport type { LoadOptions as ActualLoadOptions } from './actual/load.ts'\nexport const actual = { load: actualLoad }\n\nimport { load as lockfileLoad } from './lockfile/load.ts'\nimport type { LoadOptions as LockfileLoadOptions } from './lockfile/load.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { save } from './lockfile/save.ts'\nexport const lockfile = {\n load: lockfileLoad,\n loadEdges,\n loadNodes,\n save,\n}\n\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.ts'\n\nimport { build } from './ideal/build.ts'\nimport type { BuildIdealOptions } from './ideal/build.ts'\nexport type { BuildIdealOptions }\nexport const ideal = { build }\n\nexport { reify } from './reify/index.ts'\nexport type { ReifyOptions } from './reify/index.ts'\nexport type { BuildResult } from './reify/build.ts'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAG5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAM3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGvC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,iBAAiB,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,OAAO,YACT,cAAc,QACjB,2BAA2B;;;;;;;;EAyNlC,CAAA"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAG5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAM3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGvC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,iBAAiB,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,OAAO,YACT,cAAc,QACjB,2BAA2B;;;;;;;;EAmOlC,CAAA"}
@@ -7,7 +7,7 @@ import { error } from '@vltpkg/error-cause';
7
7
  import { asError } from '@vltpkg/types';
8
8
  import { getDependencies } from "./dependencies.js";
9
9
  import { RollbackRemove } from '@vltpkg/rollback-remove';
10
- import { existsSync } from 'node:fs';
10
+ import { existsSync, rmSync } from 'node:fs';
11
11
  import { resolve } from 'node:path';
12
12
  import { load as loadVirtual } from "./lockfile/load.js";
13
13
  import { getImporterSpecs } from "./ideal/get-importer-specs.js";
@@ -183,6 +183,14 @@ export const install = async (options, add) => {
183
183
  catch (err) {
184
184
  /* c8 ignore next */
185
185
  await remover.rollback().catch(() => { });
186
+ // Remove hidden lockfile on failure
187
+ try {
188
+ const hiddenLockfile = resolve(options.projectRoot, 'node_modules/.vlt-lock.json');
189
+ if (existsSync(hiddenLockfile)) {
190
+ rmSync(hiddenLockfile, { force: true });
191
+ }
192
+ }
193
+ catch { }
186
194
  throw err;
187
195
  }
188
196
  };