From 5d6bb5615ca080ebac7f136834b02ab04dcf8786 Mon Sep 17 00:00:00 2001 From: Nathan Gendron Date: Tue, 1 Apr 2025 13:41:59 -0400 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20typescript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/typescript/README.md | 24 ++++++ packages/typescript/index.d.ts | 10 +++ packages/typescript/index.js | 9 +++ packages/typescript/nursery.js | 12 +++ packages/typescript/package.json | 47 +++++++++++ packages/typescript/postinstall.js | 4 + pnpm-lock.yaml | 120 +++++++++++++++++++++++++++++ 7 files changed, 226 insertions(+) create mode 100644 packages/typescript/README.md create mode 100644 packages/typescript/index.d.ts create mode 100644 packages/typescript/index.js create mode 100644 packages/typescript/nursery.js create mode 100644 packages/typescript/package.json create mode 100644 packages/typescript/postinstall.js diff --git a/packages/typescript/README.md b/packages/typescript/README.md new file mode 100644 index 0000000..39bf541 --- /dev/null +++ b/packages/typescript/README.md @@ -0,0 +1,24 @@ +# ast-grep napi language for typescript + +## Installation + +In a pnpm project, run: + +```bash +pnpm install @ast-grep/lang-typescript +pnpm install @ast-grep/napi +# install the tree-sitter-cli if no prebuild is available +pnpm install @tree-sitter/cli --save-dev +``` + +## Usage + +```js +import typescript from '@ast-grep/lang-typescript' +import { registerDynamicLanguage, parse } from '@ast-grep/napi' + +registerDynamicLanguage({ typescript }) + +const sg = parse('typescript', `your code`) +sg.root().kind() +``` diff --git a/packages/typescript/index.d.ts b/packages/typescript/index.d.ts new file mode 100644 index 0000000..11140a6 --- /dev/null +++ b/packages/typescript/index.d.ts @@ -0,0 +1,10 @@ +type LanguageRegistration = { + libraryPath: string + extensions: string[] + languageSymbol?: string + metaVarChar?: string + expandoChar?: string +} + +declare const registration: LanguageRegistration +export default registration diff --git a/packages/typescript/index.js b/packages/typescript/index.js new file mode 100644 index 0000000..9ba05f8 --- /dev/null +++ b/packages/typescript/index.js @@ -0,0 +1,9 @@ +const path = require('node:path') +const libPath = path.join(__dirname, 'parser.so') + +module.exports = { + libraryPath: libPath, + extensions: ['ts', 'cts', 'mts'], + languageSymbol: 'tree_sitter_typescript', + expandoChar: '$', +} diff --git a/packages/typescript/nursery.js b/packages/typescript/nursery.js new file mode 100644 index 0000000..2ee873f --- /dev/null +++ b/packages/typescript/nursery.js @@ -0,0 +1,12 @@ +const { setup } = require('@ast-grep/nursery') +const languageRegistration = require('./index') + +setup({ + dirname: __dirname, + name: 'typescript', + treeSitterPackage: 'tree-sitter-typescript', + languageRegistration, + testRunner: parse => { + // add test here + }, +}) diff --git a/packages/typescript/package.json b/packages/typescript/package.json new file mode 100644 index 0000000..1d749cf --- /dev/null +++ b/packages/typescript/package.json @@ -0,0 +1,47 @@ +{ + "name": "@ast-grep/lang-typescript", + "version": "0.0.1", + "description": "", + "main": "index.js", + "scripts": { + "build": "tree-sitter build -o parser.so", + "source": "node nursery.js source", + "prepublishOnly": "node nursery.js source", + "postinstall": "node postinstall.js", + "test": "node nursery.js test" + }, + "files": [ + "index.js", + "index.d.ts", + "type.d.ts", + "postinstall.js", + "src", + "prebuilds" + ], + "keywords": ["ast-grep"], + "author": "", + "license": "ISC", + "dependencies": { + "@ast-grep/setup-lang": "0.0.3" + }, + "peerDependencies": { + "tree-sitter-cli": "0.24.6" + }, + "peerDependenciesMeta": { + "tree-sitter-cli": { + "optional": true + } + }, + "devDependencies": { + "@ast-grep/nursery": "0.0.2", + "tree-sitter-cli": "0.24.6", + "tree-sitter-typescript": "0.23.2" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org/" + }, + "pnpm": { + "onlyBuiltDependencies": ["@ast-grep/lang-typescript", "tree-sitter-cli"] + } +} diff --git a/packages/typescript/postinstall.js b/packages/typescript/postinstall.js new file mode 100644 index 0000000..b9141ff --- /dev/null +++ b/packages/typescript/postinstall.js @@ -0,0 +1,4 @@ +const { postinstall } = require('@ast-grep/setup-lang') +postinstall({ + dirname: __dirname, +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 139761b..07fafb8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -418,6 +418,22 @@ importers: specifier: ^0.23.2 version: 0.23.2(tree-sitter@0.21.1) + packages/typescript: + dependencies: + '@ast-grep/setup-lang': + specifier: 0.0.3 + version: 0.0.3 + devDependencies: + '@ast-grep/nursery': + specifier: 0.0.2 + version: 0.0.2 + tree-sitter-cli: + specifier: 0.24.6 + version: 0.24.6 + tree-sitter-typescript: + specifier: 0.23.2 + version: 0.23.2(tree-sitter@0.21.1) + scripts/create-lang: dependencies: prompts: @@ -458,64 +474,125 @@ importers: packages: + '@ast-grep/napi-darwin-arm64@0.33.0': + resolution: {integrity: sha512-FsBQiBNGbqeU6z2sjFgnV6MXuBa0wYUb4PViMnqsKLeWiO7kRii5crmXLCtdTD2hufXTG6Rll8X46AkYOAwGGQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + '@ast-grep/napi-darwin-arm64@0.36.2': resolution: {integrity: sha512-0dzW+5SRuUxAlfwgMiUWXSvvyVD3nffzLtH5RhH2a1VXbQxi2UFWZqtfhv6e27iIUTnPfZDnZGNRw8FZgttMfQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] + '@ast-grep/napi-darwin-x64@0.33.0': + resolution: {integrity: sha512-rWo1wG7fc7K20z9ExIeN6U4QqjHhoQSpBDDnmxKTR0nIwPfyMq338sS4sWZomutxprcZDtWrekxH1lXjNvfuiA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + '@ast-grep/napi-darwin-x64@0.36.2': resolution: {integrity: sha512-7TPdnq55OBXGcJLDARObI5BUFbp0AVRMGEzjnIBMWbRSowlDVTH7qBWwNAYk4auCdkwG8EBL40BUIHmagzpoCw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] + '@ast-grep/napi-linux-arm64-gnu@0.33.0': + resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + '@ast-grep/napi-linux-arm64-gnu@0.36.2': resolution: {integrity: sha512-/h51eEnEYCq4bclzhynH+964LQXDKXgNb2Un+Y9TLOU8VRaGNawTkZkFq+iBp8T1hl0CznnsQQsg+9pHDHprHQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + '@ast-grep/napi-linux-arm64-musl@0.33.0': + resolution: {integrity: sha512-oUGZgCaVCijFgvC+X52ttgoWUqgrIsSVJZgn+1VBY3n4mpzcoYAghFomSUbRTBUL2ebvZweA33Klqks4okY61w==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + '@ast-grep/napi-linux-arm64-musl@0.36.2': resolution: {integrity: sha512-RIuk0VaQW2b5uOPJzuYFQBwMZIEVnp6maXPjnatUHxfniirSI172E7LtOU/FIEpCjU9Fpq23A79S43ImFt1KLA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + '@ast-grep/napi-linux-x64-gnu@0.33.0': + resolution: {integrity: sha512-QTAkfxQSsOGRza0hnkeAgJDQqR00iDerRNq42dOGIzgF+Kse491By3UmBEMG4oCbv17yYcBBlknQkzKSKtigjw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + '@ast-grep/napi-linux-x64-gnu@0.36.2': resolution: {integrity: sha512-Xmb50HPfRNi+iLtHp+8/dqiTd8tjArYxOdj1tZzjRndpKhFpQDVrcOnPFObDCRgxVeLovdql9A1ad6BMcEL01Q==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + '@ast-grep/napi-linux-x64-musl@0.33.0': + resolution: {integrity: sha512-PW6bZO7MyQsBNZv0idI/Ah6ak66T8LqZ21wBGjtQp9NDGViOtkLeu+eJJGaZjMqUdidKHKgmMKXksZHl2m8ulQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + '@ast-grep/napi-linux-x64-musl@0.36.2': resolution: {integrity: sha512-RSnqCsl3OBfJWh2rETtv3o7xd4QnbB2YTh6H6oYfFhhX0tlon/V+bUXI77hU2/W73hj9GHqWZsygsF43NXn/Hw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + '@ast-grep/napi-win32-arm64-msvc@0.33.0': + resolution: {integrity: sha512-ijmFQcFc32JOIQlSfnhDJpb3qFb2RhrRqfeY0EHHN1xRSGwZHfsHTSS66nKR2sREmxTIMgxXOtylKicbyyMVKA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + '@ast-grep/napi-win32-arm64-msvc@0.36.2': resolution: {integrity: sha512-/Q85h8F9K2G8qig0lndZWb+ykCfhfpSN27F3i7Aw5C0Ph7S6vFH76xn3l3dJTZb2CwUSsv4JNoqmFmY4B8DExQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] + '@ast-grep/napi-win32-ia32-msvc@0.33.0': + resolution: {integrity: sha512-NNIb2VK3Z2BwKp0QJSw8gkhwOUp85SgTsxJ38p+wIUAA/KzAKCJOmyOaZ301qGHt4gL+jTHgTIvJJX+9eT/REg==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + '@ast-grep/napi-win32-ia32-msvc@0.36.2': resolution: {integrity: sha512-bDdwErB7zf9DvRx3kNZyMKJb9by5ra24WAXSiVzI8MR387ibZP9UCTzKuGqPrbuZADYWiOgsg3nXMklyPFtmhQ==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] + '@ast-grep/napi-win32-x64-msvc@0.33.0': + resolution: {integrity: sha512-gW7viQQjdPA1HoCkpCqoonC81TOwcpP828w/XqZFE/L6uhD8SF2usul8KNBQOiX3O7/fqYEOnbtWMCrwZIqG1Q==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + '@ast-grep/napi-win32-x64-msvc@0.36.2': resolution: {integrity: sha512-LVZ2DqP9fRfyUceE0BGnlKoPmSx3dYYApSEUdt82Pn7jEVWpFFyTLFmZ9ILiCSaVc6urMJpKWdxAHFqDNNlGfg==} engines: {node: '>= 10'} cpu: [x64] os: [win32] + '@ast-grep/napi@0.33.0': + resolution: {integrity: sha512-6heRMmomhSD0dkummRQ+R4xWXXmc41OaDPoPI49mKJXPyvwJPdPZUcQjXdIitOVL4uJV+qM2ZBucDPENDBSixw==} + engines: {node: '>= 10'} + '@ast-grep/napi@0.36.2': resolution: {integrity: sha512-ByenQQ0BtqqY0pvlmipvkDv/cKl/9vVjBydS7hloXOdmXPoUF0pHdlilC7ZfrRW97EzPQQZT2jgHl2tu7zg9QA==} engines: {node: '>= 10'} + '@ast-grep/nursery@0.0.2': + resolution: {integrity: sha512-Epb5KpdiXbHEOegPvEGejGI8UFtpK44Uz8lSb03mVbtBMB1VflMJ6/3wZz2CsZ65S0cdq5YQqt1Rm7E+S68oHQ==} + '@ast-grep/nursery@0.0.3': resolution: {integrity: sha512-fIOozkRrRHcDMv5t06SqUjQMkAwFgn1aiAtpXtOVpF19VE4oWK5MJOXbjI034cNGFDGGmCyMh7r0y2iWlTRRLw==} @@ -1218,33 +1295,72 @@ packages: snapshots: + '@ast-grep/napi-darwin-arm64@0.33.0': + optional: true + '@ast-grep/napi-darwin-arm64@0.36.2': optional: true + '@ast-grep/napi-darwin-x64@0.33.0': + optional: true + '@ast-grep/napi-darwin-x64@0.36.2': optional: true + '@ast-grep/napi-linux-arm64-gnu@0.33.0': + optional: true + '@ast-grep/napi-linux-arm64-gnu@0.36.2': optional: true + '@ast-grep/napi-linux-arm64-musl@0.33.0': + optional: true + '@ast-grep/napi-linux-arm64-musl@0.36.2': optional: true + '@ast-grep/napi-linux-x64-gnu@0.33.0': + optional: true + '@ast-grep/napi-linux-x64-gnu@0.36.2': optional: true + '@ast-grep/napi-linux-x64-musl@0.33.0': + optional: true + '@ast-grep/napi-linux-x64-musl@0.36.2': optional: true + '@ast-grep/napi-win32-arm64-msvc@0.33.0': + optional: true + '@ast-grep/napi-win32-arm64-msvc@0.36.2': optional: true + '@ast-grep/napi-win32-ia32-msvc@0.33.0': + optional: true + '@ast-grep/napi-win32-ia32-msvc@0.36.2': optional: true + '@ast-grep/napi-win32-x64-msvc@0.33.0': + optional: true + '@ast-grep/napi-win32-x64-msvc@0.36.2': optional: true + '@ast-grep/napi@0.33.0': + optionalDependencies: + '@ast-grep/napi-darwin-arm64': 0.33.0 + '@ast-grep/napi-darwin-x64': 0.33.0 + '@ast-grep/napi-linux-arm64-gnu': 0.33.0 + '@ast-grep/napi-linux-arm64-musl': 0.33.0 + '@ast-grep/napi-linux-x64-gnu': 0.33.0 + '@ast-grep/napi-linux-x64-musl': 0.33.0 + '@ast-grep/napi-win32-arm64-msvc': 0.33.0 + '@ast-grep/napi-win32-ia32-msvc': 0.33.0 + '@ast-grep/napi-win32-x64-msvc': 0.33.0 + '@ast-grep/napi@0.36.2': optionalDependencies: '@ast-grep/napi-darwin-arm64': 0.36.2 @@ -1257,6 +1373,10 @@ snapshots: '@ast-grep/napi-win32-ia32-msvc': 0.36.2 '@ast-grep/napi-win32-x64-msvc': 0.36.2 + '@ast-grep/nursery@0.0.2': + dependencies: + '@ast-grep/napi': 0.33.0 + '@ast-grep/nursery@0.0.3': dependencies: '@ast-grep/napi': 0.36.2 From d612c9e9361bcff8eb619f17078a78c5fa36cecc Mon Sep 17 00:00:00 2001 From: Nathan Gendron Date: Thu, 10 Apr 2025 14:04:11 -0400 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20Set=20tree-sitter-typescript?= =?UTF-8?q?=20inner=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/typescript/nursery.js | 2 + packages/typescript/package.json | 4 +- pnpm-lock.yaml | 108 +------------------------------ 3 files changed, 6 insertions(+), 108 deletions(-) diff --git a/packages/typescript/nursery.js b/packages/typescript/nursery.js index 2ee873f..b6220b3 100644 --- a/packages/typescript/nursery.js +++ b/packages/typescript/nursery.js @@ -1,10 +1,12 @@ const { setup } = require('@ast-grep/nursery') const languageRegistration = require('./index') +const path = require('node:path') setup({ dirname: __dirname, name: 'typescript', treeSitterPackage: 'tree-sitter-typescript', + src: path.join('typescript', 'src'), languageRegistration, testRunner: parse => { // add test here diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 1d749cf..a45f068 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "tree-sitter build -o parser.so", + "build": "tree-sitter build -o parser.so ./node_modules/tree-sitter-typescript/typescript", "source": "node nursery.js source", "prepublishOnly": "node nursery.js source", "postinstall": "node postinstall.js", @@ -33,7 +33,7 @@ } }, "devDependencies": { - "@ast-grep/nursery": "0.0.2", + "@ast-grep/nursery": "0.0.3", "tree-sitter-cli": "0.24.6", "tree-sitter-typescript": "0.23.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 07fafb8..9defd56 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -425,8 +425,8 @@ importers: version: 0.0.3 devDependencies: '@ast-grep/nursery': - specifier: 0.0.2 - version: 0.0.2 + specifier: 0.0.3 + version: 0.0.3 tree-sitter-cli: specifier: 0.24.6 version: 0.24.6 @@ -474,125 +474,64 @@ importers: packages: - '@ast-grep/napi-darwin-arm64@0.33.0': - resolution: {integrity: sha512-FsBQiBNGbqeU6z2sjFgnV6MXuBa0wYUb4PViMnqsKLeWiO7kRii5crmXLCtdTD2hufXTG6Rll8X46AkYOAwGGQ==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - '@ast-grep/napi-darwin-arm64@0.36.2': resolution: {integrity: sha512-0dzW+5SRuUxAlfwgMiUWXSvvyVD3nffzLtH5RhH2a1VXbQxi2UFWZqtfhv6e27iIUTnPfZDnZGNRw8FZgttMfQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@ast-grep/napi-darwin-x64@0.33.0': - resolution: {integrity: sha512-rWo1wG7fc7K20z9ExIeN6U4QqjHhoQSpBDDnmxKTR0nIwPfyMq338sS4sWZomutxprcZDtWrekxH1lXjNvfuiA==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - '@ast-grep/napi-darwin-x64@0.36.2': resolution: {integrity: sha512-7TPdnq55OBXGcJLDARObI5BUFbp0AVRMGEzjnIBMWbRSowlDVTH7qBWwNAYk4auCdkwG8EBL40BUIHmagzpoCw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@ast-grep/napi-linux-arm64-gnu@0.33.0': - resolution: {integrity: sha512-3ZnA2k57kxfvLg4s9+6rHaCx1FbWt0EF8fumJMf5nwevu7GbVOOhCkzAetZe80FBgZuIOSR4IS2QMj9ZHI0UdQ==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - '@ast-grep/napi-linux-arm64-gnu@0.36.2': resolution: {integrity: sha512-/h51eEnEYCq4bclzhynH+964LQXDKXgNb2Un+Y9TLOU8VRaGNawTkZkFq+iBp8T1hl0CznnsQQsg+9pHDHprHQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@ast-grep/napi-linux-arm64-musl@0.33.0': - resolution: {integrity: sha512-oUGZgCaVCijFgvC+X52ttgoWUqgrIsSVJZgn+1VBY3n4mpzcoYAghFomSUbRTBUL2ebvZweA33Klqks4okY61w==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [linux] - '@ast-grep/napi-linux-arm64-musl@0.36.2': resolution: {integrity: sha512-RIuk0VaQW2b5uOPJzuYFQBwMZIEVnp6maXPjnatUHxfniirSI172E7LtOU/FIEpCjU9Fpq23A79S43ImFt1KLA==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@ast-grep/napi-linux-x64-gnu@0.33.0': - resolution: {integrity: sha512-QTAkfxQSsOGRza0hnkeAgJDQqR00iDerRNq42dOGIzgF+Kse491By3UmBEMG4oCbv17yYcBBlknQkzKSKtigjw==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - '@ast-grep/napi-linux-x64-gnu@0.36.2': resolution: {integrity: sha512-Xmb50HPfRNi+iLtHp+8/dqiTd8tjArYxOdj1tZzjRndpKhFpQDVrcOnPFObDCRgxVeLovdql9A1ad6BMcEL01Q==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@ast-grep/napi-linux-x64-musl@0.33.0': - resolution: {integrity: sha512-PW6bZO7MyQsBNZv0idI/Ah6ak66T8LqZ21wBGjtQp9NDGViOtkLeu+eJJGaZjMqUdidKHKgmMKXksZHl2m8ulQ==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - '@ast-grep/napi-linux-x64-musl@0.36.2': resolution: {integrity: sha512-RSnqCsl3OBfJWh2rETtv3o7xd4QnbB2YTh6H6oYfFhhX0tlon/V+bUXI77hU2/W73hj9GHqWZsygsF43NXn/Hw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@ast-grep/napi-win32-arm64-msvc@0.33.0': - resolution: {integrity: sha512-ijmFQcFc32JOIQlSfnhDJpb3qFb2RhrRqfeY0EHHN1xRSGwZHfsHTSS66nKR2sREmxTIMgxXOtylKicbyyMVKA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [win32] - '@ast-grep/napi-win32-arm64-msvc@0.36.2': resolution: {integrity: sha512-/Q85h8F9K2G8qig0lndZWb+ykCfhfpSN27F3i7Aw5C0Ph7S6vFH76xn3l3dJTZb2CwUSsv4JNoqmFmY4B8DExQ==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@ast-grep/napi-win32-ia32-msvc@0.33.0': - resolution: {integrity: sha512-NNIb2VK3Z2BwKp0QJSw8gkhwOUp85SgTsxJ38p+wIUAA/KzAKCJOmyOaZ301qGHt4gL+jTHgTIvJJX+9eT/REg==} - engines: {node: '>= 10'} - cpu: [ia32] - os: [win32] - '@ast-grep/napi-win32-ia32-msvc@0.36.2': resolution: {integrity: sha512-bDdwErB7zf9DvRx3kNZyMKJb9by5ra24WAXSiVzI8MR387ibZP9UCTzKuGqPrbuZADYWiOgsg3nXMklyPFtmhQ==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@ast-grep/napi-win32-x64-msvc@0.33.0': - resolution: {integrity: sha512-gW7viQQjdPA1HoCkpCqoonC81TOwcpP828w/XqZFE/L6uhD8SF2usul8KNBQOiX3O7/fqYEOnbtWMCrwZIqG1Q==} - engines: {node: '>= 10'} - cpu: [x64] - os: [win32] - '@ast-grep/napi-win32-x64-msvc@0.36.2': resolution: {integrity: sha512-LVZ2DqP9fRfyUceE0BGnlKoPmSx3dYYApSEUdt82Pn7jEVWpFFyTLFmZ9ILiCSaVc6urMJpKWdxAHFqDNNlGfg==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@ast-grep/napi@0.33.0': - resolution: {integrity: sha512-6heRMmomhSD0dkummRQ+R4xWXXmc41OaDPoPI49mKJXPyvwJPdPZUcQjXdIitOVL4uJV+qM2ZBucDPENDBSixw==} - engines: {node: '>= 10'} - '@ast-grep/napi@0.36.2': resolution: {integrity: sha512-ByenQQ0BtqqY0pvlmipvkDv/cKl/9vVjBydS7hloXOdmXPoUF0pHdlilC7ZfrRW97EzPQQZT2jgHl2tu7zg9QA==} engines: {node: '>= 10'} - '@ast-grep/nursery@0.0.2': - resolution: {integrity: sha512-Epb5KpdiXbHEOegPvEGejGI8UFtpK44Uz8lSb03mVbtBMB1VflMJ6/3wZz2CsZ65S0cdq5YQqt1Rm7E+S68oHQ==} - '@ast-grep/nursery@0.0.3': resolution: {integrity: sha512-fIOozkRrRHcDMv5t06SqUjQMkAwFgn1aiAtpXtOVpF19VE4oWK5MJOXbjI034cNGFDGGmCyMh7r0y2iWlTRRLw==} @@ -1295,72 +1234,33 @@ packages: snapshots: - '@ast-grep/napi-darwin-arm64@0.33.0': - optional: true - '@ast-grep/napi-darwin-arm64@0.36.2': optional: true - '@ast-grep/napi-darwin-x64@0.33.0': - optional: true - '@ast-grep/napi-darwin-x64@0.36.2': optional: true - '@ast-grep/napi-linux-arm64-gnu@0.33.0': - optional: true - '@ast-grep/napi-linux-arm64-gnu@0.36.2': optional: true - '@ast-grep/napi-linux-arm64-musl@0.33.0': - optional: true - '@ast-grep/napi-linux-arm64-musl@0.36.2': optional: true - '@ast-grep/napi-linux-x64-gnu@0.33.0': - optional: true - '@ast-grep/napi-linux-x64-gnu@0.36.2': optional: true - '@ast-grep/napi-linux-x64-musl@0.33.0': - optional: true - '@ast-grep/napi-linux-x64-musl@0.36.2': optional: true - '@ast-grep/napi-win32-arm64-msvc@0.33.0': - optional: true - '@ast-grep/napi-win32-arm64-msvc@0.36.2': optional: true - '@ast-grep/napi-win32-ia32-msvc@0.33.0': - optional: true - '@ast-grep/napi-win32-ia32-msvc@0.36.2': optional: true - '@ast-grep/napi-win32-x64-msvc@0.33.0': - optional: true - '@ast-grep/napi-win32-x64-msvc@0.36.2': optional: true - '@ast-grep/napi@0.33.0': - optionalDependencies: - '@ast-grep/napi-darwin-arm64': 0.33.0 - '@ast-grep/napi-darwin-x64': 0.33.0 - '@ast-grep/napi-linux-arm64-gnu': 0.33.0 - '@ast-grep/napi-linux-arm64-musl': 0.33.0 - '@ast-grep/napi-linux-x64-gnu': 0.33.0 - '@ast-grep/napi-linux-x64-musl': 0.33.0 - '@ast-grep/napi-win32-arm64-msvc': 0.33.0 - '@ast-grep/napi-win32-ia32-msvc': 0.33.0 - '@ast-grep/napi-win32-x64-msvc': 0.33.0 - '@ast-grep/napi@0.36.2': optionalDependencies: '@ast-grep/napi-darwin-arm64': 0.36.2 @@ -1373,10 +1273,6 @@ snapshots: '@ast-grep/napi-win32-ia32-msvc': 0.36.2 '@ast-grep/napi-win32-x64-msvc': 0.36.2 - '@ast-grep/nursery@0.0.2': - dependencies: - '@ast-grep/napi': 0.33.0 - '@ast-grep/nursery@0.0.3': dependencies: '@ast-grep/napi': 0.36.2 From cf2d90c671a8de144996ed5fae2b74818496c388 Mon Sep 17 00:00:00 2001 From: Nathan Gendron Date: Thu, 10 Apr 2025 14:27:20 -0400 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20TypeScript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/typescript/nursery.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/typescript/nursery.js b/packages/typescript/nursery.js index b6220b3..272679b 100644 --- a/packages/typescript/nursery.js +++ b/packages/typescript/nursery.js @@ -1,4 +1,5 @@ const { setup } = require('@ast-grep/nursery') +const assert = require('node:assert') const languageRegistration = require('./index') const path = require('node:path') @@ -9,6 +10,9 @@ setup({ src: path.join('typescript', 'src'), languageRegistration, testRunner: parse => { - // add test here + const sg = parse('let x: number = 123') + const root = sg.root() + const node = root.find('let $VAR: number = $VALUE') + assert.equal(node.kind(), 'lexical_declaration') }, }) From 83b790272ab0b828abfa5430ce87a05f7b85aa16 Mon Sep 17 00:00:00 2001 From: Nathan Gendron Date: Thu, 10 Apr 2025 14:28:57 -0400 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Add=20changeset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/warm-streets-type.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/warm-streets-type.md diff --git a/.changeset/warm-streets-type.md b/.changeset/warm-streets-type.md new file mode 100644 index 0000000..ac9b644 --- /dev/null +++ b/.changeset/warm-streets-type.md @@ -0,0 +1,5 @@ +--- +"@ast-grep/lang-typescript": patch +--- + +Add @ast-grep/lang-typescript