Skip to content

Commit e3cc574

Browse files
committed
Documentation nodes are now written to the file system as same as the code nodes so that they can be uploaded like them only
1 parent 4aeaf98 commit e3cc574

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

ingestion/src/main.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { exec } from "child_process"
22
import { v4 as uuid } from "uuid"
33

4+
import { REPO_URI } from "./constants"
45
import { Documentation } from "./process/documentation/documentation"
6+
import { insertDataIntoDB } from "./process/ingest/ingest"
7+
import { Codebase } from "./process/prepare/codebase"
8+
import { FileProcessor } from "./process/prepare/processor/file"
59

610
namespace Algorithms {
711
export async function execCommand(command: string) {
@@ -24,16 +28,17 @@ namespace Algorithms {
2428
async function main() {
2529
const sessionID = uuid()
2630

27-
// await Algorithms.execCommand(`git clone ${REPO_URI} ${sessionID}`)
28-
// {
29-
// const codebase = new Codebase(sessionID, new FileProcessor(), 1)
30-
// await codebase.process()
31-
// await insertDataIntoDB(codebase.dataDirPath)
32-
// }
33-
// await Algorithms.execCommand(`rm -rf ${sessionID}`)
31+
await Algorithms.execCommand(`git clone ${REPO_URI} ${sessionID}`)
32+
{
33+
const codebase = new Codebase(sessionID, new FileProcessor(), 1)
34+
await codebase.process()
3435

35-
const docs = new Documentation()
36-
await docs.prepare()
36+
const docs = new Documentation()
37+
await docs.prepare(codebase.dataDirPath)
38+
39+
await insertDataIntoDB(codebase.dataDirPath)
40+
}
41+
await Algorithms.execCommand(`rm -rf ${sessionID}`)
3742
}
3843

3944
main()

ingestion/src/process/documentation/documentation.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { writeFileSync } from "fs"
21
import puppeteer from "puppeteer"
32

3+
import { writeFile } from "fs/promises"
44
import { DOCUMENTATION_URL } from "../../constants"
55
import { DevDocDBNode } from "../../core/devDocsDBNode"
66
import { IDocumentation } from "./documentation.types"
@@ -54,8 +54,14 @@ export class Documentation implements IDocumentation {
5454
return flattenedNodes
5555
}
5656

57-
async prepare() {
57+
async prepare(dataDirPath: string) {
5858
const nodes = await this.prepareDevDocsNodes()
59-
writeFileSync("nodes.json", JSON.stringify(nodes, null, 3))
59+
60+
const jobs = []
61+
for (const node of nodes) {
62+
jobs.push(
63+
writeFile(`${dataDirPath}/docs-${node.id}.json`, JSON.stringify(node))
64+
)
65+
}
6066
}
6167
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export interface IDocumentation {
2-
prepare(): Promise<void>
2+
prepare(dataDirPath: string): Promise<void>
33
}

0 commit comments

Comments
 (0)