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

Conversation

@zkat
Copy link
Contributor

@zkat zkat commented Jan 14, 2017

Yay!

So this PR makes it so the npm CLI actually hits the shiny new search endpoint! Default npm search on the main registry should be blazing fast now.

No. Seriously:

fastaf

The search system still falls back to cache or /-/all-based searches for registries that don't support this endpoint, and if you happen to have a cache while running offline, it'll use that cache with classic search.

To-Do

Note: The PR is basically ready to review of the bulk of the changes, but below are a couple of items that are still pending.

  • unit tests for esearch
  • get rid of gunzip-maybe because it adds almost 2MB
  • Figure out what to do about --searchlimit when using all-package-search
  • unit tests for all-package-search
  • Check what negation is gonna be like
  • figure out whether/how to add sorting to esearch

@zkat zkat added the review label Jan 14, 2017
@zkat zkat requested review from bcoe and iarna January 14, 2017 10:09
@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 85.929% when pulling 9368967 on zkat/fastsearch into 58aa3b6 on latest.

@bcoe
Copy link
Contributor

bcoe commented Jan 16, 2017

@zkat this is amazing; I will read through the pull while OSSing over the next couple days. We should get you added to the npms.io slack too; so we can discuss adding --searchexclude.

CC: @satazor, @atduarte, how cool is this?!

Copy link
Contributor

@bcoe bcoe left a comment

Choose a reason for hiding this comment

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

this is looking pretty solid to me; I like the how you fallback to the old search.

One thing comes to mind, because browserify-zlib check in there fixture directory, we end up with some pretty odd artifacts in the bundled dependencies. e.g., this picture of a person:

https://github.com/npm/npm/blob/936896722f6ba18a90120c7fac475ddecfecd9cd/node_modules/gunzip-maybe/node_modules/browserify-zlib/test/fixtures/person.jpg

It might be worth opening an issue, or simply sending a pull-request to browserify-zlib that removes test files from the package.

function esearch (opts) {
var stream = ms.through.obj()

mapToRegistry('-/v1/search', npm.config, function (er, uri, auth) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this warms my heart 👍

@satazor
Copy link

satazor commented Jan 16, 2017

This is definitively cool! One question: does it support qualifiers? e.g.: npm search author:sindresorhus

@bcoe I guess you have permissions to invite @zkat to our slack.

@zkat
Copy link
Contributor Author

zkat commented Jan 16, 2017

@satazor all the current search syntax is supported because we pretty much pass arguments directly to the endpoint. You can do maintainer:zkat just fine. :)

EDIT: oops. You already talked about that! I'd love an invite to the Slack :)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.06%) to 85.798% when pulling 5b6eb36 on zkat/fastsearch into 58aa3b6 on latest.

@atduarte
Copy link

Awesome! :D

@zkat zkat removed the in-progress label Jan 18, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 85.95% when pulling a514935 on zkat/fastsearch into 58aa3b6 on latest.

@bcoe
Copy link
Contributor

bcoe commented Jan 18, 2017

🎉 🎈 this is really exciting.

Copy link
Contributor

@iarna iarna left a comment

Choose a reason for hiding this comment

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

This looks great! Can't wait to have it!

I had a couple of nits but nothing blocking.

streaming: true
}
var q = buildQuery(opts)
npm.registry.request(uri + '?text=' + encodeURIComponent(q) + '&size=' + opts.limit, params, function (er, res) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Absurdly picky style note: If we use err then standard can complaint if we fail to check it. I've been trying to get in the habit of using err instead of er so I can have that validation.

// Modify how `res` is used here at your own risk.
var entryStream = ms.pipeline.obj(
res,
ms.through(function (chunk, enc, cb) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just to turn res into a modern stream?
I think usingnew stream.PassThrough() here would be less ambiguous..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it's just literally that weird and there's something about using this particular type of passthrough that worked through an issue I was having. I didn't do the due diligence of figuring out what was happening back then (during the original rewrite, which this code is based on). So maybe I'll just have to do it but siiiiiggghhhh

}

function cleanup () {
server.done()
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this in a different place than server.close()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

close shuts down the server. done does missing-request checks while letting us reuse the same server (so, it errors if we don't hit the mocked endpoint at all)

@@ -0,0 +1,192 @@
var common = require('../common-tap.js')
Copy link
Contributor

Choose a reason for hiding this comment

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

search.esearch.js? Not search-esearch.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's just me being inconsistent. I've been using the former with pacote and cacache and it just feels nicer for hierarchies of tests in a single flat dir

@zkat zkat added this to the next milestone Jan 25, 2017
@zkat zkat changed the base branch from latest to release-next January 25, 2017 13:04
@coveralls
Copy link

Coverage Status

Coverage increased (+0.08%) to 85.94% when pulling d93f97d70eda95558ac44a345f58d7899980e8f8 on zkat/fastsearch into 04fca22 on release-next.

zkat added 5 commits January 25, 2017 14:42
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
@zkat zkat merged commit c56618c into release-next Jan 25, 2017
zkat added a commit that referenced this pull request Jan 25, 2017
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
zkat added a commit that referenced this pull request Jan 25, 2017
zkat added a commit that referenced this pull request Jan 25, 2017
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
zkat added a commit that referenced this pull request Jan 25, 2017
PR-URL: #15481
Credit: @zkat
Reviewed-By: @iarna
Reviewed-By: @bcoe
@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 85.952% when pulling eb64046 on zkat/fastsearch into 04fca22 on release-next.

@zkat zkat mentioned this pull request Feb 14, 2017
4 tasks
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.

6 participants