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

NPM: handle EBADENGINE better #7194

Merged
merged 1 commit into from
Apr 28, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ def handle_npm_updater_error(error)
raise Dependabot::DependencyFileNotParseable, msg
end

if error_message.include?("EBADENGINE")
msg = "Dependabot uses Node.js #{`node --version`} and NPM #{`npm --version`}. " \
"Due to the engine-strict setting, the update will not succeed."
raise Dependabot::DependencyFileNotResolvable, msg
end

raise error
end
# rubocop:enable Metrics/AbcSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@
end
end

context "with engines-strict and a version that won't work with Dependabot" do
let(:files) { project_dependency_files("npm8/engines") }

it "raises a helpful error" do
expect { updated_npm_lock_content }.
to raise_error(Dependabot::DependencyFileNotResolvable)
end
end

context "when the lockfile does not have indentation" do
let(:files) { project_dependency_files("npm8/simple_no_indentation") }

Expand Down
1 change: 1 addition & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
164 changes: 164 additions & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions npm_and_yarn/spec/fixtures/projects/npm8/engines/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "{{ name }}",
"engines": {
"node": "512",
"npm": "256"
},
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no\\ test\ specified\" && exit 1",
"prettify": "prettier --write \"{{packages/*/src,examples,cypress,scripts}/**/,}*.{js,jsx,ts,tsx,css,md}\""
},
"repository": {
"type": "git",
"url": "git+https://github.com/waltfy/PROTO_TEST.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/waltfy/PROTO_TEST/issues"
},
"homepage": "https://github.com/waltfy/PROTO_TEST#readme",
"dependencies": {
"fetch-factory": "^0.0.1"
},
"devDependencies": {
"etag" : "^1.0.0"
}}