Skip to content

Commit 165a81e

Browse files
feat(generator/orama-db): clean implementaiton
1 parent c824195 commit 165a81e

File tree

3 files changed

+46
-26
lines changed

3 files changed

+46
-26
lines changed

package-lock.json

+37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
"prettier": "3.5.2"
3434
},
3535
"dependencies": {
36-
"acorn": "^8.14.0",
3736
"@actions/core": "^1.11.1",
37+
"@orama/orama": "^3.1.3",
38+
"@orama/plugin-data-persistence": "^3.1.3",
39+
"acorn": "^8.14.0",
3840
"commander": "^13.1.0",
39-
"estree-util-visit": "^2.0.0",
4041
"dedent": "^1.5.3",
42+
"estree-util-visit": "^2.0.0",
4143
"github-slugger": "^2.0.0",
4244
"glob": "^11.0.1",
4345
"hast-util-to-string": "^3.0.1",

src/generators/orama-db/index.mjs

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
'use strict';
22

3-
import { writeFile } from 'node:fs/promises';
4-
import { join } from 'node:path';
53
import { create } from '@orama/orama';
4+
import { persistToFile } from '@orama/plugin-data-persistence/server';
65
import { groupNodesByModule } from '../../utils/generators.mjs';
76
import { createSectionBuilder } from '../legacy-json/utils/buildSection.mjs';
87

@@ -29,7 +28,7 @@ export default {
2928
* @param {Input} input
3029
* @param {Partial<GeneratorOptions>} options
3130
*/
32-
async generate(input, { output }) {
31+
async generate(input) {
3332
const buildSection = createSectionBuilder();
3433

3534
// Create the Orama instance with the schema
@@ -83,27 +82,9 @@ export default {
8382
return section;
8483
};
8584

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');
10788

10889
return db;
10990
},

0 commit comments

Comments
 (0)