UNPKG

12.1 kBMarkdownView Raw
1# :open_file_folder: tslint-folders-diagrams
2
3Generate architecture diagrams from the folder configuration of tslint-folders.
4
5## status - stable
6
7tslint-folders-diagrams is stable and in use every day in CI builds and on dev boxes (Linux, Mac, Windows) for at least one major product.
8
9[![Travis](https://img.shields.io/travis/mrseanryan/tslint-folders-diagrams.svg)](https://travis-ci.org/mrseanryan/tslint-folders-diagrams)
10
11<!-- TODO add unit tests! -->
12<!-- [![Coveralls](https://img.shields.io/coveralls/mrseanryan/tslint-folders-diagrams.svg)](https://coveralls.io/github/mrseanryan/tslint-folders-diagrams) -->
13
14[![install size](https://packagephobia.now.sh/badge?p=tslint-folders-diagrams)](https://packagephobia.now.sh/result?p=tslint-folders-diagrams)
15
16[![Dependencies](https://david-dm.org/mrseanryan/tslint-folders-diagrams.svg)](https://david-dm.org/mrseanryan/tslint-folders-diagrams)
17[![Dev Dependencies](https://david-dm.org/mrseanryan/tslint-folders-diagrams/dev-status.svg)](https://david-dm.org/mrseanryan/tslint-folders-diagrams?type=dev)
18
19[![npm Package](https://img.shields.io/npm/v/tslint-folders-diagrams.svg?style=flat-square)](https://www.npmjs.org/package/tslint-folders-diagrams)
20[![NPM Downloads](https://img.shields.io/npm/dm/tslint-folders-diagrams.svg)](https://npmjs.org/package/tslint-folders-diagrams)
21
22[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
23[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
24
25[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
26
27---
28
29## why?
30
31Automatically create up-to-date architecture diagrams from the same config as used by [tslint-folders](https://github.com/mrseanryan/tslint-folders) to validate the source code.
32
33---
34
35## features
36
37- Provides a tool to generate architecture diagrams from the same model used by [tslint-folders](https://github.com/mrseanryan/tslint-folders)
38- Output formats:
39 - plain text - suitable for a markdown file
40 - dot (graphviz)
41 - svg (via graphviz)
42
43---
44
45## versioning
46
47We use [SemVer](https://semver.org) for versioning. For the versions available, see [Releases](https://github.com/mrseanryan/tslint-folders-diagrams/releases).
48
49---
50
51## usage
52
53### 1 Install via yarn into your website
54
55```
56yarn add tslint-folders-diagrams
57```
58
59### 2 Generate a summary of the package configuration
60
61Assuming that [tslint.tslint-folders.json](./tslint.tslint-folders.json) (from [tslint-folders](https://github.com/mrseanryan/tslint-folders)) has been correctly configured to model the expected package structure, then you can run this command to generate a summary:
62
63```
64node node_modules/tslint-folders-diagrams/dist/lib/tslint-folders-diagrams.js tslint.tslint-folders.json Text
65```
66
67example output:
68
69```
70package structure:
71_____
72shell - Application Shell
73 --> (any)
74
75todo-area - TODO Area Package
76 --> grid-package, utils
77 folders:
78 components - components
79 --> (any)
80
81 viewmodels - view models
82 --> models, utils
83
84 models - models
85 --> utils
86
87 utils - utils
88 --> (none)
89
90contact-area - Area that shows contact details
91 --> grid-package, utils
92
93grid-package - Grid Package with no dependencies
94 --> (none)
95
96utils - Utils package
97 --> (none)
98
99_____
100```
101
102Allowed imports are shown for each package, after the `-->` arrow.
103
104### using graphviz to generate image diagrams of the architecture
105
106A diagram can be automatically generated from the same config used to validated the code:
107
108![example diagram](https://github.com/mrseanryan/tslint-folders-diagrams/blob/master/static/images/example_diagram_from_Dot_output.png?raw=true)
109
110see [generating diagrams](https://github.com/mrseanryan/tslint-folders-diagrams/blob/master/readme.generating-diagram-images.md) for details.
111
112### command line arguments
113
114`tslint-folders-diagrams` has many command line arguments, to allow you to customize the output.
115
116To see the available arguments, you can run the command, with no arguments:
117
118```
119node node_modules/tslint-folders-diagrams/dist/lib/tslint-folders-diagrams.js
120```
121
122The general usage pattern is:
123
124```
125node node_modules/tslint-folders-diagrams/dist/lib/tslint-folders-diagrams.js <path to tslint.json> <format> [options]
126```
127
128- where format is one of: Text, Dot
129
130The general options are:
131
132| Option | Description | Example |
133| --------------- | ------------------------------------------------------------------------------------ | -------------------------------------- |
134| help | Shows the usage text. | `-help` or `-h` |
135| importBlacklist | Exclude these top-level packages from the diagram. Helps to simplify the diagram. | `-importBlacklist=package-1,package-2` |
136| importWhitelist | Include only these top-level packages in the diagram. Helps to simplify the diagram. | `-importWhitelist=package-1,package-2` |
137| output | Write the output to the given filepath, instead of using standard output. | `-outpath=/tmp/my-file.dot` |
138| skipSubFolders | Exclude sub-folders from the diagram. | `-skipSubFolders` |
139
140The following options are specific to the `Dot` output format:
141
142| Option | Description | Example |
143| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- |
144| clusterFromTslintJson | Use `diagramCluster` from the `tslint.tslint-folders.json` config file, instead of automatically calculating a suitable cluster. | `-clusterFromTslintJson` |
145| colorScheme | Controls which [graphviz color scheme](https://graphviz.gitlab.io/_pages/doc/info/colors.html) to use. Defaults to `pastel19` | `-colorScheme=piyg11` |
146| disableGraphOptimizer | Disable the graph optimizer. The graph optimizer tries to automatically simplify the diagram, by avoiding duplicate edges, and by merging shared edge end points and clusters. For some configurations, it could be that the result is better with optimizations turned off. | `-disableGraphOptimizer` |
147| maxColors | Control the maximum number of colors used from the graphviz theme. Defaults to 9 colors. | `-maxColors=6` |
148| packageShape | Control what kind of shapes are used to draw the packages. Defaults to oval. Allowed values are: box, oval, octagon, component, cyclinder, box3d, folder. | `-packageShape=cylinder` |
149| showImportAnyAsNodeNotEdges | If a package can import any other package, then this can result in a large number of edges connected to this package. To avoid that, this option instead renders the 'any' specification as a single 'imports any' node, which helps to simplify the diagram. | `-showImportAnyAsNodeNotEdges` |
150| subFolderShape | Control what kind of shapes are used to draw the sub-folders. Defaults to folder. Allowed values are: box, oval, octagon, component, cyclinder, box3d, folder. | `-subFolderShape=octagon` |
151| subTitle | Set the sub-title of the diagram. | `-subTitle="Top-level Packages"` |
152| title | Set the title of the diagram. | `-title="Project Packages"` |
153
154### examples
155
156For working examples, see the following scripts:
157
158| Script | Description |
159| --------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
160| `./generate_graph_image_example.sh` | Basic example that generates an image from the example configuration (`./tslint.tslint-folders.json`). |
161| `./generate_graph_image_example_shapes.sh` | Uses different kinds of shapes to draw the packages and sub-folders. |
162| `./generate_graph_image_optimized_example.sh` | Uses optimization options to simplify the diagram. |
163
164---
165
166## sites
167
168| site | URL |
169| -------------------- | ----------------------------------------------------- |
170| source code (github) | https://github.com/mrseanryan/tslint-folders-diagrams |
171| github page | https://mrseanryan.github.io/tslint-folders-diagrams/ |
172| npm | https://www.npmjs.com/package/tslint-folders-diagrams |
173
174---
175
176## building and testing this source code
177
178To work on the source code for tslint-folders-diagrams, there are a few scripts:
179
180| command | description |
181| ---------- | ---------------------------------------------------------------------- |
182| yarn build | Builds the tool to the 'dist' folder, where it can be executed. |
183| yarn docs | Generates a summary of the package structure described in tslint.json. |
184| yarn lint | Lints the source code of the rules. |
185| yarn start | Builds, tests and lints the code. |
186
187---
188
189## developing code in _this_ repository
190
191see the [contributing readme](CONTRIBUTING.md).
192
193## origin
194
195This project is based on the excellent seeder project [typescript-library-starter](https://github.com/alexjoverm/typescript-library-starter).
196
197The project was started to avoid having to repeatedly fix similar coding issues in large TypeScript code bases.
198
199### ORIGINAL readme (from the seeder project)
200
201[see here](https://github.com/mrseanryan/tslint-folders-diagrams/blob/master/readme.original.md)
202
203---
204
205## that's it
206
207That's pretty much it. Let me know if this is useful or how it can be improved!
208
209## authors
210
211Original work by Sean Ryan - mr.sean.ryan(at gmail.com)
212
213## licence = MIT
214
215This project is licensed under the MIT License - see the [LICENSE](https://github.com/mrseanryan/tslint-folders-diagrams/blob/master/LICENSE) file for details.