dependabot-npm_and_yarn 0.334.0 → 0.335.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 (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dependabot/npm_and_yarn/constraint_helper.rb +30 -21
  3. data/lib/dependabot/npm_and_yarn/dependency_files_filterer.rb +12 -6
  4. data/lib/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder.rb +21 -13
  5. data/lib/dependabot/npm_and_yarn/file_fetcher.rb +14 -7
  6. data/lib/dependabot/npm_and_yarn/file_parser.rb +84 -44
  7. data/lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb +18 -10
  8. data/lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb +16 -8
  9. data/lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb +4 -2
  10. data/lib/dependabot/npm_and_yarn/file_updater/pnpm_workspace_updater.rb +5 -3
  11. data/lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb +42 -25
  12. data/lib/dependabot/npm_and_yarn/file_updater.rb +4 -2
  13. data/lib/dependabot/npm_and_yarn/metadata_finder.rb +2 -2
  14. data/lib/dependabot/npm_and_yarn/npm_package_manager.rb +9 -6
  15. data/lib/dependabot/npm_and_yarn/package/registry_finder.rb +10 -2
  16. data/lib/dependabot/npm_and_yarn/package_manager.rb +9 -6
  17. data/lib/dependabot/npm_and_yarn/package_name.rb +2 -1
  18. data/lib/dependabot/npm_and_yarn/pnpm_package_manager.rb +9 -6
  19. data/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb +8 -2
  20. data/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb +23 -8
  21. data/lib/dependabot/npm_and_yarn/update_checker/vulnerability_auditor.rb +4 -2
  22. data/lib/dependabot/npm_and_yarn/update_checker.rb +17 -7
  23. data/lib/dependabot/npm_and_yarn/version.rb +17 -14
  24. data/lib/dependabot/npm_and_yarn/yarn_package_manager.rb +9 -6
  25. data/lib/dependabot/npm_and_yarn.rb +435 -406
  26. metadata +12 -12
@@ -93,10 +93,13 @@ module Dependabot
93
93
  YARN_PACKAGE_NOT_FOUND_CODE_1 = /Couldn't find package "[^@].*(?<dep>.*)" on the "(?<regis>.*)" registry./
94
94
  YARN_PACKAGE_NOT_FOUND_CODE_2 = /Couldn't find package "[^@].*(?<dep>.*)" required by "(?<pkg>.*)" on the "(?<regis>.*)" registry./ # rubocop:disable Layout/LineLength
95
95
 
96
- YN0035 = T.let({
97
- PACKAGE_NOT_FOUND: %r{(?<package_req>@[\w-]+\/[\w-]+@\S+): Package not found},
98
- FAILED_TO_RETRIEVE: %r{(?<package_req>@[\w-]+\/[\w-]+@\S+): The remote server failed to provide the requested resource} # rubocop:disable Layout/LineLength
99
- }.freeze, T::Hash[String, Regexp])
96
+ YN0035 = T.let(
97
+ {
98
+ PACKAGE_NOT_FOUND: %r{(?<package_req>@[\w-]+\/[\w-]+@\S+): Package not found},
99
+ FAILED_TO_RETRIEVE: %r{(?<package_req>@[\w-]+\/[\w-]+@\S+): The remote server failed to provide the requested resource} # rubocop:disable Layout/LineLength
100
+ }.freeze,
101
+ T::Hash[String, Regexp]
102
+ )
100
103
 
101
104
  YN0082_PACKAGE_NOT_FOUND_REGEX = /YN0082:.*?(\S+@\S+): No candidates found/
102
105
 
@@ -146,32 +149,47 @@ module Dependabot
146
149
  # if not package found with specified version
147
150
  YARN_PACKAGE_NOT_FOUND = /MessageError: Couldn't find any versions for "(?<pkg>.*?)" that matches "(?<ver>.*?)"/
148
151
 
149
- YN0001_DEPS_RESOLUTION_FAILED = T.let({
150
- DEPS_INCORRECT_MET: /peer dependencies are incorrectly met/
151
- }.freeze, T::Hash[String, Regexp])
152
-
153
- YN0001_FILE_NOT_RESOLVED_CODES = T.let({
154
- FIND_PACKAGE_LOCATION: /YN0001:(.*?)UsageError: Couldn't find the (?<pkg>.*) state file/,
155
- NO_CANDIDATE_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): No candidates found/,
156
- NO_SUPPORTED_RESOLVER: /YN0001:(.*?)Error: (?<pkg>.*) isn't supported by any available resolver/,
157
- WORKSPACE_NOT_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): Workspace not found/,
158
- ENOENT: /YN0001:(.*?)Thrown Error: (?<pkg>.*) ENOENT/,
159
- MANIFEST_NOT_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): Manifest not found/,
160
- LIBZIP_ERROR: /YN0001:(.*?)Libzip Error: Failed to open the cache entry for (?<pkg>.*): Not a zip archive/
161
- }.freeze, T::Hash[String, Regexp])
162
-
163
- YN0001_AUTH_ERROR_CODES = T.let({
164
- AUTH_ERROR: /YN0001:*.*Fatal Error: could not read Username for '(?<url>.*)': terminal prompts disabled/
165
- }.freeze, T::Hash[String, Regexp])
166
-
167
- YN0001_REQ_NOT_FOUND_CODES = T.let({
168
- REQUIREMENT_NOT_SATISFIED: /provides (?<dep>.*)(.*?)with version (?<ver>.*), which doesn't satisfy what (?<pkg>.*) requests/, # rubocop:disable Layout/LineLength
169
- REQUIREMENT_NOT_PROVIDED: /(?<dep>.*)(.*?)doesn't provide (?<pkg>.*)(.*?), requested by (?<parent>.*)/
170
- }.freeze, T::Hash[String, Regexp])
171
-
172
- YN0001_INVALID_TYPE_ERRORS = T.let({
173
- INVALID_URL: /TypeError: (?<dep>.*): Invalid URL/
174
- }.freeze, T::Hash[String, Regexp])
152
+ YN0001_DEPS_RESOLUTION_FAILED = T.let(
153
+ {
154
+ DEPS_INCORRECT_MET: /peer dependencies are incorrectly met/
155
+ }.freeze,
156
+ T::Hash[String, Regexp]
157
+ )
158
+
159
+ YN0001_FILE_NOT_RESOLVED_CODES = T.let(
160
+ {
161
+ FIND_PACKAGE_LOCATION: /YN0001:(.*?)UsageError: Couldn't find the (?<pkg>.*) state file/,
162
+ NO_CANDIDATE_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): No candidates found/,
163
+ NO_SUPPORTED_RESOLVER: /YN0001:(.*?)Error: (?<pkg>.*) isn't supported by any available resolver/,
164
+ WORKSPACE_NOT_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): Workspace not found/,
165
+ ENOENT: /YN0001:(.*?)Thrown Error: (?<pkg>.*) ENOENT/,
166
+ MANIFEST_NOT_FOUND: /YN0001:(.*?)Error: (?<pkg>.*): Manifest not found/,
167
+ LIBZIP_ERROR: /YN0001:(.*?)Libzip Error: Failed to open the cache entry for (?<pkg>.*): Not a zip archive/
168
+ }.freeze,
169
+ T::Hash[String, Regexp]
170
+ )
171
+
172
+ YN0001_AUTH_ERROR_CODES = T.let(
173
+ {
174
+ AUTH_ERROR: /YN0001:*.*Fatal Error: could not read Username for '(?<url>.*)': terminal prompts disabled/
175
+ }.freeze,
176
+ T::Hash[String, Regexp]
177
+ )
178
+
179
+ YN0001_REQ_NOT_FOUND_CODES = T.let(
180
+ {
181
+ REQUIREMENT_NOT_SATISFIED: /provides (?<dep>.*)(.*?)with version (?<ver>.*), which doesn't satisfy what (?<pkg>.*) requests/, # rubocop:disable Layout/LineLength
182
+ REQUIREMENT_NOT_PROVIDED: /(?<dep>.*)(.*?)doesn't provide (?<pkg>.*)(.*?), requested by (?<parent>.*)/
183
+ }.freeze,
184
+ T::Hash[String, Regexp]
185
+ )
186
+
187
+ YN0001_INVALID_TYPE_ERRORS = T.let(
188
+ {
189
+ INVALID_URL: /TypeError: (?<dep>.*): Invalid URL/
190
+ }.freeze,
191
+ T::Hash[String, Regexp]
192
+ )
175
193
 
