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

Function getBuildEntries

packages/cli/src/controller/build-controller.ts:153–190  ·  view source on GitHub ↗
(directory: string, logger?: Logger)

Source from the content-addressed store, hash-verified

151}
152
153export function getBuildEntries(directory: string, logger?: Logger): Record<string, string> {
154 // FIXME: this is an assumption that the default entry is src/index.ts, in reality it should read from the project manifest
155 const defaultEntry = path.join(directory, 'src/index.ts');
156 let buildEntries: Record<string, string> = {
157 index: defaultEntry,
158 };
159
160 globSync(path.join(directory, 'src/test/**/*.test.ts')).forEach((testFile) => {
161 const testName = path.basename(testFile).replace('.ts', '');
162 buildEntries[`test/${testName}`] = testFile;
163 });
164
165 globSync(path.join(directory, 'src/tests/**/*.test.ts')).forEach((testFile) => {
166 const testName = path.basename(testFile).replace('.ts', '');
167 buildEntries[`tests/${testName}`] = testFile;
168 });
169
170 // Get the output location from the project package.json main field
171 const pjson = JSON.parse(readFileSync(path.join(directory, 'package.json')).toString());
172 if (pjson.exports && typeof pjson.exports !== 'string') {
173 buildEntries = Object.entries(pjson.exports as Record<string, string>).reduce(
174 (acc, [key, value]) => {
175 acc[key] = path.resolve(directory, value);
176 return acc;
177 },
178 {...buildEntries}
179 );
180 }
181
182 for (const i in buildEntries) {
183 if (typeof buildEntries[i] !== 'string') {
184 logger?.warn(`Ignoring entry ${i} from build.`);
185 delete buildEntries[i];
186 }
187 }
188
189 return buildEntries;
190}

Callers 2

buildAdapterFunction · 0.90

Calls 1

warnMethod · 0.45

Tested by

no test coverage detected