Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/commands/devup/export-devup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ function isTextSearchNode(node: SceneNode): node is TextSearchNode {
return 'findAllWithCriteria' in node
}

export async function exportDevup(
output: 'json' | 'excel',
/**
* Build the Devup config object from the current Figma file.
* Extracts colors from Devup variable collection and typography from text styles.
* When treeshaking is enabled, only typography used in the document is included.
*/
export async function buildDevupConfig(
treeshaking: boolean = true,
) {
perfReset()
const t = perfStart()
): Promise<Devup> {
const devup: Devup = {}

const tColors = perfStart()
Expand Down Expand Up @@ -236,6 +238,16 @@ export async function exportDevup(
)
}

return devup
}

export async function exportDevup(
output: 'json' | 'excel',
treeshaking: boolean = true,
) {
perfReset()
const t = perfStart()
const devup = await buildDevupConfig(treeshaking)
perfEnd('exportDevup()', t)
console.info(perfReport())

Expand Down
2 changes: 1 addition & 1 deletion src/commands/devup/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { exportDevup } from './export-devup'
export { buildDevupConfig, exportDevup } from './export-devup'
export { importDevup } from './import-devup'
8 changes: 8 additions & 0 deletions src/commands/exportPagesAndComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { wrapComponent } from '../codegen/utils/wrap-component'
import { getComponentName } from '../utils'
import { downloadFile } from '../utils/download-file'
import { toPascal } from '../utils/to-pascal'
import { buildDevupConfig } from './devup'

const NOTIFY_TIMEOUT = 3000
// Figma throttles >4 concurrent exportAsync calls for large PNGs (screenshots).
Expand Down Expand Up @@ -180,6 +181,9 @@ export async function exportPagesAndComponents() {
// Deferred work collectors
const screenshotTargets: ScreenshotTarget[] = []

// Fire devup config build early — runs in parallel with codegen
const devupConfigPromise = buildDevupConfig()

// Reset global asset registry so buildTree() populates it fresh
resetGlobalAssetNodes()

Expand Down Expand Up @@ -341,6 +345,10 @@ export async function exportPagesAndComponents() {
return
}

// Await devup config (started in parallel with codegen) and add to ZIP
const devupConfig = await devupConfigPromise
zip.file('devup.json', JSON.stringify(devupConfig), ZIP_TEXT_FILE_OPTIONS)

// Asset nodes were already collected by Codegen's buildTree() into the
// global registry — no need to re-walk the Figma node tree via IPC.
const assetNodes = getGlobalAssetNodes()
Expand Down