@gld5000-cli/dependency-finder 1.0.11 → 1.0.13

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] [PascalCase only] [Import path filter]
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,7 +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 filter** | Filter imports to only those containing this substring | (none) | `folder-a` or `@components` |
49
+ | **Import path includes** | Filter imports to only those containing this substring | (none) | `folder-a` or `@components` |
50
50
 
51
51
  ### Example Usage
52
52
 
@@ -151,7 +151,7 @@ After running, check `dependents-report.json` and review the `noDependents` sect
151
151
  ### Audit Before Deprecating a Component Library
152
152
 
153
153
  ```bash
154
- npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./pages/**/*.tsx|./features/**/*.tsx|./layouts/**/*.tsx" ".test"
154
+ npx @gld5000-cli/dependency-finder "./node_modules/my_package/build/components/**/index.d.ts" "./components/**/*.tsx|./pages/**/*.tsx" ".test|.stories" "y" "my_package"
155
155
  ```
156
156
 
157
157
  Review the `someDependents` section to see exactly where each component is used before deprecating or refactoring.
@@ -163,6 +163,40 @@ Review the `someDependents` section to see exactly where each component is used
163
163
  npx @gld5000-cli/dependency-finder
164
164
  ```
165
165
 
166
+ ### Run in CI pipeline for repo files
167
+
168
+ ```yaml
169
+ dependency_report:
170
+ stage: test
171
+ image: node:latest
172
+ script:
173
+ # Run the command; file is created automatically by the package: npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [File ignore patterns] [PascalCase only] [Import path includes]
174
+ - npx @gld5000-cli/dependency-finder "./components/**/*.tsx" "./components/**/*.tsx|./pages/**/*.tsx" ".test|.stories" "y"
175
+ artifacts:
176
+ paths:
177
+ - dependents-report.json
178
+ when: always # Optional: uploads the report even if the job fails
179
+ expire_in: 1 week # Optional: defines how long to keep the file
180
+ ```
181
+
182
+ ### Run in CI pipeline for project dependencies
183
+
184
+ ```yaml
185
+ my_package_dependency_report:
186
+ stage: test
187
+ image: node:latest
188
+ script:
189
+ # Install node_modules
190
+ - npm install
191
+ # Run the command; file is created automatically by the package: npx @gld5000-cli/dependency-finder [Component directory] [Dependents paths] [File ignore patterns] [PascalCase only] [Import path includes]
192
+ - npx @gld5000-cli/dependency-finder "./node_modules/my_package/build/components/**/index.d.ts" "./components/**/*.tsx|./pages/**/*.tsx" ".test|.stories" "y" "my_package"
193
+ artifacts:
194
+ paths:
195
+ - dependents-report.json
196
+ when: always # Optional: uploads the report even if the job fails
197
+ expire_in: 1 week # Optional: defines how long to keep the file
198
+ ```
199
+
166
200
  Follow the prompts to customize paths for your project structure.
167
201
 
168
202
  ## Contributing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gld5000-cli/dependency-finder",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Finds how many dependents your components have.",
5
5
  "keywords": [
6
6
  "CLI",
@@ -7,7 +7,7 @@ export function findDependentsInTargetPaths(
7
7
  componentObjectArray,
8
8
  targetPaths,
9
9
  ignorePatterns,
10
- importPathSubstring,
10
+ importPathIncludes,
11
11
  ) {
12
12
  return targetPaths.reduce(targetPathReducer, componentObjectArray);
13
13
  /**
@@ -67,13 +67,13 @@ export function findDependentsInTargetPaths(
67
67
  ),
68
68
  )
69
69
  .filter((currentString) => {
70
- // console.log("importPathSubstring", importPathSubstring);
70
+ // console.log("importPathIncludes", importPathIncludes);
71
71
  // console.log("currentsSring", currentString);
72
72
  return (
73
- (currentString.length > 0 && !importPathSubstring) ||
74
- (importPathSubstring &&
73
+ (currentString.length > 0 && !importPathIncludes) ||
74
+ (importPathIncludes &&
75
75
  currentString.length > 0 &&
76
- currentString.indexOf(importPathSubstring) !== -1)
76
+ currentString.indexOf(importPathIncludes) !== -1)
77
77
  );
78
78
  });
79
79
  if (dependentsCandidates && dependentsCandidates.length > 0) {
package/src/index.mjs CHANGED
@@ -17,14 +17,14 @@ export function runDependencyFinder(
17
17
  targetPaths,
18
18
  ignorePatterns,
19
19
  isPascalCase,
20
- importPathSubstring,
20
+ importPathIncludes,
21
21
  ) {
22
22
  // Get files with TSX exports
23
23
  const allDependents = findDependentsInTargetPaths(
24
24
  findComponents(searchPattern, ignorePatterns, isPascalCase),
25
25
  targetPaths,
26
26
  ignorePatterns,
27
- importPathSubstring,
27
+ importPathIncludes,
28
28
  );
29
29
  const noDependents = filterNoDependents(allDependents);
30
30
  const someDependents = filterSomeDependents(allDependents);