2024-04-30 23:53:22 -07:00
|
|
|
const { log } = require('proc-log')
|
|
|
|
const BaseCommand = require('./base-cmd.js')
|
2022-12-06 22:18:33 -05:00
|
|
|
|
2021-05-13 16:18:53 -04:00
|
|
|
// This is the base for all commands whose execWorkspaces just gets
|
|
|
|
// a list of workspace names and passes it on to new Arborist() to
|
|
|
|
// be able to run a filtered Arborist.reify() at some point.
|
|
|
|
class ArboristCmd extends BaseCommand {
|
2021-10-14 22:17:47 +00:00
|
|
|
get isArboristCmd () {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-11-18 20:58:02 +00:00
|
|
|
static params = [
|
|
|
|
'workspace',
|
|
|
|
'workspaces',
|
|
|
|
'include-workspace-root',
|
2022-04-28 18:41:15 +05:30
|
|
|
'install-links',
|
2021-11-18 20:58:02 +00:00
|
|
|
]
|
2021-05-13 16:18:53 -04:00
|
|
|
|
2023-01-16 22:38:23 -05:00
|
|
|
static workspaces = true
|
2022-03-03 21:38:08 +00:00
|
|
|
static ignoreImplicitWorkspace = false
|
2024-10-05 06:54:06 -07:00
|
|
|
static checkDevEngines = true
|
2022-03-03 21:38:08 +00:00
|
|
|
|
2022-12-06 22:18:33 -05:00
|
|
|
constructor (npm) {
|
|
|
|
super(npm)
|
2023-01-16 22:38:23 -05:00
|
|
|
|
|
|
|
const { config } = this.npm
|
|
|
|
|
|
|
|
// when location isn't set and global isn't true check for a package.json at
|
|
|
|
// the localPrefix and set the location to project if found
|
|
|
|
const locationProject = config.get('location') === 'project' || (
|
|
|
|
config.isDefault('location')
|
|
|
|
// this is different then `npm.global` which falls back to checking
|
|
|
|
// location which we do not want to use here
|
|
|
|
&& !config.get('global')
|
|
|
|
&& npm.localPackage
|
|
|
|
)
|
|
|
|
|
|
|
|
// if audit is not set and we are in global mode and location is not project
|
|
|
|
// and we assume its not a project related context, then we set audit=false
|
|
|
|
if (config.isDefault('audit') && (this.npm.global || !locationProject)) {
|
|
|
|
config.set('audit', false)
|
|
|
|
} else if (this.npm.global && config.get('audit')) {
|
|
|
|
log.warn('config', 'includes both --global and --audit, which is currently unsupported.')
|
2022-12-06 22:18:33 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-16 22:38:23 -05:00
|
|
|
async execWorkspaces (args) {
|
|
|
|
await this.setWorkspaces()
|
2021-11-04 20:42:47 +00:00
|
|
|
return this.exec(args)
|
2021-05-13 16:18:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ArboristCmd
|