@gld5000-cli/dependency-finder 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -35,7 +35,7 @@ npx @gld5000-cli/dependency-finder
35
35
  ## Run with arguments
36
36
 
37
37
  ```
38
- npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [File ignore patterns]
38
+ npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [File ignore patterns] [PascalCase only]
39
39
  ```
40
40
 
41
41
  ### Arguments
@@ -45,6 +45,7 @@ npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [Fil
45
45
  | **Component directory** | Glob pattern for component files to analyze | `./components/**/*.tsx` | `./src/components/**/*.tsx` |
46
46
  | **Dependents paths** | Pipe-separated glob patterns for where to search for imports | `./components/**/*.tsx\|./pages/**/*.tsx` | `./src/**/*.tsx\|./app/**/*.ts` |
47
47
  | **File ignore patterns** | Pipe-separated patterns to exclude from analysis | `.test\|.stories` | `.test\|.spec\|.mock` |
48
+ | **PascalCase only** | Filter exports to PascalCase names only (React components) | `n` | `y` or `n` |
48
49
 
49
50
  ### Example Usage
50
51
 
@@ -57,6 +58,12 @@ npx @gld5000-cli/dependency-finder "./src/components/**/*.ts" "./src/**/*.ts" ".
57
58
 
58
59
  # Analyze React components including JSX
59
60
  npx @gld5000-cli/dependency-finder "./components/**/*.{tsx,jsx}" "./src/**/*.{tsx,jsx}|./pages/**/*.{tsx,jsx}" ".test|.stories|.mock"
61
+
62
+ # Analyze TSX components with PascalCase filtering (for strict React component naming)
63
+ npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./components/**/*.tsx|./pages/**/*.tsx" ".test|.stories" "y"
64
+
65
+ # Analyze JSX components with PascalCase filtering enabled
66
+ npx @gld5000-cli/dependency-finder "./src/components/**/*.jsx" "./src/**/*.jsx" ".test|.stories" "y"
60
67
  ```
61
68
 
62
69
  ## Output
@@ -117,11 +124,12 @@ The tool generates a `dependents-report.json` file in your project root with the
117
124
 
118
125
  1. **Discover Components** - Scans your codebase using the component directory pattern to find all component files
119
126
  2. **Extract Exports** - Identifies exported components in each file
120
- 3. **Search for Imports** - Searches target paths for import statements referencing each component
121
- 4. **Categorize Results** - Groups components into those with dependents and those without
122
- 5. **Generate Report** - Creates a detailed JSON report with all findings
127
+ 3. **Filter Exports** - Optionally filters exports to include only PascalCase names (enforces React component naming conventions)
128
+ 4. **Search for Imports** - Searches target paths for import statements referencing each component
129
+ 5. **Categorize Results** - Groups components into those with dependents and those without
130
+ 6. **Generate Report** - Creates a detailed JSON report with all findings
123
131
 
124
- The tool uses glob patterns for flexible file matching and supports filtering to exclude test files, stories, and other non-production code.
132
+ The tool uses glob patterns for flexible file matching and supports filtering to exclude test files, stories, and other non-production code. For TSX/JSX components, enable PascalCase filtering to strictly enforce React naming conventions and ignore helper functions and utilities.
125
133
 
126
134
  ## Examples
127
135
 
package/bin/index.mjs CHANGED
@@ -29,4 +29,12 @@ const ignorePatterns = `${
29
29
  defaultIgnorePatterns,
30
30
  ))
31
31
  }`.split("|");
32
- runDependencyFinder(searchPattern, targetPaths, ignorePatterns);
32
+
33
+ const isPascalCase =
34
+ (args[3] ||
35
+ (await answerStringQuestion(
36
+ "PascalCase exports only?",
37
+ defaultExportCase,
38
+ ))) === "y";
39
+
40
+ runDependencyFinder(searchPattern, targetPaths, ignorePatterns, isPascalCase);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gld5000-cli/dependency-finder",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Finds how many dependents your components have.",
5
5
  "keywords": [
6
6
  "CLI",
@@ -7,10 +7,12 @@ import { searchFiles } from "./searchFiles.mjs";
7
7
  * @param {string} inputPath
8
8
  * @returns {[path: string, matches: string[]]}
9
9
  */
10
- export function findComponents(inputPath, ignorePatterns) {
10
+ export function findComponents(inputPath, ignorePatterns, isPascalCase) {
11
11
  return searchFiles(
12
12
  filterFilesNot(findFiles(inputPath), ignorePatterns),
13
- /(export default function|export const|export default) ([a-zA-Z]+)/g,
13
+ isPascalCase
14
+ ? /(export default function|export const|export default|export declare const) ([A-Z][a-zA-Z]+)/g
15
+ : /(export default function|export const|export default|export declare const) ([a-zA-Z]+)/g,
14
16
  2,
15
17
  );
16
18
  }
package/src/index.mjs CHANGED
@@ -16,12 +16,14 @@ export function runDependencyFinder(
16
16
  searchPattern,
17
17
  targetPaths,
18
18
  ignorePatterns,
19
+ isPascalCase,
19
20
  ) {
20
21
  // Get files with TSX exports
21
22
  const allDependents = findDependentsInTargetPaths(
22
23
  findComponents(searchPattern, ignorePatterns),
23
24
  targetPaths,
24
25
  ignorePatterns,
26
+ isPascalCase,
25
27
  );
26
28
  const noDependents = filterNoDependents(allDependents);
27
29
  const someDependents = filterSomeDependents(allDependents);