Skip to content

Commit

Permalink
Merge pull request #2 from wtlin1228/feature/database-support
Browse files Browse the repository at this point in the history
add database support
  • Loading branch information
wtlin1228 authored Oct 11, 2024
2 parents 99d2cf5 + f83c981 commit 594a7e8
Show file tree
Hide file tree
Showing 22 changed files with 1,674 additions and 203 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
/outputs
/database
79 changes: 71 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/cli",
"crates/demo",
"crates/dt_core",
"crates/dt_database",
"crates/dt_graph",
"crates/dt_i18n",
"crates/dt_parser",
Expand All @@ -23,3 +24,5 @@ serde_json = "1.0"
swc_core = { version = "0.104.2", features = ["common", "ecma_ast", "ecma_visit", "ecma_plugin_transform"] }
swc_ecma_parser = { version = "0.150.0", features = ["typescript"] }
clap = { version = "4.5", features = ["derive"] }
rusqlite = { version = "0.32.1", features = ["bundled"] }
indicatif = "0.17.8"
60 changes: 57 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ flowchart TD

reexport all the library crates:

- database
- graph
- i18n
- parser
Expand All @@ -88,6 +89,12 @@ reexport all the library crates:
- scheduler
- tracker

### Database

`Database` defines the models using in the `cli` and `api_server` crate.

![ERD](./assets/erd.jpeg)

### Graph

`DependOnGraph` takes the `SymbolDependency` one by one to construct a DAG. You have to add the `SymbolDependency` by topological order so that `DependOnGraph` can handle the wildcard import and export for you.
Expand Down Expand Up @@ -203,11 +210,58 @@ let paths = dt.trace("<module_path>", TraceTarget::LocalVar("variable_name")).un

### Demo

See the `demo` crate. You can run `cargo run --bin demo -- -s ./test-project/everybodyyyy -d ~/tmp`.
See the `demo` crate.

### Portable
```
Track fine-grained symbol dependency graph
Usage: demo -s <SRC> -d <DST>
Options:
-s <SRC> Path of project to trace
-d <DST> Path of the output folder
-h, --help Print help
-V, --version Print version
```

### CLI

See the `cli` crate.

```
Parse a project and serialize its output
See the `cli` crate. You can run `cargo run --bin cli -- -i <INPUT> -o <OUTPUT>`.
Usage: cli <COMMAND>
Commands:
portable Parse and export the project in portable format
database Parse and export the project in database format
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
```

Usage:

- `cli portable -i <INPUT> -t <TRANSLATION_PATH> -o <OUTPUT>`
- `cli database -i <INPUT> -t <TRANSLATION_PATH> -o <OUTPUT>`

### API Server

see the `api_server` crate. The database is the one generated by CLI with `database` command.

```
Start the server to provide search API
Usage: api_server --db <DB>
Options:
--db <DB> The path of your database
-h, --help Print help
-V, --version Print version
```

## Client

Expand Down
Binary file added assets/erd.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 594a7e8

Please sign in to comment.