MCPcopy Index your code
hub / github.com/BCsabaEngine/svelteesp32 / getCppCode

Function getCppCode

src/cppCode.ts:209–248  ·  view source on GitHub ↗
(
  sources: CppCodeSources,
  filesByExtension: ExtensionGroups,
  options: ICopyFilesArguments
)

Source from the content-addressed store, hash-verified

207 .replaceAll(/\n{2,}/g, '\n');
208
209export const getCppCode = (
210 sources: CppCodeSources,
211 filesByExtension: ExtensionGroups,
212 options: ICopyFilesArguments
213): string => {
214 const transformedSources = sources.map((s) => {
215 const effectiveCacheTime =
216 s.mime === 'text/html'
217 ? (options.cachetimeHtml ?? options.cachetime)
218 : (options.cachetimeAssets ?? options.cachetime);
219 return transformSourceToTemplateData(s, options.etag, effectiveCacheTime);
220 });
221 const spaSource = options.spa ? transformedSources.find((s) => s.isDefault) : undefined;
222 const routeCount = computeRouteCount(sources, options.engine, options.basePath, !!options.spa);
223 const templateData: TemplateData = {
224 config: formatConfig(options),
225 now: (() => {
226 const d = new Date();
227 return `${d.toLocaleDateString()} ${d.toLocaleTimeString()}`;
228 })(),
229 fileCount: sources.length.toString(),
230 fileSize: sources.reduce((previous, current) => previous + current.content.length, 0).toString(),
231 fileGzipSize: sources.reduce((previous, current) => previous + current.contentGzip.length, 0).toString(),
232 sources: transformedSources,
233 filesByExtension,
234 etag: options.etag,
235 gzip: options.gzip,
236 created: options.created,
237 version: options.version,
238 methodName: options.espmethod,
239 definePrefix: options.define,
240 basePath: options.basePath,
241 spa: !!options.spa,
242 spaSource,
243 isPsychic: options.engine === 'psychic',
244 uriHandlers: routeCount.toString(),
245 maxUriHandlers: (routeCount + 5).toString()
246 };
247 return postProcessCppCode(getGenerator(options.engine)(templateData));
248};

Callers 4

cppCode.test.tsFile · 0.90
runPipelineFunction · 0.90

Calls 5

formatConfigFunction · 0.90
computeRouteCountFunction · 0.85
postProcessCppCodeFunction · 0.85
getGeneratorFunction · 0.85

Tested by

no test coverage detected