rev-dep 1.0.0-alpha.6 β 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -48
- package/bin.js +1 -1
- package/dist/babel/index.d.ts +1 -0
- package/dist/cli/commonOptions.d.ts +23 -0
- package/dist/cli/createCommands.d.ts +2 -0
- package/dist/cli/docs/generate.d.ts +20 -0
- package/dist/cli/docs/index.d.ts +3 -0
- package/dist/cli/docs/template.d.ts +3 -0
- package/dist/cli/entryPoints/index.d.ts +2 -0
- package/dist/cli/entryPoints/types.d.ts +4 -0
- package/dist/cli/files/index.d.ts +2 -0
- package/dist/cli/files/types.d.ts +3 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/resolve/formatResults.d.ts +9 -0
- package/dist/cli/resolve/index.d.ts +2 -0
- package/dist/cli/resolve/types.d.ts +9 -0
- package/dist/lib/buildDepsGraph.d.ts +2 -0
- package/dist/lib/cleanupDpdmDeps.d.ts +3 -0
- package/dist/lib/getDepsSetWebpack.d.ts +6 -0
- package/dist/lib/getDepsTree.d.ts +1 -0
- package/dist/lib/getEntryPoints.d.ts +9 -0
- package/dist/lib/getMaxDepthInGraph.d.ts +4 -0
- package/dist/lib/resolve.d.ts +11 -0
- package/dist/lib/types.d.ts +10 -0
- package/dist/lib/utils.d.ts +6 -0
- package/dist/module.d.ts +2 -0
- package/package.json +3 -2
- package/dist/lib/find.js +0 -46
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<h3 align="center">
|
|
2
|
-
<code>rev
|
|
2
|
+
<code>rev-dep</code>
|
|
3
3
|
</h3>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
<img alt="rev-dep version" src="https://img.shields.io/npm/v/rev-dep"> <img alt="rev-dep license" src="https://img.shields.io/npm/l/rev-dep"> <img alt="rev-dep PRs welcome" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square">
|
|
12
12
|
|
|
13
|
-
## About
|
|
13
|
+
## About π£
|
|
14
14
|
|
|
15
15
|
The tool was created help with daily dev struggles by answering these questions:
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
π What entry points my codebase have
|
|
18
|
+
|
|
19
|
+
π Which entry points uses a given file
|
|
20
|
+
|
|
21
|
+
π Which dependencies a given file has
|
|
20
22
|
|
|
21
23
|
This helps to debug project dependencies, plan refactoring, optimize bundles or plan code splitting.
|
|
22
24
|
|
|
@@ -24,14 +26,13 @@ It's especially useful in JS world without TypeScript or tests coverage.
|
|
|
24
26
|
|
|
25
27
|
It also helps to identify and eliminate dead files, understand the complexity of the file dependencies
|
|
26
28
|
|
|
27
|
-
[Jump to CLI reference](#cli-reference)
|
|
29
|
+
[π¦ Jump to CLI reference](#cli-reference)
|
|
28
30
|
|
|
29
|
-
[`export * from` problem](#export-from-problem)
|
|
31
|
+
[πΈοΈ `export * from` problem](#export-from-problem)
|
|
30
32
|
|
|
31
|
-
### Use cases
|
|
33
|
+
### Use cases π§βπ»
|
|
32
34
|
|
|
33
35
|
- [You plan to refactor some file and you wonder which entry points are affected](#how-to-identify-where-a-file-is-used-in-the-project)
|
|
34
|
-
|
|
35
36
|
- [You are wondering wether a given source file is used](#how-to-check-if-a-file-is-used-in-the-project)
|
|
36
37
|
- [You wonder if there are any dead files in your project](#how-to-identify-dead-files-in-the-project)
|
|
37
38
|
- [You want to verify if a given entry point imports only the required files](#how-to-check-which-files-are-imported-by-a-given-file)
|
|
@@ -45,7 +46,7 @@ While graphs can be useful to identify major problems like too big bundle size o
|
|
|
45
46
|
|
|
46
47
|
`rev-dep` visualize dependencies as lists, so it's really easy to see where to cut the line to solve the problem.
|
|
47
48
|
|
|
48
|
-
## Getting Started
|
|
49
|
+
## Getting Started π
|
|
49
50
|
|
|
50
51
|
### Install globally to use as CLI tool
|
|
51
52
|
|
|
@@ -63,7 +64,7 @@ or
|
|
|
63
64
|
|
|
64
65
|
`npm install rev-dep`
|
|
65
66
|
|
|
66
|
-
## Recipes
|
|
67
|
+
## Recipes πΆοΈ
|
|
67
68
|
|
|
68
69
|
### How to identify where a file is used in the project?
|
|
69
70
|
|
|
@@ -72,23 +73,24 @@ Just use `rev-dep resolve path/to/file.ts`
|
|
|
72
73
|
You will see all the entry points that implicitly require given file together with resolution path.
|
|
73
74
|
|
|
74
75
|
[`resolve` Command CLI reference](#command-resolve)
|
|
76
|
+
|
|
75
77
|
<details>
|
|
76
78
|
<summary>Example for the rev-dep repository</summary>
|
|
77
79
|
|
|
78
|
-
command:
|
|
80
|
+
command:
|
|
79
81
|
|
|
80
82
|
`rev-dep resolve src/lib/utils.ts`
|
|
81
83
|
|
|
82
84
|
output:
|
|
83
85
|
|
|
84
86
|
```s
|
|
85
|
-
src/babel/index.js :
|
|
87
|
+
src/babel/index.js :
|
|
86
88
|
|
|
87
89
|
β src/babel/index.js
|
|
88
|
-
β src/lib/utils.ts
|
|
90
|
+
β src/lib/utils.ts
|
|
89
91
|
_____________________
|
|
90
92
|
|
|
91
|
-
src/cli/index.ts :
|
|
93
|
+
src/cli/index.ts :
|
|
92
94
|
|
|
93
95
|
β src/cli/index.ts
|
|
94
96
|
β src/cli/createCommands.ts
|
|
@@ -96,10 +98,11 @@ src/cli/index.ts :
|
|
|
96
98
|
β src/lib/find.ts
|
|
97
99
|
β src/lib/getDepsTree.ts
|
|
98
100
|
β src/lib/getDepsSetWebpack.ts
|
|
99
|
-
β src/lib/utils.ts
|
|
101
|
+
β src/lib/utils.ts
|
|
100
102
|
_____________________
|
|
101
103
|
|
|
102
104
|
```
|
|
105
|
+
|
|
103
106
|
</details>
|
|
104
107
|
|
|
105
108
|
#### Getting more details about file resolution in given entry point
|
|
@@ -111,14 +114,14 @@ To find out all paths combination use `rev-dep resolve` with `-a` flag
|
|
|
111
114
|
<details>
|
|
112
115
|
<summary>Example for the rev-dep repository</summary>
|
|
113
116
|
|
|
114
|
-
command:
|
|
117
|
+
command:
|
|
115
118
|
|
|
116
119
|
`rev-dep resolve src/lib/utils.ts src/cli/index.ts --all`
|
|
117
120
|
|
|
118
121
|
output:
|
|
119
122
|
|
|
120
123
|
```s
|
|
121
|
-
src/cli/index.ts :
|
|
124
|
+
src/cli/index.ts :
|
|
122
125
|
|
|
123
126
|
β src/cli/index.ts
|
|
124
127
|
β src/cli/createCommands.ts
|
|
@@ -126,7 +129,7 @@ src/cli/index.ts :
|
|
|
126
129
|
β src/lib/find.ts
|
|
127
130
|
β src/lib/getDepsTree.ts
|
|
128
131
|
β src/lib/getDepsSetWebpack.ts
|
|
129
|
-
β src/lib/utils.ts
|
|
132
|
+
β src/lib/utils.ts
|
|
130
133
|
|
|
131
134
|
β src/cli/index.ts
|
|
132
135
|
β src/cli/createCommands.ts
|
|
@@ -135,7 +138,7 @@ src/cli/index.ts :
|
|
|
135
138
|
β src/lib/getEntryPoints.ts
|
|
136
139
|
β src/lib/getDepsTree.ts
|
|
137
140
|
β src/lib/getDepsSetWebpack.ts
|
|
138
|
-
β src/lib/utils.ts
|
|
141
|
+
β src/lib/utils.ts
|
|
139
142
|
|
|
140
143
|
β src/cli/index.ts
|
|
141
144
|
β src/cli/createCommands.ts
|
|
@@ -143,55 +146,56 @@ src/cli/index.ts :
|
|
|
143
146
|
β src/lib/getEntryPoints.ts
|
|
144
147
|
β src/lib/getDepsTree.ts
|
|
145
148
|
β src/lib/getDepsSetWebpack.ts
|
|
146
|
-
β src/lib/utils.ts
|
|
149
|
+
β src/lib/utils.ts
|
|
147
150
|
|
|
148
151
|
β src/cli/index.ts
|
|
149
152
|
β src/cli/createCommands.ts
|
|
150
153
|
β src/cli/files/index.ts
|
|
151
154
|
β src/lib/getDepsTree.ts
|
|
152
155
|
β src/lib/getDepsSetWebpack.ts
|
|
153
|
-
β src/lib/utils.ts
|
|
156
|
+
β src/lib/utils.ts
|
|
154
157
|
|
|
155
158
|
β src/cli/index.ts
|
|
156
159
|
β src/cli/createCommands.ts
|
|
157
160
|
β src/cli/resolve/index.ts
|
|
158
161
|
β src/lib/find.ts
|
|
159
162
|
β src/lib/getEntryPoints.ts
|
|
160
|
-
β src/lib/utils.ts
|
|
163
|
+
β src/lib/utils.ts
|
|
161
164
|
|
|
162
165
|
β src/cli/index.ts
|
|
163
166
|
β src/cli/createCommands.ts
|
|
164
167
|
β src/cli/entryPoints/index.ts
|
|
165
168
|
β src/lib/getEntryPoints.ts
|
|
166
|
-
β src/lib/utils.ts
|
|
169
|
+
β src/lib/utils.ts
|
|
167
170
|
|
|
168
171
|
β src/cli/index.ts
|
|
169
172
|
β src/cli/createCommands.ts
|
|
170
173
|
β src/cli/resolve/index.ts
|
|
171
174
|
β src/lib/find.ts
|
|
172
|
-
β src/lib/utils.ts
|
|
175
|
+
β src/lib/utils.ts
|
|
173
176
|
|
|
174
177
|
β src/cli/index.ts
|
|
175
178
|
β src/cli/createCommands.ts
|
|
176
179
|
β src/cli/resolve/index.ts
|
|
177
|
-
β src/lib/utils.ts
|
|
180
|
+
β src/lib/utils.ts
|
|
178
181
|
|
|
179
182
|
β src/cli/index.ts
|
|
180
183
|
β src/cli/createCommands.ts
|
|
181
184
|
β src/cli/entryPoints/index.ts
|
|
182
|
-
β src/lib/utils.ts
|
|
185
|
+
β src/lib/utils.ts
|
|
183
186
|
|
|
184
187
|
β src/cli/index.ts
|
|
185
188
|
β src/cli/createCommands.ts
|
|
186
189
|
β src/cli/files/index.ts
|
|
187
|
-
β src/lib/utils.ts
|
|
190
|
+
β src/lib/utils.ts
|
|
188
191
|
|
|
189
192
|
```
|
|
193
|
+
|
|
190
194
|
</details>
|
|
191
195
|
|
|
192
196
|
### How to check if a file is used in the project?
|
|
193
197
|
|
|
194
|
-
Use `rev-dep resolve path/to/file.ts --compactSummary`
|
|
198
|
+
Use `rev-dep resolve path/to/file.ts --compactSummary`
|
|
195
199
|
|
|
196
200
|
As a result you will see total amount of entry points requiring a given file.
|
|
197
201
|
|
|
@@ -202,7 +206,7 @@ As a result you will see total amount of entry points requiring a given file.
|
|
|
202
206
|
<details>
|
|
203
207
|
<summary>Example for the rev-dep repository</summary>
|
|
204
208
|
|
|
205
|
-
command:
|
|
209
|
+
command:
|
|
206
210
|
|
|
207
211
|
`rev-dep resolve src/lib/utils.ts --compactSummary`
|
|
208
212
|
|
|
@@ -222,6 +226,7 @@ types.d.ts : 0
|
|
|
222
226
|
|
|
223
227
|
Total: 2
|
|
224
228
|
```
|
|
229
|
+
|
|
225
230
|
</details>
|
|
226
231
|
|
|
227
232
|
### How to identify dead files in the project?
|
|
@@ -237,7 +242,7 @@ Review the list and look for suspicious files like `src/ui/components/SomeCompon
|
|
|
237
242
|
<details>
|
|
238
243
|
<summary>Example for the rev-dep repository</summary>
|
|
239
244
|
|
|
240
|
-
command:
|
|
245
|
+
command:
|
|
241
246
|
|
|
242
247
|
`rev-dep entry-points --exclude '__tests__/**' 'types.d.ts'`
|
|
243
248
|
|
|
@@ -253,14 +258,15 @@ src/lib/getMaxDepthInGraph.ts
|
|
|
253
258
|
|
|
254
259
|
```
|
|
255
260
|
|
|
256
|
-
The last one `src/lib/getMaxDepthInGraph.ts` is the source file that is not used at the moment.
|
|
261
|
+
The last one `src/lib/getMaxDepthInGraph.ts` is the source file that is not used at the moment.
|
|
257
262
|
|
|
258
263
|
The rest of them looks legit!
|
|
264
|
+
|
|
259
265
|
</details>
|
|
260
266
|
|
|
261
267
|
### How to check which files are imported by a given file?
|
|
262
268
|
|
|
263
|
-
To get a full list of files imported by given entry point use `rev-dep files path/to/file.ts`.
|
|
269
|
+
To get a full list of files imported by given entry point use `rev-dep files path/to/file.ts`.
|
|
264
270
|
|
|
265
271
|
You can use `--count` flag if you are interested in the amount.
|
|
266
272
|
|
|
@@ -271,7 +277,7 @@ This is a good indicator of how heavy a given entry point or component is
|
|
|
271
277
|
<details>
|
|
272
278
|
<summary>Example for the rev-dep repository</summary>
|
|
273
279
|
|
|
274
|
-
command:
|
|
280
|
+
command:
|
|
275
281
|
|
|
276
282
|
`rev-dep files files src/cli/index.ts`
|
|
277
283
|
|
|
@@ -304,23 +310,25 @@ src/lib/cleanupDpdmDeps.ts
|
|
|
304
310
|
```
|
|
305
311
|
|
|
306
312
|
As you can see cli even import `package.json`. This is to print version of the cli
|
|
307
|
-
</details>
|
|
308
313
|
|
|
314
|
+
</details>
|
|
309
315
|
|
|
310
316
|
### How to reduce amount of files imported by entry point?
|
|
311
317
|
|
|
312
|
-
There is no easy how to for this process, but you can do it iteratively using
|
|
313
|
-
|
|
314
|
-
-
|
|
318
|
+
There is no easy how to for this process, but you can do it iteratively using `rev-dep` commands `files` and `resolve`
|
|
319
|
+
|
|
320
|
+
1. Get the list of files imported by entry-point
|
|
321
|
+
|
|
322
|
+
`rev-dep files path/to/entry-point`
|
|
315
323
|
|
|
316
|
-
1. Get the list of files imported by entry-point
|
|
317
|
-
- `rev-dep files path/to/entry-point`
|
|
318
324
|
2. Identify some suspicious files on the list, components that should not be used on the given page or not related utility files
|
|
319
325
|
3. Get all resolution paths for a suspicious file
|
|
320
|
-
|
|
326
|
+
|
|
327
|
+
`rev-dep resolve path/to/suspicious-file path/to/entry-point --all`
|
|
328
|
+
|
|
321
329
|
4. You would usually find out that there is some file, like directory `index` file that given entry point is using, which is mandatory, but as a side effect it imports a few files that are redundant for your entry point. In most cases you should be able to decouple the imports or reverse the dependency to cut off the resolution path for the unwanted file
|
|
322
330
|
|
|
323
|
-
## Usage
|
|
331
|
+
## Usage π¨
|
|
324
332
|
|
|
325
333
|
Project can be used as a CLI tool or as a module
|
|
326
334
|
|
|
@@ -335,7 +343,7 @@ For CLI usage see [CLI reference](#cli-reference)
|
|
|
335
343
|
```ts
|
|
336
344
|
import { resolve } from "rev-dep";
|
|
337
345
|
|
|
338
|
-
const paths = resolve({
|
|
346
|
+
const [paths] = await resolve({
|
|
339
347
|
entryPoints: ["index.js"],
|
|
340
348
|
filePath: "utils.js",
|
|
341
349
|
});
|
|
@@ -348,14 +356,14 @@ console.log(paths);
|
|
|
348
356
|
```ts
|
|
349
357
|
import { getEntryPoints } from "rev-dep";
|
|
350
358
|
|
|
351
|
-
const entryPoints = getEntryPoints({
|
|
359
|
+
const [entryPoints] = await getEntryPoints({
|
|
352
360
|
cwd: process.cwd(),
|
|
353
361
|
});
|
|
354
362
|
|
|
355
363
|
console.log(entryPoints);
|
|
356
364
|
```
|
|
357
365
|
|
|
358
|
-
## CLI reference
|
|
366
|
+
## CLI reference π
|
|
359
367
|
|
|
360
368
|
<!-- cli-docs-start -->
|
|
361
369
|
|
|
@@ -447,9 +455,7 @@ rev-dep docs <outputPath> [options]
|
|
|
447
455
|
```js
|
|
448
456
|
// babel.config.js
|
|
449
457
|
module.exports = {
|
|
450
|
-
plugins: [
|
|
451
|
-
'rev-dep/babel'
|
|
452
|
-
]
|
|
458
|
+
plugins: ["rev-dep/babel"],
|
|
453
459
|
};
|
|
454
460
|
```
|
|
455
461
|
|
package/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('./dist/cli')
|
|
2
|
+
require('./dist/cli')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare type OptionMeta2 = [string, string];
|
|
2
|
+
declare type OptionMeta3 = [string, string, string];
|
|
3
|
+
export declare const webpackConfigOption: OptionMeta2;
|
|
4
|
+
export declare type WebpackConfigOptionType = {
|
|
5
|
+
webpackConfig?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const cwdOption: OptionMeta3;
|
|
8
|
+
export declare type CwdOptionType = {
|
|
9
|
+
cwd: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const reexportRewireOption: OptionMeta2;
|
|
12
|
+
export declare type ReexportRewireOptionType = {
|
|
13
|
+
reexportRewire?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const includeOption: OptionMeta2;
|
|
16
|
+
export declare type IncludeOptionType = {
|
|
17
|
+
include?: string[];
|
|
18
|
+
};
|
|
19
|
+
export declare const excludeOption: OptionMeta2;
|
|
20
|
+
export declare type ExcludeOptionType = {
|
|
21
|
+
exclude?: string[];
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare type Command = {
|
|
2
|
+
name: string;
|
|
3
|
+
arguments: {
|
|
4
|
+
nameRaw: string;
|
|
5
|
+
name: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
description?: string;
|
|
8
|
+
}[];
|
|
9
|
+
description?: string;
|
|
10
|
+
options: {
|
|
11
|
+
shortName: string;
|
|
12
|
+
longName?: string;
|
|
13
|
+
argument?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
defaultValue?: string;
|
|
16
|
+
required: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
declare function generate(output: string, initialHeaderLevel: number): void;
|
|
20
|
+
export default generate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InputParams } from './types';
|
|
2
|
+
declare type Results = Array<Array<Array<string>>>;
|
|
3
|
+
export declare function formatResults({ results, filePath, entryPoints, compactSummary }: {
|
|
4
|
+
results: Results;
|
|
5
|
+
compactSummary: InputParams['compactSummary'];
|
|
6
|
+
entryPoints: string[];
|
|
7
|
+
filePath: string;
|
|
8
|
+
}): string;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDepsTree(cwd: string, entryPoints: string[], webpackConfigPath?: string): Promise<import("./types").MinimalDependencyTree>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MinimalDependencyTree } from './types';
|
|
2
|
+
export declare const getDirectoriesForEntryPointsSearch: (dir: string) => Promise<string[]>;
|
|
3
|
+
export declare const findEntryPointsInDepsTree: (deps: MinimalDependencyTree, exclude?: string[], include?: string[] | undefined) => string[];
|
|
4
|
+
export declare const getEntryPoints: ({ cwd, exclude, include, webpackConfigPath }: {
|
|
5
|
+
cwd: string;
|
|
6
|
+
exclude?: string[] | undefined;
|
|
7
|
+
include?: string[] | undefined;
|
|
8
|
+
webpackConfigPath?: string | undefined;
|
|
9
|
+
}) => Promise<[string[], MinimalDependencyTree]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare type ResolveParams = {
|
|
2
|
+
entryPoints: string[];
|
|
3
|
+
filePath: string;
|
|
4
|
+
webpackConfig?: string;
|
|
5
|
+
cwd?: string;
|
|
6
|
+
all: boolean;
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
include?: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare const resolve: ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd, all, include, exclude }: ResolveParams) => Promise<[string[][][], string[]]>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Dependency } from 'dpdm';
|
|
2
|
+
export declare type Node = {
|
|
3
|
+
path: string;
|
|
4
|
+
children: Node[];
|
|
5
|
+
parents: Node[];
|
|
6
|
+
};
|
|
7
|
+
export declare type MinimalDependency = Pick<Dependency, 'id' | 'request'>;
|
|
8
|
+
export declare type MinimalDependencyTree = {
|
|
9
|
+
[key: string]: readonly MinimalDependency[] | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const removeInitialDot: (path: string) => string;
|
|
2
|
+
export declare const createResolveAbsolutePath: (cwd: string) => (p: string | undefined) => string | undefined;
|
|
3
|
+
export declare const asyncFilter: <T>(arr: T[], predicate: (el: T) => Promise<boolean>) => Promise<T[]>;
|
|
4
|
+
export declare const sanitizeUserEntryPoints: (entryPoints: string[]) => string[];
|
|
5
|
+
export declare const resolvePath: <P extends string | undefined>(p: P) => string | P;
|
|
6
|
+
export declare const findTsConfig: (cwd?: string) => string | undefined;
|
package/dist/module.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rev-dep",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Dependency debugging tool for JavaScript and TypeScript projects",
|
|
5
5
|
"main": "dist/module.js",
|
|
6
6
|
"bin": "bin.js",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"node": ">=10"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
+
"checks": "yarn lint && yarn typecheck",
|
|
24
25
|
"lint": "eslint --ext .js,.ts src",
|
|
25
26
|
"lint:fix": "yarn lint --fix",
|
|
26
27
|
"docs-gen": "node ./scripts/addDocsToReadme.js",
|
|
27
28
|
"dev": "node bin",
|
|
28
29
|
"test": "jest",
|
|
29
30
|
"release": "release-it",
|
|
30
|
-
"build": "tsc",
|
|
31
|
+
"build": "tsc --declaration",
|
|
31
32
|
"build:watch": "tsc --watch",
|
|
32
33
|
"typecheck": "tsc --noEmit"
|
|
33
34
|
},
|
package/dist/lib/find.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolve = void 0;
|
|
4
|
-
const buildDepsGraph_1 = require("./buildDepsGraph");
|
|
5
|
-
const getDepsTree_1 = require("./getDepsTree");
|
|
6
|
-
const getEntryPoints_1 = require("./getEntryPoints");
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
const resolvePathsToRoot = (node, all = false, resolvedPaths = [[]]) => {
|
|
9
|
-
const newPaths = resolvedPaths.map((resolvedPath) => [
|
|
10
|
-
node.path,
|
|
11
|
-
...resolvedPath
|
|
12
|
-
]);
|
|
13
|
-
if (node.parents.length === 0) {
|
|
14
|
-
return newPaths;
|
|
15
|
-
}
|
|
16
|
-
if (all) {
|
|
17
|
-
return node.parents
|
|
18
|
-
.map((parentPath) => resolvePathsToRoot(parentPath, all, newPaths))
|
|
19
|
-
.flat(1);
|
|
20
|
-
}
|
|
21
|
-
return resolvePathsToRoot(node.parents[0], false, newPaths);
|
|
22
|
-
};
|
|
23
|
-
const resolve = async ({ entryPoints: _entryPoints, filePath, webpackConfig, cwd = process.cwd(), all, include, exclude }) => {
|
|
24
|
-
let deps, entryPoints;
|
|
25
|
-
if (_entryPoints.length > 0) {
|
|
26
|
-
entryPoints = _entryPoints;
|
|
27
|
-
const sanitizedEntryPoints = (0, utils_1.sanitizeUserEntryPoints)(entryPoints);
|
|
28
|
-
deps = await (0, getDepsTree_1.getDepsTree)(cwd, sanitizedEntryPoints, webpackConfig);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
;
|
|
32
|
-
[entryPoints, deps] = await (0, getEntryPoints_1.getEntryPoints)({ cwd, exclude, include });
|
|
33
|
-
}
|
|
34
|
-
const cleanedEntryPoints = entryPoints.map(utils_1.removeInitialDot);
|
|
35
|
-
const cleanedFilePath = (0, utils_1.removeInitialDot)(filePath);
|
|
36
|
-
const forest = cleanedEntryPoints.map((0, buildDepsGraph_1.buildGraphDpdm)(deps, cleanedFilePath));
|
|
37
|
-
const resolvedPaths = forest.reduce((allPaths, [_, fileNode]) => {
|
|
38
|
-
if (!fileNode) {
|
|
39
|
-
return [...allPaths, []];
|
|
40
|
-
}
|
|
41
|
-
const pathsForTree = resolvePathsToRoot(fileNode, all);
|
|
42
|
-
return [...allPaths, pathsForTree];
|
|
43
|
-
}, []);
|
|
44
|
-
return [resolvedPaths, entryPoints];
|
|
45
|
-
};
|
|
46
|
-
exports.resolve = resolve;
|