How to use @pnpm/prune-lockfile - 5 common examples

To help you get started, we’ve selected a few @pnpm/prune-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 / link / index.ts View on Github external
const addLinkOpts = {
      linkedPkgName: linkFromAlias || manifest.name,
      manifest: ctx.manifest,
      packagePath,
    }
    addLinkToLockfile(ctx.currentLockfile.importers[importerId], addLinkOpts)
    addLinkToLockfile(ctx.wantedLockfile.importers[importerId], addLinkOpts)

    linkedPkgs.push({
      alias: linkFromAlias || manifest.name,
      manifest,
      path: linkFromPath,
    })
  }

  const updatedCurrentLockfile = pruneSharedLockfile(ctx.currentLockfile)

  const warn = (message: string) => logger.warn({ message, prefix: opts.dir })
  const updatedWantedLockfile = pruneSharedLockfile(ctx.wantedLockfile, { warn })

  await prune(
    [
      {
        binsDir: opts.binsDir,
        id: importerId,
        modulesDir: ctx.modulesDir,
        rootDir: opts.dir,
      },
    ],
    {
      currentLockfile,
      hoistedAliases: ctx.hoistedAliases,
github pnpm / pnpm / packages / supi / src / link / index.ts View on Github external
packagePath,
    }
    addLinkToLockfile(ctx.currentLockfile.importers[importerId], addLinkOpts)
    addLinkToLockfile(ctx.wantedLockfile.importers[importerId], addLinkOpts)

    linkedPkgs.push({
      alias: linkFromAlias || manifest.name,
      manifest,
      path: linkFromPath,
    })
  }

  const updatedCurrentLockfile = pruneSharedLockfile(ctx.currentLockfile)

  const warn = (message: string) => logger.warn({ message, prefix: opts.dir })
  const updatedWantedLockfile = pruneSharedLockfile(ctx.wantedLockfile, { warn })

  await prune(
    [
      {
        binsDir: opts.binsDir,
        id: importerId,
        modulesDir: ctx.modulesDir,
        rootDir: opts.dir,
      },
    ],
    {
      currentLockfile,
      hoistedAliases: ctx.hoistedAliases,
      hoistedModulesDir: opts.hoistPattern && ctx.hoistedModulesDir || undefined,
      include: ctx.include,
      lockfileDir: opts.lockfileDir,
github pnpm / pnpm / packages / supi / src / install / updateLockfile.ts View on Github external
Object.keys(depNode.children).map((alias) => ({ alias, depPath: depNode.children[alias] })),
    )
    lockfile.packages[relDepPath] = toLockfileDependency(pendingRequiresBuilds, depNode.additionalInfo, {
      depGraph,
      depPath,
      prevSnapshot: lockfile.packages[relDepPath],
      registries,
      registry: dp.getRegistryByPackageName(registries, depNode.name),
      relDepPath,
      updatedDeps: result[1],
      updatedOptionalDeps: result[0],
    })
  }
  const warn = (message: string) => logger.warn({ message, prefix })
  return {
    newLockfile: pruneSharedLockfile(lockfile, { warn }),
    pendingRequiresBuilds,
  }
}
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
export async function uninstallInContext (
  pkgsToUninstall: string[],
  ctx: PnpmSingleContext,
  opts: StrictUninstallOptions,
) {
  const makePartialCurrentLockfile = !lockfilesEqual(ctx.currentLockfile, ctx.wantedLockfile)

  const saveType = getSaveType(opts)
  const pkg = await removeDeps(ctx.manifest, pkgsToUninstall, { prefix: opts.prefix, saveType })
  const newLockfile = pruneLockfile(ctx.wantedLockfile, pkg, ctx.importerId, {
    defaultRegistry: ctx.registries.default,
    warn: (message) => logger.warn({ message, prefix: ctx.prefix }),
  })
  const removedPkgIds = await prune({
    importers: [
      {
        bin: opts.bin,
        hoistedAliases: ctx.hoistedAliases,
        id: ctx.importerId,
        modulesDir: ctx.modulesDir,
        prefix: ctx.prefix,
        removePackages: pkgsToUninstall,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    ],
    lockfileDirectory: opts.lockfileDirectory,
github pnpm / pnpm / packages / supi / src / uninstall / index.ts View on Github external
prefix: ctx.prefix,
        removePackages: pkgsToUninstall,
        shamefullyFlatten: opts.shamefullyFlatten,
      },
    ],
    lockfileDirectory: opts.lockfileDirectory,
    newLockfile,
    oldLockfile: ctx.currentLockfile,
    registries: ctx.registries,
    storeController: opts.storeController,
    virtualStoreDir: ctx.virtualStoreDir,
  })
  ctx.pendingBuilds = ctx.pendingBuilds.filter((pkgId) => !removedPkgIds.has(dp.resolve(ctx.registries, pkgId)))
  await opts.storeController.close()
  const currentLockfile = makePartialCurrentLockfile
    ? pruneLockfile(ctx.currentLockfile, pkg, ctx.importerId, { defaultRegistry: ctx.registries.default })
    : newLockfile
  const lockfileOpts = { forceSharedFormat: opts.forceSharedLockfile }
  if (opts.useLockfile) {
    await writeLockfiles(ctx.lockfileDirectory, newLockfile, currentLockfile, lockfileOpts)
  } else {
    await writeCurrentLockfile(ctx.lockfileDirectory, currentLockfile, lockfileOpts)
  }

  if (opts.shamefullyFlatten) {
    ctx.hoistedAliases = await shamefullyFlattenByLockfile(currentLockfile, ctx.importerId, {
      getIndependentPackageLocation: opts.independentLeaves
        ? async (packageId: string, packageName: string) => {
          const { directory } = await opts.storeController.getPackageLocation(packageId, packageName, {
            lockfileDirectory: ctx.lockfileDirectory,
            targetEngine: opts.sideEffectsCacheRead && ENGINE_NAME || undefined,
          })

@pnpm/prune-lockfile

Prune a pnpm-lock.yaml

MIT
Latest version published 20 days ago

Package Health Score

66 / 100
Full package analysis