infographic-cli 0.1.0 → 0.4.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 +3 -3
- package/README.md +27 -19
- package/dist/commands/render.js +14 -3
- package/dist/index.js +2 -1
- package/dist-types/commands/render.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,8 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
## [0.1.0] - 2025-01-20
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
|
-
- Initial release of
|
|
12
|
-
- Simple command `ifgc` to render infographics from .
|
|
11
|
+
- Initial release of `infographic-cli`
|
|
12
|
+
- Simple command `ifgc` to render infographics from .ifgc files to SVG
|
|
13
13
|
- Support for 236+ built-in infographic templates
|
|
14
14
|
- `template` command to list all available templates
|
|
15
15
|
- Theme support (`--theme` option)
|
|
@@ -19,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
19
|
- Comprehensive test suite (26 tests)
|
|
20
20
|
|
|
21
21
|
### Features
|
|
22
|
-
- Render from file: `ifgc -i input.
|
|
22
|
+
- Render from file: `ifgc -i input.ifgc -o output.svg`
|
|
23
23
|
- Render from stdin: `echo "..." | ifgc -o output.svg`
|
|
24
24
|
- List templates: `ifgc template`
|
|
25
25
|
- Automatic output file naming (defaults to input.svg)
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# infographic-cli
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/infographic-cli)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://www.npmjs.com/package/infographic-cli)
|
|
6
6
|
|
|
7
7
|
Command-line interface for [AntV Infographic](https://github.com/antvis/Infographic) - render declarative infographic syntax to SVG images.
|
|
8
8
|
|
|
@@ -10,18 +10,18 @@ Command-line interface for [AntV Infographic](https://github.com/antvis/Infograp
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# Install
|
|
13
|
-
npm install -g
|
|
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
|
-
ifgc -i input.
|
|
24
|
+
ifgc -i input.ifgc -o output.svg
|
|
25
25
|
|
|
26
26
|
# List available templates
|
|
27
27
|
ifgc template
|
|
@@ -30,7 +30,7 @@ ifgc template
|
|
|
30
30
|
## Installation
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
npm install -g
|
|
33
|
+
npm install -g infographic-cli
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
This installs two commands: `ifgc` (short) and `infographic` (long).
|
|
@@ -40,24 +40,32 @@ 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
|
-
ifgc -i input.
|
|
51
|
+
ifgc -i input.ifgc
|
|
45
52
|
|
|
46
53
|
# Specify output file
|
|
47
|
-
ifgc -i input.
|
|
54
|
+
ifgc -i input.ifgc -o output.svg
|
|
48
55
|
|
|
49
56
|
# From stdin
|
|
50
57
|
echo '...' | ifgc -o output.svg
|
|
51
58
|
|
|
52
59
|
# From stdin with file input
|
|
53
|
-
cat input.
|
|
60
|
+
cat input.ifgc | ifgc -o output.svg
|
|
54
61
|
```
|
|
55
62
|
|
|
56
63
|
### Options
|
|
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 |
|
|
@@ -77,7 +85,7 @@ Visit [AntV Infographic](https://github.com/antvis/Infographic) to see template
|
|
|
77
85
|
### Example 1: Simple Step List
|
|
78
86
|
|
|
79
87
|
```bash
|
|
80
|
-
cat > steps.
|
|
88
|
+
cat > steps.ifgc << EOF
|
|
81
89
|
infographic list-row-simple-horizontal-arrow
|
|
82
90
|
data
|
|
83
91
|
title Getting Started
|
|
@@ -91,13 +99,13 @@ data
|
|
|
91
99
|
desc Export and share
|
|
92
100
|
EOF
|
|
93
101
|
|
|
94
|
-
ifgc -i steps.
|
|
102
|
+
ifgc -i steps.ifgc -o steps.svg
|
|
95
103
|
```
|
|
96
104
|
|
|
97
105
|
### Example 2: Timeline
|
|
98
106
|
|
|
99
107
|
```bash
|
|
100
|
-
cat > timeline.
|
|
108
|
+
cat > timeline.ifgc << EOF
|
|
101
109
|
infographic timeline-horizontal-basic-date
|
|
102
110
|
data
|
|
103
111
|
title Project Roadmap
|
|
@@ -112,13 +120,13 @@ data
|
|
|
112
120
|
desc Launch
|
|
113
121
|
EOF
|
|
114
122
|
|
|
115
|
-
ifgc -i timeline.
|
|
123
|
+
ifgc -i timeline.ifgc -o timeline.svg
|
|
116
124
|
```
|
|
117
125
|
|
|
118
126
|
### Example 3: Using Theme
|
|
119
127
|
|
|
120
128
|
```bash
|
|
121
|
-
cat > swot.
|
|
129
|
+
cat > swot.ifgc << EOF
|
|
122
130
|
infographic compare-quadrant-four-areas-card
|
|
123
131
|
data
|
|
124
132
|
title SWOT Analysis
|
|
@@ -133,7 +141,7 @@ data
|
|
|
133
141
|
desc External risks
|
|
134
142
|
EOF
|
|
135
143
|
|
|
136
|
-
ifgc -i swot.
|
|
144
|
+
ifgc -i swot.ifgc -o swot.svg -t dark
|
|
137
145
|
```
|
|
138
146
|
|
|
139
147
|
### Example 4: From stdin
|
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
|
@@ -13,7 +13,8 @@ program
|
|
|
13
13
|
.version(packageJson.default.version);
|
|
14
14
|
// Main options (render by default, like mmdc)
|
|
15
15
|
program
|
|
16
|
-
.option('-i, --input <file>', 'Input .
|
|
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')
|