({
account,
spinner,
overwrite,
memoryDir,
memoryName,
documentName
}: {
account: Account;
spinner: Spinner;
memoryDir: string;
overwrite: boolean;
memoryName: string;
documentName: string;
})
| 78 | } |
| 79 | |
| 80 | async function deployDocument({ |
| 81 | account, |
| 82 | spinner, |
| 83 | overwrite, |
| 84 | memoryDir, |
| 85 | memoryName, |
| 86 | documentName |
| 87 | }: { |
| 88 | account: Account; |
| 89 | spinner: Spinner; |
| 90 | memoryDir: string; |
| 91 | overwrite: boolean; |
| 92 | memoryName: string; |
| 93 | documentName: string; |
| 94 | }) { |
| 95 | const memoryPath = path.join(memoryDir, `${memoryName}.json`); |
| 96 | try { |
| 97 | const memoryContent = await fs.readFile(memoryPath, 'utf-8'); |
| 98 | const memoryObject = JSON.parse(memoryContent); |
| 99 | |
| 100 | if (!memoryObject) { |
| 101 | handleInvalidConfig({ spinner, name: memoryName, type: 'memory' }); |
| 102 | process.exit(1); |
| 103 | } |
| 104 | |
| 105 | p.log.step(`Processing ${documentName} of memory: ${memoryName}`); |
| 106 | const memoryDocs = await loadMemoryFiles(memoryName); |
| 107 | |
| 108 | const document = memoryDocs.find(doc => doc.name === documentName); |
| 109 | |
| 110 | if (!document) { |
| 111 | spinner.stop( |
| 112 | `Document ${documentName} not found in memory ${memoryName}` |
| 113 | ); |
| 114 | process.exit(1); |
| 115 | } |
| 116 | |
| 117 | await handleSingleDocDeploy({ |
| 118 | memory: memoryObject, |
| 119 | account, |
| 120 | document, |
| 121 | overwrite |
| 122 | }); |
| 123 | |
| 124 | spinner.stop( |
| 125 | `Finished processing document ${documentName} of memory ${memoryName}` |
| 126 | ); |
| 127 | } catch (error) { |
| 128 | handleDeploymentError({ |
| 129 | spinner, |
| 130 | name: memoryName, |
| 131 | error, |
| 132 | type: 'memory' |
| 133 | }); |
| 134 | process.exit(1); |
| 135 | } |
| 136 | } |
| 137 |
no test coverage detected