@friggframework/devtools 2.0.0--canary.497.a3f25f9.0 → 2.0.0--canary.490.fd1ef7f.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.
- package/frigg-cli/deploy-command/index.js +9 -3
- package/infrastructure/README.md +28 -0
- package/infrastructure/domains/database/migration-builder.js +19 -13
- package/infrastructure/domains/database/migration-builder.test.js +57 -0
- package/infrastructure/domains/integration/integration-builder.js +19 -14
- package/infrastructure/domains/integration/integration-builder.test.js +0 -74
- package/infrastructure/domains/networking/vpc-builder.js +240 -18
- package/infrastructure/domains/networking/vpc-builder.test.js +711 -13
- package/infrastructure/domains/networking/vpc-resolver.js +221 -40
- package/infrastructure/domains/networking/vpc-resolver.test.js +318 -18
- package/infrastructure/domains/security/kms-builder.js +55 -6
- package/infrastructure/domains/security/kms-builder.test.js +19 -1
- package/infrastructure/domains/shared/cloudformation-discovery.js +310 -13
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +395 -0
- package/infrastructure/domains/shared/providers/aws-provider-adapter.js +41 -6
- package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +39 -0
- package/infrastructure/domains/shared/resource-discovery.js +17 -5
- package/infrastructure/domains/shared/resource-discovery.test.js +36 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +27 -17
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +73 -0
- package/infrastructure/infrastructure-composer.js +11 -3
- package/infrastructure/scripts/build-prisma-layer.js +8 -81
- package/infrastructure/scripts/build-prisma-layer.test.js +1 -53
- package/layers/prisma/.build-complete +3 -0
- package/package.json +7 -7
- package/infrastructure/scripts/verify-prisma-layer.js +0 -72
|
@@ -16,18 +16,20 @@ const { buildEnvironment } = require('../environment-builder');
|
|
|
16
16
|
* Frigg applications need, including:
|
|
17
17
|
* - Core Lambda functions (auth, user, health, dbMigrate)
|
|
18
18
|
* - Error handling infrastructure (SQS, SNS, CloudWatch)
|
|
19
|
-
* - Prisma Lambda Layer
|
|
19
|
+
* - Prisma Lambda Layer (optional, controlled by usePrismaLayer)
|
|
20
20
|
* - Base plugins and esbuild configuration
|
|
21
21
|
*
|
|
22
22
|
* @param {Object} AppDefinition - Application definition
|
|
23
23
|
* @param {Object} appEnvironmentVars - Environment variables from app definition
|
|
24
24
|
* @param {Object} discoveredResources - AWS resources discovered during build
|
|
25
|
+
* @param {boolean} usePrismaLayer - Whether to use Prisma Lambda Layer (default true)
|
|
25
26
|
* @returns {Object} Base serverless definition
|
|
26
27
|
*/
|
|
27
28
|
function createBaseDefinition(
|
|
28
29
|
AppDefinition,
|
|
29
30
|
appEnvironmentVars,
|
|
30
|
-
discoveredResources
|
|
31
|
+
discoveredResources,
|
|
32
|
+
usePrismaLayer = true
|
|
31
33
|
) {
|
|
32
34
|
const region = process.env.AWS_REGION || 'us-east-1';
|
|
33
35
|
|
|
@@ -42,11 +44,13 @@ function createBaseDefinition(
|
|
|
42
44
|
: []),
|
|
43
45
|
],
|
|
44
46
|
exclude: [
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
// Conditionally exclude Prisma (only if using Lambda Layer)
|
|
48
|
+
...(usePrismaLayer ? [
|
|
49
|
+
'node_modules/@prisma/**',
|
|
50
|
+
'node_modules/.prisma/**',
|
|
51
|
+
'node_modules/prisma/**',
|
|
52
|
+
'node_modules/@friggframework/core/generated/**',
|
|
53
|
+
] : []),
|
|
50
54
|
|
|
51
55
|
// Exclude AWS SDK (provided by Lambda runtime)
|
|
52
56
|
'node_modules/aws-sdk/**',
|
|
@@ -218,9 +222,12 @@ function createBaseDefinition(
|
|
|
218
222
|
external: [
|
|
219
223
|
'@aws-sdk/*',
|
|
220
224
|
'aws-sdk',
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
225
|
+
// Conditionally mark Prisma as external (only if using layer)
|
|
226
|
+
...(usePrismaLayer ? [
|
|
227
|
+
'@prisma/client',
|
|
228
|
+
'prisma',
|
|
229
|
+
'.prisma/*',
|
|
230
|
+
] : []),
|
|
224
231
|
],
|
|
225
232
|
packager: 'npm',
|
|
226
233
|
keepNames: true,
|
|
@@ -228,8 +235,11 @@ function createBaseDefinition(
|
|
|
228
235
|
exclude: [
|
|
229
236
|
'aws-sdk',
|
|
230
237
|
'@aws-sdk/*',
|
|
231
|
-
|
|
232
|
-
|
|
238
|
+
// Conditionally exclude Prisma (only if using layer)
|
|
239
|
+
...(usePrismaLayer ? [
|
|
240
|
+
'@prisma/client',
|
|
241
|
+
'prisma',
|
|
242
|
+
] : []),
|
|
233
243
|
],
|
|
234
244
|
},
|
|
235
245
|
'serverless-offline': {
|
|
@@ -252,7 +262,7 @@ function createBaseDefinition(
|
|
|
252
262
|
functions: {
|
|
253
263
|
auth: {
|
|
254
264
|
handler: 'node_modules/@friggframework/core/handlers/routers/auth.handler',
|
|
255
|
-
layers: [{ Ref: 'PrismaLambdaLayer' }],
|
|
265
|
+
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
256
266
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
257
267
|
package: skipEsbuildPackageConfig,
|
|
258
268
|
events: [
|
|
@@ -268,14 +278,14 @@ function createBaseDefinition(
|
|
|
268
278
|
},
|
|
269
279
|
user: {
|
|
270
280
|
handler: 'node_modules/@friggframework/core/handlers/routers/user.handler',
|
|
271
|
-
layers: [{ Ref: 'PrismaLambdaLayer' }],
|
|
281
|
+
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
272
282
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
273
283
|
package: skipEsbuildPackageConfig,
|
|
274
284
|
events: [{ httpApi: { path: '/user/{proxy+}', method: 'ANY' } }],
|
|
275
285
|
},
|
|
276
286
|
health: {
|
|
277
287
|
handler: 'node_modules/@friggframework/core/handlers/routers/health.handler',
|
|
278
|
-
layers: [{ Ref: 'PrismaLambdaLayer' }],
|
|
288
|
+
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
279
289
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
280
290
|
package: skipEsbuildPackageConfig,
|
|
281
291
|
events: [
|
|
@@ -286,7 +296,7 @@ function createBaseDefinition(
|
|
|
286
296
|
// Note: dbMigrate removed - MigrationBuilder now handles migration infrastructure
|
|
287
297
|
// See: packages/devtools/infrastructure/domains/database/migration-builder.js
|
|
288
298
|
},
|
|
289
|
-
layers: {
|
|
299
|
+
layers: usePrismaLayer ? {
|
|
290
300
|
prisma: {
|
|
291
301
|
path: 'layers/prisma',
|
|
292
302
|
name: '${self:service}-prisma-${sls:stage}',
|
|
@@ -294,7 +304,7 @@ function createBaseDefinition(
|
|
|
294
304
|
compatibleRuntimes: ['nodejs20.x', 'nodejs22.x'],
|
|
295
305
|
retain: false,
|
|
296
306
|
},
|
|
297
|
-
},
|
|
307
|
+
} : {},
|
|
298
308
|
resources: {
|
|
299
309
|
Resources: {
|
|
300
310
|
InternalErrorQueue: {
|
|
@@ -243,6 +243,79 @@ describe('Base Definition Factory', () => {
|
|
|
243
243
|
expect(result.useDotenv).toBeDefined();
|
|
244
244
|
expect(typeof result.useDotenv).toBe('boolean');
|
|
245
245
|
});
|
|
246
|
+
|
|
247
|
+
describe('usePrismaLayer configuration', () => {
|
|
248
|
+
it('should include Prisma layer by default (usePrismaLayer=true)', () => {
|
|
249
|
+
const result = createBaseDefinition({}, {}, {}, true);
|
|
250
|
+
|
|
251
|
+
// Layer definition should exist
|
|
252
|
+
expect(result.layers.prisma).toBeDefined();
|
|
253
|
+
expect(result.layers.prisma.path).toBe('layers/prisma');
|
|
254
|
+
|
|
255
|
+
// Functions should reference the layer
|
|
256
|
+
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
257
|
+
expect(result.functions.user.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
258
|
+
expect(result.functions.health.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
259
|
+
|
|
260
|
+
// Prisma should be excluded from packages
|
|
261
|
+
expect(result.functions.auth.package.exclude).toEqual(
|
|
262
|
+
expect.arrayContaining([
|
|
263
|
+
'node_modules/@prisma/**',
|
|
264
|
+
'node_modules/.prisma/**',
|
|
265
|
+
'node_modules/prisma/**',
|
|
266
|
+
'node_modules/@friggframework/core/generated/**',
|
|
267
|
+
])
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
// Prisma should be external in esbuild
|
|
271
|
+
expect(result.custom.esbuild.external).toContain('@prisma/client');
|
|
272
|
+
expect(result.custom.esbuild.external).toContain('prisma');
|
|
273
|
+
expect(result.custom.esbuild.exclude).toContain('@prisma/client');
|
|
274
|
+
expect(result.custom.esbuild.exclude).toContain('prisma');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should NOT include Prisma layer when usePrismaLayer=false', () => {
|
|
278
|
+
const result = createBaseDefinition({}, {}, {}, false);
|
|
279
|
+
|
|
280
|
+
// Layer definition should NOT exist
|
|
281
|
+
expect(result.layers).toEqual({});
|
|
282
|
+
|
|
283
|
+
// Functions should NOT have layer references
|
|
284
|
+
expect(result.functions.auth.layers).toBeUndefined();
|
|
285
|
+
expect(result.functions.user.layers).toBeUndefined();
|
|
286
|
+
expect(result.functions.health.layers).toBeUndefined();
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('should bundle Prisma with functions when usePrismaLayer=false', () => {
|
|
290
|
+
const result = createBaseDefinition({}, {}, {}, false);
|
|
291
|
+
|
|
292
|
+
// Prisma should NOT be excluded from packages
|
|
293
|
+
expect(result.functions.auth.package.exclude).not.toEqual(
|
|
294
|
+
expect.arrayContaining([
|
|
295
|
+
'node_modules/@prisma/**',
|
|
296
|
+
'node_modules/.prisma/**',
|
|
297
|
+
'node_modules/prisma/**',
|
|
298
|
+
'node_modules/@friggframework/core/generated/**',
|
|
299
|
+
])
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
// Prisma should NOT be external in esbuild
|
|
303
|
+
expect(result.custom.esbuild.external).not.toContain('@prisma/client');
|
|
304
|
+
expect(result.custom.esbuild.external).not.toContain('prisma');
|
|
305
|
+
expect(result.custom.esbuild.external).not.toContain('.prisma/*');
|
|
306
|
+
expect(result.custom.esbuild.exclude).not.toContain('@prisma/client');
|
|
307
|
+
expect(result.custom.esbuild.exclude).not.toContain('prisma');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('should default to usePrismaLayer=true when parameter not provided', () => {
|
|
311
|
+
// Call without 4th parameter
|
|
312
|
+
const result = createBaseDefinition({}, {}, {});
|
|
313
|
+
|
|
314
|
+
// Should behave as if usePrismaLayer=true
|
|
315
|
+
expect(result.layers.prisma).toBeDefined();
|
|
316
|
+
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
246
319
|
});
|
|
247
320
|
});
|
|
248
321
|
|
|
@@ -32,8 +32,15 @@ const { validateAndCleanPlugins, validatePackagingConfiguration } = require('./d
|
|
|
32
32
|
const composeServerlessDefinition = async (AppDefinition) => {
|
|
33
33
|
console.log('🏗️ Composing serverless definition with domain builders...');
|
|
34
34
|
|
|
35
|
-
//
|
|
36
|
-
|
|
35
|
+
// Determine if using Prisma Lambda Layer (default true)
|
|
36
|
+
const usePrismaLayer = AppDefinition.usePrismaLambdaLayer !== false;
|
|
37
|
+
|
|
38
|
+
// Ensure Prisma layer exists only if using layer mode
|
|
39
|
+
if (usePrismaLayer) {
|
|
40
|
+
await ensurePrismaLayerExists(AppDefinition.database || {});
|
|
41
|
+
} else {
|
|
42
|
+
console.log('📦 Skipping Prisma Lambda Layer (usePrismaLambdaLayer=false - will bundle with functions)');
|
|
43
|
+
}
|
|
37
44
|
|
|
38
45
|
// Create orchestrator with all domain builders
|
|
39
46
|
const orchestrator = new BuilderOrchestrator([
|
|
@@ -55,7 +62,8 @@ const composeServerlessDefinition = async (AppDefinition) => {
|
|
|
55
62
|
const definition = createBaseDefinition(
|
|
56
63
|
AppDefinition,
|
|
57
64
|
appEnvironmentVars,
|
|
58
|
-
discoveredResources
|
|
65
|
+
discoveredResources,
|
|
66
|
+
usePrismaLayer
|
|
59
67
|
);
|
|
60
68
|
|
|
61
69
|
// Merge builder results into definition
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* The CLI is only needed for migrations and is packaged separately with the dbMigrate function.
|
|
11
11
|
*
|
|
12
12
|
* The layer is configured based on AppDefinition database settings:
|
|
13
|
-
* - PostgreSQL: Includes PostgreSQL client + query engine
|
|
14
|
-
* - MongoDB: Includes MongoDB client + query engine
|
|
13
|
+
* - PostgreSQL: Includes PostgreSQL client + query engine only
|
|
14
|
+
* - MongoDB: Includes MongoDB client + query engine only (if needed)
|
|
15
15
|
* - Defaults to PostgreSQL only if not specified
|
|
16
16
|
*
|
|
17
17
|
* Usage:
|
|
@@ -22,11 +22,7 @@
|
|
|
22
22
|
* layers/prisma/nodejs/node_modules/
|
|
23
23
|
* ├── @prisma/client (runtime only, ~10-15MB)
|
|
24
24
|
* ├── generated/prisma-postgresql (if PostgreSQL enabled)
|
|
25
|
-
* │ ├── schema.prisma
|
|
26
|
-
* │ └── migrations/
|
|
27
25
|
* └── generated/prisma-mongodb (if MongoDB enabled)
|
|
28
|
-
* ├── schema.prisma
|
|
29
|
-
* └── migrations/
|
|
30
26
|
*
|
|
31
27
|
* See: LAMBDA-LAYER-PRISMA.md for complete documentation
|
|
32
28
|
*/
|
|
@@ -89,27 +85,6 @@ function getGeneratedClientPackages(databaseConfig = {}) {
|
|
|
89
85
|
return packages;
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
function getMigrationsPackages(clientPackages) {
|
|
93
|
-
return clientPackages.map(pkg => ({
|
|
94
|
-
dbType: pkg.replace('generated/prisma-', ''),
|
|
95
|
-
clientPackage: pkg
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getMigrationSourcePath(searchPaths, dbType) {
|
|
100
|
-
for (const searchPath of searchPaths) {
|
|
101
|
-
const candidatePath = path.join(searchPath, `prisma-${dbType}`, 'migrations');
|
|
102
|
-
if (fs.existsSync(candidatePath)) {
|
|
103
|
-
return candidatePath;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getMigrationDestinationPath(layerNodeModules, clientPackage) {
|
|
110
|
-
return path.join(layerNodeModules, clientPackage, 'migrations');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
88
|
// Configuration
|
|
114
89
|
// Script runs from integration project root (e.g., backend/)
|
|
115
90
|
// and reads Prisma packages from @friggframework/core
|
|
@@ -324,47 +299,11 @@ async function copyPrismaPackages(clientPackages) {
|
|
|
324
299
|
logSuccess(`Copied ${copiedCount} generated client packages from @friggframework/core`);
|
|
325
300
|
}
|
|
326
301
|
|
|
327
|
-
async function copyMigrations(clientPackages) {
|
|
328
|
-
logStep(5, 'Copying migrations from @friggframework/core');
|
|
329
|
-
|
|
330
|
-
const workspaceNodeModules = path.join(path.dirname(CORE_PACKAGE_PATH), '..');
|
|
331
|
-
const searchPaths = [
|
|
332
|
-
path.join(CORE_PACKAGE_PATH, 'node_modules'),
|
|
333
|
-
path.join(PROJECT_ROOT, 'node_modules'),
|
|
334
|
-
workspaceNodeModules,
|
|
335
|
-
CORE_PACKAGE_PATH,
|
|
336
|
-
];
|
|
337
|
-
|
|
338
|
-
const migrations = getMigrationsPackages(clientPackages);
|
|
339
|
-
let copiedCount = 0;
|
|
340
|
-
|
|
341
|
-
for (const { dbType, clientPackage } of migrations) {
|
|
342
|
-
const sourcePath = getMigrationSourcePath(searchPaths, dbType);
|
|
343
|
-
|
|
344
|
-
if (sourcePath) {
|
|
345
|
-
const destPath = getMigrationDestinationPath(LAYER_NODE_MODULES, clientPackage);
|
|
346
|
-
await fs.copy(sourcePath, destPath, { dereference: true });
|
|
347
|
-
|
|
348
|
-
const fromLocation = sourcePath.includes('@friggframework/core/prisma')
|
|
349
|
-
? 'core package'
|
|
350
|
-
: 'workspace';
|
|
351
|
-
logSuccess(`Copied migrations for ${dbType} (from ${fromLocation})`);
|
|
352
|
-
copiedCount++;
|
|
353
|
-
} else {
|
|
354
|
-
logWarning(`Migrations not found for ${dbType} - this may cause migration failures`);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (copiedCount > 0) {
|
|
359
|
-
logSuccess(`Copied migrations for ${copiedCount} database ${copiedCount === 1 ? 'type' : 'types'}`);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
302
|
/**
|
|
364
303
|
* Remove unnecessary files to reduce layer size
|
|
365
304
|
*/
|
|
366
305
|
async function removeUnnecessaryFiles() {
|
|
367
|
-
logStep(
|
|
306
|
+
logStep(5, 'Removing unnecessary files (source maps, docs, tests)');
|
|
368
307
|
|
|
369
308
|
let removedCount = 0;
|
|
370
309
|
let totalSize = 0;
|
|
@@ -402,7 +341,7 @@ async function removeUnnecessaryFiles() {
|
|
|
402
341
|
* Remove non-rhel engine binaries to reduce layer size
|
|
403
342
|
*/
|
|
404
343
|
async function removeNonRhelBinaries() {
|
|
405
|
-
logStep(
|
|
344
|
+
logStep(6, 'Removing non-rhel engine binaries');
|
|
406
345
|
|
|
407
346
|
let removedCount = 0;
|
|
408
347
|
let totalSize = 0;
|
|
@@ -441,7 +380,7 @@ async function removeNonRhelBinaries() {
|
|
|
441
380
|
* @param {Array} expectedClients - List of client packages that should have binaries
|
|
442
381
|
*/
|
|
443
382
|
async function verifyRhelBinaries(expectedClients) {
|
|
444
|
-
logStep(
|
|
383
|
+
logStep(7, 'Verifying rhel-openssl-3.0.x binaries are present');
|
|
445
384
|
|
|
446
385
|
try {
|
|
447
386
|
const findCmd = `find "${LAYER_NODE_MODULES}" -name "*rhel-openssl-3.0.x*" 2>/dev/null || true`;
|
|
@@ -475,7 +414,7 @@ async function verifyRhelBinaries(expectedClients) {
|
|
|
475
414
|
* @param {Array} clientPackages - Generated client packages that were included
|
|
476
415
|
*/
|
|
477
416
|
async function verifyLayerStructure(clientPackages) {
|
|
478
|
-
logStep(
|
|
417
|
+
logStep(8, 'Verifying layer structure (runtime only)');
|
|
479
418
|
|
|
480
419
|
const requiredPaths = [
|
|
481
420
|
'@prisma/client/runtime',
|
|
@@ -487,11 +426,6 @@ async function verifyLayerStructure(clientPackages) {
|
|
|
487
426
|
requiredPaths.push(`${pkg}/schema.prisma`);
|
|
488
427
|
}
|
|
489
428
|
|
|
490
|
-
// Add migrations directory for each included client
|
|
491
|
-
for (const pkg of clientPackages) {
|
|
492
|
-
requiredPaths.push(`${pkg}/migrations/migration_lock.toml`);
|
|
493
|
-
}
|
|
494
|
-
|
|
495
429
|
// Verify CLI is NOT present (keeps layer small)
|
|
496
430
|
const forbiddenPaths = [
|
|
497
431
|
'prisma/build',
|
|
@@ -529,7 +463,7 @@ async function verifyLayerStructure(clientPackages) {
|
|
|
529
463
|
* Calculate and display final layer size
|
|
530
464
|
*/
|
|
531
465
|
async function displayLayerSummary() {
|
|
532
|
-
logStep(
|
|
466
|
+
logStep(9, 'Layer build summary');
|
|
533
467
|
|
|
534
468
|
const layerSizeMB = getDirectorySize(LAYER_OUTPUT_PATH);
|
|
535
469
|
|
|
@@ -580,7 +514,6 @@ async function buildPrismaLayer(databaseConfig = {}) {
|
|
|
580
514
|
await createLayerStructure();
|
|
581
515
|
await installPrismaPackages(); // Install runtime client only (NO CLI)
|
|
582
516
|
await copyPrismaPackages(clientPackages); // Copy generated clients from core
|
|
583
|
-
await copyMigrations(clientPackages); // Copy migrations from core
|
|
584
517
|
await removeUnnecessaryFiles(); // Remove source maps, docs, tests (37MB+)
|
|
585
518
|
await removeNonRhelBinaries(); // Remove non-Linux binaries
|
|
586
519
|
await verifyRhelBinaries(clientPackages); // Verify query engines present
|
|
@@ -617,10 +550,4 @@ if (require.main === module) {
|
|
|
617
550
|
.catch(() => process.exit(1));
|
|
618
551
|
}
|
|
619
552
|
|
|
620
|
-
module.exports = {
|
|
621
|
-
buildPrismaLayer,
|
|
622
|
-
getGeneratedClientPackages,
|
|
623
|
-
getMigrationsPackages,
|
|
624
|
-
getMigrationSourcePath,
|
|
625
|
-
getMigrationDestinationPath
|
|
626
|
-
};
|
|
553
|
+
module.exports = { buildPrismaLayer, getGeneratedClientPackages };
|
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
* Validates database client selection logic
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
const {
|
|
7
|
-
getGeneratedClientPackages,
|
|
8
|
-
getMigrationsPackages,
|
|
9
|
-
getMigrationSourcePath,
|
|
10
|
-
getMigrationDestinationPath
|
|
11
|
-
} = require('./build-prisma-layer');
|
|
6
|
+
const { getGeneratedClientPackages } = require('./build-prisma-layer');
|
|
12
7
|
|
|
13
8
|
// Mock the log function
|
|
14
9
|
jest.mock('./build-prisma-layer', () => {
|
|
@@ -16,9 +11,6 @@ jest.mock('./build-prisma-layer', () => {
|
|
|
16
11
|
return {
|
|
17
12
|
...actual,
|
|
18
13
|
getGeneratedClientPackages: actual.getGeneratedClientPackages,
|
|
19
|
-
getMigrationsPackages: actual.getMigrationsPackages,
|
|
20
|
-
getMigrationSourcePath: actual.getMigrationSourcePath,
|
|
21
|
-
getMigrationDestinationPath: actual.getMigrationDestinationPath,
|
|
22
14
|
};
|
|
23
15
|
});
|
|
24
16
|
|
|
@@ -107,48 +99,4 @@ describe('getGeneratedClientPackages()', () => {
|
|
|
107
99
|
});
|
|
108
100
|
});
|
|
109
101
|
|
|
110
|
-
describe('getMigrationsPackages()', () => {
|
|
111
|
-
it('should extract database types from client packages', () => {
|
|
112
|
-
const clientPackages = ['generated/prisma-postgresql', 'generated/prisma-mongodb'];
|
|
113
|
-
const migrations = getMigrationsPackages(clientPackages);
|
|
114
102
|
|
|
115
|
-
expect(migrations).toEqual([
|
|
116
|
-
{ dbType: 'postgresql', clientPackage: 'generated/prisma-postgresql' },
|
|
117
|
-
{ dbType: 'mongodb', clientPackage: 'generated/prisma-mongodb' }
|
|
118
|
-
]);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
it('should handle single client package', () => {
|
|
122
|
-
const clientPackages = ['generated/prisma-postgresql'];
|
|
123
|
-
const migrations = getMigrationsPackages(clientPackages);
|
|
124
|
-
|
|
125
|
-
expect(migrations).toEqual([
|
|
126
|
-
{ dbType: 'postgresql', clientPackage: 'generated/prisma-postgresql' }
|
|
127
|
-
]);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('should handle empty array', () => {
|
|
131
|
-
const migrations = getMigrationsPackages([]);
|
|
132
|
-
expect(migrations).toEqual([]);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('getMigrationSourcePath()', () => {
|
|
137
|
-
it('should return correct source path for database type', () => {
|
|
138
|
-
const searchPaths = ['/workspace/packages/core'];
|
|
139
|
-
const dbType = 'postgresql';
|
|
140
|
-
|
|
141
|
-
const sourcePath = getMigrationSourcePath(searchPaths, dbType);
|
|
142
|
-
expect(sourcePath).toBe('/workspace/packages/core/prisma-postgresql/migrations');
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('getMigrationDestinationPath()', () => {
|
|
147
|
-
it('should return correct destination path for client package', () => {
|
|
148
|
-
const layerNodeModules = '/layers/prisma/nodejs/node_modules';
|
|
149
|
-
const clientPackage = 'generated/prisma-postgresql';
|
|
150
|
-
|
|
151
|
-
const destPath = getMigrationDestinationPath(layerNodeModules, clientPackage);
|
|
152
|
-
expect(destPath).toBe('/layers/prisma/nodejs/node_modules/generated/prisma-postgresql/migrations');
|
|
153
|
-
});
|
|
154
|
-
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.490.fd1ef7f.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@babel/eslint-parser": "^7.18.9",
|
|
17
17
|
"@babel/parser": "^7.25.3",
|
|
18
18
|
"@babel/traverse": "^7.25.3",
|
|
19
|
-
"@friggframework/core": "2.0.0--canary.
|
|
20
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
21
|
-
"@friggframework/test": "2.0.0--canary.
|
|
19
|
+
"@friggframework/core": "2.0.0--canary.490.fd1ef7f.0",
|
|
20
|
+
"@friggframework/schemas": "2.0.0--canary.490.fd1ef7f.0",
|
|
21
|
+
"@friggframework/test": "2.0.0--canary.490.fd1ef7f.0",
|
|
22
22
|
"@hapi/boom": "^10.0.1",
|
|
23
23
|
"@inquirer/prompts": "^5.3.8",
|
|
24
24
|
"axios": "^1.7.2",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"validate-npm-package-name": "^5.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
50
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
49
|
+
"@friggframework/eslint-config": "2.0.0--canary.490.fd1ef7f.0",
|
|
50
|
+
"@friggframework/prettier-config": "2.0.0--canary.490.fd1ef7f.0",
|
|
51
51
|
"aws-sdk-client-mock": "^4.1.0",
|
|
52
52
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
53
53
|
"jest": "^30.1.3",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "fd1ef7faa5d1584934b3c2e15d1e0aa4d068fa38"
|
|
83
83
|
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
const PROJECT_ROOT = process.cwd();
|
|
7
|
-
const LAYER_PATH = path.join(PROJECT_ROOT, 'layers/prisma/nodejs/node_modules');
|
|
8
|
-
|
|
9
|
-
async function verifyLayerStructure() {
|
|
10
|
-
console.log('Verifying Prisma layer structure...\n');
|
|
11
|
-
|
|
12
|
-
const checks = [
|
|
13
|
-
{
|
|
14
|
-
name: 'PostgreSQL schema',
|
|
15
|
-
path: 'generated/prisma-postgresql/schema.prisma'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
name: 'PostgreSQL migrations directory',
|
|
19
|
-
path: 'generated/prisma-postgresql/migrations'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'PostgreSQL migration_lock.toml',
|
|
23
|
-
path: 'generated/prisma-postgresql/migrations/migration_lock.toml'
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: '@prisma/client runtime',
|
|
27
|
-
path: '@prisma/client/runtime'
|
|
28
|
-
}
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
let allPassed = true;
|
|
32
|
-
|
|
33
|
-
for (const check of checks) {
|
|
34
|
-
const fullPath = path.join(LAYER_PATH, check.path);
|
|
35
|
-
const exists = await fs.pathExists(fullPath);
|
|
36
|
-
|
|
37
|
-
if (exists) {
|
|
38
|
-
console.log(`✓ ${check.name}`);
|
|
39
|
-
} else {
|
|
40
|
-
console.log(`✗ ${check.name} (missing)`);
|
|
41
|
-
allPassed = false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log('\n');
|
|
46
|
-
|
|
47
|
-
if (allPassed) {
|
|
48
|
-
console.log('✓ All checks passed!');
|
|
49
|
-
const migrationsPath = path.join(LAYER_PATH, 'generated/prisma-postgresql/migrations');
|
|
50
|
-
const migrationFiles = await fs.readdir(migrationsPath);
|
|
51
|
-
console.log(`\nFound ${migrationFiles.length} items in migrations directory:`);
|
|
52
|
-
migrationFiles.forEach(file => {
|
|
53
|
-
console.log(` - ${file}`);
|
|
54
|
-
});
|
|
55
|
-
return 0;
|
|
56
|
-
} else {
|
|
57
|
-
console.log('✗ Some checks failed!');
|
|
58
|
-
return 1;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (require.main === module) {
|
|
63
|
-
verifyLayerStructure()
|
|
64
|
-
.then(code => process.exit(code))
|
|
65
|
-
.catch(err => {
|
|
66
|
-
console.error('Error:', err.message);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
module.exports = { verifyLayerStructure };
|
|
72
|
-
|