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

fix(cli): add prefix hint when installing a package globally #26629

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

mbrdg
Copy link
Contributor

@mbrdg mbrdg commented Oct 29, 2024

closes #26545

Shows a hint when a package is installed globally, otherwise fallbacks to the existing implementation.

@CLAassistant
Copy link

CLAassistant commented Oct 29, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @mbrdg, is there any chance you could add a test for this change?

@mbrdg
Copy link
Contributor Author

mbrdg commented Nov 7, 2024

Thanks for the PR @mbrdg, is there any chance you could add a test for this change?

Rookie mistake on my side, but I got a few questions regarding the test.

First, I've tried to add a new test in tests/integration/install_tests.rs to cover this change. Is this the right place to introduce the new test?

Additionally, I've followed the logic from other tests by instantiating a TestContextBuilder but I'm only able to get module not found errors when a try to install a package from npm and another from jsr without their prefixes. I can't obtain prefix errors because context's http server immediately tries to download from localhost. How can I overcome this issue within the test environment?

@bartlomieju
Copy link
Member

@mbrdg that's correct, you can call .add_npm_env_vars() and .add_jsr_env_vars() which will set up the test context to use testing registry. Then you should be able to install packages like npm:@denotest/bin and jsr:@denotest/add.

@mbrdg mbrdg force-pushed the show-hint-on-global-install branch from d2cc655 to 84ceac0 Compare November 16, 2024 12:46
@mbrdg mbrdg requested a review from bartlomieju November 16, 2024 13:24
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great fix and nice work. Thank you @mbrdg

@bartlomieju bartlomieju merged commit 99d5c6e into denoland:main Nov 16, 2024
17 checks passed
@mbrdg mbrdg deleted the show-hint-on-global-install branch November 16, 2024 14:08
@KnorpelSenf
Copy link
Contributor

I believe that these changes caused a bug for deno install -g for local files. I have opened #26969.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show hint when trying to install a package globally without a :npm/:jsr prefix
4 participants