import path from 'path' ; import { GeneratorContext , GeneratorCore } from '@modern-js/codesmith' ; import { AppAPI } from '@modern-js/codesmith-api-app' ; import { DependenceGenerator , i18n } from '@modern-js/generator-common' ; const getGeneratorPath = ( generator , distTag ) => { if ( process . env . CODESMITH_ENV === 'development' ) { return path . dirname ( require . resolve ( generator ) ) ; } else if ( distTag ) { return `${ generator }@${ distTag }` ; } return generator ; } ; const handleTemplateFile = async ( context , generator , appApi ) => { await appApi . runSubGenerator ( getGeneratorPath ( DependenceGenerator , context . config . distTag ) , undefined , { ... context . config , dependencies : { ... ( context . config . dependencies || { } ) , tailwindcss : `^2.2.19` , } , } ) ; } ; export default async ( context , generator ) => { const appApi = new AppAPI ( context , generator ) ; const { locale } = context . config ; i18n . changeLanguage ( { locale } ) ; appApi . i18n . changeLanguage ( { locale } ) ; if ( ! ( await appApi . checkEnvironment ( ) ) ) { process . exit ( 1 ) ; } generator . logger . debug ( `start run @modern-js/tailwindcss-generator` ) ; generator . logger . debug ( `context=${ JSON . stringify ( context ) }` ) ; generator . logger . debug ( `context.data=${ JSON . stringify ( context . data ) }` ) ; await handleTemplateFile ( context , generator , appApi ) ; generator . logger . debug ( `forge @modern-js/tailwindcss-generator succeed ` ) ; } ;