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

Function buildAdapter

packages/cli/src/commands/build.ts:25–53  ·  view source on GitHub ↗
(
  workingDir: string,
  args: BuildInputs,
  logger: Logger
)

Source from the content-addressed store, hash-verified

23const buildOutputs = z.void();
24
25export async function buildAdapter(
26 workingDir: string,
27 args: BuildInputs,
28 logger: Logger
29): Promise<z.infer<typeof buildOutputs>> {
30 const location = resolveToAbsolutePath(path.resolve(workingDir, args.location ?? ''));
31 assert(existsSync(location), 'Argument `location` is not a valid directory or file');
32
33 const directory = lstatSync(location).isDirectory() ? location : path.dirname(location);
34
35 await buildTsManifest(location, logger.info.bind(logger));
36
37 // Check that this is a SubQuery project
38 const projectSearch = path.resolve(
39 directory,
40 `./{project*.{yaml,yml},subquery-multichain.yaml${directory !== location ? `,${path.basename(location)}` : ''}}`
41 );
42 const manifests = await glob(projectSearch, {windowsPathsNoEscape: true});
43 if (!manifests.length) {
44 throw new Error(
45 'This is not a SubQuery project, please make sure you run this in the root of your project directory.'
46 );
47 }
48
49 const buildEntries = getBuildEntries(directory, logger);
50 const outputDir = path.resolve(directory, args.output);
51
52 await runBundle(buildEntries, directory, outputDir, false, true, logger);
53}
54
55export default class Build extends Command {
56 static description = 'Build this SubQuery project code into a bundle';

Callers 3

publishAdapterFunction · 0.90
runMethod · 0.85
registerBuildMCPToolFunction · 0.85

Calls 4

resolveToAbsolutePathFunction · 0.90
buildTsManifestFunction · 0.90
getBuildEntriesFunction · 0.90
runBundleFunction · 0.90

Tested by

no test coverage detected