UNPKG

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