@ast-grep/napi 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -1
- package/index.js +13 -2
- package/package.json +8 -8
package/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export const enum FrontEndLanguage {
|
|
|
7
7
|
Html = 0,
|
|
8
8
|
JavaScript = 1,
|
|
9
9
|
Tsx = 2,
|
|
10
|
-
|
|
10
|
+
Css = 3,
|
|
11
|
+
TypeScript = 4
|
|
11
12
|
}
|
|
12
13
|
export interface Pos {
|
|
13
14
|
/** line number starting from 1 */
|
|
@@ -26,6 +27,7 @@ export interface NapiConfig {
|
|
|
26
27
|
constraints?: any
|
|
27
28
|
language?: FrontEndLanguage
|
|
28
29
|
}
|
|
30
|
+
export function parseFiles(paths: string[], callback: (err: null | Error, result: SgRoot) => void): Promise<number>
|
|
29
31
|
export class SgNode {
|
|
30
32
|
range(): Range
|
|
31
33
|
isLeaf(): boolean
|
|
@@ -52,6 +54,7 @@ export class SgNode {
|
|
|
52
54
|
}
|
|
53
55
|
export class SgRoot {
|
|
54
56
|
root(): SgNode
|
|
57
|
+
filename(): string
|
|
55
58
|
}
|
|
56
59
|
export namespace html {
|
|
57
60
|
export function parse(src: string): SgRoot
|
package/index.js
CHANGED
|
@@ -11,7 +11,8 @@ function isMusl() {
|
|
|
11
11
|
// For Node 10
|
|
12
12
|
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
13
13
|
try {
|
|
14
|
-
|
|
14
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim();
|
|
15
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
15
16
|
} catch (e) {
|
|
16
17
|
return true
|
|
17
18
|
}
|
|
@@ -101,6 +102,15 @@ switch (platform) {
|
|
|
101
102
|
}
|
|
102
103
|
break
|
|
103
104
|
case 'darwin':
|
|
105
|
+
localFileExisted = existsSync(join(__dirname, 'ast-grep-napi.darwin-universal.node'))
|
|
106
|
+
try {
|
|
107
|
+
if (localFileExisted) {
|
|
108
|
+
nativeBinding = require('./ast-grep-napi.darwin-universal.node')
|
|
109
|
+
} else {
|
|
110
|
+
nativeBinding = require('@ast-grep/napi-darwin-universal')
|
|
111
|
+
}
|
|
112
|
+
break
|
|
113
|
+
} catch {}
|
|
104
114
|
switch (arch) {
|
|
105
115
|
case 'x64':
|
|
106
116
|
localFileExisted = existsSync(join(__dirname, 'ast-grep-napi.darwin-x64.node'))
|
|
@@ -236,11 +246,12 @@ if (!nativeBinding) {
|
|
|
236
246
|
throw new Error(`Failed to load native binding`)
|
|
237
247
|
}
|
|
238
248
|
|
|
239
|
-
const { FrontEndLanguage, SgNode, SgRoot, html, js, jsx, ts, tsx } = nativeBinding
|
|
249
|
+
const { FrontEndLanguage, SgNode, SgRoot, parseFiles, html, js, jsx, ts, tsx } = nativeBinding
|
|
240
250
|
|
|
241
251
|
module.exports.FrontEndLanguage = FrontEndLanguage
|
|
242
252
|
module.exports.SgNode = SgNode
|
|
243
253
|
module.exports.SgRoot = SgRoot
|
|
254
|
+
module.exports.parseFiles = parseFiles
|
|
244
255
|
module.exports.html = html
|
|
245
256
|
module.exports.js = js
|
|
246
257
|
module.exports.jsx = jsx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ast-grep/napi",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Search and Rewrite code at large scale using precise AST pattern",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": "https://github.com/ast-grep/ast-grep",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"version": "napi version"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@napi-rs/cli": "2.14.
|
|
46
|
+
"@napi-rs/cli": "2.14.4",
|
|
47
47
|
"ava": "5.1.1",
|
|
48
48
|
"chalk": "5.2.0",
|
|
49
49
|
"ts-node": "10.9.1",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
},
|
|
65
65
|
"packageManager": "yarn@3.2.3",
|
|
66
66
|
"optionalDependencies": {
|
|
67
|
-
"@ast-grep/napi-win32-x64-msvc": "0.2.
|
|
68
|
-
"@ast-grep/napi-darwin-x64": "0.2.
|
|
69
|
-
"@ast-grep/napi-linux-x64-gnu": "0.2.
|
|
70
|
-
"@ast-grep/napi-win32-ia32-msvc": "0.2.
|
|
71
|
-
"@ast-grep/napi-darwin-arm64": "0.2.
|
|
72
|
-
"@ast-grep/napi-win32-arm64-msvc": "0.2.
|
|
67
|
+
"@ast-grep/napi-win32-x64-msvc": "0.2.3",
|
|
68
|
+
"@ast-grep/napi-darwin-x64": "0.2.3",
|
|
69
|
+
"@ast-grep/napi-linux-x64-gnu": "0.2.3",
|
|
70
|
+
"@ast-grep/napi-win32-ia32-msvc": "0.2.3",
|
|
71
|
+
"@ast-grep/napi-darwin-arm64": "0.2.3",
|
|
72
|
+
"@ast-grep/napi-win32-arm64-msvc": "0.2.3"
|
|
73
73
|
}
|
|
74
74
|
}
|