How to use the @pnpm/core-loggers.statsLogger.debug function in @pnpm/core-loggers

To help you get started, we’ve selected a few @pnpm/core-loggers 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 / modules-cleaner / src / prune.ts View on Github external
const selectedImporterIds = importers.map((importer) => importer.id).sort()
  // In case installation is done on a subset of importers,
  // we may only prune dependencies that are used only by that subset of importers.
  // Otherwise, we would break the node_modules.
  const currentPkgIdsByDepPaths = R.equals(selectedImporterIds, Object.keys(opts.currentLockfile.importers))
    ? getPkgsDepPaths(opts.registries, opts.currentLockfile.packages || {})
    : getPkgsDepPathsOwnedOnlyByImporters(selectedImporterIds, opts.registries, opts.currentLockfile, opts.include, opts.skipped)
  const wantedPkgIdsByDepPaths = getPkgsDepPaths(opts.registries, wantedLockfile.packages || {})

  const oldDepPaths = Object.keys(currentPkgIdsByDepPaths)
  const newDepPaths = Object.keys(wantedPkgIdsByDepPaths)

  const orphanDepPaths = R.difference(oldDepPaths, newDepPaths)
  const orphanPkgIds = new Set(R.props(orphanDepPaths, currentPkgIdsByDepPaths))

  statsLogger.debug({
    prefix: opts.lockfileDir,
    removed: orphanPkgIds.size,
  })

  if (!opts.dryRun) {
    if (orphanDepPaths.length) {
      if (opts.currentLockfile.packages && opts.hoistedModulesDir) {
        const modulesDir = opts.hoistedModulesDir
        const binsDir = path.join(opts.hoistedModulesDir, '.bin')
        const prefix = path.join(opts.virtualStoreDir, '../..')
        await Promise.all(orphanDepPaths.map(async (orphanDepPath) => {
          if (opts.hoistedAliases[orphanDepPath]) {
            await Promise.all(opts.hoistedAliases[orphanDepPath].map((alias) => {
              return removeDirectDependency({
                name: alias,
              }, {
github pnpm / pnpm / packages / supi / src / install / link.ts View on Github external
const wantedRelDepPaths = R.keys(wantedLockfile.packages)

  let newDepPathsSet: Set
  if (opts.force) {
    newDepPathsSet = new Set(
      wantedRelDepPaths
        .map((relDepPath) => dp.resolve(opts.registries, relDepPath))
        // when installing a new package, not all the nodes are analyzed
        // just skip the ones that are in the lockfile but were not analyzed
        .filter((depPath) => depGraph[depPath]),
    )
  } else {
    newDepPathsSet = await selectNewFromWantedDeps(wantedRelDepPaths, currentLockfile, depGraph, opts)
  }

  statsLogger.debug({
    added: newDepPathsSet.size,
    prefix: opts.lockfileDir,
  })

  const existingWithUpdatedDeps = []
  if (!opts.force && currentLockfile.packages && wantedLockfile.packages) {
    // add subdependencies that have been updated
    // TODO: no need to relink everything. Can be relinked only what was changed
    for (const relDepPath of wantedRelDepPaths) {
      if (currentLockfile.packages[relDepPath] &&
        (!R.equals(currentLockfile.packages[relDepPath].dependencies, wantedLockfile.packages[relDepPath].dependencies) ||
        !R.equals(currentLockfile.packages[relDepPath].optionalDependencies, wantedLockfile.packages[relDepPath].optionalDependencies))) {
        const depPath = dp.resolve(opts.registries, relDepPath)

        // TODO: come up with a test that triggers the usecase of depGraph[depPath] undefined
        // see related issue: https://github.com/pnpm/pnpm/issues/870