From c98968cf9136630a1d0035341572beb77362fa36 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Thu, 18 Jun 2020 12:57:39 +0200 Subject: [PATCH 01/10] Add ctrl l hotkey and output persisting on toggling --- .../browser-repl/src/components/editor.tsx | 23 +++++++--------- .../src/components/shell-input.tsx | 22 ++++++--------- .../browser-repl/src/components/shell.tsx | 27 +++++++------------ .../compass-shell/compass-shell.jsx | 13 +++++++-- .../compass-shell/compass-shell.less | 6 ++++- .../src/components/info-modal/info-modal.jsx | 3 +++ 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/browser-repl/src/components/editor.tsx b/packages/browser-repl/src/components/editor.tsx index acf4744604..7e5db05633 100644 --- a/packages/browser-repl/src/components/editor.tsx +++ b/packages/browser-repl/src/components/editor.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import AceEditor from 'react-ace'; import { Autocompleter } from '@mongosh/browser-runtime-core'; import { AceAutocompleterAdapter } from './ace-autocompleter-adapter'; @@ -11,35 +10,26 @@ import './ace-theme'; import ace from 'brace'; const tools = ace.acequire('ace/ext/language_tools'); -const noop = (): void => { - // -}; +const noop = (): void => {}; interface EditorProps { onEnter?(): void | Promise; onArrowUpOnFirstLine?(): void | Promise; onArrowDownOnLastLine?(): void | Promise; onChange?(value: string): void | Promise; + onClearCommand?(): void | Promise; autocompleter?: Autocompleter; setInputRef?(ref): void; value?: string; } export class Editor extends Component { - static propTypes = { - onEnter: PropTypes.func, - onArrowUpOnFirstLine: PropTypes.func, - onArrowDownOnLastLine: PropTypes.func, - onChange: PropTypes.func, - setInputRef: PropTypes.func, - value: PropTypes.string - }; - static defaultProps = { onEnter: noop, onArrowUpOnFirstLine: noop, onArrowDownOnLastLine: noop, onChange: noop, + onClearCommand: noop, value: '' }; @@ -60,6 +50,8 @@ export class Editor extends Component { }; render(): JSX.Element { + const { onClearCommand } = this.props; + return ( { this.props.onArrowDownOnLastLine(); } + }, + { + name: 'clearShell', + bindKey: { win: 'Ctrl-L', mac: 'Command-L' }, + exec: onClearCommand } ]} width="100%" diff --git a/packages/browser-repl/src/components/shell-input.tsx b/packages/browser-repl/src/components/shell-input.tsx index 002ba4dda2..cd05a44d41 100644 --- a/packages/browser-repl/src/components/shell-input.tsx +++ b/packages/browser-repl/src/components/shell-input.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import classnames from 'classnames'; import { Editor } from './editor'; import { Autocompleter } from '@mongosh/browser-runtime-core'; @@ -9,9 +8,10 @@ import Icon from '@leafygreen-ui/icon'; const styles = require('./shell-input.less'); interface ShellInputProps { - onInput?(code: string): void | Promise; - history?: readonly string[]; autocompleter?: Autocompleter; + history?: readonly string[]; + onClearCommand?(): void | Promise; + onInput?(code: string): void | Promise; setInputRef?(ref): void; } @@ -20,13 +20,6 @@ interface ShellInputState { } export class ShellInput extends Component { - static propTypes = { - onInput: PropTypes.func, - history: PropTypes.arrayOf(PropTypes.string), - autocompleter: PropTypes.object, - setInputRef: PropTypes.func - }; - readonly state: ShellInputState = { currentValue: '' }; @@ -116,13 +109,14 @@ export class ShellInput extends Component { />); const editor = (); const className = classnames(styles['shell-input']); diff --git a/packages/browser-repl/src/components/shell.tsx b/packages/browser-repl/src/components/shell.tsx index 00d63a8b1b..c799d37d91 100644 --- a/packages/browser-repl/src/components/shell.tsx +++ b/packages/browser-repl/src/components/shell.tsx @@ -1,5 +1,4 @@ import React, { Component } from 'react'; -import PropTypes from 'prop-types'; import classnames from 'classnames'; import { ShellInput } from './shell-input'; import { ShellOutput, ShellOutputEntry } from './shell-output'; @@ -72,22 +71,6 @@ const noop = (): void => { * The browser-repl Shell component */ export class Shell extends Component { - static propTypes = { - runtime: PropTypes.shape({ - evaluate: PropTypes.func.isRequired - }).isRequired, - onOutputChanged: PropTypes.func, - onHistoryChanged: PropTypes.func, - redactInfo: PropTypes.bool, - maxOutputLength: PropTypes.number, - maxHistoryLength: PropTypes.number, - initialOutput: PropTypes.arrayOf(PropTypes.shape({ - format: PropTypes.string.isRequired, - value: PropTypes.any.isRequired - })), - initialHistory: PropTypes.arrayOf(PropTypes.string) - }; - static defaultProps = { onHistoryChanged: noop, onOutputChanged: noop, @@ -162,6 +145,15 @@ export class Shell extends Component { return output; } + private onClearCommand = (): void => { + const output = []; + + Object.freeze(output); + + this.setState({ output }); + this.props.onOutputChanged(output); + }; + private onInput = async(code: string): Promise => { const inputLine: ShellOutputEntry = { format: 'input', @@ -212,6 +204,7 @@ export class Shell extends Component {
{ this.shellInputElement = el; }}> { + this.shellOutput = output; + } + lastOpenHeight = defaultShellHeightOpened; + resizableRef = null; + shellOutput = []; saveHistory = async(history) => { if (!this.props.historyStorage) { @@ -143,11 +148,15 @@ export class CompassShell extends Component { onShellToggleClicked={this.shellToggleClicked} /> {isExpanded && ( -
+
)} diff --git a/packages/compass-shell/src/components/compass-shell/compass-shell.less b/packages/compass-shell/src/components/compass-shell/compass-shell.less index 0b121a8dca..5e59c112a7 100644 --- a/packages/compass-shell/src/components/compass-shell/compass-shell.less +++ b/packages/compass-shell/src/components/compass-shell/compass-shell.less @@ -12,8 +12,12 @@ &-shell-container { flex-grow: 1; - display: flex; + display: none; overflow: auto; border-top: 1px solid @leafygreen__gray--dark-2; + + &-is-expanded { + display: flex; + } } } diff --git a/packages/compass-shell/src/components/info-modal/info-modal.jsx b/packages/compass-shell/src/components/info-modal/info-modal.jsx index 1a37a7c25f..f68d47da37 100644 --- a/packages/compass-shell/src/components/info-modal/info-modal.jsx +++ b/packages/compass-shell/src/components/info-modal/info-modal.jsx @@ -26,6 +26,9 @@ const hotkeys = [{ }, { key: 'Ctrl+H', description: 'Erases one character. Similar to hitting backspace.' +}, { + key: 'Ctrl+L', + description: 'Clears the screen, similar to the clear command.' }, { key: 'Ctrl+T', description: 'Swap the last two characters before the cursor.' From f5dbbafd1ea5f5dbe38de3a31e51580e06868d58 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Fri, 19 Jun 2020 15:27:58 +0200 Subject: [PATCH 02/10] Add general test for browser-repl --- packages/browser-repl/src/index.spec.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 packages/browser-repl/src/index.spec.tsx diff --git a/packages/browser-repl/src/index.spec.tsx b/packages/browser-repl/src/index.spec.tsx new file mode 100644 index 0000000000..1793343c68 --- /dev/null +++ b/packages/browser-repl/src/index.spec.tsx @@ -0,0 +1,23 @@ +// import sinon from 'sinon'; +import React from 'react'; +import { expect } from '../testing/chai'; +import { shallow } from '../testing/enzyme'; + +import { Shell } from './components/shell'; +import { Shell as BrowserRepl } from './index'; + +describe('BrowserRepl', () => { + context('when it is required', () => { + it('renders', () => { + const fakeRuntime: any = {}; + const wrapper = shallow( +
+ +
+ ); + console.log('wrapper', wrapper); + expect(wrapper.find(Shell)).to.have.lengthOf(1); + }); + }); +}); + From 7c606dd23ccb72cca6f8381a024559f8a82d29f1 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Fri, 19 Jun 2020 17:24:26 +0200 Subject: [PATCH 03/10] Move completions to runtime --- packages/cli-repl/src/completer.ts | 16 ++++++++-------- packages/shell-api/src/decorators.ts | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/cli-repl/src/completer.ts b/packages/cli-repl/src/completer.ts index 928c1db909..76e5bc0818 100644 --- a/packages/cli-repl/src/completer.ts +++ b/packages/cli-repl/src/completer.ts @@ -16,14 +16,6 @@ const BASE_COMPLETIONS = EXPRESSION_OPERATORS.concat( const MATCH_COMPLETIONS = QUERY_OPERATORS.concat(BSON_TYPES); -const SHELL_COMPLETIONS = shellSignatures.ShellApi.attributes; -const COLL_COMPLETIONS = shellSignatures.Collection.attributes; -const DB_COMPLETIONS = shellSignatures.Database.attributes; -const AGG_CURSOR_COMPLETIONS = shellSignatures.AggregationCursor.attributes; -const COLL_CURSOR_COMPLETIONS = shellSignatures.Cursor.attributes; -const RS_COMPLETIONS = shellSignatures.ReplicaSet.attributes; -const SHARD_COMPLETE = shellSignatures.Shard.attributes; - /** * The proect stage operator. */ @@ -42,6 +34,14 @@ const GROUP = '$group'; * @returns {array} Matching Completions, Current User Input. */ function completer(mdbVersion: string, line: string): [string[], string] { + const SHELL_COMPLETIONS = shellSignatures.ShellApi.attributes; + const COLL_COMPLETIONS = shellSignatures.Collection.attributes; + const DB_COMPLETIONS = shellSignatures.Database.attributes; + const AGG_CURSOR_COMPLETIONS = shellSignatures.AggregationCursor.attributes; + const COLL_CURSOR_COMPLETIONS = shellSignatures.Cursor.attributes; + const RS_COMPLETIONS = shellSignatures.ReplicaSet.attributes; + const SHARD_COMPLETE = shellSignatures.Shard.attributes; + // keep initial line param intact to always return in return statement // check for contents of line with: const splitLine = line.split('.'); diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index 9f3349c81f..cf0b504fcb 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -45,7 +45,12 @@ interface TypeSignature { interface Signatures { [key: string]: TypeSignature; } -const signatures = {} as Signatures; + +if (!global['!!!mdb.signatures']) { + global['!!!mdb.signatures'] = {}; +} + +const signatures: Signatures = global['!!!mdb.signatures']; export const toIgnore = [asShellResult, 'asPrintable', 'constructor']; export function shellApiClassDefault(constructor: Function): void { From c7ecbf6d81e485f07fa449bd1fc3830c415dacbc Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Fri, 19 Jun 2020 17:47:52 +0200 Subject: [PATCH 04/10] Remove unused css property --- packages/browser-repl/src/index.spec.tsx | 2 +- .../src/components/compass-shell/compass-shell.less | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/browser-repl/src/index.spec.tsx b/packages/browser-repl/src/index.spec.tsx index 1793343c68..0ce072076c 100644 --- a/packages/browser-repl/src/index.spec.tsx +++ b/packages/browser-repl/src/index.spec.tsx @@ -15,7 +15,7 @@ describe('BrowserRepl', () => {
); - console.log('wrapper', wrapper); + expect(wrapper.find(Shell)).to.have.lengthOf(1); }); }); diff --git a/packages/compass-shell/src/components/compass-shell/compass-shell.less b/packages/compass-shell/src/components/compass-shell/compass-shell.less index 5e59c112a7..0b121a8dca 100644 --- a/packages/compass-shell/src/components/compass-shell/compass-shell.less +++ b/packages/compass-shell/src/components/compass-shell/compass-shell.less @@ -12,12 +12,8 @@ &-shell-container { flex-grow: 1; - display: none; + display: flex; overflow: auto; border-top: 1px solid @leafygreen__gray--dark-2; - - &-is-expanded { - display: flex; - } } } From 3de17ba2596576c4ba115d3de5bf8d145bdcd806 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Mon, 22 Jun 2020 14:28:34 +0200 Subject: [PATCH 05/10] Add tests for clear command and setting shell output --- .../src/components/editor.spec.tsx | 66 +++++++++++++++---- packages/browser-repl/src/index.spec.tsx | 3 +- .../compass-shell/compass-shell.jsx | 4 +- .../compass-shell/compass-shell.spec.js | 41 ++++++++++++ .../src/components/info-modal/info-modal.jsx | 5 +- packages/shell-api/src/decorators.ts | 7 +- 6 files changed, 105 insertions(+), 21 deletions(-) diff --git a/packages/browser-repl/src/components/editor.spec.tsx b/packages/browser-repl/src/components/editor.spec.tsx index 1e4fbe5cfd..7228ec86f2 100644 --- a/packages/browser-repl/src/components/editor.spec.tsx +++ b/packages/browser-repl/src/components/editor.spec.tsx @@ -11,19 +11,22 @@ describe('', () => { return aceEditor.instance().editor as any; }; - const execCommandBoundTo = (aceEditor: any, key: string): void => { + const execCommandBoundTo = ( + aceEditor: any, + key: { win: string; mac: string } + ): void => { const commands = Object.values(aceEditor.commands.commands); - const command: any = commands.find(({ bindKey }) => { + const command: any = commands.find(({ name, bindKey }) => { if (!bindKey) { return false; } - - if (typeof bindKey === 'string') { - return key === bindKey; + if (name === 'gotoline') { + // Ignore gotoline - our command overrides. + return false; } - const { win, mac } = bindKey as {win: string; mac: string}; - return win === key && mac === key; + const { win, mac } = bindKey as { win: string; mac: string }; + return win === key.win && mac === key.mac; }); if (!command) { @@ -58,7 +61,24 @@ describe('', () => { const aceEditor = getAceEditorInstance(wrapper); expect(spy).not.to.have.been.called; - execCommandBoundTo(aceEditor, 'Return'); + execCommandBoundTo(aceEditor, { + win: 'Return', + mac: 'Return' + }); + expect(spy).to.have.been.calledOnce; + }); + + it('calls onClearCommand when command/ctrl+L is pressed', () => { + const spy = sinon.spy(); + const wrapper = mount(); + + const aceEditor = getAceEditorInstance(wrapper); + + expect(spy).not.to.have.been.called; + execCommandBoundTo(aceEditor, { + win: 'Ctrl-L', + mac: 'Command-L' + }); expect(spy).to.have.been.calledOnce; }); @@ -69,7 +89,10 @@ describe('', () => { const aceEditor = getAceEditorInstance(wrapper); expect(spy).not.to.have.been.called; - execCommandBoundTo(aceEditor, 'Up'); + execCommandBoundTo(aceEditor, { + win: 'Up', + mac: 'Up' + }); expect(spy).to.have.been.calledOnce; }); @@ -82,7 +105,10 @@ describe('', () => { aceEditor.moveCursorToPosition({ row: 1, column: 0 }); aceEditor.clearSelection(); - execCommandBoundTo(aceEditor, 'Up'); + execCommandBoundTo(aceEditor, { + win: 'Up', + mac: 'Up' + }); expect(spy).not.to.have.been.called; }); @@ -96,7 +122,10 @@ describe('', () => { aceEditor.clearSelection(); expect(spy).not.to.have.been.called; - execCommandBoundTo(aceEditor, 'Down'); + execCommandBoundTo(aceEditor, { + win: 'Down', + mac: 'Down' + }); expect(spy).to.have.been.calledOnce; }); @@ -107,7 +136,10 @@ describe('', () => { const aceEditor = getAceEditorInstance(wrapper); aceEditor.setValue('row 0\nrow 1'); - execCommandBoundTo(aceEditor, 'Down'); + execCommandBoundTo(aceEditor, { + win: 'Down', + mac: 'Down' + }); expect(spy).not.to.have.been.called; }); @@ -119,7 +151,10 @@ describe('', () => { aceEditor.setValue('text'); aceEditor.selectAll(); - execCommandBoundTo(aceEditor, 'Up'); + execCommandBoundTo(aceEditor, { + win: 'Up', + mac: 'Up' + }); expect(spy).not.to.have.been.called; }); @@ -131,7 +166,10 @@ describe('', () => { aceEditor.setValue('text'); aceEditor.selectAll(); - execCommandBoundTo(aceEditor, 'Down'); + execCommandBoundTo(aceEditor, { + win: 'Down', + mac: 'Down' + }); expect(spy).not.to.have.been.called; }); diff --git a/packages/browser-repl/src/index.spec.tsx b/packages/browser-repl/src/index.spec.tsx index 0ce072076c..f71b5024f4 100644 --- a/packages/browser-repl/src/index.spec.tsx +++ b/packages/browser-repl/src/index.spec.tsx @@ -1,4 +1,3 @@ -// import sinon from 'sinon'; import React from 'react'; import { expect } from '../testing/chai'; import { shallow } from '../testing/enzyme'; @@ -8,7 +7,7 @@ import { Shell as BrowserRepl } from './index'; describe('BrowserRepl', () => { context('when it is required', () => { - it('renders', () => { + it('renders the Shell component', () => { const fakeRuntime: any = {}; const wrapper = shallow(
diff --git a/packages/compass-shell/src/components/compass-shell/compass-shell.jsx b/packages/compass-shell/src/components/compass-shell/compass-shell.jsx index a1114e7795..b5fab5e885 100644 --- a/packages/compass-shell/src/components/compass-shell/compass-shell.jsx +++ b/packages/compass-shell/src/components/compass-shell/compass-shell.jsx @@ -29,6 +29,7 @@ export class CompassShell extends Component { static propTypes = { isExpanded: PropTypes.bool, runtime: PropTypes.object, + shellOutput: PropTypes.array, historyStorage: PropTypes.object }; @@ -38,6 +39,8 @@ export class CompassShell extends Component { constructor(props) { super(props); + this.shellOutput = this.props.shellOutput || []; + this.state = { initialHistory: this.props.historyStorage ? null : [], isExpanded: !!this.props.isExpanded @@ -54,7 +57,6 @@ export class CompassShell extends Component { lastOpenHeight = defaultShellHeightOpened; resizableRef = null; - shellOutput = []; saveHistory = async(history) => { if (!this.props.historyStorage) { diff --git a/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js b/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js index 7c9fab6193..9ff6c51631 100644 --- a/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js +++ b/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js @@ -63,6 +63,29 @@ describe('CompassShell', () => { top: , }); }); + + it('renders the Shell with an output change handler', () => { + const fakeRuntime = {}; + const wrapper = shallow(); + expect(!!wrapper.find(Shell).prop('onOutputChanged')).to.equal(true); + }); + + it('passes saved shell output', () => { + const fakeRuntime = {}; + const wrapper = shallow(); + + expect(wrapper.find(Shell).prop('initialOutput')).to.deep.equal([{ + type: 'output', + value: 'pineapple' + }]); + }); }); context('when historyStorage is not present', () => { @@ -187,5 +210,23 @@ describe('CompassShell', () => { ).to.equal(true); }); }); + + it('sets shellOutput on onShellOutputChanged', () => { + const shell = new CompassShell({ isExpanded: true }); + + shell.onShellOutputChanged([{ + type: 'output', + value: 'some output' + }]); + console.log('shell.shellOutput', shell.shellOutput, [{ + type: 'output', + value: 'some output' + }]); + + expect(shell.shellOutput).to.deep.equal([{ + type: 'output', + value: 'some output' + }]); + }); }); diff --git a/packages/compass-shell/src/components/info-modal/info-modal.jsx b/packages/compass-shell/src/components/info-modal/info-modal.jsx index f68d47da37..4da2ad2428 100644 --- a/packages/compass-shell/src/components/info-modal/info-modal.jsx +++ b/packages/compass-shell/src/components/info-modal/info-modal.jsx @@ -78,7 +78,10 @@ export class InfoModal extends PureComponent {
{hotkeys.map(shortcut => ( -
+
{shortcut.key}{shortcut.description} diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index cf0b504fcb..094f9c1069 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -46,11 +46,12 @@ interface Signatures { [key: string]: TypeSignature; } -if (!global['!!!mdb.signatures']) { - global['!!!mdb.signatures'] = {}; +const signaturesGlobalIdentifier = '@@@mdb.signatures@@@'; +if (!global[signaturesGlobalIdentifier]) { + global[signaturesGlobalIdentifier] = {}; } -const signatures: Signatures = global['!!!mdb.signatures']; +const signatures: Signatures = global[signaturesGlobalIdentifier]; export const toIgnore = [asShellResult, 'asPrintable', 'constructor']; export function shellApiClassDefault(constructor: Function): void { From 5ac6d8cb0cfd73fd95cc34005dec7125070cb186 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Mon, 22 Jun 2020 15:25:59 +0200 Subject: [PATCH 06/10] Removed unneeded global and extra tests --- packages/browser-repl/src/index.spec.tsx | 22 ---------------------- packages/shell-api/src/decorators.ts | 7 +------ 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 packages/browser-repl/src/index.spec.tsx diff --git a/packages/browser-repl/src/index.spec.tsx b/packages/browser-repl/src/index.spec.tsx deleted file mode 100644 index f71b5024f4..0000000000 --- a/packages/browser-repl/src/index.spec.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import { expect } from '../testing/chai'; -import { shallow } from '../testing/enzyme'; - -import { Shell } from './components/shell'; -import { Shell as BrowserRepl } from './index'; - -describe('BrowserRepl', () => { - context('when it is required', () => { - it('renders the Shell component', () => { - const fakeRuntime: any = {}; - const wrapper = shallow( -
- -
- ); - - expect(wrapper.find(Shell)).to.have.lengthOf(1); - }); - }); -}); - diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index 094f9c1069..25c1be408f 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -46,12 +46,7 @@ interface Signatures { [key: string]: TypeSignature; } -const signaturesGlobalIdentifier = '@@@mdb.signatures@@@'; -if (!global[signaturesGlobalIdentifier]) { - global[signaturesGlobalIdentifier] = {}; -} - -const signatures: Signatures = global[signaturesGlobalIdentifier]; +const signatures: Signatures = {}; export const toIgnore = [asShellResult, 'asPrintable', 'constructor']; export function shellApiClassDefault(constructor: Function): void { From b880a7a6e2cbb8765c61018a882b3ea6be517f87 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Mon, 22 Jun 2020 15:29:29 +0200 Subject: [PATCH 07/10] Tweak change to signatures definition to get rid of git change --- packages/shell-api/src/decorators.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index 25c1be408f..9f3349c81f 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -45,8 +45,7 @@ interface TypeSignature { interface Signatures { [key: string]: TypeSignature; } - -const signatures: Signatures = {}; +const signatures = {} as Signatures; export const toIgnore = [asShellResult, 'asPrintable', 'constructor']; export function shellApiClassDefault(constructor: Function): void { From 43297d8f5d2877b966fd5ecc8656fec6d1525a89 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Tue, 30 Jun 2020 23:17:19 +0200 Subject: [PATCH 08/10] Commit updated package json with bootstrap --- packages/compass-shell/package-lock.json | 79 +++++++++++++++++------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/packages/compass-shell/package-lock.json b/packages/compass-shell/package-lock.json index 74c449864b..192f9de3ce 100644 --- a/packages/compass-shell/package-lock.json +++ b/packages/compass-shell/package-lock.json @@ -4848,6 +4848,7 @@ "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, + "optional": true, "requires": { "hoek": "2.x.x" } @@ -9431,7 +9432,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -9452,12 +9454,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -9472,17 +9476,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -9599,7 +9606,8 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -9611,6 +9619,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -9625,6 +9634,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -9632,12 +9642,14 @@ "minimist": { "version": "1.2.5", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9656,6 +9668,7 @@ "version": "0.5.3", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "^1.2.5" } @@ -9717,7 +9730,8 @@ "npm-normalize-package-bin": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "npm-packlist": { "version": "1.4.8", @@ -9745,7 +9759,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -9757,6 +9772,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -9834,7 +9850,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -9870,6 +9887,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9889,6 +9907,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9932,12 +9951,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -10482,7 +10503,8 @@ "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true + "dev": true, + "optional": true }, "hoist-non-react-statics": { "version": "1.2.0", @@ -11574,7 +11596,8 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true }, "isobject": { "version": "3.0.1", @@ -13997,7 +14020,8 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true + "dev": true, + "optional": true }, "ansi-styles": { "version": "4.2.1", @@ -14079,7 +14103,8 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "optional": true }, "find-up": { "version": "4.1.0", @@ -14103,7 +14128,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true + "dev": true, + "optional": true }, "locate-path": { "version": "5.0.0", @@ -14167,6 +14193,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", "dev": true, + "optional": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -14178,6 +14205,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, + "optional": true, "requires": { "ansi-regex": "^5.0.0" } @@ -14568,6 +14596,7 @@ "lodash.defaults": "^4.2.0", "lodash.uniq": "^4.5.0", "minimist": "^1.2.0", + "pre-commit": "github:mongodb-js/pre-commit#f4158768a7ef58b46808cc09a6f6a0994c0baa67", "precinct": "^6.2.0" }, "dependencies": { @@ -14616,6 +14645,7 @@ "version": "6.0.5", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, "requires": { "nice-try": "^1.0.4", "path-key": "^2.0.1", @@ -14657,6 +14687,7 @@ "pre-commit": { "version": "github:mongodb-js/pre-commit#f4158768a7ef58b46808cc09a6f6a0994c0baa67", "from": "github:mongodb-js/pre-commit#f4158768a7ef58b46808cc09a6f6a0994c0baa67", + "dev": true, "requires": { "cross-spawn": "^6.0.5", "which": "1.3.x" @@ -14877,7 +14908,8 @@ "nice-try": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==" + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true }, "nise": { "version": "1.5.3", @@ -16793,7 +16825,8 @@ "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true }, "path-parse": { "version": "1.0.6", @@ -20462,7 +20495,8 @@ "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true }, "send": { "version": "0.17.1", @@ -20675,6 +20709,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, "requires": { "shebang-regex": "^1.0.0" } @@ -20688,7 +20723,8 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true }, "shell-quote": { "version": "1.6.1", @@ -23943,6 +23979,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, "requires": { "isexe": "^2.0.0" } From 240da75908f4d1fa3219fd301cb3c552979f18f8 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Tue, 30 Jun 2020 23:18:38 +0200 Subject: [PATCH 09/10] Ensure global signature reference --- packages/shell-api/src/decorators.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index 9f3349c81f..7b62c09016 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -45,7 +45,12 @@ interface TypeSignature { interface Signatures { [key: string]: TypeSignature; } -const signatures = {} as Signatures; +const signaturesGlobalIdentifier = '@@@mdb.signatures@@@'; +if (!global[signaturesGlobalIdentifier]) { + global[signaturesGlobalIdentifier] = {}; +} + +const signatures: Signatures = global[signaturesGlobalIdentifier]; export const toIgnore = [asShellResult, 'asPrintable', 'constructor']; export function shellApiClassDefault(constructor: Function): void { From a0d82c94355925a6b44b17ffdd22df0343dbf5c6 Mon Sep 17 00:00:00 2001 From: Rhys Howell Date: Tue, 30 Jun 2020 23:46:37 +0200 Subject: [PATCH 10/10] Remove extra log --- .../src/components/compass-shell/compass-shell.spec.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js b/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js index 9ff6c51631..c34e260716 100644 --- a/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js +++ b/packages/compass-shell/src/components/compass-shell/compass-shell.spec.js @@ -218,10 +218,6 @@ describe('CompassShell', () => { type: 'output', value: 'some output' }]); - console.log('shell.shellOutput', shell.shellOutput, [{ - type: 'output', - value: 'some output' - }]); expect(shell.shellOutput).to.deep.equal([{ type: 'output',