infographic-cli 0.3.0 → 0.5.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/README.md +13 -5
- package/dist/commands/render.js +14 -3
- package/dist/index.js +1 -0
- package/dist-types/commands/render.d.ts +1 -0
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.npmjs.com/package/infographic-cli)
|
|
6
6
|
|
|
7
|
-
Command-line interface for [AntV Infographic](https://github.com/antvis/Infographic) -
|
|
7
|
+
Command-line interface for [AntV Infographic](https://github.com/antvis/Infographic) - instantly create stunning SVG infographics from simple declarative syntax. Render from strings, files, or stdin.
|
|
8
8
|
|
|
9
9
|
## Quick Start
|
|
10
10
|
|
|
@@ -12,13 +12,13 @@ Command-line interface for [AntV Infographic](https://github.com/antvis/Infograp
|
|
|
12
12
|
# Install
|
|
13
13
|
npm install -g infographic-cli
|
|
14
14
|
|
|
15
|
-
# Render from
|
|
16
|
-
|
|
15
|
+
# Render from string (quickest for testing)
|
|
16
|
+
ifgc -s "infographic list-row-simple-horizontal-arrow
|
|
17
17
|
data
|
|
18
18
|
title My First Infographic
|
|
19
19
|
items
|
|
20
20
|
- label Step 1
|
|
21
|
-
- label Step 2
|
|
21
|
+
- label Step 2" -o output.svg
|
|
22
22
|
|
|
23
23
|
# Render from file
|
|
24
24
|
ifgc -i input.ifgc -o output.svg
|
|
@@ -40,6 +40,13 @@ This installs two commands: `ifgc` (short) and `infographic` (long).
|
|
|
40
40
|
### Basic Rendering
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
+
# From string (quickest for testing)
|
|
44
|
+
ifgc -s "infographic list-row-simple-horizontal-arrow
|
|
45
|
+
data
|
|
46
|
+
title My Chart
|
|
47
|
+
items
|
|
48
|
+
- label Item 1" -o output.svg
|
|
49
|
+
|
|
43
50
|
# From file (output defaults to input.svg)
|
|
44
51
|
ifgc -i input.ifgc
|
|
45
52
|
|
|
@@ -57,7 +64,8 @@ cat input.ifgc | ifgc -o output.svg
|
|
|
57
64
|
|
|
58
65
|
| Option | Description |
|
|
59
66
|
|--------|-------------|
|
|
60
|
-
| `-
|
|
67
|
+
| `-s, --string <content>` | Input .ifgc content as a string |
|
|
68
|
+
| `-i, --input <file>` | Input .ifgc file |
|
|
61
69
|
| `-o, --output <file>` | Output file (default: input.svg) |
|
|
62
70
|
| `--background <color>` | Background color (default: transparent) |
|
|
63
71
|
| `-c, --config <file>` | JSON configuration file |
|
package/dist/commands/render.js
CHANGED
|
@@ -4,9 +4,13 @@ import { error, info, success } from '../utils/error.js';
|
|
|
4
4
|
import { getInputData } from '../utils/input.js';
|
|
5
5
|
import { getDefaultOutput, writeOutput } from '../utils/output.js';
|
|
6
6
|
export async function renderCommand(options) {
|
|
7
|
-
const { input, output: userOutput, quiet, config: configFile, theme, } = options;
|
|
7
|
+
const { input, string: stringInput, output: userOutput, quiet, config: configFile, theme, } = options;
|
|
8
8
|
const log = quiet ? () => { } : info;
|
|
9
|
-
// Validate input
|
|
9
|
+
// Validate input - cannot use both input file and string
|
|
10
|
+
if (input && stringInput) {
|
|
11
|
+
error('Cannot use both --input and --string options. Please use one.');
|
|
12
|
+
}
|
|
13
|
+
// Validate input file exists
|
|
10
14
|
if (input && input !== '-') {
|
|
11
15
|
try {
|
|
12
16
|
await fs.access(input);
|
|
@@ -39,7 +43,14 @@ export async function renderCommand(options) {
|
|
|
39
43
|
output = '/dev/stdout';
|
|
40
44
|
}
|
|
41
45
|
// Read input data
|
|
42
|
-
|
|
46
|
+
let inputData;
|
|
47
|
+
if (stringInput) {
|
|
48
|
+
// Convert \n to actual newlines and unescape other escape sequences
|
|
49
|
+
inputData = stringInput.replace(/\\n/g, '\n').replace(/\\t/g, '\t');
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
inputData = await getInputData(input && input !== '-' ? input : undefined);
|
|
53
|
+
}
|
|
43
54
|
if (!inputData.trim()) {
|
|
44
55
|
error('No input data provided');
|
|
45
56
|
}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ program
|
|
|
14
14
|
// Main options (render by default, like mmdc)
|
|
15
15
|
program
|
|
16
16
|
.option('-i, --input <file>', 'Input .ifgc file (omit to read from stdin)')
|
|
17
|
+
.option('-s, --string <content>', 'Input .ifgc content as a string (use \\n for newlines)')
|
|
17
18
|
.option('-o, --output <file>', 'Output file (default: input file with .svg extension)')
|
|
18
19
|
.option('--background <color>', 'Background color (default: transparent)', 'transparent')
|
|
19
20
|
.option('-c, --config <file>', 'JSON configuration file')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "infographic-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Instantly create stunning SVG infographics from simple declarative syntax. Render from strings, files, or stdin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "lyw405",
|
|
7
7
|
"type": "module",
|
|
@@ -50,8 +50,16 @@
|
|
|
50
50
|
],
|
|
51
51
|
"keywords": [
|
|
52
52
|
"infographic",
|
|
53
|
+
"infographics",
|
|
53
54
|
"cli",
|
|
55
|
+
"svg",
|
|
56
|
+
"generator",
|
|
54
57
|
"visualization",
|
|
55
|
-
"
|
|
58
|
+
"charts",
|
|
59
|
+
"diagrams",
|
|
60
|
+
"antv",
|
|
61
|
+
"templates",
|
|
62
|
+
"graphics",
|
|
63
|
+
"command-line"
|
|
56
64
|
]
|
|
57
65
|
}
|