/
usr
/
local
/
lib
/
node_modules
/
npm
/
lib
/
commands
/
/usr/local/lib/node_modules/npm/lib/commands
mkdir
upload
Name
Size
Mode
Actions
trust/
-
0755
rm
access.js
6313
0644
edit
dl
rm
adduser.js
1321
0644
edit
dl
rm
audit.js
3248
0644
edit
dl
rm
bugs.js
847
0644
edit
dl
rm
cache.js
11754
0644
edit
dl
rm
ci.js
4339
0644
edit
dl
rm
completion.js
11085
0644
edit
dl
rm
config.js
11753
0644
edit
dl
rm
dedupe.js
1450
0644
edit
dl
rm
deprecate.js
2488
0644
edit
dl
rm
diff.js
8109
0644
edit
dl
rm
dist-tag.js
5629
0644
edit
dl
rm
docs.js
449
0644
edit
dl
rm
doctor.js
10226
0644
edit
dl
rm
edit.js
1765
0644
edit
dl
rm
exec.js
3475
0644
edit
dl
rm
explain.js
3631
0644
edit
dl
rm
explore.js
2158
0644
edit
dl
rm
find-dupes.js
578
0644
edit
dl
rm
fund.js
6533
0644
edit
dl
rm
get.js
538
0644
edit
dl
rm
help-search.js
5662
0644
edit
dl
rm
help.js
3731
0644
edit
dl
rm
init.js
7186
0644
edit
dl
rm
install-ci-test.js
308
0644
edit
dl
rm
install-test.js
303
0644
edit
dl
rm
install.js
5221
0644
edit
dl
rm
link.js
5364
0644
edit
dl
rm
ll.js
234
0644
edit
dl
rm
login.js
1318
0644
edit
dl
rm
logout.js
1453
0644
edit
dl
rm
ls.js
18464
0644
edit
dl
rm
org.js
4054
0644
edit
dl
rm
outdated.js
8111
0644
edit
dl
rm
owner.js
6094
0644
edit
dl
rm
pack.js
2833
0644
edit
dl
rm
ping.js
873
0644
edit
dl
rm
pkg.js
3667
0644
edit
dl
rm
prefix.js
309
0644
edit
dl
rm
profile.js
10547
0644
edit
dl
rm
prune.js
770
0644
edit
dl
rm
publish.js
9698
0644
edit
dl
rm
query.js
3840
0644
edit
dl
rm
rebuild.js
2202
0644
edit
dl
rm
repo.js
1274
0644
edit
dl
rm
restart.js
303
0644
edit
dl
rm
root.js
295
0644
edit
dl
rm
run.js
6417
0644
edit
dl
rm
sbom.js
4578
0644
edit
dl
rm
search.js
1877
0644
edit
dl
rm
set.js
632
0644
edit
dl
rm
shrinkwrap.js
2691
0644
edit
dl
rm
star.js
1920
0644
edit
dl
rm
stars.js
1058
0644
edit
dl
rm
start.js
293
0644
edit
dl
rm
stop.js
288
0644
edit
dl
rm
team.js
4436
0644
edit
dl
rm
test.js
288
0644
edit
dl
rm
token.js
8153
0644
edit
dl
rm
undeprecate.js
302
0644
edit
dl
rm
uninstall.js
1522
0644
edit
dl
rm
unpublish.js
5368
0644
edit
dl
rm
unstar.js
183
0644
edit
dl
rm
update.js
1733
0644
edit
dl
rm
version.js
3621
0644
edit
dl
rm
view.js
13802
0644
edit
dl
rm
whoami.js
527
0644
edit
dl
rm
Edit:
/usr/local/lib/node_modules/npm/lib/commands/ci.js
(4339B)
const reifyFinish = require('../utils/reify-finish.js') const runScript = require('@npmcli/run-script') const fs = require('node:fs/promises') const path = require('node:path') const { log, time } = require('proc-log') const validateLockfile = require('../utils/validate-lockfile.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') const getWorkspaces = require('../utils/get-workspaces.js') class CI extends ArboristWorkspaceCmd { static description = 'Clean install a project' static name = 'ci' // These are in the order they will show up in when running "-h" static params = [ 'install-strategy', 'legacy-bundling', 'global-style', 'omit', 'include', 'strict-peer-deps', 'foreground-scripts', 'ignore-scripts', 'allow-git', 'audit', 'bin-links', 'fund', 'dry-run', ...super.params, ] async exec () { if (this.npm.global) { throw Object.assign(new Error('`npm ci` does not work for global packages'), { code: 'ECIGLOBAL', }) } const dryRun = this.npm.config.get('dry-run') const ignoreScripts = this.npm.config.get('ignore-scripts') const where = this.npm.prefix const Arborist = require('@npmcli/arborist') const opts = { ...this.npm.flatOptions, packageLock: true, // npm ci should never skip lock files path: where, save: false, // npm ci should never modify the lockfile or package.json workspaces: this.workspaceNames, } // generate an inventory from the virtual tree in the lockfile const virtualArb = new Arborist(opts) try { await virtualArb.loadVirtual() } catch (err) { log.verbose('loadVirtual', err.stack) const msg = 'The `npm ci` command can only install with an existing package-lock.json or\n' + 'npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or\n' + 'later to generate a package-lock.json file, then try again.' throw this.usageError(msg) } const virtualInventory = new Map(virtualArb.virtualTree.inventory) // Now we make our real Arborist. // We need a new one because the virtual tree fromt the lockfile can have extraneous dependencies in it that won't install on this platform const arb = new Arborist(opts) await arb.buildIdealTree() // Verifies that the packages from the ideal tree will match the same versions that are present in the virtual tree (lock file). const errors = validateLockfile(virtualInventory, arb.idealTree.inventory) if (errors.length) { throw this.usageError( '`npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. ' + 'Please update your lock file with `npm install` before continuing.\n\n' + errors.join('\n') ) } if (!dryRun) { const workspacePaths = await getWorkspaces([], { path: this.npm.localPrefix, includeWorkspaceRoot: true, }) // Only remove node_modules after we've successfully loaded the virtual tree and validated the lockfile await time.start('npm-ci:rm', async () => { return await Promise.all([...workspacePaths.values()].map(async modulePath => { const fullPath = path.join(modulePath, 'node_modules') // get the list of entries so we can skip the glob for performance const entries = await fs.readdir(fullPath, null).catch(() => []) return Promise.all(entries.map(folder => { return fs.rm(path.join(fullPath, folder), { force: true, recursive: true }) })) })) }) } await arb.reify(opts) // run the same set of scripts that `npm install` runs. if (!ignoreScripts) { const scripts = [ 'preinstall', 'install', 'postinstall', 'prepublish', // XXX should we remove this finally?? 'preprepare', 'prepare', 'postprepare', ] const scriptShell = this.npm.config.get('script-shell') || undefined for (const event of scripts) { await runScript({ path: where, args: [], scriptShell, stdio: 'inherit', event, }) } } await reifyFinish(this.npm, arb) } } module.exports = CI
Save
cmd:
run