From ae8c1eac106750037bfed1b58666742dcd6fc036 Mon Sep 17 00:00:00 2001 From: Aditya Pudipeddi Date: Tue, 17 Mar 2026 13:11:03 +0530 Subject: [PATCH] fix(NODE-6795): support build-from-source installs --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/test.yml | 2 +- {.github/scripts => etc}/get-commit-from-ref.sh | 0 {.github/scripts => etc}/libmongocrypt.mjs | 0 {.github/scripts => etc}/utils.mjs | 4 ++-- package.json | 10 +++++++--- 7 files changed, 12 insertions(+), 8 deletions(-) rename {.github/scripts => etc}/get-commit-from-ref.sh (100%) rename {.github/scripts => etc}/libmongocrypt.mjs (100%) rename {.github/scripts => etc}/utils.mjs (96%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0a03d7..9275b38 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v5 - name: Build ${{ matrix.os }} Prebuild - run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }} + run: node etc/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }} shell: bash - id: upload diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index d8d55f0..5bff903 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -46,7 +46,7 @@ jobs: - if: matrix.build-mode == 'manual' shell: bash - run: node .github/scripts/libmongocrypt.mjs + run: node etc/libmongocrypt.mjs - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a241ef7..03e2abf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,7 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Build with Node.js ${{ matrix.node }} on ${{ matrix.os }} - run: node .github/scripts/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }} + run: node etc/libmongocrypt.mjs ${{ runner.os == 'Windows' && '--build' || '' }} shell: bash - name: Test ${{ matrix.os }} diff --git a/.github/scripts/get-commit-from-ref.sh b/etc/get-commit-from-ref.sh similarity index 100% rename from .github/scripts/get-commit-from-ref.sh rename to etc/get-commit-from-ref.sh diff --git a/.github/scripts/libmongocrypt.mjs b/etc/libmongocrypt.mjs similarity index 100% rename from .github/scripts/libmongocrypt.mjs rename to etc/libmongocrypt.mjs diff --git a/.github/scripts/utils.mjs b/etc/utils.mjs similarity index 96% rename from .github/scripts/utils.mjs rename to etc/utils.mjs index 65ef1a5..37228bd 100644 --- a/.github/scripts/utils.mjs +++ b/etc/utils.mjs @@ -10,12 +10,12 @@ const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); /** Resolves to the root of this repository */ export function resolveRoot(...paths) { - return path.resolve(__dirname, '..', '..', ...paths); + return path.resolve(__dirname, '..', ...paths); } export function getCommitFromRef(ref) { console.error(`resolving ref: ${ref}`); - const script = resolveRoot('.github', 'scripts', 'get-commit-from-ref.sh'); + const script = resolveRoot('etc', 'get-commit-from-ref.sh'); const output = execSync(`bash ${script}`, { env: { REF: ref }, encoding: 'utf-8' }) const regex = /COMMIT_HASH=(?[a-zA-Z0-9]+)/ diff --git a/package.json b/package.json index 400d7d9..56ce1d3 100644 --- a/package.json +++ b/package.json @@ -10,14 +10,18 @@ "addon", "lib", "src", - "binding.gyp" + "binding.gyp", + "etc/libmongocrypt.mjs", + "etc/utils.mjs", + "etc/get-commit-from-ref.sh" ], "directories": { "lib": "lib" }, "scripts": { - "install:libmongocrypt": "node .github/scripts/libmongocrypt.mjs", - "install": "prebuild-install --runtime napi || node-gyp rebuild", + "install:libmongocrypt": "node etc/libmongocrypt.mjs", + "clean-install": "node etc/libmongocrypt.mjs --skip-bindings && node-gyp rebuild", + "install": "prebuild-install --runtime napi || npm run clean-install", "clang-format": "clang-format --style=file:.clang-format --Werror -i addon/*", "check:eslint": "ESLINT_USE_FLAT_CONFIG=false eslint src test", "check:clang-format": "clang-format --style=file:.clang-format --dry-run --Werror addon/*",