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

Function buildManifestFromLocation

packages/cli/src/utils/build.ts:32–63  ·  view source on GitHub ↗
(location: string, log: (...args: any[]) => void)

Source from the content-addressed store, hash-verified

30}
31
32export async function buildManifestFromLocation(location: string, log: (...args: any[]) => void): Promise<string> {
33 let directory: string;
34 let projectManifestEntry: string;
35 // lstatSync will throw if location not exist
36 if (lstatSync(location).isDirectory()) {
37 directory = location;
38 projectManifestEntry = path.join(directory, DEFAULT_TS_MANIFEST);
39 } else if (lstatSync(location).isFile()) {
40 directory = path.dirname(location);
41 projectManifestEntry = location;
42 } else {
43 throw new Error('Argument `location` is not a valid directory or file');
44 }
45
46 // We compile from TypeScript every time, even if the current YAML file exists, to ensure that the YAML file remains up-to-date with the latest changes
47 try {
48 //we could have a multichain yaml with ts projects inside it
49 const projectYamlPath = projectManifestEntry.endsWith('.ts')
50 ? await generateManifestFromTs(projectManifestEntry)
51 : projectManifestEntry;
52
53 if (isMultichain(projectYamlPath)) {
54 const tsManifests = getTsManifestsFromMultichain(projectYamlPath);
55 await Promise.all(tsManifests.map((manifest) => generateManifestFromTs(manifest)));
56 replaceTsReferencesInMultichain(projectYamlPath);
57 }
58 } catch (e: any) {
59 console.log(e);
60 throw new Error(`Failed to generate manifest from typescript ${projectManifestEntry}, ${e.message}`);
61 }
62 return directory;
63}
64
65export async function buildTsManifest(location: string, log: (...args: any[]) => void): Promise<void> {
66 const tsManifest = getTsManifest(location);

Callers 4

build.spec.tsFile · 0.90
codegenAdapterFunction · 0.90
generateAdapterFunction · 0.90
buildTsManifestFunction · 0.85

Calls 6

isMultichainFunction · 0.90
generateManifestFromTsFunction · 0.85
mapMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected