(projectPath: string)
| 364 | } |
| 365 | |
| 366 | export async function prepareProjectScaffold(projectPath: string): Promise<void> { |
| 367 | // remove all existing abis & handler files |
| 368 | await prepareDirPath(path.join(projectPath, 'abis/'), false); |
| 369 | await prepareDirPath(path.join(projectPath, 'src/mappings/'), true); |
| 370 | |
| 371 | const defaultTsPath = defaultTSManifestPath(projectPath); |
| 372 | |
| 373 | try { |
| 374 | // clean dataSources |
| 375 | if (fs.existsSync(defaultTsPath)) { |
| 376 | // ts check should be first |
| 377 | await prepareProjectScaffoldTS(defaultTsPath); |
| 378 | } else { |
| 379 | await prepareProjectScaffoldYAML(defaultYamlManifestPath(projectPath)); |
| 380 | } |
| 381 | } catch (e) { |
| 382 | throw new Error('Failed to prepare project scaffold'); |
| 383 | } |
| 384 | |
| 385 | // remove handler file from index.ts |
| 386 | fs.truncateSync(path.join(projectPath, 'src/index.ts'), 0); |
| 387 | } |
| 388 | |
| 389 | async function prepareProjectScaffoldTS(defaultTsPath: string): Promise<void> { |
| 390 | const manifest = await fs.promises.readFile(defaultTsPath, 'utf8'); |
nothing calls this directly
no test coverage detected