Skip to content

Commit

Permalink
fix: make install-local script work, update react to 17 VSCODE-310 (#471
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Anemy authored Feb 27, 2023
1 parent 7b6222f commit 946d790
Show file tree
Hide file tree
Showing 26 changed files with 1,566 additions and 1,117 deletions.
2 changes: 1 addition & 1 deletion .depcheckrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ignores:
- "@babel/core"
- "@leafygreen-ui/palette"
- "@mongodb-js/prettier-config-compass"
- "@types/jest"
- "buffer"
- "eslint-config-mongodb-js"
- "keytar"
- "electron"
- "mocha-junit-reporter"
- "mocha-multi"
- "mongodb-client-encryption"
Expand Down
2,199 changes: 1,327 additions & 872 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,6 @@
"@iconify-icons/codicon": "^1.2.16",
"@iconify/react": "^1.1.4",
"@leafygreen-ui/logo": "^6.1.3",
"@leafygreen-ui/palette": "^3.4.2",
"@leafygreen-ui/toggle": "^7.0.5",
"@mongodb-js/mongodb-constants": "^0.2.1",
"@mongosh/browser-runtime-electron": "^1.6.2",
Expand All @@ -1020,13 +1019,13 @@
"mongodb-build-info": "^1.5.0",
"mongodb-cloud-info": "^1.1.3",
"mongodb-connection-string-url": "^2.5.3",
"mongodb-data-service": "^22.1.1",
"mongodb-data-service": "^22.4.1",
"mongodb-query-parser": "^2.4.6",
"mongodb-schema": "^10.0.0",
"numeral": "^2.0.6",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react-redux": "^7.2.8",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^8.0.5",
"redux": "^4.2.0",
"ts-log": "^2.2.5",
"uuid": "^8.3.2",
Expand Down Expand Up @@ -1056,6 +1055,7 @@
"@typescript-eslint/eslint-plugin": "^5.38.0",
"@typescript-eslint/parser": "^5.38.0",
"@vscode/test-electron": "^2.1.5",
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"autoprefixer": "^9.8.8",
"buffer": "^6.0.3",
"chai": "^4.3.6",
Expand All @@ -1069,8 +1069,8 @@
"css-loader": "^3.6.0",
"depcheck": "^1.4.3",
"download": "^8.0.0",
"electron": "^23.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"eslint": "^8.23.1",
"eslint-config-mongodb-js": "^5.0.3",
"eslint-plugin-mocha": "^10.1.0",
Expand All @@ -1086,7 +1086,7 @@
"mocha": "^8.4.0",
"mocha-junit-reporter": "^2.0.2",
"mocha-multi": "^1.1.6",
"mongodb-client-encryption": "^2.2.1",
"mongodb-client-encryption": "^2.4.0",
"mongodb-runner": "^4.9.0",
"node-loader": "^0.6.0",
"npm-run-all": "^4.1.5",
Expand Down
3 changes: 1 addition & 2 deletions scripts/no-npm-list-fail.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';
// Monkey-patch child_process so that the `npm list` command run by
// `vsce package` does not fail because of `mongodb` being a 4.x prerelease
// rather than a "proper" version number.
// `vsce package` does not fail.
const child_process = require('child_process');
const origExec = child_process.exec;
child_process.exec = (cmd, options, cb) => {
Expand Down
4 changes: 1 addition & 3 deletions src/editors/collectionDocumentsProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as vscode from 'vscode';
import * as util from 'util';
import { URLSearchParams } from 'url';

import CollectionDocumentsOperationsStore from './collectionDocumentsOperationsStore';
Expand Down Expand Up @@ -85,8 +84,7 @@ export default class CollectionViewProvider
}

try {
const find = util.promisify(dataservice.find.bind(dataservice));
const documents = await find(
const documents = await dataservice.find(
namespace,
{}, // No filter.
{ limit: documentLimit }
Expand Down
3 changes: 1 addition & 2 deletions src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ export default class MongoDBDocumentService {
this._statusView.showMessage('Fetching document...');

try {
const find = util.promisify(dataservice.find.bind(dataservice));
const documents = await find(
const documents = await dataservice.find(
namespace,
{ _id: documentId },
{ limit: 1 }
Expand Down
14 changes: 6 additions & 8 deletions src/explorer/collectionTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as util from 'util';
import * as vscode from 'vscode';
import path from 'path';
import type { DataService } from 'mongodb-data-service';

import DocumentListTreeItem, {
CollectionTypes,
Expand Down Expand Up @@ -72,7 +73,7 @@ export default class CollectionTreeItem
databaseName: string;
namespace: string;

private _dataService: any;
private _dataService: DataService;
private _type: CollectionTypes;
documentCount: number | null = null;

Expand Down Expand Up @@ -320,16 +321,13 @@ export default class CollectionTreeItem
try {
// We fetch the document when we expand in order to show
// the document count in the document list tree item `description`.
const estimatedCount = util.promisify(
this._dataService.estimatedCount.bind(this._dataService)
);

this.documentCount = await estimatedCount(
this.documentCount = await this._dataService.estimatedCount(
this.namespace,
{} // No options.
{}, // No options.
undefined
);

return this.documentCount as number;
return this.documentCount;
} catch (err) {
this.documentCount = null;
return 0;
Expand Down
6 changes: 1 addition & 5 deletions src/explorer/documentListTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as util from 'util';
import * as vscode from 'vscode';
import numeral from 'numeral';

Expand Down Expand Up @@ -202,10 +201,7 @@ export default class DocumentListTreeItem
let documents;

try {
const find = util.promisify(
this._dataService.find.bind(this._dataService)
);
documents = await find(
documents = await this._dataService.find(
this.namespace,
{}, // No filter.
{ limit: this._maxDocumentsToShow }
Expand Down
3 changes: 1 addition & 2 deletions src/explorer/documentTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ export default class DocumentTreeItem
}

async getDocumentContents(): Promise<Document> {
const find = promisify(this.dataService.find.bind(this.dataService));
const documents = await find(
const documents = await this.dataService.find(
this.namespace,
{ _id: this.documentId },
{ limit: 1 }
Expand Down
11 changes: 4 additions & 7 deletions src/explorer/schemaTreeItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as util from 'util';
import * as vscode from 'vscode';
import parseSchema from 'mongodb-schema';
import path from 'path';
Expand All @@ -9,6 +8,7 @@ import formatError from '../utils/formatError';
import { getImagesPath } from '../extensionConstants';
import TreeItemParent from './treeItemParentInterface';
import { MAX_DOCUMENTS_VISIBLE } from './documentListTreeItem';
import { DataService } from 'mongodb-data-service';

const log = createLogger('tree view document list');

Expand Down Expand Up @@ -52,7 +52,7 @@ export default class SchemaTreeItem
collectionName: string;
databaseName: string;

private _dataService: any;
private _dataService: DataService;

isExpanded: boolean;

Expand All @@ -62,7 +62,7 @@ export default class SchemaTreeItem
constructor(
collectionName: string,
databaseName: string,
dataService: any,
dataService: DataService,
isExpanded: boolean,
hasClickedShowMoreFields: boolean,
hasMoreFieldsToShow: boolean,
Expand Down Expand Up @@ -100,10 +100,7 @@ export default class SchemaTreeItem
const namespace = `${this.databaseName}.${this.collectionName}`;
let documents;
try {
const find = util.promisify(
this._dataService.find.bind(this._dataService)
);
documents = await find(
documents = await this._dataService.find(
namespace,
{}, // No filter.
{ limit: MAX_DOCUMENTS_VISIBLE }
Expand Down
31 changes: 18 additions & 13 deletions src/test/suite/editors/activeDBCodeLensProvider.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as vscode from 'vscode';
import { beforeEach, afterEach } from 'mocha';
import { DataService } from 'mongodb-data-service';
import chai from 'chai';
import sinon from 'sinon';
import type { DataService } from 'mongodb-data-service';

import ActiveDBCodeLensProvider from '../../../editors/activeConnectionCodeLensProvider';
import ConnectionController from '../../../connectionController';
Expand Down Expand Up @@ -63,19 +63,24 @@ suite('Active DB CodeLens Provider Test Suite', () => {
const testCodeLensProvider = new ActiveDBCodeLensProvider(
testConnectionController
);
const mockActiveDataService = {
find: (namespace, filter, options, callback): void => {
return callback(null, [{ field: 'Text message' }]);
},
instance: () =>
Promise.resolve({
dataLake: {},
build: {},
genuineMongoDB: {},
host: {},
}),
} as DataService;

const findStub = sinon.stub();
findStub.resolves([
{
field: 'Text message',
},
]);
const instanceStub = sinon.stub();
instanceStub.resolves({
dataLake: {},
build: {},
genuineMongoDB: {},
host: {},
} as unknown as Awaited<ReturnType<DataService['instance']>>);
const mockActiveDataService = {
find: findStub,
instance: instanceStub,
} as Pick<DataService, 'find' | 'instance'> as unknown as DataService;
testConnectionController.setActiveDataService(mockActiveDataService);

beforeEach(() => {
Expand Down
Loading

0 comments on commit 946d790

Please sign in to comment.