Skip to content

Commit

Permalink
use a shell-api constant and switch to 2.3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
gagik committed Jan 10, 2025
1 parent 2b912d9 commit a9d2422
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/browser-runtime-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"@mongosh/types": "2.3.7",
"@mongosh/types": "2.3.8",
"bson": "^6.10.1",
"depcheck": "^1.4.7",
"eslint": "^7.25.0",
Expand Down
30 changes: 30 additions & 0 deletions packages/build/src/npm-packages/bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,36 @@ export async function bumpMongoshReleasePackages(): Promise<void> {
JSON.stringify(packageJson, null, 2) + '\n'
);
}

await bumpShellApiMongoshVersion(version);
}

/** Sets the shell-api constant to match the mongosh version. */
export async function bumpShellApiMongoshVersion(version: string) {
const shellApiVersionFilePath = path.join(
__dirname,
PROJECT_ROOT,
'packages',
'shell-api',
'src',
'mongosh-version.ts'
);

const versionFileContent = await fs.readFile(
shellApiVersionFilePath,
'utf-8'
);

// Write the updated content back to the mongosh-version file
await fs.writeFile(
shellApiVersionFilePath,
// Replace the version inside MONGOSH_VERSION = '...'
versionFileContent.replace(
/MONGOSH_VERSION = '.*'/,
`MONGOSH_VERSION = '${version}'`
),
'utf-8'
);
}

/** Bumps auxiliary packages without setting a new version of mongosh. */
Expand Down
6 changes: 3 additions & 3 deletions packages/logging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
},
"dependencies": {
"@mongodb-js/devtools-connect": "^3.3.4",
"@mongosh/errors": "2.3.7",
"@mongosh/history": "2.3.7",
"@mongosh/types": "2.3.7",
"@mongosh/errors": "2.3.8",
"@mongosh/history": "2.3.8",
"@mongosh/types": "2.3.8",
"mongodb-log-writer": "^1.4.2",
"mongodb-redact": "^1.1.2"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/node-runtime-worker-thread/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"@mongosh/browser-runtime-core": "2.3.7",
"@mongosh/browser-runtime-electron": "2.3.7",
"@mongosh/service-provider-core": "2.3.7",
"@mongosh/service-provider-node-driver": "2.3.7",
"@mongosh/types": "2.3.7",
"@mongosh/browser-runtime-core": "2.3.8",
"@mongosh/browser-runtime-electron": "2.3.8",
"@mongosh/service-provider-core": "2.3.8",
"@mongosh/service-provider-node-driver": "2.3.8",
"@mongosh/types": "2.3.8",
"bson": "^6.10.1",
"depcheck": "^1.4.7",
"eslint": "^7.25.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export class WorkerThreadEvaluationListener {
(Promise.resolve() as Promise<never>)
);
},
version: workerRuntime.evaluationListener?.version,
},
worker
);
Expand Down
2 changes: 1 addition & 1 deletion packages/service-provider-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@aws-sdk/credential-providers": "^3.525.0",
"@mongosh/errors": "2.3.7",
"@mongosh/errors": "2.3.8",
"bson": "^6.10.1",
"mongodb": "^6.12.0",
"mongodb-build-info": "^1.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/shell-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"@mongosh/types": "2.3.7",
"@mongosh/types": "2.3.8",
"bson": "^6.10.1",
"depcheck": "^1.4.7",
"eslint": "^7.25.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/shell-api/src/mongosh-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* NOTE: Do not manually modify this file.
* The MONGOSH_VERSION gets re-generated automatically with scripts/set-mongosh-version.ts
**/

/** Current mongosh cli-repl version. */
export const MONGOSH_VERSION = '2.3.8';
7 changes: 2 additions & 5 deletions packages/shell-api/src/shell-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { ClientSideFieldLevelEncryptionOptions } from './field-level-encryp
import { dirname } from 'path';
import { ShellUserConfig } from '@mongosh/types';
import i18n from '@mongosh/i18n';
import { MONGOSH_VERSION } from './mongosh-version';

const instanceStateSymbol = Symbol.for('@@mongosh.instanceState');
const loadCallNestingLevelSymbol = Symbol.for('@@mongosh.loadCallNestingLevel');
Expand Down Expand Up @@ -289,11 +290,7 @@ export default class ShellApi extends ShellApiClass {
}

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

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

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

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/snippet-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
},
"dependencies": {
"@mongodb-js/devtools-proxy-support": "^0.4.2",
"@mongosh/errors": "2.3.7",
"@mongosh/shell-api": "2.3.7",
"@mongosh/types": "2.3.7",
"@mongosh/errors": "2.3.8",
"@mongosh/shell-api": "2.3.8",
"@mongosh/types": "2.3.8",
"bson": "^6.10.1",
"cross-spawn": "^7.0.5",
"escape-string-regexp": "^4.0.0",
Expand Down

0 comments on commit a9d2422

Please sign in to comment.