dependency-cruiser 18.3.1 → 18.5.0

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.
Files changed (36) hide show
  1. package/README.md +1 -1
  2. package/bin/dependency-cruiser.mjs +2 -2
  3. package/package.json +4 -4
  4. package/src/analyze/summarize/get-stats.mjs +38 -3
  5. package/src/analyze/summarize/index.mjs +30 -6
  6. package/src/analyze/summarize/summarize-options.mjs +1 -0
  7. package/src/cache/cache.mjs +1 -1
  8. package/src/cache/options-compatible.mjs +2 -0
  9. package/src/cli/init-config/build-config.mjs +14 -0
  10. package/src/cli/init-config/config-template.mjs +5 -0
  11. package/src/cli/init-config/environment-helpers.mjs +5 -1
  12. package/src/cli/init-config/get-user-input.mjs +11 -0
  13. package/src/cli/init-config/index.mjs +1 -0
  14. package/src/cli/init-config/normalize-init-options.mjs +1 -1
  15. package/src/cli/init-config/types.d.mts +4 -0
  16. package/src/cli/init-config/write-run-scripts-to-manifest.mjs +2 -2
  17. package/src/extract/transpile/meta.mjs +2 -2
  18. package/src/extract/transpile/try-import-available.mjs +1 -1
  19. package/src/extract/tsc/extract-typescript-deps.mjs +57 -12
  20. package/src/extract/tsc/extract.mjs +2 -0
  21. package/src/main/options/defaults.mjs +1 -0
  22. package/src/main/options/normalize.mjs +4 -1
  23. package/src/meta.cjs +1 -1
  24. package/src/report/azure-devops.mjs +6 -2
  25. package/src/report/baseline.mjs +22 -7
  26. package/src/report/error-html/error-html-template.mjs +2 -0
  27. package/src/report/error-html/index.mjs +84 -8
  28. package/src/report/error.mjs +62 -13
  29. package/src/report/markdown.mjs +89 -19
  30. package/src/report/null.mjs +6 -3
  31. package/src/report/teamcity.mjs +4 -1
  32. package/src/schema/configuration.validate.mjs +1 -1
  33. package/src/schema/cruise-result.validate.mjs +1 -1
  34. package/types/cruise-result.d.mts +14 -0
  35. package/types/options.d.mts +21 -2
  36. package/types/reporter-options.d.mts +30 -5
@@ -342,6 +342,20 @@ export interface ISummary {
342
342
  * the number of informational level notices in the dependencies
343
343
  */
344
344
  info: number;
345
+ /**
346
+ * the number of violations in the baseline
347
+ */
348
+ baselineSize?: number;
349
+ /**
350
+ * the number of violations in the baseline that matched violations from the current cruise
351
+ */
352
+ baselineStale?: number;
353
+ /**
354
+ * for reporters that emit non-zero exit codes: the number of errors encountered OR, in case
355
+ * options.baseline.staleEntriesSeverity equals 'error' - the number of errors encountered +
356
+ * the number of stale entries in the baseline.
357
+ */
358
+ advisedExitCode: number;
345
359
  optionsUsed: IOptions;
346
360
  /**
347
361
  * rules used in the cruise
@@ -10,13 +10,17 @@ import type {
10
10
  } from "./filter-types.mjs";
11
11
  import type { IReporterOptions } from "./reporter-options.mjs";
12
12
  import type { IFlattenedRuleSet } from "./rule-set.mjs";
13
- import type { ModuleSystemType, OutputType } from "./shared-types.mjs";
13
+ import type {
14
+ ModuleSystemType,
15
+ OutputType,
16
+ SeverityType,
17
+ } from "./shared-types.mjs";
14
18
 
15
19
  export type ExternalModuleResolutionStrategyType = "node_modules" | "yarn-pnp";
16
20
  export type ProgressType =
17
21
  "cli-feedback" | "performance-log" | "ndjson" | "none";
18
22
  export type ParserType = "acorn" | "tsc" | "swc";
19
- export type BaselineModeType = "full" | "shrink-only";
23
+ export type BaselineModeType = "full" | "shrink-only" | "format";
20
24
 
21
25
  export interface ITsConfig {
22
26
  fileName?: string;
@@ -152,6 +156,11 @@ export interface ICruiseOptions {
152
156
  * import statements. Implies `"parser": "tsc"`. Defaults to false.'
153
157
  */
154
158
  detectJSDocImports?: boolean;
159
+ /**
160
+ * When true, dependency-cruiser will detect imports in ambient module and
161
+ * namespace declarations. Implies `"parser": "tsc"`. Defaults to false.
162
+ */
163
+ detectImportsInAmbientModules?: boolean;
155
164
  /**
156
165
  * When true, dependency-cruiser will detect calls to `process.getBuiltinModule`/
157
166
  * `globalThis.process.getBuiltinModule` as imports.
@@ -437,8 +446,18 @@ export interface ICruiseOptions {
437
446
  * 'full' - replaces all violations with the current set (the default behaviour)
438
447
  * 'shrink-only' - keeps existing violations, removes fixed violations, but
439
448
  * does not add new ones.
449
+ * 'format' - rewrites the baseline, but doesn't remove or add anything - only
450
+ * showing the stats.
440
451
  */
441
452
  mode?: BaselineModeType;
453
+ /**
454
+ * Severity to use when there's stale entries in the baseline. In reporters that can
455
+ * emit non-zero exit codes (like err, err-long and null), when the value of this attribute
456
+ * equals 'error' and there's stale entries in the baseline, they'll exit with a non-zero
457
+ * exit code.
458
+ * Defaults to 'warn'
459
+ */
460
+ staleEntriesSeverity?: SeverityType;
442
461
  };
