How to use @pnpm/package-is-installable - 3 common examples

To help you get started, we’ve selected a few @pnpm/package-is-installable 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 / filter-lockfile / src / filterLockfileByImportersAndEngine.ts View on Github external
}
    let installable!: boolean
    if (!parentIsInstallable) {
      installable = false
      if (!ctx.pickedPackages[relDepPath]) {
        opts.skipped.add(relDepPath)
      }
    } else {
      const pkg = {
        ...nameVerFromPkgSnapshot(relDepPath, pkgSnapshot),
        cpu: pkgSnapshot.cpu,
        engines: pkgSnapshot.engines,
        os: pkgSnapshot.os,
      }
      // TODO: relDepPath is not the package ID. Should be fixed
      installable = opts.includeIncompatiblePackages || packageIsInstallable(pkgSnapshot.id || relDepPath, pkg, {
        engineStrict: opts.engineStrict,
        lockfileDir: opts.lockfileDir,
        nodeVersion: opts.currentEngine.nodeVersion,
        optional: pkgSnapshot.optional === true,
        pnpmVersion: opts.currentEngine.pnpmVersion,
      }) !== false
      if (!installable) {
        if (!ctx.pickedPackages[relDepPath]) {
          opts.skipped.add(relDepPath)
        }
      } else {
        opts.skipped.delete(relDepPath)
        ctx.pickedPackages[relDepPath] = pkgSnapshot
      }
    }
    const nextRelDepPaths = R.toPairs(
github pnpm / pnpm / packages / resolve-dependencies / src / resolveDependencies.ts View on Github external
deprecationLogger.debug({
      deprecated: pkg.deprecated,
      depth: options.currentDepth,
      pkgId: pkgResponse.body.id,
      pkgName: pkg.name,
      pkgVersion: pkg.version,
      prefix: ctx.prefix,
    })
  }

  // using colon as it will never be used inside a package ID
  const nodeId = createNodeId(options.parentNodeId, pkgResponse.body.id)

  const currentIsInstallable = (
      ctx.force ||
      packageIsInstallable(pkgResponse.body.id, pkg, {
        engineStrict: ctx.engineStrict,
        lockfileDir: ctx.lockfileDir,
        nodeVersion: ctx.nodeVersion,
        optional: wantedDependency.optional,
        pnpmVersion: ctx.pnpmVersion,
      })
    )
  if (currentIsInstallable !== true || !parentIsInstallable) {
    ctx.skipped.add(pkgResponse.body.id)
  }
  const installable = parentIsInstallable && currentIsInstallable !== false
  const isNew = !ctx.resolvedPackagesByPackageId[pkgResponse.body.id]

  if (isNew) {
    progressLogger.debug({
      packageId: pkgResponse.body.id,
github pnpm / pnpm / packages / cli-utils / src / packageIsInstallable.ts View on Github external
export function packageIsInstallable (
  pkgPath: string,
  pkg: {
    engines?: WantedEngine,
    cpu?: string[],
    os?: string[],
  },
  opts: {
    engineStrict?: boolean,
  },
) {
  const err = checkPackage(pkgPath, pkg, {
    pnpmVersion: packageManager.stableVersion,
  })
  if (err === null) return
  if (
    (err instanceof UnsupportedEngineError && err.wanted.pnpm) ||
    opts.engineStrict
  ) throw err
  logger.warn({
    message: `Unsupported ${
      err instanceof UnsupportedEngineError ? 'engine' : 'platform'
    }: wanted: ${JSON.stringify(err.wanted)} (current: ${JSON.stringify(err.current)})`,
    prefix: pkgPath,
  })
}

@pnpm/package-is-installable

Checks if a package is installable on the current system

MIT
Latest version published 8 days ago

Package Health Score

66 / 100
Full package analysis

Popular @pnpm/package-is-installable functions

Similar packages