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 searched for similiar issues before filing this issue.
node version: *
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-versionsfrom 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.xnotation. The second task can be very sneaky since as you know, Lerna will not properly bootstrap dependencies marked withlatest,*or whatever else. Also,update-versionsworks on normal repos, it's probably faster thannpm-check-updatesanyway because it's simpler and uses npm's native pacote (instead of in-house solution thatnpm-check-updatesuses).
@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.