How to use @pnpm/lockfile-walker - 3 common examples

To help you get started, we’ve selected a few @pnpm/lockfile-walker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnpm / pnpm / packages / plugin-commands-rebuild / src / implementation / index.ts View on Github external
virtualStoreDir: string,
    rootModulesDir: string,
    currentLockfile: Lockfile,
    importers: Array<{ id: string, rootDir: string }>,
    independentLeaves: boolean,
    extraBinPaths: string[],
  },
  opts: StrictRebuildOptions,
) {
  const pkgsThatWereRebuilt = new Set()
  const graph = new Map()
  const pkgSnapshots: PackageSnapshots = ctx.currentLockfile.packages || {}

  const nodesToBuildAndTransitive = new Set()
  getSubgraphToBuild(
    lockfileWalker(
      ctx.currentLockfile,
      ctx.importers.map(({ id }) => id),
      {
        include: {
          dependencies: opts.production,
          devDependencies: opts.development,
          optionalDependencies: opts.optional,
        }
      }
    ),
    nodesToBuildAndTransitive,
    { pkgsToRebuild: ctx.pkgsToRebuild }
  )
  const nodesToBuildAndTransitiveArray = Array.from(nodesToBuildAndTransitive)

  for (const relDepPath of nodesToBuildAndTransitiveArray) {
github pnpm / pnpm / packages / hoist / src / index.ts View on Github external
export default async function hoistByLockfile (
  match: (dependencyName: string) => boolean,
  opts: {
    getIndependentPackageLocation?: (packageId: string, packageName: string) => Promise,
    lockfile: Lockfile,
    lockfileDir: string,
    modulesDir: string,
    registries: Registries,
    virtualStoreDir: string,
  },
) {
  if (!opts.lockfile.packages) return {}

  const deps = await getDependencies(
    lockfileWalker(
      opts.lockfile,
      Object.keys(opts.lockfile.importers)
    ),
    0,
    {
      getIndependentPackageLocation: opts.getIndependentPackageLocation,
      lockfileDir: opts.lockfileDir,
      registries: opts.registries,
      virtualStoreDir: opts.virtualStoreDir,
    },
  )

  const aliasesByDependencyPath = await hoistGraph(deps, opts.lockfile.importers['.'].specifiers, {
    dryRun: false,
    match,
    modulesDir: opts.modulesDir,
github pnpm / pnpm / packages / filter-lockfile / src / filterLockfileByImporters.ts View on Github external
lockfile: Lockfile,
  importerIds: string[],
  opts: {
    include: { [dependenciesField in DependenciesField]: boolean },
    registries: Registries,
    skipped: Set,
    failOnMissingDependencies: boolean,
  },
): Lockfile {
  if (R.equals(importerIds.sort(), R.keys(lockfile.importers).sort())) {
    return filterLockfile(lockfile, opts)
  }
  const packages = {} as PackageSnapshots
  if (lockfile.packages) {
    pkgAllDeps(
      lockfileWalker(
        lockfile,
        importerIds,
        { include: opts.include, skipped: opts.skipped }
      ),
      packages,
      {
        failOnMissingDependencies: opts.failOnMissingDependencies,
      },
    )
  }

  const importers = importerIds.reduce((acc, importerId) => {
    acc[importerId] = filterImporter(lockfile.importers[importerId], opts.include)
    return acc
  }, { ...lockfile.importers })

@pnpm/lockfile-walker

Walk over all the dependencies in a lockfile

MIT
Latest version published 5 months ago

Package Health Score

62 / 100
Full package analysis

Popular @pnpm/lockfile-walker functions