How to use the pacote.manifest function in pacote

To help you get started, we’ve selected a few pacote 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 ShabadOS / desktop / app / lib / Updater.js View on Github external
async isLatestDatabase() {
    // Read package.json database semver and database package file
    const [ remotePackage, localPackage ] = await Promise.all( [
      manifest( databasePackage ),
      readJSON( join( DATABASE_FOLDER, 'package.json' ), 'utf-8' ),
    ] )

    const { version: local } = localPackage
    const { version: remote } = remotePackage

    this.emit( 'database-version', { local, remote } )
    logger.info( 'Local Database Version:', local )
    logger.info( 'Remote Database Version:', remote )

    return localPackage.version === remotePackage.version
  }
github cerebral / webpack-packager / src / url-generator / dependencyMapper.js View on Github external
function getManifest(depString) {
  if (cache[depString]) {
    // Only use it if it's not expired
    if (cache[depString].ttl + MAX_TTL > Date.now()) {
      return cache[depString].promise;
    }
  }

  const promise = pacote.manifest(depString);
  cache[depString] = promise;

  return promise;
}
github npm / arborist / lib / arborist.js View on Github external
newNodeFromSpec (name, spec, parent) {
    // pacote will slap integrity on its options, so we have to clone
    // the object so it doesn't get mutated.
    // Don't bother to load the manifest for link deps, because the target
    // might be within another package that doesn't exist yet.
    return spec.type === 'directory'
      ? Promise.resolve(new Link({ name, parent, realpath: spec.fetchSpec }))
      : pacote.manifest(spec, Object.create(this.options))
        .then(pkg => new Node({ name, pkg, parent }))
  }
github sk770 / npm-offline-packager / lib / fetch-packages.js View on Github external
.catch((error) => {
                if (error.code === 'ETARGET') {
                    const { latest } = error.distTags;
                    return pacote.manifest(`${packageName}@${latest}`, pacoteOptions);
                }

                if (error.code === 'E404') {
                    console.error(`\nError: "${packageName}@${packageVersion}" not found`);
                    return packageVersion !== 'latest' ? pacote.manifest(packageName, pacoteOptions)
                        : Promise.reject(new Error(`${packageName}@${packageVersion} not found`));
                }

                return Promise.reject(error);
            }),
        packageVersion !== 'latest' ? pacote.packument(packageName, pacoteOptions) : Promise.resolve(),
github sk770 / npm-offline-packager / lib / fetch-packages.js View on Github external
.catch((error) => {
                if (error.code === 'ETARGET') {
                    const { latest } = error.distTags;
                    return pacote.manifest(`${packageName}@${latest}`, pacoteOptions);
                }

                if (error.code === 'E404') {
                    console.error(`\nError: "${packageName}@${packageVersion}" not found`);
                    return packageVersion !== 'latest' ? pacote.manifest(packageName, pacoteOptions)
                        : Promise.reject(new Error(`${packageName}@${packageVersion} not found`));
                }

                return Promise.reject(error);
            }),
        packageVersion !== 'latest' ? pacote.packument(packageName, pacoteOptions) : Promise.resolve(),
github xpack / xpm-js / lib / xpm / install.js View on Github external
async installPackage (packSpec) {
    const log = this.log
    log.trace(`${this.constructor.name}.installPackage('${packSpec}')`)

    const config = this.config

    const cachePath = this.globalConfig.cacheFolderPath
    let manifest
    try {
      manifest = await pacote.manifest(packSpec, { cache: cachePath })
      log.trace(manifest)
    } catch (err) {
      log.error(err.message)
      return CliExitCodes.ERROR.INPUT
    }

    const manifestId = new ManifestId(manifest)
    log.trace(manifestId)

    const globalPackagePath = path.join(
      this.globalConfig.globalFolderPath, manifestId.getPath())

    const packFullName = manifestId.getFullName()

    log.info(`Processing ${packFullName}...`)
github xpack / xpm-js / lib / xpm / install.js View on Github external
async collectDevDependencies (json) {
    const log = this.log
    log.trace(`${this.constructor.name}.collectDevDependencies()` +
      ` for ${json.name}`)

    const cachePath = this.globalConfig.cacheFolderPath

    if (json.devDependencies) {
      for (const [key, value] of Object.entries(json.devDependencies)) {
        const version = value.replace(/^[^0-9]+/, '')
        const pack = `${key}@${version}`
        let manifest
        try {
          log.info(`Processing package ${pack}...`)
          manifest = await pacote.manifest(pack, { cache: cachePath })
        } catch (err) {
          log.error(err.message)
          return CliExitCodes.ERROR.APPLICATION
        }

        if (!this.collectedDependencies[key]) {
          manifest.isContributedByDevDependencies = true
          this.collectedDependencies[key] = manifest
        } else {
          if (version !== manifest.version) {
            log.error('Version mitigation not yet implemented.')
            return CliExitCodes.ERROR.APPLICATION
          }
        }
      }
    }

pacote

JavaScript package downloader

ISC
Latest version published 3 months ago

Package Health Score

95 / 100
Full package analysis