From 79cb3048a48b333cbd0531ee1e334fb92b0a73db Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Mon, 2 Dec 2024 10:40:49 -0700 Subject: [PATCH] remove bindings dependency --- .github/docker/Dockerfile.glibc | 2 +- package-lock.json | 27 --------------------------- package.json | 3 +-- src/index.ts | 15 +++++++++++---- 4 files changed, 13 insertions(+), 34 deletions(-) diff --git a/.github/docker/Dockerfile.glibc b/.github/docker/Dockerfile.glibc index e0a89d3..b22a180 100644 --- a/.github/docker/Dockerfile.glibc +++ b/.github/docker/Dockerfile.glibc @@ -16,7 +16,7 @@ RUN apt-get -qq update && apt-get -qq install -y python3 build-essential && ldd RUN npm run install:libmongocrypt ARG RUN_TEST -RUN [ -n "$RUN_TEST" ] && npm run test || echo 'skipping testing!' +RUN if [ -n "$RUN_TEST" ]; then npm test ; else echo "skipping tests" ; fi FROM scratch diff --git a/package-lock.json b/package-lock.json index 548a558..8914301 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.2" }, @@ -1581,14 +1580,6 @@ "node": ">=8" } }, - "node_modules/bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dependencies": { - "file-uri-to-path": "1.0.0" - } - }, "node_modules/bl": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz", @@ -3405,11 +3396,6 @@ "node": ">=16.0.0" } }, - "node_modules/file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "node_modules/fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", @@ -9353,14 +9339,6 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, "bl": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/bl/-/bl-3.0.1.tgz", @@ -10763,11 +10741,6 @@ "flat-cache": "^4.0.0" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, "fill-range": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", diff --git a/package.json b/package.json index 175b60d..92da208 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "gypfile": true, "mongodb:libmongocrypt": "1.11.0", "dependencies": { - "bindings": "^1.5.0", "node-addon-api": "^4.3.0", "prebuild-install": "^7.1.2" }, @@ -97,4 +96,4 @@ "moduleResolution": "node" } } -} +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 85ab3d2..e529dce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,15 @@ import { cryptoCallbacks } from './crypto_callbacks'; export { cryptoCallbacks }; -import bindings = require('bindings'); -const mc: MongoCryptBindings = bindings('mongocrypt'); +function load() { + try { + return require('../build/Release/mongocrypt.node'); + } catch { + return require('../build/Debug/mongocrypt.node'); + } +} + +const mc: MongoCryptBindings = load(); /** * The value returned by the native bindings @@ -54,7 +61,7 @@ type MongoCryptConstructorOptions = { }; export interface MongoCryptConstructor { - new (options: MongoCryptConstructorOptions): MongoCrypt; + new(options: MongoCryptConstructorOptions): MongoCrypt; libmongocryptVersion: string; } @@ -116,6 +123,6 @@ export const MongoCrypt: MongoCryptConstructor = class MongoCrypt extends mc.Mon /** exported for testing only. */ interface MongoCryptContextCtor { - new (): MongoCryptContext; + new(): MongoCryptContext; } export const MongoCryptContextCtor: MongoCryptContextCtor = mc.MongoCryptContextCtor;