11import getDatabaseName from '#common/getDatabaseName' ;
22import getMetadata from '#common/getMetadata' ;
3+ import { CE_MERMAID_THEME } from '#configs/const-enum/CE_MERMAID_THEME' ;
34import { CE_OUTPUT_FORMAT } from '#configs/const-enum/CE_OUTPUT_FORMAT' ;
45import type IBuildCommandOption from '#configs/interfaces/IBuildCommandOption' ;
56import createHtml from '#creators/createHtml' ;
@@ -33,6 +34,8 @@ export default async function buildDocumentCommandHandler(option: IBuildCommandO
3334 let localDataSource : DataSource | undefined ;
3435
3536 try {
37+ consola . info ( `connection initialize: "${ chalk . yellowBright ( `${ option . dataSourcePath } ` ) } "` ) ;
38+
3639 const dataSource = await getDataSource ( option ) ;
3740 await dataSource . initialize ( ) ;
3841
@@ -45,10 +48,11 @@ export default async function buildDocumentCommandHandler(option: IBuildCommandO
4548
4649 const metadata = await getMetadata ( dataSource , option ) ;
4750
48- consola . info ( `connection initialize: "${ chalk . yellowBright ( `${ option . dataSourcePath } ` ) } "` ) ;
49- consola . info ( `extract entities in ${ getDatabaseName ( dataSource . options ) } ` ) ;
51+ consola . success ( 'connection initialized' ) ;
5052 consola . info ( `version: ${ metadata . version } ` ) ;
5153
54+ consola . info ( `extract entities in ${ getDatabaseName ( dataSource . options ) } ` ) ;
55+
5256 const entities = getEntityRecords ( dataSource , metadata ) ;
5357 const columns = dataSource . entityMetadatas
5458 . map ( ( entity ) => entity . columns . map ( ( column ) => getColumnRecord ( column , option , metadata ) ) )
@@ -69,6 +73,10 @@ export default async function buildDocumentCommandHandler(option: IBuildCommandO
6973
7074 const dedupedRelations = dedupeManaToManyRelationRecord ( passRelations ) ;
7175 const records = [ ...entities , ...columns , ...dedupedRelations ] ;
76+
77+ consola . success ( 'complete extraction' ) ;
78+ consola . info ( 'Database open and processing' ) ;
79+
7280 const db = await openDatabase ( option ) ;
7381 const processedDb = await processDatabase ( metadata , db , option ) ;
7482 const compared = compareDatabase ( metadata , records , processedDb . prev ) ;
@@ -77,12 +85,23 @@ export default async function buildDocumentCommandHandler(option: IBuildCommandO
7785 const renderData = await getRenderData ( nextDb , metadata , option ) ;
7886
7987 await flushDatabase ( option , nextDb ) ;
88+ consola . success ( 'Database open and processing completed' ) ;
8089
8190 consola . info ( `output format: ${ option . format } ` ) ;
8291
8392 if ( option . format === CE_OUTPUT_FORMAT . HTML ) {
93+ const imageOption : IBuildCommandOption = {
94+ ...option ,
95+ format : CE_OUTPUT_FORMAT . IMAGE ,
96+ imageFormat : 'svg' ,
97+ theme : CE_MERMAID_THEME . DARK ,
98+ } ;
8499 const documents = await createHtml ( option , renderData ) ;
100+ const imageDocument = await createImageHtml ( imageOption , renderData ) ;
101+
102+ await writeToImage ( imageDocument , imageOption , renderData ) ;
85103 await Promise . all ( documents . map ( ( document ) => fs . promises . writeFile ( document . filename , document . content ) ) ) ;
104+
86105 return documents . map ( ( document ) => document . filename ) ;
87106 }
88107
0 commit comments