import { writeFileSync } from "fs" ; import { resolve } from "path" ; import formatToStyleDictionary from "./format-sd" ; import globalColorRefs , { ColorT } from "./global-color-ref" ; import parseName from "./parse-name" ; type FigmaColorsT = { [ key ] : string ; } ; const parseColors = async ( figmaColors ) => { const colors = Object . entries ( figmaColors ) . map ( ( [ key , value ] ) => ( { name : parseName ( key ) , color : value } ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) . reverse ( ) ; const colorsWithRef = globalColorRefs ( colors ) . reduce ( ( old , color ) => ( { [ color . name ] : color . color , ... old } ) , { } ) ; const styleDictionaryFormat = formatToStyleDictionary ( colorsWithRef , "color" ) ; writeFileSync ( resolve ( "./src/colors.json" ) , JSON . stringify ( styleDictionaryFormat , null , 2 ) ) ; } ; export default parseColors ;