UNPKG

@nodesecure/tree-walker

Version:
69 lines 2.63 kB
import pacote from "pacote"; import type { PackageJSON, WorkspacesPackageJSON, ManifestVersion } from "@nodesecure/npm-types"; import { type LocalDependencyTreeLoaderProvider } from "./LocalDependencyTreeLoader.js"; import { type DependencyJSON, type NpmSpec } from "../Dependency.class.js"; export interface PacoteProviderApi { manifest(spec: string, opts?: pacote.Options): Promise<pacote.AbbreviatedManifest & pacote.ManifestResult>; packument(spec: string, opts?: pacote.Options): Promise<pacote.AbbreviatedPackument & pacote.PackumentResult>; } export interface TreeWalkerOptions { registry?: string; providers?: { pacote?: PacoteProviderApi; localTreeLoader?: LocalDependencyTreeLoaderProvider; }; } export interface WalkOptions { /** * Specifies the maximum depth to traverse for each root dependency. * For example, a value of 2 would mean only traversing dependencies and their immediate dependencies. * * @default Infinity */ maxDepth?: number; /** * Includes development dependencies in the walk. * Note that enabling this option can significantly increase processing time. * * @default false */ includeDevDeps?: boolean; /** * Enables the use of Arborist for rapidly walking over the dependency tree. * When enabled, it triggers different methods based on the presence of `node_modules`: * - `loadActual()` if `node_modules` is available. * - `loadVirtual()` otherwise. * * When disabled, it will iterate on all dependencies by using pacote */ packageLock?: { /** * Fetches all manifests for additional metadata. * This option is useful only when `usePackageLock` is enabled. * * @default false */ fetchManifest?: boolean; /** * Specifies the location of the manifest file for Arborist. * This is typically the path to the `package.json` file. */ location: string; }; } export declare class TreeWalker { /** * A Map of Children Spec -> Parent Spec (as a unique list) */ relationsMap: Map<NpmSpec, Set<NpmSpec>>; registry: string; private providers; constructor(options?: TreeWalkerOptions); private get registryOptions(); private addTreeRelation; private resolveDependencyVersion; private walkRemoteDependency; private walkLocalDependency; walk(manifest: PackageJSON | WorkspacesPackageJSON | ManifestVersion, options?: WalkOptions): AsyncIterableIterator<DependencyJSON>; } //# sourceMappingURL=walker.d.ts.map