puml-for-markdown 1.2.0 → 2.0.0
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/CHANGELOG.md +24 -0
- package/README.md +181 -29
- package/bin/index.js +88 -71
- package/index.js +305 -206
- package/lib/cache.js +45 -0
- package/lib/network.js +38 -0
- package/package.json +19 -11
- package/.nvmrc +0 -1
- package/CONTRIBUTING.md +0 -1
- package/puml/c4_styles.puml +0 -37
- package/puml/constants.puml +0 -32
- package/puml/level_1_system_view.puml +0 -36
- package/puml/level_2_container_view.puml +0 -55
- package/puml/level_3_component_view_label_retrieval_job.puml +0 -40
- package/puml/level_3_component_view_pipeline.puml +0 -58
- package/puml/level_4_activity_diagram_export_bq_snapshot_job.puml +0 -13
- package/puml/level_4_activity_diagram_sampler_a.puml +0 -79
- package/puml/level_4_activity_diagram_sampler_b.puml +0 -32
- package/puml/level_4_erd.puml +0 -106
- package/puml/styles.puml +0 -22
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Migration from version 1
|
|
6
|
+
|
|
7
|
+
- Requires Node.js 22 or newer. Upgrade Node.js before installing version 2.
|
|
8
|
+
- CLI failures now exit with a nonzero status so scripts and CI can detect errors.
|
|
9
|
+
- The CLI creates `.puml-cache.json` by default. Add it to `.gitignore`, or use
|
|
10
|
+
`--no-cache` to disable caching. Refresh with `--no-cache` when remote includes
|
|
11
|
+
or the rendering server change.
|
|
12
|
+
|
|
13
|
+
### Features and fixes
|
|
14
|
+
|
|
15
|
+
- Add local image links, offline check and dry-run modes, persistent caching,
|
|
16
|
+
and private Polr URL shortening.
|
|
17
|
+
- Support `.plantuml` files, Windows paths, nested ignore rules, and recursive
|
|
18
|
+
includes with cycle detection.
|
|
19
|
+
- Preserve Markdown formatting and code examples while replacing diagram links.
|
|
20
|
+
- Validate references before editing Markdown and preserve unrelated exported
|
|
21
|
+
files. Export images atomically with readable permissions.
|
|
22
|
+
- Handle HTTP errors and timeouts, and serialize watch updates.
|
|
23
|
+
- Update dependencies and examples, with automated checks on Linux, macOS,
|
|
24
|
+
and Windows using Node.js 22 and 24.
|
package/README.md
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Simple CLI Usage
|
|
4
4
|
Just run `puml-for-markdown` in any directory where you have markdown files and it will render links to PlantUML files
|
|
5
|
-
in markdown comments.
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
in markdown comments. The best part about this is that it requires no build files, you don't even need to store
|
|
6
|
+
puml images in your repo. Also the embedded diagrams can link to other diagrams. [PlantUML](https://plantuml.com) files
|
|
7
|
+
allow you to create diagrams that are defined using a simple and intuitive language. By default the entire directory
|
|
8
|
+
is recursively searched, respecting root and nested `.gitignore` rules, including negation. `.git`, `node_modules`, the output directory, and symbolic links are always skipped. Both `.puml` and `.plantuml` diagram files are supported.
|
|
8
9
|
|
|
9
10
|
## Examples
|
|
10
11
|
The following examples are of a project I worked on, **yellow components will link you to another diagram**. Obviously the
|
|
@@ -19,7 +20,7 @@ You can easily add an embedded diagram to your markdown. Simply add a link to th
|
|
|
19
20
|
|
|
20
21
|
Here's the result. **Try clicking on the yellow blocks.**
|
|
21
22
|
|
|
22
|
-
[](https://tinyurl.com/2d47useb)<!---->
|
|
23
24
|
|
|
24
25
|
### Link Only
|
|
25
26
|
To render a link to a puml diagram, do the same thing but exclude the `!`
|
|
@@ -29,7 +30,7 @@ To render a link to a puml diagram, do the same thing but exclude the `!`
|
|
|
29
30
|
|
|
30
31
|
which renders into
|
|
31
32
|
|
|
32
|
-
[Click to Open Interactive Diagram](https://tinyurl.com/
|
|
33
|
+
[Click to Open Interactive Diagram](https://tinyurl.com/2d47useb)<!--[Click to Open Interactive Diagram](./puml/level_1_system_view.puml)-->
|
|
33
34
|
|
|
34
35
|
## Goal
|
|
35
36
|
The goal is to make PlantUML diagrams easily accessible from markdown, specifically GitHub flavored.
|
|
@@ -75,43 +76,79 @@ If you want to update the link text or switch it between image and link, just up
|
|
|
75
76
|
don't need to delete the rendered image or link.
|
|
76
77
|
|
|
77
78
|
### Installation
|
|
79
|
+
Requires **Node.js 22 or newer** (Node.js 24 recommended for development).
|
|
80
|
+
|
|
81
|
+
Version 2 raises the minimum Node.js version to 22. Upgrade Node.js before upgrading
|
|
82
|
+
from version 1. Existing dependencies pinned to `1.x` or `^1.2.1` stay on version 1;
|
|
83
|
+
installing `latest` will select version 2 once it is published. See the
|
|
84
|
+
[release notes](./CHANGELOG.md) for the changes.
|
|
85
|
+
|
|
78
86
|
`npm i -g puml-for-markdown`
|
|
79
87
|
|
|
80
88
|
### Advanced Usage
|
|
81
89
|
Here are some other features supported
|
|
82
|
-
- You can specify the CLI to output the diagram images as png and/or svg see `--output-images` and `--image-formats
|
|
90
|
+
- You can specify the CLI to output the diagram images as png and/or svg see `--output-images` and `--image-formats`.
|
|
91
|
+
For an example of outputted images, checkout [dist_puml/puml](./dist_puml/puml). These images were created by the
|
|
92
|
+
[pre-commit hook](./.husky/pre-commit).
|
|
83
93
|
- You can specify the PUML server used to render the diagrams see `--puml-server-url`
|
|
84
94
|
|
|
85
95
|
### All CLI Options
|
|
86
|
-
```
|
|
96
|
+
```text
|
|
87
97
|
Usage: puml-for-markdown [options]
|
|
88
98
|
|
|
89
99
|
An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.
|
|
90
100
|
|
|
91
101
|
Options:
|
|
92
|
-
-s, --puml-server-url <url> This is the base URL used to render
|
|
102
|
+
-s, --puml-server-url <url> This is the base URL used to render
|
|
103
|
+
diagrams. Defaults to the public plantuml
|
|
104
|
+
server. (default:
|
|
105
|
+
"https://www.plantuml.com/plantuml")
|
|
93
106
|
-x, --root-directory <path> The path to your project (default: CWD)
|
|
94
|
-
-r, --hot-reload Rerun markdown generator every `interval`
|
|
95
|
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
-r, --hot-reload Rerun markdown generator every `interval`
|
|
108
|
+
seconds, determined by interval option
|
|
109
|
+
-v, --interval-seconds <number> If --hot-reload is set, how often should it
|
|
110
|
+
reload (default: 2)
|
|
111
|
+
-p, --puml-directory <path> Path to directory containing puml files
|
|
112
|
+
which are referenced in markdown files
|
|
113
|
+
(default: rootDirectory)
|
|
114
|
+
-m, --markdown-directory <path> Path to directory containing markdown files
|
|
115
|
+
referencing puml files (default:
|
|
116
|
+
rootDirectory)
|
|
117
|
+
-g, --ignore-gitignore Don't use .gitignore rules to skip PUML and
|
|
118
|
+
MD
|
|
119
|
+
-i, --gitignore-path <path> Use this as path to .gitignore file.
|
|
120
|
+
(default: rootDirectory/.gitignore)
|
|
121
|
+
-d, --output-images If set, will output images of diagrams to
|
|
122
|
+
the dist directory
|
|
123
|
+
-b, --dist-directory <path> If --output-images is set, path to output
|
|
124
|
+
diagram images (default:
|
|
125
|
+
rootDirectory/dist_puml)
|
|
126
|
+
-f, --image-formats <format> If --output-images is set, sets the output
|
|
127
|
+
image format (choices: "png", "svg", "both",
|
|
128
|
+
default: "png")
|
|
129
|
+
-t, --turn-off-link-shortening Use the full puml server link instead of the
|
|
130
|
+
tiny url, if your diagrams are too big this
|
|
131
|
+
won't work
|
|
132
|
+
--local-images Link Markdown to exported local images
|
|
133
|
+
(implies --output-images)
|
|
134
|
+
--interactive-links Wrap local image previews in an interactive
|
|
135
|
+
renderer link
|
|
136
|
+
--check Check for stale Markdown and images without
|
|
137
|
+
writing or using the network
|
|
138
|
+
--dry-run List planned changes without writing or
|
|
139
|
+
using the network
|
|
140
|
+
--no-cache Disable the persistent diagram and image
|
|
141
|
+
cache
|
|
142
|
+
-l, --polr-url <url> Use a private Polr shortener; reads
|
|
143
|
+
POLR_APIKEY from the environment
|
|
104
144
|
-h, --help display help for command
|
|
105
145
|
```
|
|
106
146
|
|
|
107
147
|
### Notes
|
|
108
148
|
- Comments within inline or multiline code styling will be ignored
|
|
109
|
-
-
|
|
110
|
-
to it
|
|
149
|
+
- Cyclic diagram links and recursive local includes fail with an error showing the reference chain.
|
|
111
150
|
- See the [pre-commit hook](./.husky/pre-commit) to see how to add a git hook
|
|
112
|
-
-
|
|
113
|
-
(i.e. [example](./puml/constants.puml)) you'll see a warning in the console saying it failed to save the image to file
|
|
114
|
-
because these aren't renderable on their own (since there is nothing to render)
|
|
151
|
+
- Image export skips files without an `@start...` directive and files used only as local includes. A Markdown reference or diagram hyperlink makes an included file exportable. Other files must render successfully.
|
|
115
152
|
- Anything inside `inline code` or `code blocks` will be excluded from rendering
|
|
116
153
|
|
|
117
154
|
### How It Works
|
|
@@ -145,25 +182,140 @@ though.
|
|
|
145
182
|
### Other Helpful Links
|
|
146
183
|
* [C4-Puml](https://github.com/plantuml-stdlib/C4-PlantUML): A collection of PlantUML diagrams for use in C4, you'll see me using this in my examples
|
|
147
184
|
|
|
185
|
+
### Known Issues
|
|
186
|
+
* Seems to be breaking on Windows, see [here](https://github.com/danielyaa5/puml-for-markdown/issues/6). I don't have a
|
|
187
|
+
Windows machine to test on so help here would be appreciated.
|
|
188
|
+
|
|
148
189
|
### More Examples
|
|
149
|
-
[](https://tinyurl.com/2amb263t)<!---->
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
[](https://tinyurl.com/284kg5h5)<!---->
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
[](https://tinyurl.com/262ys7bk)<!---->
|
|
199
|
+
|
|
150
200
|
|
|
151
201
|
|
|
202
|
+
[](https://tinyurl.com/2xlmr44t)<!---->
|
|
152
203
|
|
|
153
|
-
[](https://tinyurl.com/yblre3m4)<!---->
|
|
154
204
|
|
|
155
205
|
|
|
206
|
+
[](https://tinyurl.com/26j5s2fw)<!---->
|
|
156
207
|
|
|
157
|
-
[](https://tinyurl.com/y8egw3wt)<!---->
|
|
158
208
|
|
|
159
209
|
|
|
210
|
+
[](https://tinyurl.com/2cqvdekn)<!---->
|
|
160
211
|
|
|
161
|
-
[](https://tinyurl.com/y9j7twkz)<!---->
|
|
162
212
|
|
|
213
|
+
### Reliability and operational notes
|
|
163
214
|
|
|
215
|
+
- Fatal errors return a nonzero exit status, suitable for CI. Watch mode logs errors
|
|
216
|
+
and retries on the next interval; it runs immediately on startup.
|
|
217
|
+
- Local `!include` files are expanded recursively relative to the file containing
|
|
218
|
+
the directive. Remote, standard-library, and macro-based includes remain for the
|
|
219
|
+
renderer to evaluate. This is not a complete PlantUML preprocessor: conditional
|
|
220
|
+
includes and `!include_once` / `!include_many` are not expanded locally.
|
|
221
|
+
- Unrelated Markdown links, fenced/indented code, inline code, and line endings
|
|
222
|
+
are preserved. Unchanged Markdown files are not rewritten.
|
|
223
|
+
- All Markdown references are checked before documents are written. Image exports
|
|
224
|
+
complete before Markdown is updated, but an export failure can leave earlier
|
|
225
|
+
successfully exported images updated; the operation is not a multi-file transaction.
|
|
226
|
+
- Export overwrites the matching generated image files but never clears the output
|
|
227
|
+
directory. Stale images are retained. Ambiguous output names and symlinks inside
|
|
228
|
+
the output path are rejected.
|
|
229
|
+
- Renderer and shortener requests time out after 30 seconds. If TinyURL fails,
|
|
230
|
+
a warning is printed and the direct PlantUML URL is used. Large URLs can still
|
|
231
|
+
exceed renderer/proxy limits; shortening does not remove the renderer's limit.
|
|
232
|
+
- **Diagram privacy:** encoded diagram URLs contain recoverable source text.
|
|
233
|
+
The default shortener receives that URL, and the renderer receives the diagram
|
|
234
|
+
when someone opens it or when images are exported. For private diagrams, use
|
|
235
|
+
your own renderer with `--puml-server-url` and disable shortening with `-t`.
|
|
164
236
|
|
|
165
|
-
[](https://tinyurl.com/ybp8ju9x)<!---->
|
|
166
237
|
|
|
238
|
+
### Local images and offline viewing
|
|
239
|
+
|
|
240
|
+
```sh
|
|
241
|
+
puml-for-markdown --local-images --image-formats svg
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
This implies `--output-images` and produces relative Markdown links to files in
|
|
245
|
+
`dist_puml`. For example, `<!---->` becomes
|
|
246
|
+
`<!---->`.
|
|
247
|
+
Paths are relative to each Markdown file and URL-encoded, including spaces.
|
|
248
|
+
Both `.puml` and `.plantuml` sources work.
|
|
249
|
+
|
|
250
|
+
SVG diagrams link to other exported SVG diagrams using relative paths. Open the
|
|
251
|
+
SVG directly in a browser or serve the export folder to navigate between them.
|
|
252
|
+
Markdown hosts may disable links inside embedded SVG images. PNG previews cannot
|
|
253
|
+
contain clickable elements. With `--image-formats both`, Markdown uses SVG.
|
|
254
|
+
|
|
255
|
+
Add `--interactive-links` to wrap a local preview in a link to the online renderer.
|
|
256
|
+
That renderer link uses separate source with online diagram hyperlinks, while
|
|
257
|
+
exported SVGs retain their local hyperlinks. Local-only mode skips URL shortening.
|
|
258
|
+
Rendering still contacts the configured PlantUML server; use `--puml-server-url`
|
|
259
|
+
with your own renderer when the source must remain private.
|
|
260
|
+
|
|
261
|
+
### Check or preview changes without modifying files
|
|
262
|
+
|
|
263
|
+
```sh
|
|
264
|
+
puml-for-markdown --dry-run -t
|
|
265
|
+
puml-for-markdown --check -t
|
|
266
|
+
puml-for-markdown --local-images --image-formats svg --check
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Both commands are offline and never write Markdown, images, or cache files.
|
|
270
|
+
`--dry-run` lists planned changes and exits successfully; `--check` exits with 1
|
|
271
|
+
if documentation is stale, otherwise 0. Invalid inputs still exit with 1.
|
|
272
|
+
Neither can be combined with `--hot-reload`.
|
|
273
|
+
|
|
274
|
+
A check that uses shortened URLs or exported images needs the cache from a prior
|
|
275
|
+
successful generation with the same settings. If it is missing, the check reports
|
|
276
|
+
that generation is needed rather than contacting a shortener or claiming the files
|
|
277
|
+
are current. Direct-URL Markdown checks (`--check -t` without image export) do not
|
|
278
|
+
require a cache. For CI, use that deterministic mode or restore the generation
|
|
279
|
+
cache with the exported images.
|
|
280
|
+
|
|
281
|
+
### Persistent cache and incremental watch mode
|
|
282
|
+
|
|
283
|
+
Successful runs save `.puml-cache.json` at the project root. Add it to your
|
|
284
|
+
`.gitignore`: encoded URLs contain recoverable source text, even for private diagrams.
|
|
285
|
+
The cache contains no Polr API key. Renderer/provider settings and a hash of the key
|
|
286
|
+
separate cache entries when configuration changes.
|
|
287
|
+
|
|
288
|
+
The CLI reuses encodings, shortened URLs, and verified image files. Watch mode
|
|
289
|
+
checks inputs each interval and only rebuilds affected content. Local include
|
|
290
|
+
changes invalidate their parent diagrams; remote diagram links invalidate parents
|
|
291
|
+
when their target URL changes. Local links stay stable when only a child changes.
|
|
292
|
+
Missing or externally modified images are rendered again.
|
|
293
|
+
|
|
294
|
+
```sh
|
|
295
|
+
puml-for-markdown --hot-reload
|
|
296
|
+
puml-for-markdown --no-cache
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
`--no-cache` forces regeneration without reading or writing the cache. Use it to
|
|
300
|
+
refresh remote includes, renderer upgrades at the same URL, or expired short links:
|
|
301
|
+
those external changes cannot be detected from local file content. Failed shortening
|
|
302
|
+
attempts are not cached, allowing the next run to retry. Stale generated images are
|
|
303
|
+
retained; the CLI never clears the destination directory.
|
|
304
|
+
|
|
305
|
+
### Private Polr URL shortening
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
# Set POLR_APIKEY in your shell or CI secret environment first.
|
|
309
|
+
puml-for-markdown --puml-server-url https://uml.example.com/plantuml \
|
|
310
|
+
--polr-url https://short.example.com
|
|
311
|
+
```
|
|
167
312
|
|
|
313
|
+
This adapts the provider idea from [PR #8](https://github.com/danielyaa5/puml-for-markdown/pull/8)
|
|
314
|
+
by @mzagar. The implementation uses the [Polr v2 API](https://docs.polrproject.org/en/latest/developer-guide/api/):
|
|
315
|
+
POST `/api/v2/action/shorten`, with URL-encoded `url`, `key`, and `response_type`
|
|
316
|
+
fields. JSON and plain-text responses are accepted and validated. Credentials are
|
|
317
|
+
never written into generated links or the cache. A failed Polr request falls back
|
|
318
|
+
to the direct renderer URL, never TinyURL. `--polr-url` cannot be combined with `-t`.
|
|
168
319
|
|
|
169
|
-
|
|
320
|
+
To avoid a shortener entirely, use your own renderer with `-t`. This is also the
|
|
321
|
+
simplest setup for private diagrams when URLs are short enough for your renderer.
|
package/bin/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const path = require('path')
|
|
4
|
+
const fs = require('fs')
|
|
4
5
|
|
|
5
6
|
const {Command, Option} = require('commander')
|
|
6
7
|
|
|
@@ -12,75 +13,91 @@ const run = require(path.resolve(__dirname, '../index.js'))
|
|
|
12
13
|
// =============
|
|
13
14
|
|
|
14
15
|
new Command()
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
16
|
+
.name('puml-for-markdown')
|
|
17
|
+
.description('An application to add interactive PUML diagrams to your github markdown files. If running with default arguments, run in project root directory.')
|
|
18
|
+
.option(
|
|
19
|
+
'-s, --puml-server-url <url>',
|
|
20
|
+
'This is the base URL used to render diagrams. Defaults to the public plantuml server.',
|
|
21
|
+
'https://www.plantuml.com/plantuml',
|
|
22
|
+
)
|
|
23
|
+
.addOption(new Option(
|
|
24
|
+
'-x, --root-directory <path>',
|
|
25
|
+
'The path to your project'
|
|
26
|
+
).default(process.cwd(), 'CWD')
|
|
27
|
+
)
|
|
28
|
+
.option(
|
|
29
|
+
'-r, --hot-reload',
|
|
30
|
+
'Rerun markdown generator every `interval` seconds, determined by interval option',
|
|
31
|
+
)
|
|
32
|
+
.option(
|
|
33
|
+
'-v, --interval-seconds <number>',
|
|
34
|
+
'If --hot-reload is set, how often should it reload',
|
|
35
|
+
2,
|
|
36
|
+
)
|
|
37
|
+
.addOption(new Option(
|
|
38
|
+
'-p, --puml-directory <path>',
|
|
39
|
+
'Path to directory containing puml files which are referenced in markdown files',
|
|
40
|
+
).default(false, 'rootDirectory')
|
|
41
|
+
)
|
|
42
|
+
.addOption(new Option(
|
|
43
|
+
'-m, --markdown-directory <path>',
|
|
44
|
+
'Path to directory containing markdown files referencing puml files',
|
|
45
|
+
).default(false, 'rootDirectory')
|
|
46
|
+
)
|
|
47
|
+
.option(
|
|
48
|
+
'-g, --ignore-gitignore',
|
|
49
|
+
"Don't use .gitignore rules to skip PUML and MD",
|
|
50
|
+
)
|
|
51
|
+
.addOption(new Option(
|
|
52
|
+
'-i, --gitignore-path <path>',
|
|
53
|
+
'Use this as path to .gitignore file.'
|
|
54
|
+
).default(false, 'rootDirectory/.gitignore')
|
|
55
|
+
)
|
|
56
|
+
.option(
|
|
57
|
+
'-d, --output-images',
|
|
58
|
+
'If set, will output images of diagrams to the dist directory',
|
|
59
|
+
)
|
|
60
|
+
.addOption(new Option(
|
|
61
|
+
'-b, --dist-directory <path>',
|
|
62
|
+
'If --output-images is set, path to output diagram images'
|
|
63
|
+
).default(false, 'rootDirectory/dist_puml')
|
|
64
|
+
)
|
|
65
|
+
.addOption(new Option(
|
|
66
|
+
'-f, --image-formats <format>',
|
|
67
|
+
'If --output-images is set, sets the output image format',
|
|
68
|
+
).choices(['png', 'svg', 'both']).default('png')
|
|
69
|
+
)
|
|
70
|
+
.option(
|
|
71
|
+
'-t, --turn-off-link-shortening',
|
|
72
|
+
"Use the full puml server link instead of the tiny url, if your diagrams are too big this won't work",
|
|
73
|
+
)
|
|
74
|
+
.option('--local-images', 'Link Markdown to exported local images (implies --output-images)')
|
|
75
|
+
.option('--interactive-links', 'Wrap local image previews in an interactive renderer link')
|
|
76
|
+
.option('--check', 'Check for stale Markdown and images without writing or using the network')
|
|
77
|
+
.option('--dry-run', 'List planned changes without writing or using the network')
|
|
78
|
+
.option('--no-cache', 'Disable the persistent diagram and image cache')
|
|
79
|
+
.option('-l, --polr-url <url>', 'Use a private Polr shortener; reads POLR_APIKEY from the environment')
|
|
80
|
+
.action(opts => {
|
|
81
|
+
const useDefaultGitignorePath = !opts.gitignorePath
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
opts.distDirectory = opts.distDirectory || path.resolve(opts.rootDirectory, 'dist_puml')
|
|
84
|
+
opts.gitignorePath = opts.gitignorePath || path.resolve(opts.rootDirectory, '.gitignore')
|
|
85
|
+
opts.markdownDirectory = opts.markdownDirectory || opts.rootDirectory
|
|
86
|
+
opts.pumlDirectory = opts.pumlDirectory || opts.rootDirectory
|
|
87
|
+
opts.shouldShortenLinks = !opts.turnOffLinkShortening
|
|
88
|
+
opts.respectGitignore = !opts.ignoreGitignore
|
|
89
|
+
opts.imageFormats = opts.imageFormats === 'both' ? ['png', 'svg'] : [opts.imageFormats]
|
|
90
|
+
|
|
91
|
+
// A missing root ignore file must not disable nested .gitignore files.
|
|
92
|
+
if (useDefaultGitignorePath && !fs.existsSync(opts.gitignorePath)) {
|
|
93
|
+
opts.gitignorePath = undefined
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return run(opts).then(result => {
|
|
97
|
+
if (opts.check && result.stale) process.exitCode = 1
|
|
98
|
+
}).catch((e) => {
|
|
99
|
+
console.error(`ERROR: ${e.message}`)
|
|
100
|
+
process.exitCode = 1
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
.parse(process.argv)
|