import { IPluginAPI } from 'build-scripts' ; import ReactGenerator from './ReactGenerator' ; import RaxGenerator from './RaxGenerator' ; import { IGeneratorOptions , IGenerateResult } from '../types' ; function generatePageFiles ( api , options ) { const { framework , pageEntry , isAppEntry } = options ; let generator ; if ( framework === 'react' ) { generator = new ReactGenerator ( api , options ) ; } else if ( framework === 'rax' ) { generator = new RaxGenerator ( api , options ) ; } const { context : { userConfig } } = api ; const generateTasks = [ ] ; generateTasks . push ( ( ) => { generator . generateRunAppFile ( userConfig ) ; } ) ; if ( isAppEntry ) { return { generator , generateTasks , entryPath : pageEntry , runAppPath : generator . runAppPath , routesFilePath : generator . routesFilePath , } ; } generateTasks . push ( ( ) => { generator . generateEntryFile ( ) ; } ) ; return { generator , generateTasks , entryPath : generator . entryPath , runAppPath : generator . runAppPath , routesFilePath : generator . routesFilePath , } ; } export default generatePageFiles ;