443
462
  }
444
463
 
@@ -220,6 +220,11 @@ export interface IMarkdownReporterOptions {
220
220
  * Whether or not to collapse the list of violations in a <details> block. Defaults to true.
221
221
  */
222
222
  collapseDetails?: boolean;
223
+ /**
224
+ * The text to show in the <summary> section of the <details> block. E.g. 'click to see all violations'
225
+ * When left out shows a default value.
226
+ */
227
+ collapsedMessage?: string;
223
228
  /**
224
229
  * For external modules (typically those in node_modules) show the unresolved module name instead
225
230
  * of the resolved one in the error overview.
@@ -235,16 +240,36 @@ export interface IMarkdownReporterOptions {
235
240
  * Defaults to false.
236
241
  */
237
242
  showAliasedModulesUnresolved?: boolean;
238
- /**
239
- * The text to in the <summary> section of the <details> block. E.g. 'click to see all violations'
240
- * When left out shows a default value.
241
- */
242
- collapsedMessage?: string;
243
243
  /**
244
244
  * The text to show when no violations were found. E.g. 'No violations found'.
245
245
  * When left out shows a default value.
246
246
  */
247
247
  noViolationsMessage?: string;
248
+ /**
249
+ * Whether or not to show a detailed list of stale violations in the baseline (if any).
250
+ * Defaults to true
251
+ */
252
+ showStaleBaselineDetails?: boolean;
253
+ /**
254
+ * Text shown as the heading above stale baseline violations. Defaults to the
255
+ * standard stale-baseline heading.
256
+ */
257
+ staleBaselineHeader?: string;
258
+ /**
259
+ * Whether or not to wrap stale baseline violations in a collapsible
260
+ * <details> block. Defaults to true.
261
+ */
262
+ collapseStaleBaseline?: boolean;
263
+ /**
264
+ * Text shown in the <summary> element when stale baseline details are
265
+ * collapsible. Defaults to 'Stale violations in the baseline - click to expand'.
266
+ */
267
+ collapseStaleBaselineMessage?: string;
268
+ /**
269
+ * Introductory text shown before stale baseline violations. Defaults to an
270
+ * explanation of why they are stale and how to remove them.
271
+ */
272
+ staleBaselineIntro?: string;
248
273
  /**
249
274
  * Whether or not to show a footer (with version & run date) at the bottom of the report.
250
275
  * Defaults to true