-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11267 from dependabot/markhallen/add-bun-package-…
…manager Add bun package manager
- Loading branch information
Showing
7 changed files
with
342 additions
and
194 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
npm_and_yarn/lib/dependabot/npm_and_yarn/bun_package_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
module Dependabot | ||
module NpmAndYarn | ||
class BunPackageManager < Ecosystem::VersionManager | ||
extend T::Sig | ||
NAME = "bun" | ||
LOCKFILE_NAME = "bun.lock" | ||
|
||
# In Bun 1.1.39, the lockfile format was changed from a binary bun.lockb to a text-based bun.lock. | ||
# https://bun.sh/blog/bun-lock-text-lockfile | ||
MIN_SUPPORTED_VERSION = Version.new("1.1.39") | ||
SUPPORTED_VERSIONS = T.let([MIN_SUPPORTED_VERSION].freeze, T::Array[Dependabot::Version]) | ||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig do | ||
params( | ||
detected_version: T.nilable(String), | ||
raw_version: T.nilable(String), | ||
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement) | ||
).void | ||
end | ||
def initialize(detected_version: nil, raw_version: nil, requirement: nil) | ||
super( | ||
name: NAME, | ||
detected_version: detected_version ? Version.new(detected_version) : nil, | ||
version: raw_version ? Version.new(raw_version) : nil, | ||
deprecated_versions: DEPRECATED_VERSIONS, | ||
supported_versions: SUPPORTED_VERSIONS, | ||
requirement: requirement | ||
) | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def deprecated? | ||
false | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def unsupported? | ||
supported_versions.all? { |supported| supported > version } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/npm_and_yarn/package_manager" | ||
|
||
module Dependabot | ||
module NpmAndYarn | ||
class Language < Ecosystem::VersionManager | ||
extend T::Sig | ||
NAME = "node" | ||
|
||
SUPPORTED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig do | ||
params( | ||
detected_version: T.nilable(String), | ||
raw_version: T.nilable(String), | ||
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement) | ||
).void | ||
end | ||
def initialize(detected_version: nil, raw_version: nil, requirement: nil) | ||
super( | ||
name: NAME, | ||
detected_version: detected_version ? Version.new(detected_version) : nil, | ||
version: raw_version ? Version.new(raw_version) : nil, | ||
deprecated_versions: DEPRECATED_VERSIONS, | ||
supported_versions: SUPPORTED_VERSIONS, | ||
requirement: requirement | ||
) | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def deprecated? | ||
false | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def unsupported? | ||
false | ||
end | ||
end | ||
end | ||
end |
70 changes: 70 additions & 0 deletions
70
npm_and_yarn/lib/dependabot/npm_and_yarn/npm_package_manager.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# typed: strong | ||
# frozen_string_literal: true | ||
|
||
require "dependabot/npm_and_yarn/package_manager" | ||
|
||
module Dependabot | ||
module NpmAndYarn | ||
class NpmPackageManager < Ecosystem::VersionManager | ||
extend T::Sig | ||
NAME = "npm" | ||
RC_FILENAME = ".npmrc" | ||
LOCKFILE_NAME = "package-lock.json" | ||
SHRINKWRAP_LOCKFILE_NAME = "npm-shrinkwrap.json" | ||
|
||
NPM_V6 = "6" | ||
NPM_V7 = "7" | ||
NPM_V8 = "8" | ||
NPM_V9 = "9" | ||
NPM_V10 = "10" | ||
|
||
# Keep versions in ascending order | ||
SUPPORTED_VERSIONS = T.let([ | ||
Version.new(NPM_V7), | ||
Version.new(NPM_V8), | ||
Version.new(NPM_V9), | ||
Version.new(NPM_V10) | ||
].freeze, T::Array[Dependabot::Version]) | ||
|
||
DEPRECATED_VERSIONS = T.let([Version.new(NPM_V6)].freeze, T::Array[Dependabot::Version]) | ||
|
||
sig do | ||
params( | ||
detected_version: T.nilable(String), | ||
raw_version: T.nilable(String), | ||
requirement: T.nilable(Dependabot::NpmAndYarn::Requirement) | ||
).void | ||
end | ||
def initialize(detected_version: nil, raw_version: nil, requirement: nil) | ||
super( | ||
name: NAME, | ||
detected_version: detected_version ? Version.new(detected_version) : nil, | ||
version: raw_version ? Version.new(raw_version) : nil, | ||
deprecated_versions: DEPRECATED_VERSIONS, | ||
supported_versions: SUPPORTED_VERSIONS, | ||
requirement: requirement | ||
) | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def deprecated? | ||
return false unless detected_version | ||
|
||
return false if unsupported? | ||
|
||
return false unless Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning) | ||
|
||
deprecated_versions.include?(detected_version) | ||
end | ||
|
||
sig { override.returns(T::Boolean) } | ||
def unsupported? | ||
return false unless detected_version | ||
|
||
return false unless Dependabot::Experiments.enabled?(:npm_v6_unsupported_error) | ||
|
||
supported_versions.all? { |supported| supported > detected_version } | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.