@leancodepl/folder-structure-cruiser 10.4.0 → 10.5.1

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.5.1](https://github.com/leancodepl/js_corelibrary/compare/v10.4.0...v10.5.1) (2026-07-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - do not return exit code 1 for validateSharedComponent
11
+ ([ec5240e](https://github.com/leancodepl/js_corelibrary/commit/ec5240ee4733dbe32550e188c78b451894c873ee))
12
+ - strip opaque segments in checkSharedComponents
13
+ ([73b9fc7](https://github.com/leancodepl/js_corelibrary/commit/73b9fc71e875f9e7bbb9c58ee88387e424f7f53a))
14
+
15
+ # Change Log
16
+
17
+ All notable changes to this project will be documented in this file. See
18
+ [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
19
+
6
20
  # [10.4.0](https://github.com/leancodepl/js_corelibrary/compare/v10.3.1...v10.4.0) (2026-06-23)
7
21
 
8
22
  ### Features
package/dist/bin.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";const t=require("commander"),r=require("./validateSharedComponent-BHinLxNm.cjs");t.program.name("folder-structure-cruiser").description("CLI tool for validating folder structure rules");function s(o){o>0&&(process.exitCode=1)}function f(o){r.logger.error(o instanceof Error?o:new Error(String(o))),process.exitCode=1}t.program.command("validate-shared-components").description("Validate if shared components are located at the first shared level").option("-d, --directory <dir>","Directory to analyze",".").option("-c, --config <path_to_config>","Path to config file").option("-t, --tsConfig <path_to_ts_config>","Path to ts config file").option("-w, --webpackConfig <path_to_webpack_config>","Path to webpack config file").action(async o=>{const e=o.directory?[o.directory]:[".*"],i=o.config??"",a=o.tsConfig,n=o.webpackConfig,c=await r.validateSharedComponent({directories:e,configPath:i,tsConfigPath:a,webpackConfigPath:n});s(c)});t.program.command("validate-cross-feature-imports").description("Validate if cross-feature nested imports are allowed").option("-d, --directory <dir>","Directory to analyze",".").option("-c, --config <path_to_config>","Path to config file").option("-t, --tsConfig <path_to_ts_config>","Path to ts config file").option("-w, --webpackConfig <path_to_webpack_config>","Path to webpack config file").action(async o=>{const e=o.directory?[o.directory]:[".*"],i=o.config??"",a=o.tsConfig,n=o.webpackConfig,c=await r.validateCrossFeatureImports({directories:e,configPath:i,tsConfigPath:a,webpackConfigPath:n});s(c)});t.program.parseAsync().catch(f);
2
+ "use strict";const t=require("commander"),r=require("./validateSharedComponent-DaLncijO.cjs");t.program.name("folder-structure-cruiser").description("CLI tool for validating folder structure rules");function s(o){o>0&&(process.exitCode=1)}function f(o){r.logger.error(o instanceof Error?o:new Error(String(o))),process.exitCode=1}t.program.command("validate-shared-components").description("Validate if shared components are located at the first shared level").option("-d, --directory <dir>","Directory to analyze",".").option("-c, --config <path_to_config>","Path to config file").option("-t, --tsConfig <path_to_ts_config>","Path to ts config file").option("-w, --webpackConfig <path_to_webpack_config>","Path to webpack config file").action(async o=>{const e=o.directory?[o.directory]:[".*"],i=o.config??"",a=o.tsConfig,n=o.webpackConfig,c=await r.validateSharedComponent({directories:e,configPath:i,tsConfigPath:a,webpackConfigPath:n});s(c)});t.program.command("validate-cross-feature-imports").description("Validate if cross-feature nested imports are allowed").option("-d, --directory <dir>","Directory to analyze",".").option("-c, --config <path_to_config>","Path to config file").option("-t, --tsConfig <path_to_ts_config>","Path to ts config file").option("-w, --webpackConfig <path_to_webpack_config>","Path to webpack config file").action(async o=>{const e=o.directory?[o.directory]:[".*"],i=o.config??"",a=o.tsConfig,n=o.webpackConfig,c=await r.validateCrossFeatureImports({directories:e,configPath:i,tsConfigPath:a,webpackConfigPath:n});s(c)});t.program.parseAsync().catch(f);
package/dist/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { program as t } from "commander";
3
- import { a as s, v as f, l as d } from "./validateSharedComponent-D24GPyRZ.js";
3
+ import { a as s, v as f, l as d } from "./validateSharedComponent-_ujfixtH.js";
4
4
  t.name("folder-structure-cruiser").description("CLI tool for validating folder structure rules");
5
5
  function r(o) {
6
6
  o > 0 && (process.exitCode = 1);
@@ -17,7 +17,7 @@ import { CruiseParams } from '../lib/getCruiseResult.js';
17
17
  * @param cruiseParams.tsConfigPath - Optional path to TypeScript configuration file for enhanced type resolution
18
18
  * @param cruiseParams.webpackConfigPath - Optional path to webpack configuration file for webpack alias resolution
19
19
  *
20
- * @returns Promise<number> - Number of detected violations
20
+ * @returns Promise<number> - Number of error-level violations
21
21
  *
22
22
  * @throws {Error} - Throws an error if the dependency analysis fails or configuration is invalid
23
23
  *
@@ -16,7 +16,8 @@ import { CruiseParams } from '../lib/getCruiseResult.js';
16
16
  * @param cruiseParams.tsConfigPath - Optional path to TypeScript configuration file for enhanced type resolution
17
17
  * @param cruiseParams.webpackConfigPath - Optional path to webpack configuration file for webpack alias resolution
18
18
  *
19
- * @returns Promise<number> - Number of detected violations
19
+ * @returns Promise<number> - Number of error-level violations. This rule is purely informational,
20
+ * so it always resolves to 0 and never fails the command, even when recommendations are reported.
20
21
  *
21
22
  * @throws {Error} - Throws an error if the dependency analysis fails or configuration is invalid
22
23
  *
@@ -1 +1 @@
1
- {"version":3,"file":"validateSharedComponent.d.ts","sourceRoot":"","sources":["../../src/commands/validateSharedComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAmB,MAAM,2BAA2B,CAAA;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBzF"}
1
+ {"version":3,"file":"validateSharedComponent.d.ts","sourceRoot":"","sources":["../../src/commands/validateSharedComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAmB,MAAM,2BAA2B,CAAA;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBzF"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./validateSharedComponent-BHinLxNm.cjs");exports.validateCrossFeatureImports=e.validateCrossFeatureImports;exports.validateSharedComponent=e.validateSharedComponent;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./validateSharedComponent-DaLncijO.cjs");exports.validateCrossFeatureImports=e.validateCrossFeatureImports;exports.validateSharedComponent=e.validateSharedComponent;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { v as o, a as r } from "./validateSharedComponent-D24GPyRZ.js";
1
+ import { v as o, a as r } from "./validateSharedComponent-_ujfixtH.js";
2
2
  export {
3
3
  o as validateCrossFeatureImports,
4
4
  r as validateSharedComponent
@@ -1 +1 @@
1
- {"version":3,"file":"checkCrossFeatureImports.d.ts","sourceRoot":"","sources":["../../src/lib/checkCrossFeatureImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CA0C7E"}
1
+ {"version":3,"file":"checkCrossFeatureImports.d.ts","sourceRoot":"","sources":["../../src/lib/checkCrossFeatureImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CA0C7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkSharedComponents.d.ts","sourceRoot":"","sources":["../../src/lib/checkSharedComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE7C,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAmBhE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CA8C1E"}
1
+ {"version":3,"file":"checkSharedComponents.d.ts","sourceRoot":"","sources":["../../src/lib/checkSharedComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C,KAAK,WAAW,GAAG;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAmBhE,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CA8C1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"findCommonPathsPrefix.d.ts","sourceRoot":"","sources":["../../src/lib/findCommonPathsPrefix.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAiBjE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAErE"}
1
+ {"version":3,"file":"findCommonPathsPrefix.d.ts","sourceRoot":"","sources":["../../src/lib/findCommonPathsPrefix.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAmBjE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAErE"}
@@ -1,9 +1,9 @@
1
1
  export declare const logger: import('packages/logger/dist/lib/logger').Logger<{}, {
2
- error: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
3
- warn: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
4
- success: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
5
- info: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
6
- verbose: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
7
- debug: import('packages/logger/dist/lib/logger').MethodHandler<unknown>;
2
+ error: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
3
+ warn: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
4
+ success: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
5
+ info: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
6
+ verbose: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
7
+ debug: import('packages/logger/dist/lib/logger').MethodHandler<import('packages/logger/dist/lib/logger').SupportedOutput>;
8
8
  }>;
9
9
  //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A directory whose name ends with a single underscore (e.g. `features_`) is
3
+ * opaque: a transparent container that doesn't count toward the folder
4
+ * structure depth.
5
+ *
6
+ * The single-trailing-underscore rule deliberately spares names like
7
+ * `__tests__`, where the trailing underscore is part of the convention rather
8
+ * than an opacity marker.
9
+ */
10
+ export declare function isOpaqueSegment(segment: string): boolean;
11
+ export declare function stripOpaqueSegments(segments: string[]): string[];
12
+ //# sourceMappingURL=opaqueSegments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opaqueSegments.d.ts","sourceRoot":"","sources":["../../src/lib/opaqueSegments.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAEhE"}
@@ -0,0 +1,3 @@
1
+ "use strict";const x=require("chalk"),P=require("dependency-cruiser"),y=require("dependency-cruiser/config-utl/extract-depcruise-options"),$=require("dependency-cruiser/config-utl/extract-ts-config"),q=require("dependency-cruiser/config-utl/extract-webpack-resolve-config"),F=require("@leancodepl/logger/cli");function g(e){const[t,...s]=e;if(!t)return[];if(s.length===0)return t;const o=[],n=Math.min(...e.map(r=>r.length));for(let r=0;r<n;r++){const i=t[r];if(i===void 0)break;if(e.every(u=>u[r]===i))o.push(i);else break}return o}function p(e){return g(e).length}function M(e){return/[^_]_$/.test(e)}function d(e){return e.filter(t=>!M(t))}function j(e){const t=typeof e.output=="object"?e.output:void 0,s=t?.modules??[],o=[];for(const n of s){if(n.coreModule)continue;const r=n.dependencies||[],i=d(n.source.split("/"));r.forEach(u=>{if(b(u.dependencyTypes))return;const l=d(u.resolved.split("/")),c=p([i,l]);(!c||c<i.length&&l.length>c+k)&&o.push({source:n.source,target:u.resolved,rule:"cross-feature-nested-imports",severity:"error"})})}return{messages:o,totalCruised:t?.summary.totalCruised??0}}const k=2;function b(e){return e?.some(t=>t==="core"||t==="unknown"||t.startsWith("npm"))??!1}const{bold:m}=x;function h(e){return e.map(t=>`${t.rule}: ${m(t.source)} → ${m(t.target)}`)}async function C({directories:e=[".*"],configPath:t,tsConfigPath:s,webpackConfigPath:o}){const n=await y(t),r=o?await q(o):void 0,i=s?$(s):void 0;return await P.cruise(e,{...n},r,{tsConfig:i})}const a=F.createCliLogger();async function w(e){const t=await C(e),{messages:s,totalCruised:o}=j(t);if(s.length===0&&a.success("✅ No issues found!"),s.length>0){const n=h(s);a.error(n.join(`
2
+ `)),a.error(`Found ${s.length} violation(s). ${o} modules cruised.`)}return s.length}function L(e,t,s){const o=e.at(-1)??"";if(!/index\.(tsx?|jsx?|ts|js)$/.test(o))return!1;const n=e.at(-3)??"",r=t.at(-1);return n===r&&s===e.length-2}function R(e){const t=typeof e.output=="object"?e.output:void 0,s=t?.modules??[],o=[];for(const n of s){if(n.coreModule)continue;const r=n.dependents||[];if(r.length<=1)continue;const i=d(n.source.split("/")),u=i.length;if(u<=2)continue;const l=r.map(v=>d(v.split("/"))),c=g(l),f=p([i,c]);L(i,c,f)||f<u-1&&o.push({source:n.source,target:c.join("/"),rule:"not-shared-level",severity:"info"})}return{messages:o,totalCruised:t?.summary.totalCruised??0}}async function S(e){const t=await C(e),{messages:s,totalCruised:o}=R(t);if(s.length===0&&a.success("✅ No issues found!"),s.length>0){const n=h(s);a.info(n.join(`
3
+ `)),a.info(`Found ${s.length} violation(s). ${o} modules cruised.`)}return 0}exports.logger=a;exports.validateCrossFeatureImports=w;exports.validateSharedComponent=S;
@@ -5,32 +5,40 @@ import $ from "dependency-cruiser/config-utl/extract-ts-config";
5
5
  import M from "dependency-cruiser/config-utl/extract-webpack-resolve-config";
6
6
  import { createCliLogger as j } from "@leancodepl/logger/cli";
7
7
  function p(e) {
8
- if (e.length === 0) return [];
9
- if (e.length === 1) return e[0];
10
- const t = [], o = Math.min(...e.map((n) => n.length));
11
- for (let n = 0; n < o; n++) {
12
- const s = e[0][n];
13
- if (e.every((r) => r[n] === s))
14
- t.push(s);
8
+ const [t, ...o] = e;
9
+ if (!t) return [];
10
+ if (o.length === 0) return t;
11
+ const n = [], s = Math.min(...e.map((r) => r.length));
12
+ for (let r = 0; r < s; r++) {
13
+ const i = t[r];
14
+ if (i === void 0) break;
15
+ if (e.every((u) => u[r] === i))
16
+ n.push(i);
15
17
  else
16
18
  break;
17
19
  }
18
- return t;
20
+ return n;
19
21
  }
20
22
  function g(e) {
21
23
  return p(e).length;
22
24
  }
25
+ function k(e) {
26
+ return /[^_]_$/.test(e);
27
+ }
28
+ function l(e) {
29
+ return e.filter((t) => !k(t));
30
+ }
23
31
  function F(e) {
24
32
  const t = typeof e.output == "object" ? e.output : void 0, o = t?.modules ?? [], n = [];
25
33
  for (const s of o) {
26
34
  if (s.coreModule)
27
35
  continue;
28
- const r = s.dependencies || [], i = m(s.source.split("/"));
36
+ const r = s.dependencies || [], i = l(s.source.split("/"));
29
37
  r.forEach((u) => {
30
38
  if (w(u.dependencyTypes))
31
39
  return;
32
- const l = m(u.resolved.split("/")), c = g([i, l]);
33
- (!c || c < i.length && l.length > c + k) && n.push({
40
+ const f = l(u.resolved.split("/")), c = g([i, f]);
41
+ (!c || c < i.length && f.length > c + b) && n.push({
34
42
  source: s.source,
35
43
  target: u.resolved,
36
44
  rule: "cross-feature-nested-imports",
@@ -43,21 +51,15 @@ function F(e) {
43
51
  totalCruised: t?.summary.totalCruised ?? 0
44
52
  };
45
53
  }
46
- const k = 2;
54
+ const b = 2;
47
55
  function w(e) {
48
56
  return e?.some((t) => t === "core" || t === "unknown" || t.startsWith("npm")) ?? !1;
49
57
  }
50
- function L(e) {
51
- return /[^_]_$/.test(e);
52
- }
53
- function m(e) {
54
- return e.filter((t) => !L(t));
55
- }
56
58
  const { bold: d } = C;
57
59
  function h(e) {
58
60
  return e.map((t) => `${t.rule}: ${d(t.source)} → ${d(t.target)}`);
59
61
  }
60
- async function x({
62
+ async function v({
61
63
  directories: e = [".*"],
62
64
  configPath: t,
63
65
  tsConfigPath: o,
@@ -70,7 +72,7 @@ async function x({
70
72
  }
71
73
  const a = j();
72
74
  async function E(e) {
73
- const t = await x(e), { messages: o, totalCruised: n } = F(t);
75
+ const t = await v(e), { messages: o, totalCruised: n } = F(t);
74
76
  if (o.length === 0 && a.success("✅ No issues found!"), o.length > 0) {
75
77
  const s = h(o);
76
78
  a.error(s.join(`
@@ -78,14 +80,14 @@ async function E(e) {
78
80
  }
79
81
  return o.length;
80
82
  }
81
- function R(e, t, o) {
83
+ function L(e, t, o) {
82
84
  const n = e.at(-1) ?? "";
83
85
  if (!/index\.(tsx?|jsx?|ts|js)$/.test(n))
84
86
  return !1;
85
87
  const s = e.at(-3) ?? "", r = t.at(-1);
86
88
  return s === r && o === e.length - 2;
87
89
  }
88
- function b(e) {
90
+ function R(e) {
89
91
  const t = typeof e.output == "object" ? e.output : void 0, o = t?.modules ?? [], n = [];
90
92
  for (const s of o) {
91
93
  if (s.coreModule)
@@ -93,11 +95,11 @@ function b(e) {
93
95
  const r = s.dependents || [];
94
96
  if (r.length <= 1)
95
97
  continue;
96
- const i = s.source.split("/"), u = i.length;
98
+ const i = l(s.source.split("/")), u = i.length;
97
99
  if (u <= 2)
98
100
  continue;
99
- const l = r.map((v) => v.split("/")), c = p(l), f = g([i, c]);
100
- R(i, c, f) || f < u - 1 && n.push({
101
+ const f = r.map((x) => l(x.split("/"))), c = p(f), m = g([i, c]);
102
+ L(i, c, m) || m < u - 1 && n.push({
101
103
  source: s.source,
102
104
  target: c.join("/"),
103
105
  rule: "not-shared-level",
@@ -110,13 +112,13 @@ function b(e) {
110
112
  };
111
113
  }
112
114
  async function T(e) {
113
- const t = await x(e), { messages: o, totalCruised: n } = b(t);
115
+ const t = await v(e), { messages: o, totalCruised: n } = R(t);
114
116
  if (o.length === 0 && a.success("✅ No issues found!"), o.length > 0) {
115
117
  const s = h(o);
116
118
  a.info(s.join(`
117
119
  `)), a.info(`Found ${o.length} violation(s). ${n} modules cruised.`);
118
120
  }
119
- return o.length;
121
+ return 0;
120
122
  }
121
123
  export {
122
124
  T as a,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/folder-structure-cruiser",
3
- "version": "10.4.0",
3
+ "version": "10.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,15 +19,16 @@
19
19
  "folder-structure-cruiser": "./dist/bin.js"
20
20
  },
21
21
  "dependencies": {
22
- "@leancodepl/logger": "10.4.0",
22
+ "@leancodepl/logger": "10.5.1",
23
23
  "chalk": ">=5.0.0",
24
- "commander": "^14.0.0"
24
+ "commander": "^15.0.0"
25
25
  },
26
26
  "devDependencies": {
27
+ "dependency-cruiser": "^18.0.0",
27
28
  "vitest": "*"
28
29
  },
29
30
  "peerDependencies": {
30
- "dependency-cruiser": "^17.0.0"
31
+ "dependency-cruiser": "^17.0.0 || ^18.0.0"
31
32
  },
32
33
  "publishConfig": {
33
34
  "access": "public",
@@ -1,3 +0,0 @@
1
- "use strict";const x=require("chalk"),P=require("dependency-cruiser"),y=require("dependency-cruiser/config-utl/extract-depcruise-options"),$=require("dependency-cruiser/config-utl/extract-ts-config"),q=require("dependency-cruiser/config-utl/extract-webpack-resolve-config"),F=require("@leancodepl/logger/cli");function g(e){if(e.length===0)return[];if(e.length===1)return e[0];const t=[],n=Math.min(...e.map(s=>s.length));for(let s=0;s<n;s++){const o=e[0][s];if(e.every(r=>r[s]===o))t.push(o);else break}return t}function p(e){return g(e).length}function M(e){const t=typeof e.output=="object"?e.output:void 0,n=t?.modules??[],s=[];for(const o of n){if(o.coreModule)continue;const r=o.dependencies||[],i=f(o.source.split("/"));r.forEach(u=>{if(k(u.dependencyTypes))return;const l=f(u.resolved.split("/")),c=p([i,l]);(!c||c<i.length&&l.length>c+j)&&s.push({source:o.source,target:u.resolved,rule:"cross-feature-nested-imports",severity:"error"})})}return{messages:s,totalCruised:t?.summary.totalCruised??0}}const j=2;function k(e){return e?.some(t=>t==="core"||t==="unknown"||t.startsWith("npm"))??!1}function w(e){return/[^_]_$/.test(e)}function f(e){return e.filter(t=>!w(t))}const{bold:m}=x;function h(e){return e.map(t=>`${t.rule}: ${m(t.source)} → ${m(t.target)}`)}async function C({directories:e=[".*"],configPath:t,tsConfigPath:n,webpackConfigPath:s}){const o=await y(t),r=s?await q(s):void 0,i=n?$(n):void 0;return await P.cruise(e,{...o},r,{tsConfig:i})}const a=F.createCliLogger();async function L(e){const t=await C(e),{messages:n,totalCruised:s}=M(t);if(n.length===0&&a.success("✅ No issues found!"),n.length>0){const o=h(n);a.error(o.join(`
2
- `)),a.error(`Found ${n.length} violation(s). ${s} modules cruised.`)}return n.length}function R(e,t,n){const s=e.at(-1)??"";if(!/index\.(tsx?|jsx?|ts|js)$/.test(s))return!1;const o=e.at(-3)??"",r=t.at(-1);return o===r&&n===e.length-2}function S(e){const t=typeof e.output=="object"?e.output:void 0,n=t?.modules??[],s=[];for(const o of n){if(o.coreModule)continue;const r=o.dependents||[];if(r.length<=1)continue;const i=o.source.split("/"),u=i.length;if(u<=2)continue;const l=r.map(v=>v.split("/")),c=g(l),d=p([i,c]);R(i,c,d)||d<u-1&&s.push({source:o.source,target:c.join("/"),rule:"not-shared-level",severity:"info"})}return{messages:s,totalCruised:t?.summary.totalCruised??0}}async function b(e){const t=await C(e),{messages:n,totalCruised:s}=S(t);if(n.length===0&&a.success("✅ No issues found!"),n.length>0){const o=h(n);a.info(o.join(`
3
- `)),a.info(`Found ${n.length} violation(s). ${s} modules cruised.`)}return n.length}exports.logger=a;exports.validateCrossFeatureImports=L;exports.validateSharedComponent=b;