-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bun package manager #11267
Open
markhallen
wants to merge
2
commits into
main
Choose a base branch
from
markhallen/add-bun-package-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+342
−194
Open
Add bun package manager #11267
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markhallen ,
Is there a reason we recreated package manager for npm, pnpm and yarn? There in PackageManagerHelper normally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I extracted these out as the
package_manager.rb
file was becoming very big. They have not changed and the specs still pass. They just live in new files.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see but as per our discussion I thought we are going to keep the bun completely seperated. The reason why npm, pnpm, yarn are together because they share the same flow. However for bun you shouldn't need that so, maybe it is not good to make changes for
npm
,pnpm
, andyarn
while working forbun
. Later when we seperate ecosystems definitely it is going to be individual package manager files for each of them as it is for other ecosystems.