@vltpkg/graph 0.0.0-30 → 0.0.0-31

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 (87) hide show
  1. package/dist/esm/actual/load.d.ts +5 -0
  2. package/dist/esm/actual/load.d.ts.map +1 -1
  3. package/dist/esm/actual/load.js +1 -0
  4. package/dist/esm/actual/load.js.map +1 -1
  5. package/dist/esm/build.d.ts +29 -0
  6. package/dist/esm/build.d.ts.map +1 -0
  7. package/dist/esm/build.js +79 -0
  8. package/dist/esm/build.js.map +1 -0
  9. package/dist/esm/diff.d.ts +62 -0
  10. package/dist/esm/diff.d.ts.map +1 -1
  11. package/dist/esm/diff.js +12 -0
  12. package/dist/esm/diff.js.map +1 -1
  13. package/dist/esm/edge.d.ts +6 -0
  14. package/dist/esm/edge.d.ts.map +1 -1
  15. package/dist/esm/edge.js +8 -0
  16. package/dist/esm/edge.js.map +1 -1
  17. package/dist/esm/ideal/add-nodes.d.ts +12 -2
  18. package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
  19. package/dist/esm/ideal/add-nodes.js +8 -2
  20. package/dist/esm/ideal/add-nodes.js.map +1 -1
  21. package/dist/esm/ideal/append-nodes.d.ts +3 -1
  22. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  23. package/dist/esm/ideal/append-nodes.js +24 -3
  24. package/dist/esm/ideal/append-nodes.js.map +1 -1
  25. package/dist/esm/ideal/build.d.ts +5 -0
  26. package/dist/esm/ideal/build.d.ts.map +1 -1
  27. package/dist/esm/ideal/build.js +2 -1
  28. package/dist/esm/ideal/build.js.map +1 -1
  29. package/dist/esm/index.d.ts +2 -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 +7 -0
  34. package/dist/esm/install.d.ts.map +1 -1
  35. package/dist/esm/install.js +26 -2
  36. package/dist/esm/install.js.map +1 -1
  37. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  38. package/dist/esm/lockfile/load-nodes.js +6 -2
  39. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  40. package/dist/esm/lockfile/load.d.ts.map +1 -1
  41. package/dist/esm/lockfile/load.js +3 -1
  42. package/dist/esm/lockfile/load.js.map +1 -1
  43. package/dist/esm/lockfile/save.d.ts +6 -2
  44. package/dist/esm/lockfile/save.d.ts.map +1 -1
  45. package/dist/esm/lockfile/save.js +16 -5
  46. package/dist/esm/lockfile/save.js.map +1 -1
  47. package/dist/esm/lockfile/types.d.ts +17 -1
  48. package/dist/esm/lockfile/types.d.ts.map +1 -1
  49. package/dist/esm/lockfile/types.js +31 -0
  50. package/dist/esm/lockfile/types.js.map +1 -1
  51. package/dist/esm/node.d.ts +19 -1
  52. package/dist/esm/node.d.ts.map +1 -1
  53. package/dist/esm/node.js +17 -0
  54. package/dist/esm/node.js.map +1 -1
  55. package/dist/esm/reify/add-nodes.d.ts.map +1 -1
  56. package/dist/esm/reify/add-nodes.js +4 -29
  57. package/dist/esm/reify/add-nodes.js.map +1 -1
  58. package/dist/esm/reify/build.d.ts +10 -1
  59. package/dist/esm/reify/build.d.ts.map +1 -1
  60. package/dist/esm/reify/build.js +30 -4
  61. package/dist/esm/reify/build.js.map +1 -1
  62. package/dist/esm/reify/check-needed-build.d.ts +25 -0
  63. package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
  64. package/dist/esm/reify/check-needed-build.js +50 -0
  65. package/dist/esm/reify/check-needed-build.js.map +1 -0
  66. package/dist/esm/reify/extract-node.d.ts +24 -0
  67. package/dist/esm/reify/extract-node.d.ts.map +1 -0
  68. package/dist/esm/reify/extract-node.js +76 -0
  69. package/dist/esm/reify/extract-node.js.map +1 -0
  70. package/dist/esm/reify/index.d.ts +16 -1
  71. package/dist/esm/reify/index.d.ts.map +1 -1
  72. package/dist/esm/reify/index.js +59 -12
  73. package/dist/esm/reify/index.js.map +1 -1
  74. package/dist/esm/transfer-data/load.d.ts.map +1 -1
  75. package/dist/esm/transfer-data/load.js.map +1 -1
  76. package/dist/esm/uninstall.d.ts +5 -1
  77. package/dist/esm/uninstall.d.ts.map +1 -1
  78. package/dist/esm/uninstall.js +51 -19
  79. package/dist/esm/uninstall.js.map +1 -1
  80. package/dist/esm/update.d.ts +2 -0
  81. package/dist/esm/update.d.ts.map +1 -1
  82. package/dist/esm/update.js +36 -22
  83. package/dist/esm/update.js.map +1 -1
  84. package/dist/esm/virtual-root.d.ts.map +1 -1
  85. package/dist/esm/virtual-root.js +1 -0
  86. package/dist/esm/virtual-root.js.map +1 -1
  87. package/package.json +21 -20
