From a3701a560f8ef8ecd9e2498313873df3be15c090 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 8 Feb 2026 22:04:14 +0000 Subject: [PATCH 1/2] build(deps-dev): bump the npm group across 1 directory with 2 updates Bumps the npm group with 2 updates in the / directory: [@napi-rs/cli](https://github.com/napi-rs/napi-rs) and [oxlint](https://github.com/oxc-project/oxc/tree/HEAD/npm/oxlint). Updates `@napi-rs/cli` from 3.5.0 to 3.5.1 - [Release notes](https://github.com/napi-rs/napi-rs/releases) - [Commits](https://github.com/napi-rs/napi-rs/compare/@napi-rs/cli@3.5.0...@napi-rs/cli@3.5.1) Updates `oxlint` from 1.31.0 to 1.37.0 - [Release notes](https://github.com/oxc-project/oxc/releases) - [Changelog](https://github.com/oxc-project/oxc/blob/main/npm/oxlint/CHANGELOG.md) - [Commits](https://github.com/oxc-project/oxc/commits/oxlint_v1.37.0/npm/oxlint) --- updated-dependencies: - dependency-name: "@napi-rs/cli" dependency-version: 3.5.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: npm - dependency-name: oxlint dependency-version: 1.37.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: npm ... Signed-off-by: dependabot[bot] --- bindings/node/package.json | 4 +- yarn.lock | 87 +++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/bindings/node/package.json b/bindings/node/package.json index a40a98f..6f768d8 100644 --- a/bindings/node/package.json +++ b/bindings/node/package.json @@ -21,9 +21,9 @@ }, "license": "MIT", "devDependencies": { - "@napi-rs/cli": "3.5.0", + "@napi-rs/cli": "3.5.1", "ava": "^6.4.1", - "oxlint": "^1.31.0" + "oxlint": "^1.42.0" }, "ava": { "timeout": "3m" diff --git a/yarn.lock b/yarn.lock index a4cff31..805c1f9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,9 +15,9 @@ __metadata: version: 0.0.0-use.local resolution: "@cpp-linter/cpp-linter@workspace:bindings/node" dependencies: - "@napi-rs/cli": "npm:3.5.0" + "@napi-rs/cli": "npm:3.5.1" ava: "npm:^6.4.1" - oxlint: "npm:^1.31.0" + oxlint: "npm:^1.42.0" bin: cpp-linter: cli.js languageName: unknown @@ -332,9 +332,9 @@ __metadata: languageName: node linkType: hard -"@napi-rs/cli@npm:3.5.0": - version: 3.5.0 - resolution: "@napi-rs/cli@npm:3.5.0" +"@napi-rs/cli@npm:3.5.1": + version: 3.5.1 + resolution: "@napi-rs/cli@npm:3.5.1" dependencies: "@inquirer/prompts": "npm:^8.0.0" "@napi-rs/cross-toolchain": "npm:^1.0.3" @@ -356,7 +356,7 @@ __metadata: bin: napi: dist/cli.js napi-raw: cli.mjs - checksum: 10c0/e1556cb547ba2a2df6fbe585d32f9eaf0c857bb727673950c9e6574dce8fd63c8dfd37600313ed86a317895eaf52fca90872a8e7a348f8abab7ab7d6f817336d + checksum: 10c0/b67d057a052a28917c90653101dfcff9e7f60342b1120f4613d571533cf8080116d97d9825ad88d672c79a5165a0edf7aec4eb4db702464c0551ed48c1b81adf languageName: node linkType: hard @@ -1058,58 +1058,58 @@ __metadata: languageName: node linkType: hard -"@oxlint/darwin-arm64@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/darwin-arm64@npm:1.31.0" +"@oxlint/darwin-arm64@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/darwin-arm64@npm:1.43.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@oxlint/darwin-x64@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/darwin-x64@npm:1.31.0" +"@oxlint/darwin-x64@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/darwin-x64@npm:1.43.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@oxlint/linux-arm64-gnu@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/linux-arm64-gnu@npm:1.31.0" +"@oxlint/linux-arm64-gnu@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/linux-arm64-gnu@npm:1.43.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@oxlint/linux-arm64-musl@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/linux-arm64-musl@npm:1.31.0" +"@oxlint/linux-arm64-musl@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/linux-arm64-musl@npm:1.43.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@oxlint/linux-x64-gnu@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/linux-x64-gnu@npm:1.31.0" +"@oxlint/linux-x64-gnu@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/linux-x64-gnu@npm:1.43.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@oxlint/linux-x64-musl@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/linux-x64-musl@npm:1.31.0" +"@oxlint/linux-x64-musl@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/linux-x64-musl@npm:1.43.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@oxlint/win32-arm64@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/win32-arm64@npm:1.31.0" +"@oxlint/win32-arm64@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/win32-arm64@npm:1.43.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@oxlint/win32-x64@npm:1.31.0": - version: 1.31.0 - resolution: "@oxlint/win32-x64@npm:1.31.0" +"@oxlint/win32-x64@npm:1.43.0": + version: 1.43.0 + resolution: "@oxlint/win32-x64@npm:1.43.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -2179,20 +2179,20 @@ __metadata: languageName: node linkType: hard -"oxlint@npm:^1.31.0": - version: 1.31.0 - resolution: "oxlint@npm:1.31.0" +"oxlint@npm:^1.42.0": + version: 1.43.0 + resolution: "oxlint@npm:1.43.0" dependencies: - "@oxlint/darwin-arm64": "npm:1.31.0" - "@oxlint/darwin-x64": "npm:1.31.0" - "@oxlint/linux-arm64-gnu": "npm:1.31.0" - "@oxlint/linux-arm64-musl": "npm:1.31.0" - "@oxlint/linux-x64-gnu": "npm:1.31.0" - "@oxlint/linux-x64-musl": "npm:1.31.0" - "@oxlint/win32-arm64": "npm:1.31.0" - "@oxlint/win32-x64": "npm:1.31.0" + "@oxlint/darwin-arm64": "npm:1.43.0" + "@oxlint/darwin-x64": "npm:1.43.0" + "@oxlint/linux-arm64-gnu": "npm:1.43.0" + "@oxlint/linux-arm64-musl": "npm:1.43.0" + "@oxlint/linux-x64-gnu": "npm:1.43.0" + "@oxlint/linux-x64-musl": "npm:1.43.0" + "@oxlint/win32-arm64": "npm:1.43.0" + "@oxlint/win32-x64": "npm:1.43.0" peerDependencies: - oxlint-tsgolint: ">=0.8.1" + oxlint-tsgolint: ">=0.11.2" dependenciesMeta: "@oxlint/darwin-arm64": optional: true @@ -2214,9 +2214,8 @@ __metadata: oxlint-tsgolint: optional: true bin: - oxc_language_server: bin/oxc_language_server oxlint: bin/oxlint - checksum: 10c0/f8555b2549e8b93d5a7d628bc696220c7b82d243db8fecb7947fb2797b71e3c8caffe48a15d9ed370aff745aea5be7c72cfa49ec5a9c3f7c2e142b1cc5b89f49 + checksum: 10c0/ca7415bdace08faf9cad7ad3c715e8a03f6e2151d1ce784a52a18427fb482457a41ea4175cc1816be19ff8e3aa4e9e6fdab5ec9e5eef4070e4755b5b1418b1c1 languageName: node linkType: hard From e1937f69bb546f93fbc89dfffb6d5372bf1ca00e Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 17 Feb 2026 20:19:37 -0800 Subject: [PATCH 2/2] regenerate node.js loading script (index.js) we should probably avoid checking this file into the repo remote. --- bindings/node/index.js | 253 +++++++++++++++++++++++++++++++++++------ cspell.config.yml | 2 + 2 files changed, 220 insertions(+), 35 deletions(-) diff --git a/bindings/node/index.js b/bindings/node/index.js index 8def36f..70e40df 100644 --- a/bindings/node/index.js +++ b/bindings/node/index.js @@ -3,9 +3,6 @@ // @ts-nocheck /* auto-generated by NAPI-RS */ -const { createRequire } = require('node:module') -require = createRequire(__filename) - const { readFileSync } = require('node:fs') let nativeBinding = null const loadErrors = [] @@ -66,7 +63,7 @@ const isMuslFromChildProcess = () => { function requireNative() { if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) { try { - nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); + return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH); } catch (err) { loadErrors.push(err) } @@ -78,7 +75,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-android-arm64') + const binding = require('@cpp-linter/cpp-linter-android-arm64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-android-arm64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -89,7 +91,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-android-arm-eabi') + const binding = require('@cpp-linter/cpp-linter-android-arm-eabi') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-android-arm-eabi/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -98,16 +105,39 @@ function requireNative() { } } else if (process.platform === 'win32') { if (process.arch === 'x64') { + if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') { + try { + return require('./cpp-linter.win32-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } try { + const binding = require('@cpp-linter/cpp-linter-win32-x64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-win32-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { return require('./cpp-linter.win32-x64-msvc.node') } catch (e) { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-win32-x64-msvc') + const binding = require('@cpp-linter/cpp-linter-win32-x64-msvc') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-win32-x64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } + } } else if (process.arch === 'ia32') { try { return require('./cpp-linter.win32-ia32-msvc.node') @@ -115,7 +145,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-win32-ia32-msvc') + const binding = require('@cpp-linter/cpp-linter-win32-ia32-msvc') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-win32-ia32-msvc/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -126,7 +161,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-win32-arm64-msvc') + const binding = require('@cpp-linter/cpp-linter-win32-arm64-msvc') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-win32-arm64-msvc/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -140,7 +180,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-darwin-universal') + const binding = require('@cpp-linter/cpp-linter-darwin-universal') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-darwin-universal/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -151,7 +196,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-darwin-x64') + const binding = require('@cpp-linter/cpp-linter-darwin-x64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-darwin-x64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -162,7 +212,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-darwin-arm64') + const binding = require('@cpp-linter/cpp-linter-darwin-arm64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-darwin-arm64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -177,7 +232,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-freebsd-x64') + const binding = require('@cpp-linter/cpp-linter-freebsd-x64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-freebsd-x64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -188,7 +248,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-freebsd-arm64') + const binding = require('@cpp-linter/cpp-linter-freebsd-arm64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-freebsd-arm64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -204,7 +269,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-x64-musl') + const binding = require('@cpp-linter/cpp-linter-linux-x64-musl') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-x64-musl/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -215,7 +285,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-x64-gnu') + const binding = require('@cpp-linter/cpp-linter-linux-x64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-x64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -228,7 +303,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm64-musl') + const binding = require('@cpp-linter/cpp-linter-linux-arm64-musl') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-arm64-musl/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -239,7 +319,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm64-gnu') + const binding = require('@cpp-linter/cpp-linter-linux-arm64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-arm64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -252,7 +337,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm-musleabihf') + const binding = require('@cpp-linter/cpp-linter-linux-arm-musleabihf') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-arm-musleabihf/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -263,7 +353,46 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm-gnueabihf') + const binding = require('@cpp-linter/cpp-linter-linux-arm-gnueabihf') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-arm-gnueabihf/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } + } else if (process.arch === 'loong64') { + if (isMusl()) { + try { + return require('./cpp-linter.linux-loong64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@cpp-linter/cpp-linter-linux-loong64-musl') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-loong64-musl/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding + } catch (e) { + loadErrors.push(e) + } + } else { + try { + return require('./cpp-linter.linux-loong64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + const binding = require('@cpp-linter/cpp-linter-linux-loong64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-loong64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -276,7 +405,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-riscv64-musl') + const binding = require('@cpp-linter/cpp-linter-linux-riscv64-musl') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-riscv64-musl/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -287,7 +421,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-riscv64-gnu') + const binding = require('@cpp-linter/cpp-linter-linux-riscv64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-riscv64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -299,7 +438,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-ppc64-gnu') + const binding = require('@cpp-linter/cpp-linter-linux-ppc64-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-ppc64-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -310,7 +454,12 @@ function requireNative() { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-s390x-gnu') + const binding = require('@cpp-linter/cpp-linter-linux-s390x-gnu') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-linux-s390x-gnu/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -320,34 +469,49 @@ function requireNative() { } else if (process.platform === 'openharmony') { if (process.arch === 'arm64') { try { - return require('./cpp-linter.linux-arm64-ohos.node') + return require('./cpp-linter.openharmony-arm64.node') } catch (e) { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm64-ohos') + const binding = require('@cpp-linter/cpp-linter-openharmony-arm64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-openharmony-arm64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } } else if (process.arch === 'x64') { try { - return require('./cpp-linter.linux-x64-ohos.node') + return require('./cpp-linter.openharmony-x64.node') } catch (e) { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-x64-ohos') + const binding = require('@cpp-linter/cpp-linter-openharmony-x64') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-openharmony-x64/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } } else if (process.arch === 'arm') { try { - return require('./cpp-linter.linux-arm-ohos.node') + return require('./cpp-linter.openharmony-arm.node') } catch (e) { loadErrors.push(e) } try { - return require('@cpp-linter/cpp-linter-linux-arm-ohos') + const binding = require('@cpp-linter/cpp-linter-openharmony-arm') + const bindingPackageVersion = require('@cpp-linter/cpp-linter-openharmony-arm/package.json').version + if (bindingPackageVersion !== '2.0.0-rc15' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') { + throw new Error(`Native binding package version mismatch, expected 2.0.0-rc15 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`) + } + return binding } catch (e) { loadErrors.push(e) } @@ -362,22 +526,36 @@ function requireNative() { nativeBinding = requireNative() if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + let wasiBinding = null + let wasiBindingError = null try { - nativeBinding = require('./cpp-linter.wasi.cjs') + wasiBinding = require('./cpp-linter.wasi.cjs') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { - loadErrors.push(err) + wasiBindingError = err } } - if (!nativeBinding) { + if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { try { - nativeBinding = require('@cpp-linter/cpp-linter-wasm32-wasi') + wasiBinding = require('@cpp-linter/cpp-linter-wasm32-wasi') + nativeBinding = wasiBinding } catch (err) { if (process.env.NAPI_RS_FORCE_WASI) { + if (!wasiBindingError) { + wasiBindingError = err + } else { + wasiBindingError.cause = err + } loadErrors.push(err) } } } + if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) { + const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error') + error.cause = wasiBindingError + throw error + } } if (!nativeBinding) { @@ -386,7 +564,12 @@ if (!nativeBinding) { `Cannot find native binding. ` + `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` + 'Please try `npm i` again after removing both package-lock.json and node_modules directory.', - { cause: loadErrors } + { + cause: loadErrors.reduce((err, cur) => { + cur.cause = err + return cur + }), + }, ) } throw new Error(`Failed to load native binding`) diff --git a/cspell.config.yml b/cspell.config.yml index d355508..1337c04 100644 --- a/cspell.config.yml +++ b/cspell.config.yml @@ -134,3 +134,5 @@ ignorePaths: - .vscode/extensions.json - .yarn/releases/* - "*.lock" + # generated file out of our control + - bindings/node/index.js