Skip to content
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

Remove FF and tests for npm6 deprecation and unsupported error #11622

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bun/spec/dependabot/bun/file_updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
.with(:enable_corepack_for_npm_and_yarn).and_return(enable_corepack_for_npm_and_yarn)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:enable_shared_helpers_command_timeout).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:avoid_duplicate_updates_package_json).and_return(false)
end
Expand Down
6 changes: 0 additions & 6 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ module Helpers # rubocop:disable Metrics/ModuleLength
# Otherwise, we are going to use old versionining npm 6
sig { params(lockfile: T.nilable(DependencyFile)).returns(Integer) }
def self.npm_version_numeric(lockfile)
return npm_version_numeric_latest(lockfile) if Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)

fallback_version_npm8 = Dependabot::Experiments.enabled?(:npm_fallback_version_above_v6)

return npm_version_numeric_npm8_or_higher(lockfile) if fallback_version_npm8
Expand Down Expand Up @@ -184,10 +182,6 @@ def self.fetch_yarnrc_yml_value(key, default_value)
def self.npm8?(package_lock)
return true unless package_lock&.content

if Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)
return npm_version_numeric_latest(package_lock) >= NPM_V8
end

npm_version_numeric(package_lock) == NPM_V8
end

Expand Down
14 changes: 0 additions & 14 deletions npm_and_yarn/lib/dependabot/npm_and_yarn/npm_package_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ def initialize(detected_version: nil, raw_version: nil, requirement: nil)
requirement: requirement
)
end

sig { override.returns(T::Boolean) }
def deprecated?
return false unless Dependabot::Experiments.enabled?(:npm_v6_deprecation_warning)

super
end

sig { override.returns(T::Boolean) }
def unsupported?
return false unless Dependabot::Experiments.enabled?(:npm_v6_unsupported_error)

super
end
end
end
end
77 changes: 71 additions & 6 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/file_fetcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,18 @@
stub_request(:get, File.join(url, "yarn.lock?ref=sha"))
.with(headers: { "Authorization" => "token token" })
.to_return(status: 404)
stub_request(:get, File.join(url, "package.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package.json"),
headers: json_header
)
stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture("github", "package_lock_content.json"),
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end
Expand All @@ -623,7 +630,7 @@

it "parses the npm lockfile" do
expect(file_fetcher_instance.ecosystem_versions).to eq(
{ package_managers: { "npm" => 6 } }
{ package_managers: { "npm" => 8 } }
)
end
end
Expand All @@ -648,7 +655,7 @@
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture("github", "package_lock_content.json"),
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end
Expand All @@ -660,7 +667,7 @@

it "parses the package manager version" do
expect(file_fetcher_instance.ecosystem_versions).to eq(
{ package_managers: { "npm" => 6, "yarn" => 1 } }
{ package_managers: { "npm" => 8, "yarn" => 1 } }
)
end
end
Expand Down Expand Up @@ -2189,6 +2196,12 @@
body: fixture_to_response("projects/generic/package_manager_with_ver_with_engine_info_yarn", "package.json"),
headers: json_header
)
stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from packageManager and not engines" do
Expand All @@ -2211,6 +2224,14 @@
body: fixture_to_response("projects/generic/package_manager_with_ver_with_engine_info_pnpm", "package.json"),
headers: json_header
)
stub_request(:get, File.join(url, "package.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
# body: fixture_to_response("projects/generic/package_manager_with_ver_with_no_engine_info_pnpm",
# "package.json"),
headers: json_header
)
end

it "fetches package.json fine and pnpm version is picked from packageManager and not engines" do
Expand All @@ -2230,8 +2251,18 @@
stub_request(:get, File.join(url, "package.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/generic/package_manager_with_ver_with_no_engine_info_pnpm",
"package.json"),
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
# body: fixture_to_response("projects/generic/package_manager_with_ver_with_no_engine_info_pnpm",
# "package.json"),
headers: json_header
)

stub_request(:get, File.join(url, "package.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
# body: fixture_to_response("projects/generic/package_manager_with_ver_with_no_engine_info_pnpm",
# "package.json"),
headers: json_header
)
end
Expand All @@ -2257,6 +2288,13 @@
"package.json"),
headers: json_header
)

stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from packageManager" do
Expand All @@ -2280,6 +2318,13 @@
"package.json"),
headers: json_header
)

stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from packageManager and not engines" do
Expand All @@ -2303,6 +2348,13 @@
"package.json"),
headers: json_header
)

stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from packageManager and not engines" do
Expand All @@ -2326,6 +2378,12 @@
"package.json"),
headers: json_header
)
stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from engines" do
Expand All @@ -2349,6 +2407,13 @@
"package.json"),
headers: json_header
)

stub_request(:get, File.join(url, "package-lock.json?ref=sha"))
.to_return(
status: 200,
body: fixture_to_response("projects/npm8/simple", "package-lock.json"),
headers: json_header
)
end

it "fetches package.json fine and yarn version is picked from engines" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
.with(:enable_corepack_for_npm_and_yarn).and_return(enable_corepack_for_npm_and_yarn)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:enable_shared_helpers_command_timeout).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning).and_return(true)
end

after do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
.with(:enable_corepack_for_npm_and_yarn).and_return(enable_corepack_for_npm_and_yarn)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:enable_shared_helpers_command_timeout).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:avoid_duplicate_updates_package_json).and_return(false)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
.with(:enable_corepack_for_npm_and_yarn).and_return(enable_corepack_for_npm_and_yarn)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:enable_shared_helpers_command_timeout).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:avoid_duplicate_updates_package_json).and_return(false)
end
Expand Down
8 changes: 1 addition & 7 deletions npm_and_yarn/spec/dependabot/npm_and_yarn/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
context "when the feature flag :enable_corepack_for_npm_and_yarn is enabled" do
before do
allow(Dependabot::Experiments).to receive(:enabled?).with(:enable_corepack_for_npm_and_yarn).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?).with(:npm_v6_deprecation_warning).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?).with(:npm_fallback_version_above_v6).and_return(true)
end

it "returns true if lockfileVersion is 3 or higher" do
Expand All @@ -393,17 +393,11 @@
context "when the feature flag :enable_corepack_for_npm_and_yarn is disabled" do
before do
allow(Dependabot::Experiments).to receive(:enabled?).with(:enable_corepack_for_npm_and_yarn).and_return(false)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning)
.and_return(true)
end

context "when :npm_fallback_version_above_v6 is enabled" do
before do
allow(Dependabot::Experiments).to receive(:enabled?).with(:npm_fallback_version_above_v6).and_return(true)
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:npm_v6_deprecation_warning)
.and_return(true)
end

it "returns true if lockfileVersion is 2 or higher" do
Expand Down
Loading
Loading