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

Function codegenAdapter

packages/cli/src/commands/codegen/index.ts:22–56  ·  view source on GitHub ↗
(
  workingDir: string,
  args: CodegenInputs,
  logger: Logger
)

Source from the content-addressed store, hash-verified

20const codegenOutputs = z.void();
21
22export async function codegenAdapter(
23 workingDir: string,
24 args: CodegenInputs,
25 logger: Logger
26): Promise<z.infer<typeof codegenOutputs>> {
27 const location = resolveToAbsolutePath(path.resolve(workingDir, args.location ?? ''));
28 assert(existsSync(location), 'Argument `location` is not a valid directory or file');
29
30 /*
31 ts manifest can be either single chain ts manifest
32 or multichain ts manifest
33 or multichain yaml manifest containing single chain ts project paths
34 */
35 const tsManifest = getTsManifest(location);
36
37 if (tsManifest) {
38 await buildManifestFromLocation(tsManifest, logger.info.bind(logger));
39 }
40
41 const {manifests, root} = getProjectRootAndManifest(location);
42
43 let firstSchemaPath: string | null = null;
44
45 for (const manifest of manifests) {
46 const schemaPath = getSchemaPath(root, manifest);
47
48 if (firstSchemaPath === null) {
49 firstSchemaPath = schemaPath;
50 } else if (schemaPath !== firstSchemaPath) {
51 throw new Error('All schema paths are not the same');
52 }
53 }
54
55 await codegen(root, manifests);
56}
57
58export default class Codegen extends Command {
59 static description = 'Generate entity types from the GraphQL schema and contract interfaces';

Callers 2

runMethod · 0.85
registerCodegenMCPToolFunction · 0.85

Calls 6

resolveToAbsolutePathFunction · 0.90
getTsManifestFunction · 0.90
getSchemaPathFunction · 0.90
codegenFunction · 0.90

Tested by

no test coverage detected