Skip to content

Commit

Permalink
remove bump, use version
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Jan 8, 2025
1 parent 72cde48 commit 4da9db1
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .evergreen/install-npm-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ npm run mark-ci-required-optional-dependencies
# along with its types, but npm wouldn't try and compile the addon
(npm ci && test -e node_modules/mongodb-client-encryption) || npm ci --ignore-scripts

npm run evergreen-release bump

echo "npm packages after installation"
npm ls || true
3 changes: 3 additions & 0 deletions packages/cli-repl/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import i18n from '@mongosh/i18n';
import { colorizeForStderr as clr } from './clr';

// eslint-disable-next-line @typescript-eslint/no-var-requires
export const MONGOSH_VERSION: string = require('../package.json').version;

export const TELEMETRY_GREETING_MESSAGE = `
${i18n.__('cli-repl.cli-repl.telemetry')}
${i18n.__('cli-repl.cli-repl.disableTelemetry')}${clr(
Expand Down
7 changes: 6 additions & 1 deletion packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ import { callbackify, promisify } from 'util';
import * as asyncRepl from './async-repl';
import type { StyleDefinition } from './clr';
import clr from './clr';
import { MONGOSH_WIKI, TELEMETRY_GREETING_MESSAGE } from './constants';
import {
MONGOSH_VERSION,
MONGOSH_WIKI,
TELEMETRY_GREETING_MESSAGE,
} from './constants';
import formatOutput, { formatError } from './format-output';
import { makeMultilineJSIntoSingleLine } from '@mongosh/js-multiline-to-singleline';
import { LineByLineInput } from './line-by-line-input';
Expand Down Expand Up @@ -144,6 +148,7 @@ class MongoshNodeRepl implements EvaluationListener {
loadNestingLevel = 0;
redactHistory: 'keep' | 'remove' | 'remove-redact' = 'remove';
rawValueToShellResult: WeakMap<any, ShellResult> = new WeakMap();
version: string = MONGOSH_VERSION;

constructor(options: MongoshNodeReplOptions) {
this.input = options.input;
Expand Down
15 changes: 13 additions & 2 deletions packages/e2e-tests/test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { once } from 'events';
import type { AddressInfo } from 'net';
const { EJSON } = bson;
import { sleep } from './util-helpers';
import { MONGOSH_VERSION } from '../../cli-repl/src/constants';

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

it('version', async function () {
const expected = require('../package.json').version;
const expectedPackageVersion: string =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../package.json')['dependencies']['@mongosh/cli-repl'];
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const expectedVersionFromRepl = MONGOSH_VERSION;

expect(expectedPackageVersion).not.null;
expect(expectedPackageVersion).equals(expectedVersionFromRepl);

await shell.executeLine('version()');
shell.assertContainsOutput(expected);
shell.assertNoErrors();
shell.assertContainsOutput(expectedPackageVersion);
shell.assertContainsOutput(expectedVersionFromRepl);
});

it('fle addon is available', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import type { RuntimeEvaluationListener } from '@mongosh/browser-runtime-core';
export class WorkerThreadEvaluationListener {
exposedListener: Exposed<
Required<
Omit<RuntimeEvaluationListener, 'onLoad' | 'getCryptLibraryOptions'>
Omit<
RuntimeEvaluationListener,
'version' | 'onLoad' | 'getCryptLibraryOptions'
>
>
>;

Expand Down Expand Up @@ -56,6 +59,7 @@ export class WorkerThreadEvaluationListener {
(Promise.resolve() as Promise<never>)
);
},
version: workerRuntime.evaluationListener?.version,
},
worker
);
Expand Down
5 changes: 4 additions & 1 deletion packages/shell-api/src/shell-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,10 @@ export default class ShellApi extends ShellApiClass {
}

version(): string {
const version = require('../package.json').version;
const version = this._instanceState.evaluationListener.version;
if (!version) {
throw new MongoshInternalError('mongosh version not known');
}
return version;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/shell-api/src/shell-instance-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ export interface EvaluationListener
* options used to access it.
*/
getCryptLibraryOptions?: () => Promise<AutoEncryptionOptions['extraOptions']>;

/** References the mongosh version used by the EvaluationListener */
version?: string;
}

/**
Expand Down

0 comments on commit 4da9db1

Please sign in to comment.