Skip to content

Commit 6a31cb6

Browse files
committed
feat(deps,docs): upgrade to latest & update docs
1 parent e14bc36 commit 6a31cb6

File tree

6 files changed

+1676
-1646
lines changed

6 files changed

+1676
-1646
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
yarn lint-staged
4+
npx pretty-quick --staged

README.md

Lines changed: 110 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,128 @@
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>&nbsp;|&nbsp;</span>
16+
<a href="#install">Install</a>
17+
<span>&nbsp;|&nbsp;</span>
18+
<a href="#usage-in-command-line">Usage</a>
19+
<span>&nbsp;|&nbsp;</span>
20+
<a href="#options">Options</a>
21+
<span>&nbsp;|&nbsp;</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
3090
Options:
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+
![Screenshot](./assets/screenshot.png)
124+
125+
## Usage as a package
60126
61127
```typescript jsx
62128
import { parseDependencyTree, parseCircular, prettyCircular } from 'dpdm';
@@ -69,7 +135,7 @@ parseDependencyTree('./index', {
69135
});
70136
```
71137
72-
## API
138+
### API Reference
73139
74140
1. `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)

assets/screenshot.png

-11.9 KB
Loading

package.json

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dpdm",
3-
"version": "3.8.0",
3+
"version": "3.9.0",
44
"description": "Analyze circular dependencies in your JavaScript/TypeScript projects.",
55
"keywords": [
66
"circular",
@@ -50,32 +50,27 @@
5050
},
5151
"license": "MIT",
5252
"devDependencies": {
53-
"@types/jest": "^27.0.3",
53+
"@types/jest": "^27.4.1",
5454
"husky": "^7.0.4",
55-
"jest": "^27.4.5",
56-
"lint-staged": "^12.1.4",
55+
"jest": "^27.5.1",
5756
"npm-run-all": "^4.1.5",
58-
"prettier": "^2.5.1",
59-
"rollup": "^2.62.0",
60-
"ts-jest": "^27.1.2",
61-
"ts-node": "^10.4.0"
57+
"prettier": "^2.6.1",
58+
"pretty-quick": "^3.1.3",
59+
"rollup": "^2.70.1",
60+
"ts-jest": "^27.1.4",
61+
"ts-node": "^10.7.0"
6262
},
6363
"dependencies": {
6464
"@types/fs-extra": "^9.0.13",
6565
"@types/glob": "^7.2.0",
66-
"@types/yargs": "^17.0.8",
66+
"@types/yargs": "^17.0.10",
6767
"chalk": "^4.1.2",
68-
"fs-extra": "^10.0.0",
68+
"fs-extra": "^10.0.1",
6969
"glob": "^7.2.0",
7070
"ora": "^5.4.1",
7171
"tslib": "^2.3.1",
72-
"typescript": "^4.5.4",
73-
"yargs": "^17.3.1"
74-
},
75-
"lint-staged": {
76-
"*.{js,jsx,ts,tsx,json,css,less,scss,md}": [
77-
"prettier --write"
78-
]
72+
"typescript": "^4.6.3",
73+
"yargs": "^17.4.0"
7974
},
8075
"jest": {
8176
"moduleFileExtensions": [

src/utils.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ describe('util', () => {
1212
const local = await simpleResolver(__dirname, './bin/dpdm', ext);
1313
const index = await simpleResolver(__dirname, '.', ext);
1414
// dependents on yarn.lock
15-
const pkg = await simpleResolver(__dirname, 'expect', ext);
16-
const deepPkg = await simpleResolver(dirname(pkg!), 'ansi-styles', ext);
15+
const pkg = await simpleResolver(__dirname, 'string_decoder', ext);
16+
const deepPkg = await simpleResolver(dirname(pkg!), 'safe-buffer', ext);
1717
const notFound = await simpleResolver(__dirname, './utils.tsx', ext);
1818
expect([local, index, pkg, deepPkg, notFound]).toEqual([
1919
join(__dirname, 'bin/dpdm.ts'),
2020
join(__dirname, 'index.ts'),
21-
join(__dirname, '../node_modules/expect/build/index.js'),
21+
join(__dirname, '../node_modules/string_decoder/lib/string_decoder.js'),
2222
join(
2323
__dirname,
24-
'../node_modules/expect/node_modules/ansi-styles/index.js',
24+
'../node_modules/string_decoder/node_modules/safe-buffer/index.js',
2525
),
2626
null,
2727
]);

0 commit comments

Comments
 (0)