( workingDir: string, args: CodegenInputs, logger: Logger )
| 20 | const codegenOutputs = z.void(); |
| 21 | |
| 22 | export 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 | |
| 58 | export default class Codegen extends Command { |
| 59 | static description = 'Generate entity types from the GraphQL schema and contract interfaces'; |
no test coverage detected