Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
update.js67 linesDownload Raw Back to commands
1const path = require('node:path')
2const { log } = require('proc-log')
3const reifyFinish = require('../utils/reify-finish.js')
4const ArboristWorkspaceCmd = require('../arborist-cmd.js')
5
6class Update extends ArboristWorkspaceCmd {
7  static description = 'Update packages'
8  static name = 'update'
9
10  static params = [
11    'save',
12    'global',
13    'install-strategy',
14    'legacy-bundling',
15    'global-style',
16    'omit',
17    'include',
18    'strict-peer-deps',
19    'package-lock',
20    'foreground-scripts',
21    'ignore-scripts',
22    'audit',
23    'before',
24    'bin-links',
25    'fund',
26    'dry-run',
27    ...super.params,
28  ]
29
30  static usage = ['[<pkg>...]']
31
32  static async completion (opts, npm) {
33    const completion = require('../utils/installed-deep.js')
34    return completion(npm, opts)
35  }
36
37  async exec (args) {
38    const update = args.length === 0 ? true : args
39    const global = path.resolve(this.npm.globalDir, '..')
40    const where = this.npm.global ? global : this.npm.prefix
41
42    // In the context of `npm update` the save config value should default to `false`
43    const save = this.npm.config.isDefault('save')
44      ? false
45      : this.npm.config.get('save')
46
47    if (this.npm.config.get('depth')) {
48      log.warn('update', 'The --depth option no longer has any effect. See RFC0019.\n' +
49        'https://github.com/npm/rfcs/blob/latest/implemented/0019-remove-update-depth-option.md')
50    }
51
52    const Arborist = require('@npmcli/arborist')
53    const opts = {
54      ...this.npm.flatOptions,
55      path: where,
56      save,
57      workspaces: this.workspaceNames,
58    }
59    const arb = new Arborist(opts)
60
61    await arb.reify({ ...opts, update })
62    await reifyFinish(this.npm, arb)
63  }
64}
65
66module.exports = Update
67 
codekingpro/portable-devtools · Team Ai