/snap/node/11691/lib/node_modules/npm/lib/commands
NameSizeModeActions
access.js61890644editdlrm
adduser.js13210644editdlrm
audit.js32210644editdlrm
bugs.js8470644editdlrm
cache.js72920644editdlrm
ci.js43250644editdlrm
completion.js91160644editdlrm
config.js114440644editdlrm
dedupe.js14430644editdlrm
deprecate.js21820644editdlrm
diff.js81910644editdlrm
dist-tag.js56540644editdlrm
docs.js4490644editdlrm
doctor.js103470644editdlrm
edit.js18040644editdlrm
exec.js35000644editdlrm
explain.js36610644editdlrm
explore.js22110644editdlrm
find-dupes.js6340644editdlrm
fund.js66100644editdlrm
get.js5770644editdlrm
help-search.js56500644editdlrm
help.js37520644editdlrm
hook.js34530644editdlrm
init.js70180644editdlrm
install-ci-test.js3730644editdlrm
install-test.js3700644editdlrm
install.js52770644editdlrm
link.js53810644editdlrm
ll.js2340644editdlrm
login.js13180644editdlrm
logout.js14530644editdlrm
ls.js186290644editdlrm
org.js41210644editdlrm
outdated.js78800644editdlrm
owner.js59880644editdlrm
pack.js26650644editdlrm
ping.js8730644editdlrm
pkg.js36410644editdlrm
prefix.js3350644editdlrm
profile.js108190644editdlrm
prune.js7990644editdlrm
publish.js75520644editdlrm
query.js35950644editdlrm
rebuild.js22410644editdlrm
repo.js12780644editdlrm
restart.js3100644editdlrm
root.js2950644editdlrm
run-script.js62210644editdlrm
sbom.js46160644editdlrm
search.js18770644editdlrm
set.js6710644editdlrm
shrinkwrap.js27120644editdlrm
star.js19110644editdlrm
stars.js10520644editdlrm
start.js3000644editdlrm
stop.js2950644editdlrm
team.js44610644editdlrm
test.js2950644editdlrm
token.js61600644editdlrm
uninstall.js15610644editdlrm
unpublish.js53940644editdlrm
unstar.js1830644editdlrm
update.js17650644editdlrm
version.js36280644editdlrm
view.js131060644editdlrm
whoami.js5270644editdlrm
Edit: /snap/node/11691/lib/node_modules/npm/lib/commands/cache.js (7292B)
const cacache = require('cacache') const pacote = require('pacote') const fs = require('node:fs/promises') const { join } = require('node:path') const semver = require('semver') const BaseCommand = require('../base-cmd.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, output } = require('proc-log') const searchCachePackage = async (path, parsed, cacheKeys) => { /* eslint-disable-next-line max-len */ const searchMFH = new RegExp(`^make-fetch-happen:request-cache:.*(?', 'clean []', 'ls [@]', 'verify', ] static async completion (opts) { const argv = opts.conf.argv.remain if (argv.length === 2) { return ['add', 'clean', 'verify', 'ls'] } // TODO - eventually... switch (argv[2]) { case 'verify': case 'clean': case 'add': case 'ls': 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 = 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 fs.rm(cachePath, { recursive: true, force: true }) } for (const key of args) { let entry try { entry = await cacache.get(cachePath, key) } catch (err) { log.warn('cache', `Not Found: ${key}`) break } output.standard(`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 ... // npm cache add ... // npm cache add ... // npm cache add ... async add (args) { log.silly('cache add', 'args', args) if (args.length === 0) { throw this.usageError('First argument to `add` is required') } await Promise.all(args.map(async 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. await pacote.tarball.stream(spec, stream => { stream.resume() return stream.promise() }, { ...this.npm.flatOptions }) await pacote.manifest(spec, { ...this.npm.flatOptions, fullMetadata: true, }) })) } async verify () { const cache = 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) output.standard(`Cache verified and compressed (${prefix})`) output.standard(`Content verified: ${stats.verifiedContent} (${stats.keptSize} bytes)`) if (stats.badContentCount) { output.standard(`Corrupted content removed: ${stats.badContentCount}`) } if (stats.reclaimedCount) { /* eslint-disable-next-line max-len */ output.standard(`Content garbage-collected: ${stats.reclaimedCount} (${stats.reclaimedSize} bytes)`) } if (stats.missingContent) { output.standard(`Missing content: ${stats.missingContent}`) } output.standard(`Index entries: ${stats.totalEntries}`) output.standard(`Finished in ${stats.runTime.total / 1000}s`) } // npm cache ls [--package ...] async ls (specs) { const cachePath = 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 => output.standard(key)) return } cacheKeys.sort(localeCompare).forEach(key => output.standard(key)) } } module.exports = Cache