Skip to content

Commit 68ecd21

Browse files
feat: add template files
1 parent 1b9544e commit 68ecd21

File tree

9 files changed

+79
-5
lines changed

9 files changed

+79
-5
lines changed

packages/toml/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ast-grep/lang-toml",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

packages/toml/postinstall.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const { postinstall } = require('@ast-grep/setup-lang')
22
postinstall({
33
dirname: __dirname,
4-
treeSitterPackage: '@tree-sitter-grammars/tree-sitter-toml',
54
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
type LanguageRegistration = {
2+
libraryPath: string
3+
extensions: string[]
4+
languageSymbol?: string
5+
metaVarChar?: string
6+
expandoChar?: string
7+
}
8+
9+
declare const registratoin: LanguageRegistration
10+
export default registratoin

scripts/create-lang/template/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('node:path')
2+
const libPath = path.join(__dirname, 'parser.so')
3+
4+
module.exports = {
5+
libraryPath: libPath,
6+
extensions: $$EXTENSIONS$$,
7+
languageSymbol: $$LANGUAGE_SYMBOL$$,
8+
expandoChar: '_',
9+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { setup } = require('@ast-grep/nursery')
2+
const languageRegistration = require('./index')
3+
4+
setup({
5+
dirname: __dirname,
6+
name: '$$NAME$$',
7+
treeSitterPackage: '$$TREE_SITTER_PACKAGE$$',
8+
languageRegistration,
9+
testRunner: (parse) => {
10+
// add test here
11+
}
12+
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@ast-grep/lang-$$NAME$$",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "tree-sitter build -o parser.so",
8+
"source": "node nursery.js source",
9+
"prepublishOnly": "node nursery.js source",
10+
"postinstall": "node postinstall.js",
11+
"test": "node nursery.js test"
12+
},
13+
"files": [
14+
"index.js",
15+
"index.d.ts",
16+
"type.d.ts",
17+
"postinstall.js",
18+
"src",
19+
"prebuilds"
20+
],
21+
"keywords": [],
22+
"author": "",
23+
"license": "ISC",
24+
"dependencies": {
25+
"@ast-grep/setup-lang": "0.0.2"
26+
},
27+
"peerDependencies": {
28+
"tree-sitter-cli": "0.24.6"
29+
},
30+
"peerDependenciesMeta": {
31+
"tree-sitter-cli": {
32+
"optional": true
33+
}
34+
},
35+
"devDependencies": {
36+
"@ast-grep/nursery": "0.0.2"
37+
},
38+
"publishConfig": {
39+
"access": "public",
40+
"registry": "https://registry.npmjs.org/"
41+
}
42+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { postinstall } = require('@ast-grep/setup-lang')
2+
postinstall({
3+
dirname: __dirname,
4+
})

scripts/setup/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ function log(...args: unknown[]) {
1212
interface SetupConfig {
1313
/** Directory of the lang package. e.g. __dirname */
1414
dirname: string
15-
/** Package name of tree-sitter package. e.g. tree-sitter-css */
16-
treeSitterPackage: string
1715
}
1816

1917
/**

scripts/setup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ast-grep/setup-lang",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"private": false,
55
"description": "",
66
"main": "index.js",

0 commit comments

Comments
 (0)