Skip to content

Commit

Permalink
fix: bundle paths
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Apr 24, 2024
1 parent 64a53e1 commit 593f1f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
10 changes: 5 additions & 5 deletions src/build/plan/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function planProjectBuild(
description: "_gen/output.js",
async build({ signal }) {
const gen = resolve(project.path, "_gen");
const bundledFile = resolve(gen, "/output.js");
const bundledFile = resolve(gen, "output.js");

await esbuild.build({
entryPoints: [resolve(gen, "entrypoint.ts")],
Expand Down Expand Up @@ -167,7 +167,7 @@ export async function planProjectBuild(
module.path,
"_gen",
"prisma",
"query-engine.wasm",
"query_engine_bg.wasm",
);

if (await exists(moduleWasmPath)) {
Expand All @@ -180,11 +180,11 @@ export async function planProjectBuild(
if (wasmPath) {
// Make wasm import relative
bundleStr = bundleStr.replaceAll(
/file:[\w\\/\.\-]+query-engine\.wasm/g,
/file:[\w\\/\.\-]+query_engine_bg\.wasm/g,
"query-engine.wasm",
);
} else if (/"[\w\\/\.\-]+query-engine\.wasm/.test(bundleStr)) {
throw new InternalError("Failed to find required query-engine.wasm", { path: bundledFile });
} else if (/file:[\w\\/\.\-]+query_engine_bg\.wasm/.test(bundleStr)) {
throw new InternalError("Failed to find required query_engine_bg.wasm", { path: bundledFile });
}

signal.throwIfAborted();
Expand Down
24 changes: 5 additions & 19 deletions src/migrate/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,6 @@ async function ensurePrismaWorkspaceInner(project: Project): Promise<void> {
throw new CommandError("Failed to install prisma dependencies.", { commandOutput: installOutput });
}

// Fix permissions on the repo
const chownOutput2 = await new Deno.Command("docker", {
args: [
"exec",
NODE_CONTAINER_NAME,
// ===
"chown",
"-R",
`${Deno.uid()}:${Deno.gid()}`,
"/prisma",
],
}).output();
if (!chownOutput2.success) throw new CommandError("Failed to fix permissions.", { commandOutput: chownOutput2 });

verbose("Prisma workspace init complete", prismaDir);
}
/**
Expand Down Expand Up @@ -162,7 +148,7 @@ export interface RunPrismaCommandOpts {
* We don't use `deno run npm:prisma` because:
*
* - We already have Prisma installed in the workspace
* - There are minor bugs with Deno's compatability with Prisma
* - There are minor bugs with Deno's compatibility with Prisma
*/

export async function runPrismaCommand(
Expand All @@ -185,13 +171,13 @@ export async function runPrismaCommand(
// Unique isolated folder for this command to run in. This runs in the Prisma
// workspace where Prisma is already installed.
const prismaDir = getPrismaDir(project);
const worksapceId = crypto.randomUUID();
const dbDirHost = resolve(prismaDir, "db", worksapceId);
const workspaceId = crypto.randomUUID();
const dbDirHost = resolve(prismaDir, "db", workspaceId);
await Deno.mkdir(dbDirHost, { recursive: true });
verbose("Setting up Prisma command dir", dbDirHost);

// Force POSIX paths since this is in a Docker container.
const dbDirContainer = `/prisma/db/${worksapceId}`;
const dbDirContainer = `/prisma/db/${workspaceId}`;

// Copy database
await copy(resolve(module.path, "db"), dbDirHost, { overwrite: true });
Expand All @@ -209,7 +195,7 @@ export async function runPrismaCommand(
`;
await Deno.writeTextFile(schemaPath, schema);

// HACK: Replace the host with the Docker gateway. This isn't a failsave solution.
// HACK: Replace the host with the Docker gateway. This isn't a failsafe solution.
if (opts.env.DATABASE_URL) {
opts.env.DATABASE_URL = opts.env.DATABASE_URL
.replace("localhost", "host.docker.internal")
Expand Down

0 comments on commit 593f1f4

Please sign in to comment.