MCPcopy
hub / github.com/subquery/subql / prepareProjectScaffold

Function prepareProjectScaffold

packages/cli/src/controller/init-controller.ts:366–387  ·  view source on GitHub ↗
(projectPath: string)

Source from the content-addressed store, hash-verified

364}
365
366export 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
389async function prepareProjectScaffoldTS(defaultTsPath: string): Promise<void> {
390 const manifest = await fs.promises.readFile(defaultTsPath, 'utf8');

Callers

nothing calls this directly

Calls 5

prepareDirPathFunction · 0.90
defaultTSManifestPathFunction · 0.90
defaultYamlManifestPathFunction · 0.90
prepareProjectScaffoldTSFunction · 0.85

Tested by

no test coverage detected