@nova-infra/d2c-cli 1.0.0 → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +118 -0
  2. package/dist/cli.js +42 -42
  3. package/package.json +4 -1
package/README.md ADDED
@@ -0,0 +1,118 @@
1
+ # @nova-infra/d2c-cli (nova-d2c)
2
+
3
+ Agent-Friendly Figma 设计提取 CLI。
4
+
5
+ 从 Figma 提取平台无关的设计数据(节点、组件、变量、样式、布局树)以及图片资源,供 AI Agent 驱动的 D2C 工作流使用。
6
+
7
+ 官网与文档:
8
+
9
+ - 官网:https://nova-d2c.pages.dev
10
+ - 文档:https://nova-d2c.pages.dev/docs
11
+ - npmjs:https://www.npmjs.com/package/@nova-infra/d2c-cli
12
+
13
+ ## 安装
14
+
15
+ ```bash
16
+ npm install -g @nova-infra/d2c-cli
17
+ ```
18
+
19
+ ## 配置 Figma Token
20
+
21
+ 从 https://figma.com/developers 获取 Personal Access Token。
22
+
23
+ 推荐设置为全局环境变量(zsh):
24
+
25
+ ```bash
26
+ echo 'export FIGMA_TOKEN=figd_your_token_here' >> ~/.zshrc && source ~/.zshrc
27
+ ```
28
+
29
+ 也可以在命令行里用 `--token` 显式传入。
30
+
31
+ ## 快速开始
32
+
33
+ ```bash
34
+ # 1) 检查环境
35
+ nova-d2c doctor
36
+
37
+ # 2) 发现结构(推荐入口)
38
+ nova-d2c explore "https://www.figma.com/design/xxx"
39
+
40
+ # 3) 提取设计数据
41
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2
42
+
43
+ # 4) 导出图片资源
44
+ nova-d2c images "https://www.figma.com/design/xxx" --node-id 1:2 --output ./assets
45
+ ```
46
+
47
+ ## 命令
48
+
49
+ ### doctor
50
+
51
+ 检查 Token、API 连通性与缓存状态。
52
+
53
+ ```bash
54
+ nova-d2c doctor
55
+ ```
56
+
57
+ ### explore <figma-url>
58
+
59
+ 分析文件结构并输出推荐节点与后续建议命令。
60
+
61
+ ```bash
62
+ nova-d2c explore "https://www.figma.com/design/xxx"
63
+ ```
64
+
65
+ ### get <figma-url>
66
+
67
+ 提取设计数据。
68
+
69
+ 常用示例:
70
+
71
+ ```bash
72
+ # 提取指定节点
73
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2
74
+
75
+ # 过滤输出
76
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --only components
77
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --only variables
78
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --only styles
79
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --only tree
80
+
81
+ # 内联解析后的样式(减少下游 join 成本)
82
+ nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --resolved
83
+ ```
84
+
85
+ ### images <figma-url>
86
+
87
+ 从指定节点导出 PNG/SVG 图片资源。
88
+
89
+ ```bash
90
+ nova-d2c images "https://www.figma.com/design/xxx" \
91
+ --node-id 1:2,3:4 \
92
+ --output assets/ \
93
+ --image-format png \
94
+ --scale 2
95
+ ```
96
+
97
+ ## 选项速查
98
+
99
+ | 选项 | 说明 |
100
+ |------|------|
101
+ | `--node-id` | 节点 ID,逗号分隔 |
102
+ | `--only` | `pages` `components` `variables` `styles` `tree` `resolved` |
103
+ | `--format` | `yaml` `json` `md` `compact` |
104
+ | `--depth` | 节点遍历深度 |
105
+ | `--resolved` | `--only resolved` 的快捷方式 |
106
+ | `--output` | 写入文件路径 |
107
+ | `--no-cache` | 跳过缓存,强制重新获取 |
108
+ | `--token` | 显式传 Figma Token |
109
+ | `--image-format` | `png` 或 `svg` |
110
+ | `--scale` | PNG 缩放倍率 |
111
+
112
+ ## 缓存
113
+
114
+ `get` 会将首次提取结果缓存约 5 分钟,后续使用 `--only` 切不同视图时不会重复请求 Figma API。
115
+
116
+ ## License
117
+
118
+ MIT