1 | #!/usr/bin/env node
|
2 | const validateNodeEnvironment = require("../src/cli/validate-node-environment");
|
3 |
|
4 | try {
|
5 | validateNodeEnvironment();
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const program = require("commander");
|
12 | const $package = require("../package.json");
|
13 | const cli = require("../src/cli");
|
14 |
|
15 | program
|
16 | .version($package.version)
|
17 | .description(
|
18 | "Validate and visualize dependencies.\nDetails: https://github.com/sverweij/dependency-cruiser"
|
19 | )
|
20 | .option(
|
21 | "-i, --info",
|
22 | `shows what languages and extensions
|
23 | dependency-cruiser supports`
|
24 | )
|
25 | .option(
|
26 | "-c, --config [file]",
|
27 | `read rules and options from [file]
|
28 | (default: .dependency-cruiser.json)`
|
29 | )
|
30 | .option("-v, --validate [file]", `alias for --config`)
|
31 | .option(
|
32 | "-f, --output-to <file>",
|
33 | `file to write output to; - for stdout
|
34 | `,
|
35 | "-"
|
36 | )
|
37 | .option(
|
38 | "-X, --do-not-follow <regex>",
|
39 | `include modules matching the regex,
|
40 | but don't follow them any further`
|
41 | )
|
42 | .option("-x, --exclude <regex>", "exclude all modules matching the regex")
|
43 | .option("--include-only <regex>", "only include modules matching the regex")
|
44 | .option(
|
45 | "--focus <regex>",
|
46 | `only output modules matching the regex,
|
47 | + their direct neighbours`
|
48 | )
|
49 | .option(
|
50 | "-d, --max-depth <n>",
|
51 | `the maximum depth to cruise; 0 <= n <= 99
|
52 | (default: 0, which means 'infinite depth')`
|
53 | )
|
54 | .option(
|
55 | "-M, --module-systems <items>",
|
56 | `list of module systems (default: amd,cjs,es6,tsd)`
|
57 | )
|
58 | .option(
|
59 | "-T, --output-type <type>",
|
60 | `output type - err|err-long|err-html|dot|ddot|archi|json
|
61 | (default: err)`
|
62 | )
|
63 | .option(
|
64 | "-P, --prefix <prefix>",
|
65 | `prefix to use for links in the dot, err and
|
66 | err-html reporters`
|
67 | )
|
68 | .option("--preserve-symlinks", `leave symlinks unchanged (off by default)`)
|
69 | .option(
|
70 | "--ts-pre-compilation-deps",
|
71 | `detect dependencies that only exist before
|
72 | typescript-to-javascript compilation
|
73 | (off by default)`
|
74 | )
|
75 | .option(
|
76 | "--ts-config [file]",
|
77 | `use a typescript configuration ('project')
|
78 | (default: tsconfig.json)`
|
79 | )
|
80 | .option(
|
81 | "--webpack-config [file]",
|
82 | `use a webpack configuration
|
83 | (default: webpack.config.js)`
|
84 | )
|
85 | .option(
|
86 | "--init [oneshot]",
|
87 | `write a .dependency-cruiser config with basic
|
88 | validations to the current folder.`
|
89 | )
|
90 | .arguments("<files-or-directories>")
|
91 | .parse(process.argv);
|
92 |
|
93 | if (Boolean(program.args[0]) || program.info || program.init) {
|
94 | process.exitCode = cli(program.args, program);
|
95 | } else {
|
96 | program.help();
|
97 | }
|
98 | } catch (pError) {
|
99 | process.stderr.write(pError.message);
|
100 | process.exitCode = 1;
|
101 | }
|