1- # dpdm
2-
3- A static dependencies analyzer for your ` JavaScript ` and ` TypeScript ` projects.
4-
5- ## Features
1+ <h1 align =" center " >
2+ DPDM
3+ <br/>
4+ <img src="https://img.shields.io/npm/v/dpdm" alt="version">
5+ <img src="https://img.shields.io/npm/dm/dpdm" alt="downloads">
6+ <img src="https://img.shields.io/github/stars/acrazing/dpdm" alt="stars">
7+ <img src="https://img.shields.io/librariesio/github/acrazing/dpdm" alt="dependencies">
8+ <img src="https://img.shields.io/github/license/acrazing/dpdm" alt="license">
9+ </h1 >
10+
11+ <p align =" center " >A robust static dependency analyzer for your <code >JavaScript</code > and <code >TypeScript</code > projects.</p >
12+
13+ <p align =" center " >
14+ <a href="#highlights">Highlights</a>
15+ <span> | </span>
16+ <a href="#install">Install</a>
17+ <span> | </span>
18+ <a href="#usage-in-command-line">Usage</a>
19+ <span> | </span>
20+ <a href="#options">Options</a>
21+ <span> | </span>
22+ <a href="#usage-as-a-package">API</a>
23+ </p >
24+
25+ ## Highlights
626
727- Supports ` CommonJS ` , ` ESM ` .
828- Supports ` JavaScript ` and ` TypeScript ` completely.
929 - Supports TypeScript [ path mapping] ( https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping ) .
10- - Supports ignore TypeScript type dependency
11- - Light weight: use [ typescript ] ( https://npmjs.com/package/typescript ) to parse all modules.
30+ - Supports ignore TypeScript type dependencies.
31+ - Light weight: use [ TypeScript ] ( https://npmjs.com/package/typescript ) to parse all modules.
1232- Fast: use asynchronous API to load modules.
13- - Stable output: This is compared to madge, whose results are completely inconclusive when analyze ` TypeScript ` .
33+ - Stable output: This is compared to ` madge ` , whose results are completely inconclusive when analyze ` TypeScript ` .
1434
1535## Install
1636
17- ``` bash
18- npm i dpdm # or yarn add dpdm
37+ 1 . For command line
1938
20- # use as command line
21- npm i -g dpdm # or yarn global add dpdm
22- dpdm --help
23- ```
39+ ``` bash
40+ npm i -g dpdm
41+ # or via yarn
42+ yarn global add dpdm
43+ ```
44+
45+ 2 . As a module
46+
47+ ``` bash
48+ npm i -D dpdm
49+ # or via yarn
50+ yarn add -D dpdm
51+ ```
52+
53+ ## Usage in command line
54+
55+ 1 . Simple usage
56+
57+ ``` bash
58+ dpdm ./src/index.ts
59+ ```
60+
61+ 2 . Print circular dependencies only
2462
25- ## Usage in line
63+ ``` bash
64+ dpdm --no-warning --no-tree ./src/index.ts
65+ ```
66+
67+ 3 . Exit with a non-zero code if a circular dependency is found.
68+
69+ ``` bash
70+ dpdm --exit-code circular:1 ./src/index.ts
71+ ```
72+
73+ 4 . Ignore type dependencies for TypeScript modules
74+
75+ ``` bash
76+ dpdm -T ./src/index.ts
77+ ```
78+
79+ ### Options
2680
2781``` bash
28- dpdm.ts [options] files...
82+ $ dpdm --help
83+ dpdm [options] < files...>
84+
85+ Analyze the files' dependencies.
86+
87+ Positionals:
88+ files The file paths or globs [string]
2989
3090Options:
31- --version Show version number [boolean]
32- --context the context directory to shorten path, default is current directory [string]
33- --extensions, --ext comma separated extensions to resolve
34- [string] [default: " .ts,.tsx,.mjs,.js,.jsx,.json" ]
35- --js comma separated extensions indicate the file is js like
36- [string] [default: " .ts,.tsx,.mjs,.js,.jsx" ]
37- --include included filenames regexp in string, default includes all files
38- [string] [default: " .*" ]
39- --exclude excluded filenames regexp in string, set as empty string to include all files
40- [string] [default: " \/node_modules\/" ]
41- --output, -o output json to file [string]
42- --tree print tree to stdout [boolean] [default: true]
43- --circular print circular to stdout [boolean] [default: true]
44- --warning print warning to stdout [boolean] [default: true]
45- --tsconfig the tsconfig path, which is used for resolve path alias, default is
46- tsconfig.json if it exists in context directory [string]
47- --transform, -T transform typescript modules to javascript before analyze, it allows you to
48- omit types dependency in typescript [boolean] [default: false]
49- --exit-code exit with specified code, the value format is CASE:CODE, ` circular` is the
50- only supported CASE, CODE should be a integer between 0 and 128. For example:
51- ` dpdm --exit-code circular:1` the program will exit with code 1 if circular
52- dependency found. [string]
53- -h, --help Show help [boolean]
91+ --version Show version number [boolean]
92+ --context the context directory to shorten path, default is current
93+ directory [string]
94+ --extensions, --ext comma separated extensions to resolve
95+ [string] [default: ".ts,.tsx,.mjs,.js,.jsx,.json"]
96+ --js comma separated extensions indicate the file is js like
97+ [string] [default: ".ts,.tsx,.mjs,.js,.jsx"]
98+ --include included filenames regexp in string, default includes all files
99+ [string] [default: ".*"]
100+ --exclude excluded filenames regexp in string, set as empty string to
101+ include all files [string] [default: "node_modules"]
102+ -o, --output output json to file [string]
103+ --tree print tree to stdout [boolean] [default: true]
104+ --circular print circular to stdout [boolean] [default: true]
105+ --warning print warning to stdout [boolean] [default: true]
106+ --tsconfig the tsconfig path, which is used for resolve path alias,
107+ default is tsconfig.json if it exists in context directory
108+ [string]
109+ -T, --transform transform typescript modules to javascript before analyze, it
110+ allows you to omit types dependency in typescript
111+ [boolean] [default: false]
112+ --exit-code exit with specified code, the value format is CASE:CODE,
113+ `circular` is the only supported CASE, CODE should be a integer
114+ between 0 and 128. For example: `dpdm --exit-code circular:1`
115+ the program will exit with code 1 if circular dependency found.
116+ [string]
117+ --progress show progress bar [boolean] [default: true]
118+ -h, --help Show help [boolean]
54119```
55120
56- > The result example:
57- > ! [](./assets/screenshot.png)
121+ ### Example output
58122
59- # # Usage in module
123+ 
124+
125+ ## Usage as a package
60126
61127```typescript jsx
62128import { parseDependencyTree, parseCircular, prettyCircular } from ' dpdm' ;
@@ -69,7 +135,7 @@ parseDependencyTree('./index', {
69135});
70136```
71137
72- # # API
138+ ### API Reference
73139
741401. `parseDependencyTree(entries, option, output)`: parse dependencies for glob entries
75141
@@ -118,12 +184,8 @@ parseDependencyTree('./index', {
118184 export declare function parseCircular(tree: DependencyTree): string[][];
119185 ```
120186
121- # # TODO
187+ ## TODOs
122188
123189- [ ] Supports HTML and HTML like modules
124190- [ ] Supports CSS and CSS like modules
125191- [ ] Prints interactive SVG
126-
127- # # LICENSE
128-
129- [MIT](./LICENSE)
0 commit comments