176
194
  YN0086_DEPS_RESOLUTION_FAILED = /peer dependencies are incorrectly met/
177
195
 
@@ -214,421 +232,432 @@ module Dependabot
214
232
  end
215
233
 
216
234
  YARN_CODE_REGEX = /(YN\d{4})/
217
- YARN_ERROR_CODES = T.let({
218
- "YN0001" => {
219
- message: "Exception error",
220
- handler: lambda { |message, _error, _params|
221
- YN0001_FILE_NOT_RESOLVED_CODES.each do |(_yn0001_key, yn0001_regex)|
222
- if (msg = message.match(yn0001_regex))
223
- return Dependabot::DependencyFileNotResolvable.new(msg)
235
+ YARN_ERROR_CODES = T.let(
236
+ {
237
+ "YN0001" => {
238
+ message: "Exception error",
239
+ handler: lambda { |message, _error, _params|
240
+ YN0001_FILE_NOT_RESOLVED_CODES.each do |(_yn0001_key, yn0001_regex)|
241
+ if (msg = message.match(yn0001_regex))
242
+ return Dependabot::DependencyFileNotResolvable.new(msg)
243
+ end
224
244
  end
225
- end
226
245
 
227
- YN0001_AUTH_ERROR_CODES.each do |(_yn0001_key, yn0001_regex)|
228
- if (msg = message.match(yn0001_regex))
229
- url = msg.named_captures.fetch(URL_CAPTURE)
230
- return Dependabot::PrivateSourceAuthenticationFailure.new(url)
246
+ YN0001_AUTH_ERROR_CODES.each do |(_yn0001_key, yn0001_regex)|
247
+ if (msg = message.match(yn0001_regex))
248
+ url = msg.named_captures.fetch(URL_CAPTURE)
249
+ return Dependabot::PrivateSourceAuthenticationFailure.new(url)
250
+ end
231
251
  end
232
- end
233
252
 
234
- YN0001_REQ_NOT_FOUND_CODES.each do |(_yn0001_key, yn0001_regex)|
235
- if (msg = message.match(yn0001_regex))
236
- return Dependabot::DependencyFileNotResolvable.new(msg)
253
+ YN0001_REQ_NOT_FOUND_CODES.each do |(_yn0001_key, yn0001_regex)|
254
+ if (msg = message.match(yn0001_regex))
255
+ return Dependabot::DependencyFileNotResolvable.new(msg)
256
+ end
237
257
  end
238
- end
239
258
 
240
- YN0001_DEPS_RESOLUTION_FAILED.each do |(_yn0001_key, yn0001_regex)|
241
- if (msg = message.match(yn0001_regex))
242
- return Dependabot::DependencyFileNotResolvable.new(msg)
259
+ YN0001_DEPS_RESOLUTION_FAILED.each do |(_yn0001_key, yn0001_regex)|
260
+ if (msg = message.match(yn0001_regex))
261
+ return Dependabot::DependencyFileNotResolvable.new(msg)
262
+ end
243
263
  end
244
- end
245
264
 
246
- YN0001_INVALID_TYPE_ERRORS.each do |(_yn0001_key, yn0001_regex)|
247
- if (msg = message.match(yn0001_regex))
265
+ YN0001_INVALID_TYPE_ERRORS.each do |(_yn0001_key, yn0001_regex)|
266
+ if (msg = message.match(yn0001_regex))
248
267
 
249
- return Dependabot::DependencyFileNotResolvable.new(msg)
268
+ return Dependabot::DependencyFileNotResolvable.new(msg)
269
+ end
250
270
  end
251
- end
252
271
 
253
- Dependabot::DependabotError.new(message)
254
- }
255
- },
256
- "YN0002" => {
257
- message: "Missing peer dependency",
258
- handler: lambda { |message, _error, _params|
259
- Dependabot::DependencyFileNotResolvable.new(message)
260
- }
261
- },
262
- "YN0009" => {
263
- message: "Build Failed",
264
- handler: lambda { |message, _error, _params|
265
- Dependabot::DependencyFileNotResolvable.new(message)
266
- }
267
- },
268
- "YN0016" => {
269
- message: "Remote not found",
270
- handler: lambda { |message, _error, _params|
271
- Dependabot::GitDependenciesNotReachable.new(message)
272
- }
273
- },
274
- "YN0020" => {
275
- message: "Missing lockfile entry",
276
- handler: lambda { |message, _error, _params|
277
- Dependabot::DependencyFileNotFound.new(message)
278
- }
279
- },
280
- "YN0035" => {
281
- message: "Package not found",
282
- handler: lambda { |message, _error, _params|
283
- YN0035.each do |(_yn0035_key, yn0035_regex)|
284
- if (match_data = message.match(yn0035_regex)) && (package_req = match_data[:package_req])
285
- return Dependabot::DependencyNotFound.new(
286
- "#{package_req} Detail: #{message}"
287
- )
272
+ Dependabot::DependabotError.new(message)
273
+ }
274
+ },
275
+ "YN0002" => {
276
+ message: "Missing peer dependency",
277
+ handler: lambda { |message, _error, _params|
278
+ Dependabot::DependencyFileNotResolvable.new(message)
279
+ }
280
+ },
281
+ "YN0009" => {
282
+ message: "Build Failed",
283
+ handler: lambda { |message, _error, _params|
284
+ Dependabot::DependencyFileNotResolvable.new(message)
285
+ }
286
+ },
287
+ "YN0016" => {
288
+ message: "Remote not found",
289
+ handler: lambda { |message, _error, _params|
290
+ Dependabot::GitDependenciesNotReachable.new(message)
291
+ }
292
+ },
293
+ "YN0020" => {
294
+ message: "Missing lockfile entry",
295
+ handler: lambda { |message, _error, _params|
296
+ Dependabot::DependencyFileNotFound.new(message)
297
+ }
298
+ },
299
+ "YN0035" => {
300
+ message: "Package not found",
301
+ handler: lambda { |message, _error, _params|
302
+ YN0035.each do |(_yn0035_key, yn0035_regex)|
303
+ if (match_data = message.match(yn0035_regex)) && (package_req = match_data[:package_req])
304
+ return Dependabot::DependencyNotFound.new(
305
+ "#{package_req} Detail: #{message}"
306
+ )
307
+ end
288
308
  end
289
- end
290
- Dependabot::DependencyNotFound.new(message)
291
- }
292
- },
293
- "YN0041" => {
294
- message: "Invalid authentication",
295
- handler: lambda { |message, _error, _params|
296
- url = T.must(URI.decode_www_form_component(message).split("https://").last).split("/").first
297
- Dependabot::PrivateSourceAuthenticationFailure.new(url)
298
- }
299
- },
300
- "YN0046" => {
301
- message: "Automerge failed to parse",
302
- handler: lambda { |message, _error, _params|
303
- Dependabot::MisconfiguredTooling.new("Yarn", message)
304
- }
305
- },
306
- "YN0047" => {
307
- message: "Automerge immutable",
308
- handler: lambda { |message, _error, _params|
309
- Dependabot::MisconfiguredTooling.new("Yarn", message)
310
- }
311
- },
312
- "YN0062" => {
313
- message: "Incompatible OS",
314
- handler: lambda { |message, _error, _params|
315
- Dependabot::DependabotError.new(message)
316
- }
317
- },
318
- "YN0063" => {
319
- message: "Incompatible CPU",
320
- handler: lambda { |message, _error, _params|
321
- Dependabot::IncompatibleCPU.new(message)
322
- }
323
- },
324
- "YN0068" => {
325
- message: "No matching package",
326
- handler: lambda { |message, _error, _params|
327
- Dependabot::DependencyFileNotResolvable.new(message)
328
- }
329
- },
330
- "YN0071" => {
331
- message: "NM can't install external soft link",
332
- handler: lambda { |message, _error, _params|
333
- Dependabot::MisconfiguredTooling.new("Yarn", message)
334
- }
335
- },
336
- "YN0072" => {
337
- message: "NM preserve symlinks required",
338
- handler: lambda { |message, _error, _params|
339
- Dependabot::MisconfiguredTooling.new("Yarn", message)
340
- }
341
- },
342
- "YN0075" => {
343
- message: "Prolog instantiation error",
344
- handler: lambda { |message, _error, _params|
345
- Dependabot::MisconfiguredTooling.new("Yarn", message)
346
- }
347
- },
348
- "YN0077" => {
349
- message: "Ghost architecture",
350
- handler: lambda { |message, _error, _params|
351
- Dependabot::MisconfiguredTooling.new("Yarn", message)
352
- }
353
- },
354
- "YN0080" => {
355
- message: "Network disabled",
356
- handler: lambda { |message, _error, _params|
357
- Dependabot::MisconfiguredTooling.new("Yarn", message)
358
- }
359
- },
360
- "YN0081" => {
361
- message: "Network unsafe HTTP",
362
- handler: lambda { |message, _error, _params|
363
- Dependabot::NetworkUnsafeHTTP.new(message)
364
- }
365
- },
366
- "YN0082" => {
367
- message: "No candidates found",
368
- handler: lambda { |message, _error, _params|
369
- match_data = message.match(YN0082_PACKAGE_NOT_FOUND_REGEX)
370
- if match_data
371
- package_req = match_data[1]
372
- Dependabot::DependencyNotFound.new("#{package_req} Detail: #{message}")
373
- else
374
309
  Dependabot::DependencyNotFound.new(message)
375
- end
376
- }
377
- },
378
- "YN0086" => {
379
- message: "deps resolution failed",
380
- handler: lambda { |message, _error, _params|
381
- msg = message.match(YN0086_DEPS_RESOLUTION_FAILED)
382
- Dependabot::DependencyFileNotResolvable.new(msg || message)
310
+ }
311
+ },
312
+ "YN0041" => {
313
+ message: "Invalid authentication",
314
+ handler: lambda { |message, _error, _params|
315
+ url = T.must(URI.decode_www_form_component(message).split("https://").last).split("/").first
316
+ Dependabot::PrivateSourceAuthenticationFailure.new(url)
317
+ }
318
+ },
319
+ "YN0046" => {
320
+ message: "Automerge failed to parse",
321
+ handler: lambda { |message, _error, _params|
322
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
323
+ }
324
+ },
325
+ "YN0047" => {
326
+ message: "Automerge immutable",
327
+ handler: lambda { |message, _error, _params|
328
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
329
+ }
330
+ },
331
+ "YN0062" => {
332
+ message: "Incompatible OS",
333
+ handler: lambda { |message, _error, _params|
334
+ Dependabot::DependabotError.new(message)
335
+ }
336
+ },
337
+ "YN0063" => {
338
+ message: "Incompatible CPU",
339
+ handler: lambda { |message, _error, _params|
340
+ Dependabot::IncompatibleCPU.new(message)
341
+ }
342
+ },
343
+ "YN0068" => {
344
+ message: "No matching package",
345
+ handler: lambda { |message, _error, _params|
346
+ Dependabot::DependencyFileNotResolvable.new(message)
347
+ }
348
+ },
349
+ "YN0071" => {
350
+ message: "NM can't install external soft link",
351
+ handler: lambda { |message, _error, _params|
352
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
353
+ }
354
+ },
355
+ "YN0072" => {
356
+ message: "NM preserve symlinks required",
357
+ handler: lambda { |message, _error, _params|
358
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
359
+ }
360
+ },
361
+ "YN0075" => {
362
+ message: "Prolog instantiation error",
363
+ handler: lambda { |message, _error, _params|
364
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
365
+ }
366
+ },
367
+ "YN0077" => {
368
+ message: "Ghost architecture",
369
+ handler: lambda { |message, _error, _params|
370
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
371
+ }
372
+ },
373
+ "YN0080" => {
374
+ message: "Network disabled",
375
+ handler: lambda { |message, _error, _params|
376
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
377
+ }
378
+ },
379
+ "YN0081" => {
380
+ message: "Network unsafe HTTP",
381
+ handler: lambda { |message, _error, _params|
382
+ Dependabot::NetworkUnsafeHTTP.new(message)
383
+ }
384
+ },
385
+ "YN0082" => {
386
+ message: "No candidates found",
387
+ handler: lambda { |message, _error, _params|
388
+ match_data = message.match(YN0082_PACKAGE_NOT_FOUND_REGEX)
389
+ if match_data
390
+ package_req = match_data[1]
391
+ Dependabot::DependencyNotFound.new("#{package_req} Detail: #{message}")
392
+ else
393
+ Dependabot::DependencyNotFound.new(message)
394
+ end
395
+ }
396
+ },
397
+ "YN0086" => {
398
+ message: "deps resolution failed",
399
+ handler: lambda { |message, _error, _params|
400
+ msg = message.match(YN0086_DEPS_RESOLUTION_FAILED)
401
+ Dependabot::DependencyFileNotResolvable.new(msg || message)
402
+ }
383
403
  }
384
- }
385
- }.freeze, T::Hash[String, {
386
- message: T.any(String, NilClass),
387
- handler: ErrorHandler
388
- }])
404
+ }.freeze,
405
+ T::Hash[String,
406
+ {
407
+ message: T.any(String, NilClass),
408
+ handler: ErrorHandler
409
+ }]
410
+ )
389
411
 
390
412
  # Group of patterns to validate error message and raise specific error
391
- VALIDATION_GROUP_PATTERNS = T.let([
392
- {
393
- patterns: [INVALID_NAME_IN_PACKAGE_JSON],
394
- handler: lambda { |message, _error, _params|
395
- Dependabot::DependencyFileNotResolvable.new(message)
413
+ VALIDATION_GROUP_PATTERNS = T.let(
414
+ [
415
+ {
416
+ patterns: [INVALID_NAME_IN_PACKAGE_JSON],
417
+ handler: lambda { |message, _error, _params|
418
+ Dependabot::DependencyFileNotResolvable.new(message)
419
+ },
420
+ in_usage: false,
421
+ matchfn: nil
396
422
  },
397
- in_usage: false,
398
- matchfn: nil
399
- },
400
- {
401
- # Check if sub dependency is using local path and raise a resolvability error
402
- patterns: [INVALID_PACKAGE_REGEX, SUB_DEP_LOCAL_PATH_TEXT],
403
- handler: lambda { |message, _error, params|
404
- Dependabot::DependencyFileNotResolvable.new(
405
- Utils.sanitize_resolvability_message(
406
- message,
407
- params[:dependencies],
408
- params[:yarn_lock]
423
+ {
424
+ # Check if sub dependency is using local path and raise a resolvability error
425
+ patterns: [INVALID_PACKAGE_REGEX, SUB_DEP_LOCAL_PATH_TEXT],
426
+ handler: lambda { |message, _error, params|
427
+ Dependabot::DependencyFileNotResolvable.new(
428
+ Utils.sanitize_resolvability_message(
429
+ message,
430
+ params[:dependencies],
431
+ params[:yarn_lock]
432
+ )
409
433
  )
410
- )
434
+ },
435
+ in_usage: false,
436
+ matchfn: nil
411
437
  },
412
- in_usage: false,
413
- matchfn: nil
414
- },
415
- {
416
- patterns: [NODE_MODULES_STATE_FILE_NOT_FOUND],
417
- handler: lambda { |message, _error, _params|
418
- Dependabot::MisconfiguredTooling.new("Yarn", message)
438
+ {
439
+ patterns: [NODE_MODULES_STATE_FILE_NOT_FOUND],
440
+ handler: lambda { |message, _error, _params|
441
+ Dependabot::MisconfiguredTooling.new("Yarn", message)
442
+ },
443
+ in_usage: true,
444
+ matchfn: nil
419
445
  },
420
- in_usage: true,
421
- matchfn: nil
422
- },
423
- {
424
- patterns: [TARBALL_IS_NOT_IN_NETWORK],
425
- handler: lambda { |message, _error, _params|
426
- Dependabot::DependencyFileNotResolvable.new(message)
446
+ {
447
+ patterns: [TARBALL_IS_NOT_IN_NETWORK],
448
+ handler: lambda { |message, _error, _params|
449
+ Dependabot::DependencyFileNotResolvable.new(message)
450
+ },
451
+ in_usage: false,
452
+ matchfn: nil
427
453
  },
428
- in_usage: false,
429
- matchfn: nil
430
- },
431
- {
432
- patterns: [NODE_VERSION_NOT_SATISFY_REGEX],
433
- handler: lambda { |message, _error, _params|
434
- versions = Utils.extract_node_versions(message)
435
- current_version = versions[:current_version]
436
- required_version = versions[:required_version]
437
-
438
- return Dependabot::DependabotError.new(message) unless current_version && required_version
439
-
440
- Dependabot::ToolVersionNotSupported.new("Yarn", current_version, required_version)
454
+ {
455
+ patterns: [NODE_VERSION_NOT_SATISFY_REGEX],
456
+ handler: lambda { |message, _error, _params|
457
+ versions = Utils.extract_node_versions(message)
458
+ current_version = versions[:current_version]
459
+ required_version = versions[:required_version]
460
+
461
+ return Dependabot::DependabotError.new(message) unless current_version && required_version
462
+
463
+ Dependabot::ToolVersionNotSupported.new("Yarn", current_version, required_version)
464
+ },
465
+ in_usage: false,
466
+ matchfn: nil
441
467
  },
442
- in_usage: false,
443
- matchfn: nil
444
- },
445
- {
446
- patterns: [AUTHENTICATION_TOKEN_NOT_PROVIDED, AUTHENTICATION_IS_NOT_CONFIGURED,
447
- AUTHENTICATION_HEADER_NOT_PROVIDED],
448
- handler: lambda { |message, _error, _params|
449
- Dependabot::PrivateSourceAuthenticationFailure.new(message)
450
- },
451
- in_usage: false,
452
- matchfn: nil
453
- },
454
- {
455
- patterns: [DEPENDENCY_FILE_NOT_RESOLVABLE],
456
- handler: lambda { |message, _error, _params|
457
- DependencyFileNotResolvable.new(message)
468
+ {
469
+ patterns: [AUTHENTICATION_TOKEN_NOT_PROVIDED, AUTHENTICATION_IS_NOT_CONFIGURED,
470
+ AUTHENTICATION_HEADER_NOT_PROVIDED],
471
+ handler: lambda { |message, _error, _params|
472
+ Dependabot::PrivateSourceAuthenticationFailure.new(message)
473
+ },
474
+ in_usage: false,
475
+ matchfn: nil
458
476
  },
459
- in_usage: false,
460
- matchfn: nil
461
- },
462
- {
463
- patterns: [ENV_VAR_NOT_RESOLVABLE],
464
- handler: lambda { |message, _error, _params|
465
- var = Utils.extract_var(message)
466
-
467
- Dependabot::MissingEnvironmentVariable.new(var, message)
477
+ {
478
+ patterns: [DEPENDENCY_FILE_NOT_RESOLVABLE],
479
+ handler: lambda { |message, _error, _params|
480
+ DependencyFileNotResolvable.new(message)
481
+ },
482
+ in_usage: false,
483
+ matchfn: nil
468
484
  },
469
- in_usage: false,
470
- matchfn: nil
471
- },
472
- {
473
- patterns: [ONLY_PRIVATE_WORKSPACE_TEXT],
474
- handler: lambda { |message, _error, _params|
475
- Dependabot::DependencyFileNotEvaluatable.new(message)
485
+ {
486
+ patterns: [ENV_VAR_NOT_RESOLVABLE],
487
+ handler: lambda { |message, _error, _params|
488
+ var = Utils.extract_var(message)
489
+
490
+ Dependabot::MissingEnvironmentVariable.new(var, message)
491
+ },
492
+ in_usage: false,
493
+ matchfn: nil
476
494
  },
477
- in_usage: false,
478
- matchfn: nil
479
- },
480
- {
481
- patterns: [UNREACHABLE_GIT_CHECK_REGEX],
482
- handler: lambda { |message, _error, _params|
483
- dependency_url = message.match(UNREACHABLE_GIT_CHECK_REGEX).named_captures.fetch(URL_CAPTURE)
484
-
485
- Dependabot::GitDependenciesNotReachable.new(dependency_url)
495
+ {
496
+ patterns: [ONLY_PRIVATE_WORKSPACE_TEXT],
497
+ handler: lambda { |message, _error, _params|
498
+ Dependabot::DependencyFileNotEvaluatable.new(message)
499
+ },
500
+ in_usage: false,
501
+ matchfn: nil
486
502
  },
487
- in_usage: false,
488
- matchfn: nil
489
- },
490
- {
491
- patterns: [SOCKET_HANG_UP],
492
- handler: lambda { |message, _error, _params|
493
- url = message.match(SOCKET_HANG_UP).named_captures.fetch(URL_CAPTURE)
494
-
495
- Dependabot::PrivateSourceTimedOut.new(url.gsub(HTTP_CHECK_REGEX, ""))
503
+ {
504
+ patterns: [UNREACHABLE_GIT_CHECK_REGEX],
505
+ handler: lambda { |message, _error, _params|
506
+ dependency_url = message.match(UNREACHABLE_GIT_CHECK_REGEX).named_captures.fetch(URL_CAPTURE)
507
+
508
+ Dependabot::GitDependenciesNotReachable.new(dependency_url)
509
+ },
510
+ in_usage: false,
511
+ matchfn: nil
496
512
  },
497
- in_usage: false,
498
- matchfn: nil
499
- },
500
- {
501
- patterns: [ESOCKETTIMEDOUT],
502
- handler: lambda { |message, _error, _params|
503
- package_req = message.match(ESOCKETTIMEDOUT).named_captures.fetch("package")
504
-
505
- Dependabot::PrivateSourceTimedOut.new(package_req.gsub(HTTP_CHECK_REGEX, ""))
513
+ {
514
+ patterns: [SOCKET_HANG_UP],
515
+ handler: lambda { |message, _error, _params|
516
+ url = message.match(SOCKET_HANG_UP).named_captures.fetch(URL_CAPTURE)
517
+
518
+ Dependabot::PrivateSourceTimedOut.new(url.gsub(HTTP_CHECK_REGEX, ""))
519
+ },
520
+ in_usage: false,
521
+ matchfn: nil
506
522
  },
507
- in_usage: false,
508
- matchfn: nil
509
- },
510
- {
511
- patterns: [OUT_OF_DISKSPACE],
512
- handler: lambda { |message, _error, _params|
513
- Dependabot::OutOfDisk.new(message)
523
+ {
524
+ patterns: [ESOCKETTIMEDOUT],
525
+ handler: lambda { |message, _error, _params|
526
+ package_req = message.match(ESOCKETTIMEDOUT).named_captures.fetch("package")
527
+
528
+ Dependabot::PrivateSourceTimedOut.new(package_req.gsub(HTTP_CHECK_REGEX, ""))
529
+ },
530
+ in_usage: false,
531
+ matchfn: nil
514
532
  },
515
- in_usage: false,
516
- matchfn: nil
517
- },
518
- {
519
- patterns: [YARNRC_PARSE_ERROR],
520
- handler: lambda { |message, _error, _params|
521
- filename = message.match(YARNRC_PARSE_ERROR).named_captures["filename"]
522
-
523
- msg = "Error while loading \"#{filename.split('/').last}\"."
524
- Dependabot::DependencyFileNotResolvable.new(msg)
533
+ {
534
+ patterns: [OUT_OF_DISKSPACE],
535
+ handler: lambda { |message, _error, _params|
536
+ Dependabot::OutOfDisk.new(message)
537
+ },
538
+ in_usage: false,
539
+ matchfn: nil
525
540
  },
526
- in_usage: false,
527
- matchfn: nil
528
- },
529
- {
530
- patterns: [YARNRC_ENV_NOT_FOUND],
531
- handler: lambda { |message, _error, _params|
532
- error_message = message.gsub(/[[:space:]]+/, " ").strip
541
+ {
542
+ patterns: [YARNRC_PARSE_ERROR],
543
+ handler: lambda { |message, _error, _params|
544
+ filename = message.match(YARNRC_PARSE_ERROR).named_captures["filename"]
545
+
546
+ msg = "Error while loading \"#{filename.split('/').last}\"."
547
+ Dependabot::DependencyFileNotResolvable.new(msg)
548
+ },
549
+ in_usage: false,
550
+ matchfn: nil
551
+ },
552
+ {
553
+ patterns: [YARNRC_ENV_NOT_FOUND],
554
+ handler: lambda { |message, _error, _params|
555
+ error_message = message.gsub(/[[:space:]]+/, " ").strip
533
556
 
534
- filename = error_message.match(YARNRC_ENV_NOT_FOUND_REGEX)
535
- .named_captures["filename"]
557
+ filename = error_message.match(YARNRC_ENV_NOT_FOUND_REGEX)
558
+ .named_captures["filename"]
536
559
 
537
- env_var = error_message.match(YARNRC_ENV_NOT_FOUND_REGEX)
538
- .named_captures["token"]
560
+ env_var = error_message.match(YARNRC_ENV_NOT_FOUND_REGEX)
561
+ .named_captures["token"]
539
562
 
540
- msg = "Environment variable \"#{env_var}\" not found in \"#{filename.split('/').last}\"."
541
- Dependabot::MissingEnvironmentVariable.new(env_var, msg)
563
+ msg = "Environment variable \"#{env_var}\" not found in \"#{filename.split('/').last}\"."
564
+ Dependabot::MissingEnvironmentVariable.new(env_var, msg)
565
+ },
566
+ in_usage: false,
567
+ matchfn: nil
542
568
  },
543
- in_usage: false,
544
- matchfn: nil
545
- },
546
- {
547
- patterns: [YARNRC_EAI_AGAIN],
548
- handler: lambda { |_message, _error, _params|
549
- Dependabot::DependencyFileNotResolvable.new("Network error while resolving dependency.")
569
+ {
570
+ patterns: [YARNRC_EAI_AGAIN],
571
+ handler: lambda { |_message, _error, _params|
572
+ Dependabot::DependencyFileNotResolvable.new("Network error while resolving dependency.")
573
+ },
574
+ in_usage: false,
575
+ matchfn: nil
550
576
  },
551
- in_usage: false,
552
- matchfn: nil
553
- },
554
- {
555
- patterns: [YARNRC_ENOENT],
556
- handler: lambda { |message, _error, _params|
557
- error_message = message.gsub(/[[:space:]]+/, " ").strip
558
- filename = error_message.match(YARNRC_ENOENT_REGEX).named_captures["filename"]
559
-
560
- Dependabot::DependencyFileNotResolvable.new("Internal error while resolving dependency." \
561
- "File not found \"#{filename.split('/').last}\"")
577
+ {
578
+ patterns: [YARNRC_ENOENT],
579
+ handler: lambda { |message, _error, _params|
580
+ error_message = message.gsub(/[[:space:]]+/, " ").strip
581
+ filename = error_message.match(YARNRC_ENOENT_REGEX).named_captures["filename"]
582
+
583
+ Dependabot::DependencyFileNotResolvable.new(
584
+ "Internal error while resolving dependency." \
585
+ "File not found \"#{filename.split('/').last}\""
586
+ )
587
+ },
588
+ in_usage: false,
589
+ matchfn: nil
562
590
  },
563
- in_usage: false,
564
- matchfn: nil
565
- },
566
- {
567
- patterns: [YARN_PACKAGE_NOT_FOUND],
568
- handler: lambda { |message, _error, _params|
569
- package_name = message.match(YARN_PACKAGE_NOT_FOUND).named_captures["pkg"]
570
- version = message.match(YARN_PACKAGE_NOT_FOUND).named_captures["ver"]
571
-
572
- Dependabot::InconsistentRegistryResponse.new("Couldn't find any versions for \"#{package_name}\" that " \
573
- "matches \"#{version}\"")
591
+ {
592
+ patterns: [YARN_PACKAGE_NOT_FOUND],
593
+ handler: lambda { |message, _error, _params|
594
+ package_name = message.match(YARN_PACKAGE_NOT_FOUND).named_captures["pkg"]
595
+ version = message.match(YARN_PACKAGE_NOT_FOUND).named_captures["ver"]
596
+
597
+ Dependabot::InconsistentRegistryResponse.new(
598
+ "Couldn't find any versions for \"#{package_name}\" that " \
599
+ "matches \"#{version}\""
600
+ )
601
+ },
602
+ in_usage: false,
603
+ matchfn: nil
574
604
  },
575
- in_usage: false,
576
- matchfn: nil
577
- },
578
- {
579
- patterns: [YARN_PACKAGE_NOT_FOUND_CODE, YARN_PACKAGE_NOT_FOUND_CODE_1, YARN_PACKAGE_NOT_FOUND_CODE_2],
580
- handler: lambda { |message, _error, _params|
581
- msg = message.match(YARN_PACKAGE_NOT_FOUND_CODE) || message.match(YARN_PACKAGE_NOT_FOUND_CODE_1) ||
582
- message.match(YARN_PACKAGE_NOT_FOUND_CODE_2)
583
-
584
- Dependabot::DependencyFileNotResolvable.new(msg)
605
+ {
606
+ patterns: [YARN_PACKAGE_NOT_FOUND_CODE, YARN_PACKAGE_NOT_FOUND_CODE_1, YARN_PACKAGE_NOT_FOUND_CODE_2],
607
+ handler: lambda { |message, _error, _params|
608
+ msg = message.match(YARN_PACKAGE_NOT_FOUND_CODE) || message.match(YARN_PACKAGE_NOT_FOUND_CODE_1) ||
609
+ message.match(YARN_PACKAGE_NOT_FOUND_CODE_2)
610
+
611
+ Dependabot::DependencyFileNotResolvable.new(msg)
612
+ },
613
+ in_usage: false,
614
+ matchfn: nil
585
615
  },
586
- in_usage: false,
587
- matchfn: nil
588
- },
589
- {
590
- patterns: [REQUEST_ERROR_E403, AUTH_REQUIRED_ERROR, PERMISSION_DENIED, BAD_REQUEST],
591
- handler: lambda { |message, _error, _params|
592
- dependency_url = T.must(URI.decode_www_form_component(message).split("https://").last).split("/").first
593
-
594
- Dependabot::PrivateSourceAuthenticationFailure.new(dependency_url)
616
+ {
617
+ patterns: [REQUEST_ERROR_E403, AUTH_REQUIRED_ERROR, PERMISSION_DENIED, BAD_REQUEST],
618
+ handler: lambda { |message, _error, _params|
619
+ dependency_url = T.must(URI.decode_www_form_component(message).split("https://").last).split("/").first
620
+
621
+ Dependabot::PrivateSourceAuthenticationFailure.new(dependency_url)
622
+ },
623
+ in_usage: false,
624
+ matchfn: nil
595
625
  },
596
- in_usage: false,
597
- matchfn: nil
598
- },
599
- {
600
- patterns: [MANIFEST_NOT_FOUND],
601
- handler: lambda { |message, _error, _params|
602
- msg = message.match(MANIFEST_NOT_FOUND)
603
- Dependabot::DependencyFileNotResolvable.new(msg)
604
- },
605
- in_usage: false,
606
- matchfn: nil
607
- },
608
- {
609
- patterns: [INTERNAL_SERVER_ERROR],
610
- handler: lambda { |message, _error, _params|
611
- msg = message.match(INTERNAL_SERVER_ERROR)
612
- Dependabot::DependencyFileNotResolvable.new(msg)
613
- },
614
- in_usage: false,
615
- matchfn: nil
616
- },
617
- {
618
- patterns: [REGISTRY_NOT_REACHABLE],
619
- handler: lambda { |message, _error, _params|
620
- msg = message.match(REGISTRY_NOT_REACHABLE)
621
- Dependabot::DependencyFileNotResolvable.new(msg)
622
- },
623
- in_usage: false,
624
- matchfn: nil
625
- }
626
- ].freeze, T::Array[{
627
- patterns: T::Array[T.any(String, Regexp)],
628
- handler: ErrorHandler,
629
- in_usage: T.nilable(T::Boolean),
630
- matchfn: T.nilable(T.proc.params(usage: String, message: String).returns(T::Boolean))
631
- }])
626
+ {
627
+ patterns: [MANIFEST_NOT_FOUND],
628
+ handler: lambda { |message, _error, _params|
629
+ msg = message.match(MANIFEST_NOT_FOUND)
630
+ Dependabot::DependencyFileNotResolvable.new(msg)
631
+ },
632
+ in_usage: false,
633
+ matchfn: nil
634
+ },
635
+ {
636
+ patterns: [INTERNAL_SERVER_ERROR],
637
+ handler: lambda { |message, _error, _params|
638
+ msg = message.match(INTERNAL_SERVER_ERROR)
639
+ Dependabot::DependencyFileNotResolvable.new(msg)
640
+ },
641
+ in_usage: false,
642
+ matchfn: nil
643
+ },
644
+ {
645
+ patterns: [REGISTRY_NOT_REACHABLE],
646
+ handler: lambda { |message, _error, _params|
647
+ msg = message.match(REGISTRY_NOT_REACHABLE)
648
+ Dependabot::DependencyFileNotResolvable.new(msg)
649
+ },
650
+ in_usage: false,
651
+ matchfn: nil
652
+ }
653
+ ].freeze,
654
+ T::Array[{
655
+ patterns: T::Array[T.any(String, Regexp)],
656
+ handler: ErrorHandler,
657
+ in_usage: T.nilable(T::Boolean),
658
+ matchfn: T.nilable(T.proc.params(usage: String, message: String).returns(T::Boolean))
659
+ }]
660
+ )
632
661
  end
633
662
  # rubocop:enable Metrics/ModuleLength
634
663
  end