import Build from './Build' ; import { IBuildCode } from './types' ; export default class BuildCode extends Build implements IBuildCode { method createVariants ( ) { if ( this . theme . variants . length ) { this . theme . variants . forEach ( theme => { this . theme . final [ `${ theme . variant }.${ theme . fontStyle && typeof theme . fontStyle === 'string' ? `${ theme . fontStyle }.${ this . settings . fileType }` : this . settings . fileType }` ] = theme ; } ) ; } else { this . theme . final [ `${ this . theme . stage . variant }.${ this . settings . fileType }` ] = this . theme . stage ; } return 'created' ; } method setFontStyles ( ) { let theme = this . theme . stage ; if ( theme . fontStyle ) { Object . values ( theme . fontStyle ) . forEach ( ( fontStyle ) => { theme = { ... theme , tokenColors : theme . tokenColors . map ( ( token ) => ( { ... token , settings : { ... token . settings , fontStyle : fontStyle === 'none' ? '' : fontStyle , } , } ) ) , fontStyle : fontStyle === 'none' ? '' : fontStyle , } ; this . theme . variants . push ( theme ) ; } ) ; } return this ; } function param theme merge ( theme ) { this . theme . stage = theme ; this . setColors ( ) . setFontStyles ( ) . createVariants ( ) ; } method stage ( ) { this . listThemes . forEach ( themeName => { this . merge ( { ... this . getFile ( `${ this . rootDir . themes }/common/base.json` ) , ... this . getFile ( `${ this . rootDir . themes }/${ themeName }` ) , } ) ; } ) ; } method compile ( ) { this . stage ( ) ; if ( this . theme . final ) { Object . entries ( this . theme . final ) . map ( ( [ name , theme ] ) => this . createFile ( { path : this . rootDir . build , file : theme , fileName : name , } ) ) ; } return 'done' ; } }