Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Add a success message to adduser/login #10903

Closed
wants to merge 2 commits into from

Conversation

ekmartin
Copy link
Contributor

Basically just adds a green Authentication successful. message to login/adduser (fixes #10775):
image

Also refactors some of the adduser tests to have less duplicate code.

@othiym23
Copy link
Contributor

Thanks for putting this together, and thanks for cleaning up the tests!

Two bits of feedback:

  1. Anything using color must observe the --color / --no-color configuration option used elsewhere in the code base. Also, I'm not sure that color is super useful in this case, as it's a simple single line of output. Consider ditching that.

  2. Take a look at the resolution to @zkat's resolution of UX: Add login success message #10775 (comment) – it would be useful to have something like

    Logged in as othiym23 on https://registry.npmjs.org/.
    

    or

    Logged in as othiym23 to scope @nothingness on https://registry.npmjs.org/.
    

    which is a nice visual confirmation of what the user actually did.

If you can work those bits in, we'll get this merged in the next following release. Thanks again for your time!

@ekmartin
Copy link
Contributor Author

That seems better indeed.
Without a scope it now prints:
Logged in as ekmartin on https://registry.npmjs.org/.

With a scope it prints:
Logged in as ekmartin to scope @myco on https://registry.npmjs.org/.

Also removed the color.

@othiym23
Copy link
Contributor

Fantastic! Pending Travis being green, this can be merged to both npm@master and npm@2.x.


if (remaining === 0) runner.stdin.end()
test('npm login --scope', function (t) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@othiym23, maybe the --scope test should check a few other things as well?
Examples:

  • That @scope:registry is set to the registry URI in the config upon completion.
  • That the correct registry URI is set when a scope is given.

I.e. this block of code: https://github.com/npm/npm/blob/master/lib/adduser.js#L133-L140 (by the way, what does the multiple argument npm.config.get do here (npm.config.get('registry', 'cli'))?

Could test the @ prefixing of scopes too.

Copy link
Contributor

Choose a reason for hiding this comment

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

what does the multiple argument npm.config.get do here (npm.config.get('registry', 'cli'))?

npm uses a package called config-chain to set up the precedence hierarchy between the various configuration files, environment variables, and configuration options set as command-line arguments. It's not really widely-known, but you can query one of those sources in particular by passing its name to config.get() as the second parameter, as you see here. The reason for this is that for the specific case of npm login, we don't want a scope set in a config file to trigger the scope-specific behavior for login.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, those tests sound like great ideas. You have a few days until we're going to be in a position to merge this change, so if you want to try other approaches and refine the tests, that would be greatly appreciated. Just let us know, so we can re-review before merging. Thanks for your help!

@ekmartin
Copy link
Contributor Author

Added a few tests for --scope in a7f9576.

zkat added a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
0.8 http streams have a bug, where if they're paused with data in
their buffers when the socket closes, they call `end` before emptying
those buffers, which results in the entire pipeline ending and thus
the point that applied backpressure never being able to trigger a
`resume`.

We work around this by piping into a pass through stream that has
unlimited buffering. The pass through stream is from readable-stream
and is thus a current streams3 implementation that is free of these
bugs even on 0.8.

PR-URL: #10903
Credit: @iarna
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat added a commit that referenced this pull request Jan 19, 2016
Specially on travis -- changing ports prevents that conflict
from happening, but we'll need to keep doing it for every test
that uses git.

PR-URL: #10903
Credit: @zkat
zkat added a commit that referenced this pull request Jan 19, 2016
zkat added a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
zkat pushed a commit that referenced this pull request Jan 19, 2016
@iarna iarna added this to the next milestone Jan 20, 2016
iarna pushed a commit that referenced this pull request Jan 20, 2016
iarna pushed a commit that referenced this pull request Jan 21, 2016
@iarna
Copy link
Contributor

iarna commented Jan 25, 2016

This was merged to 3.6.0 & 2.14.16! =)

@iarna iarna closed this Jan 25, 2016
@ekmartin ekmartin deleted the adduser_message branch January 25, 2016 22:31
@ekmartin
Copy link
Contributor Author

Great!

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

Successfully merging this pull request may close these issues.

3 participants