404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.129.211.156: ~ $
const cacache = require('cacache')
const { promisify } = require('util')
const pacote = require('pacote')
const path = require('path')
const rimraf = promisify(require('rimraf'))
const semver = require('semver')
const BaseCommand = require('../base-command.js')
const npa = require('npm-package-arg')
const jsonParse = require('json-parse-even-better-errors')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const log = require('../utils/log-shim')

const searchCachePackage = async (path, parsed, cacheKeys) => {
  /* eslint-disable-next-line max-len */
  const searchMFH = new RegExp(`^make-fetch-happen:request-cache:.*(?<!/[@a-zA-Z]+)/${parsed.name}/-/(${parsed.name}[^/]+.tgz)$`)
  const searchPack = new RegExp(`^make-fetch-happen:request-cache:.*/${parsed.escapedName}$`)
  const results = new Set()
  cacheKeys = new Set(cacheKeys)
  for (const key of cacheKeys) {
    // match on the public key registry url format
    if (searchMFH.test(key)) {
      // extract the version from the filename
      const filename = key.match(searchMFH)[1]
      const noExt = filename.slice(0, -4)
      const noScope = `${parsed.name.split('/').pop()}-`
      const ver = noExt.slice(noScope.length)
      if (semver.satisfies(ver, parsed.rawSpec)) {
        results.add(key)
      }
      continue
    }
    // is this key a packument?
    if (!searchPack.test(key)) {
      continue
    }

    results.add(key)
    let packument, details
    try {
      details = await cacache.get(path, key)
      packument = jsonParse(details.data)
    } catch (_) {
      // if we couldn't parse the packument, abort
      continue
    }
    if (!packument.versions || typeof packument.versions !== 'object') {
      continue
    }

    // assuming this is a packument
    for (const ver of Object.keys(packument.versions)) {
      if (semver.satisfies(ver, parsed.rawSpec)) {
        if (packument.versions[ver].dist &&
          typeof packument.versions[ver].dist === 'object' &&
          packument.versions[ver].dist.tarball !== undefined &&
          cacheKeys.has(`make-fetch-happen:request-cache:${packument.versions[ver].dist.tarball}`)
        ) {
          results.add(`make-fetch-happen:request-cache:${packument.versions[ver].dist.tarball}`)
        }
      }
    }
  }
  return results
}

class Cache extends BaseCommand {
  static description = 'Manipulates packages cache'
  static name = 'cache'
  static params = ['cache']
  static usage = [
    'add <package-spec>',
    'clean [<key>]',
    'ls [<name>@<version>]',
    'verify',
  ]

  static ignoreImplicitWorkspace = true

  async completion (opts) {
    const argv = opts.conf.argv.remain
    if (argv.length === 2) {
      return ['add', 'clean', 'verify', 'ls', 'delete']
    }

    // TODO - eventually...
    switch (argv[2]) {
      case 'verify':
      case 'clean':
      case 'add':
      case 'ls':
      case 'delete':
        return []
    }
  }

  async exec (args) {
    const cmd = args.shift()
    switch (cmd) {
      case 'rm': case 'clear': case 'clean':
        return await this.clean(args)
      case 'add':
        return await this.add(args)
      case 'verify': case 'check':
        return await this.verify()
      case 'ls':
        return await this.ls(args)
      default:
        throw this.usageError()
    }
  }

  // npm cache clean [pkg]*
  async clean (args) {
    const cachePath = path.join(this.npm.cache, '_cacache')
    if (args.length === 0) {
      if (!this.npm.config.get('force')) {
        throw new Error(`As of npm@5, the npm cache self-heals from corruption issues
  by treating integrity mismatches as cache misses.  As a result,
  data extracted from the cache is guaranteed to be valid.  If you
  want to make sure everything is consistent, use \`npm cache verify\`
  instead.  Deleting the cache can only make npm go slower, and is
  not likely to correct any problems you may be encountering!

  On the other hand, if you're debugging an issue with the installer,
  or race conditions that depend on the timing of writing to an empty
  cache, you can use \`npm install --cache /tmp/empty-cache\` to use a
  temporary cache instead of nuking the actual one.

  If you're sure you want to delete the entire cache, rerun this command
  with --force.`)
      }
      return rimraf(cachePath)
    }
    for (const key of args) {
      let entry
      try {
        entry = await cacache.get(cachePath, key)
      } catch (err) {
        log.warn(`Not Found: ${key}`)
        break
      }
      this.npm.output(`Deleted: ${key}`)
      await cacache.rm.entry(cachePath, key)
      // XXX this could leave other entries without content!
      await cacache.rm.content(cachePath, entry.integrity)
    }
  }

