Skip to content

Commit 594a7e8

Browse files
authored
Merge pull request wtlin1228#2 from wtlin1228/feature/database-support
add database support
2 parents 99d2cf5 + f83c981 commit 594a7e8

File tree

22 files changed

+1674
-203
lines changed

22 files changed

+1674
-203
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
22
/outputs
3+
/database

Cargo.lock

Lines changed: 71 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"crates/cli",
55
"crates/demo",
66
"crates/dt_core",
7+
"crates/dt_database",
78
"crates/dt_graph",
89
"crates/dt_i18n",
910
"crates/dt_parser",
@@ -23,3 +24,5 @@ serde_json = "1.0"
2324
swc_core = { version = "0.104.2", features = ["common", "ecma_ast", "ecma_visit", "ecma_plugin_transform"] }
2425
swc_ecma_parser = { version = "0.150.0", features = ["typescript"] }
2526
clap = { version = "4.5", features = ["derive"] }
27+
rusqlite = { version = "0.32.1", features = ["bundled"] }
28+
indicatif = "0.17.8"

README.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ flowchart TD
7979

8080
reexport all the library crates:
8181

82+
- database
8283
- graph
8384
- i18n
8485
- parser
@@ -88,6 +89,12 @@ reexport all the library crates:
8889
- scheduler
8990
- tracker
9091

92+
### Database
93+
94+
`Database` defines the models using in the `cli` and `api_server` crate.
95+
96+
![ERD](./assets/erd.jpeg)
97+
9198
### Graph
9299

93100
`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.
@@ -203,11 +210,58 @@ let paths = dt.trace("<module_path>", TraceTarget::LocalVar("variable_name")).un
203210

204211
### Demo
205212

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

208-
### Portable
215+
```
216+
Track fine-grained symbol dependency graph
217+
218+
Usage: demo -s <SRC> -d <DST>
219+
220+
Options:
221+
-s <SRC> Path of project to trace
222+
-d <DST> Path of the output folder
223+
-h, --help Print help
224+
-V, --version Print version
225+
```
226+
227+
### CLI
228+
229+
See the `cli` crate.
230+
231+
```
232+
Parse a project and serialize its output
209233
210-
See the `cli` crate. You can run `cargo run --bin cli -- -i <INPUT> -o <OUTPUT>`.
234+
Usage: cli <COMMAND>
235+
236+
Commands:
237+
portable Parse and export the project in portable format
238+
database Parse and export the project in database format
239+
help Print this message or the help of the given subcommand(s)
240+
241+
Options:
242+
-h, --help Print help
243+
-V, --version Print version
244+
```
245+
246+
Usage:
247+
248+
- `cli portable -i <INPUT> -t <TRANSLATION_PATH> -o <OUTPUT>`
249+
- `cli database -i <INPUT> -t <TRANSLATION_PATH> -o <OUTPUT>`
250+
251+
### API Server
252+
253+
see the `api_server` crate. The database is the one generated by CLI with `database` command.
254+
255+
```
256+
Start the server to provide search API
257+
258+
Usage: api_server --db <DB>
259+
260+
Options:
261+
--db <DB> The path of your database
262+
-h, --help Print help
263+
-V, --version Print version
264+
```
211265

212266
## Client
213267

assets/erd.jpeg

48 KB
Loading

0 commit comments

Comments
 (0)