({
memoryName,
documentName,
overwrite
}: {
memoryName: string;
documentName: string;
overwrite: boolean;
})
| 24 | type Spinner = ReturnType<typeof p.spinner>; |
| 25 | |
| 26 | export async function deploySingleDocument({ |
| 27 | memoryName, |
| 28 | documentName, |
| 29 | overwrite |
| 30 | }: { |
| 31 | memoryName: string; |
| 32 | documentName: string; |
| 33 | overwrite: boolean; |
| 34 | }) { |
| 35 | p.intro(heading({ text: 'DEPLOY', sub: 'Deploy a document' })); |
| 36 | |
| 37 | const spinner = p.spinner(); |
| 38 | try { |
| 39 | const { validDocumentName, validMemoryName } = await isMemoryDocExist({ |
| 40 | spinner, |
| 41 | memoryName, |
| 42 | documentName |
| 43 | }); |
| 44 | |
| 45 | spinner.stop('Loaded docs'); |
| 46 | |
| 47 | await buildMemory({ memoryName: validMemoryName }); |
| 48 | const buildDir = path.join(process.cwd(), '.baseai'); |
| 49 | const memoryDir = path.join(buildDir, 'memory'); |
| 50 | |
| 51 | const account = await retrieveAuthentication({ spinner }); |
| 52 | if (!account) { |
| 53 | p.outro( |
| 54 | `No account found. Skipping deployment. \n Run: ${cyan('npx baseai@latest auth')}` |
| 55 | ); |
| 56 | process.exit(1); |
| 57 | } |
| 58 | |
| 59 | await deployDocument({ |
| 60 | account, |
| 61 | spinner, |
| 62 | memoryDir, |
| 63 | overwrite, |
| 64 | memoryName: validMemoryName, |
| 65 | documentName: validDocumentName |
| 66 | }); |
| 67 | |
| 68 | p.outro( |
| 69 | heading({ text: 'DEPLOYED', sub: 'successfully', green: true }) |
| 70 | ); |
| 71 | } catch (error) { |
| 72 | handleError({ |
| 73 | spinner, |
| 74 | message: 'An unexpected error occurred', |
| 75 | error |
| 76 | }); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | async function deployDocument({ |
| 81 | account, |
no test coverage detected