How to use the @pnpm/lockfile-file.readCurrentLockfile function in @pnpm/lockfile-file

To help you get started, we’ve selected a few @pnpm/lockfile-file 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 / get-context / src / readLockfiles.ts View on Github external
wantedLockfile: Lockfile,
}> {
  // ignore `pnpm-lock.yaml` on CI servers
  // a latest pnpm should not break all the builds
  const lockfileOpts = {
    ignoreIncompatible: opts.force || isCI,
    wantedVersion: LOCKFILE_VERSION,
  }
  const files = await Promise.all([
    opts.useLockfile && readWantedLockfile(opts.lockfileDir, lockfileOpts)
      || await existsWantedLockfile(opts.lockfileDir) &&
        logger.warn({
          message: `A ${WANTED_LOCKFILE} file exists. The current configuration prohibits to read or write a lockfile`,
          prefix: opts.lockfileDir,
        }),
    readCurrentLockfile(opts.virtualStoreDir, lockfileOpts),
  ])
  const sopts = { lockfileVersion: LOCKFILE_VERSION }
  const importerIds = opts.importers.map((importer) => importer.id)
  const currentLockfile = files[1] || createLockfileObject(importerIds, sopts)
  for (const importerId of importerIds) {
    if (!currentLockfile.importers[importerId]) {
      currentLockfile.importers[importerId] = {
        specifiers: {},
      }
    }
  }
  const wantedLockfile = files[0] ||
    currentLockfile && R.clone(currentLockfile) ||
    createLockfileObject(importerIds, sopts)
  for (const importerId of importerIds) {
    if (!wantedLockfile.importers[importerId]) {
github pnpm / pnpm / packages / plugin-commands-outdated / src / outdated.ts View on Github external
export async function outdatedDependenciesOfWorkspacePackages (
  pkgs: Array<{dir: string, manifest: ImporterManifest}>,
  args: string[],
  opts: OutdatedOptions,
) {
  const lockfileDir = opts.lockfileDir || opts.dir
  const modules = await readModulesManifest(path.join(lockfileDir, 'node_modules'))
  const virtualStoreDir = modules?.virtualStoreDir || path.join(lockfileDir, 'node_modules/.pnpm')
  const currentLockfile = await readCurrentLockfile(virtualStoreDir, { ignoreIncompatible: false })
  const wantedLockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: false }) || currentLockfile
  if (!wantedLockfile) {
    throw new PnpmError('OUTDATED_NO_LOCKFILE', 'No lockfile in this directory. Run `pnpm install` to generate one.')
  }
  const storeDir = await storePath(opts.dir, opts.store)
  const getLatestManifest = createLatestManifestGetter({
    ...opts,
    lockfileDir,
    storeDir,
  })
  return Promise.all(pkgs.map(async ({ dir, manifest }) => {
    let match = args.length && matcher(args) || undefined
    return {
      manifest,
      outdatedPackages: await outdated({
        currentLockfile,