Skip to content
This repository was archived by the owner on May 17, 2021. It is now read-only.

Commit 6011d67

Browse files
authored
chore(deps): COMPASS-4191: Switch to namespaced fork of triejs on npm (#62)
[COMPASS-4191](https://jira.mongodb.org/browse/COMPASS-4191) notes: > vscode `npm run package` fails like so: https://dev.azure.com/team-compass/vscode/_build/results?buildId=746&view=logs&j=291b3e6c-60a9-5f30-6b17-b27c7388dcd0&t=73e02479-b06a-558b-66de-a6177ecb9da0&l=63 > > ``` > ERROR Command failed: npm list --production --parseable --depth=99999 --loglevel=error > npm ERR! missing: triejs@github:rueckstiess/triejs, required by mongodb-index-model@2.5.0 > ``` The [changes to triejs are minimal](pthurlow/triejs@master...rueckstiess:master) in the fork so I made [`@mongodb-js/triejs`](https://npm.im/@mongodb-js/triejs) to remove the `git://` dep complexity from our build toolchain. While I'm in here, I've also done dependency updates, fixed tests, and added additional debugging for Compass' sake. * chore: Update dependencies ``` ☉ [triejs] index-model/ ncu -u async lodash mongodb mongodb-js-errors mongodb-ns debug eslint-config-mongodb-js mocha mongodb-js-precommit mongodb-runner; npm i;Upgrading /Users/lucas/index-model/package.json [====================] 10/10 100% async ^1.5.2 → ^3.2.0 lodash ^4.8.2 → ^4.17.15 mongodb ^3.1.9 → ^3.5.4 mongodb-js-errors ^0.4.0 → ^0.5.0 mongodb-ns ^2.0.0 → ^2.2.0 debug ^2.2.0 → ^4.1.1 eslint-config-mongodb-js ^3.0.1 → ^5.0.3 mocha ^5.2.0 → ^7.1.0 mongodb-js-precommit ^2.0.0 → ^2.2.1 mongodb-runner ^4.7.1 → ^4.8.0 ``` * chore: Fixes for dependency updates - `async@3` tasks in an `auto()` chain have callback and data args flipped from `async@1.5` - `mongodb` prints warning unless `useUnifiedTopology: true` in `connect()` - `mocha.opts` file is deprecated - bring travis and npmignore templates up to date
1 parent c8731b0 commit 6011d67

File tree

8 files changed

+1645
-2449
lines changed

8 files changed

+1645
-2449
lines changed

.npmignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.jshintrc
2-
.jsfmtrc
1+
.eslintrc
32
.travis.yml
4-
.zuul.yml
5-
examples/
3+
img/
64
test/

.travis.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
language: node_js
2-
sudo: false
2+
dist: bionic
33
node_js:
4-
- 8.9.3
5-
- 10.2.1
4+
- 12.4.0
65
script:
76
- npm run check
87
- npm test
9-
cache:
10-
directories:
11-
- node_modules
8+
cache: npm

lib/fetch.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ function attach(anything, done) {
2222

2323
/**
2424
* get basic index information via `db.collection.indexes()`
25-
* @param {Function} done callback
2625
* @param {object} results results from async.auto
26+
* @param {Function} done callback
2727
*/
28-
function getIndexes(done, results) {
28+
function getIndexes(results, done) {
2929
var client = results.client;
3030
var ns = mongodbNS(results.namespace);
3131
client
@@ -45,10 +45,10 @@ function getIndexes(done, results) {
4545

4646
/**
4747
* get index statistics via `db.collection.aggregate({$indexStats: {}})`
48-
* @param {Function} done callback
4948
* @param {object} results results from async.auto
49+
* @param {Function} done callback
5050
*/
51-
function getIndexStats(done, results) {
51+
function getIndexStats(results, done) {
5252
var client = results.client;
5353
var ns = mongodbNS(results.namespace);
5454
var pipeline = [
@@ -62,10 +62,12 @@ function getIndexStats(done, results) {
6262
}
6363
}
6464
];
65+
debug('Getting $indexStats for %s', results.namespace);
6566
var collection = client.db(ns.database).collection(ns.collection);
6667
collection.aggregate(pipeline, { cursor: {} }).toArray(function(err, res) {
6768
if (err) {
6869
if (isNotAuthorizedError(err)) {
70+
debug('Not authorized to get index stats', err);
6971
/**
7072
* In the 3.2 server, `readWriteAnyDatabase@admin` does not grant sufficient privileges for $indexStats.
7173
* The `clusterMonitor` role is required to run $indexStats.
@@ -75,7 +77,7 @@ function getIndexStats(done, results) {
7577
}
7678

7779
if (err.message.match(/Unrecognized pipeline stage name/)) {
78-
// $indexStats not yet supported, return empty document
80+
debug('$indexStats not yet supported, return empty document', err);
7981
return done(null, {});
8082
}
8183
done(err);
@@ -89,13 +91,14 @@ function getIndexStats(done, results) {
8991

9092
/**
9193
* get index sizes via `db.collection.stats()` (`indexSizes` field)
92-
* @param {Function} done callback
9394
* @param {object} results results from async.auto
95+
* @param {Function} done callback
9496
*/
9597

96-
function getIndexSizes(done, results) {
98+
function getIndexSizes(results, done) {
9799
var client = results.client;
98100
var ns = mongodbNS(results.namespace);
101+
debug('Getting index sizes for %s', results.namespace);
99102
client
100103
.db(ns.database)
101104
.collection(ns.collection)
@@ -107,22 +110,24 @@ function getIndexSizes(done, results) {
107110
);
108111
return done(null, {});
109112
}
113+
debug('Error getting index sizes for %s', results.namespace, err);
110114
return done(err);
111115
}
112116

113117
res = _.mapValues(res.indexSizes, function(size) {
114118
return { size: size };
115119
});
120+
debug('Got index sizes for %s', results.namespace, res);
116121
done(null, res);
117122
});
118123
}
119124

120125
/**
121126
* merge all information together for each index
122-
* @param {Function} done callback
123127
* @param {object} results results from async.auto
128+
* @param {Function} done callback
124129
*/
125-
function combineStatsAndIndexes(done, results) {
130+
function combineStatsAndIndexes(results, done) {
126131
var indexes = results.getIndexes;
127132
var stats = results.getIndexStats;
128133
var sizes = results.getIndexSizes;
@@ -153,12 +158,13 @@ function getIndexDetails(client, namespace, done) {
153158
combineStatsAndIndexes
154159
]
155160
};
156-
161+
debug('Getting index details for namespace %s', namespace);
157162
async.auto(tasks, function(err, results) {
158163
if (err) {
159-
// report error
164+
debug('Failed to get index details for namespace %s', namespace, err);
160165
return done(err);
161166
}
167+
debug('Index details for namespace %s', namespace, results.indexes);
162168
// all info was collected in indexes
163169
return done(null, results.indexes);
164170
});

lib/warnings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var Triejs = require('triejs');
1+
var Triejs = require('@mongodb-js/triejs');
22
var Model = require('ampersand-model');
33
var Collection = require('ampersand-collection');
44
var _ = require('lodash');

0 commit comments

Comments
 (0)