-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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: add missing scope on flat options #4060
Conversation
Thank you for submitting this PR! ETA: I was wrong, that wouldn't affect folks' having it set in their npmrc. |
Question, what would prevent us from fixing |
It seems
Right now However, the code piece on the above link confuses me about whether it is the right call on to use |
the
Then |
@wraithgar How does it look now? |
lib/utils/config/definitions.js
Outdated
@@ -1782,7 +1782,7 @@ define('scope', { | |||
`, | |||
flatten (key, obj, flatOptions) { | |||
const value = obj[key] | |||
flatOptions.projectScope = value && !/^@/.test(value) ? `@${value}` : value | |||
flatOptions.scope = value && !/^@/.test(value) ? `@${value}` : value |
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.
This still need to be projectScope
because that's where npm-registry-fetch
uses this to set appropriate headers in its requests
MUCH better. Only one fix and that is the flatOptions attribute still must be
|
I see that every mention of scope config throughout the project is named as What do you think? If it is not OK, I can do the rename thing. I'll rebase the fixup commit when I get your confirmation |
It's important to note that when adduser, logout, et al are looking for Keeping it For now I also think saving both to flatOptions is the right choice, and since ONLY npm-registry-fetch consumes that flatOption, we can make it look for |
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.
Lots of unneeded code removed, my favorite kind of PR.
Rebased for better commit messages. Opened another PR to fix the same issue on v7: #4073 |
PR-URL: #4060 Credit: @yuqu Close: #4060 Reviewed-by: @wraithgar
The following command does not add scope into the npmrc file on npm cli versions >=7.7.0 as described in #3515
Apparently 6598bfe refactors the config structure.
flatten
method ofscope
definition somehow setsflatOptions.projectScope
but does not setflatOptions.scope
. On the other hand, adduser command gets the scope parameter from the flat options, which is always resolving to undefined.https://github.com/npm/cli/blob/latest/lib/commands/adduser.js#L28
I don't know if setting
flatOptions.projectScope
was a mistake or intended, hence I just kept it there. Alternatively, it could be renamed toflatOptions.scope
instead of adding another line.References
Fixes #3515