-
Notifications
You must be signed in to change notification settings - Fork 12k
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(@angular/cli): handle NPM_CONFIG environment variables during ng update and ng add #21297
fix(@angular/cli): handle NPM_CONFIG environment variables during ng update and ng add #21297
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
@googlebot I signed it! |
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.
Thanks for your contribution.
I did take a quick look at this and it appears that some wrong assumptions were made.
- You can use NPMRC togather environment variables. The latter will override the former.
engine-strict = true
registry = http://foo.com
NPM_CONFIG_REGISTRY=http://bar.com npm i
Should result in the following
{
registry: 'http://bar.com',
'engine-strict': true,
}
- Environment name variables need to be normalized
NPM_CONFIG_HTTPS_PROXY
->https-proxy
. The rules are trim the first 11 characters, lowercase and replace_
with-
.
Once the above are addressed, can you also add an E2E test, something similar to https://github.com/angular/angular-cli/blob/master/tests/legacy-cli/e2e/tests/commands/add/secure-registry.ts but instead of using an NPMRC to set the authentication, use an environment variable?. When you are at this stage, I can help you with this.
Thanks for reviewing so quickly, Alan. I'll get started on the changes and let you know if I have any issues. |
Just to clarify, @alan-agius4, the use case that I'm trying to address is when there is no configuration file present. When that occurs, we have found that the environment variables are never looked at because the substitution is only done in the existing code if a file is found. This leads to The code I added will address this scenario. Are you saying that the code shouldn't be needed at all or are you asking for a change to the logic I've added? I'll work on adding an E2E test in the meantime to illustrate this use case. |
Hi, I am asking for changes in logic to make this code behave as NPM would. Because certain assumptions made during this change are not correct.
The commit message should also be updated to something like the below;
|
Thanks for the clarification. Changes coming. |
@alan-agius4 I believe I have everything up and running now. Took me a while to pin down some of the inadvertent changes to the environment variables in the tests but I think I found them all. Please review and let me know what you think. |
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.
Thanks for this, a couple of NITs.
…update and ng add Some organizations are moving away from storing tokens/secrets in an NPM config file in favor of environment variables that only exist for the span of a terminal session. This commit will make sure those variables are read even when there is no NPM config file present.
Looks like we're back to a passing test suite. Let me know if there's anything else you'd like me to do. |
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.
Thanks for your contribution.
Thanks for your patience and guidance, @alan-agius4. |
…date` and `ng add` With this change we handle yarn specific environment variables during `ng update` and `ng add`. This is a follow up of #21297
@mikejancar, welcome and thanks again for your contribution. FYI: I did follow up to support Yarn enviorment vars #21378 |
I did see that. Nice follow up. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Some organizations are moving away from storing tokens/secrets in an npm config file in favor of environment variables that only exist for the span of a terminal session. This commit will read those variables in when no options have been configured via a file.
From a testing perspective, I was not able to get the full unit test/e2e suites to run successfully. The unit test suite fails immediately with a Bazel build failure. If you have any insight into what might be causing this, I'm more than happy to keep trying things. I wasn't very successful at finding similar issues in the normal places (i.e. Stack Overflow).
The full e2e suite failed at different steps in each of my attempts. The latest one is below as an example. If there's some common gotchas with the e2e tests, I'm willing to try again.
I was able to successfully run the following tests which looked to be the most relevant to the logic I was updating.