feat: run Velum project jobs in the background and process DOCX locally
This commit is contained in:
26
scripts/build-project-worker.mjs
Normal file
26
scripts/build-project-worker.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
import { copyFile, mkdir } from "node:fs/promises";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { join, resolve } from "node:path";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const root = fileURLToPath(new URL("..", import.meta.url));
|
||||
const server = process.env.VELUM_BACKEND_DIR ?? join(root, "../../velum/backend");
|
||||
const assets = join(root, "assets");
|
||||
const python = join(assets, "velum-docx", "velum");
|
||||
await mkdir(join(python, "assets"), { recursive: true });
|
||||
const files = ["documents.py", "docx_local.py", "office_images.py", "contexts.py", "assets/image-placeholder.png"];
|
||||
for (const file of files) {
|
||||
try {
|
||||
await copyFile(join(server, "velum", file), join(python, file));
|
||||
} catch (error) {
|
||||
throw new Error(`Velum-Backend-Quellen fehlen unter ${server}. Setze VELUM_BACKEND_DIR auf das backend-Verzeichnis des Velum-Checkouts.`, { cause: error });
|
||||
}
|
||||
}
|
||||
await build({
|
||||
entryPoints: [join(root, "src/project-worker.ts")],
|
||||
outfile: join(assets, "velum-project-worker.cjs"),
|
||||
platform: "node",
|
||||
target: "node22",
|
||||
bundle: true,
|
||||
alias: { "@raycast/api": resolve(root, "src/lib/worker-runtime.ts") },
|
||||
});
|
||||
Reference in New Issue
Block a user