1
1
'use strict' ;
2
2
3
- import { writeFile } from 'node:fs/promises' ;
4
- import { join } from 'node:path' ;
5
3
import { create } from '@orama/orama' ;
4
+ import { persistToFile } from '@orama/plugin-data-persistence/server' ;
6
5
import { groupNodesByModule } from '../../utils/generators.mjs' ;
7
6
import { createSectionBuilder } from '../legacy-json/utils/buildSection.mjs' ;
8
7
@@ -29,7 +28,7 @@ export default {
29
28
* @param {Input } input
30
29
* @param {Partial<GeneratorOptions> } options
31
30
*/
32
- async generate ( input , { output } ) {
31
+ async generate ( input ) {
33
32
const buildSection = createSectionBuilder ( ) ;
34
33
35
34
// Create the Orama instance with the schema
@@ -83,27 +82,9 @@ export default {
83
82
return section ;
84
83
} ;
85
84
86
- await Promise . all (
87
- headNodes . map ( async node => {
88
- // Get the json for the node's section
89
- const section = processModuleNodes ( node ) ;
90
-
91
- // Write it to the output file
92
- if ( output ) {
93
- await writeFile (
94
- join ( output , `${ node . api } .json` ) ,
95
- JSON . stringify ( section )
96
- ) ;
97
- }
98
- } )
99
- ) ;
100
-
101
- // Generate the JSON representation of the Orama db
102
- const oramaDbJson = JSON . stringify ( db ) ;
103
-
104
- if ( output ) {
105
- await writeFile ( join ( output , 'orama-db.json' ) , oramaDbJson ) ;
106
- }
85
+ headNodes . map ( processModuleNodes ) ;
86
+
87
+ await persistToFile ( db , 'json' , './db.json' ) ;
107
88
108
89
return db ;
109
90
} ,
0 commit comments