🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ast-grep/napi

Package Overview
Dependencies
Maintainers
1
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ast-grep/napi - npm Package Compare versions

Comparing version
0.42.0
to
0.42.1
+218
-35
index.js

@@ -6,5 +6,2 @@ // prettier-ignore

const { createRequire } = require('node:module')
require = createRequire(__filename)
const { readFileSync } = require('node:fs')

@@ -70,3 +67,3 @@ let nativeBinding = null

try {
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {

@@ -83,3 +80,8 @@ loadErrors.push(err)

try {
return require('@ast-grep/napi-android-arm64')
const binding = require('@ast-grep/napi-android-arm64')
const bindingPackageVersion = require('@ast-grep/napi-android-arm64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -95,3 +97,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-android-arm-eabi')
const binding = require('@ast-grep/napi-android-arm-eabi')
const bindingPackageVersion = require('@ast-grep/napi-android-arm-eabi/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -105,3 +112,20 @@ loadErrors.push(e)

if (process.arch === 'x64') {
if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
try {
return require('./ast-grep-napi.win32-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ast-grep/napi-win32-x64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-win32-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./ast-grep-napi.win32-x64-msvc.node')

@@ -112,6 +136,12 @@ } catch (e) {

try {
return require('@ast-grep/napi-win32-x64-msvc')
const binding = require('@ast-grep/napi-win32-x64-msvc')
const bindingPackageVersion = require('@ast-grep/napi-win32-x64-msvc/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ia32') {

@@ -124,3 +154,8 @@ try {

try {
return require('@ast-grep/napi-win32-ia32-msvc')
const binding = require('@ast-grep/napi-win32-ia32-msvc')
const bindingPackageVersion = require('@ast-grep/napi-win32-ia32-msvc/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -136,3 +171,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-win32-arm64-msvc')
const binding = require('@ast-grep/napi-win32-arm64-msvc')
const bindingPackageVersion = require('@ast-grep/napi-win32-arm64-msvc/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -151,3 +191,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-darwin-universal')
const binding = require('@ast-grep/napi-darwin-universal')
const bindingPackageVersion = require('@ast-grep/napi-darwin-universal/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -163,3 +208,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-darwin-x64')
const binding = require('@ast-grep/napi-darwin-x64')
const bindingPackageVersion = require('@ast-grep/napi-darwin-x64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -175,3 +225,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-darwin-arm64')
const binding = require('@ast-grep/napi-darwin-arm64')
const bindingPackageVersion = require('@ast-grep/napi-darwin-arm64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -191,3 +246,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-freebsd-x64')
const binding = require('@ast-grep/napi-freebsd-x64')
const bindingPackageVersion = require('@ast-grep/napi-freebsd-x64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -203,3 +263,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-freebsd-arm64')
const binding = require('@ast-grep/napi-freebsd-arm64')
const bindingPackageVersion = require('@ast-grep/napi-freebsd-arm64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -220,3 +285,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-x64-musl')
const binding = require('@ast-grep/napi-linux-x64-musl')
const bindingPackageVersion = require('@ast-grep/napi-linux-x64-musl/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -232,3 +302,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-x64-gnu')
const binding = require('@ast-grep/napi-linux-x64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-x64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -246,3 +321,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm64-musl')
const binding = require('@ast-grep/napi-linux-arm64-musl')
const bindingPackageVersion = require('@ast-grep/napi-linux-arm64-musl/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -258,3 +338,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm64-gnu')
const binding = require('@ast-grep/napi-linux-arm64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-arm64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -272,3 +357,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm-musleabihf')
const binding = require('@ast-grep/napi-linux-arm-musleabihf')
const bindingPackageVersion = require('@ast-grep/napi-linux-arm-musleabihf/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -284,3 +374,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm-gnueabihf')
const binding = require('@ast-grep/napi-linux-arm-gnueabihf')
const bindingPackageVersion = require('@ast-grep/napi-linux-arm-gnueabihf/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -290,2 +385,36 @@ loadErrors.push(e)

}
} else if (process.arch === 'loong64') {
if (isMusl()) {
try {
return require('./ast-grep-napi.linux-loong64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ast-grep/napi-linux-loong64-musl')
const bindingPackageVersion = require('@ast-grep/napi-linux-loong64-musl/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./ast-grep-napi.linux-loong64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
const binding = require('@ast-grep/napi-linux-loong64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-loong64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {

@@ -299,3 +428,8 @@ if (isMusl()) {

try {
return require('@ast-grep/napi-linux-riscv64-musl')
const binding = require('@ast-grep/napi-linux-riscv64-musl')
const bindingPackageVersion = require('@ast-grep/napi-linux-riscv64-musl/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -311,3 +445,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-riscv64-gnu')
const binding = require('@ast-grep/napi-linux-riscv64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-riscv64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -324,3 +463,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-ppc64-gnu')
const binding = require('@ast-grep/napi-linux-ppc64-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-ppc64-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -336,3 +480,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-s390x-gnu')
const binding = require('@ast-grep/napi-linux-s390x-gnu')
const bindingPackageVersion = require('@ast-grep/napi-linux-s390x-gnu/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -347,3 +496,3 @@ loadErrors.push(e)

try {
return require('./ast-grep-napi.linux-arm64-ohos.node')
return require('./ast-grep-napi.openharmony-arm64.node')
} catch (e) {

@@ -353,3 +502,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm64-ohos')
const binding = require('@ast-grep/napi-openharmony-arm64')
const bindingPackageVersion = require('@ast-grep/napi-openharmony-arm64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -360,3 +514,3 @@ loadErrors.push(e)

try {
return require('./ast-grep-napi.linux-x64-ohos.node')
return require('./ast-grep-napi.openharmony-x64.node')
} catch (e) {

@@ -366,3 +520,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-x64-ohos')
const binding = require('@ast-grep/napi-openharmony-x64')
const bindingPackageVersion = require('@ast-grep/napi-openharmony-x64/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -373,3 +532,3 @@ loadErrors.push(e)

try {
return require('./ast-grep-napi.linux-arm-ohos.node')
return require('./ast-grep-napi.openharmony-arm.node')
} catch (e) {

@@ -379,3 +538,8 @@ loadErrors.push(e)

try {
return require('@ast-grep/napi-linux-arm-ohos')
const binding = require('@ast-grep/napi-openharmony-arm')
const bindingPackageVersion = require('@ast-grep/napi-openharmony-arm/package.json').version
if (bindingPackageVersion !== '0.42.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
throw new Error(`Native binding package version mismatch, expected 0.42.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
}
return binding
} catch (e) {

@@ -395,14 +559,23 @@ loadErrors.push(e)

if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
let wasiBinding = null
let wasiBindingError = null
try {
nativeBinding = require('./ast-grep-napi.wasi.cjs')
wasiBinding = require('./ast-grep-napi.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('@ast-grep/napi-wasm32-wasi')
wasiBinding = require('@ast-grep/napi-wasm32-wasi')
nativeBinding = wasiBinding
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
if (!wasiBindingError) {
wasiBindingError = err
} else {
wasiBindingError.cause = err
}
loadErrors.push(err)

@@ -412,2 +585,7 @@ }

}
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
}
}

@@ -421,3 +599,8 @@

'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
}),
},
)

@@ -424,0 +607,0 @@ }

+23
-23
{
"name": "@ast-grep/napi",
"version": "0.42.0",
"version": "0.42.1",
"description": "Search and Rewrite code at large scale using precise AST pattern",

@@ -48,3 +48,3 @@ "homepage": "https://ast-grep.github.io",

"prepublishOnly": "napi prepublish -t npm --no-gh-release",
"pretest": "ts-node scripts/generateTypes.ts --test-only",
"pretest": "tsimp scripts/generateTypes.ts --test-only",
"test": "tsc --noEmit && ava",

@@ -55,23 +55,23 @@ "version": "napi version",

"format:check": "dprint check",
"typegen": "ts-node scripts/generateTypes.ts"
"typegen": "tsimp scripts/generateTypes.ts"
},
"devDependencies": {
"@ast-grep/napi": "0.41.1",
"@napi-rs/cli": "3.5.1",
"@ast-grep/napi": "0.42.0",
"@napi-rs/cli": "3.6.0",
"@types/node": "^24.0.0",
"oxlint": "1.55.0",
"oxlint": "1.58.0",
"ava": "7.0.0",
"chalk": "5.6.2",
"dprint": "0.53.0",
"dprint": "0.53.2",
"smol-toml": "^1.3.1",
"ts-node": "10.9.2",
"typescript": "5.9.3"
"tsimp": "2.0.12",
"typescript": "6.0.2"
},
"ava": {
"require": [
"ts-node/register"
"nodeArguments": [
"--import=tsimp"
],
"extensions": [
"ts"
],
"extensions": {
"ts": "module"
},
"timeout": "2m",

@@ -84,12 +84,12 @@ "workerThreads": false,

"optionalDependencies": {
"@ast-grep/napi-linux-x64-gnu": "0.42.0",
"@ast-grep/napi-win32-x64-msvc": "0.42.0",
"@ast-grep/napi-darwin-x64": "0.42.0",
"@ast-grep/napi-win32-ia32-msvc": "0.42.0",
"@ast-grep/napi-darwin-arm64": "0.42.0",
"@ast-grep/napi-win32-arm64-msvc": "0.42.0",
"@ast-grep/napi-linux-arm64-gnu": "0.42.0",
"@ast-grep/napi-linux-arm64-musl": "0.42.0",
"@ast-grep/napi-linux-x64-musl": "0.42.0"
"@ast-grep/napi-linux-x64-gnu": "0.42.1",
"@ast-grep/napi-win32-x64-msvc": "0.42.1",
"@ast-grep/napi-darwin-x64": "0.42.1",
"@ast-grep/napi-win32-ia32-msvc": "0.42.1",
"@ast-grep/napi-darwin-arm64": "0.42.1",
"@ast-grep/napi-win32-arm64-msvc": "0.42.1",
"@ast-grep/napi-linux-arm64-gnu": "0.42.1",
"@ast-grep/napi-linux-arm64-musl": "0.42.1",
"@ast-grep/napi-linux-x64-musl": "0.42.1"
}
}