rev-dep 1.0.1 β 1.0.4
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 +20 -21
- package/dist/cli/docs/template.js +4 -2
- package/package.json +1 -1
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
|
|
|
@@ -314,29 +315,26 @@ As you can see cli even import `package.json`. This is to print version of the c
|
|
|
314
315
|
|
|
315
316
|
### How to reduce amount of files imported by entry point?
|
|
316
317
|
|
|
317
|
-
There is no easy how to for this process, but you can do it iteratively using
|
|
318
|
-
|
|
319
|
-
- `files`
|
|
320
|
-
- `resolve`
|
|
318
|
+
There is no easy how to for this process, but you can do it iteratively using `rev-dep` commands `files` and `resolve`
|
|
321
319
|
|
|
322
320
|
1. Get the list of files imported by entry-point
|
|
323
321
|
|
|
324
|
-
|
|
322
|
+
`rev-dep files path/to/entry-point`
|
|
325
323
|
|
|
326
324
|
2. Identify some suspicious files on the list, components that should not be used on the given page or not related utility files
|
|
327
325
|
3. Get all resolution paths for a suspicious file
|
|
328
326
|
|
|
329
|
-
|
|
327
|
+
`rev-dep resolve path/to/suspicious-file path/to/entry-point --all`
|
|
330
328
|
|
|
331
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
|
|
332
330
|
|
|
333
|
-
## Usage
|
|
331
|
+
## Usage π¨
|
|
334
332
|
|
|
335
333
|
Project can be used as a CLI tool or as a module
|
|
336
334
|
|
|
337
335
|
### CLI Tool
|
|
338
336
|
|
|
339
|
-
For CLI usage see [CLI reference](#cli-reference)
|
|
337
|
+
For CLI usage see [CLI reference](#cli-reference-)
|
|
340
338
|
|
|
341
339
|
### Module
|
|
342
340
|
|
|
@@ -365,7 +363,7 @@ const [entryPoints] = await getEntryPoints({
|
|
|
365
363
|
console.log(entryPoints);
|
|
366
364
|
```
|
|
367
365
|
|
|
368
|
-
## CLI reference
|
|
366
|
+
## CLI reference π
|
|
369
367
|
|
|
370
368
|
<!-- cli-docs-start -->
|
|
371
369
|
|
|
@@ -381,7 +379,8 @@ rev-dep resolve <filePath> [entryPoints...] [options]
|
|
|
381
379
|
|
|
382
380
|
#### Arguments
|
|
383
381
|
|
|
384
|
-
- `filePath` - Path to a file that should be resolved in entry points (**required**)
|
|
382
|
+
- `filePath` - Path to a file that should be resolved in entry points (**required**)
|
|
383
|
+
- `entryPoints...` - List of entry points to look for file (_optional_)
|
|
385
384
|
|
|
386
385
|
#### Options
|
|
387
386
|
|
|
@@ -29,9 +29,11 @@ function template(commands, headerLevel) {
|
|
|
29
29
|
]))}
|
|
30
30
|
${cmd.arguments.length > 0 ? header(headerLevel + 1, 'Arguments') : ''}
|
|
31
31
|
|
|
32
|
-
${cmd.arguments
|
|
32
|
+
${cmd.arguments
|
|
33
|
+
.map(({ name, required, description }) => (0, dedent_1.default) `
|
|
33
34
|
* ${code(name)} - ${description} (${required ? requiredStr : optionalStr})
|
|
34
|
-
`)
|
|
35
|
+
`)
|
|
36
|
+
.join('\n')}
|
|
35
37
|
|
|
36
38
|
${cmd.options.length > 0 ? header(headerLevel + 1, 'Options') : ''}
|
|
37
39
|
|