Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/cli/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const devCommand = async () => {
consola.error(
"Revert your schema change, fix the issue, and restart with `edgepod dev`.",
);
await cleanup();
cleanup();
process.exit(1);
} finally {
isMigrating = false;
Expand All @@ -81,11 +81,11 @@ export const devCommand = async () => {
);
}

const cleanup = async () => {
const cleanup = () => {
consola.info("Shutting down EdgePod dev server...");
if (debounceTimer) clearTimeout(debounceTimer);
if (watcher) {
await watcher.close();
watcher.close().catch(() => {});
watcher = null;
}
wrangler.kill("SIGTERM", { forceKillAfterTimeout: 5000 });
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/migrations/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ async function loadJson<T>(filePath: string, fallback: () => T): Promise<T> {
}
}

const indentJson = (value: unknown) =>
JSON.stringify(value, null, 2)
.split("\n")
.map((line, i) => (i === 0 ? line : ` ${line}`))
.join("\n");

async function writeMigrationsIndex(
outputDir: string,
journal: Journal,
Expand All @@ -59,14 +65,14 @@ async function writeMigrationsIndex(
.map((e) => {
const key = `m${String(e.idx).padStart(4, "0")}`;
const sql = sqlContents.get(e.tag) ?? "";
return ` ${JSON.stringify(key)}: ${JSON.stringify(sql)},`;
return ` ${JSON.stringify(key)}: ${JSON.stringify(sql)},`;
})
.join("\n");

const content = `// This file is auto-generated by EdgePod CLI. Do not edit manually.

export default {
journal: ${JSON.stringify(journal, null, 2)},
journal: ${indentJson(journal)},
migrations: {
${migrationsObj}
},
Expand Down
8 changes: 7 additions & 1 deletion packages/client/src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ export function edgepod(): Plugin {

return {
name: "edgepod",
apply: "serve",
configureServer: (server: ViteDevServer) => {
edgepodProcess = spawn("edgepod", ["dev"], { stdio: "inherit" });
edgepodProcess = spawn("edgepod", ["dev"], {
stdio: ["ignore", "pipe", "pipe"],
});

edgepodProcess.stdout?.pipe(process.stdout);
edgepodProcess.stderr?.pipe(process.stderr);

edgepodProcess.on("error", (err) => {
console.error(
Expand Down
4 changes: 3 additions & 1 deletion packages/server/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export const edgePodFetch = async (
{
success: true,
data: result.data,
_meta: { t: hashMetaTableNames(result.meta.read) },
_meta: {
t: hashMetaTableNames([...new Set([...result.meta.read, ...result.meta.changed])]),
},
...(result.warnings.length > 0 ? { warnings: result.warnings } : {}),
},
{ headers: serverHeader },
Expand Down
11 changes: 1 addition & 10 deletions playground/edgepod/.generated/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
{
"entries": [
{
"idx": 0,
"tag": "0000_migration",
"when": 1778523638396,
"breakpoints": true
}
]
}
{ "entries": [{ "idx": 0, "tag": "0000_migration", "when": 1778523638396, "breakpoints": true }] }
4 changes: 2 additions & 2 deletions playground/edgepod/.generated/migrations/snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@
"internal": {
"indexes": {}
},
"id": "b96f8c1a-c44e-4c15-9714-e51803012fbc",
"prevId": "00000000-0000-0000-0000-000000000000"
"id": "51d054f7-7a4e-4830-bd71-2c27c90ae836",
"prevId": "3a25f9ad-a8af-436c-8672-d159a998baa3"
}