11cb0ef41Sopenharmony_ciconst path = require('path') 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst log = require('../utils/log-shim.js') 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst reifyFinish = require('../utils/reify-finish.js') 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst ArboristWorkspaceCmd = require('../arborist-cmd.js') 81cb0ef41Sopenharmony_ciclass Update extends ArboristWorkspaceCmd { 91cb0ef41Sopenharmony_ci static description = 'Update packages' 101cb0ef41Sopenharmony_ci static name = 'update' 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci static params = [ 131cb0ef41Sopenharmony_ci 'save', 141cb0ef41Sopenharmony_ci 'global', 151cb0ef41Sopenharmony_ci 'install-strategy', 161cb0ef41Sopenharmony_ci 'legacy-bundling', 171cb0ef41Sopenharmony_ci 'global-style', 181cb0ef41Sopenharmony_ci 'omit', 191cb0ef41Sopenharmony_ci 'include', 201cb0ef41Sopenharmony_ci 'strict-peer-deps', 211cb0ef41Sopenharmony_ci 'package-lock', 221cb0ef41Sopenharmony_ci 'foreground-scripts', 231cb0ef41Sopenharmony_ci 'ignore-scripts', 241cb0ef41Sopenharmony_ci 'audit', 251cb0ef41Sopenharmony_ci 'bin-links', 261cb0ef41Sopenharmony_ci 'fund', 271cb0ef41Sopenharmony_ci 'dry-run', 281cb0ef41Sopenharmony_ci ...super.params, 291cb0ef41Sopenharmony_ci ] 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci static usage = ['[<pkg>...]'] 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci // TODO 341cb0ef41Sopenharmony_ci /* istanbul ignore next */ 351cb0ef41Sopenharmony_ci static async completion (opts, npm) { 361cb0ef41Sopenharmony_ci const completion = require('../utils/completion/installed-deep.js') 371cb0ef41Sopenharmony_ci return completion(npm, opts) 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci async exec (args) { 411cb0ef41Sopenharmony_ci const update = args.length === 0 ? true : args 421cb0ef41Sopenharmony_ci const global = path.resolve(this.npm.globalDir, '..') 431cb0ef41Sopenharmony_ci const where = this.npm.global ? global : this.npm.prefix 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci // In the context of `npm update` the save 461cb0ef41Sopenharmony_ci // config value should default to `false` 471cb0ef41Sopenharmony_ci const save = this.npm.config.isDefault('save') 481cb0ef41Sopenharmony_ci ? false 491cb0ef41Sopenharmony_ci : this.npm.config.get('save') 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ci if (this.npm.config.get('depth')) { 521cb0ef41Sopenharmony_ci log.warn('update', 'The --depth option no longer has any effect. See RFC0019.\n' + 531cb0ef41Sopenharmony_ci 'https://github.com/npm/rfcs/blob/latest/implemented/0019-remove-update-depth-option.md') 541cb0ef41Sopenharmony_ci } 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci const Arborist = require('@npmcli/arborist') 571cb0ef41Sopenharmony_ci const opts = { 581cb0ef41Sopenharmony_ci ...this.npm.flatOptions, 591cb0ef41Sopenharmony_ci path: where, 601cb0ef41Sopenharmony_ci save, 611cb0ef41Sopenharmony_ci workspaces: this.workspaceNames, 621cb0ef41Sopenharmony_ci } 631cb0ef41Sopenharmony_ci const arb = new Arborist(opts) 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci await arb.reify({ ...opts, update }) 661cb0ef41Sopenharmony_ci await reifyFinish(this.npm, arb) 671cb0ef41Sopenharmony_ci } 681cb0ef41Sopenharmony_ci} 691cb0ef41Sopenharmony_cimodule.exports = Update 70