Home

Awesome

ENRE-ts

npm version

ENtity Relationship Extractor for ECMAScript and TypeScript based on @babel/parser.

By doing static code analysis, ENRE-ts extracts entities and relations between them (aka code dependencies), to help developers have a better and clearer view of understanding on code repos they are dealing with.

Features

Supported Language

LanguageMaximum Version
ECMAScript2023
TypeScript5.0
JSX-
HTML/CSSNot Supported

Getting Started

Pre-request

DependencyVersionNote
Node.js16~18Does not support 19+

npm packages

Source code usage

$ git clone https://github.com/xjtu-enre/ENRE-ts.git --depth=1
$ cd ENRE-ts
$ npm install & npm run build
$ node --experimental-specifier-resolution=node packages/enre-cli/lib/index.js <...options>

Single bundled file

From assets of the latest release, download the file named with enre-ts-x.x.x.js, then run it with the following command:

$ node enre-ts-x.x.x.js

Usage

Append -h or --help without any other arguments to see list of options:

Usage: enre-ts [options]

A static source code entity relationship extractor for ECMAScript and TypeScript.

Options:
  -V, --version                   output the version number
  -i, --input <path>              specify the path to a file or directory (default: ".")
  -o, --output <file path>/false  specify where to output the Analyze results
                                  use extension '.json' (default) or '.lsif' to specify format (default: "./output.json")
  -e, --exclude <name...>         specify file or directory name to be excluded from analysis
  -v, --verbose                   enable to print more message while processing (default: false)
  -h, --help                      display help for command

Examples

$ node enre-ts.js -i path/to/directory
$ node enre-ts.js -i path/to/file.js -o path/to/output/result.json
<!-- * Analyze files under a directory and output in [LSIF](https://microsoft.github.io/language-server-protocol/) format ```shell $ node enre-ts.js -i path/to/directory -o path/to/output/result.lsif ``` -->
$ node enre-ts.js -i path/to/directory -v

Documentation

Specifications on which kinds of entities and relations can be captured and any other details can be found in docs.

Building

After cloning this repository, run npm install to install all dependencies.

References

  1. https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md