How to use @pnpm/filter-lockfile - 6 common examples

To help you get started, we’ve selected a few @pnpm/filter-lockfile 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 / supi / src / install / link.ts View on Github external
// TODO: try to cover with unit test the case when entry is no longer available in lockfile
    // It is an edge that probably happens if the entry is removed during lockfile prune
    if (depNode.requiresBuild && newWantedLockfile.packages![relativeDepPath]) {
      newWantedLockfile.packages![relativeDepPath].requiresBuild = true
    }
  }))

  let currentLockfile: Lockfile
  const allImportersIncluded = R.equals(importerIds.sort(), Object.keys(newWantedLockfile.importers).sort())
  if (
    opts.makePartialCurrentLockfile ||
    !allImportersIncluded
  ) {
    const filteredCurrentLockfile = allImportersIncluded
      ? opts.currentLockfile
      : filterLockfileByImporters(
        opts.currentLockfile,
        Object.keys(newWantedLockfile.importers)
          .filter((importerId) => !importerIds.includes(importerId) && opts.currentLockfile.importers[importerId]),
        {
          ...filterOpts,
          failOnMissingDependencies: false,
        },
      )
    const packages = filteredCurrentLockfile.packages || {}
    if (newWantedLockfile.packages) {
      for (const relDepPath in newWantedLockfile.packages) { // tslint:disable-line:forin
        const depPath = dp.resolve(opts.registries, relDepPath)
        if (depGraph[depPath]) {
          packages[relDepPath] = newWantedLockfile.packages[relDepPath]
        }
      }
github pnpm / pnpm / packages / modules-cleaner / src / prune.ts View on Github external
function getPkgsDepPathsOwnedOnlyByImporters (
  importerIds: string[],
  registries: Registries,
  lockfile: Lockfile,
  include: { [dependenciesField in DependenciesField]: boolean },
  skipped: Set,
) {
  const selected = filterLockfileByImporters(lockfile,
    importerIds,
    {
      failOnMissingDependencies: false,
      include,
      registries,
      skipped,
    })
  const other = filterLockfileByImporters(lockfile,
    R.difference(Object.keys(lockfile.importers), importerIds),
    {
      failOnMissingDependencies: false,
      include,
      registries,
      skipped,
    })
  const packagesOfSelectedOnly = R.pickAll(R.difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots
  return getPkgsDepPaths(registries, packagesOfSelectedOnly)
}
github pnpm / pnpm / packages / supi / src / install / link.ts View on Github external
virtualStoreDir: opts.virtualStoreDir,
    wantedLockfile: newWantedLockfile,
  })

  stageLogger.debug({
    prefix: opts.lockfileDir,
    stage: 'importing_started',
  })

  const importerIds = importers.map(({ id }) => id)
  const filterOpts = {
    include: opts.include,
    registries: opts.registries,
    skipped: opts.skipped,
  }
  const newCurrentLockfile = filterLockfileByImporters(newWantedLockfile, importerIds, {
    ...filterOpts,
    failOnMissingDependencies: true,
  })
  const newDepPaths = await linkNewPackages(
    filterLockfileByImporters(opts.currentLockfile, importerIds, {
      ...filterOpts,
      failOnMissingDependencies: false,
    }),
    newCurrentLockfile,
    depGraph,
    {
      dryRun: opts.dryRun,
      force: opts.force,
      lockfileDir: opts.lockfileDir,
      optional: opts.include.optionalDependencies,
      registries: opts.registries,
github pnpm / pnpm / packages / supi / src / install / link.ts View on Github external
prefix: opts.lockfileDir,
    stage: 'importing_started',
  })

  const importerIds = importers.map(({ id }) => id)
  const filterOpts = {
    include: opts.include,
    registries: opts.registries,
    skipped: opts.skipped,
  }
  const newCurrentLockfile = filterLockfileByImporters(newWantedLockfile, importerIds, {
    ...filterOpts,
    failOnMissingDependencies: true,
  })
  const newDepPaths = await linkNewPackages(
    filterLockfileByImporters(opts.currentLockfile, importerIds, {
      ...filterOpts,
      failOnMissingDependencies: false,
    }),
    newCurrentLockfile,
    depGraph,
    {
      dryRun: opts.dryRun,
      force: opts.force,
      lockfileDir: opts.lockfileDir,
      optional: opts.include.optionalDependencies,
      registries: opts.registries,
      storeController: opts.storeController,
      virtualStoreDir: opts.virtualStoreDir,
    },
  )
github pnpm / pnpm / packages / modules-cleaner / src / prune.ts View on Github external
function getPkgsDepPathsOwnedOnlyByImporters (
  importerIds: string[],
  registries: Registries,
  lockfile: Lockfile,
  include: { [dependenciesField in DependenciesField]: boolean },
  skipped: Set,
) {
  const selected = filterLockfileByImporters(lockfile,
    importerIds,
    {
      failOnMissingDependencies: false,
      include,
      registries,
      skipped,
    })
  const other = filterLockfileByImporters(lockfile,
    R.difference(Object.keys(lockfile.importers), importerIds),
    {
      failOnMissingDependencies: false,
      include,
      registries,
      skipped,
    })
  const packagesOfSelectedOnly = R.pickAll(R.difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots
github pnpm / pnpm / packages / modules-cleaner / src / prune.ts View on Github external
opts: {
    dryRun?: boolean,
    include: { [dependenciesField in DependenciesField]: boolean },
    hoistedAliases: {[depPath: string]: string[]},
    hoistedModulesDir?: string,
    wantedLockfile: Lockfile,
    currentLockfile: Lockfile,
    pruneStore?: boolean,
    registries: Registries,
    skipped: Set,
    virtualStoreDir: string,
    lockfileDir: string,
    storeController: StoreController,
  },
): Promise> {
  const wantedLockfile = filterLockfile(opts.wantedLockfile, {
    include: opts.include,
    registries: opts.registries,
    skipped: opts.skipped,
  })
  await Promise.all(importers.map(async ({ binsDir, id, modulesDir, pruneDirectDependencies, removePackages, rootDir }) => {
    const currentImporter = opts.currentLockfile.importers[id] || {} as LockfileImporter
    const currentPkgs = R.toPairs(mergeDependencies(currentImporter))
    const wantedPkgs = R.toPairs(mergeDependencies(wantedLockfile.importers[id]))

    const allCurrentPackages = new Set(
      (pruneDirectDependencies || removePackages?.length)
        ? (await readModulesDir(modulesDir) || [])
        : [],
    )
    const depsToRemove = new Set([
      ...(removePackages || []).filter((removePackage) => allCurrentPackages.has(removePackage)),

@pnpm/filter-lockfile

Filters a lockfile

MIT
Latest version published 5 months ago

Package Health Score

62 / 100
Full package analysis