diff --git a/node_modules/libnpmsearch/.travis.yml b/node_modules/libnpmsearch/.travis.yml new file mode 100644 index 000000000000..db5ea8b01864 --- /dev/null +++ b/node_modules/libnpmsearch/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +sudo: false +node_js: + - "10" + - "9" + - "8" + - "6" diff --git a/node_modules/libnpmsearch/CHANGELOG.md b/node_modules/libnpmsearch/CHANGELOG.md index 6ca044d3f48b..9417b57563a6 100644 --- a/node_modules/libnpmsearch/CHANGELOG.md +++ b/node_modules/libnpmsearch/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [2.0.1](https://github.com/npm/libnpmsearch/compare/v2.0.0...v2.0.1) (2019-06-10) + + +### Bug Fixes + +* **opts:** support `opts.from` properly ([#2](https://github.com/npm/libnpmsearch/issues/2)) ([da6636c](https://github.com/npm/libnpmsearch/commit/da6636c)) +* **standard:** standard --fix ([beca19c](https://github.com/npm/libnpmsearch/commit/beca19c)) + + + # [2.0.0](https://github.com/npm/libnpmsearch/compare/v1.0.0...v2.0.0) (2018-08-28) diff --git a/node_modules/libnpmsearch/README.md b/node_modules/libnpmsearch/README.md index 6617ddb89d11..a83988cc2867 100644 --- a/node_modules/libnpmsearch/README.md +++ b/node_modules/libnpmsearch/README.md @@ -46,7 +46,7 @@ console.log(await search('libnpm')) The following opts are used directly by `libnpmsearch` itself: * `opts.limit` - Number of results to limit the query to. Default: 20 -* `opts.offset` - Offset number for results. Used with `opts.limit` for pagination. Default: 0 +* `opts.from` - Offset number for results. Used with `opts.limit` for pagination. Default: 0 * `opts.detailed` - If true, returns an object with `package`, `score`, and `searchScore` fields, with `package` being what would usually be returned, and the other two containing details about how that package scored. Useful for UIs. Default: false * `opts.sortBy` - Used as a shorthand to set `opts.quality`, `opts.maintenance`, and `opts.popularity` with values that prioritize each one. Should be one of `'optimal'`, `'quality'`, `'maintenance'`, or `'popularity'`. Default: `'optimal'` * `opts.maintenance` - Decimal number between `0` and `1` that defines the weight of `maintenance` metrics when scoring and sorting packages. Default: `0.65` (same as `opts.sortBy: 'optimal'`) diff --git a/node_modules/libnpmsearch/appveyor.yml b/node_modules/libnpmsearch/appveyor.yml new file mode 100644 index 000000000000..9cc64c58e02f --- /dev/null +++ b/node_modules/libnpmsearch/appveyor.yml @@ -0,0 +1,22 @@ +environment: + matrix: + - nodejs_version: "10" + - nodejs_version: "9" + - nodejs_version: "8" + - nodejs_version: "6" + +platform: + - x64 + +install: + - ps: Install-Product node $env:nodejs_version $env:platform + - npm config set spin false + - npm install + +test_script: + - npm test + +matrix: + fast_finish: true + +build: off diff --git a/node_modules/libnpmsearch/index.js b/node_modules/libnpmsearch/index.js index b84cab150bea..995549aeee03 100644 --- a/node_modules/libnpmsearch/index.js +++ b/node_modules/libnpmsearch/index.js @@ -5,12 +5,12 @@ const getStream = require('get-stream') const npmFetch = require('npm-registry-fetch') const SearchOpts = figgyPudding({ - detailed: {default: false}, - limit: {default: 20}, - from: {default: 0}, - quality: {default: 0.65}, - popularity: {default: 0.98}, - maintenance: {default: 0.5}, + detailed: { default: false }, + limit: { default: 20 }, + from: { default: 0 }, + quality: { default: 0.65 }, + popularity: { default: 0.98 }, + maintenance: { default: 0.5 }, sortBy: {} }) @@ -60,6 +60,7 @@ function searchStream (query, opts) { query: { text: Array.isArray(query) ? query.join(' ') : query, size: opts.limit, + from: opts.from, quality: opts.quality, popularity: opts.popularity, maintenance: opts.maintenance diff --git a/node_modules/libnpmsearch/package.json b/node_modules/libnpmsearch/package.json index 50e74c7adbff..041dc168ddc2 100644 --- a/node_modules/libnpmsearch/package.json +++ b/node_modules/libnpmsearch/package.json @@ -1,32 +1,29 @@ { - "_args": [ - [ - "libnpmsearch@2.0.0", - "/Users/zkat/Documents/code/work/npm" - ] - ], - "_from": "libnpmsearch@2.0.0", - "_id": "libnpmsearch@2.0.0", + "_from": "libnpmsearch@2.0.1", + "_id": "libnpmsearch@2.0.1", "_inBundle": false, - "_integrity": "sha512-vd+JWbTGzOSfiOc+72MU6y7WqmBXn49egCCrIXp27iE/88bX8EpG64ST1blWQI1bSMUr9l1AKPMVsqa2tS5KWA==", + "_integrity": "sha512-K0yXyut9MHHCAH+DOiglQCpmBKPZXSUu76+BE2maSEfQN15OwNaA/Aiioe9lRFlVFOr7WcuJCY+VSl+gLi9NTA==", "_location": "/libnpmsearch", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "libnpmsearch@2.0.0", + "raw": "libnpmsearch@2.0.1", "name": "libnpmsearch", "escapedName": "libnpmsearch", - "rawSpec": "2.0.0", + "rawSpec": "2.0.1", "saveSpec": null, - "fetchSpec": "2.0.0" + "fetchSpec": "2.0.1" }, "_requiredBy": [ + "#USER", + "/", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-2.0.0.tgz", - "_spec": "2.0.0", - "_where": "/Users/zkat/Documents/code/work/npm", + "_resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-2.0.1.tgz", + "_shasum": "eccc73a8fbf267d765d18082b85daa2512501f96", + "_spec": "libnpmsearch@2.0.1", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Kat Marchán", "email": "kzm@zkat.tech" @@ -34,17 +31,19 @@ "bugs": { "url": "https://github.com/npm/libnpmsearch/issues" }, + "bundleDependencies": false, "dependencies": { "figgy-pudding": "^3.5.1", "get-stream": "^4.0.0", "npm-registry-fetch": "^3.8.0" }, + "deprecated": false, "description": "Programmatic API for searching in npm and compatible registries.", "devDependencies": { "nock": "^9.6.1", - "standard": "*", + "standard": "^12.0.0", "standard-version": "*", - "tap": "*", + "tap": "^12.0.1", "weallbehave": "*", "weallcontribute": "*" }, @@ -70,5 +69,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "2.0.0" + "version": "2.0.1" } diff --git a/node_modules/libnpmsearch/test/index.js b/node_modules/libnpmsearch/test/index.js index f926af6da855..bec5c70e4642 100644 --- a/node_modules/libnpmsearch/test/index.js +++ b/node_modules/libnpmsearch/test/index.js @@ -6,7 +6,7 @@ const qs = require('querystring') const test = require('tap').test const tnock = require('./util/tnock.js') -const OPTS = figgyPudding({registry: {}})({ +const OPTS = figgyPudding({ registry: {} })({ registry: 'https://mock.reg/' }) @@ -17,6 +17,7 @@ test('basic test', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -42,6 +43,7 @@ test('search.stream', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -69,6 +71,7 @@ test('accepts a limit option', t => { const query = qs.stringify({ text: 'oo', size: 3, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -81,7 +84,29 @@ test('accepts a limit option', t => { { package: { name: 'cool', version: '1.0.0' } } ] }) - return search('oo', OPTS.concat({limit: 3})).then(results => { + return search('oo', OPTS.concat({ limit: 3 })).then(results => { + t.equal(results.length, 4, 'returns more results if endpoint does so') + }) +}) + +test('accepts a from option', t => { + const query = qs.stringify({ + text: 'oo', + size: 20, + from: 1, + quality: 0.65, + popularity: 0.98, + maintenance: 0.5 + }) + tnock(t, REG).get(`/-/v1/search?${query}`).once().reply(200, { + objects: [ + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.1.0' } }, + { package: { name: 'cool', version: '1.0.0' } }, + { package: { name: 'cool', version: '1.0.0' } } + ] + }) + return search('oo', OPTS.concat({ from: 1 })).then(results => { t.equal(results.length, 4, 'returns more results if endpoint does so') }) }) @@ -90,6 +115,7 @@ test('accepts quality/mainenance/popularity options', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 1, popularity: 2, maintenance: 3 @@ -115,6 +141,7 @@ test('sortBy: quality', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 1, popularity: 0, maintenance: 0 @@ -138,6 +165,7 @@ test('sortBy: popularity', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0, popularity: 1, maintenance: 0 @@ -161,6 +189,7 @@ test('sortBy: maintenance', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0, popularity: 0, maintenance: 1 @@ -184,6 +213,7 @@ test('sortBy: optimal', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -207,6 +237,7 @@ test('detailed format', t => { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0, popularity: 0, maintenance: 1 @@ -252,6 +283,7 @@ test('space-separates and URI-encodes multiple search params', t => { const query = qs.stringify({ text: 'foo bar:baz quux?=', size: 1, + from: 0, quality: 1, popularity: 2, maintenance: 3 diff --git a/package-lock.json b/package-lock.json index bb8a09ff674f..46e334da2b14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3236,9 +3236,9 @@ } }, "libnpmsearch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-2.0.0.tgz", - "integrity": "sha512-vd+JWbTGzOSfiOc+72MU6y7WqmBXn49egCCrIXp27iE/88bX8EpG64ST1blWQI1bSMUr9l1AKPMVsqa2tS5KWA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/libnpmsearch/-/libnpmsearch-2.0.1.tgz", + "integrity": "sha512-K0yXyut9MHHCAH+DOiglQCpmBKPZXSUu76+BE2maSEfQN15OwNaA/Aiioe9lRFlVFOr7WcuJCY+VSl+gLi9NTA==", "requires": { "figgy-pudding": "^3.5.1", "get-stream": "^4.0.0", diff --git a/package.json b/package.json index 7d1a22fddc2d..dae23dc4f546 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "libcipm": "^3.0.3", "libnpm": "^2.0.1", "libnpmhook": "^5.0.2", + "libnpmsearch": "^2.0.1", "libnpx": "^10.2.0", "lock-verify": "^2.1.0", "lockfile": "^1.0.4", diff --git a/test/tap/search.all-package-search.js b/test/tap/search.all-package-search.js index 419e4fdeed69..1115dcaf1ae3 100644 --- a/test/tap/search.all-package-search.js +++ b/test/tap/search.all-package-search.js @@ -146,6 +146,7 @@ searches.forEach(function (search) { const query = qs.stringify({ text: search.term, size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 diff --git a/test/tap/search.js b/test/tap/search.js index 70d17e5469d4..a7e269df7abd 100644 --- a/test/tap/search.js +++ b/test/tap/search.js @@ -35,6 +35,7 @@ test('notifies when there are no results', function (t) { const query = qs.stringify({ text: 'none', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -60,6 +61,7 @@ test('spits out a useful error when no cache nor network', function (t) { const query = qs.stringify({ text: 'foo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -91,6 +93,7 @@ test('can switch to JSON mode', function (t) { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -130,6 +133,7 @@ test('JSON mode does not notify on empty', function (t) { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -157,6 +161,7 @@ test('can switch to tab separated mode', function (t) { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5 @@ -187,6 +192,7 @@ test('tab mode does not notify on empty', function (t) { const query = qs.stringify({ text: 'oo', size: 20, + from: 0, quality: 0.65, popularity: 0.98, maintenance: 0.5