Skip to content

Commit 11fcb75

Browse files
authored
Merge pull request #2440 from trycompai/main
[comp] Production Deploy
2 parents d772cac + 1bde775 commit 11fcb75

6 files changed

Lines changed: 78 additions & 36 deletions

.github/workflows/trigger-api-tasks-deploy-main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ jobs:
3737
- name: Build DB package
3838
working-directory: ./packages/db
3939
run: bun run build
40-
- name: Copy model files to api schema dir and generate client
40+
- name: Copy model files to api schema dir
4141
working-directory: ./apps/api
4242
run: |
4343
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
44-
bunx prisma generate --schema=prisma/schema
4544
- name: 🚀 Deploy Trigger.dev
4645
working-directory: ./apps/api
4746
timeout-minutes: 20

.github/workflows/trigger-api-tasks-deploy-release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,10 @@ jobs:
4343
working-directory: ./packages/db
4444
run: bun run build
4545

46-
- name: Copy model files to api schema dir and generate client
46+
- name: Copy model files to api schema dir
4747
working-directory: ./apps/api
4848
run: |
4949
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
50-
bunx prisma generate --schema=prisma/schema
5150
5251
- name: 🚀 Deploy Trigger.dev
5352
working-directory: ./apps/api

.github/workflows/trigger-tasks-deploy-main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ jobs:
3333
- name: Build Integration Platform package
3434
working-directory: ./packages/integration-platform
3535
run: bun run build
36-
- name: Copy schema to app and generate client
37-
working-directory: ./apps/app
36+
- name: Generate Prisma clients
3837
run: |
39-
mkdir -p prisma/schema
38+
cd packages/db && node scripts/generate-prisma-client-js.js
39+
cd ../..
40+
cd apps/app && mkdir -p prisma/schema
4041
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
4142
bunx prisma generate --schema=prisma/schema
4243
- name: 🚀 Deploy Trigger.dev

.github/workflows/trigger-tasks-deploy-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ jobs:
3939
working-directory: ./packages/integration-platform
4040
run: bun run build
4141

42-
- name: Copy schema to app and generate client
43-
working-directory: ./apps/app
42+
- name: Generate Prisma clients
4443
run: |
45-
mkdir -p prisma/schema
44+
cd packages/db && node scripts/generate-prisma-client-js.js
45+
cd ../..
46+
cd apps/app && mkdir -p prisma/schema
4647
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
4748
bunx prisma generate --schema=prisma/schema
4849

apps/api/customPrismaExtension.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,31 +283,52 @@ export class PrismaExtension implements BuildExtension {
283283
}
284284

