1 |
|
2 | 'use strict'
|
3 |
|
4 | const ora = require('ora')
|
5 | const depCheck = require('../src/dependency-check')
|
6 |
|
7 | const EPILOG = `
|
8 | Supports options forwarding with '--' for more info check https://github.com/maxogden/dependency-check#cli-usage
|
9 | `
|
10 |
|
11 | const commandName = depCheck.commandNames[0]
|
12 |
|
13 | module.exports = {
|
14 | command: `${commandName} [input...]`,
|
15 | aliases: depCheck.commandNames.filter(name => name !== commandName),
|
16 | desc: 'Run `dependency-check` cli with aegir defaults.',
|
17 | builder: (yargs) => {
|
18 | yargs
|
19 | .epilog(EPILOG)
|
20 | .example('aegir dependency-check -- --unused', 'To check unused packages in your repo.')
|
21 | .example('aegir dependency-check -- --unused --ignore typescript', 'To check unused packages in your repo, ignoring typescript.')
|
22 | .positional('input', {
|
23 | describe: 'Files to check',
|
24 | type: 'array',
|
25 | default: depCheck.defaultInput
|
26 | })
|
27 | .option('p', {
|
28 | alias: 'production-only',
|
29 | describe: 'Check production dependencies and paths only',
|
30 | type: 'boolean',
|
31 | default: false
|
32 | })
|
33 | .option('i', {
|
34 | alias: 'ignore',
|
35 | describe: 'Ignore these dependencies when considering which are used and which are not',
|
36 | type: 'array',
|
37 | default: []
|
38 | })
|
39 | },
|
40 | async handler (argv) {
|
41 | const spinner = ora('Checking dependencies').start()
|
42 |
|
43 | try {
|
44 | await depCheck(argv, process.argv)
|
45 | spinner.succeed()
|
46 | } catch (err) {
|
47 | spinner.fail()
|
48 | throw err
|
49 | }
|
50 | }
|
51 | }
|