@friggframework/core 2.0.0--canary.454.25d396a.0 → 2.0.0--canary.461.84ff4f5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,25 @@ async function runPrismaGenerate(dbType, verbose = false) {
49
49
  try {
50
50
  const schemaPath = getPrismaSchemaPath(dbType);
51
51
 
52
+ // Check if Prisma client already exists (e.g., in Lambda or pre-generated)
53
+ const generatedClientPath = path.join(path.dirname(path.dirname(schemaPath)), 'generated', `prisma-${dbType}`, 'client.js');
54
+ const isLambdaEnvironment = !!process.env.AWS_LAMBDA_FUNCTION_NAME || !!process.env.LAMBDA_TASK_ROOT;
55
+
56
+ if (fs.existsSync(generatedClientPath)) {
57
+ if (verbose) {
58
+ console.log(chalk.gray(`✓ Prisma client already generated at: ${generatedClientPath}`));
59
+ }
60
+ if (isLambdaEnvironment) {
61
+ if (verbose) {
62
+ console.log(chalk.gray('Skipping generation in Lambda environment (using pre-generated client)'));
63
+ }
64
+ return {
65
+ success: true,
66
+ output: 'Using pre-generated Prisma client (Lambda environment)'
67
+ };
68
+ }
69
+ }
70
+
52
71
  if (verbose) {
53
72
  console.log(chalk.gray(`Running: npx prisma generate --schema=${schemaPath}`));
54
73
  }
@@ -128,6 +147,38 @@ async function checkDatabaseState(dbType) {
128
147
  }
129
148
  }
130
149
 
150
+ /**
151
+ * Get Prisma binary path for Lambda environment
152
+ * Checks multiple locations in priority order:
153
+ * 1. Function's bundled Prisma (/var/task/node_modules/.bin/prisma) - for standalone functions
154
+ * 2. Layer's Prisma (/opt/nodejs/node_modules/.bin/prisma) - for functions using Prisma layer with CLI
155
+ * 3. Fallback to npx for local development
156
+ */
157
+ function getPrismaBinaryPath() {
158
+ const fs = require('fs');
159
+ const isLambdaEnvironment = !!process.env.AWS_LAMBDA_FUNCTION_NAME || !!process.env.LAMBDA_TASK_ROOT;
160
+
161
+ if (!isLambdaEnvironment) {
162
+ return 'npx';
163
+ }
164
+
165
+ // Check function's own node_modules first (standalone dbMigrate)
166
+ const functionPrisma = '/var/task/node_modules/.bin/prisma';
167
+ if (fs.existsSync(functionPrisma)) {
168
+ return functionPrisma;
169
+ }
170
+
171
+ // Fall back to layer path (functions using Prisma layer with CLI)
172
+ const layerPrisma = '/opt/nodejs/node_modules/.bin/prisma';
173
+ if (fs.existsSync(layerPrisma)) {
174
+ return layerPrisma;
175
+ }
176
+
177
+ // Should not reach here in Lambda, but provide fallback
178
+ console.warn('⚠️ Prisma binary not found in expected Lambda paths, using npx');
179
+ return 'npx';
180
+ }
181
+
131
182
  /**
132
183
  * Runs Prisma migrate for PostgreSQL
133
184
  * @param {'dev'|'deploy'} command - Migration command (dev or deploy)
@@ -139,19 +190,26 @@ async function runPrismaMigrate(command = 'dev', verbose = false) {
139
190
  try {
140
191
  const schemaPath = getPrismaSchemaPath('postgresql');
141
192
 
142
- const args = [
143
- 'prisma',
144
- 'migrate',
145
- command,
146
- '--schema',
147
- schemaPath
148
- ];
193
+ // Get Prisma binary path (checks multiple locations)
194
+ const isLambdaEnvironment = !!process.env.AWS_LAMBDA_FUNCTION_NAME || !!process.env.LAMBDA_TASK_ROOT;
195
+ const prismaBin = getPrismaBinaryPath();
196
+
197
+ // Determine args based on whether we're using direct binary or npx
198
+ // Direct binary (e.g., /var/task/node_modules/.bin/prisma): ['migrate', command, ...]
199
+ // npx (local dev or fallback): ['prisma', 'migrate', command, ...]
200
+ const isDirectBinary = prismaBin !== 'npx';
201
+ const args = isDirectBinary
202
+ ? ['migrate', command, '--schema', schemaPath]
203
+ : ['prisma', 'migrate', command, '--schema', schemaPath];
149
204
 
150
205
  if (verbose) {
151
- console.log(chalk.gray(`Running: npx ${args.join(' ')}`));
206
+ const displayCmd = isDirectBinary
207
+ ? `${prismaBin} ${args.join(' ')}`
208
+ : `npx ${args.join(' ')}`;
209
+ console.log(chalk.gray(`Running: ${displayCmd}`));
152
210
  }
153
211
 
154
- const proc = spawn('npx', args, {
212
+ const proc = spawn(prismaBin, args, {
155
213
  stdio: 'inherit',
156
214
  env: {
157
215
  ...process.env,
@@ -292,6 +350,12 @@ async function runPrismaDbPush(verbose = false, nonInteractive = false) {
292
350
  * @returns {'dev'|'deploy'}
293
351
  */
294
352
  function getMigrationCommand(stage) {
353
+ // Always use 'deploy' in Lambda environment (it's non-interactive and doesn't create migrations)
354
+ const isLambdaEnvironment = !!process.env.AWS_LAMBDA_FUNCTION_NAME || !!process.env.LAMBDA_TASK_ROOT;
355
+ if (isLambdaEnvironment) {
356
+ return 'deploy';
357
+ }
358
+
295
359
  const normalizedStage = (stage || process.env.STAGE || 'development').toLowerCase();
296
360
 
297
361
  const developmentStages = ['dev', 'local', 'test', 'development'];
@@ -199,8 +199,8 @@ class ProcessRepositoryPostgres extends ProcessRepositoryInterface {
199
199
  results: process.results,
200
200
  childProcesses: Array.isArray(process.childProcesses)
201
201
  ? process.childProcesses.length > 0 &&
202
- typeof process.childProcesses[0] === 'object' &&
203
- process.childProcesses[0] !== null
202
+ typeof process.childProcesses[0] === 'object' &&
203
+ process.childProcesses[0] !== null
204
204
  ? process.childProcesses.map((child) => String(child.id))
205
205
  : process.childProcesses
206
206
  : [],
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.454.25d396a.0",
4
+ "version": "2.0.0--canary.461.84ff4f5.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
- "aws-sdk": "^2.1200.0",
8
7
  "bcryptjs": "^2.4.3",
9
8
  "body-parser": "^1.20.2",
10
9
  "chalk": "^4.1.2",
@@ -24,6 +23,7 @@
24
23
  },
25
24
  "peerDependencies": {
26
25
  "@prisma/client": "^6.16.3",
26
+ "aws-sdk": "^2.1200.0",
27
27
  "prisma": "^6.16.3"
28
28
  },
29
29
  "peerDependenciesMeta": {
@@ -32,12 +32,15 @@
32
32
  },
33
33
  "prisma": {
34
34
  "optional": true
35
+ },
36
+ "aws-sdk": {
37
+ "optional": true
35
38
  }
36
39
  },
37
40
  "devDependencies": {
38
- "@friggframework/eslint-config": "2.0.0--canary.454.25d396a.0",
39
- "@friggframework/prettier-config": "2.0.0--canary.454.25d396a.0",
40
- "@friggframework/test": "2.0.0--canary.454.25d396a.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.461.84ff4f5.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.461.84ff4f5.0",
43
+ "@friggframework/test": "2.0.0--canary.461.84ff4f5.0",
41
44
  "@prisma/client": "^6.17.0",
42
45
  "@types/lodash": "4.17.15",
43
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -77,5 +80,5 @@
77
80
  "publishConfig": {
78
81
  "access": "public"
79
82
  },
80
- "gitHead": "25d396ab0d73094bfab4853f9ff15a5500174ca7"
83
+ "gitHead": "84ff4f5a8ab85a143a491d4337965e534c1a73fb"
81
84
  }