Skip to content

Commit 8636d2a

Browse files
authored
Merge pull request #37 from dev-five-git/add-devup
Add devup.json to exporting
2 parents c63d190 + 04ffed2 commit 8636d2a

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/commands/devup/export-devup.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ function isTextSearchNode(node: SceneNode): node is TextSearchNode {
2424
return 'findAllWithCriteria' in node
2525
}
2626

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

3537
const tColors = perfStart()
@@ -236,6 +238,16 @@ export async function exportDevup(
236238
)
237239
}
238240

241+
return devup
242+
}
243+
244+
export async function exportDevup(
245+
output: 'json' | 'excel',
246+
treeshaking: boolean = true,
247+
) {
248+
perfReset()
249+
const t = perfStart()
250+
const devup = await buildDevupConfig(treeshaking)
239251
perfEnd('exportDevup()', t)
240252
console.info(perfReport())
241253

src/commands/devup/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { exportDevup } from './export-devup'
1+
export { buildDevupConfig, exportDevup } from './export-devup'
22
export { importDevup } from './import-devup'

src/commands/exportPagesAndComponents.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { wrapComponent } from '../codegen/utils/wrap-component'
1717
import { getComponentName } from '../utils'
1818
import { downloadFile } from '../utils/download-file'
1919
import { toPascal } from '../utils/to-pascal'
20+
import { buildDevupConfig } from './devup'
2021

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

184+
// Fire devup config build early — runs in parallel with codegen
185+
const devupConfigPromise = buildDevupConfig()
186+
183187
// Reset global asset registry so buildTree() populates it fresh
184188
resetGlobalAssetNodes()
185189

@@ -341,6 +345,10 @@ export async function exportPagesAndComponents() {
341345
return
342346
}
343347

348+
// Await devup config (started in parallel with codegen) and add to ZIP
349+
const devupConfig = await devupConfigPromise
350+
zip.file('devup.json', JSON.stringify(devupConfig), ZIP_TEXT_FILE_OPTIONS)
351+
344352
// Asset nodes were already collected by Codegen's buildTree() into the
345353
// global registry — no need to re-walk the Figma node tree via IPC.
346354
const assetNodes = getGlobalAssetNodes()

0 commit comments

Comments
 (0)