|
1 | 1 | #!/usr/bin/env node |
2 | | -const prog = require('caporal'); |
3 | | -const packageJSON = require('./package.json'); |
4 | | -const surfaceAction = require('./cli/surface'); |
5 | | -const dependenciesAction = require('./cli/dependencies'); |
6 | | -const dependentAction = require('./cli/dependent'); |
7 | | -const nayliasAction = require('./cli/naylias'); |
8 | | - |
9 | | -prog.version(packageJSON.version); |
10 | | - |
11 | | -const GLOBAL_OPTIONS = [ |
12 | | - ['--targetDir <path>', 'Target scan directory', prog.STRING, '.'], |
13 | | - ['--projectRoot <path>', 'Project root path', prog.STRING, process.cwd()], |
14 | | - ['--ext <extensions>', 'File extensions to be matched', prog.LIST, 'js'], |
15 | | - [ |
16 | | - '--incl <glob-patterns>', |
17 | | - 'Glob patterns to include in scan', |
18 | | - prog.LIST, |
19 | | - '**/*.js' |
20 | | - ], |
21 | | - [ |
22 | | - '--excl <glob-patterns>', |
23 | | - 'Glob patterns to exclude in scan', |
24 | | - prog.LIST, |
25 | | - 'node_modules/**' |
26 | | - ], |
27 | | - [ |
28 | | - '--alias <aliases>', |
29 | | - 'Alias used within your project. E.g: my-alias-name:path/to/my/alias', |
30 | | - prog.REPEATABLE, |
31 | | - '', |
32 | | - false |
33 | | - ], |
34 | | - [ |
35 | | - '--rescan <boolean>', |
36 | | - 'Invalidates chipper cache and forces a rescan', |
37 | | - prog.BOOL, |
38 | | - false, |
39 | | - false |
40 | | - ] |
41 | | -]; |
42 | | - |
43 | | -const surfaceCmd = prog |
44 | | - .command( |
45 | | - 'surface', |
46 | | - 'Examine the surface area of a module or a directory of modules' |
47 | | - ) |
48 | | - .alias('surf') |
49 | | - .argument( |
50 | | - 'target', |
51 | | - 'Target module or directory of modules to analyse usage.', |
52 | | - prog.STRING |
53 | | - ) |
54 | | - .action(surfaceAction); |
55 | | - |
56 | | -const depsCmd = prog |
57 | | - .command( |
58 | | - 'dependencies', |
59 | | - 'List all imports by a module or a directory of modules' |
60 | | - ) |
61 | | - .alias('dep') |
62 | | - .argument( |
63 | | - 'target', |
64 | | - 'Target module or directory of modules to see all imports for', |
65 | | - prog.STRING |
66 | | - ) |
67 | | - .action(dependenciesAction); |
68 | | - |
69 | | -const dependentCmd = prog |
70 | | - .command('dependent', 'Check if a module depends on another module') |
71 | | - .argument( |
72 | | - 'source', |
73 | | - 'Source module to check if it is dependent on target module', |
74 | | - prog.STRING |
75 | | - ) |
76 | | - .argument('target', 'target module', prog.STRING) |
77 | | - .action(dependentAction); |
78 | | - |
79 | | -const nayliasCmd = prog |
80 | | - .command('naylias', 'List all modules where an alias could be utilized') |
81 | | - .alias('nay') |
82 | | - .argument('alias', 'Alias to check for utilization', prog.STRING) |
83 | | - .action(nayliasAction); |
84 | | - |
85 | | -GLOBAL_OPTIONS.forEach(o => { |
86 | | - surfaceCmd.option(...o); |
87 | | - depsCmd.option(...o); |
88 | | - nayliasCmd.option(...o); |
89 | | - dependentCmd.option(...o); |
90 | | -}); |
| 2 | +const prog = require('./prog'); |
91 | 3 |
|
92 | 4 | prog.parse(process.argv); |
93 | | - |
94 | | -module.exports = prog; |
0 commit comments