285285
private buildSchemaCandidates(context: ExtendedBuildContext): string[] {
286-
const candidates = new Set<string>();
287-
288-
const addNodeModuleCandidates = (start: string | undefined) => {
289-
if (!start) {
290-
return;
286+
const candidates: string[] = [];
287+
const seen = new Set<string>();
288+
const add = (p: string) => {
289+
const resolved = resolve(p);
290+
if (!seen.has(resolved)) {
291+
seen.add(resolved);
292+
candidates.push(resolved);
291293
}
294+
};
295+
296+
// Strategy 1: Resolve @trycompai/db via Node module resolution (follows workspace symlinks)
297+
try {
298+
const dbPkgJson = require.resolve('@trycompai/db/package.json', {
299+
paths: [context.workingDir],
300+
});
301+
const dbRoot = dirname(dbPkgJson);
302+
add(join(dbRoot, 'dist', 'schema.prisma'));
303+
add(join(dbRoot, 'prisma', 'schema', 'schema.prisma'));
304+
} catch {
305+
// Package not resolvable yet (pre-install), fall through to other strategies
306+
}
292307

308+
// Strategy 2: Walk up node_modules hierarchy from workingDir and workspaceDir
309+
const addNodeModuleCandidates = (start: string | undefined) => {
310+
if (!start) return;
293311
let current = start;
294312
while (true) {
295-
candidates.add(resolve(current, 'node_modules/@trycompai/db/dist/schema.prisma'));
313+
const dbDir = resolve(current, 'node_modules', '@trycompai', 'db');
314+
add(join(dbDir, 'dist', 'schema.prisma'));
315+
add(join(dbDir, 'prisma', 'schema', 'schema.prisma'));
296316
const parent = dirname(current);
297-
if (parent === current) {
298-
break;
299-
}
317+
if (parent === current) break;
300318
current = parent;
301319
}
302320
};
303-
304321
addNodeModuleCandidates(context.workingDir);
305322
addNodeModuleCandidates(context.workspaceDir);
306323

307-
candidates.add(resolve(context.workingDir, '../../packages/db/dist/schema.prisma'));
308-
candidates.add(resolve(context.workingDir, '../packages/db/dist/schema.prisma'));
324+
// Strategy 3: Relative monorepo paths (apps/api → packages/db, apps/app → packages/db)
325+
for (const rel of ['../../packages/db', '../packages/db']) {
326+
const dbDir = resolve(context.workingDir, rel);
327+
add(join(dbDir, 'dist', 'schema.prisma'));
328+
add(join(dbDir, 'prisma', 'schema', 'schema.prisma'));
329+
}
309330

310-
return Array.from(candidates);
331+
return candidates;
311332
}
312333
}
313334

apps/app/customPrismaExtension.ts

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,30 +283,51 @@ export class PrismaExtension implements BuildExtension {
283283
}
284284

285285
private buildSchemaCandidates(context: ExtendedBuildContext): string[] {
286-
const candidates = new Set<string>();
287-
288-
const addNodeModuleCandidates = (start: string | undefined) => {
289-
if (!start) {
290-
return;
286+
const candidates: string[] = [];
287+
const seen = new Set<string>();
288+
const add = (p: string) => {
289+
const resolved = resolve(p);
290+
if (!seen.has(resolved)) {
291+
seen.add(resolved);
292+
candidates.push(resolved);
291293
}
294+
};
295+
296+
// Strategy 1: Resolve @trycompai/db via Node module resolution (follows workspace symlinks)
297+
try {
298+
const dbPkgJson = require.resolve('@trycompai/db/package.json', {
299+
paths: [context.workingDir],
300+
});
301+
const dbRoot = dirname(dbPkgJson);
302+
add(join(dbRoot, 'dist', 'schema.prisma'));
303+
add(join(dbRoot, 'prisma', 'schema', 'schema.prisma'));
304+
} catch {
305+
// Package not resolvable yet (pre-install), fall through to other strategies
306+
}
292307

308+
// Strategy 2: Walk up node_modules hierarchy from workingDir and workspaceDir
309+
const addNodeModuleCandidates = (start: string | undefined) => {
310+
if (!start) return;
293311
let current = start;
294312
while (true) {
295-
candidates.add(resolve(current, 'node_modules/@trycompai/db/dist/schema.prisma'));
313+
const dbDir = resolve(current, 'node_modules', '@trycompai', 'db');
314+
add(join(dbDir, 'dist', 'schema.prisma'));
315+
add(join(dbDir, 'prisma', 'schema', 'schema.prisma'));
296316
const parent = dirname(current);
297-
if (parent === current) {
298-
break;
299-
}
317+
if (parent === current) break;
300318
current = parent;
301319
}
302320
};
303-
304321
addNodeModuleCandidates(context.workingDir);
305322
addNodeModuleCandidates(context.workspaceDir);
306323

307-
candidates.add(resolve(context.workingDir, '../../packages/db/dist/schema.prisma'));
308-
candidates.add(resolve(context.workingDir, '../packages/db/dist/schema.prisma'));
324+
// Strategy 3: Relative monorepo paths (apps/api → packages/db, apps/app → packages/db)
325+
for (const rel of ['../../packages/db', '../packages/db']) {
326+
const dbDir = resolve(context.workingDir, rel);
327+
add(join(dbDir, 'dist', 'schema.prisma'));
328+
add(join(dbDir, 'prisma', 'schema', 'schema.prisma'));
329+
}
309330

310-
return Array.from(candidates);
331+
return candidates;
311332
}
312333
}

0 commit comments

Comments
 (0)