How to use @pnpm/types - 7 common examples

To help you get started, we’ve selected a few @pnpm/types 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 / uninstall / removeDeps.ts View on Github external
removedPackages: string[],
  opts: {
    saveType?: DependenciesField,
    prefix: string,
  },
): Promise {
  if (opts.saveType) {
    packageManifest[opts.saveType] = packageManifest[opts.saveType]

    if (!packageManifest[opts.saveType]) return packageManifest

    removedPackages.forEach((dependency) => {
      delete packageManifest[opts.saveType as DependenciesField]![dependency]
    })
  } else {
    DEPENDENCIES_FIELDS
      .filter((depField) => packageManifest[depField])
      .forEach((depField) => {
        removedPackages.forEach((dependency) => {
          delete packageManifest[depField]![dependency]
        })
      })
  }
  if (packageManifest.peerDependencies) {
    for (const removedDependency of removedPackages) {
      delete packageManifest.peerDependencies[removedDependency]
    }
  }

  packageManifestLogger.debug({
    prefix: opts.prefix,
    updated: packageManifest,
github pnpm / pnpm / packages / get-context / src / index.ts View on Github external
function stringifyIncludedDeps (included: IncludedDependencies) {
  return DEPENDENCIES_FIELDS.filter((depsField) => included[depsField]).join(', ')
}
github pnpm / pnpm / packages / supi / src / save.ts View on Github external
packageSpecs.forEach((packageSpec) => {
    if (packageSpec.saveType) {
      const spec = packageSpec.pref || findSpec(packageSpec.alias, packageManifest as ImporterManifest)
      if (spec) {
        packageManifest[packageSpec.saveType] = packageManifest[packageSpec.saveType] || {}
        packageManifest[packageSpec.saveType]![packageSpec.alias] = spec
        DEPENDENCIES_FIELDS.filter((depField) => depField !== packageSpec.saveType).forEach((deptype) => {
          if (packageManifest[deptype]) {
            delete packageManifest[deptype]![packageSpec.alias]
          }
        })
        if (packageSpec.peer === true) {
          packageManifest.peerDependencies = packageManifest.peerDependencies || {}
          packageManifest.peerDependencies[packageSpec.alias] = spec
        }
      }
    } else if (packageSpec.pref) {
      const usedDepType = guessDependencyType(packageSpec.alias, packageManifest as ImporterManifest) || 'dependencies'
      packageManifest[usedDepType] = packageManifest[usedDepType] || {}
      packageManifest[usedDepType]![packageSpec.alias] = packageSpec.pref
    }
  })
github pnpm / pnpm / packages / supi / src / save.ts View on Github external
export function guessDependencyType (alias: string, manifest: ImporterManifest): DependenciesField | undefined {
  return DEPENDENCIES_FIELDS
    .find((depField) => Boolean(manifest[depField]?.[alias]))
}
github pnpm / pnpm / packages / list / src / renderTree.ts View on Github external
!pkg.optionalDependencies?.length &&
    !pkg.unsavedDependencies?.length
  ) return ''

  let label = ''
  if (pkg.name) {
    label += pkg.name
    if (pkg.version) {
      label += `@${pkg.version}`
    }
    label += ' '
  }
  label += pkg.path
  let output = (opts.depth > -1 ? LEGEND : '') + label + '\n'
  const useColumns = opts.depth === 0 && opts.long === false && !opts.search
  for (let dependenciesField of [...DEPENDENCIES_FIELDS.sort(), 'unsavedDependencies']) {
    if (pkg[dependenciesField]?.length) {
      const depsLabel = chalk.cyanBright(
        dependenciesField !== 'unsavedDependencies'
          ? `${dependenciesField}:`
          : 'not saved (you should add these dependencies to package.json if you need them):'
      )
      output += `\n${depsLabel}\n`
      const gPkgColor = dependenciesField === 'unsavedDependencies' ? () => NOT_SAVED_DEP_CLR : getPkgColor
      if (useColumns && pkg[dependenciesField].length > 10) {
        output += cliColumns(pkg[dependenciesField].map(printLabel.bind(printLabel, gPkgColor))) + '\n'
        continue
      }
      const data = await toArchyTree(gPkgColor, pkg[dependenciesField]!, {
        long: opts.long,
        modules: path.join(pkg.path, 'node_modules'),
      })
github pnpm / pnpm / packages / list / src / renderJson.ts View on Github external
const jsonArr = await Promise.all(pkgs.map(async (pkg) => {
    const jsonObj = {
      name: pkg.name,

      version: pkg.version,
    }
    for (const dependenciesField of [...DEPENDENCIES_FIELDS.sort(), 'unsavedDependencies']) {
      if (pkg[dependenciesField]?.length) {
        jsonObj[dependenciesField] = await toJsonResult(pkg[dependenciesField], { long: opts.long })
      }
    }

    return jsonObj
  }))
github pnpm / pnpm / packages / modules-cleaner / src / prune.ts View on Github external
function mergeDependencies (lockfileImporter: LockfileImporter): { [depName: string]: string } {
  return R.mergeAll(
    DEPENDENCIES_FIELDS.map((depType) => lockfileImporter[depType] || {}),
  )
}

@pnpm/types

Basic types used by pnpm

MIT
Latest version published 23 days ago

Package Health Score

72 / 100
Full package analysis