MCPcopy
hub / github.com/freshframework/fresh / flush

Method flush

packages/fresh/src/dev/dev_build_cache.ts:308–408  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

306 }
307
308 async flush(): Promise<void> {
309 const { staticDir: staticDirs, outDir, target, root } = this.#config;
310
311 const seen = new Set<string>();
312
313 for (const staticDir of staticDirs) {
314 if (!(await fsAdapter.isDirectory(staticDir))) continue;
315
316 const entries = fsAdapter.walk(staticDir, {
317 includeDirs: false,
318 includeFiles: true,
319 followSymlinks: false,
320 // Skip any folder or file starting with a ".", but allow
321 // ".well-known" for things like PWA manifests
322 skip: [/\/\.(?!well-known)[^/]+(\/|$)/],
323 });
324
325 for await (const entry of entries) {
326 // OutDir might be inside static dir
327 if (!path.relative(outDir, entry.path).startsWith("..")) {
328 continue;
329 }
330
331 const result = await this.#transformer.process(
332 entry.path,
333 "production",
334 target,
335 );
336
337 if (result !== null) {
338 for (let i = 0; i < result.length; i++) {
339 const file = result[i];
340 assertInDir(file.path, staticDir);
341 const pathname = `/${path.relative(staticDir, file.path)}`;
342 if (!seen.has(pathname)) {
343 seen.add(pathname);
344 await this.addProcessedFile(pathname, file.content, null);
345 }
346 }
347 } else {
348 const relative = path.relative(staticDir, entry.path);
349 const pathname = `/${relative}`;
350 if (!seen.has(pathname)) {
351 seen.add(pathname);
352 this.addUnprocessedFile(pathname, staticDir);
353 }
354 }
355 }
356 }
357
358 const staticFiles: PendingStaticFile[] = [];
359 for (const [name, filePath] of this.#unprocessedFiles.entries()) {
360 staticFiles.push({ filePath, pathname: name, hash: null });
361 }
362
363 for (const [name, maybeHash] of this.#processedFiles.entries()) {
364 // Ignore esbuild meta file. It's not intended for serving
365 if (name === "/metafile.json") {

Callers

nothing calls this directly

Calls 13

addProcessedFileMethod · 0.95
addUnprocessedFileMethod · 0.95
assertInDirFunction · 0.90
pathToSpecFunction · 0.90
generateSnapshotServerFunction · 0.85
getClientEntryFunction · 0.85
generateServerEntryFunction · 0.85
toPosixFunction · 0.85
writeCompiledEntryFunction · 0.85
isDirectoryMethod · 0.80
walkMethod · 0.80
processMethod · 0.80

Tested by

no test coverage detected