dependency-cruiser 16.10.2 → 16.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,43 +1,69 @@
1
1
  #!/usr/bin/env node
2
- import { program } from "commander";
2
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
3
+ import { parseArgs } from "node:util";
3
4
  import assertNodeEnvironmentSuitable from "#cli/assert-node-environment-suitable.mjs";
4
5
  import cli from "#cli/index.mjs";
5
6
  import meta from "#meta.cjs";
6
7
 
7
- function formatError(pError) {
8
- process.stderr.write(pError.message);
9
- process.exitCode = 1;
8
+ function showHelp() {
9
+ process.stdout
10
+ .write(`Usage: depcruise-baseline [options] <files-or-directories...>
11
+
12
+ Writes all known violations of rules in a .dependency-cruiser.js to a file.
13
+ Alias for depcruise -c -T baseline -f .dependency-cruiser-known-violations.json [files-or-directories]
14
+ Details: https://github.com/sverweij/dependency-cruiser
15
+
16
+ Options:
17
+ -c, --config [file] read rules and options from [file] (default: true)
18
+ -f, --output-to [file] file to write output to; - for stdout (default: ".dependency-cruiser-known-violations.json")
19
+ -V, --version display version number
20
+ -h, --help display help for command
21
+ `);
10
22
  }
11
23
 
12
24
  try {
13
25
  assertNodeEnvironmentSuitable();
14
26
 
15
- program
16
- .description(
17
- "Writes all known violations of rules in a .dependency-cruiser.js to a file.\n" +
18
- "Alias for depcruise -c -T baseline -f .dependency-cruiser-known-violations.json [files-or-directories]\n" +
19
- "Details: https://github.com/sverweij/dependency-cruiser",
20
- )
21
- .option("-c, --config [file]", "read rules and options from [file]", true)
22
- .option(
23
- "-f, --output-to [file]",
24
- "file to write output to; - for stdout",
25
- ".dependency-cruiser-known-violations.json",
26
- )
27
- .version(meta.version)
28
- .argument("<files-or-directories...>")
29
- .parse(process.argv);
27
+ const { values: options, positionals } = parseArgs({
28
+ options: {
29
+ config: {
30
+ type: "string",
31
+ short: "c",
32
+ default: "",
33
+ },
34
+ "output-to": {
35
+ type: "string",
36
+ short: "f",
37
+ default: ".dependency-cruiser-known-violations.json",
38
+ },
39
+ version: {
40
+ type: "boolean",
41
+ short: "V",
42
+ },
43
+ help: {
44
+ type: "boolean",
45
+ short: "h",
46
+ },
47
+ },
48
+ allowPositionals: true,
49
+ });
30
50
 
31
- if (program.args[0]) {
32
- process.exitCode = await cli(program.args, {
33
- ...program.opts(),
51
+ if (options.version) {
52
+ process.stdout.write(`${meta.version}\n`);
53
+ } else if (options.help || positionals.length === 0) {
54
+ showHelp();
55
+ } else {
56
+ if (options.config === "") {
57
+ options.config = true;
58
+ }
59
+ process.exitCode = await cli(positionals, {
60
+ config: options.config,
61
+ outputTo: options["output-to"],
34
62
  cache: false,
35
63
  outputType: "baseline",
36
64
  });
37
- } else {
38
- program.help();
39
65
  }
40
66
  } catch (pError) {
41
- formatError(pError);
67
+ process.stderr.write(pError.message);
42
68
  process.exitCode = 1;
43
69
  }
@@ -1,82 +1,126 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { program } from "commander";
2
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
3
+ import { parseArgs } from "node:util";
4
4
  import assertNodeEnvironmentSuitable from "#cli/assert-node-environment-suitable.mjs";
5
5
  import format from "#cli/format.mjs";
6
6
  import meta from "#meta.cjs";
7
7
 
8
- function formatError(pError) {
9
- process.stderr.write(pError.message);
10
- process.exitCode = 1;
8
+ function showHelp() {
9
+ process.stdout.write(`Usage: depcruise-fmt [options] <dependency-cruiser-json>
10
+
11
+ Format dependency-cruiser output json.
12
+ Details: https://github.com/sverweij/dependency-cruiser
13
+
14
+ Options:
15
+ -f, --output-to <file> file to write output to; - for stdout (default: "-")
16
+ -T, --output-type <type> output type; e.g. err, err-html, dot, ddot, archi, flat,
17
+ d2, mermaid or json (default: "err")
18
+ -I, --include-only <regex> only include modules matching the regex
19
+ -F, --focus <regex> only include modules matching the regex + their direct neighbours
20
+ --focus-depth <number> the depth to focus on - only applied when --focus is passed too.
21
+ 1= direct neighbors, 2=neighbours of neighbours etc. (default: 1)
22
+ -R, --reaches <regex> only include modules matching the regex + all modules that can reach it
23
+ -H, --highlight <regex> mark modules matching the regex as 'highlighted'
24
+ -x, --exclude <regex> exclude all modules matching the regex
25
+ -S, --collapse <regex> collapse to a folder depth by passing a single digit (e.g. 2). Or
26
+ pass a regex to collapse to a pattern E.g. ^packages/[^/]+/ would
27
+ collapse to modules/ folders directly under your packages folder.
28
+ -P, --prefix <prefix> prefix to use for links in the dot and err-html reporters
29
+ -e, --exit-code exit with a non-zero exit code when the input json contains error
30
+ level dependency violations. Works for err, err-long and teamcity
31
+ output types
32
+ -V, --version display version number
33
+ -h, --help display help for command
34
+ `);
11
35
  }
12
36
 
13
37
  try {
14
38
  assertNodeEnvironmentSuitable();
15
39
 
16
- program
17
- .description(
18
- "Format dependency-cruiser output json.\nDetails: https://github.com/sverweij/dependency-cruiser",
19
- )
20
- .option(
21
- "-f, --output-to <file>",
22
- "file to write output to; - for stdout",
23
- "-",
24
- )
25
- .option(
26
- "-T, --output-type <type>",
27
- "output type; e.g. err, err-html, dot, ddot, archi, flat, d2, mermaid or json",
28
- "err",
29
- )
30
- .option(
31
- "-I, --include-only <regex>",
32
- "only include modules matching the regex",
33
- )
34
- .option(
35
- "-F, --focus <regex>",
36
- "only include modules matching the regex + their direct neighbours",
37
- )
38
- .option(
39
- "--focus-depth <number>",
40
- "the depth to focus on - only applied when --focus is passed too. " +
41
- "1= direct neighbors, 2=neighbours of neighbours etc.",
42
- 1,
43
- )
44
- .option(
45
- "-R, --reaches <regex>",
46
- "only include modules matching the regex + all modules that can reach it",
47
- )
48
- .option(
49
- "-H, --highlight <regex>",
50
- "mark modules matching the regex as 'highlighted'",
51
- )
52
- .option("-x, --exclude <regex>", "exclude all modules matching the regex")
53
- .option(
54
- "-S, --collapse <regex>",
55
- "collapse to a folder depth by passing a single digit (e.g. 2). Or pass a " +
56
- "regex to collapse to a pattern E.g. ^packages/[^/]+/ would collapse to " +
57
- "modules/ folders directly under your packages folder. ",
58
- )
59
- .option(
60
- "-P, --prefix <prefix>",
61
- "prefix to use for links in the dot and err-html reporters",
62
- )
63
- .option(
64
- "-e, --exit-code",
65
- "exit with a non-zero exit code when the input json contains error level " +
66
- "dependency violations. Works for err, err-long and teamcity output types",
67
- )
68
- .version(meta.version)
69
- .argument("<dependency-cruiser-json>")
70
- .parse(process.argv);
40
+ const { values: options, positionals } = parseArgs({
41
+ options: {
42
+ "output-to": {
43
+ type: "string",
44
+ short: "f",
45
+ default: "-",
46
+ },
47
+ "output-type": {
48
+ type: "string",
49
+ short: "T",
50
+ default: "err",
51
+ },
52
+ "include-only": {
53
+ type: "string",
54
+ short: "I",
55
+ },
56
+ focus: {
57
+ type: "string",
58
+ short: "F",
59
+ },
60
+ "focus-depth": {
61
+ type: "string",
62
+ default: "1",
63
+ },
64
+ reaches: {
65
+ type: "string",
66
+ short: "R",
67
+ },
68
+ highlight: {
69
+ type: "string",
70
+ short: "H",
71
+ },
72
+ exclude: {
73
+ type: "string",
74
+ short: "x",
75
+ },
76
+ collapse: {
77
+ type: "string",
78
+ short: "S",
79
+ },
80
+ prefix: {
81
+ type: "string",
82
+ short: "P",
83
+ },
84
+ "exit-code": {
85
+ type: "boolean",
86
+ short: "e",
87
+ },
88
+ version: {
89
+ type: "boolean",
90
+ short: "V",
91
+ },
92
+ help: {
93
+ type: "boolean",
94
+ short: "h",
95
+ },
96
+ },
97
+ allowPositionals: true,
98
+ });
71
99
 
72
- if (program.args[0]) {
73
- const lExitCode = await format(program.args[0], program.opts());
74
- if (program.opts().exitCode) {
100
+ if (options.version) {
101
+ process.stdout.write(`${meta.version}\n`);
102
+ } else if (options.help || positionals.length === 0) {
103
+ showHelp();
104
+ } else {
105
+ const lFormatOptions = {
106
+ ...options,
107
+ outputTo: options["output-to"],
108
+ outputType: options["output-type"],
109
+ includeOnly: options["include-only"],
110
+ focusDepth: options["focus-depth"],
111
+ exitCode: options["exit-code"],
112
+ };
113
+ delete lFormatOptions["output-to"];
114
+ delete lFormatOptions["output-type"];
115
+ delete lFormatOptions["include-only"];
116
+ delete lFormatOptions["focus-depth"];
117
+ delete lFormatOptions["exit-code"];
118
+ const lExitCode = await format(positionals[0], lFormatOptions);
119
+ if (lFormatOptions.exitCode) {
75
120
  process.exitCode = lExitCode;
76
121
  }
77
- } else {
78
- program.help();
79
122
  }
80
123
  } catch (pError) {
81
- formatError(pError);
124
+ process.stderr.write(pError.message);
125
+ process.exitCode = 1;
82
126
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "16.10.2",
3
+ "version": "16.10.3",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -140,15 +140,15 @@
140
140
  "README.md"
141
141
  ],
142
142
  "dependencies": {
143
- "acorn": "^8.14.1",
143
+ "acorn": "^8.15.0",
144
144
  "acorn-jsx": "^5.3.2",
145
145
  "acorn-jsx-walk": "^2.0.0",
146
- "acorn-loose": "^8.5.0",
146
+ "acorn-loose": "^8.5.1",
147
147
  "acorn-walk": "^8.3.4",
148
148
  "ajv": "^8.17.1",
149
149
  "commander": "^13.1.0",
150
150
  "enhanced-resolve": "^5.18.1",
151
- "ignore": "^7.0.4",
151
+ "ignore": "^7.0.5",
152
152
  "interpret": "^3.1.1",
153
153
  "is-installed-globally": "^1.0.0",
154
154
  "json5": "^2.2.3",
@@ -158,7 +158,7 @@
158
158
  "prompts": "^2.4.2",
159
159
  "rechoir": "^0.8.0",
160
160
  "safe-regex": "^2.1.1",
161
- "semver": "^7.7.1",
161
+ "semver": "^7.7.2",
162
162
  "teamcity-service-messages": "^0.1.14",
163
163
  "tsconfig-paths-webpack-plugin": "^4.2.0",
164
164
  "watskeburt": "^4.2.3"
package/src/meta.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "16.10.2",
4
+ version: "16.10.3",
5
5
  engines: {
6
6
  node: "^18.17||>=20",
7
7
  },