@gld5000-cli/dependency-finder 1.0.10 → 1.0.12
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 +8 -1
- package/bin/index.mjs +7 -1
- package/dependents-report.json +1 -1
- package/package.json +1 -1
- package/src/findDependents.mjs +11 -1
- package/src/index.mjs +2 -0
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] [PascalCase only]
|
|
38
|
+
npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [File ignore patterns] [PascalCase only] [Import path includes]
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
### Arguments
|
|
@@ -46,6 +46,7 @@ npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [Fil
|
|
|
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
48
|
| **PascalCase only** | Filter exports to PascalCase names only (React components) | `y` | `y` or `n` |
|
|
49
|
+
| **Import path includes** | Filter imports to only those containing this substring | (none) | `folder-a` or `@components` |
|
|
49
50
|
|
|
50
51
|
### Example Usage
|
|
51
52
|
|
|
@@ -64,6 +65,12 @@ npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./components/**/*.ts
|
|
|
64
65
|
|
|
65
66
|
# Analyze JSX components with PascalCase filtering enabled
|
|
66
67
|
npx @gld5000-cli/dependency-finder "./src/components/**/*.jsx" "./src/**/*.jsx" ".test|.stories" "y"
|
|
68
|
+
|
|
69
|
+
# Filter imports to only those from a specific folder path
|
|
70
|
+
npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./src/**/*.tsx" ".test|.stories" "y" "folder-a"
|
|
71
|
+
|
|
72
|
+
# Filter imports to only those from a scoped package
|
|
73
|
+
npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./src/**/*.tsx" ".test" "y" "@mycompany/components"
|
|
67
74
|
```
|
|
68
75
|
|
|
69
76
|
## Output
|
package/bin/index.mjs
CHANGED
package/dependents-report.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"noDependents":{"count":2,"results":[{"matches":[
|
|
1
|
+
{"noDependents":{"count":2,"results":[{"matches":["ComponentC"],"filePath":"test\\test-components\\folder-c\\test3.tsx","dependents":[]},{"matches":["ComponentB"],"filePath":"test\\test-components\\folder-b\\test2.tsx","dependents":[]}]},"someDependents":{"count":1,"results":[{"matches":["ComponentA"],"filePath":"test\\test-components\\folder-a\\test1.tsx","dependents":[{"filePath":"test\\test-components\\index.tsx","matches":["import ComponentA from \"./folder-a/test1\"","import { ComponentA } from \"./folder-a/test1\""]}]}]}}
|
package/package.json
CHANGED
package/src/findDependents.mjs
CHANGED
|
@@ -7,6 +7,7 @@ export function findDependentsInTargetPaths(
|
|
|
7
7
|
componentObjectArray,
|
|
8
8
|
targetPaths,
|
|
9
9
|
ignorePatterns,
|
|
10
|
+
importPathIncludes,
|
|
10
11
|
) {
|
|
11
12
|
return targetPaths.reduce(targetPathReducer, componentObjectArray);
|
|
12
13
|
/**
|
|
@@ -65,7 +66,16 @@ export function findDependentsInTargetPaths(
|
|
|
65
66
|
),
|
|
66
67
|
),
|
|
67
68
|
)
|
|
68
|
-
.filter((
|
|
69
|
+
.filter((currentString) => {
|
|
70
|
+
// console.log("importPathIncludes", importPathIncludes);
|
|
71
|
+
// console.log("currentsSring", currentString);
|
|
72
|
+
return (
|
|
73
|
+
(currentString.length > 0 && !importPathIncludes) ||
|
|
74
|
+
(importPathIncludes &&
|
|
75
|
+
currentString.length > 0 &&
|
|
76
|
+
currentString.indexOf(importPathIncludes) !== -1)
|
|
77
|
+
);
|
|
78
|
+
});
|
|
69
79
|
if (dependentsCandidates && dependentsCandidates.length > 0) {
|
|
70
80
|
acc.dependentsArray.push({
|
|
71
81
|
filePath: currentFilePath,
|
package/src/index.mjs
CHANGED
|
@@ -17,12 +17,14 @@ export function runDependencyFinder(
|
|
|
17
17
|
targetPaths,
|
|
18
18
|
ignorePatterns,
|
|
19
19
|
isPascalCase,
|
|
20
|
+
importPathIncludes,
|
|
20
21
|
) {
|
|
21
22
|
// Get files with TSX exports
|
|
22
23
|
const allDependents = findDependentsInTargetPaths(
|
|
23
24
|
findComponents(searchPattern, ignorePatterns, isPascalCase),
|
|
24
25
|
targetPaths,
|
|
25
26
|
ignorePatterns,
|
|
27
|
+
importPathIncludes,
|
|
26
28
|
);
|
|
27
29
|
const noDependents = filterNoDependents(allDependents);
|
|
28
30
|
const someDependents = filterSomeDependents(allDependents);
|