/snap/node/11782/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/11782/lib/node_modules/npm/lib/commands/shrinkwrap.js (2712B)
const { resolve, basename } = require('node:path') const { unlink } = require('node:fs/promises') const { log } = require('proc-log') const BaseCommand = require('../base-cmd.js') class Shrinkwrap extends BaseCommand { static description = 'Lock down dependency versions for publication' static name = 'shrinkwrap' static ignoreImplicitWorkspace = false async exec () { // if has a npm-shrinkwrap.json, nothing to do // if has a package-lock.json, rename to npm-shrinkwrap.json // if has neither, load the actual tree and save that as npm-shrinkwrap.json // // loadVirtual, fall back to loadActual // rename shrinkwrap file type, and tree.meta.save() if (this.npm.global) { const er = new Error('`npm shrinkwrap` does not work for global packages') er.code = 'ESHRINKWRAPGLOBAL' throw er } const Arborist = require('@npmcli/arborist') const path = this.npm.prefix const sw = resolve(path, 'npm-shrinkwrap.json') const arb = new Arborist({ ...this.npm.flatOptions, path }) const tree = await arb.loadVirtual().catch(() => arb.loadActual()) const { meta } = tree const newFile = meta.hiddenLockfile || !meta.loadedFromDisk const oldFilename = meta.filename const notSW = !newFile && basename(oldFilename) !== 'npm-shrinkwrap.json' // The computed lockfile version of a hidden lockfile is always 3 // even if the actual value of the property is a different. // When shrinkwrap is run with only a hidden lockfile we want to // set the shrinkwrap lockfile version as whatever was explicitly // requested with a fallback to the actual value from the hidden // lockfile. if (meta.hiddenLockfile) { meta.lockfileVersion = arb.options.lockfileVersion || meta.originalLockfileVersion } meta.hiddenLockfile = false meta.filename = sw await meta.save() const updatedVersion = meta.originalLockfileVersion !== meta.lockfileVersion ? meta.lockfileVersion : null if (newFile) { let message = 'created a lockfile as npm-shrinkwrap.json' if (updatedVersion) { message += ` with version ${updatedVersion}` } log.notice('', message) } else if (notSW) { await unlink(oldFilename) let message = 'package-lock.json has been renamed to npm-shrinkwrap.json' if (updatedVersion) { message += ` and updated to version ${updatedVersion}` } log.notice('', message) } else if (updatedVersion) { log.notice('', `npm-shrinkwrap.json updated to version ${updatedVersion}`) } else { log.notice('', 'npm-shrinkwrap.json up to date') } } } module.exports = Shrinkwrap