@vltpkg/graph 0.0.0-9 → 1.0.0-rc.10
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.
- package/README.md +136 -1
- package/dist/esm/actual/load.d.ts +49 -3
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +146 -74
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +8 -4
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +6 -2
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/build.d.ts +29 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +79 -0
- package/dist/esm/build.js.map +1 -0
- package/dist/esm/dependencies.d.ts +10 -3
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +63 -0
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/diff.d.ts +69 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js +25 -0
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +8 -2
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +12 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/fixup-added-names.d.ts +16 -0
- package/dist/esm/fixup-added-names.d.ts.map +1 -0
- package/dist/esm/fixup-added-names.js +31 -0
- package/dist/esm/fixup-added-names.js.map +1 -0
- package/dist/esm/graph.d.ts +34 -10
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +150 -24
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +12 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +303 -53
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +4 -4
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +35 -16
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +9 -0
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +31 -1
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +11 -3
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js +86 -9
- package/dist/esm/ideal/get-importer-specs.js.map +1 -1
- package/dist/esm/ideal/get-ordered-dependencies.d.ts +10 -0
- package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +1 -0
- package/dist/esm/ideal/get-ordered-dependencies.js +42 -0
- package/dist/esm/ideal/get-ordered-dependencies.js.map +1 -0
- package/dist/esm/ideal/peers.d.ts +71 -0
- package/dist/esm/ideal/peers.d.ts.map +1 -0
- package/dist/esm/ideal/peers.js +318 -0
- package/dist/esm/ideal/peers.js.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.d.ts +48 -0
- package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.js +79 -0
- package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -0
- package/dist/esm/ideal/types.d.ts +78 -1
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.js.map +1 -1
- package/dist/esm/index.d.ts +9 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +10 -4
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +191 -20
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-edges.d.ts +8 -1
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +80 -15
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +3 -2
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +85 -13
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +18 -5
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +28 -20
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +16 -3
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +64 -17
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +34 -4
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js +31 -0
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/modifiers.d.ts +189 -0
- package/dist/esm/modifiers.d.ts.map +1 -0
- package/dist/esm/modifiers.js +330 -0
- package/dist/esm/modifiers.js.map +1 -0
- package/dist/esm/node.d.ts +91 -6
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +119 -5
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.d.ts +1 -2
- package/dist/esm/reify/add-edge.d.ts.map +1 -1
- package/dist/esm/reify/add-edge.js +29 -18
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/add-edges.d.ts +1 -2
- package/dist/esm/reify/add-edges.d.ts.map +1 -1
- package/dist/esm/reify/add-edges.js +3 -3
- package/dist/esm/reify/add-edges.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +4 -27
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/bin-chmod.d.ts +11 -0
- package/dist/esm/reify/bin-chmod.d.ts.map +1 -0
- package/dist/esm/reify/bin-chmod.js +39 -0
- package/dist/esm/reify/bin-chmod.js.map +1 -0
- package/dist/esm/reify/build.d.ts +10 -1
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +36 -23
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/calculate-save-value.d.ts +3 -0
- package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
- package/dist/esm/reify/calculate-save-value.js +45 -0
- package/dist/esm/reify/calculate-save-value.js.map +1 -0
- package/dist/esm/reify/check-needed-build.d.ts +25 -0
- package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
- package/dist/esm/reify/check-needed-build.js +50 -0
- package/dist/esm/reify/check-needed-build.js.map +1 -0
- package/dist/esm/reify/delete-edge.d.ts.map +1 -1
- package/dist/esm/reify/delete-edge.js +3 -4
- package/dist/esm/reify/delete-edge.js.map +1 -1
- package/dist/esm/reify/extract-node.d.ts +24 -0
- package/dist/esm/reify/extract-node.d.ts.map +1 -0
- package/dist/esm/reify/extract-node.js +84 -0
- package/dist/esm/reify/extract-node.js.map +1 -0
- package/dist/esm/reify/index.d.ts +18 -1
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +85 -15
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/internal-hoist.d.ts +9 -0
- package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
- package/dist/esm/reify/internal-hoist.js +134 -0
- package/dist/esm/reify/internal-hoist.js.map +1 -0
- package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js +33 -24
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/remove-optional-subgraph.js +1 -1
- package/dist/esm/remove-optional-subgraph.js.map +1 -1
- package/dist/esm/resolve-save-type.d.ts +1 -2
- package/dist/esm/resolve-save-type.d.ts.map +1 -1
- package/dist/esm/resolve-save-type.js.map +1 -1
- package/dist/esm/stringify-node.d.ts +1 -1
- package/dist/esm/stringify-node.d.ts.map +1 -1
- package/dist/esm/stringify-node.js +10 -1
- package/dist/esm/stringify-node.js.map +1 -1
- package/dist/esm/transfer-data/load.d.ts +44 -0
- package/dist/esm/transfer-data/load.d.ts.map +1 -0
- package/dist/esm/transfer-data/load.js +176 -0
- package/dist/esm/transfer-data/load.js.map +1 -0
- package/dist/esm/uninstall.d.ts +5 -4
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +61 -19
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts +13 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +73 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/virtual-root.d.ts +16 -0
- package/dist/esm/virtual-root.d.ts.map +1 -0
- package/dist/esm/virtual-root.js +79 -0
- package/dist/esm/virtual-root.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +4 -5
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +47 -19
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +7 -2
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +35 -12
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +7 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +110 -14
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/dist/esm/visualization/object-like-output.d.ts +1 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
- package/dist/esm/visualization/object-like-output.js.map +1 -1
- package/package.json +35 -29
- package/dist/esm/ideal/add-nodes.d.ts +0 -19
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -32
- package/dist/esm/ideal/add-nodes.js.map +0 -1
- package/dist/esm/ideal/remove-nodes.d.ts +0 -7
- package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/remove-nodes.js +0 -19
- package/dist/esm/ideal/remove-nodes.js.map +0 -1
- package/dist/esm/reify/bin-paths.d.ts +0 -4
- package/dist/esm/reify/bin-paths.d.ts.map +0 -1
- package/dist/esm/reify/bin-paths.js +0 -23
- package/dist/esm/reify/bin-paths.js.map +0 -1
- package/dist/esm/types.d.ts +0 -42
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
|
@@ -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;AAGjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AA6C1C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AACpD,MAAM,eAAe,GAAG,CACtB,IAAY,EACkB,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1D,MAAM,cAAc,GAAG,CACrB,IAAU,EACV,IAAY,EACO,EAAE,CACrB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,SAAS,CAAA;AAEb;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,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Ac,CAAA;IAEvC,uEAAuE;IACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;IACH,CAAC;IAED,qEAAqE;IACrE,sEAAsE;IACtE,0DAA0D;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type { Manifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport { shorten } from '../dependencies.ts'\nimport type { RawDependency } from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { Node } from '../node.ts'\nimport { graphStep } from '@vltpkg/output'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest?: Manifest\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry: PathScurry\n /**\n * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\nconst getPathBasedId = (\n spec: Spec,\n path: string,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path])\n : undefined\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of the current node.\n */\nconst getDeps = (node: Node) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests } = options\n const dependencies = getDeps(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n const h = hydrate(depId, alias, {\n ...options,\n registry: fromNode.registry,\n })\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n ...(h.registrySpec ?\n { version: h.registrySpec } // adds version if available\n : null),\n },\n depId,\n )\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n const spec = Spec.parse(alias, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n const maybeId = getPathBasedId(spec, realpath.relativePosix())\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n )\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n graph.placePackage(fromNode, depType, spec)\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n // TODO: once hidden lockfile is more reliable, default to false here\n const {\n skipHiddenLockfile = true,\n projectRoot,\n packageJson,\n scurry,\n monorepo,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n // TODO: check mtime of lockfile vs .vlt folder\n return graph\n } catch {}\n }\n\n const graph = new Graph({ ...options, mainManifest })\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n done()\n\n return graph\n}\n"]}
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,OAAO,EACP,cAAc,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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;QAElC,6DAA6D;QAC7D,IACE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,EAC7D,CAAC;YACD,UAAU,CAAC;gBACT,GAAG,OAAO;gBACV,KAAK;aACN,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import {\n asDepID,\n hydrate,\n joinDepIDTuple,\n joinExtra,\n splitDepID,\n splitExtra,\n} 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 { saveHidden } from '../lockfile/save.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, options)\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 if (\n h.type === 'registry' &&\n h.registry === h.options.registry &&\n fromNode.registry\n ) {\n h.registry = fromNode.registry\n }\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 joinExtra({ modifier: 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 registry: fromNode.registry,\n })\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 let peerSetHash: string | undefined\n if (maybeId) {\n // parses extra info from depID to retrieve peerSetHash\n try {\n const tuple = splitDepID(maybeId)\n const type = tuple[0]\n const extra =\n type === 'registry' || type === 'git' ?\n tuple[3]\n : tuple[2]\n\n peerSetHash =\n extra ? splitExtra(extra).peerSetHash : undefined\n /* c8 ignore next - impossible: getPathBasedId asserts valid dep id */\n } catch {}\n }\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n joinExtra({ modifier: queryModifier, peerSetHash }),\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 registry: fromNode.registry,\n })\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 joinExtra({ modifier: 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 // caches the load result to the hidden lockfile when enabled\n if (\n scurry.cwd.resolve('node_modules').lstatSync()?.isDirectory()\n ) {\n saveHidden({\n ...options,\n graph,\n })\n }\n }\n\n done()\n\n return graph\n}\n"]}
|
package/dist/esm/browser.d.ts
CHANGED
|
@@ -2,10 +2,14 @@ import { longDependencyTypes } from '@vltpkg/types';
|
|
|
2
2
|
import { asDependencyTypeShort, shorten } from './dependencies.ts';
|
|
3
3
|
import { getBooleanFlagsFromNum } from './lockfile/types.ts';
|
|
4
4
|
import { stringifyNode } from './stringify-node.ts';
|
|
5
|
-
export
|
|
5
|
+
export type { LoadResult, TransferData, } from './transfer-data/load.ts';
|
|
6
|
+
export * from './virtual-root.ts';
|
|
6
7
|
declare const lockfile: {
|
|
7
|
-
loadEdges: (graph: import("
|
|
8
|
-
loadNodes: (graph: import("
|
|
8
|
+
loadEdges: (graph: import("@vltpkg/types").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
9
|
+
loadNodes: (graph: import("@vltpkg/types").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"], options: import("@vltpkg/spec").SpecOptions, actual?: import("@vltpkg/types").GraphLike, throwOnMissingManifest?: boolean) => void;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
declare const transfer: {
|
|
12
|
+
load: (transfered: import("./transfer-data/load.ts").TransferData) => import("./transfer-data/load.ts").LoadResult;
|
|
13
|
+
};
|
|
14
|
+
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, transfer, };
|
|
11
15
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAInD,YAAY,EACV,UAAU,EACV,YAAY,GACb,MAAM,yBAAyB,CAAA;AAEhC,cAAc,mBAAmB,CAAA;AAEjC,QAAA,MAAM,QAAQ;;;CAGb,CAAA;AAED,QAAA,MAAM,QAAQ;;CAEb,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,QAAQ,GACT,CAAA"}
|
package/dist/esm/browser.js
CHANGED
|
@@ -4,10 +4,14 @@ import { getBooleanFlagsFromNum } from "./lockfile/types.js";
|
|
|
4
4
|
import { stringifyNode } from "./stringify-node.js";
|
|
5
5
|
import { loadEdges } from "./lockfile/load-edges.js";
|
|
6
6
|
import { loadNodes } from "./lockfile/load-nodes.js";
|
|
7
|
-
|
|
7
|
+
import { load } from "./transfer-data/load.js";
|
|
8
|
+
export * from "./virtual-root.js";
|
|
8
9
|
const lockfile = {
|
|
9
10
|
loadEdges,
|
|
10
11
|
loadNodes,
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
const transfer = {
|
|
14
|
+
load,
|
|
15
|
+
};
|
|
16
|
+
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, transfer, };
|
|
13
17
|
//# sourceMappingURL=browser.js.map
|
package/dist/esm/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,cAAc,
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAM9C,cAAc,mBAAmB,CAAA;AAEjC,MAAM,QAAQ,GAAG;IACf,SAAS;IACT,SAAS;CACV,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,IAAI;CACL,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,EACb,QAAQ,GACT,CAAA","sourcesContent":["import { longDependencyTypes } from '@vltpkg/types'\nimport { asDependencyTypeShort, shorten } from './dependencies.ts'\nimport { getBooleanFlagsFromNum } from './lockfile/types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { load } from './transfer-data/load.ts'\nexport type {\n LoadResult,\n TransferData,\n} from './transfer-data/load.ts'\n\nexport * from './virtual-root.ts'\n\nconst lockfile = {\n loadEdges,\n loadNodes,\n}\n\nconst transfer = {\n load,\n}\n\nexport {\n asDependencyTypeShort,\n getBooleanFlagsFromNum,\n lockfile,\n longDependencyTypes,\n shorten,\n stringifyNode,\n transfer,\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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C,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"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { DepID } from '@vltpkg/dep-id';
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
2
|
+
import { Spec } from '@vltpkg/spec/browser';
|
|
3
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
4
|
+
import type { DependencySaveType, DependencyTypeLong, DependencyTypeShort, Manifest, NodeLike } from '@vltpkg/types';
|
|
4
5
|
export declare const isDependencyTypeShort: (obj: unknown) => obj is DependencyTypeShort;
|
|
5
6
|
export declare const isDependencySaveType: (obj: unknown) => obj is DependencyTypeShort;
|
|
6
7
|
export declare const asDependencyTypeShort: (obj: unknown) => DependencyTypeShort;
|
|
@@ -55,5 +56,11 @@ export declare const asDependency: (obj: unknown) => Dependency;
|
|
|
55
56
|
/**
|
|
56
57
|
* Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.
|
|
57
58
|
*/
|
|
58
|
-
export declare const shorten: (typeLong: DependencyTypeLong, name?: string, manifest?: Manifest) => DependencyTypeShort;
|
|
59
|
+
export declare const shorten: (typeLong: DependencyTypeLong, name?: string, manifest?: Pick<Manifest, "peerDependenciesMeta"> | null) => DependencyTypeShort;
|
|
60
|
+
export declare const getRawDependencies: (node: NodeLike) => Map<string, RawDependency>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a map of all dependencies, of all types, that can be inferred
|
|
63
|
+
* from a given node manifest, including missing dependencies.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getDependencies: (node: NodeLike, options: SpecOptions) => Map<string, Dependency>;
|
|
59
66
|
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,QAAQ,EACT,MAAM,eAAe,CAAA;AAOtB,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,GAAG,IAAI,mBAC4C,CAAA;AAEtD,eAAO,MAAM,oBAAoB,QAC1B,OAAO,KACX,GAAG,IAAI,mBAEU,CAAA;AAEpB,eAAO,MAA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spec/browser';
|
|
2
3
|
import { dependencyTypes, longDependencyTypes, shortDependencyTypes, } from '@vltpkg/types';
|
|
3
4
|
export const isDependencyTypeShort = (obj) => shortDependencyTypes.has(obj);
|
|
4
5
|
export const isDependencySaveType = (obj) => shortDependencyTypes.has(obj) ||
|
|
@@ -46,4 +47,66 @@ export const shorten = (typeLong, name, manifest) => {
|
|
|
46
47
|
}
|
|
47
48
|
return 'peer';
|
|
48
49
|
};
|
|
50
|
+
const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'string');
|
|
51
|
+
/*
|
|
52
|
+
* Retrieves a map of all dependencies, of all types, that can be iterated
|
|
53
|
+
* on and consulted when parsing the directory contents of a given node.
|
|
54
|
+
*/
|
|
55
|
+
export const getRawDependencies = (node) => {
|
|
56
|
+
const dependencies = new Map();
|
|
57
|
+
const bundleDeps = node.manifest?.bundleDependencies ?? [];
|
|
58
|
+
// if it's an importer, bundleDeps are just normal. if it's a dep,
|
|
59
|
+
// then they're ignored entirely.
|
|
60
|
+
const bundled = (!node.importer &&
|
|
61
|
+
!node.id.startsWith('git') &&
|
|
62
|
+
isStringArray(bundleDeps)) ?
|
|
63
|
+
new Set(bundleDeps)
|
|
64
|
+
: new Set();
|
|
65
|
+
for (const depType of longDependencyTypes) {
|
|
66
|
+
const obj = node.manifest?.[depType];
|
|
67
|
+
// only care about devDeps for importers and git or symlink deps
|
|
68
|
+
// technically this will also include devDeps for tarball file: specs,
|
|
69
|
+
// but that is likely rare enough to not worry about too much.
|
|
70
|
+
if (depType === 'devDependencies' &&
|
|
71
|
+
!node.importer &&
|
|
72
|
+
!node.id.startsWith('git') &&
|
|
73
|
+
!node.id.startsWith('file')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (obj) {
|
|
77
|
+
for (const [name, bareSpec] of Object.entries(obj)) {
|
|
78
|
+
// if it's a bundled dependency, we just ignore it entirely.
|
|
79
|
+
if (bundled.has(name))
|
|
80
|
+
continue;
|
|
81
|
+
dependencies.set(name, {
|
|
82
|
+
name,
|
|
83
|
+
type: depType,
|
|
84
|
+
bareSpec,
|
|
85
|
+
registry: node.registry,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return dependencies;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Retrieves a map of all dependencies, of all types, that can be inferred
|
|
94
|
+
* from a given node manifest, including missing dependencies.
|
|
95
|
+
*/
|
|
96
|
+
export const getDependencies = (node, options) => {
|
|
97
|
+
const res = new Map();
|
|
98
|
+
const dependencies = getRawDependencies(node);
|
|
99
|
+
for (const { name, type, bareSpec } of dependencies.values()) {
|
|
100
|
+
const depType = shorten(type, name, node.manifest);
|
|
101
|
+
const spec = Spec.parse(name, bareSpec, {
|
|
102
|
+
...options,
|
|
103
|
+
registry: node.registry,
|
|
104
|
+
});
|
|
105
|
+
res.set(name, {
|
|
106
|
+
spec,
|
|
107
|
+
type: depType,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return res;
|
|
111
|
+
};
|
|
49
112
|
//# sourceMappingURL=dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAS3C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC,CAAA;AAEtD,MAAM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IAAI,EAAE;YACZ,IAAI;YACJ,IAAI,EAAE,OAAO;SACd,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { Spec } from '@vltpkg/spec/browser'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type {\n DependencySaveType,\n DependencyTypeLong,\n DependencyTypeShort,\n Manifest,\n NodeLike,\n} from '@vltpkg/types'\nimport {\n dependencyTypes,\n longDependencyTypes,\n shortDependencyTypes,\n} from '@vltpkg/types'\n\nexport const isDependencyTypeShort = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort)\n\nexport const isDependencySaveType = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort) ||\n obj === 'implicit'\n\nexport const asDependencyTypeShort = (\n obj: unknown,\n): DependencyTypeShort => {\n if (!isDependencyTypeShort(obj)) {\n throw error('Invalid dependency type', {\n found: obj,\n validOptions: [...shortDependencyTypes],\n })\n }\n return obj\n}\n\n/**\n * Dependency entries info as defined in a package.json file.\n */\nexport type RawDependency = {\n name: string\n bareSpec: string\n type: DependencyTypeLong\n registry?: string\n}\n\n/**\n * Parsed dependency entries info.\n */\nexport type Dependency = {\n /**\n * The parsed {@link Spec} object describing the dependency requirements.\n */\n spec: Spec\n /**\n * The {@link DependencySaveType}, describing the way this dependency should\n * be saved back to the manifest.\n */\n type: DependencySaveType\n}\n\n/**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type AddImportersDependenciesMap = Map<\n DepID,\n Map<string, Dependency>\n> & { modifiedDependencies: boolean }\n\n/**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type RemoveImportersDependenciesMap = Map<\n DepID,\n Set<string>\n> & { modifiedDependencies: boolean }\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\n// TODO: it would be nice to have a @vltpkg/spec.isSpec method\nexport const isDependency = (o: unknown): o is Dependency =>\n // TODO: it would be nice to have a @vltpkg/spec.isSpec method\n isObj(o) &&\n isObj(o.spec) &&\n !!o.spec.type &&\n isDependencySaveType(o.type)\n\nexport const asDependency = (obj: unknown): Dependency => {\n if (!isDependency(obj)) {\n throw error('Invalid dependency', { found: obj })\n }\n return obj\n}\n\n/**\n * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.\n */\nexport const shorten = (\n typeLong: DependencyTypeLong,\n name?: string,\n manifest?: Pick<Manifest, 'peerDependenciesMeta'> | null,\n): DependencyTypeShort => {\n const shortName = dependencyTypes.get(typeLong)\n if (!shortName) {\n throw error('Invalid dependency type name', {\n found: typeLong,\n validOptions: [...longDependencyTypes],\n })\n }\n if (shortName !== 'peer') {\n return shortName\n }\n if (\n name &&\n manifest?.peerDependenciesMeta?.[name]?.optional === true\n ) {\n return 'peerOptional'\n }\n return 'peer'\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of a given node.\n */\nexport const getRawDependencies = (node: NodeLike) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Retrieves a map of all dependencies, of all types, that can be inferred\n * from a given node manifest, including missing dependencies.\n */\nexport const getDependencies = (\n node: NodeLike,\n options: SpecOptions,\n): Map<string, Dependency> => {\n const res = new Map<string, Dependency>()\n const dependencies = getRawDependencies(node)\n for (const { name, type, bareSpec } of dependencies.values()) {\n const depType = shorten(type, name, node.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: node.registry,\n })\n res.set(name, {\n spec,\n type: depType,\n })\n }\n return res\n}\n"]}
|
package/dist/esm/diff.d.ts
CHANGED
|
@@ -41,9 +41,78 @@ export declare class Diff {
|
|
|
41
41
|
/** Edges in the `from` graph that are not found in the `to` graph */
|
|
42
42
|
delete: Set<Edge>;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* True if the diff only contains optional nodes (computed during construction)
|
|
46
|
+
*/
|
|
47
|
+
optionalOnly: boolean;
|
|
44
48
|
get [Symbol.toStringTag](): string;
|
|
45
49
|
constructor(from: Graph, to: Graph);
|
|
46
50
|
[kCustomInspect](_: number, options?: InspectOptions): string;
|
|
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
|
+
peerSetHash?: string | undefined;
|
|
57
|
+
id: import("@vltpkg/dep-id").DepID;
|
|
58
|
+
name: string;
|
|
59
|
+
version: string | undefined;
|
|
60
|
+
location: string;
|
|
61
|
+
importer: boolean;
|
|
62
|
+
manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
63
|
+
projectRoot: string;
|
|
64
|
+
integrity: `sha512-${string}` | undefined;
|
|
65
|
+
resolved: string | undefined;
|
|
66
|
+
dev: boolean;
|
|
67
|
+
optional: boolean;
|
|
68
|
+
confused: boolean;
|
|
69
|
+
modifier: string | undefined;
|
|
70
|
+
platform: {
|
|
71
|
+
engines?: Record<string, string>;
|
|
72
|
+
os?: string[] | string;
|
|
73
|
+
cpu?: string[] | string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
buildState: "none" | "needed" | "built" | "failed";
|
|
76
|
+
}[];
|
|
77
|
+
delete: {
|
|
78
|
+
rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
79
|
+
peerSetHash?: string | undefined;
|
|
80
|
+
id: import("@vltpkg/dep-id").DepID;
|
|
81
|
+
name: string;
|
|
82
|
+
version: string | undefined;
|
|
83
|
+
location: string;
|
|
84
|
+
importer: boolean;
|
|
85
|
+
manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
86
|
+
projectRoot: string;
|
|
87
|
+
integrity: `sha512-${string}` | undefined;
|
|
88
|
+
resolved: string | undefined;
|
|
89
|
+
dev: boolean;
|
|
90
|
+
optional: boolean;
|
|
91
|
+
confused: boolean;
|
|
92
|
+
modifier: string | undefined;
|
|
93
|
+
platform: {
|
|
94
|
+
engines?: Record<string, string>;
|
|
95
|
+
os?: string[] | string;
|
|
96
|
+
cpu?: string[] | string;
|
|
97
|
+
} | undefined;
|
|
98
|
+
buildState: "none" | "needed" | "built" | "failed";
|
|
99
|
+
}[];
|
|
100
|
+
};
|
|
101
|
+
edges: {
|
|
102
|
+
add: {
|
|
103
|
+
from: import("@vltpkg/dep-id").DepID;
|
|
104
|
+
to: import("@vltpkg/dep-id").DepID | undefined;
|
|
105
|
+
type: import("@vltpkg/types").DependencyTypeShort;
|
|
106
|
+
spec: string;
|
|
107
|
+
}[];
|
|
108
|
+
delete: {
|
|
109
|
+
from: import("@vltpkg/dep-id").DepID;
|
|
110
|
+
to: import("@vltpkg/dep-id").DepID | undefined;
|
|
111
|
+
type: import("@vltpkg/types").DependencyTypeShort;
|
|
112
|
+
spec: string;
|
|
113
|
+
}[];
|
|
114
|
+
};
|
|
115
|
+
};
|
|
47
116
|
}
|
|
48
117
|
export {};
|
|
49
118
|
//# sourceMappingURL=diff.d.ts.map
|
package/dist/esm/diff.d.ts.map
CHANGED
|
@@ -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,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;
|
|
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
|
@@ -42,6 +42,10 @@ export class Diff {
|
|
|
42
42
|
/** Edges in the `from` graph that are not found in the `to` graph */
|
|
43
43
|
delete: new Set(),
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* True if the diff only contains optional nodes (computed during construction)
|
|
47
|
+
*/
|
|
48
|
+
optionalOnly = true;
|
|
45
49
|
get [Symbol.toStringTag]() {
|
|
46
50
|
return '@vltpkg/graph.Diff';
|
|
47
51
|
}
|
|
@@ -63,6 +67,9 @@ export class Diff {
|
|
|
63
67
|
for (const [id, node] of this.to.nodes) {
|
|
64
68
|
if (!this.from.nodes.get(id)?.equals(node)) {
|
|
65
69
|
this.nodes.add.add(node);
|
|
70
|
+
if (!node.optional) {
|
|
71
|
+
this.optionalOnly = false;
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
for (const edge of this.to.edges) {
|
|
@@ -119,5 +126,23 @@ ${lines
|
|
|
119
126
|
.join('\n')}
|
|
120
127
|
}`;
|
|
121
128
|
}
|
|
129
|
+
hasChanges() {
|
|
130
|
+
return (this.nodes.add.size > 0 ||
|
|
131
|
+
this.nodes.delete.size > 0 ||
|
|
132
|
+
this.edges.add.size > 0 ||
|
|
133
|
+
this.edges.delete.size > 0);
|
|
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
|
+
}
|
|
122
147
|
}
|
|
123
148
|
//# sourceMappingURL=diff.js.map
|