import { checkTheme , findSource , assignConfig } from '../utils/check' ; import { compileCatalog , compileMarkdown , copyTheme , copyInlineHtml , copyAssets } from '../compile' ; import File from '../utils/file' ; import Log from '../utils/log' ; import Filter from '../utils/filter' ; import { resolve } from 'path' ; const removeDir = async ( dir ) => { await File . exists ( dir ) && await File . exec ( `rm -rf ${ dir }` ) ; } ; ( async ( ) => { const root = Filter . path ( `${ __dirname }/../..` ) ; const templateTargetPath = `${ root }/templates/target` ; const templateTempPath = `${ root }/templates/temp` ; Log . time . start ( 'check config' ) ; const source = await findSource ( process . cwd ( ) ) ; const config = await assignConfig ( source ) ; Log . time . over ( ) ; const targetPath = `${ resolve ( ) }/${ config . output }` ; const catalogs = await compileCatalog ( config ) ; await compileMarkdown ( catalogs , source ) ; Log . time . start ( 'generative assets' ) ; await removeDir ( templateTargetPath ) ; await checkTheme ( config ) ; await copyTheme ( config ) ; await copyAssets ( config ) ; Log . time . over ( ) ; await File . exec ( `cp -r ${ templateTempPath }/ ${ templateTargetPath }` ) ; await removeDir ( templateTempPath ) ; await copyInlineHtml ( config , catalogs ) ; Log . time . start ( 'clear up' ) ; await removeDir ( targetPath ) ; await File . exec ( `cp -R ${ templateTargetPath }/ ${ targetPath }/` ) ; Log . time . over ( ) ; } ) ( ) ;