Skip to content

AI-native design editor. Open-source Figma alternative.

fix(cli): export fig documents by default

Danila Poyarkov5830b9f976b8
diff --git a/packages/cli/src/commands/export.ts b/packages/cli/src/commands/export.ts
index b3e65eb46..5caa0dc1b 100644
--- a/packages/cli/src/commands/export.ts
+++ b/packages/cli/src/commands/export.ts
@@ -81,7 +81,8 @@ function exportFileName(defaultName: string, extension: string, scale?: number):
return scale ? `${defaultName}@${scale}x.${extension}` : `${defaultName}.${extension}`
}
-function targetLabel(pageName?: string, nodeId?: string): string {
+function targetLabel(scope: 'document' | 'node' | 'page', pageName?: string, nodeId?: string): string {
+ if (scope === 'document') return 'document'
if (nodeId) return `node ${nodeId}`
return pageName ? `page "${pageName}"` : 'first page'
}
@@ -109,9 +110,17 @@ async function exportFromFile(format: string, args: ExportArgs) {
process.exit(1)
}
- const target = args.node
- ? { scope: 'node' as const, nodeId: args.node }
- : { scope: 'page' as const, pageId: page.id }
+ let target:
+ | { scope: 'document' }
+ | { scope: 'node'; nodeId: string }
+ | { scope: 'page'; pageId: string }
+ if (args.node) {
+ target = { scope: 'node', nodeId: args.node }
+ } else if (format === 'FIG' && !args.page) {
+ target = { scope: 'document' }
+ } else {
+ target = { scope: 'page', pageId: page.id }
+ }
if (args.thumbnail) {
printError('Thumbnail export is not supported by the shared file export path yet.')
@@ -140,7 +149,7 @@ async function exportFromFile(format: string, args: ExportArgs) {
)
)
await writeAndLog(output, result.data as string | Uint8Array)
- console.log(ok(`Target: ${targetLabel(args.page, args.node)}`))
+ console.log(ok(`Target: ${targetLabel(target.scope, args.page, args.node)}`))
}
export default defineCommand({