-
Notifications
You must be signed in to change notification settings - Fork 52
run fast store #1099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
run fast store #1099
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,11 +17,18 @@ import { | |||||||||
| import { grep, type GrepResult } from "./grep.ts"; | ||||||||||
|
|
||||||||||
| const inferMetadata = async (filepath: string): Promise<Metadata | null> => { | ||||||||||
| return { kind: "file" }; | ||||||||||
|
|
||||||||||
|
Comment on lines
19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 20 unconditionally returns Proposed fix const inferMetadata = async (filepath: string): Promise<Metadata | null> => {
- return { kind: "file" };
-
try {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| try { | ||||||||||
| console.log("filepath", filepath) | ||||||||||
| const { __resolveType, name, path } = JSON.parse( | ||||||||||
| await Deno.readTextFile(filepath), | ||||||||||
| ); | ||||||||||
| console.log("__resolveType", __resolveType) | ||||||||||
| console.log("name", name) | ||||||||||
| console.log("path", path) | ||||||||||
| const blockType = await inferBlockType(__resolveType); | ||||||||||
| console.log("blockType", blockType) | ||||||||||
|
|
||||||||||
| if (!blockType) { | ||||||||||
| return { kind: "file" }; | ||||||||||
|
|
@@ -43,6 +50,7 @@ const inferMetadata = async (filepath: string): Promise<Metadata | null> => { | |||||||||
| __resolveType, | ||||||||||
| }; | ||||||||||
| } catch (error) { | ||||||||||
| console.log("error", error) | ||||||||||
| if (error instanceof Deno.errors.NotFound) { | ||||||||||
| return null; | ||||||||||
| } | ||||||||||
|
|
@@ -102,10 +110,25 @@ export interface GrepAPI { | |||||||||
| response: GrepResult; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const shouldIgnore = (path: string) => | ||||||||||
| basename(path) !== ".gitignore" && | ||||||||||
| path.includes(`${SEPARATOR}.git`) || | ||||||||||
| path.includes(`${SEPARATOR}node_modules${SEPARATOR}`); | ||||||||||
| const shouldIgnore = (path: string) => { | ||||||||||
| if (basename(path) === ".gitignore") { | ||||||||||
| return false; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Check if path contains these directories anywhere in the path | ||||||||||
| const ignoredDirs = [ | ||||||||||
| '.git', | ||||||||||
| 'node_modules', | ||||||||||
| '.next', | ||||||||||
| '.faststore', | ||||||||||
| 'dist', | ||||||||||
| 'build', | ||||||||||
| '.turbo' | ||||||||||
| ]; | ||||||||||
|
|
||||||||||
| const pathSegments = path.split(SEPARATOR); | ||||||||||
| return ignoredDirs.some(dir => pathSegments.includes(dir)); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| const systemPathFromBrowser = (pathAndQuery: string) => { | ||||||||||
| const [url] = pathAndQuery.split("?"); | ||||||||||
|
|
@@ -120,37 +143,62 @@ const browserPathFromSystem = (filepath: string) => | |||||||||
|
|
||||||||||
| export async function* start(since: number): AsyncIterableIterator<FSEvent> { | ||||||||||
| try { | ||||||||||
| // Handle invalid since values (NaN, undefined, etc.) | ||||||||||
| const sinceTimestamp = Number.isFinite(since) ? since : 0; | ||||||||||
| console.log("[watchFS.start] Starting file walk, since:", since, "-> normalized:", sinceTimestamp); | ||||||||||
| const walker = walk(Deno.cwd(), { includeDirs: false, includeFiles: true }); | ||||||||||
| let fileCount = 0; | ||||||||||
| let skippedCount = 0; | ||||||||||
| let processedCount = 0; | ||||||||||
|
|
||||||||||
| for await (const entry of walker) { | ||||||||||
| processedCount++; | ||||||||||
|
|
||||||||||
| if (shouldIgnore(entry.path)) { | ||||||||||
| skippedCount++; | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
| console.log("entry", entry) | ||||||||||
|
|
||||||||||
| const [metadata, mtime] = await Promise.all([ | ||||||||||
| inferMetadata(entry.path), | ||||||||||
| mtimeFor(entry.path), | ||||||||||
| ]); | ||||||||||
| console.log("metadata", metadata); | ||||||||||
| console.log("mtime", mtime) | ||||||||||
|
Comment on lines
+161
to
+168
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove or gate hot-loop debug logs in filesystem scan. Lines 161/167/168 log per file and will heavily impact large repos; this should be behind Proposed fix (verbose-gated logs)- console.log("entry", entry)
+ if (VERBOSE) console.log("[watchFS.start] entry", entry.path);
@@
- console.log("metadata", metadata);
- console.log("mtime", mtime)
+ if (VERBOSE) {
+ console.log("[watchFS.start] metadata/mtime", { path: entry.path, metadata, mtime });
+ }
@@
- console.log(`[watchFS.start] File walk complete! Processed: ${processedCount}, Sent: ${fileCount}, Skipped: ${skippedCount}`);
- console.log("[watchFS.start] Sending fs-snapshot event...");
+ if (VERBOSE) {
+ console.log(`[watchFS.start] File walk complete! Processed: ${processedCount}, Sent: ${fileCount}, Skipped: ${skippedCount}`);
+ console.log("[watchFS.start] Sending fs-snapshot event...");
+ }
@@
- console.log("[watchFS.start] ✅ fs-snapshot event sent successfully");
+ if (VERBOSE) console.log("[watchFS.start] ✅ fs-snapshot event sent successfully");Also applies to: 191-193, 199-201 🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| if ( | ||||||||||
| !metadata || mtime < since | ||||||||||
| ) { | ||||||||||
| if (!metadata) { | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (mtime < sinceTimestamp) { | ||||||||||
| continue; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const filepath = browserPathFromSystem(entry.path); | ||||||||||
| fileCount++; | ||||||||||
|
|
||||||||||
| if (fileCount % 100 === 0) { | ||||||||||
| console.log(`[watchFS.start] Progress: ${fileCount} files sent, ${processedCount} processed, ${skippedCount} skipped`); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| yield { | ||||||||||
| type: "fs-sync", | ||||||||||
| detail: { metadata, filepath, timestamp: mtime }, | ||||||||||
| }; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| console.log(`[watchFS.start] File walk complete! Processed: ${processedCount}, Sent: ${fileCount}, Skipped: ${skippedCount}`); | ||||||||||
| console.log("[watchFS.start] Sending fs-snapshot event..."); | ||||||||||
|
|
||||||||||
| yield { | ||||||||||
| type: "fs-snapshot", | ||||||||||
| detail: { timestamp: Date.now(), status: await git.status() }, | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| console.log("[watchFS.start] ✅ fs-snapshot event sent successfully"); | ||||||||||
| } catch (error) { | ||||||||||
| console.error(error); | ||||||||||
| console.error("[watchFS.start] ❌ Error during file walk:", error); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,6 +27,7 @@ import { activityMonitor, createIdleHandler } from "./monitor.ts"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { register } from "./tunnel.ts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createWorker, type WorkerOptions } from "./worker.ts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { portPool } from "./workers/portpool.ts"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { exists } from "@std/fs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const parsedArgs = parseArgs(Deno.args, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| string: ["build-cmd"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -118,6 +119,25 @@ globalThis.addEventListener("unhandledrejection", (e: { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("unhandled rejection at:", e.promise, "reason:", e.reason); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ProjectType = "faststore" | "fresh" | "hono"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const detectProjectType = async (): Promise<ProjectType> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJsonPath = join(Deno.cwd(), "package.json"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (await exists(packageJsonPath)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJson = JSON.parse(await Deno.readTextFile(packageJsonPath)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (packageJson.dependencies?.["@faststore/cli"]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "faststore"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Could add more Node.js framework detection here (e.g., Hono) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "fresh"; // Default to Fresh for Deno projects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Project-type detection is too narrow for FastStore installs. Line 129 only checks Proposed fix const detectProjectType = async (): Promise<ProjectType> => {
try {
const packageJsonPath = join(Deno.cwd(), "package.json");
if (await exists(packageJsonPath)) {
const packageJson = JSON.parse(await Deno.readTextFile(packageJsonPath));
- if (packageJson.dependencies?.["@faststore/cli"]) {
+ const deps = {
+ ...packageJson.dependencies,
+ ...packageJson.devDependencies,
+ };
+ if (deps?.["@faststore/cli"]) {
return "faststore";
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("Error detecting project type, defaulting to fresh:", error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "fresh"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createBundler = (appName?: string) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const bundler = bundleApp(Deno.cwd()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -221,7 +241,7 @@ const watch = async () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createDeps = (): MiddlewareHandler => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createDeps = (projectType: ProjectType): MiddlewareHandler => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let ok: Promise<unknown> | null | false = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const start = async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -234,33 +254,48 @@ const createDeps = (): MiddlewareHandler => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| }ms`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start = performance.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await genManifestTS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${colors.bold("[step 2/4]")}: Manifest generation took ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (performance.now() - start).toFixed(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }ms`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only run Fresh-specific operations for Fresh projects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (projectType === "fresh") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start = performance.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await genManifestTS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${colors.bold("[step 2/4]")}: Manifest generation took ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (performance.now() - start).toFixed(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }ms`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start = performance.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await genBlocksJSON(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${colors.bold("[step 3/4]")}: Blocks metadata generation took ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (performance.now() - start).toFixed(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }ms`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watchMeta().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await genManifestTS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${colors.bold("[step 2/4]")}: Skipped Fresh-specific operations (FastStore project)`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start = performance.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await genBlocksJSON(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // watchFS is needed for all project types (sends events to admin) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watchFS().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${colors.bold("[step 3/4]")}: Blocks metadata generation took ${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (performance.now() - start).toFixed(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }ms`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: colors.green("File system watcher started"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watch().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watchMeta().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| watchFS().catch(console.error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `${ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| colors.bold("[step 4/4]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: Started file watcher in background`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: Initialization complete`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -277,6 +312,9 @@ const createDeps = (): MiddlewareHandler => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Detect project type early for configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const PROJECT_TYPE = await detectProjectType(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const app = new Hono(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (VERBOSE) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -306,7 +344,7 @@ app.get("/deco/_is_idle", createIdleHandler(DECO_SITE_NAME!, DECO_ENV_NAME!)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.get("/deco/_liveness", () => new Response("OK", { status: 200 })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Globals are started after healthcheck to ensure k8s does not kill the pod before it is ready | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.use(createDeps()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.use(createDeps(PROJECT_TYPE)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.use(activityMonitor); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // These are the APIs that communicate with admin UI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.use(createDaemonAPIs({ build: buildCmd, site: DECO_SITE_NAME })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -337,6 +375,58 @@ if (createRunCmd) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.route("", createWorker(createWorkerOptions)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // No explicit run command, create appropriate worker based on detected type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (PROJECT_TYPE === "faststore") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: colors.green("Detected FastStore project, starting Node.js worker..."), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // FastStore/Next.js runs on port 3000 by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const FASTSTORE_PORT = 3000; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const createFastStoreWorkerOptions = async (): Promise<WorkerOptions> => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJsonPath = join(Deno.cwd(), "package.json"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageJson = JSON.parse(await Deno.readTextFile(packageJsonPath)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Detect package manager | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasYarnLock = await exists(join(Deno.cwd(), "yarn.lock")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const hasPnpmLock = await exists(join(Deno.cwd(), "pnpm-lock.yaml")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const packageManager = hasPnpmLock ? "pnpm" : hasYarnLock ? "yarn" : "npm"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Use volta-specified node version if available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nodeVersion = packageJson.volta?.node; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (nodeVersion) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: `Using Node.js ${nodeVersion} from Volta configuration`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| logs.push({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| level: "info", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: colors.blue(`FastStore worker will run on port ${FASTSTORE_PORT}`), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| command: new Deno.Command(packageManager, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args: ["run", "dev"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cwd: Deno.cwd(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stdout: "piped", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stderr: "piped", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| env: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PORT: `${FASTSTORE_PORT}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NODE_ENV: "development", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| port: FASTSTORE_PORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| persist, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app.route("", createWorker(createFastStoreWorkerOptions)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const LOCAL_STORAGE_ENV_NAME = "deco_host_env_name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: The early return makes the rest of inferMetadata unreachable, so block metadata is never inferred. Remove the unconditional return so the try/catch executes.
Prompt for AI agents