This script creates Abstract Syntax Tree (AST) of all JS/TS files in JSON format. The AST is created by using the bundled babel parser (for JavaScript, TypeScript). Type maps are generated using the Typescript compiler / type checker API.
| Language | Tool used | Notes |
|---|---|---|
| JavaScript | babel | types via tsc |
| TypeScript | babel | types via tsc |
| Vue | babel | |
| JSX | babel | |
| TSX | babel |
yarn install
yarn buildPlatform-specific binaries can now be build using pkg:
yarn binaryyarn install
yarn build
yarn testThis will use jest with ts-jest to run the tests in test/.
The regression harness compares AST and type-map output between two versions of astgen (base branch vs. PR) across two real-world TypeScript corpora: typeorm@0.3.21 and fastify@v5.3.3.
Run locally (compares current branch against main):
yarn regressionTo compare against a different base branch:
python3 scripts/regression-local.py --base-branch <branch>The script builds both versions, clones the corpora, runs astgen on each, and prints a Markdown report to stdout showing:
- AST and typemap file counts and total sizes
- Wall-clock execution time
- Per-file content diffs (collapsible, truncated to 200 lines)
CI: The regression workflow runs automatically on every pull request (.github/workflows/regression.yml) and posts or updates a comment on the PR with the full report.
./astgen -h
Options:
-v, --version Print version number [boolean]
-i, --src Source directory [default: "."]
-o, --output Output directory for generated AST json files
[default: "ast_out"]
-t, --type Project type. Default auto-detect
-r, --recurse Recurse mode suitable for mono-repos [boolean] [default: true]
-h Show help [boolean]Navigate to the project and run astgen command.
cd <path to project>
astgenTo specify the project type and the path to the project.
astgen -t js -i <path to project>
astgen -t vue -i <path containing .vue files>