2024-05-30 04:21:05 -07:00
|
|
|
const path = require('node:path')
|
2024-04-30 23:53:22 -07:00
|
|
|
const { log } = require('proc-log')
|
2021-11-04 20:42:47 +00:00
|
|
|
const reifyFinish = require('../utils/reify-finish.js')
|
|
|
|
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
|
2024-04-30 23:53:22 -07:00
|
|
|
|
2021-05-20 15:54:50 -04:00
|
|
|
class Update extends ArboristWorkspaceCmd {
|
2021-11-18 20:58:02 +00:00
|
|
|
static description = 'Update packages'
|
|
|
|
static name = 'update'
|
2022-03-17 20:22:31 +00:00
|
|
|
|
2021-11-18 20:58:02 +00:00
|
|
|
static params = [
|
2022-03-17 20:22:31 +00:00
|
|
|
'save',
|
2021-11-18 20:58:02 +00:00
|
|
|
'global',
|
2022-12-06 22:18:33 -05:00
|
|
|
'install-strategy',
|
2021-11-18 20:58:02 +00:00
|
|
|
'legacy-bundling',
|
2022-12-06 22:18:33 -05:00
|
|
|
'global-style',
|
2022-03-17 20:22:31 +00:00
|
|
|
'omit',
|
2023-10-13 06:55:37 -07:00
|
|
|
'include',
|
2021-11-18 20:58:02 +00:00
|
|
|
'strict-peer-deps',
|
|
|
|
'package-lock',
|
2022-03-17 20:22:31 +00:00
|
|
|
'foreground-scripts',
|
2021-11-18 20:58:02 +00:00
|
|
|
'ignore-scripts',
|
|
|
|
'audit',
|
|
|
|
'bin-links',
|
|
|
|
'fund',
|
|
|
|
'dry-run',
|
|
|
|
...super.params,
|
|
|
|
]
|
|
|
|
|
|
|
|
static usage = ['[<pkg>...]']
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
/* istanbul ignore next */
|
2023-06-08 05:24:49 -07:00
|
|
|
static async completion (opts, npm) {
|
2024-04-30 23:53:22 -07:00
|
|
|
const completion = require('../utils/installed-deep.js')
|
2023-06-08 05:24:49 -07:00
|
|
|
return completion(npm, opts)
|
2020-10-02 17:52:19 -04:00
|
|
|
}
|
2017-12-07 14:05:23 -08:00
|
|
|
|
2021-11-04 20:42:47 +00:00
|
|
|
async exec (args) {
|
2021-03-04 17:40:28 -05:00
|
|
|
const update = args.length === 0 ? true : args
|
|
|
|
const global = path.resolve(this.npm.globalDir, '..')
|
2023-01-16 22:38:23 -05:00
|
|
|
const where = this.npm.global ? global : this.npm.prefix
|
2021-03-04 17:40:28 -05:00
|
|
|
|
2022-01-20 22:08:53 +00:00
|
|
|
// In the context of `npm update` the save
|
|
|
|
// config value should default to `false`
|
|
|
|
const save = this.npm.config.isDefault('save')
|
|
|
|
? false
|
|
|
|
: this.npm.config.get('save')
|
|
|
|
|
2021-03-23 14:58:11 -04:00
|
|
|
if (this.npm.config.get('depth')) {
|
2021-03-04 17:40:28 -05:00
|
|
|
log.warn('update', 'The --depth option no longer has any effect. See RFC0019.\n' +
|
|
|
|
'https://github.com/npm/rfcs/blob/latest/implemented/0019-remove-update-depth-option.md')
|
|
|
|
}
|
|
|
|
|
2023-05-07 03:37:34 -07:00
|
|
|
const Arborist = require('@npmcli/arborist')
|
2022-01-20 22:08:53 +00:00
|
|
|
const opts = {
|
2021-03-04 17:40:28 -05:00
|
|
|
...this.npm.flatOptions,
|
|
|
|
path: where,
|
2022-01-20 22:08:53 +00:00
|
|
|
save,
|
2021-06-17 18:59:38 +00:00
|
|
|
workspaces: this.workspaceNames,
|
2022-01-20 22:08:53 +00:00
|
|
|
}
|
|
|
|
const arb = new Arborist(opts)
|
2021-03-04 17:40:28 -05:00
|
|
|
|
2022-01-20 22:08:53 +00:00
|
|
|
await arb.reify({ ...opts, update })
|
2021-03-04 17:40:28 -05:00
|
|
|
await reifyFinish(this.npm, arb)
|
|
|
|
}
|
2011-11-21 09:48:45 -08:00
|
|
|
}
|
2024-04-30 23:53:22 -07:00
|
|
|
|
2021-03-04 17:40:28 -05:00
|
|
|
module.exports = Update
|