dependabot-bun 0.296.2 → 0.296.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/.eslintrc +11 -0
- data/helpers/README.md +29 -0
- data/helpers/build +26 -0
- data/helpers/jest.config.js +5 -0
- data/helpers/lib/npm/conflicting-dependency-parser.js +78 -0
- data/helpers/lib/npm/index.js +9 -0
- data/helpers/lib/npm/vulnerability-auditor.js +291 -0
- data/helpers/lib/npm6/helpers.js +25 -0
- data/helpers/lib/npm6/index.js +9 -0
- data/helpers/lib/npm6/peer-dependency-checker.js +111 -0
- data/helpers/lib/npm6/remove-dependencies-from-lockfile.js +22 -0
- data/helpers/lib/npm6/subdependency-updater.js +78 -0
- data/helpers/lib/npm6/updater.js +199 -0
- data/helpers/lib/pnpm/index.js +5 -0
- data/helpers/lib/pnpm/lockfile-parser.js +82 -0
- data/helpers/lib/yarn/conflicting-dependency-parser.js +176 -0
- data/helpers/lib/yarn/fix-duplicates.js +80 -0
- data/helpers/lib/yarn/helpers.js +54 -0
- data/helpers/lib/yarn/index.js +14 -0
- data/helpers/lib/yarn/lockfile-parser.js +21 -0
- data/helpers/lib/yarn/peer-dependency-checker.js +132 -0
- data/helpers/lib/yarn/replace-lockfile-declaration.js +57 -0
- data/helpers/lib/yarn/subdependency-updater.js +83 -0
- data/helpers/lib/yarn/updater.js +209 -0
- data/helpers/package-lock.json +28519 -0
- data/helpers/package.json +29 -0
- data/helpers/patches/npm++pacote+9.5.12.patch +14 -0
- data/helpers/run.js +30 -0
- data/helpers/test/npm6/conflicting-dependency-parser.test.js +66 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/deeply-nested/package-lock.json +591 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/deeply-nested/package.json +14 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/nested/package-lock.json +188 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/nested/package.json +14 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/simple/package-lock.json +27 -0
- data/helpers/test/npm6/fixtures/conflicting-dependency-parser/simple/package.json +14 -0
- data/helpers/test/npm6/fixtures/updater/original/package-lock.json +16 -0
- data/helpers/test/npm6/fixtures/updater/original/package.json +9 -0
- data/helpers/test/npm6/fixtures/updater/updated/package-lock.json +16 -0
- data/helpers/test/npm6/helpers.js +21 -0
- data/helpers/test/npm6/updater.test.js +30 -0
- data/helpers/test/pnpm/fixtures/parser/empty_version/pnpm-lock.yaml +72 -0
- data/helpers/test/pnpm/fixtures/parser/no_lockfile_change/pnpm-lock.yaml +2744 -0
- data/helpers/test/pnpm/fixtures/parser/only_dev_dependencies/pnpm-lock.yaml +16 -0
- data/helpers/test/pnpm/fixtures/parser/peer_disambiguation/pnpm-lock.yaml +855 -0
- data/helpers/test/pnpm/lockfile-parser.test.js +62 -0
- data/helpers/test/yarn/conflicting-dependency-parser.test.js +83 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/deeply-nested/package.json +14 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/deeply-nested/yarn.lock +496 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/dev-dependencies/package.json +14 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/dev-dependencies/yarn.lock +21 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/nested/package.json +14 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/nested/yarn.lock +183 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/simple/package.json +14 -0
- data/helpers/test/yarn/fixtures/conflicting-dependency-parser/simple/yarn.lock +21 -0
- data/helpers/test/yarn/fixtures/updater/illegal_character/package.json +8 -0
- data/helpers/test/yarn/fixtures/updater/illegal_character/yarn.lock +14 -0
- data/helpers/test/yarn/fixtures/updater/original/package.json +6 -0
- data/helpers/test/yarn/fixtures/updater/original/yarn.lock +11 -0
- data/helpers/test/yarn/fixtures/updater/updated/yarn.lock +12 -0
- data/helpers/test/yarn/fixtures/updater/with-version-comments/package.json +5 -0
- data/helpers/test/yarn/fixtures/updater/with-version-comments/yarn.lock +13 -0
- data/helpers/test/yarn/helpers.js +18 -0
- data/helpers/test/yarn/updater.test.js +117 -0
- data/lib/dependabot/bun/bun_package_manager.rb +47 -0
- data/lib/dependabot/bun/constraint_helper.rb +359 -0
- data/lib/dependabot/bun/dependency_files_filterer.rb +157 -0
- data/lib/dependabot/bun/file_fetcher/path_dependency_builder.rb +184 -0
- data/lib/dependabot/bun/file_fetcher.rb +402 -0
- data/lib/dependabot/bun/file_parser/bun_lock.rb +140 -0
- data/lib/dependabot/bun/file_parser/lockfile_parser.rb +105 -0
- data/lib/dependabot/bun/file_parser.rb +477 -0
- data/lib/dependabot/bun/file_updater/bun_lockfile_updater.rb +144 -0
- data/lib/dependabot/bun/file_updater/npmrc_builder.rb +256 -0
- data/lib/dependabot/bun/file_updater/package_json_preparer.rb +88 -0
- data/lib/dependabot/bun/file_updater/package_json_updater.rb +378 -0
- data/lib/dependabot/bun/file_updater.rb +203 -0
- data/lib/dependabot/bun/helpers.rb +93 -0
- data/lib/dependabot/bun/language.rb +45 -0
- data/lib/dependabot/bun/metadata_finder.rb +214 -0
- data/lib/dependabot/bun/native_helpers.rb +19 -0
- data/lib/dependabot/bun/package_manager.rb +280 -0
- data/lib/dependabot/bun/package_name.rb +118 -0
- data/lib/dependabot/bun/pnpm_package_manager.rb +55 -0
- data/lib/dependabot/bun/registry_helper.rb +188 -0
- data/lib/dependabot/bun/registry_parser.rb +93 -0
- data/lib/dependabot/bun/requirement.rb +146 -0
- data/lib/dependabot/bun/sub_dependency_files_filterer.rb +82 -0
- data/lib/dependabot/bun/update_checker/conflicting_dependency_resolver.rb +59 -0
- data/lib/dependabot/bun/update_checker/dependency_files_builder.rb +79 -0
- data/lib/dependabot/bun/update_checker/latest_version_finder.rb +448 -0
- data/lib/dependabot/bun/update_checker/library_detector.rb +76 -0
- data/lib/dependabot/bun/update_checker/registry_finder.rb +279 -0
- data/lib/dependabot/bun/update_checker/requirements_updater.rb +206 -0
- data/lib/dependabot/bun/update_checker/subdependency_version_resolver.rb +154 -0
- data/lib/dependabot/bun/update_checker/version_resolver.rb +583 -0
- data/lib/dependabot/bun/update_checker/vulnerability_auditor.rb +164 -0
- data/lib/dependabot/bun/update_checker.rb +455 -0
- data/lib/dependabot/bun/version.rb +138 -0
- data/lib/dependabot/bun/version_selector.rb +61 -0
- data/lib/dependabot/bun.rb +337 -35
- metadata +108 -65
- data/lib/dependabot/javascript/bun/file_fetcher.rb +0 -77
- data/lib/dependabot/javascript/bun/file_parser/bun_lock.rb +0 -156
- data/lib/dependabot/javascript/bun/file_parser/lockfile_parser.rb +0 -55
- data/lib/dependabot/javascript/bun/file_parser.rb +0 -74
- data/lib/dependabot/javascript/bun/file_updater/lockfile_updater.rb +0 -138
- data/lib/dependabot/javascript/bun/file_updater.rb +0 -75
- data/lib/dependabot/javascript/bun/helpers.rb +0 -72
- data/lib/dependabot/javascript/bun/package_manager.rb +0 -48
- data/lib/dependabot/javascript/bun/requirement.rb +0 -11
- data/lib/dependabot/javascript/bun/update_checker/conflicting_dependency_resolver.rb +0 -64
- data/lib/dependabot/javascript/bun/update_checker/dependency_files_builder.rb +0 -47
- data/lib/dependabot/javascript/bun/update_checker/latest_version_finder.rb +0 -450
- data/lib/dependabot/javascript/bun/update_checker/library_detector.rb +0 -76
- data/lib/dependabot/javascript/bun/update_checker/requirements_updater.rb +0 -203
- data/lib/dependabot/javascript/bun/update_checker/subdependency_version_resolver.rb +0 -144
- data/lib/dependabot/javascript/bun/update_checker/version_resolver.rb +0 -525
- data/lib/dependabot/javascript/bun/update_checker/vulnerability_auditor.rb +0 -165
- data/lib/dependabot/javascript/bun/update_checker.rb +0 -440
- data/lib/dependabot/javascript/bun/version.rb +0 -11
- data/lib/dependabot/javascript/shared/constraint_helper.rb +0 -359
- data/lib/dependabot/javascript/shared/dependency_files_filterer.rb +0 -164
- data/lib/dependabot/javascript/shared/file_fetcher.rb +0 -283
- data/lib/dependabot/javascript/shared/file_parser/lockfile_parser.rb +0 -106
- data/lib/dependabot/javascript/shared/file_parser.rb +0 -454
- data/lib/dependabot/javascript/shared/file_updater/npmrc_builder.rb +0 -394
- data/lib/dependabot/javascript/shared/file_updater/package_json_preparer.rb +0 -87
- data/lib/dependabot/javascript/shared/file_updater/package_json_updater.rb +0 -376
- data/lib/dependabot/javascript/shared/file_updater.rb +0 -179
- data/lib/dependabot/javascript/shared/language.rb +0 -45
- data/lib/dependabot/javascript/shared/metadata_finder.rb +0 -209
- data/lib/dependabot/javascript/shared/native_helpers.rb +0 -21
- data/lib/dependabot/javascript/shared/package_manager_detector.rb +0 -72
- data/lib/dependabot/javascript/shared/package_name.rb +0 -118
- data/lib/dependabot/javascript/shared/registry_helper.rb +0 -190
- data/lib/dependabot/javascript/shared/registry_parser.rb +0 -93
- data/lib/dependabot/javascript/shared/requirement.rb +0 -144
- data/lib/dependabot/javascript/shared/sub_dependency_files_filterer.rb +0 -79
- data/lib/dependabot/javascript/shared/update_checker/dependency_files_builder.rb +0 -87
- data/lib/dependabot/javascript/shared/update_checker/registry_finder.rb +0 -358
- data/lib/dependabot/javascript/shared/version.rb +0 -133
- data/lib/dependabot/javascript/shared/version_selector.rb +0 -60
- data/lib/dependabot/javascript.rb +0 -39
@@ -1,138 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
class FileUpdater
|
8
|
-
class LockfileUpdater
|
9
|
-
def initialize(dependencies:, dependency_files:, repo_contents_path:, credentials:)
|
10
|
-
@dependencies = dependencies
|
11
|
-
@dependency_files = dependency_files
|
12
|
-
@repo_contents_path = repo_contents_path
|
13
|
-
@credentials = credentials
|
14
|
-
end
|
15
|
-
|
16
|
-
def updated_bun_lock_content(bun_lock)
|
17
|
-
@updated_bun_lock_content ||= {}
|
18
|
-
return @updated_bun_lock_content[bun_lock.name] if @updated_bun_lock_content[bun_lock.name]
|
19
|
-
|
20
|
-
new_content = run_bun_update(bun_lock: bun_lock)
|
21
|
-
@updated_bun_lock_content[bun_lock.name] = new_content
|
22
|
-
rescue SharedHelpers::HelperSubprocessFailed => e
|
23
|
-
handle_bun_lock_updater_error(e, bun_lock)
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
attr_reader :dependencies
|
29
|
-
attr_reader :dependency_files
|
30
|
-
attr_reader :repo_contents_path
|
31
|
-
attr_reader :credentials
|
32
|
-
|
33
|
-
ERR_PATTERNS = {
|
34
|
-
/get .* 404/i => Dependabot::DependencyNotFound,
|
35
|
-
/installfailed cloning repository/i => Dependabot::DependencyNotFound,
|
36
|
-
/file:.* failed to resolve/i => Dependabot::DependencyNotFound,
|
37
|
-
/no version matching/i => Dependabot::DependencyFileNotResolvable,
|
38
|
-
/failed to resolve/i => Dependabot::DependencyFileNotResolvable
|
39
|
-
}.freeze
|
40
|
-
|
41
|
-
def run_bun_update(bun_lock:)
|
42
|
-
SharedHelpers.in_a_temporary_repo_directory(base_dir, repo_contents_path) do
|
43
|
-
File.write(".npmrc", npmrc_content(bun_lock))
|
44
|
-
|
45
|
-
SharedHelpers.with_git_configured(credentials: credentials) do
|
46
|
-
run_bun_updater
|
47
|
-
|
48
|
-
write_final_package_json_files
|
49
|
-
|
50
|
-
run_bun_install
|
51
|
-
|
52
|
-
File.read(bun_lock.name)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def run_bun_updater
|
58
|
-
dependency_updates = dependencies.map do |d|
|
59
|
-
"#{d.name}@#{d.version}"
|
60
|
-
end.join(" ")
|
61
|
-
|
62
|
-
Helpers.run_bun_command(
|
63
|
-
"install #{dependency_updates} --save-text-lockfile",
|
64
|
-
fingerprint: "install <dependency_updates> --save-text-lockfile"
|
65
|
-
)
|
66
|
-
end
|
67
|
-
|
68
|
-
def run_bun_install
|
69
|
-
Helpers.run_bun_command(
|
70
|
-
"install --save-text-lockfile"
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
def lockfile_dependencies(lockfile)
|
75
|
-
@lockfile_dependencies ||= {}
|
76
|
-
@lockfile_dependencies[lockfile.name] ||=
|
77
|
-
FileParser.new(
|
78
|
-
dependency_files: [lockfile, *package_files],
|
79
|
-
source: nil,
|
80
|
-
credentials: credentials
|
81
|
-
).parse
|
82
|
-
end
|
83
|
-
|
84
|
-
def handle_bun_lock_updater_error(error, _bun_lock)
|
85
|
-
error_message = error.message
|
86
|
-
|
87
|
-
ERR_PATTERNS.each do |pattern, error_class|
|
88
|
-
raise error_class, error_message if error_message.match?(pattern)
|
89
|
-
end
|
90
|
-
|
91
|
-
raise error
|
92
|
-
end
|
93
|
-
|
94
|
-
def write_final_package_json_files
|
95
|
-
package_files.each do |file|
|
96
|
-
path = file.name
|
97
|
-
FileUtils.mkdir_p(Pathname.new(path).dirname)
|
98
|
-
File.write(path, updated_package_json_content(file))
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def npmrc_content(bun_lock)
|
103
|
-
Dependabot::Javascript::Shared::FileUpdater::NpmrcBuilder.new(
|
104
|
-
credentials: credentials,
|
105
|
-
dependency_files: dependency_files,
|
106
|
-
dependencies: lockfile_dependencies(bun_lock)
|
107
|
-
).npmrc_content
|
108
|
-
end
|
109
|
-
|
110
|
-
def updated_package_json_content(file)
|
111
|
-
@updated_package_json_content ||= {}
|
112
|
-
@updated_package_json_content[file.name] ||=
|
113
|
-
Dependabot::Javascript::Shared::FileUpdater::PackageJsonUpdater.new(
|
114
|
-
package_json: file,
|
115
|
-
dependencies: dependencies
|
116
|
-
).updated_package_json.content
|
117
|
-
end
|
118
|
-
|
119
|
-
def package_files
|
120
|
-
@package_files ||= dependency_files.select { |f| f.name.end_with?("package.json") }
|
121
|
-
end
|
122
|
-
|
123
|
-
def base_dir
|
124
|
-
dependency_files.first.directory
|
125
|
-
end
|
126
|
-
|
127
|
-
def npmrc_file
|
128
|
-
dependency_files.find { |f| f.name == ".npmrc" }
|
129
|
-
end
|
130
|
-
|
131
|
-
def sanitize_message(message)
|
132
|
-
message.gsub(/"|\[|\]|\}|\{/, "")
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
class FileUpdater < Shared::FileUpdater
|
8
|
-
sig { override.returns(T::Array[Regexp]) }
|
9
|
-
def self.updated_files_regex
|
10
|
-
[
|
11
|
-
%r{^(?:.*/)?package\.json$},
|
12
|
-
%r{^(?:.*/)?bun\.lock$} # Matches bun.lock files
|
13
|
-
]
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
sig { override.returns(T.class_of(FileParser::LockfileParser)) }
|
19
|
-
def lockfile_parser_class
|
20
|
-
FileParser::LockfileParser
|
21
|
-
end
|
22
|
-
|
23
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
24
|
-
def bun_locks
|
25
|
-
@bun_locks ||= T.let(
|
26
|
-
filtered_dependency_files
|
27
|
-
.select { |f| f.name.end_with?("bun.lock") },
|
28
|
-
T.nilable(T::Array[Dependabot::DependencyFile])
|
29
|
-
)
|
30
|
-
end
|
31
|
-
|
32
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(T::Boolean) }
|
33
|
-
def bun_lock_changed?(bun_lock)
|
34
|
-
bun_lock.content != updated_bun_lock_content(bun_lock)
|
35
|
-
end
|
36
|
-
|
37
|
-
sig { override.returns(T::Array[Dependabot::DependencyFile]) }
|
38
|
-
def updated_lockfiles
|
39
|
-
updated_files = []
|
40
|
-
|
41
|
-
bun_locks.each do |bun_lock|
|
42
|
-
next unless bun_lock_changed?(bun_lock)
|
43
|
-
|
44
|
-
updated_files << updated_file(
|
45
|
-
file: bun_lock,
|
46
|
-
content: updated_bun_lock_content(bun_lock)
|
47
|
-
)
|
48
|
-
end
|
49
|
-
|
50
|
-
updated_files
|
51
|
-
end
|
52
|
-
|
53
|
-
sig { params(bun_lock: Dependabot::DependencyFile).returns(String) }
|
54
|
-
def updated_bun_lock_content(bun_lock)
|
55
|
-
@updated_bun_lock_content ||= T.let({}, T.nilable(T::Hash[String, T.nilable(String)]))
|
56
|
-
@updated_bun_lock_content[bun_lock.name] ||=
|
57
|
-
bun_lockfile_updater.updated_bun_lock_content(bun_lock)
|
58
|
-
end
|
59
|
-
|
60
|
-
sig { returns(Bun::FileUpdater::LockfileUpdater) }
|
61
|
-
def bun_lockfile_updater
|
62
|
-
@bun_lockfile_updater ||= T.let(
|
63
|
-
LockfileUpdater.new(
|
64
|
-
dependencies: dependencies,
|
65
|
-
dependency_files: dependency_files,
|
66
|
-
repo_contents_path: repo_contents_path,
|
67
|
-
credentials: credentials
|
68
|
-
),
|
69
|
-
T.nilable(Bun::FileUpdater::LockfileUpdater)
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
module Helpers
|
8
|
-
extend T::Sig
|
9
|
-
|
10
|
-
# BUN Version Constants
|
11
|
-
BUN_V1 = 1
|
12
|
-
BUN_DEFAULT_VERSION = BUN_V1
|
13
|
-
|
14
|
-
sig { params(_bun_lock: T.nilable(DependencyFile)).returns(Integer) }
|
15
|
-
def self.bun_version_numeric(_bun_lock)
|
16
|
-
BUN_DEFAULT_VERSION
|
17
|
-
end
|
18
|
-
|
19
|
-
sig { returns(T.nilable(String)) }
|
20
|
-
def self.bun_version
|
21
|
-
run_bun_command("--version", fingerprint: "--version").strip
|
22
|
-
rescue StandardError => e
|
23
|
-
Dependabot.logger.error("Error retrieving Bun version: #{e.message}")
|
24
|
-
nil
|
25
|
-
end
|
26
|
-
|
27
|
-
sig { params(command: String, fingerprint: T.nilable(String)).returns(String) }
|
28
|
-
def self.run_bun_command(command, fingerprint: nil)
|
29
|
-
full_command = "bun #{command}"
|
30
|
-
|
31
|
-
Dependabot.logger.info("Running bun command: #{full_command}")
|
32
|
-
|
33
|
-
result = Dependabot::SharedHelpers.run_shell_command(
|
34
|
-
full_command,
|
35
|
-
fingerprint: "bun #{fingerprint || command}"
|
36
|
-
)
|
37
|
-
|
38
|
-
Dependabot.logger.info("Command executed successfully: #{full_command}")
|
39
|
-
result
|
40
|
-
rescue StandardError => e
|
41
|
-
Dependabot.logger.error("Error running bun command: #{full_command}, Error: #{e.message}")
|
42
|
-
raise
|
43
|
-
end
|
44
|
-
|
45
|
-
# Fetch the currently installed version of the package manager directly
|
46
|
-
# from the system
|
47
|
-
sig { params(name: String).returns(String) }
|
48
|
-
def self.local_package_manager_version(name)
|
49
|
-
Dependabot::SharedHelpers.run_shell_command(
|
50
|
-
"#{name} -v",
|
51
|
-
fingerprint: "#{name} -v"
|
52
|
-
).strip
|
53
|
-
end
|
54
|
-
|
55
|
-
# Run single command on package manager returning stdout/stderr
|
56
|
-
sig do
|
57
|
-
params(
|
58
|
-
name: String,
|
59
|
-
command: String,
|
60
|
-
fingerprint: T.nilable(String)
|
61
|
-
).returns(String)
|
62
|
-
end
|
63
|
-
def self.package_manager_run_command(name, command, fingerprint: nil)
|
64
|
-
return run_bun_command(command, fingerprint: fingerprint) if name == PackageManager::NAME
|
65
|
-
|
66
|
-
# TODO: remove this method and just use the one in the PackageManager class
|
67
|
-
"noop"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
class PackageManager < Ecosystem::VersionManager
|
8
|
-
extend T::Sig
|
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 = T.let(Version.new("1.1.39"), Dependabot::Version)
|
15
|
-
SUPPORTED_VERSIONS = T.let([MIN_SUPPORTED_VERSION].freeze, T::Array[Dependabot::Version])
|
16
|
-
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Version])
|
17
|
-
|
18
|
-
sig do
|
19
|
-
params(
|
20
|
-
detected_version: T.nilable(String),
|
21
|
-
raw_version: T.nilable(String),
|
22
|
-
requirement: T.nilable(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
|
48
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
class UpdateChecker < Dependabot::UpdateCheckers::Base
|
8
|
-
class ConflictingDependencyResolver
|
9
|
-
def initialize(dependency_files:, credentials:)
|
10
|
-
@dependency_files = dependency_files
|
11
|
-
@credentials = credentials
|
12
|
-
end
|
13
|
-
|
14
|
-
# Finds any dependencies in the `yarn.lock` or `package-lock.json` that
|
15
|
-
# have a subdependency on the given dependency that does not satisfly
|
16
|
-
# the target_version.
|
17
|
-
#
|
18
|
-
# @param dependency [Dependabot::Dependency] the dependency to check
|
19
|
-
# @param target_version [String] the version to check
|
20
|
-
# @return [Array<Hash{String => String}]
|
21
|
-
# * name [String] the blocking dependencies name
|
22
|
-
# * version [String] the version of the blocking dependency
|
23
|
-
# * requirement [String] the requirement on the target_dependency
|
24
|
-
def conflicting_dependencies(dependency:, target_version:)
|
25
|
-
SharedHelpers.in_a_temporary_directory do
|
26
|
-
dependency_files_builder = DependencyFilesBuilder.new(
|
27
|
-
dependency: dependency,
|
28
|
-
dependency_files: dependency_files,
|
29
|
-
credentials: credentials
|
30
|
-
)
|
31
|
-
dependency_files_builder.write_temporary_dependency_files
|
32
|
-
|
33
|
-
# TODO: Look into using npm/arborist for parsing yarn lockfiles (there's currently partial yarn support)
|
34
|
-
#
|
35
|
-
# Prefer the npm conflicting dependency parser if there's both a npm lockfile and a yarn.lock file as the
|
36
|
-
# npm parser handles edge cases where the package.json is out of sync with the lockfile,
|
37
|
-
# something the yarn parser doesn't deal with at the moment.
|
38
|
-
if dependency_files_builder.lockfiles.any?
|
39
|
-
SharedHelpers.run_helper_subprocess(
|
40
|
-
command: Dependabot::Javascript::Shared::NativeHelpers.helper_path,
|
41
|
-
function: "npm:findConflictingDependencies",
|
42
|
-
args: [Dir.pwd, dependency.name, target_version.to_s]
|
43
|
-
)
|
44
|
-
else
|
45
|
-
SharedHelpers.run_helper_subprocess(
|
46
|
-
command: Dependabot::Javascript::Shared::NativeHelpers.helper_path,
|
47
|
-
function: "yarn:findConflictingDependencies",
|
48
|
-
args: [Dir.pwd, dependency.name, target_version.to_s]
|
49
|
-
)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
rescue SharedHelpers::HelperSubprocessFailed
|
53
|
-
[]
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
attr_reader :dependency_files
|
59
|
-
attr_reader :credentials
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Dependabot
|
5
|
-
module Javascript
|
6
|
-
module Bun
|
7
|
-
class UpdateChecker
|
8
|
-
class DependencyFilesBuilder < Shared::UpdateChecker::DependencyFilesBuilder
|
9
|
-
extend T::Sig
|
10
|
-
|
11
|
-
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
12
|
-
def bun_locks
|
13
|
-
@bun_locks ||= T.let(
|
14
|
-
dependency_files
|
15
|
-
.select { |f| f.name.end_with?("bun.lock") },
|
16
|
-
T.nilable(T::Array[Dependabot::DependencyFile])
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
21
|
-
def root_bun_lock
|
22
|
-
@root_bun_lock ||= T.let(
|
23
|
-
dependency_files
|
24
|
-
.find { |f| f.name == "bun.lock" },
|
25
|
-
T.nilable(Dependabot::DependencyFile)
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
sig { override.returns(T::Array[Dependabot::DependencyFile]) }
|
30
|
-
def lockfiles
|
31
|
-
[*bun_locks]
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
sig { override.returns(T::Array[Dependabot::DependencyFile]) }
|
37
|
-
def write_lockfiles
|
38
|
-
[*bun_locks].each do |f|
|
39
|
-
FileUtils.mkdir_p(Pathname.new(f.name).dirname)
|
40
|
-
File.write(f.name, f.content)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|