Npm-check-updates: Implement --deep flag to update deps in monorepo

Created on 21 Mar 2019  路  6Comments  路  Source: raineorshine/npm-check-updates

Similar to #154, but would it be idea to add --deep or similar flag to check updates in monorepo to update multiple packages found in repository?

use case would be doing something like bellow, but more elegantly:

const glob = require('glob')
const childProcess = require('child_process')

const check = (pkgJsonPath) => {
  try {
    return childProcess.execSync(`./node_modules/.bin/ncu --error-level 2 --packageFileDir --packageFile ${pkgJsonPath}`).toString()
  } catch (error) {
    console.log('exec error: ' + error.message)
    process.exit(error.status)
  }
}
glob('./packages/**/package.json', {}, (er, files) => {
  files.forEach((file) => {
    if (file.includes('node_modules')) {
      return
    }
    console.log(`command to update: ./node_modules/.bin/ncu --packageFileDir --packageFile ${file} -u -i`)
    console.log(check(file))
  })
})
  • [x] I have read the list of known issues before filing this issue.
  • [x] I have searched for similiar issues before filing this issue.

  • node version: *

  • npm version: *
  • npm-check-updates version: *

enhancement

All 6 comments

In the meantime, you can use update-versions from yours truly. I wrote it to help with monorepo maintenance, after I moved to Lerna.

It does two tasks: 1. updates dependencies; 2. enforces ^x.x.x notation. The second task can be very sneaky since as you know, Lerna will not properly bootstrap dependencies marked with latest, * or whatever else. Also, update-versions works on normal repos, it's probably faster than npm-check-updates anyway because it's simpler and uses npm's native pacote (instead of in-house solution that npm-check-updates uses).

it's probably faster than npm-check-updates anyway

Testing with a rather extreme example of ~1500 dependencies

time ncu
real    0m10.082s

time upd
real    1m7.172s

^ interesting!

No offense to @revelt or lerna-update-wizard, but neither option meets my needs. I would love to see this feature in ncu. Reason being, I use exact versions and I want to update everything at once.

In the meantime, you can use update-versions from yours truly. I wrote it to help with monorepo maintenance, after I moved to Lerna.

It does two tasks: 1. updates dependencies; 2. enforces ^x.x.x notation. The second task can be very sneaky since as you know, Lerna will not properly bootstrap dependencies marked with latest, * or whatever else. Also, update-versions works on normal repos, it's probably faster than npm-check-updates anyway because it's simpler and uses npm's native pacote (instead of in-house solution that npm-check-updates uses).

@revelt It is a nice extension. However, I tried to use it today in a lerna/yarn monorepo on windows and the issue that even if I have ^x.x.x it is still doing a major version update. On my case, it is changing "antd": "^3.26.9", to "antd": "^4.1.0"` :(

Update-versions doesn't seem to offer the same level of interactivity. Or it's docs are terrible. Will be forking ncu and publishing a --deep option that was mentioned above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eschon picture Eschon  路  7Comments

fatso83 picture fatso83  路  3Comments

JanWeskamp picture JanWeskamp  路  3Comments

dereklin picture dereklin  路  6Comments

frankTadlip picture frankTadlip  路  4Comments