@promptui-lib/cli 0.1.11 → 0.1.12

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.
@@ -16,6 +16,10 @@ export declare function generateCommand(input: string, options: IGenerateOptions
16
16
  /**
17
17
  * Gera todos os componentes marcados com # no arquivo Figma
18
18
  * Se --all for passado, exporta todos os frames de nível superior
19
+ *
20
+ * A geração respeita a hierarquia:
21
+ * 1. Primeiro gera os componentes folha (sem # filhos)
22
+ * 2. Depois gera os componentes pai (que importam os filhos)
19
23
  */
20
24
  export declare function generateAllCommand(options: IGenerateOptions): Promise<void>;
21
25
  //# sourceMappingURL=generate.cmd.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.cmd.d.ts","sourceRoot":"","sources":["../../src/commands/generate.cmd.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAapF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AA0ED,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAqJf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkGjF"}
1
+ {"version":3,"file":"generate.cmd.d.ts","sourceRoot":"","sources":["../../src/commands/generate.cmd.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAapF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AA0ED,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAqJf;AAyBD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiHjF"}
@@ -185,9 +185,27 @@ export async function generateCommand(input, options) {
185
185
  process.exit(1);
186
186
  }
187
187
  }
188
+ /**
189
+ * Verifica se um node tem filhos marcados com #
190
+ */
191
+ function hasExportableChildren(node) {
192
+ if (!node.children)
193
+ return false;
194
+ for (const child of node.children) {
195
+ if (child.name.startsWith('#'))
196
+ return true;
197
+ if (hasExportableChildren(child))
198
+ return true;
199
+ }
200
+ return false;
201
+ }
188
202
  /**
189
203
  * Gera todos os componentes marcados com # no arquivo Figma
190
204
  * Se --all for passado, exporta todos os frames de nível superior
205
+ *
206
+ * A geração respeita a hierarquia:
207
+ * 1. Primeiro gera os componentes folha (sem # filhos)
208
+ * 2. Depois gera os componentes pai (que importam os filhos)
191
209
  */
192
210
  export async function generateAllCommand(options) {
193
211
  const exportAll = options.all;
@@ -212,20 +230,20 @@ export async function generateAllCommand(options) {
212
230
  try {
213
231
  const client = createFigmaClient({ token: resolved.figmaToken });
214
232
  const file = await client.getFile(resolved.figmaFileId);
215
- // Encontra todos os nodes exportáveis
233
+ // Encontra todos os nodes exportáveis com informação de profundidade
216
234
  const exportableNodes = [];
217
- function findExportable(node, depth = 0) {
235
+ function findExportable(node, depth = 0, parentId) {
218
236
  // Se --all, exporta frames de nível superior (depth <= 2 = document > page > frame)
219
237
  // Se não, apenas os que começam com #
220
238
  const isTopLevelFrame = depth === 2 && (node.type === 'FRAME' || node.type === 'COMPONENT');
221
239
  const isMarkedForExport = node.name.startsWith('#');
222
240
  if (exportAll ? isTopLevelFrame : isMarkedForExport) {
223
- exportableNodes.push(node);
241
+ exportableNodes.push({ node, depth, parentId });
224
242
  }
225
243
  // Continua buscando em profundidade (para encontrar # em qualquer nível)
226
244
  if (node.children) {
227
245
  for (const child of node.children) {
228
- findExportable(child, depth + 1);
246
+ findExportable(child, depth + 1, isMarkedForExport ? node.id : parentId);
229
247
  }
230
248
  }
231
249
  }
@@ -243,9 +261,18 @@ export async function generateAllCommand(options) {
243
261
  }
244
262
  return;
245
263
  }
264
+ // Ordena por profundidade decrescente (folhas primeiro, pais depois)
265
+ // Isso garante que componentes filhos sejam gerados antes dos pais
266
+ exportableNodes.sort((a, b) => b.depth - a.depth);
267
+ console.log('[PromptUI] Generation order (leaves first):');
268
+ for (const { node } of exportableNodes) {
269
+ const hasChildren = hasExportableChildren(node);
270
+ console.log(` ${hasChildren ? '📦' : '🍃'} ${node.name}`);
271
+ }
272
+ console.log('');
246
273
  let successCount = 0;
247
274
  let errorCount = 0;
248
- for (const node of exportableNodes) {
275
+ for (const { node } of exportableNodes) {
249
276
  try {
250
277
  const ast = parseNode(node, { forceLayer: options.layer });
251
278
  const basePath = options.output ?? resolved.outputBasePath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptui-lib/cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "private": false,
5
5
  "description": "CLI for PromptUI - Figma to React code generator",
6
6
  "license": "UNLICENSED",
@@ -45,10 +45,10 @@
45
45
  "bin"
46
46
  ],
47
47
  "dependencies": {
48
- "@promptui-lib/core": "0.1.11",
49
- "@promptui-lib/figma-parser": "0.1.11",
50
- "@promptui-lib/codegen": "0.1.11",
51
- "@promptui-lib/mcp-agent": "0.1.11"
48
+ "@promptui-lib/core": "0.1.12",
49
+ "@promptui-lib/figma-parser": "0.1.12",
50
+ "@promptui-lib/codegen": "0.1.12",
51
+ "@promptui-lib/mcp-agent": "0.1.12"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^20.0.0",