find-cypress-specs 1.23.0 → 1.24.0

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 (3) hide show
  1. package/README.md +2 -0
  2. package/bin/find.js +15 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -72,6 +72,8 @@ $ npx find-cypress-specs --branch main --parent --trace-imports cypress --cache-
72
72
 
73
73
  The cached trace will be saved in file `deps.json`, you probably want to Git ignore it.
74
74
 
75
+ You can limit the number of added traced files using the `--max-added-traced-specs <N>` parameter. This avoids ALL specs added when you change some common utility that many specs import.
76
+
75
77
  ### number of changed files
76
78
 
77
79
  You can print just the number of changed specs
package/bin/find.js CHANGED
@@ -40,6 +40,8 @@ const args = arg({
40
40
  // save a JSON file with traced dependencies to save time
41
41
  '--cache-trace': Boolean,
42
42
  '--time-trace': Boolean,
43
+ // do not add more than this number of extra specs after tracing
44
+ '--max-added-traced-specs': Number,
43
45
  // aliases
44
46
  '-n': '--names',
45
47
  '--name': '--names',
@@ -172,6 +174,13 @@ if (args['--names'] || args['--tags']) {
172
174
  }
173
175
  debug('traced dependencies via imports and require')
174
176
  debug(deps)
177
+
178
+ // add a sensible limit to the number of extra specs to add
179
+ // when we trace the dependencies in the changed source files
180
+ const addedTracedFiles = []
181
+ const maxAddTracedFiles = args['--max-added-traced-specs'] || 1000
182
+ debug('maximum traced files to add %d', maxAddTracedFiles)
183
+
175
184
  Object.entries(deps).forEach(([filename, fileDependents]) => {
176
185
  const f = path.join(args['--trace-imports'], filename)
177
186
  if (changedFiles.includes(f)) {
@@ -183,12 +192,17 @@ if (args['--names'] || args['--tags']) {
183
192
  fileDependents.forEach((name) => {
184
193
  const nameInCypressFolder = path.join(args['--trace-imports'], name)
185
194
  if (!changedFiles.includes(nameInCypressFolder)) {
186
- changedFiles.push(nameInCypressFolder)
195
+ if (addedTracedFiles.length < maxAddTracedFiles) {
196
+ changedFiles.push(nameInCypressFolder)
197
+ addedTracedFiles.push(nameInCypressFolder)
198
+ }
187
199
  }
188
200
  })
189
201
  }
190
202
  })
203
+ debug('added %d traced specs %o', addedTracedFiles.length, addedTracedFiles)
191
204
  }
205
+
192
206
  let changedSpecs = specs.filter((file) => changedFiles.includes(file))
193
207
  debug('changed %d specs %o', changedSpecs.length, changedSpecs)
194
208
  if (args['--set-gha-outputs']) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "find-cypress-specs",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "Find Cypress spec files using the config settings",
5
5
  "main": "src",
6
6
  "files": [