@mermaid-js/mermaid-cli 11.4.3 → 11.6.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/dist-types/src/index.d.ts +3 -1
- package/dist-types/src/index.d.ts.map +1 -1
- package/dist-types/src/version.d.ts +1 -1
- package/package.json +3 -2
- package/src/index.js +21 -4
- package/src/version.js +1 -1
|
@@ -61,13 +61,15 @@ export type MarkdownImageProps = {
|
|
|
61
61
|
* @param {import("puppeteer").LaunchOptions} [opts.puppeteerConfig] - Puppeteer launch options.
|
|
62
62
|
* @param {boolean} [opts.quiet] - If set, suppress log output.
|
|
63
63
|
* @param {"svg" | "png" | "pdf"} [opts.outputFormat] - Mermaid output format.
|
|
64
|
+
* @param {string} [opts.artefacts] - Path to the artefacts directory.
|
|
64
65
|
* Defaults to `output` extension. Overrides `output` extension if set.
|
|
65
66
|
* @param {ParseMDDOptions} [opts.parseMMDOptions] - Options to pass to {@link parseMMDOptions}.
|
|
66
67
|
*/
|
|
67
|
-
export function run(input: `${string}.${"md" | "markdown"}` | string | undefined, output: `${string}.${"md" | "markdown" | "svg" | "png" | "pdf"}` | "/dev/stdout", { puppeteerConfig, quiet, outputFormat, parseMMDOptions }?: {
|
|
68
|
+
export function run(input: `${string}.${"md" | "markdown"}` | string | undefined, output: `${string}.${"md" | "markdown" | "svg" | "png" | "pdf"}` | "/dev/stdout", { puppeteerConfig, quiet, outputFormat, parseMMDOptions, artefacts }?: {
|
|
68
69
|
puppeteerConfig?: puppeteer.LaunchOptions | undefined;
|
|
69
70
|
quiet?: boolean | undefined;
|
|
70
71
|
outputFormat?: "svg" | "png" | "pdf" | undefined;
|
|
72
|
+
artefacts?: string | undefined;
|
|
71
73
|
parseMMDOptions?: ParseMDDOptions | undefined;
|
|
72
74
|
}): Promise<void>;
|
|
73
75
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAgYc,MAAM;;;;SACN,MAAM;;;;;;AAqBpB;;;;;;;;;;;;;;;GAeG;AACH,2BAbW,GAAG,MAAM,IAAI,IAAI,GAAG,UAAU,EAAE,GAAG,MAAM,GAAG,SAAS,UAIrD,GAAG,MAAM,IAAI,IAAI,GAAG,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,GAAG,aAAa,yEAEhF;IAAiD,eAAe;IACzC,KAAK;IACS,YAAY;IAC3B,SAAS;IAEA,eAAe;CAChD,iBAoHA;AAxTD;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,uCAPW,OAAO,WAAW,EAAE,OAAO,GAAG,OAAO,WAAW,EAAE,cAAc,cAChE,MAAM,gBACN,KAAK,GAAG,KAAK,GAAG,KAAK,kFACrB,eAAe,GACb,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAC,CAAC,CAwIlF;AAnRD,qCAuHC;AA3MD;;;;;GAKG;AACH,+BAHW,MAAM,GACJ,KAAK,CAKjB;sBAxBqB,WAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version: "11.
|
|
1
|
+
export const version: "11.6.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mermaid-js/mermaid-cli",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.6.0",
|
|
4
4
|
"description": "Command-line interface for mermaid",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git@github.com:mermaid-js/mermaid-cli.git",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"prepare": "tsc && vite build",
|
|
26
26
|
"prepack": "tsc && vite build",
|
|
27
27
|
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
|
|
28
|
+
"test:cli": "bash run-tests.sh test-positive",
|
|
28
29
|
"version": "node scripts/version.js",
|
|
29
30
|
"lint": "standard",
|
|
30
31
|
"lint-fix": "standard --fix"
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@mermaid-js/mermaid-zenuml": "^0.2.0",
|
|
34
35
|
"chalk": "^5.0.1",
|
|
35
|
-
"commander": "^
|
|
36
|
+
"commander": "^14.0.0",
|
|
36
37
|
"import-meta-resolve": "^4.1.0",
|
|
37
38
|
"mermaid": "^11.0.2"
|
|
38
39
|
},
|
package/src/index.js
CHANGED
|
@@ -111,6 +111,7 @@ async function cli () {
|
|
|
111
111
|
.addOption(new Option('-H, --height [height]', 'Height of the page').argParser(parseCommanderInt).default(600))
|
|
112
112
|
.option('-i, --input <input>', 'Input mermaid file. Files ending in .md will be treated as Markdown and all charts (e.g. ```mermaid (...)``` or :::mermaid (...):::) will be extracted and generated. Use `-` to read from stdin.')
|
|
113
113
|
.option('-o, --output [output]', 'Output file. It should be either md, svg, png, pdf or use `-` to output to stdout. Optional. Default: input + ".svg"')
|
|
114
|
+
.option('-a, --artefacts [artefacts]', 'Output artefacts path. Only used with Markdown input file. Optional. Default: output directory')
|
|
114
115
|
.addOption(new Option('-e, --outputFormat [format]', 'Output format for the generated image.').choices(['svg', 'png', 'pdf']).default(null, 'Loaded from the output file extension'))
|
|
115
116
|
.addOption(new Option('-b, --backgroundColor [backgroundColor]', 'Background color for pngs/svgs (not pdfs). Example: transparent, red, \'#F0F0F0\'.').default('white'))
|
|
116
117
|
.option('-c, --configFile [configFile]', 'JSON configuration file for mermaid.')
|
|
@@ -125,7 +126,7 @@ async function cli () {
|
|
|
125
126
|
|
|
126
127
|
const options = commander.opts()
|
|
127
128
|
|
|
128
|
-
let { theme, width, height, input, output, outputFormat, backgroundColor, configFile, cssFile, svgId, puppeteerConfigFile, scale, pdfFit, quiet, iconPacks } = options
|
|
129
|
+
let { theme, width, height, input, output, outputFormat, backgroundColor, configFile, cssFile, svgId, puppeteerConfigFile, scale, pdfFit, quiet, iconPacks, artefacts } = options
|
|
129
130
|
|
|
130
131
|
// check input file
|
|
131
132
|
if (!input) {
|
|
@@ -166,6 +167,15 @@ async function cli () {
|
|
|
166
167
|
error('Output file must end with ".md"/".markdown", ".svg", ".png" or ".pdf"')
|
|
167
168
|
}
|
|
168
169
|
|
|
170
|
+
if (artefacts) {
|
|
171
|
+
if (!input || !/\.(?:md|markdown)$/.test(input)) {
|
|
172
|
+
error('Artefacts [-a|--artefacts] path can only be used with Markdown input file')
|
|
173
|
+
}
|
|
174
|
+
if (!fs.existsSync(artefacts)) {
|
|
175
|
+
fs.mkdirSync(artefacts, { recursive: true })
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
169
179
|
const outputDir = path.dirname(output)
|
|
170
180
|
if (output !== '/dev/stdout' && !fs.existsSync(outputDir)) {
|
|
171
181
|
error(`Output directory "${outputDir}/" doesn't exist`)
|
|
@@ -207,7 +217,8 @@ async function cli () {
|
|
|
207
217
|
outputFormat,
|
|
208
218
|
parseMMDOptions: {
|
|
209
219
|
mermaidConfig, backgroundColor, myCSS, pdfFit, viewport: { width, height, deviceScaleFactor: scale }, svgId, iconPacks
|
|
210
|
-
}
|
|
220
|
+
},
|
|
221
|
+
artefacts
|
|
211
222
|
}
|
|
212
223
|
)
|
|
213
224
|
}
|
|
@@ -405,10 +416,11 @@ function markdownImage ({ url, title, alt }) {
|
|
|
405
416
|
* @param {import("puppeteer").LaunchOptions} [opts.puppeteerConfig] - Puppeteer launch options.
|
|
406
417
|
* @param {boolean} [opts.quiet] - If set, suppress log output.
|
|
407
418
|
* @param {"svg" | "png" | "pdf"} [opts.outputFormat] - Mermaid output format.
|
|
419
|
+
* @param {string} [opts.artefacts] - Path to the artefacts directory.
|
|
408
420
|
* Defaults to `output` extension. Overrides `output` extension if set.
|
|
409
421
|
* @param {ParseMDDOptions} [opts.parseMMDOptions] - Options to pass to {@link parseMMDOptions}.
|
|
410
422
|
*/
|
|
411
|
-
async function run (input, output, { puppeteerConfig = {}, quiet = false, outputFormat, parseMMDOptions } = {}) {
|
|
423
|
+
async function run (input, output, { puppeteerConfig = {}, quiet = false, outputFormat, parseMMDOptions, artefacts } = {}) {
|
|
412
424
|
/**
|
|
413
425
|
* Logs the given message to stdout, unless `quiet` is set to `true`.
|
|
414
426
|
*
|
|
@@ -465,10 +477,15 @@ async function run (input, output, { puppeteerConfig = {}, quiet = false, output
|
|
|
465
477
|
* I.e. if "out.md". use "out-1.svg", "out-2.svg", etc
|
|
466
478
|
* @type {string}
|
|
467
479
|
*/
|
|
468
|
-
|
|
480
|
+
let outputFile = output.replace(
|
|
469
481
|
/(\.(md|markdown|png|svg|pdf))$/,
|
|
470
482
|
`-${imagePromises.length + 1}$1`
|
|
471
483
|
).replace(/\.(md|markdown)$/, `.${outputFormat}`)
|
|
484
|
+
|
|
485
|
+
if (artefacts) {
|
|
486
|
+
outputFile = path.resolve(artefacts, path.basename(outputFile))
|
|
487
|
+
}
|
|
488
|
+
|
|
472
489
|
const outputFileRelative = `./${path.relative(path.dirname(path.resolve(output)), path.resolve(outputFile))}`
|
|
473
490
|
|
|
474
491
|
const imagePromise = (async () => {
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '11.
|
|
1
|
+
export const version = '11.6.0'
|