@rsdk/depdoc.cli 6.0.0-next.42 → 6.0.0-next.44

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 (46) hide show
  1. package/DEPDOC_MODEL.md +22 -11
  2. package/__tests__/compatibility.test.ts +74 -15
  3. package/__tests__/config-validation.test.ts +46 -1
  4. package/__tests__/engine.test.ts +162 -2
  5. package/__tests__/fixtures/imports/config/aliases.json +8 -0
  6. package/__tests__/fixtures/imports/plain-root-file.ts +3 -0
  7. package/__tests__/fixtures/imports/sidebars.ts +5 -0
  8. package/__tests__/fixtures/imports/src/aliases.ts +4 -0
  9. package/__tests__/fixtures/imports/src/virtual.ts +3 -0
  10. package/__tests__/fixtures/imports/tsconfig.build.json +3 -0
  11. package/__tests__/fixtures/imports/tsconfig.json +8 -0
  12. package/__tests__/fixtures/imports/vite.config.ts +3 -0
  13. package/__tests__/imports.test.ts +72 -0
  14. package/dist/collectors/tsconfig-aliases.d.ts +1 -0
  15. package/dist/collectors/tsconfig-aliases.js +40 -0
  16. package/dist/collectors/tsconfig-aliases.js.map +1 -0
  17. package/dist/collectors/workspaces.d.ts +2 -2
  18. package/dist/collectors/workspaces.js +21 -6
  19. package/dist/collectors/workspaces.js.map +1 -1
  20. package/dist/lib/imports.d.ts +9 -4
  21. package/dist/lib/imports.js +62 -9
  22. package/dist/lib/imports.js.map +1 -1
  23. package/dist/model/config-validation.d.ts +2 -0
  24. package/dist/model/config-validation.js +44 -1
  25. package/dist/model/config-validation.js.map +1 -1
  26. package/dist/model/diagnostics.d.ts +1 -0
  27. package/dist/model/diagnostics.js +67 -0
  28. package/dist/model/diagnostics.js.map +1 -1
  29. package/dist/model/engine.js +1 -0
  30. package/dist/model/engine.js.map +1 -1
  31. package/dist/model/placement.js +12 -1
  32. package/dist/model/placement.js.map +1 -1
  33. package/dist/model/types.d.ts +8 -1
  34. package/dist/model/types.js.map +1 -1
  35. package/dist/runner.js +1 -1
  36. package/dist/runner.js.map +1 -1
  37. package/package.json +2 -2
  38. package/src/collectors/tsconfig-aliases.ts +45 -0
  39. package/src/collectors/workspaces.ts +50 -7
  40. package/src/lib/imports.ts +114 -8
  41. package/src/model/config-validation.ts +62 -3
  42. package/src/model/diagnostics.ts +105 -1
  43. package/src/model/engine.ts +7 -1
  44. package/src/model/placement.ts +19 -1
  45. package/src/model/types.ts +16 -0
  46. package/src/runner.ts +6 -1
@@ -27,6 +27,20 @@ function isTestFile(file: string): boolean {
27
27
  );
28
28
  }
29
29
 
30
+ // Build-tool config files (vite.config.ts, eslint.config.js, ...) import
31
+ // real packages, but those imports are tooling usage, not the workspace's
32
+ // own runtime surface — treat them like test files for placement purposes
33
+ // so they don't get forced into dependencies/peerDependencies. Matched by
34
+ // exact path against the workspace's collected tooling files (not by name
35
+ // pattern), so an app module that merely happens to be named e.g.
36
+ // src/auth.config.ts is never misclassified.
37
+ function isPrivateUsageFile(
38
+ file: string,
39
+ toolingFiles: ReadonlySet<string>,
40
+ ): boolean {
41
+ return isTestFile(file) || toolingFiles.has(file);
42
+ }
43
+
30
44
  export function isExternal(
31
45
  depIdent: string,
32
46
  workspaceNames: Set<string>,
@@ -215,9 +229,13 @@ export function addUsageDependencies(
215
229
  const workspace = expected.workspace;
216
230
  if (workspace.isRoot) continue;
217
231
 
232
+ const toolingFiles = workspace.toolingFiles ?? new Set<string>();
233
+
218
234
  for (const [depIdent, usage] of workspace.sourceUsage) {
219
235
  const publicType = workspace.dtsImports.has(depIdent);
220
- const runtime = [...usage.runtimeFiles].some((file) => !isTestFile(file));
236
+ const runtime = [...usage.runtimeFiles].some(
237
+ (file) => !isPrivateUsageFile(file, toolingFiles),
238
+ );
221
239
  const allTestOnly = [...usage.files].every(isTestFile);
222
240
 
223
241
  if (runtime || publicType) {
@@ -23,8 +23,18 @@ export interface DependencyRule {
23
23
  required?: boolean;
24
24
  }
25
25
 
26
+ // Extra root-level filename patterns (beyond the built-in *.config.* suffix
27
+ // convention) whose imports should be treated as tooling usage rather than
28
+ // the workspace's own runtime surface, e.g. Docusaurus' sidebars.ts.
29
+ export interface ToolingFileRule {
30
+ match: string | string[];
31
+ workspace?: string | string[];
32
+ }
33
+
26
34
  export interface DependencyModelConfig {
27
35
  version?: number;
36
+ ignoredImports?: string[];
37
+ toolingFiles?: ToolingFileRule[];
28
38
  rules?: DependencyRule[];
29
39
  doctor?: DoctorConfig;
30
40
  }
@@ -55,6 +65,7 @@ export interface DependencyViolation {
55
65
  | 'root-only'
56
66
  | 'root-only-usage'
57
67
  | 'unconstrained-version'
68
+ | 'stale-rule'
58
69
  | 'mirror'
59
70
  | 'stale'
60
71
  | 'dist-missing';
@@ -93,6 +104,11 @@ export interface WorkspaceFacts {
93
104
  hasSrc: boolean;
94
105
  hasDist: boolean;
95
106
  sourceFileCount?: number;
107
+
108
+ // Absolute paths of build-tool config files (vite.config.ts, ...) collected
109
+ // for this workspace; their imports are tooling usage, not the workspace's
110
+ // own runtime surface. Optional so callers that predate this field compile.
111
+ toolingFiles?: Set<string>;
96
112
  }
97
113
 
98
114
  export interface WorkspaceContext extends WorkspaceFacts {
package/src/runner.ts CHANGED
@@ -33,7 +33,12 @@ export function runDependencyModel(
33
33
  const config = loadConfig(rootDir, options.depdocYamlPath);
34
34
  const rules = config.rules ?? [];
35
35
  const withDts = options.withDts === true;
36
- const contexts = loadWorkspaces(rootDir, withDts);
36
+ const contexts = loadWorkspaces(
37
+ rootDir,
38
+ withDts,
39
+ config.ignoredImports ?? [],
40
+ config.toolingFiles ?? [],
41
+ );
37
42
  const packageExtensions = loadPackageExtensions(rootDir);
38
43
  const workspaceNames = new Set(
39
44
  contexts.filter((ws) => !ws.isRoot).map((ws) => ws.name),