@@ -60,6 +60,11 @@ export type LoadOptions = SpecOptions & {
60
60
  * Prevents any lockfile modifications and is stricter than expectLockfile.
61
61
  */
62
62
  frozenLockfile?: boolean;
63
+ /**
64
+ * If set to `true`, only update the lockfile without performing any node_modules
65
+ * operations. Skips package extraction, filesystem operations, and hidden lockfile saves.
66
+ */
67
+ lockfileOnly?: boolean;
63
68
  };
64
69
  export type ReadEntry = {
65
70
  alias: string;
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAQnC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAEnC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,KAAK,EACV,aAAa,EAEd,MAAM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EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CAC9C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,QACzB,OAAO,KACX,GAAG,IAAI,iBAGe,CAAA;AAEzB;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QACzB,OAAO,KACX,iBAKF,CAAA;AAUD;;;GAGG;AACH,eAAO,MAAM,cAAc,SACnB,IAAI,QACJ,IAAI,KACT,KAAK,GAAG,SAGQ,CAAA;AA2RnB;;;;GAIG;AACH,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KA4F3C,CAAA"}
@@ -246,6 +246,7 @@ export const load = (options) => {
246
246
  try {
247
247
  // if we reach here, the hidden lockfile is valid
248
248
  const graph = loadHidden({
249
+ ...options,
249
250
  projectRoot,
250
251
  mainManifest,
251
252
  packageJson,
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAYhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAsEtC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,C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EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;QACH,CAAC;QAED,kEAAkE;QAClE,SAAS,EAAE,qBAAqB,EAAE,CAAA;IACpC,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport { graphStep } from '@vltpkg/output'\nimport { isObject } from '@vltpkg/types'\nimport {\n shorten,\n getRawDependencies,\n getDependencies,\n} from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport { readFileSync } from 'node:fs'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n /**\n * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of date.\n * Used by ci command to enforce lockfile integrity.\n */\n expectLockfile?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of sync with package.json.\n * Prevents any lockfile modifications and is stricter than expectLockfile.\n */\n frozenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\n/**\n * The configuration object type as it is saved in the `.vlt/vlt.json`\n */\nexport type StoreConfigObject = {\n modifiers: Record<string, string> | undefined\n}\n\n/**\n * Checks if a given object is a {@link StoreConfigObject}.\n */\nexport const isStoreConfigObject = (\n obj: unknown,\n): obj is StoreConfigObject =>\n isObject(obj) &&\n Object.prototype.hasOwnProperty.call(obj, 'modifiers') &&\n isObject(obj.modifiers)\n\n/**\n * Returns a {@link StoreConfigObject} from a given object.\n * Throws a TypeError if the object can't be converted.\n */\nexport const asStoreConfigObject = (\n obj: unknown,\n): StoreConfigObject => {\n if (!isStoreConfigObject(obj)) {\n throw new TypeError(`Expected a store config object, got ${obj}`)\n }\n return obj\n}\n\n// path-based refer to the types of dependencies that are directly linked to\n// their real location in the file system and thus will not have an entry\n// in the `node_modules/.vlt` store\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\n\n/**\n * Returns a {@link DepID} for a given spec and path, if the spec is\n * path-based or a registry spec, otherwise returns `undefined`.\n */\nexport const getPathBasedId = (\n spec: Spec,\n path: Path,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path.relativePosix()])\n : findDepID(path)\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\n/**\n * Helper function that gets a modified {@link Spec} when finding a modifier\n * that applies to a given dependency. Otherwise returns the original spec\n * value and no queryModifier.\n */\nconst maybeApplyModifierToSpec = (\n spec: Spec,\n depName: string,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n): { spec: Spec; queryModifier?: string } => {\n const activeModifier = modifierRefs?.get(depName)\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n const modifiedSpec = activeModifier.modifier.spec\n modifiedSpec.overridden = true\n return { spec: modifiedSpec, queryModifier }\n }\n\n return { spec, queryModifier }\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests, modifiers } = options\n const dependencies = getRawDependencies(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n // Get modifier references for this node's dependencies\n const modifierRefs = modifiers?.tryDependencies(fromNode, [\n ...getDependencies(fromNode, options).values(),\n ])\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n let h = hydrate(depId, alias, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n h.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec even when not loading manifests\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(h, alias, modifierRefs)\n h = modifiedSpec\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n },\n depId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n let spec = Spec.parse(alias, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec if a modifier is complete\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, alias, modifierRefs)\n spec = modifiedSpec\n\n const maybeId = getPathBasedId(spec, realpath)\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n let spec = Spec.parse(name, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec for missing dependencies\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, name, modifierRefs)\n spec = modifiedSpec\n\n graph.placePackage(\n fromNode,\n depType,\n spec,\n undefined,\n undefined,\n queryModifier,\n )\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n const {\n modifiers,\n monorepo,\n projectRoot,\n packageJson,\n scurry,\n skipHiddenLockfile = false,\n skipLoadingNodesOnModifiersChange = false,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n // if we reach here, the hidden lockfile is valid\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n done()\n return graph\n } catch {\n // if validation fails or any other error occurs,\n // fall back to filesystem traversal\n }\n }\n\n const graph = new Graph({ ...options, mainManifest })\n\n // retrieve the configuration object from the store\n let storeConfig: StoreConfigObject = { modifiers: undefined }\n try {\n storeConfig = asStoreConfigObject(\n JSON.parse(\n readFileSync(\n scurry.resolve('node_modules/.vlt/vlt.json'),\n 'utf8',\n ),\n ),\n )\n } catch {}\n const storeModifiers = JSON.stringify(storeConfig.modifiers ?? {})\n const optionsModifiers = JSON.stringify(modifiers?.config)\n const modifiersChanged = storeModifiers !== optionsModifiers\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n\n // will only skip loading dependencies if the\n // skipLoadingNodesOnModifiersChange option is set to true\n // and the current modifiers have not changed when compared\n // to the modifiers stored in the `node_modules/.vlt/vlt.json` store config\n if (shouldLoadDependencies) {\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n modifiers?.tryImporter(importer)\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n // Clean up any pending modifier entries that were never completed\n modifiers?.rollbackActiveEntries()\n }\n\n done()\n\n return graph\n}\n"]}
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,eAAe,GAChB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAYhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA4EtC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAY,EACc,EAAE,CAC5B,QAAQ,CAAC,GAAG,CAAC;IACb,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC;IACtD,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAY,EACO,EAAE;IACrB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,SAAS,CAAC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IACH,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,CAAC,CAAA;IAClE,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;IAC1D,MAAM,gBAAgB,GAAG,cAAc,KAAK,gBAAgB,CAAA;IAC5D,MAAM,sBAAsB,GAAG,CAAC,CAC9B,iCAAiC,IAAI,gBAAgB,CACtD,CAAA;IAED,6CAA6C;IAC7C,0DAA0D;IAC1D,2DAA2D;IAC3D,2EAA2E;IAC3E,IAAI,sBAAsB,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;QAEvC,uEAAuE;QACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YAChC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;QACH,CAAC;QAED,qEAAqE;QACrE,sEAAsE;QACtE,0DAA0D;QAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;QACH,CAAC;QAED,kEAAkE;QAClE,SAAS,EAAE,qBAAqB,EAAE,CAAA;IACpC,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport { graphStep } from '@vltpkg/output'\nimport { isObject } from '@vltpkg/types'\nimport {\n shorten,\n getRawDependencies,\n getDependencies,\n} from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport type { Node } from '../node.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport { readFileSync } from 'node:fs'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n /**\n * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: boolean\n // TODO: move the lockfile-related options to a separate type file\n /**\n * If set to `true`, fail if lockfile is missing or out of date.\n * Used by ci command to enforce lockfile integrity.\n */\n expectLockfile?: boolean\n /**\n * If set to `true`, fail if lockfile is missing or out of sync with package.json.\n * Prevents any lockfile modifications and is stricter than expectLockfile.\n */\n frozenLockfile?: boolean\n /**\n * If set to `true`, only update the lockfile without performing any node_modules\n * operations. Skips package extraction, filesystem operations, and hidden lockfile saves.\n */\n lockfileOnly?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\n/**\n * The configuration object type as it is saved in the `.vlt/vlt.json`\n */\nexport type StoreConfigObject = {\n modifiers: Record<string, string> | undefined\n}\n\n/**\n * Checks if a given object is a {@link StoreConfigObject}.\n */\nexport const isStoreConfigObject = (\n obj: unknown,\n): obj is StoreConfigObject =>\n isObject(obj) &&\n Object.prototype.hasOwnProperty.call(obj, 'modifiers') &&\n isObject(obj.modifiers)\n\n/**\n * Returns a {@link StoreConfigObject} from a given object.\n * Throws a TypeError if the object can't be converted.\n */\nexport const asStoreConfigObject = (\n obj: unknown,\n): StoreConfigObject => {\n if (!isStoreConfigObject(obj)) {\n throw new TypeError(`Expected a store config object, got ${obj}`)\n }\n return obj\n}\n\n// path-based refer to the types of dependencies that are directly linked to\n// their real location in the file system and thus will not have an entry\n// in the `node_modules/.vlt` store\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\n\n/**\n * Returns a {@link DepID} for a given spec and path, if the spec is\n * path-based or a registry spec, otherwise returns `undefined`.\n */\nexport const getPathBasedId = (\n spec: Spec,\n path: Path,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path.relativePosix()])\n : findDepID(path)\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\n/**\n * Helper function that gets a modified {@link Spec} when finding a modifier\n * that applies to a given dependency. Otherwise returns the original spec\n * value and no queryModifier.\n */\nconst maybeApplyModifierToSpec = (\n spec: Spec,\n depName: string,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n): { spec: Spec; queryModifier?: string } => {\n const activeModifier = modifierRefs?.get(depName)\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n const modifiedSpec = activeModifier.modifier.spec\n modifiedSpec.overridden = true\n return { spec: modifiedSpec, queryModifier }\n }\n\n return { spec, queryModifier }\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests, modifiers } = options\n const dependencies = getRawDependencies(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n // Get modifier references for this node's dependencies\n const modifierRefs = modifiers?.tryDependencies(fromNode, [\n ...getDependencies(fromNode, options).values(),\n ])\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n let h = hydrate(depId, alias, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n h.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec even when not loading manifests\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(h, alias, modifierRefs)\n h = modifiedSpec\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n },\n depId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n let spec = Spec.parse(alias, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec if a modifier is complete\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, alias, modifierRefs)\n spec = modifiedSpec\n\n const maybeId = getPathBasedId(spec, realpath)\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n queryModifier,\n )\n\n // Update active entry after placing package\n const activeModifier = modifierRefs?.get(alias)\n if (activeModifier && node) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n let spec = Spec.parse(name, bareSpec, {\n ...options,\n })\n // if the parsed registry value is using the default value, then\n // the node should inherit the registry value from its parent node\n spec.inheritedRegistry = fromNode.registry\n\n // Check for active modifiers and replace spec for missing dependencies\n const { spec: modifiedSpec, queryModifier } =\n maybeApplyModifierToSpec(spec, name, modifierRefs)\n spec = modifiedSpec\n\n graph.placePackage(\n fromNode,\n depType,\n spec,\n undefined,\n undefined,\n queryModifier,\n )\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n const {\n modifiers,\n monorepo,\n projectRoot,\n packageJson,\n scurry,\n skipHiddenLockfile = false,\n skipLoadingNodesOnModifiersChange = false,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n // if we reach here, the hidden lockfile is valid\n const graph = loadHidden({\n ...options,\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n done()\n return graph\n } catch {\n // if validation fails or any other error occurs,\n // fall back to filesystem traversal\n }\n }\n\n const graph = new Graph({ ...options, mainManifest })\n\n // retrieve the configuration object from the store\n let storeConfig: StoreConfigObject = { modifiers: undefined }\n try {\n storeConfig = asStoreConfigObject(\n JSON.parse(\n readFileSync(\n scurry.resolve('node_modules/.vlt/vlt.json'),\n 'utf8',\n ),\n ),\n )\n } catch {}\n const storeModifiers = JSON.stringify(storeConfig.modifiers ?? {})\n const optionsModifiers = JSON.stringify(modifiers?.config)\n const modifiersChanged = storeModifiers !== optionsModifiers\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n\n // will only skip loading dependencies if the\n // skipLoadingNodesOnModifiersChange option is set to true\n // and the current modifiers have not changed when compared\n // to the modifiers stored in the `node_modules/.vlt/vlt.json` store config\n if (shouldLoadDependencies) {\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n modifiers?.tryImporter(importer)\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n // Clean up any pending modifier entries that were never completed\n modifiers?.rollbackActiveEntries()\n }\n\n done()\n\n return graph\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { Monorepo } from '@vltpkg/workspaces';
2
+ import type { BuildResult } from './reify/build.ts';
3
+ import type { LoadOptions } from './actual/load.ts';
4
+ /**
5
+ * Options for the build process
6
+ */
7
+ export interface BuildOptions extends LoadOptions {
8
+ /**
9
+ * Optional monorepo configuration. If not provided, will attempt to load from project.
10
+ */
11
+ monorepo?: Monorepo;
12
+ /**
13
+ * DSS query string to filter which nodes to build.
14
+ */
15
+ target: string;
16
+ }
17
+ /**
18
+ * Build the project based on actual graph state and build state from lockfile
19
+ *
20
+ * This function:
21
+ * 1. Loads the actual graph from node_modules
22
+ * 2. Loads build data from lockfile and transfers it to the actual graph
23
+ * 3. Constructs a Diff object representing what needs to be built
24
+ * 4. Filters nodes based on buildState === 'needed'
25
+ * 5. Calls the reify build process with the constructed diff
26
+ * 6. Persists build results to lockfile
27
+ */
28
+ export declare const build: (options: BuildOptions) => Promise<BuildResult>;
29
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAKnD;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACf;AAoCD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,YACP,YAAY,KACpB,OAAO,CAAC,WAAW,CA6DrB,CAAA"}
@@ -0,0 +1,79 @@
1
+ import { Monorepo } from '@vltpkg/workspaces';
2
+ import { load as loadActual } from "./actual/load.js";
3
+ import { build as reifyBuild } from "./reify/build.js";
4
+ import { Diff } from "./diff.js";
5
+ import { Graph } from "./graph.js";
6
+ import { Query } from '@vltpkg/query';
7
+ import { SecurityArchive } from '@vltpkg/security-archive';
8
+ import { saveHidden } from "./lockfile/save.js";
9
+ /**
10
+ * Filter nodes using a DSS query string
11
+ */
12
+ const filterNodesByQuery = async (targetQuery, graph) => {
13
+ /* c8 ignore start */
14
+ const securityArchive = Query.hasSecuritySelectors(targetQuery) ?
15
+ await SecurityArchive.start({
16
+ nodes: [...graph.nodes.values()],
17
+ })
18
+ : undefined;
19
+ /* c8 ignore stop */
20
+ const edges = graph.edges;
21
+ const nodes = new Set(graph.nodes.values());
22
+ const importers = graph.importers;
23
+ const query = new Query({
24
+ edges,
25
+ nodes,
26
+ importers,
27
+ securityArchive,
28
+ });
29
+ const { nodes: resultNodes } = await query.search(targetQuery, {
30
+ signal: new AbortController().signal,
31
+ });
32
+ return new Set(resultNodes.map(node => node.id));
33
+ };
34
+ /**
35
+ * Build the project based on actual graph state and build state from lockfile
36
+ *
37
+ * This function:
38
+ * 1. Loads the actual graph from node_modules
39
+ * 2. Loads build data from lockfile and transfers it to the actual graph
40
+ * 3. Constructs a Diff object representing what needs to be built
41
+ * 4. Filters nodes based on buildState === 'needed'
42
+ * 5. Calls the reify build process with the constructed diff
43
+ * 6. Persists build results to lockfile
44
+ */
45
+ export const build = async (options) => {
46
+ const { projectRoot, packageJson, monorepo = Monorepo.maybeLoad(projectRoot), scurry, mainManifest = packageJson.read(projectRoot), target, ...loadOptions } = options;
47
+ // Load the actual graph from node_modules
48
+ const actualGraph = loadActual({
49
+ ...loadOptions,
50
+ projectRoot,
51
+ packageJson,
52
+ monorepo,
53
+ scurry,
54
+ loadManifests: true,
55
+ });
56
+ // Filter nodes using target query provided
57
+ const targetFilteredNodes = await filterNodesByQuery(target, actualGraph);
58
+ // Create a total diff including the actual graph as 'to'
59
+ const diff = new Diff(new Graph({
60
+ ...options,
61
+ projectRoot,
62
+ monorepo,
63
+ mainManifest,
64
+ }), actualGraph);
65
+ // Now tweak the diff object to only include the nodes that need to be built
66
+ // Filter by buildState === 'needed' and target query
67
+ diff.nodes.add = new Set([...diff.nodes.add].filter(node => node.buildState === 'needed'));
68
+ // Call the reify build process with the constructed diff
69
+ // this will only build the nodes that need to be built
70
+ // as part of `diff.nodes.add`
71
+ const buildResult = await reifyBuild(diff, packageJson, scurry, targetFilteredNodes);
72
+ // Save hidden lockfile with updated buildState
73
+ saveHidden({
74
+ ...options,
75
+ graph: actualGraph,
76
+ });
77
+ return buildResult;
78
+ };
79
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAgB/C;;GAEG;AACH,MAAM,kBAAkB,GAAG,KAAK,EAC9B,WAAmB,EACnB,KAAY,EACS,EAAE;IACvB,qBAAqB;IACrB,MAAM,eAAe,GACnB,KAAK,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC;QACvC,MAAM,eAAe,CAAC,KAAK,CAAC;YAC1B,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK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M,IAAI,GAAG,IAAI,IAAI,CACnB,IAAI,KAAK,CAAC;QACR,GAAG,OAAO;QACV,WAAW;QACX,QAAQ;QACR,YAAY;KACb,CAAC,EACF,WAAW,CACZ,CAAA;IAED,4EAA4E;IAC5E,qDAAqD;IACrD,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,CACtB,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CACjE,CAAA;IAED,yDAAyD;IACzD,uDAAuD;IACvD,8BAA8B;IAC9B,MAAM,WAAW,GAAG,MAAM,UAAU,CAClC,IAAI,EACJ,WAAW,EACX,MAAM,EACN,mBAAmB,CACpB,CAAA;IAED,+CAA+C;IAC/C,UAAU,CAAC;QACT,GAAG,OAAO;QACV,KAAK,EAAE,WAAW;KACnB,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA","sourcesContent":["import { Monorepo } from '@vltpkg/workspaces'\nimport { load as loadActual } from './actual/load.ts'\nimport { build as reifyBuild } from './reify/build.ts'\nimport type { BuildResult } from './reify/build.ts'\nimport { Diff } from './diff.ts'\nimport { Graph } from './graph.ts'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport type { LoadOptions } from './actual/load.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { NodeLike } from '@vltpkg/types'\nimport { saveHidden } from './lockfile/save.ts'\n\n/**\n * Options for the build process\n */\nexport interface BuildOptions extends LoadOptions {\n /**\n * Optional monorepo configuration. If not provided, will attempt to load from project.\n */\n monorepo?: Monorepo\n /**\n * DSS query string to filter which nodes to build.\n */\n target: string\n}\n\n/**\n * Filter nodes using a DSS query string\n */\nconst filterNodesByQuery = async (\n targetQuery: string,\n graph: Graph,\n): Promise<Set<DepID>> => {\n /* c8 ignore start */\n const securityArchive =\n Query.hasSecuritySelectors(targetQuery) ?\n await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n : undefined\n /* c8 ignore stop */\n\n const edges = graph.edges\n const nodes = new Set<NodeLike>(graph.nodes.values())\n const importers = graph.importers\n\n const query = new Query({\n edges,\n nodes,\n importers,\n securityArchive,\n })\n\n const { nodes: resultNodes } = await query.search(targetQuery, {\n signal: new AbortController().signal,\n })\n\n return new Set(resultNodes.map(node => node.id))\n}\n\n/**\n * Build the project based on actual graph state and build state from lockfile\n *\n * This function:\n * 1. Loads the actual graph from node_modules\n * 2. Loads build data from lockfile and transfers it to the actual graph\n * 3. Constructs a Diff object representing what needs to be built\n * 4. Filters nodes based on buildState === 'needed'\n * 5. Calls the reify build process with the constructed diff\n * 6. Persists build results to lockfile\n */\nexport const build = async (\n options: BuildOptions,\n): Promise<BuildResult> => {\n const {\n projectRoot,\n packageJson,\n monorepo = Monorepo.maybeLoad(projectRoot),\n scurry,\n mainManifest = packageJson.read(projectRoot),\n target,\n ...loadOptions\n } = options\n\n // Load the actual graph from node_modules\n const actualGraph = loadActual({\n ...loadOptions,\n projectRoot,\n packageJson,\n monorepo,\n scurry,\n loadManifests: true,\n })\n\n // Filter nodes using target query provided\n const targetFilteredNodes: Set<DepID> = await filterNodesByQuery(\n target,\n actualGraph,\n )\n\n // Create a total diff including the actual graph as 'to'\n const diff = new Diff(\n new Graph({\n ...options,\n projectRoot,\n monorepo,\n mainManifest,\n }),\n actualGraph,\n )\n\n // Now tweak the diff object to only include the nodes that need to be built\n // Filter by buildState === 'needed' and target query\n diff.nodes.add = new Set(\n [...diff.nodes.add].filter(node => node.buildState === 'needed'),\n )\n\n // Call the reify build process with the constructed diff\n // this will only build the nodes that need to be built\n // as part of `diff.nodes.add`\n const buildResult = await reifyBuild(\n diff,\n packageJson,\n scurry,\n targetFilteredNodes,\n )\n\n // Save hidden lockfile with updated buildState\n saveHidden({\n ...options,\n graph: actualGraph,\n })\n\n return buildResult\n}\n"]}
@@ -49,6 +49,68 @@ export declare class Diff {
49
49
  constructor(from: Graph, to: Graph);
50
50
  [kCustomInspect](_: number, options?: InspectOptions): string;
51
51
  hasChanges(): boolean;
52
+ toJSON(): {
53
+ nodes: {
54
+ add: {
55
+ rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
56
+ id: import("@vltpkg/dep-id").DepID;
57
+ name: string;
58
+ version: string | undefined;
59
+ location: string;
60
+ importer: boolean;
61
+ manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
62
+ projectRoot: string;
63
+ integrity: `sha512-${string}` | undefined;
64
+ resolved: string | undefined;
65
+ dev: boolean;
66
+ optional: boolean;
67
+ confused: boolean;
68
+ modifier: string | undefined;
69
+ platform: {
70
+ engines?: Record<string, string>;
71
+ os?: string[] | string;
72
+ cpu?: string[] | string;
73
+ } | undefined;
74
+ buildState: "none" | "needed" | "built" | "failed";
75
+ }[];
76
+ delete: {
77
+ rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
78
+ id: import("@vltpkg/dep-id").DepID;
79
+ name: string;
80
+ version: string | undefined;
81
+ location: string;
82
+ importer: boolean;
83
+ manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
84
+ projectRoot: string;
85
+ integrity: `sha512-${string}` | undefined;
86
+ resolved: string | undefined;
87
+ dev: boolean;
88
+ optional: boolean;
89
+ confused: boolean;
90
+ modifier: string | undefined;
91
+ platform: {
92
+ engines?: Record<string, string>;
93
+ os?: string[] | string;
94
+ cpu?: string[] | string;
95
+ } | undefined;
96
+ buildState: "none" | "needed" | "built" | "failed";
97
+ }[];
98
+ };
99
+ edges: {
100
+ add: {
101
+ from: import("@vltpkg/dep-id").DepID;
102
+ to: import("@vltpkg/dep-id").DepID | undefined;
103
+ type: import("@vltpkg/types").DependencyTypeShort;
104
+ spec: string;
105
+ }[];
106
+ delete: {
107
+ from: import("@vltpkg/dep-id").DepID;
108
+ to: import("@vltpkg/dep-id").DepID | undefined;
109
+ type: import("@vltpkg/types").DependencyTypeShort;
110
+ spec: string;
111
+ }[];
112
+ };
113
+ };
52
114
  }
53
115
  export {};
54
116
  //# sourceMappingURL=diff.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;CAQtB"}
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;IASrB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYP"}
package/dist/esm/diff.js CHANGED
@@ -132,5 +132,17 @@ ${lines
132
132
  this.edges.add.size > 0 ||
133
133
  this.edges.delete.size > 0);
134
134
  }
135
+ toJSON() {
136
+ return {
137
+ nodes: {
138
+ add: [...this.nodes.add].map(node => node.toJSON()),
139
+ delete: [...this.nodes.delete].map(node => node.toJSON()),
140
+ },
141
+ edges: {
142
+ add: [...this.edges.add].map(edge => edge.toJSON()),
143
+ delete: [...this.edges.delete].map(edge => edge.toJSON()),
144
+ },
145
+ };
146
+ }
135
147
  }
136
148
  //# sourceMappingURL=diff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"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;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC;EACX,CAAA;IACA,CAAC;IAED,UAAU;QACR,OAAO,CACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;YACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAC3B,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n}\n"]}
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;QAC/D,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,+DAA+D;QAC/D,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,KAAK,GAAG;QACN,qEAAqE;QACrE,GAAG,EAA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AG,CAAC,CAC3B,CAAA;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;YACD,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;SACF,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n\n toJSON() {\n return {\n nodes: {\n add: [...this.nodes.add].map(node => node.toJSON()),\n delete: [...this.nodes.delete].map(node => node.toJSON()),\n },\n edges: {\n add: [...this.edges.add].map(edge => edge.toJSON()),\n delete: [...this.edges.delete].map(edge => edge.toJSON()),\n },\n }\n }\n}\n"]}
@@ -35,6 +35,12 @@ export declare class Edge implements EdgeLike {
35
35
  get peer(): boolean;
36
36
  get peerOptional(): boolean;
37
37
  valid(): boolean;
38
+ toJSON(): {
39
+ from: import("@vltpkg/dep-id").DepID;
40
+ to: import("@vltpkg/dep-id").DepID | undefined;
41
+ type: DependencyTypeShort;
42
+ spec: string;
43
+ };
38
44
  }
39
45
  export {};
40
46
  //# sourceMappingURL=edge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"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WAAW,CAAA;AAErC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D,qBAAa,IAAK,YAAW,QAAQ;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;IAWhB,MAAM;;;;;;CAQP"}
package/dist/esm/edge.js CHANGED
@@ -62,5 +62,13 @@ export class Edge {
62
62
  this.optional
63
63
  : satisfies(this.to.id, this.spec, this.from.location, this.from.projectRoot);
64
64
  }
65
+ toJSON() {
66
+ return {
67
+ from: this.from.id,
68
+ to: this.to?.id,
69
+ type: this.type,
70
+ spec: String(this.spec),
71
+ };
72
+ }
65
73
  }
66
74
  //# sourceMappingURL=edge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/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7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;SAChB,EACD,OAAO,CACR,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,EAAE,CAAO;IAET;;OAEG;IACH,IAAI,CAAqB;IAEzB;;OAEG;IACH,IAAI,CAAM;IAEV,YACE,IAAyB,EACzB,IAAU,EACV,IAAU,EACV,EAAS;QAET,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IAC7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,CAAA;IACH,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n\n toJSON() {\n return {\n from: this.from.id,\n to: this.to?.id,\n type: this.type,\n spec: String(this.spec),\n }\n }\n}\n"]}
@@ -1,8 +1,10 @@
1
+ import type { PathScurry } from 'path-scurry';
1
2
  import type { PackageInfoClient } from '@vltpkg/package-info';
2
3
  import type { SpecOptions } from '@vltpkg/spec';
3
- import type { PathScurry } from 'path-scurry';
4
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
4
5
  import type { BuildIdealAddOptions, BuildIdealFromGraphOptions } from './types.ts';
5
6
  import type { GraphModifier } from '../modifiers.ts';
7
+ import type { Graph } from '../graph.ts';
6
8
  export type AddNodesOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & SpecOptions & {
7
9
  /**
8
10
  * The graph modifiers helper object.
@@ -16,9 +18,17 @@ export type AddNodesOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions
16
18
  * A {@link PackageInfoClient} instance to read manifest info from.
17
19
  */
18
20
  packageInfo: PackageInfoClient;
21
+ /**
22
+ * The actual graph to compare against for early extraction
23
+ */
24
+ actual?: Graph;
25
+ /**
26
+ * A {@link RollbackRemove} instance to handle extraction rollbacks
27
+ */
28
+ remover: RollbackRemove;
19
29
  };
20
30
  /**
21
31
  * Add new nodes in the given `graph` for dependencies specified at `add`.
22
32
  */
23
- export declare const addNodes: ({ add, graph, modifiers, packageInfo, scurry, ...specOptions }: AddNodesOptions) => Promise<void>;
33
+ export declare const addNodes: ({ add, graph, modifiers, packageInfo, scurry, actual, remover, ...specOptions }: AddNodesOptions) => Promise<void>;
24
34
  //# sourceMappingURL=add-nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAChD,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;CAC/B,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,mEAOlB,eAAe,kBAqCjB,CAAA"}
1
+ {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAGA,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,EAC3B,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAChD,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;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,oFASlB,eAAe,kBAiDjB,CAAA"}
@@ -4,8 +4,10 @@ import { resolveSaveType } from "../resolve-save-type.js";
4
4
  /**
5
5
  * Add new nodes in the given `graph` for dependencies specified at `add`.
6
6
  */
7
- export const addNodes = async ({ add, graph, modifiers, packageInfo, scurry, ...specOptions }) => {
7
+ export const addNodes = async ({ add, graph, modifiers, packageInfo, scurry, actual, remover, ...specOptions }) => {
8
8
  const seen = new Set();
9
+ const extractPromises = [];
10
+ const seenExtracted = new Set();
9
11
  // iterates on the list of dependencies per importer updating
10
12
  // the graph using metadata fetch from the registry manifest files
11
13
  for (const [depID, dependencies] of add) {
@@ -27,7 +29,11 @@ export const addNodes = async ({ add, graph, modifiers, packageInfo, scurry, ...
27
29
  }
28
30
  // Add new nodes for packages defined in the dependencies list fetching
29
31
  // metadata from the registry manifests and updating the graph
30
- await appendNodes(dependencies, packageInfo, graph, importer, deps, scurry, specOptions, seen, modifiers, modifiers?.tryDependencies(importer, deps));
32
+ await appendNodes(dependencies, packageInfo, graph, importer, deps, scurry, specOptions, seen, modifiers, modifiers?.tryDependencies(importer, deps), extractPromises, actual, seenExtracted, remover);
33
+ }
34
+ // Wait for all extraction promises to complete
35
+ if (extractPromises.length > 0) {
36
+ await Promise.all(extractPromises);
31
37
  }
32
38
  };
33
39
  //# sourceMappingURL=add-nodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAK/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAqBzD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,GAAG,EACH,KAAK,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,GAAG,WAAW,EACE,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAS,CAAA;IAC7B,6DAA6D;IAC7D,kEAAkE;IAClE,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,GAAG,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;QACD,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;QAEhC,6DAA6D;QAC7D,iEAAiE;QACjE,MAAM,IAAI,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;QACvC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAA;YACpB,MAAM,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACrD,GAAG,CAAC,IAAI,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YACzD,MAAM,IAAI,GAAG,YAAY,EAAE,EAAE,CAAA;YAC7B,IAAI,IAAI;gBAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QAED,uEAAuE;QACvE,8DAA8D;QAC9D,MAAM,WAAW,CACf,YAAY,EACZ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,IAAI,EACJ,SAAS,EACT,SAAS,EAAE,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAC3C,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport { appendNodes } from './append-nodes.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\nimport { resolveSaveType } from '../resolve-save-type.ts'\nimport type { GraphModifier } from '../modifiers.ts'\n\nexport type AddNodesOptions = BuildIdealAddOptions &\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/**\n * Add new nodes in the given `graph` for dependencies specified at `add`.\n */\nexport const addNodes = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n ...specOptions\n}: AddNodesOptions) => {\n const seen = new Set<DepID>()\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const [depID, dependencies] of add) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n modifiers?.tryImporter(importer)\n\n // Removes any edges and nodes that are currently part of the\n // graph but are also in the list of dependencies to be installed\n const deps = [...dependencies.values()]\n for (const dep of deps) {\n const { spec } = dep\n const existingEdge = importer.edgesOut.get(spec.name)\n dep.type = resolveSaveType(importer, spec.name, dep.type)\n const node = existingEdge?.to\n if (node) graph.removeNode(node)\n }\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n dependencies,\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n modifiers,\n modifiers?.tryDependencies(importer, deps),\n )\n }\n}\n"]}
1
+ {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AA0CzD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,GAAG,EACH,KAAK,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,GAAG,WAAW,E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,IAAI,CAAC,EAC1C,eAAe,EACf,MAAM,EACN,aAAa,EACb,OAAO,CACR,CAAA;IACH,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","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { appendNodes } from './append-nodes.ts'\nimport { resolveSaveType } from '../resolve-save-type.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} from './types.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport type { Graph } from '../graph.ts'\n\nexport type AddNodesOptions = BuildIdealAddOptions &\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 * Add new nodes in the given `graph` for dependencies specified at `add`.\n */\nexport const addNodes = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n actual,\n remover,\n ...specOptions\n}: AddNodesOptions) => {\n const seen = new Set<DepID>()\n const extractPromises: Promise<ExtractResult>[] = []\n const seenExtracted = new Set<DepID>()\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 [depID, dependencies] of add) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n modifiers?.tryImporter(importer)\n\n // Removes any edges and nodes that are currently part of the\n // graph but are also in the list of dependencies to be installed\n const deps = [...dependencies.values()]\n for (const dep of deps) {\n const { spec } = dep\n const existingEdge = importer.edgesOut.get(spec.name)\n dep.type = resolveSaveType(importer, spec.name, dep.type)\n const node = existingEdge?.to\n if (node) graph.removeNode(node)\n }\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n dependencies,\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n modifiers,\n modifiers?.tryDependencies(importer, deps),\n extractPromises,\n actual,\n seenExtracted,\n remover,\n )\n }\n\n // Wait for all extraction promises to complete\n if (extractPromises.length > 0) {\n await Promise.all(extractPromises)\n }\n}\n"]}
@@ -6,6 +6,8 @@ import type { Dependency } from '../dependencies.ts';
6
6
  import type { Graph } from '../graph.ts';
7
7
  import type { Node } from '../node.ts';
8
8
  import type { GraphModifier, ModifierActiveEntry } from '../modifiers.ts';
9
+ import type { ExtractResult } from '../reify/extract-node.ts';
10
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
9
11
  /**
10
12
  * Append new nodes in the given `graph` for dependencies specified at `add`
11
13
  * and missing dependencies from the `deps` parameter.
@@ -13,5 +15,5 @@ import type { GraphModifier, ModifierActiveEntry } from '../modifiers.ts';
13
15
  * It also applies any modifiers that applies to a given node as it processes
14
16
  * and builds the graph.
15
17
  */
16
- export declare const appendNodes: (add: Map<string, Dependency>, packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>, modifiers?: GraphModifier, modifierRefs?: Map<string, ModifierActiveEntry>) => Promise<void>;
18
+ export declare const appendNodes: (add: Map<string, Dependency>, packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>, modifiers?: GraphModifier, modifierRefs?: Map<string, ModifierActiveEntry>, extractPromises?: Promise<ExtractResult>[], actual?: Graph, seenExtracted?: Set<DepID>, remover?: RollbackRemove) => Promise<void>;
17
19
  //# sourceMappingURL=append-nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"append-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAO/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AA0UxB;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QACjB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,eACf,iBAAiB,SACvB,KAAK,YACF,IAAI,QACR,UAAU,EAAE,UACV,UAAU,WACT,WAAW,QACd,GAAG,CAAC,KAAK,CAAC,cACJ,aAAa,iBACV,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,kBAqEhD,CAAA"}
1
+ {"version":3,"file":"append-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA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