dependabot-npm_and_yarn 0.348.1 → 0.349.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.
- checksums.yaml +4 -4
- data/lib/dependabot/npm_and_yarn/file_fetcher.rb +1 -32
- data/lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb +3 -11
- data/lib/dependabot/npm_and_yarn/file_parser.rb +1 -12
- data/lib/dependabot/npm_and_yarn/file_updater.rb +0 -44
- data/lib/dependabot/npm_and_yarn/helpers.rb +0 -40
- data/lib/dependabot/npm_and_yarn/package_manager.rb +2 -7
- data/lib/dependabot/npm_and_yarn/update_checker/dependency_files_builder.rb +2 -20
- data/lib/dependabot/npm_and_yarn/update_checker/subdependency_version_resolver.rb +0 -15
- data/lib/dependabot/npm_and_yarn/update_checker/version_resolver.rb +0 -23
- metadata +4 -7
- data/lib/dependabot/npm_and_yarn/bun_package_manager.rb +0 -47
- data/lib/dependabot/npm_and_yarn/file_parser/bun_lock.rb +0 -140
- data/lib/dependabot/npm_and_yarn/file_updater/bun_lockfile_updater.rb +0 -185
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4e43ee5991e6cea99e308855eb218a880627a403e38f5d629b34182b63f810e
|
|
4
|
+
data.tar.gz: 7860c1f505810459902cf13ff518f355fecf40e408d401f5536f32409165b12a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 15a4161403d48cc7e18988c67b87d104feeeb649ec78df51178475badc7d86aee54ec03f0266179db78d2ce6a5d72bcb5e2a6ec01010baf34e509f78df4400f1
|
|
7
|
+
data.tar.gz: 13d3c213858a113a55a91fce77ca257609e634393adcac8716db3270033f63a86f7b176e04c4e7fbed9d95f08275a674043c89d00b2f2ec24604f30a0bc59c53
|
|
@@ -71,7 +71,6 @@ module Dependabot
|
|
|
71
71
|
package_managers["npm"] = npm_version if npm_version
|
|
72
72
|
package_managers["yarn"] = yarn_version if yarn_version
|
|
73
73
|
package_managers["pnpm"] = pnpm_version if pnpm_version
|
|
74
|
-
package_managers["bun"] = bun_version if bun_version
|
|
75
74
|
package_managers["unknown"] = 1 if package_managers.empty?
|
|
76
75
|
|
|
77
76
|
{
|
|
@@ -87,7 +86,6 @@ module Dependabot
|
|
|
87
86
|
fetched_files += npm_files if npm_version
|
|
88
87
|
fetched_files += yarn_files if yarn_version
|
|
89
88
|
fetched_files += pnpm_files if pnpm_version
|
|
90
|
-
fetched_files += bun_files if bun_version
|
|
91
89
|
fetched_files += lerna_files
|
|
92
90
|
fetched_files += workspace_package_jsons
|
|
93
91
|
fetched_files += path_dependencies(fetched_files)
|
|
@@ -131,13 +129,6 @@ module Dependabot
|
|
|
131
129
|
fetched_pnpm_files
|
|
132
130
|
end
|
|
133
131
|
|
|
134
|
-
sig { returns(T::Array[DependencyFile]) }
|
|
135
|
-
def bun_files
|
|
136
|
-
fetched_bun_files = []
|
|
137
|
-
fetched_bun_files << bun_lock if bun_lock
|
|
138
|
-
fetched_bun_files
|
|
139
|
-
end
|
|
140
|
-
|
|
141
132
|
sig { returns(T::Array[DependencyFile]) }
|
|
142
133
|
def lerna_files
|
|
143
134
|
fetched_lerna_files = []
|
|
@@ -222,16 +213,6 @@ module Dependabot
|
|
|
222
213
|
)
|
|
223
214
|
end
|
|
224
215
|
|
|
225
|
-
sig { returns(T.nilable(T.any(Integer, String))) }
|
|
226
|
-
def bun_version
|
|
227
|
-
return @bun_version = nil unless allow_beta_ecosystems?
|
|
228
|
-
|
|
229
|
-
@bun_version ||= T.let(
|
|
230
|
-
package_manager_helper.setup(BunPackageManager::NAME),
|
|
231
|
-
T.nilable(T.any(Integer, String))
|
|
232
|
-
)
|
|
233
|
-
end
|
|
234
|
-
|
|
235
216
|
sig { returns(PackageManagerHelper) }
|
|
236
217
|
def package_manager_helper
|
|
237
218
|
@package_manager_helper ||= T.let(
|
|
@@ -250,8 +231,7 @@ module Dependabot
|
|
|
250
231
|
{
|
|
251
232
|
npm: package_lock || shrinkwrap,
|
|
252
233
|
yarn: yarn_lock,
|
|
253
|
-
pnpm: pnpm_lock
|
|
254
|
-
bun: bun_lock
|
|
234
|
+
pnpm: pnpm_lock
|
|
255
235
|
}
|
|
256
236
|
end
|
|
257
237
|
|
|
@@ -296,17 +276,6 @@ module Dependabot
|
|
|
296
276
|
@pnpm_lock = fetch_file_from_parent_directories(PNPMPackageManager::LOCKFILE_NAME)
|
|
297
277
|
end
|
|
298
278
|
|
|
299
|
-
sig { returns(T.nilable(DependencyFile)) }
|
|
300
|
-
def bun_lock
|
|
301
|
-
return @bun_lock if defined?(@bun_lock)
|
|
302
|
-
|
|
303
|
-
@bun_lock ||= T.let(fetch_file_if_present(BunPackageManager::LOCKFILE_NAME), T.nilable(DependencyFile))
|
|
304
|
-
|
|
305
|
-
return @bun_lock if @bun_lock || directory == "/"
|
|
306
|
-
|
|
307
|
-
@bun_lock = fetch_file_from_parent_directories(BunPackageManager::LOCKFILE_NAME)
|
|
308
|
-
end
|
|
309
|
-
|
|
310
279
|
sig { returns(T.nilable(DependencyFile)) }
|
|
311
280
|
def shrinkwrap
|
|
312
281
|
return @shrinkwrap if defined?(@shrinkwrap)
|
|
@@ -15,11 +15,10 @@ module Dependabot
|
|
|
15
15
|
require "dependabot/npm_and_yarn/file_parser/yarn_lock"
|
|
16
16
|
require "dependabot/npm_and_yarn/file_parser/pnpm_lock"
|
|
17
17
|
require "dependabot/npm_and_yarn/file_parser/json_lock"
|
|
18
|
-
require "dependabot/npm_and_yarn/file_parser/bun_lock"
|
|
19
18
|
|
|
20
|
-
DEFAULT_LOCKFILES = %w(package-lock.json yarn.lock pnpm-lock.yaml
|
|
19
|
+
DEFAULT_LOCKFILES = %w(package-lock.json yarn.lock pnpm-lock.yaml npm-shrinkwrap.json).freeze
|
|
21
20
|
|
|
22
|
-
LockFile = T.type_alias { T.any(JsonLock, YarnLock, PnpmLock
|
|
21
|
+
LockFile = T.type_alias { T.any(JsonLock, YarnLock, PnpmLock) }
|
|
23
22
|
|
|
24
23
|
sig { params(dependency_files: T::Array[DependencyFile]).void }
|
|
25
24
|
def initialize(dependency_files:)
|
|
@@ -34,7 +33,7 @@ module Dependabot
|
|
|
34
33
|
# end up unique by name. That's not a perfect representation of
|
|
35
34
|
# the nested nature of JS resolution, but it makes everything work
|
|
36
35
|
# comparably to other flat-resolution strategies
|
|
37
|
-
(yarn_locks + pnpm_locks + package_locks +
|
|
36
|
+
(yarn_locks + pnpm_locks + package_locks + shrinkwraps).each do |file|
|
|
38
37
|
dependency_set += lockfile_for(file).dependencies
|
|
39
38
|
end
|
|
40
39
|
|
|
@@ -87,8 +86,6 @@ module Dependabot
|
|
|
87
86
|
YarnLock.new(file)
|
|
88
87
|
when *pnpm_locks.map(&:name)
|
|
89
88
|
PnpmLock.new(file)
|
|
90
|
-
when *bun_locks.map(&:name)
|
|
91
|
-
BunLock.new(file)
|
|
92
89
|
else
|
|
93
90
|
raise "Unexpected lockfile: #{file.name}"
|
|
94
91
|
end
|
|
@@ -109,11 +106,6 @@ module Dependabot
|
|
|
109
106
|
@pnpm_locks ||= T.let(select_files_by_extension("pnpm-lock.yaml"), T.nilable(T::Array[DependencyFile]))
|
|
110
107
|
end
|
|
111
108
|
|
|
112
|
-
sig { returns(T::Array[DependencyFile]) }
|
|
113
|
-
def bun_locks
|
|
114
|
-
@bun_locks ||= T.let(select_files_by_extension("bun.lock"), T.nilable(T::Array[DependencyFile]))
|
|
115
|
-
end
|
|
116
|
-
|
|
117
109
|
sig { returns(T::Array[DependencyFile]) }
|
|
118
110
|
def yarn_locks
|
|
119
111
|
@yarn_locks ||= T.let(select_files_by_extension("yarn.lock"), T.nilable(T::Array[DependencyFile]))
|
|
@@ -112,8 +112,7 @@ module Dependabot
|
|
|
112
112
|
{
|
|
113
113
|
npm: package_lock || shrinkwrap,
|
|
114
114
|
yarn: yarn_lock,
|
|
115
|
-
pnpm: pnpm_lock
|
|
116
|
-
bun: bun_lock
|
|
115
|
+
pnpm: pnpm_lock
|
|
117
116
|
}
|
|
118
117
|
end
|
|
119
118
|
|
|
@@ -192,16 +191,6 @@ module Dependabot
|
|
|
192
191
|
)
|
|
193
192
|
end
|
|
194
193
|
|
|
195
|
-
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
196
|
-
def bun_lock
|
|
197
|
-
@bun_lock ||= T.let(
|
|
198
|
-
dependency_files.find do |f|
|
|
199
|
-
f.name.end_with?(BunPackageManager::LOCKFILE_NAME)
|
|
200
|
-
end,
|
|
201
|
-
T.nilable(Dependabot::DependencyFile)
|
|
202
|
-
)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
194
|
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
206
195
|
def npmrc
|
|
207
196
|
@npmrc ||= T.let(
|
|
@@ -18,7 +18,6 @@ module Dependabot
|
|
|
18
18
|
require_relative "file_updater/npm_lockfile_updater"
|
|
19
19
|
require_relative "file_updater/yarn_lockfile_updater"
|
|
20
20
|
require_relative "file_updater/pnpm_lockfile_updater"
|
|
21
|
-
require_relative "file_updater/bun_lockfile_updater"
|
|
22
21
|
require_relative "file_updater/pnpm_workspace_updater"
|
|
23
22
|
|
|
24
23
|
class NoChangeError < StandardError
|
|
@@ -275,15 +274,6 @@ module Dependabot
|
|
|
275
274
|
)
|
|
276
275
|
end
|
|
277
276
|
|
|
278
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
279
|
-
def bun_locks
|
|
280
|
-
@bun_locks ||= T.let(
|
|
281
|
-
filtered_dependency_files
|
|
282
|
-
.select { |f| f.name.end_with?("bun.lock") },
|
|
283
|
-
T.nilable(T::Array[Dependabot::DependencyFile])
|
|
284
|
-
)
|
|
285
|
-
end
|
|
286
|
-
|
|
287
277
|
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
288
278
|
def shrinkwraps
|
|
289
279
|
@shrinkwraps ||= T.let(
|
|
@@ -313,11 +303,6 @@ module Dependabot
|
|
|
313
303
|
pnpm_lock.content != updated_pnpm_lock_content(pnpm_lock)
|
|
314
304
|
end
|
|
315
305
|
|
|
316
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(T::Boolean) }
|
|
317
|
-
def bun_lock_changed?(bun_lock)
|
|
318
|
-
bun_lock.content != updated_bun_lock_content(bun_lock)
|
|
319
|
-
end
|
|
320
|
-
|
|
321
306
|
sig { params(package_lock: Dependabot::DependencyFile).returns(T::Boolean) }
|
|
322
307
|
def package_lock_changed?(package_lock)
|
|
323
308
|
package_lock.content != updated_lockfile_content(package_lock)
|
|
@@ -363,15 +348,6 @@ module Dependabot
|
|
|
363
348
|
|
|
364
349
|
updated_files.concat(update_pnpm_locks)
|
|
365
350
|
|
|
366
|
-
bun_locks.each do |bun_lock|
|
|
367
|
-
next unless bun_lock_changed?(bun_lock)
|
|
368
|
-
|
|
369
|
-
updated_files << updated_file(
|
|
370
|
-
file: bun_lock,
|
|
371
|
-
content: updated_bun_lock_content(bun_lock)
|
|
372
|
-
)
|
|
373
|
-
end
|
|
374
|
-
|
|
375
351
|
package_locks.each do |package_lock|
|
|
376
352
|
next unless package_lock_changed?(package_lock)
|
|
377
353
|
|
|
@@ -409,13 +385,6 @@ module Dependabot
|
|
|
409
385
|
)
|
|
410
386
|
end
|
|
411
387
|
|
|
412
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(String) }
|
|
413
|
-
def updated_bun_lock_content(bun_lock)
|
|
414
|
-
@updated_bun_lock_content ||= T.let({}, T.nilable(T::Hash[String, T.nilable(String)]))
|
|
415
|
-
@updated_bun_lock_content[bun_lock.name] ||=
|
|
416
|
-
bun_lockfile_updater.updated_bun_lock_content(bun_lock)
|
|
417
|
-
end
|
|
418
|
-
|
|
419
388
|
sig { returns(Dependabot::NpmAndYarn::FileUpdater::YarnLockfileUpdater) }
|
|
420
389
|
def yarn_lockfile_updater
|
|
421
390
|
@yarn_lockfile_updater ||= T.let(
|
|
@@ -442,19 +411,6 @@ module Dependabot
|
|
|
442
411
|
)
|
|
443
412
|
end
|
|
444
413
|
|
|
445
|
-
sig { returns(Dependabot::NpmAndYarn::FileUpdater::BunLockfileUpdater) }
|
|
446
|
-
def bun_lockfile_updater
|
|
447
|
-
@bun_lockfile_updater ||= T.let(
|
|
448
|
-
BunLockfileUpdater.new(
|
|
449
|
-
dependencies: dependencies,
|
|
450
|
-
dependency_files: dependency_files,
|
|
451
|
-
repo_contents_path: T.must(repo_contents_path),
|
|
452
|
-
credentials: credentials
|
|
453
|
-
),
|
|
454
|
-
T.nilable(Dependabot::NpmAndYarn::FileUpdater::BunLockfileUpdater)
|
|
455
|
-
)
|
|
456
|
-
end
|
|
457
|
-
|
|
458
414
|
sig { params(file: Dependabot::DependencyFile).returns(T.nilable(String)) }
|
|
459
415
|
def updated_lockfile_content(file)
|
|
460
416
|
@updated_lockfile_content ||= T.let({}, T.nilable(T::Hash[String, T.nilable(String)]))
|
|
@@ -30,10 +30,6 @@ module Dependabot
|
|
|
30
30
|
PNPM_DEFAULT_VERSION = PNPM_V10
|
|
31
31
|
PNPM_FALLBACK_VERSION = PNPM_V6
|
|
32
32
|
|
|
33
|
-
# BUN Version Constants
|
|
34
|
-
BUN_V1 = 1
|
|
35
|
-
BUN_DEFAULT_VERSION = BUN_V1
|
|
36
|
-
|
|
37
33
|
# YARN Version Constants
|
|
38
34
|
YARN_V3 = 3
|
|
39
35
|
YARN_V2 = 2
|
|
@@ -115,11 +111,6 @@ module Dependabot
|
|
|
115
111
|
PNPM_FALLBACK_VERSION
|
|
116
112
|
end
|
|
117
113
|
|
|
118
|
-
sig { params(_bun_lock: T.nilable(DependencyFile)).returns(Integer) }
|
|
119
|
-
def self.bun_version_numeric(_bun_lock)
|
|
120
|
-
BUN_DEFAULT_VERSION
|
|
121
|
-
end
|
|
122
|
-
|
|
123
114
|
sig { params(key: String, default_value: String).returns(T.untyped) }
|
|
124
115
|
def self.fetch_yarnrc_yml_value(key, default_value)
|
|
125
116
|
if File.exist?(".yarnrc.yml") && (yarnrc = YAML.load_file(".yarnrc.yml"))
|
|
@@ -338,35 +329,6 @@ module Dependabot
|
|
|
338
329
|
raise
|
|
339
330
|
end
|
|
340
331
|
|
|
341
|
-
sig { returns(T.nilable(String)) }
|
|
342
|
-
def self.bun_version
|
|
343
|
-
version = run_bun_command("--version", fingerprint: "--version").strip
|
|
344
|
-
if version.include?("+")
|
|
345
|
-
version.split("+").first # Remove build info, if present
|
|
346
|
-
end
|
|
347
|
-
rescue StandardError => e
|
|
348
|
-
Dependabot.logger.error("Error retrieving Bun version: #{e.message}")
|
|
349
|
-
nil
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
sig { params(command: String, fingerprint: T.nilable(String)).returns(String) }
|
|
353
|
-
def self.run_bun_command(command, fingerprint: nil)
|
|
354
|
-
full_command = "bun #{command}"
|
|
355
|
-
|
|
356
|
-
Dependabot.logger.info("Running bun command: #{full_command}")
|
|
357
|
-
|
|
358
|
-
result = Dependabot::SharedHelpers.run_shell_command(
|
|
359
|
-
full_command,
|
|
360
|
-
fingerprint: "bun #{fingerprint || command}"
|
|
361
|
-
)
|
|
362
|
-
|
|
363
|
-
Dependabot.logger.info("Command executed successfully: #{full_command}")
|
|
364
|
-
result
|
|
365
|
-
rescue StandardError => e
|
|
366
|
-
Dependabot.logger.error("Error running bun command: #{full_command}, Error: #{e.message}")
|
|
367
|
-
raise
|
|
368
|
-
end
|
|
369
|
-
|
|
370
332
|
# Setup yarn and run a single yarn command returning stdout/stderr
|
|
371
333
|
sig { params(command: String, fingerprint: T.nilable(String)).returns(String) }
|
|
372
334
|
def self.run_yarn_command(command, fingerprint: nil)
|
|
@@ -525,8 +487,6 @@ module Dependabot
|
|
|
525
487
|
output_observer: nil,
|
|
526
488
|
env: nil
|
|
527
489
|
)
|
|
528
|
-
return run_bun_command(command, fingerprint: fingerprint) if name == BunPackageManager::NAME
|
|
529
|
-
|
|
530
490
|
full_command = "corepack #{name} #{command}"
|
|
531
491
|
fingerprint = "corepack #{name} #{fingerprint || command}"
|
|
532
492
|
|
|
@@ -9,7 +9,6 @@ require "dependabot/npm_and_yarn/registry_helper"
|
|
|
9
9
|
require "dependabot/npm_and_yarn/npm_package_manager"
|
|
10
10
|
require "dependabot/npm_and_yarn/yarn_package_manager"
|
|
11
11
|
require "dependabot/npm_and_yarn/pnpm_package_manager"
|
|
12
|
-
require "dependabot/npm_and_yarn/bun_package_manager"
|
|
13
12
|
require "dependabot/npm_and_yarn/language"
|
|
14
13
|
require "dependabot/npm_and_yarn/constraint_helper"
|
|
15
14
|
|
|
@@ -60,8 +59,7 @@ module Dependabot
|
|
|
60
59
|
T.any(
|
|
61
60
|
T.class_of(Dependabot::NpmAndYarn::NpmPackageManager),
|
|
62
61
|
T.class_of(Dependabot::NpmAndYarn::YarnPackageManager),
|
|
63
|
-
T.class_of(Dependabot::NpmAndYarn::PNPMPackageManager)
|
|
64
|
-
T.class_of(Dependabot::NpmAndYarn::BunPackageManager)
|
|
62
|
+
T.class_of(Dependabot::NpmAndYarn::PNPMPackageManager)
|
|
65
63
|
)
|
|
66
64
|
end
|
|
67
65
|
|
|
@@ -69,8 +67,7 @@ module Dependabot
|
|
|
69
67
|
{
|
|
70
68
|
NpmPackageManager::NAME => NpmPackageManager,
|
|
71
69
|
YarnPackageManager::NAME => YarnPackageManager,
|
|
72
|
-
PNPMPackageManager::NAME => PNPMPackageManager
|
|
73
|
-
BunPackageManager::NAME => BunPackageManager
|
|
70
|
+
PNPMPackageManager::NAME => PNPMPackageManager
|
|
74
71
|
}.freeze,
|
|
75
72
|
T::Hash[String, NpmAndYarnPackageManagerClassType]
|
|
76
73
|
)
|
|
@@ -482,8 +479,6 @@ module Dependabot
|
|
|
482
479
|
NpmPackageManager::SUPPORTED_VERSIONS
|
|
483
480
|
when "yarn"
|
|
484
481
|
YarnPackageManager::SUPPORTED_VERSIONS
|
|
485
|
-
when "bun"
|
|
486
|
-
BunPackageManager::SUPPORTED_VERSIONS
|
|
487
482
|
when "pnpm"
|
|
488
483
|
PNPMPackageManager::SUPPORTED_VERSIONS
|
|
489
484
|
end
|
|
@@ -71,15 +71,6 @@ module Dependabot
|
|
|
71
71
|
)
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
75
|
-
def bun_locks
|
|
76
|
-
@bun_locks ||= T.let(
|
|
77
|
-
dependency_files
|
|
78
|
-
.select { |f| f.name.end_with?("bun.lock") },
|
|
79
|
-
T.nilable(T::Array[Dependabot::DependencyFile])
|
|
80
|
-
)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
74
|
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
84
75
|
def root_yarn_lock
|
|
85
76
|
@root_yarn_lock ||= T.let(
|
|
@@ -98,15 +89,6 @@ module Dependabot
|
|
|
98
89
|
)
|
|
99
90
|
end
|
|
100
91
|
|
|
101
|
-
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
102
|
-
def root_bun_lock
|
|
103
|
-
@root_bun_lock ||= T.let(
|
|
104
|
-
dependency_files
|
|
105
|
-
.find { |f| f.name == "bun.lock" },
|
|
106
|
-
T.nilable(Dependabot::DependencyFile)
|
|
107
|
-
)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
92
|
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
111
93
|
def shrinkwraps
|
|
112
94
|
@shrinkwraps ||= T.let(
|
|
@@ -118,7 +100,7 @@ module Dependabot
|
|
|
118
100
|
|
|
119
101
|
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
120
102
|
def lockfiles
|
|
121
|
-
[*package_locks, *shrinkwraps, *yarn_locks, *pnpm_locks
|
|
103
|
+
[*package_locks, *shrinkwraps, *yarn_locks, *pnpm_locks]
|
|
122
104
|
end
|
|
123
105
|
|
|
124
106
|
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
@@ -148,7 +130,7 @@ module Dependabot
|
|
|
148
130
|
File.write(f.name, prepared_yarn_lockfile_content(T.must(f.content)))
|
|
149
131
|
end
|
|
150
132
|
|
|
151
|
-
[*package_locks, *shrinkwraps, *pnpm_locks
|
|
133
|
+
[*package_locks, *shrinkwraps, *pnpm_locks].each do |f|
|
|
152
134
|
FileUtils.mkdir_p(Pathname.new(f.name).dirname)
|
|
153
135
|
File.write(f.name, f.content)
|
|
154
136
|
end
|
|
@@ -102,8 +102,6 @@ module Dependabot
|
|
|
102
102
|
run_yarn_updater(path, lockfile_name)
|
|
103
103
|
elsif lockfile.name.end_with?("pnpm-lock.yaml")
|
|
104
104
|
run_pnpm_updater(path, lockfile_name)
|
|
105
|
-
elsif lockfile.name.end_with?("bun.lock")
|
|
106
|
-
run_bun_updater(path, lockfile_name)
|
|
107
105
|
elsif !Helpers.parse_npm8?(lockfile)
|
|
108
106
|
run_npm6_updater(path, lockfile_name)
|
|
109
107
|
else
|
|
@@ -195,19 +193,6 @@ module Dependabot
|
|
|
195
193
|
end
|
|
196
194
|
end
|
|
197
195
|
|
|
198
|
-
sig { params(path: String, lockfile_name: String).returns(T::Hash[String, String]) }
|
|
199
|
-
def run_bun_updater(path, lockfile_name)
|
|
200
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
|
201
|
-
Dir.chdir(path) do
|
|
202
|
-
Helpers.run_bun_command(
|
|
203
|
-
"update #{dependency.name} --save-text-lockfile",
|
|
204
|
-
fingerprint: "update <dependency_name> --save-text-lockfile"
|
|
205
|
-
)
|
|
206
|
-
{ lockfile_name => File.read(lockfile_name) }
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
196
|
sig { params(path: String, lockfile_name: String).returns(T::Hash[String, String]) }
|
|
212
197
|
def run_npm6_updater(path, lockfile_name)
|
|
213
198
|
SharedHelpers.with_git_configured(credentials: credentials) do
|
|
@@ -686,18 +686,12 @@ module Dependabot
|
|
|
686
686
|
npm_lockfiles = lockfiles_for_path(lockfiles: dependency_files_builder.package_locks, path: path)
|
|
687
687
|
return run_npm_checker(path: path, version: version) if npm_lockfiles.any?
|
|
688
688
|
|
|
689
|
-
bun_lockfiles = lockfiles_for_path(lockfiles: dependency_files_builder.bun_locks, path: path)
|
|
690
|
-
return run_bun_checker(path: path, version: version) if bun_lockfiles.any?
|
|
691
|
-
|
|
692
689
|
root_yarn_lock = dependency_files_builder.root_yarn_lock
|
|
693
690
|
return run_yarn_checker(path: path, version: version, lockfile: root_yarn_lock) if root_yarn_lock
|
|
694
691
|
|
|
695
692
|
root_pnpm_lock = dependency_files_builder.root_pnpm_lock
|
|
696
693
|
return run_pnpm_checker(path: path, version: version) if root_pnpm_lock
|
|
697
694
|
|
|
698
|
-
root_bun_lock = dependency_files_builder.root_bun_lock
|
|
699
|
-
return run_bun_checker(path: path, version: version) if root_bun_lock
|
|
700
|
-
|
|
701
695
|
run_npm_checker(path: path, version: version)
|
|
702
696
|
rescue SharedHelpers::HelperSubprocessFailed => e
|
|
703
697
|
handle_peer_dependency_errors(e.message)
|
|
@@ -739,23 +733,6 @@ module Dependabot
|
|
|
739
733
|
end
|
|
740
734
|
end
|
|
741
735
|
|
|
742
|
-
sig do
|
|
743
|
-
params(
|
|
744
|
-
path: String,
|
|
745
|
-
version: T.nilable(T.any(String, Gem::Version))
|
|
746
|
-
).returns(T.untyped)
|
|
747
|
-
end
|
|
748
|
-
def run_bun_checker(path:, version:)
|
|
749
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
|
750
|
-
Dir.chdir(path) do
|
|
751
|
-
Helpers.run_bun_command(
|
|
752
|
-
"update #{dependency.name}@#{version} --save-text-lockfile",
|
|
753
|
-
fingerprint: "update <dependency_name>@<version> --save-text-lockfile"
|
|
754
|
-
)
|
|
755
|
-
end
|
|
756
|
-
end
|
|
757
|
-
end
|
|
758
|
-
|
|
759
736
|
sig do
|
|
760
737
|
params(
|
|
761
738
|
path: String,
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-npm_and_yarn
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.349.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.349.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.349.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -311,19 +311,16 @@ files:
|
|
|
311
311
|
- helpers/test/yarn/helpers.js
|
|
312
312
|
- helpers/test/yarn/updater.test.js
|
|
313
313
|
- lib/dependabot/npm_and_yarn.rb
|
|
314
|
-
- lib/dependabot/npm_and_yarn/bun_package_manager.rb
|
|
315
314
|
- lib/dependabot/npm_and_yarn/constraint_helper.rb
|
|
316
315
|
- lib/dependabot/npm_and_yarn/dependency_files_filterer.rb
|
|
317
316
|
- lib/dependabot/npm_and_yarn/file_fetcher.rb
|
|
318
317
|
- lib/dependabot/npm_and_yarn/file_fetcher/path_dependency_builder.rb
|
|
319
318
|
- lib/dependabot/npm_and_yarn/file_parser.rb
|
|
320
|
-
- lib/dependabot/npm_and_yarn/file_parser/bun_lock.rb
|
|
321
319
|
- lib/dependabot/npm_and_yarn/file_parser/json_lock.rb
|
|
322
320
|
- lib/dependabot/npm_and_yarn/file_parser/lockfile_parser.rb
|
|
323
321
|
- lib/dependabot/npm_and_yarn/file_parser/pnpm_lock.rb
|
|
324
322
|
- lib/dependabot/npm_and_yarn/file_parser/yarn_lock.rb
|
|
325
323
|
- lib/dependabot/npm_and_yarn/file_updater.rb
|
|
326
|
-
- lib/dependabot/npm_and_yarn/file_updater/bun_lockfile_updater.rb
|
|
327
324
|
- lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb
|
|
328
325
|
- lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb
|
|
329
326
|
- lib/dependabot/npm_and_yarn/file_updater/package_json_preparer.rb
|
|
@@ -362,7 +359,7 @@ licenses:
|
|
|
362
359
|
- MIT
|
|
363
360
|
metadata:
|
|
364
361
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
365
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
362
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.349.0
|
|
366
363
|
rdoc_options: []
|
|
367
364
|
require_paths:
|
|
368
365
|
- lib
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# typed: strong
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
module Dependabot
|
|
5
|
-
module NpmAndYarn
|
|
6
|
-
class BunPackageManager < Ecosystem::VersionManager
|
|
7
|
-
extend T::Sig
|
|
8
|
-
|
|
9
|
-
NAME = "bun"
|
|
10
|
-
LOCKFILE_NAME = "bun.lock"
|
|
11
|
-
|
|
12
|
-
# In Bun 1.1.39, the lockfile format was changed from a binary bun.lockb to a text-based bun.lock.
|
|
13
|
-
# https://bun.sh/blog/bun-lock-text-lockfile
|
|
14
|
-
MIN_SUPPORTED_VERSION = Version.new("1.1.39")
|
|
15
|
-
SUPPORTED_VERSIONS = T.let([MIN_SUPPORTED_VERSION].freeze, T::Array[Dependabot::Version])
|
|
16
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version])
|
|
17
|
-
|
|
18
|
-
sig do
|
|
19
|
-
params(
|
|
20
|
-
detected_version: T.nilable(String),
|
|
21
|
-
raw_version: T.nilable(String),
|
|
22
|
-
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement)
|
|
23
|
-
).void
|
|
24
|
-
end
|
|
25
|
-
def initialize(detected_version: nil, raw_version: nil, requirement: nil)
|
|
26
|
-
super(
|
|
27
|
-
name: NAME,
|
|
28
|
-
detected_version: detected_version ? Version.new(detected_version) : nil,
|
|
29
|
-
version: raw_version ? Version.new(raw_version) : nil,
|
|
30
|
-
deprecated_versions: DEPRECATED_VERSIONS,
|
|
31
|
-
supported_versions: SUPPORTED_VERSIONS,
|
|
32
|
-
requirement: requirement
|
|
33
|
-
)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
sig { override.returns(T::Boolean) }
|
|
37
|
-
def deprecated?
|
|
38
|
-
false
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
sig { override.returns(T::Boolean) }
|
|
42
|
-
def unsupported?
|
|
43
|
-
false
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# typed: strict
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "yaml"
|
|
5
|
-
require "dependabot/errors"
|
|
6
|
-
require "dependabot/npm_and_yarn/helpers"
|
|
7
|
-
require "sorbet-runtime"
|
|
8
|
-
|
|
9
|
-
module Dependabot
|
|
10
|
-
module NpmAndYarn
|
|
11
|
-
class FileParser < Dependabot::FileParsers::Base
|
|
12
|
-
class BunLock
|
|
13
|
-
extend T::Sig
|
|
14
|
-
|
|
15
|
-
sig { params(dependency_file: DependencyFile).void }
|
|
16
|
-
def initialize(dependency_file)
|
|
17
|
-
@dependency_file = dependency_file
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
sig { returns(T::Hash[String, T.untyped]) }
|
|
21
|
-
def parsed
|
|
22
|
-
@parsed ||= begin
|
|
23
|
-
content = begin
|
|
24
|
-
# Since bun.lock is a JSONC file, which is a subset of YAML, we can use YAML to parse it
|
|
25
|
-
YAML.load(T.must(@dependency_file.content))
|
|
26
|
-
rescue Psych::SyntaxError => e
|
|
27
|
-
raise_invalid!("malformed JSONC at line #{e.line}, column #{e.column}")
|
|
28
|
-
end
|
|
29
|
-
raise_invalid!("expected to be an object") unless content.is_a?(Hash)
|
|
30
|
-
|
|
31
|
-
version = content["lockfileVersion"]
|
|
32
|
-
raise_invalid!("expected 'lockfileVersion' to be an integer") unless version.is_a?(Integer)
|
|
33
|
-
raise_invalid!("expected 'lockfileVersion' to be >= 0") unless version >= 0
|
|
34
|
-
|
|
35
|
-
T.let(content, T.untyped)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
sig { returns(Dependabot::FileParsers::Base::DependencySet) }
|
|
40
|
-
def dependencies
|
|
41
|
-
dependency_set = Dependabot::FileParsers::Base::DependencySet.new
|
|
42
|
-
|
|
43
|
-
# bun.lock v0 format:
|
|
44
|
-
# https://github.com/oven-sh/bun/blob/c130df6c589fdf28f9f3c7f23ed9901140bc9349/src/install/bun.lock.zig#L595-L605
|
|
45
|
-
|
|
46
|
-
packages = parsed["packages"]
|
|
47
|
-
raise_invalid!("expected 'packages' to be an object") unless packages.is_a?(Hash)
|
|
48
|
-
|
|
49
|
-
packages.each do |key, details|
|
|
50
|
-
raise_invalid!("expected 'packages.#{key}' to be an array") unless details.is_a?(Array)
|
|
51
|
-
|
|
52
|
-
resolution = details.first
|
|
53
|
-
raise_invalid!("expected 'packages.#{key}[0]' to be a string") unless resolution.is_a?(String)
|
|
54
|
-
|
|
55
|
-
name, version = resolution.split(/(?<=\w)\@/)
|
|
56
|
-
next if name.empty?
|
|
57
|
-
|
|
58
|
-
semver = Version.semver_for(version)
|
|
59
|
-
next unless semver
|
|
60
|
-
|
|
61
|
-
dependency_set << Dependency.new(
|
|
62
|
-
name: name,
|
|
63
|
-
version: semver.to_s,
|
|
64
|
-
package_manager: "npm_and_yarn",
|
|
65
|
-
requirements: []
|
|
66
|
-
)
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
dependency_set
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
sig do
|
|
73
|
-
params(dependency_name: String, requirement: T.untyped, _manifest_name: String)
|
|
74
|
-
.returns(T.nilable(T::Hash[String, T.untyped]))
|
|
75
|
-
end
|
|
76
|
-
def details(dependency_name, requirement, _manifest_name)
|
|
77
|
-
packages = parsed["packages"]
|
|
78
|
-
return unless packages.is_a?(Hash)
|
|
79
|
-
|
|
80
|
-
candidates =
|
|
81
|
-
packages
|
|
82
|
-
.select { |name, _| name == dependency_name }
|
|
83
|
-
.values
|
|
84
|
-
|
|
85
|
-
# If there's only one entry for this dependency, use it, even if
|
|
86
|
-
# the requirement in the lockfile doesn't match
|
|
87
|
-
if candidates.one?
|
|
88
|
-
parse_details(candidates.first)
|
|
89
|
-
else
|
|
90
|
-
candidate = candidates.find do |label, _|
|
|
91
|
-
label.scan(/(?<=\w)\@(?:npm:)?([^\s,]+)/).flatten.include?(requirement)
|
|
92
|
-
end&.last
|
|
93
|
-
parse_details(candidate)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
private
|
|
98
|
-
|
|
99
|
-
sig { params(message: String).void }
|
|
100
|
-
def raise_invalid!(message)
|
|
101
|
-
raise Dependabot::DependencyFileNotParseable.new(@dependency_file.path, "Invalid bun.lock file: #{message}")
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
sig do
|
|
105
|
-
params(entry: T.nilable(T::Array[T.untyped])).returns(T.nilable(T::Hash[String, T.untyped]))
|
|
106
|
-
end
|
|
107
|
-
def parse_details(entry)
|
|
108
|
-
return unless entry.is_a?(Array)
|
|
109
|
-
|
|
110
|
-
# Either:
|
|
111
|
-
# - "{name}@{version}", registry, details, integrity
|
|
112
|
-
# - "{name}@{resolution}", details
|
|
113
|
-
resolution = entry.first
|
|
114
|
-
return unless resolution.is_a?(String)
|
|
115
|
-
|
|
116
|
-
name, version = resolution.split(/(?<=\w)\@/)
|
|
117
|
-
semver = Version.semver_for(version)
|
|
118
|
-
|
|
119
|
-
if semver
|
|
120
|
-
registry, details, integrity = entry[1..3]
|
|
121
|
-
{
|
|
122
|
-
"name" => name,
|
|
123
|
-
"version" => semver.to_s,
|
|
124
|
-
"registry" => registry,
|
|
125
|
-
"details" => details,
|
|
126
|
-
"integrity" => integrity
|
|
127
|
-
}
|
|
128
|
-
else
|
|
129
|
-
details = entry[1]
|
|
130
|
-
{
|
|
131
|
-
"name" => name,
|
|
132
|
-
"resolution" => version,
|
|
133
|
-
"details" => details
|
|
134
|
-
}
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# typed: strong
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "sorbet-runtime"
|
|
5
|
-
|
|
6
|
-
require "dependabot/npm_and_yarn/helpers"
|
|
7
|
-
require "dependabot/npm_and_yarn/package/registry_finder"
|
|
8
|
-
require "dependabot/npm_and_yarn/registry_parser"
|
|
9
|
-
require "dependabot/shared_helpers"
|
|
10
|
-
|
|
11
|
-
module Dependabot
|
|
12
|
-
module NpmAndYarn
|
|
13
|
-
class FileUpdater < Dependabot::FileUpdaters::Base
|
|
14
|
-
class BunLockfileUpdater
|
|
15
|
-
extend T::Sig
|
|
16
|
-
|
|
17
|
-
require_relative "npmrc_builder"
|
|
18
|
-
require_relative "package_json_updater"
|
|
19
|
-
|
|
20
|
-
sig do
|
|
21
|
-
params(
|
|
22
|
-
dependencies: T::Array[Dependabot::Dependency],
|
|
23
|
-
dependency_files: T::Array[Dependabot::DependencyFile],
|
|
24
|
-
repo_contents_path: String,
|
|
25
|
-
credentials: T::Array[Dependabot::Credential]
|
|
26
|
-
)
|
|
27
|
-
.void
|
|
28
|
-
end
|
|
29
|
-
def initialize(dependencies:, dependency_files:, repo_contents_path:, credentials:)
|
|
30
|
-
@dependencies = dependencies
|
|
31
|
-
@dependency_files = dependency_files
|
|
32
|
-
@repo_contents_path = repo_contents_path
|
|
33
|
-
@credentials = credentials
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(String) }
|
|
37
|
-
def updated_bun_lock_content(bun_lock)
|
|
38
|
-
@updated_bun_lock_content ||= T.let({}, T.nilable(T::Hash[String, String]))
|
|
39
|
-
return T.must(@updated_bun_lock_content[bun_lock.name]) if @updated_bun_lock_content[bun_lock.name]
|
|
40
|
-
|
|
41
|
-
new_content = run_bun_update(bun_lock: bun_lock)
|
|
42
|
-
@updated_bun_lock_content[bun_lock.name] = new_content
|
|
43
|
-
rescue SharedHelpers::HelperSubprocessFailed => e
|
|
44
|
-
handle_bun_lock_updater_error(e, bun_lock)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
sig { returns(T::Array[Dependabot::Dependency]) }
|
|
50
|
-
attr_reader :dependencies
|
|
51
|
-
|
|
52
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
53
|
-
attr_reader :dependency_files
|
|
54
|
-
|
|
55
|
-
sig { returns(String) }
|
|
56
|
-
attr_reader :repo_contents_path
|
|
57
|
-
|
|
58
|
-
sig { returns(T::Array[Dependabot::Credential]) }
|
|
59
|
-
attr_reader :credentials
|
|
60
|
-
|
|
61
|
-
ERR_PATTERNS = T.let(
|
|
62
|
-
{
|
|
63
|
-
/get .* 404/i => Dependabot::DependencyNotFound,
|
|
64
|
-
/installfailed cloning repository/i => Dependabot::DependencyNotFound,
|
|
65
|
-
/file:.* failed to resolve/i => Dependabot::DependencyNotFound,
|
|
66
|
-
/no version matching/i => Dependabot::DependencyFileNotResolvable,
|
|
67
|
-
/failed to resolve/i => Dependabot::DependencyFileNotResolvable
|
|
68
|
-
}.freeze,
|
|
69
|
-
T::Hash[Regexp, Dependabot::DependabotError]
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(String) }
|
|
73
|
-
def run_bun_update(bun_lock:)
|
|
74
|
-
SharedHelpers.in_a_temporary_repo_directory(base_dir, repo_contents_path) do
|
|
75
|
-
File.write(".npmrc", npmrc_content(bun_lock))
|
|
76
|
-
|
|
77
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
|
78
|
-
run_bun_updater
|
|
79
|
-
|
|
80
|
-
write_final_package_json_files
|
|
81
|
-
|
|
82
|
-
run_bun_install
|
|
83
|
-
|
|
84
|
-
File.read(bun_lock.name)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
sig { void }
|
|
90
|
-
def run_bun_updater
|
|
91
|
-
dependency_updates = dependencies.map do |d|
|
|
92
|
-
"#{d.name}@#{d.version}"
|
|
93
|
-
end.join(" ")
|
|
94
|
-
|
|
95
|
-
Helpers.run_bun_command(
|
|
96
|
-
"install #{dependency_updates} --save-text-lockfile",
|
|
97
|
-
fingerprint: "install <dependency_updates> --save-text-lockfile"
|
|
98
|
-
)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
sig { void }
|
|
102
|
-
def run_bun_install
|
|
103
|
-
Helpers.run_bun_command(
|
|
104
|
-
"install --save-text-lockfile"
|
|
105
|
-
)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
sig { params(lockfile: Dependabot::DependencyFile).returns(T::Array[Dependabot::Dependency]) }
|
|
109
|
-
def lockfile_dependencies(lockfile)
|
|
110
|
-
@lockfile_dependencies ||= T.let({}, T.nilable(T::Hash[String, T::Array[Dependabot::Dependency]]))
|
|
111
|
-
@lockfile_dependencies[lockfile.name] ||=
|
|
112
|
-
NpmAndYarn::FileParser.new(
|
|
113
|
-
dependency_files: [lockfile, *package_files],
|
|
114
|
-
source: nil,
|
|
115
|
-
credentials: credentials
|
|
116
|
-
).parse
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
sig { params(error: Dependabot::DependabotError, _bun_lock: Dependabot::DependencyFile).returns(T.noreturn) }
|
|
120
|
-
def handle_bun_lock_updater_error(error, _bun_lock)
|
|
121
|
-
error_message = error.message
|
|
122
|
-
|
|
123
|
-
ERR_PATTERNS.each do |pattern, error_class|
|
|
124
|
-
raise error_class, error_message if error_message.match?(pattern)
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
raise error
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
sig { void }
|
|
131
|
-
def write_final_package_json_files
|
|
132
|
-
package_files.each do |file|
|
|
133
|
-
path = file.name
|
|
134
|
-
FileUtils.mkdir_p(Pathname.new(path).dirname)
|
|
135
|
-
File.write(path, updated_package_json_content(file))
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(String) }
|
|
140
|
-
def npmrc_content(bun_lock)
|
|
141
|
-
NpmrcBuilder.new(
|
|
142
|
-
credentials: credentials,
|
|
143
|
-
dependency_files: dependency_files,
|
|
144
|
-
dependencies: lockfile_dependencies(bun_lock)
|
|
145
|
-
).npmrc_content
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
sig { params(file: Dependabot::DependencyFile).returns(String) }
|
|
149
|
-
def updated_package_json_content(file)
|
|
150
|
-
@updated_package_json_content ||= T.let({}, T.nilable(T::Hash[String, String]))
|
|
151
|
-
@updated_package_json_content[file.name] ||=
|
|
152
|
-
T.must(
|
|
153
|
-
PackageJsonUpdater.new(
|
|
154
|
-
package_json: file,
|
|
155
|
-
dependencies: dependencies
|
|
156
|
-
).updated_package_json.content
|
|
157
|
-
)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
|
161
|
-
def package_files
|
|
162
|
-
@package_files ||= T.let(
|
|
163
|
-
dependency_files.select { |f| f.name.end_with?("package.json") },
|
|
164
|
-
T.nilable(T::Array[Dependabot::DependencyFile])
|
|
165
|
-
)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
sig { returns(String) }
|
|
169
|
-
def base_dir
|
|
170
|
-
T.must(dependency_files.first).directory
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
174
|
-
def npmrc_file
|
|
175
|
-
dependency_files.find { |f| f.name == ".npmrc" }
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
sig { params(message: String).returns(String) }
|
|
179
|
-
def sanitize_message(message)
|
|
180
|
-
message.gsub(/"|\[|\]|\}|\{/, "")
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
end
|