@ast-grep/napi 0.15.1 → 0.16.0

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.
Files changed (3) hide show
  1. package/index.d.ts +26 -16
  2. package/index.js +29 -0
  3. package/package.json +10 -8
package/index.d.ts CHANGED
@@ -3,6 +3,22 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ /**
7
+ * Rule configuration similar to YAML
8
+ * See https://ast-grep.github.io/reference/yaml.html
9
+ */
10
+ export interface NapiConfig {
11
+ /** The rule object, see https://ast-grep.github.io/reference/rule.html */
12
+ rule: any
13
+ /** See https://ast-grep.github.io/guide/rule-config.html#constraints */
14
+ constraints?: any
15
+ /** Available languages: html, css, js, jsx, ts, tsx */
16
+ language?: FrontEndLanguage
17
+ /** https://ast-grep.github.io/reference/yaml.html#transform */
18
+ transform?: any
19
+ /** https://ast-grep.github.io/guide/rule-config/utility-rule.html */
20
+ utils?: any
21
+ }
6
22
  export const enum FrontEndLanguage {
7
23
  Html = 0,
8
24
  JavaScript = 1,
@@ -24,28 +40,22 @@ export interface Range {
24
40
  /** ending position of the range */
25
41
  end: Pos
26
42
  }
27
- /**
28
- * Rule configuration similar to YAML
29
- * See https://ast-grep.github.io/reference/yaml.html
30
- */
31
- export interface NapiConfig {
32
- /** The rule object, see https://ast-grep.github.io/reference/rule.html */
33
- rule: any
34
- /** See https://ast-grep.github.io/guide/rule-config.html#constraints */
35
- constraints?: any
36
- /** Available languages: html, css, js, jsx, ts, tsx */
37
- language?: FrontEndLanguage
38
- /** https://ast-grep.github.io/reference/yaml.html#transform */
39
- transform?: any
40
- /** https://ast-grep.github.io/guide/rule-config/utility-rule.html */
41
- utils?: any
43
+ export interface FileOption {
44
+ paths: Array<string>
45
+ languageGlobs: Record<string, Array<string>>
42
46
  }
43
- export function parseFiles(paths: string[], callback: (err: null | Error, result: SgRoot) => void): Promise<number>
47
+ export function parseFiles(paths: Array<string> | FileOption, callback: (err: null | Error, result: SgRoot) => void): Promise<number>
44
48
  export interface FindConfig {
45
49
  /** specify the file paths to recursively find files */
46
50
  paths: Array<string>
47
51
  /** a Rule object to find what nodes will match */
48
52
  matcher: NapiConfig
53
+ /**
54
+ * An list of pattern globs to treat of certain files in the specified language.
55
+ * eg. ['*.vue', '*.svelte'] for html.findFiles, or ['*.ts'] for tsx.findFiles.
56
+ * It is slightly different from https://ast-grep.github.io/reference/sgconfig.html#languageglobs
57
+ */
58
+ languageGlobs?: Array<string>
49
59
  }
50
60
  export class SgNode {
51
61
  range(): Range
package/index.js CHANGED
@@ -237,6 +237,35 @@ switch (platform) {
237
237
  loadError = e
238
238
  }
239
239
  break
240
+ case 'riscv64':
241
+ if (isMusl()) {
242
+ localFileExisted = existsSync(
243
+ join(__dirname, 'ast-grep-napi.linux-riscv64-musl.node')
244
+ )
245
+ try {
246
+ if (localFileExisted) {
247
+ nativeBinding = require('./ast-grep-napi.linux-riscv64-musl.node')
248
+ } else {
249
+ nativeBinding = require('@ast-grep/napi-linux-riscv64-musl')
250
+ }
251
+ } catch (e) {
252
+ loadError = e
253
+ }
254
+ } else {
255
+ localFileExisted = existsSync(
256
+ join(__dirname, 'ast-grep-napi.linux-riscv64-gnu.node')
257
+ )
258
+ try {
259
+ if (localFileExisted) {
260
+ nativeBinding = require('./ast-grep-napi.linux-riscv64-gnu.node')
261
+ } else {
262
+ nativeBinding = require('@ast-grep/napi-linux-riscv64-gnu')
263
+ }
264
+ } catch (e) {
265
+ loadError = e
266
+ }
267
+ }
268
+ break
240
269
  default:
241
270
  throw new Error(`Unsupported architecture on Linux: ${arch}`)
242
271
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ast-grep/napi",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "description": "Search and Rewrite code at large scale using precise AST pattern",
5
5
  "homepage": "https://ast-grep.github.io",
6
6
  "main": "index.js",
@@ -24,7 +24,8 @@
24
24
  "additional": [
25
25
  "i686-pc-windows-msvc",
26
26
  "aarch64-apple-darwin",
27
- "aarch64-pc-windows-msvc"
27
+ "aarch64-pc-windows-msvc",
28
+ "aarch64-unknown-linux-gnu"
28
29
  ]
29
30
  }
30
31
  },
@@ -64,11 +65,12 @@
64
65
  }
65
66
  },
66
67
  "optionalDependencies": {
67
- "@ast-grep/napi-win32-x64-msvc": "0.15.1",
68
- "@ast-grep/napi-darwin-x64": "0.15.1",
69
- "@ast-grep/napi-linux-x64-gnu": "0.15.1",
70
- "@ast-grep/napi-win32-ia32-msvc": "0.15.1",
71
- "@ast-grep/napi-darwin-arm64": "0.15.1",
72
- "@ast-grep/napi-win32-arm64-msvc": "0.15.1"
68
+ "@ast-grep/napi-win32-x64-msvc": "0.16.0",
69
+ "@ast-grep/napi-darwin-x64": "0.16.0",
70
+ "@ast-grep/napi-linux-x64-gnu": "0.16.0",
71
+ "@ast-grep/napi-win32-ia32-msvc": "0.16.0",
72
+ "@ast-grep/napi-darwin-arm64": "0.16.0",
73
+ "@ast-grep/napi-win32-arm64-msvc": "0.16.0",
74
+ "@ast-grep/napi-linux-arm64-gnu": "0.16.0"
73
75
  }
74
76
  }