  // npm cache add <tarball-url>...
  // npm cache add <pkg> <ver>...
  // npm cache add <tarball>...
  // npm cache add <folder>...
  async add (args) {
    log.silly('cache add', 'args', args)
    if (args.length === 0) {
      throw this.usageError('First argument to `add` is required')
    }

    return Promise.all(args.map(spec => {
      log.silly('cache add', 'spec', spec)
      // we ask pacote for the thing, and then just throw the data
      // away so that it tee-pipes it into the cache like it does
      // for a normal request.
      return pacote.tarball.stream(spec, stream => {
        stream.resume()
        return stream.promise()
      }, this.npm.flatOptions)
    }))
  }

  async verify () {
    const cache = path.join(this.npm.cache, '_cacache')
    const prefix = cache.indexOf(process.env.HOME) === 0
      ? `~${cache.slice(process.env.HOME.length)}`
      : cache
    const stats = await cacache.verify(cache)
    this.npm.output(`Cache verified and compressed (${prefix})`)
    this.npm.output(`Content verified: ${stats.verifiedContent} (${stats.keptSize} bytes)`)
    if (stats.badContentCount) {
      this.npm.output(`Corrupted content removed: ${stats.badContentCount}`)
    }
    if (stats.reclaimedCount) {
      /* eslint-disable-next-line max-len */
      this.npm.output(`Content garbage-collected: ${stats.reclaimedCount} (${stats.reclaimedSize} bytes)`)
    }
    if (stats.missingContent) {
      this.npm.output(`Missing content: ${stats.missingContent}`)
    }
    this.npm.output(`Index entries: ${stats.totalEntries}`)
    this.npm.output(`Finished in ${stats.runTime.total / 1000}s`)
  }

  // npm cache ls [--package <spec> ...]
  async ls (specs) {
    const cachePath = path.join(this.npm.cache, '_cacache')
    const cacheKeys = Object.keys(await cacache.ls(cachePath))
    if (specs.length > 0) {
      // get results for each package spec specified
      const results = new Set()
      for (const spec of specs) {
        const parsed = npa(spec)
        if (parsed.rawSpec !== '' && parsed.type === 'tag') {
          throw this.usageError('Cannot list cache keys for a tagged package.')
        }
        const keySet = await searchCachePackage(cachePath, parsed, cacheKeys)
        for (const key of keySet) {
          results.add(key)
        }
      }
      [...results].sort(localeCompare).forEach(key => this.npm.output(key))
      return
    }
    cacheKeys.sort(localeCompare).forEach(key => this.npm.output(key))
  }
}

module.exports = Cache

Filemanager

Name Type Size Permission Actions
access.js File 5.45 KB 0644
adduser.js File 2.2 KB 0644
audit.js File 11.95 KB 0644
bin.js File 729 B 0644
birthday.js File 508 B 0644
bugs.js File 815 B 0644
cache.js File 7.08 KB 0644
ci.js File 3.63 KB 0644
completion.js File 8.91 KB 0644
config.js File 8.11 KB 0644
dedupe.js File 1.37 KB 0644
deprecate.js File 2.06 KB 0644
diff.js File 8.1 KB 0644
dist-tag.js File 5.47 KB 0644
docs.js File 447 B 0644
doctor.js File 9.22 KB 0644
edit.js File 2 KB 0644
exec.js File 2.44 KB 0644
explain.js File 3.55 KB 0644
explore.js File 2.33 KB 0644
find-dupes.js File 602 B 0644
fund.js File 6.37 KB 0644
get.js File 524 B 0644
help-search.js File 5.62 KB 0644
help.js File 4.53 KB 0644
hook.js File 3.93 KB 0644
init.js File 6.81 KB 0644
install-ci-test.js File 377 B 0644
install-test.js File 374 B 0644
install.js File 5.11 KB 0644
link.js File 5.02 KB 0644
ll.js File 234 B 0644
logout.js File 1.34 KB 0644
ls.js File 16.94 KB 0644
org.js File 4.2 KB 0644
outdated.js File 8.84 KB 0644
owner.js File 5.88 KB 0644
pack.js File 2.36 KB 0644
ping.js File 874 B 0644
pkg.js File 3.47 KB 0644
prefix.js File 343 B 0644
profile.js File 11.25 KB 0644
prune.js File 779 B 0644
publish.js File 6.33 KB 0644
query.js File 2.81 KB 0644
rebuild.js File 2.16 KB 0644
repo.js File 1.24 KB 0644
restart.js File 351 B 0644
root.js File 298 B 0644
run-script.js File 6.9 KB 0644
search.js File 2.72 KB 0644
set-script.js File 2.63 KB 0644
set.js File 572 B 0644
shrinkwrap.js File 2.64 KB 0644
star.js File 1.87 KB 0644
stars.js File 1.03 KB 0644
start.js File 341 B 0644
stop.js File 336 B 0644
team.js File 4.44 KB 0644
test.js File 336 B 0644
token.js File 6.79 KB 0644
uninstall.js File 1.52 KB 0644
unpublish.js File 4.51 KB 0644
unstar.js File 182 B 0644
update.js File 1.7 KB 0644
version.js File 3.6 KB 0644
view.js File 14.38 KB 0644
whoami.js File 514 B 0644