Skip to content

Commit

Permalink
fix(cli): --depth description
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day committed Nov 18, 2023
1 parent 0450410 commit c3f480c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 8 deletions.
49 changes: 42 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ A super fast tool that uses [swc](https://swc.rs/) to build JavaScript/TypeScrip
## Features

- :zap: Blazing fast ESM/CJS modules scanner [WIP]
- :rainbow: Interactive module relation graph view [WIP]
- :rainbow: Interactive module relation [graph view](https://rust-redo.github.io/import-analysis/axios.html) [WIP]
- :hammer_and_pick: Strict `import` diagnosis based on [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import) rules [todo]
- :herb: Rich plugins support (vite, rollup, webpack) [todo]

## Module Graph Demo

[axios](https://rust-redo.github.io/import-analysis/axios.html)

## Install

```shell
Expand All @@ -27,6 +23,45 @@ $ npm i -g import-analysis

<!-- `import-analysis` is not only a cli tool, you can also use it as a JavaScript API or a specific bundler plugin. -->

```shell
Usage: import-analysis [options]

CLI to some JavaScript string utilities

Options:
-V, --version output the version number
-t, --target <file> target file's relative or absolute path
-r, --root <directory> target codebase root directory (default: "./")
-d, --depth <number> import relation tree's depth (default: "2")
-o, --output <file> parsing result's file path (default: "./import.json")
-h, --help display help for command
```
### parse target file with custom import-tree depth
```shell
$ it -t ./src/index.js -d 3
```
### parse target file in specific root directory
```shell
$ it -t ./src/index.js -r ../root
```
### parse target files of glob pattern
```shell
$ it -t ./**/index.js -r ../root
```
### parse target file and output graph html or json file
```shell
$ it -t ./src/index.js -o ./graph.html
$ it -t ./src/index.js -o ./import.json
```
## Benchmark
`import-analysis` tested its Nodejs api's benchmark in multiple popular third-party git repos.
Expand Down Expand Up @@ -55,14 +90,14 @@ Binaries:
### v0.1.x [WIP]

- `rust parser`
- construct import tree with specific depth
- construct import tree with specific depth :heavy_check_mark:
- parse esm static `import/export` syntax
- resolve internal/external module path
- compute circular dependencies
- handle exception robustly
- `npm core`
- cross-platform fast Nodejs api
- parse target files in glob pattern :heavy_check_mark:
- parse target files of glob pattern :heavy_check_mark:
- `npm cli`
- output import tree in json & html format :heavy_check_mark:
- check circular dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program
program
.requiredOption('-t, --target <file>', 'target file\'s relative or absolute path')
.option('-r, --root <directory>', 'target codebase root directory', './')
.option('-d, --depth <number>', 'separator character', '2')
.option('-d, --depth <number>', 'import relation tree\'s depth', '2')
.option('-o, --output <file>', 'parsing result\'s file path', './import.json')
.action((options) => {
const { root, depth, output, target } = options
Expand Down

0 comments on commit c3f480c

Please sign in to comment.