Skip to content

Commit 4da9db1

Browse files
committed
remove bump, use version
1 parent 72cde48 commit 4da9db1

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

.evergreen/install-npm-deps.sh

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,5 @@ npm run mark-ci-required-optional-dependencies
3131
# along with its types, but npm wouldn't try and compile the addon
3232
(npm ci && test -e node_modules/mongodb-client-encryption) || npm ci --ignore-scripts
3333

34-
npm run evergreen-release bump
35-
3634
echo "npm packages after installation"
3735
npm ls || true

packages/cli-repl/src/constants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import i18n from '@mongosh/i18n';
22
import { colorizeForStderr as clr } from './clr';
33

4+
// eslint-disable-next-line @typescript-eslint/no-var-requires
5+
export const MONGOSH_VERSION: string = require('../package.json').version;
6+
47
export const TELEMETRY_GREETING_MESSAGE = `
58
${i18n.__('cli-repl.cli-repl.telemetry')}
69
${i18n.__('cli-repl.cli-repl.disableTelemetry')}${clr(

packages/cli-repl/src/mongosh-repl.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ import { callbackify, promisify } from 'util';
3434
import * as asyncRepl from './async-repl';
3535
import type { StyleDefinition } from './clr';
3636
import clr from './clr';
37-
import { MONGOSH_WIKI, TELEMETRY_GREETING_MESSAGE } from './constants';
37+
import {
38+
MONGOSH_VERSION,
39+
MONGOSH_WIKI,
40+
TELEMETRY_GREETING_MESSAGE,
41+
} from './constants';
3842
import formatOutput, { formatError } from './format-output';
3943
import { makeMultilineJSIntoSingleLine } from '@mongosh/js-multiline-to-singleline';
4044
import { LineByLineInput } from './line-by-line-input';
@@ -144,6 +148,7 @@ class MongoshNodeRepl implements EvaluationListener {
144148
loadNestingLevel = 0;
145149
redactHistory: 'keep' | 'remove' | 'remove-redact' = 'remove';
146150
rawValueToShellResult: WeakMap<any, ShellResult> = new WeakMap();
151+
version: string = MONGOSH_VERSION;
147152

148153
constructor(options: MongoshNodeReplOptions) {
149154
this.input = options.input;

packages/e2e-tests/test/e2e.spec.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { once } from 'events';
2222
import type { AddressInfo } from 'net';
2323
const { EJSON } = bson;
2424
import { sleep } from './util-helpers';
25+
import { MONGOSH_VERSION } from '../../cli-repl/src/constants';
2526

2627
const jsContextFlagCombinations: `--jsContext=${'plain-vm' | 'repl'}`[][] = [
2728
[],
@@ -445,9 +446,19 @@ describe('e2e', function () {
445446
});
446447

447448
it('version', async function () {
448-
const expected = require('../package.json').version;
449+
const expectedPackageVersion: string =
450+
// eslint-disable-next-line @typescript-eslint/no-var-requires
451+
require('../package.json')['dependencies']['@mongosh/cli-repl'];
452+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
453+
const expectedVersionFromRepl = MONGOSH_VERSION;
454+
455+
expect(expectedPackageVersion).not.null;
456+
expect(expectedPackageVersion).equals(expectedVersionFromRepl);
457+
449458
await shell.executeLine('version()');
450-
shell.assertContainsOutput(expected);
459+
shell.assertNoErrors();
460+
shell.assertContainsOutput(expectedPackageVersion);
461+
shell.assertContainsOutput(expectedVersionFromRepl);
451462
});
452463

453464
it('fle addon is available', async function () {

packages/node-runtime-worker-thread/src/worker-thread-evaluation-listener.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import type { RuntimeEvaluationListener } from '@mongosh/browser-runtime-core';
77
export class WorkerThreadEvaluationListener {
88
exposedListener: Exposed<
99
Required<
10-
Omit<RuntimeEvaluationListener, 'onLoad' | 'getCryptLibraryOptions'>
10+
Omit<
11+
RuntimeEvaluationListener,
12+
'version' | 'onLoad' | 'getCryptLibraryOptions'
13+
>
1114
>
1215
>;
1316

@@ -56,6 +59,7 @@ export class WorkerThreadEvaluationListener {
5659
(Promise.resolve() as Promise<never>)
5760
);
5861
},
62+
version: workerRuntime.evaluationListener?.version,
5963
},
6064
worker
6165
);

packages/shell-api/src/shell-api.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ export default class ShellApi extends ShellApiClass {
289289
}
290290

291291
version(): string {
292-
const version = require('../package.json').version;
292+
const version = this._instanceState.evaluationListener.version;
293+
if (!version) {
294+
throw new MongoshInternalError('mongosh version not known');
295+
}
293296
return version;
294297
}
295298

packages/shell-api/src/shell-instance-state.ts

+3
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export interface EvaluationListener
116116
* options used to access it.
117117
*/
118118
getCryptLibraryOptions?: () => Promise<AutoEncryptionOptions['extraOptions']>;
119+
120+
/** References the mongosh version used by the EvaluationListener */
121+
version?: string;
119122
}
120123

121124
/**

0 commit comments

Comments
 (0)