@friggframework/devtools 2.0.0--canary.731.1c0b281.0 → 2.0.0--canary.730.f2ba24a.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/infrastructure/README.md +5 -32
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -3
- package/infrastructure/__tests__/postgres-config.test.js +0 -3
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -3
- package/infrastructure/__tests__/scoped-environment.test.js +0 -3
- package/infrastructure/__tests__/ssm-preload-node-options.test.js +0 -3
- package/infrastructure/__tests__/template-generation.test.js +0 -3
- package/infrastructure/app-definition-schema-contract.test.js +0 -5
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -2
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -22
- package/infrastructure/domains/database/migration-builder.js +2 -21
- package/infrastructure/domains/database/migration-builder.test.js +6 -61
- package/infrastructure/domains/integration/integration-builder.js +0 -2
- package/infrastructure/domains/integration/integration-builder.test.js +6 -22
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -13
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +4 -51
- package/infrastructure/domains/shared/utilities/nested-node-modules.js +6 -5
- package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +20 -26
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +12 -92
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +6 -158
- package/infrastructure/infrastructure-composer.js +1 -12
- package/infrastructure/infrastructure-composer.test.js +0 -71
- package/infrastructure/scripts/build-prisma-layer.js +50 -136
- package/infrastructure/scripts/build-prisma-layer.test.js +0 -100
- package/package.json +7 -7
- package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +0 -39
- package/infrastructure/domains/database/migration-engines.js +0 -93
- package/infrastructure/domains/database/migration-engines.test.js +0 -142
- package/infrastructure/domains/shared/lambda-architectures.js +0 -113
- package/infrastructure/domains/shared/lambda-architectures.test.js +0 -164
|
@@ -34,9 +34,6 @@
|
|
|
34
34
|
const fs = require('fs-extra');
|
|
35
35
|
const path = require('path');
|
|
36
36
|
const { execSync } = require('child_process');
|
|
37
|
-
const {
|
|
38
|
-
resolveLambdaArchitecture,
|
|
39
|
-
} = require('../domains/shared/lambda-architectures');
|
|
40
37
|
|
|
41
38
|
/**
|
|
42
39
|
* Find @friggframework/core package, handling workspace hoisting
|
|
@@ -96,31 +93,6 @@ function getGeneratedClientPackages(databaseConfig = {}) {
|
|
|
96
93
|
return packages;
|
|
97
94
|
}
|
|
98
95
|
|
|
99
|
-
/**
|
|
100
|
-
* Everything the layer contents depend on. The layer manager keys its cache
|
|
101
|
-
* on this, so a change in any of them rebuilds the layer.
|
|
102
|
-
* @param {Object} options
|
|
103
|
-
* @param {Object} options.databaseConfig - Database configuration from AppDefinition.database
|
|
104
|
-
* @param {string} options.prismaBinaryTarget - The engine the deployed architecture loads
|
|
105
|
-
* @returns {{ prismaBinaryTarget: string, clientPackages: string[], coreVersion: string, prismaClientVersion: string }}
|
|
106
|
-
*/
|
|
107
|
-
function layerBuildInputs({
|
|
108
|
-
databaseConfig = {},
|
|
109
|
-
prismaBinaryTarget = resolveLambdaArchitecture().prismaBinaryTarget,
|
|
110
|
-
} = {}) {
|
|
111
|
-
return {
|
|
112
|
-
prismaBinaryTarget,
|
|
113
|
-
clientPackages: getGeneratedClientPackages(databaseConfig),
|
|
114
|
-
coreVersion: fs.readJsonSync(path.join(CORE_PACKAGE_PATH, 'package.json'))
|
|
115
|
-
.version,
|
|
116
|
-
prismaClientVersion: fs.readJsonSync(
|
|
117
|
-
require.resolve('@prisma/client/package.json', {
|
|
118
|
-
paths: [CORE_PACKAGE_PATH],
|
|
119
|
-
})
|
|
120
|
-
).version,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
96
|
function getMigrationsPackages(clientPackages) {
|
|
125
97
|
return clientPackages.map((pkg) => ({
|
|
126
98
|
dbType: pkg.replace('generated/prisma-', ''),
|
|
@@ -186,34 +158,15 @@ const CORE_PACKAGE_PATH = findCorePackage(PROJECT_ROOT);
|
|
|
186
158
|
const LAYER_OUTPUT_PATH = path.join(PROJECT_ROOT, 'layers/prisma');
|
|
187
159
|
const LAYER_NODE_MODULES = path.join(LAYER_OUTPUT_PATH, 'nodejs/node_modules');
|
|
188
160
|
|
|
189
|
-
// Binary patterns
|
|
161
|
+
// Binary patterns to remove (non-rhel)
|
|
190
162
|
const BINARY_PATTERNS_TO_REMOVE = [
|
|
191
163
|
'*darwin*',
|
|
192
164
|
'*debian*',
|
|
165
|
+
'*linux-arm*',
|
|
193
166
|
'*linux-musl*',
|
|
194
167
|
'*windows*',
|
|
195
168
|
];
|
|
196
169
|
|
|
197
|
-
const ENGINE_FILE_PREFIXES = [
|
|
198
|
-
'libquery_engine-',
|
|
199
|
-
'query-engine-',
|
|
200
|
-
'schema-engine-',
|
|
201
|
-
];
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Engine files built for a target other than the one the layer deploys to
|
|
205
|
-
* @param {string[]} fileNames - Basenames found in the layer
|
|
206
|
-
* @param {string} prismaBinaryTarget - The engine the deployed architecture loads
|
|
207
|
-
* @returns {string[]}
|
|
208
|
-
*/
|
|
209
|
-
function engineFilesToRemove(fileNames, prismaBinaryTarget) {
|
|
210
|
-
return fileNames.filter(
|
|
211
|
-
(name) =>
|
|
212
|
-
ENGINE_FILE_PREFIXES.some((prefix) => name.startsWith(prefix)) &&
|
|
213
|
-
!name.includes(prismaBinaryTarget)
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
170
|
// Files to remove for size optimization
|
|
218
171
|
const FILES_TO_REMOVE = [
|
|
219
172
|
'*.map', // Source maps (37MB savings)
|
|
@@ -323,15 +276,21 @@ async function installPrismaPackages() {
|
|
|
323
276
|
await fs.writeJson(packageJsonPath, layerPackageJson, { spaces: 2 });
|
|
324
277
|
logSuccess('Created layer package.json');
|
|
325
278
|
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
log('Installing @prisma/client...');
|
|
279
|
+
// Install Prisma packages with Lambda binary target
|
|
280
|
+
// Setting PRISMA_CLI_BINARY_TARGETS ensures only rhel-openssl-3.0.x binary is downloaded
|
|
281
|
+
log('Installing @prisma/client for AWS Lambda (rhel-openssl-3.0.x)...');
|
|
329
282
|
try {
|
|
283
|
+
const env = {
|
|
284
|
+
...process.env,
|
|
285
|
+
PRISMA_CLI_BINARY_TARGETS: 'rhel-openssl-3.0.x',
|
|
286
|
+
};
|
|
287
|
+
|
|
330
288
|
execSync('npm install --omit=dev --no-package-lock', {
|
|
331
289
|
cwd: path.join(LAYER_OUTPUT_PATH, 'nodejs'),
|
|
332
290
|
stdio: 'inherit',
|
|
291
|
+
env,
|
|
333
292
|
});
|
|
334
|
-
logSuccess('Prisma packages installed');
|
|
293
|
+
logSuccess('Prisma packages installed with Lambda binary target');
|
|
335
294
|
} catch (error) {
|
|
336
295
|
throw new Error(`Failed to install Prisma packages: ${error.message}`);
|
|
337
296
|
}
|
|
@@ -507,40 +466,23 @@ async function removeUnnecessaryFiles() {
|
|
|
507
466
|
}
|
|
508
467
|
|
|
509
468
|
/**
|
|
510
|
-
* Remove engine binaries
|
|
511
|
-
* @param {string} prismaBinaryTarget - The engine the deployed architecture loads
|
|
469
|
+
* Remove non-rhel engine binaries to reduce layer size
|
|
512
470
|
*/
|
|
513
|
-
async function
|
|
514
|
-
logStep(7,
|
|
471
|
+
async function removeNonRhelBinaries() {
|
|
472
|
+
logStep(7, 'Removing non-rhel engine binaries');
|
|
515
473
|
|
|
516
474
|
let removedCount = 0;
|
|
517
475
|
let totalSize = 0;
|
|
518
476
|
|
|
519
|
-
const
|
|
520
|
-
...BINARY_PATTERNS_TO_REMOVE,
|
|
521
|
-
...ENGINE_FILE_PREFIXES.map((prefix) => `${prefix}*`),
|
|
522
|
-
];
|
|
523
|
-
for (const pattern of findPatterns) {
|
|
477
|
+
for (const pattern of BINARY_PATTERNS_TO_REMOVE) {
|
|
524
478
|
try {
|
|
525
479
|
// Find files matching the pattern
|
|
526
480
|
const findCmd = `find "${LAYER_NODE_MODULES}" -name "${pattern}" 2>/dev/null || true`;
|
|
527
481
|
const files = execSync(findCmd, { encoding: 'utf8' })
|
|
528
482
|
.split('\n')
|
|
529
483
|
.filter((f) => f.trim());
|
|
530
|
-
const foreign = new Set(
|
|
531
|
-
engineFilesToRemove(
|
|
532
|
-
files.map((f) => path.basename(f)),
|
|
533
|
-
prismaBinaryTarget
|
|
534
|
-
)
|
|
535
|
-
);
|
|
536
484
|
|
|
537
485
|
for (const file of files) {
|
|
538
|
-
const isEngine = ENGINE_FILE_PREFIXES.some((prefix) =>
|
|
539
|
-
path.basename(file).startsWith(prefix)
|
|
540
|
-
);
|
|
541
|
-
if (isEngine && !foreign.has(path.basename(file))) {
|
|
542
|
-
continue;
|
|
543
|
-
}
|
|
544
486
|
if (await fs.pathExists(file)) {
|
|
545
487
|
const stats = await fs.stat(file);
|
|
546
488
|
totalSize += stats.size;
|
|
@@ -556,59 +498,48 @@ async function removeForeignBinaries(prismaBinaryTarget) {
|
|
|
556
498
|
if (removedCount > 0) {
|
|
557
499
|
const sizeMB = (totalSize / (1024 * 1024)).toFixed(2);
|
|
558
500
|
logSuccess(
|
|
559
|
-
`Removed ${removedCount}
|
|
501
|
+
`Removed ${removedCount} non-rhel binaries (saved ${sizeMB} MB)`
|
|
560
502
|
);
|
|
561
503
|
} else {
|
|
562
|
-
log('No
|
|
504
|
+
log('No non-rhel binaries found to remove');
|
|
563
505
|
}
|
|
564
506
|
}
|
|
565
507
|
|
|
566
508
|
/**
|
|
567
|
-
* Verify
|
|
568
|
-
*
|
|
569
|
-
* @param {string} layerNodeModules - The layer's nodejs/node_modules
|
|
570
|
-
* @param {string} prismaBinaryTarget - The engine the deployed architecture loads
|
|
571
|
-
* @param {Array} clientPackages - Generated client packages copied into the layer
|
|
572
|
-
* @param {string} coreVersion - The @friggframework/core the clients came from
|
|
509
|
+
* Verify rhel binaries are present
|
|
510
|
+
* @param {Array} expectedClients - List of client packages that should have binaries
|
|
573
511
|
*/
|
|
574
|
-
async function
|
|
575
|
-
|
|
576
|
-
prismaBinaryTarget,
|
|
577
|
-
clientPackages,
|
|
578
|
-
coreVersion
|
|
579
|
-
) {
|
|
580
|
-
logStep(8, `Verifying ${prismaBinaryTarget} query engines are present`);
|
|
581
|
-
|
|
582
|
-
const expectedEngine = `libquery_engine-${prismaBinaryTarget}.so.node`;
|
|
583
|
-
for (const pkg of clientPackages) {
|
|
584
|
-
const clientDir = path.join(layerNodeModules, pkg);
|
|
585
|
-
const files = (await fs.pathExists(clientDir))
|
|
586
|
-
? await fs.readdir(clientDir)
|
|
587
|
-
: [];
|
|
512
|
+
async function verifyRhelBinaries(expectedClients) {
|
|
513
|
+
logStep(8, 'Verifying rhel-openssl-3.0.x binaries are present');
|
|
588
514
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
);
|
|
595
|
-
}
|
|
515
|
+
try {
|
|
516
|
+
const findCmd = `find "${LAYER_NODE_MODULES}" -name "*rhel-openssl-3.0.x*" 2>/dev/null || true`;
|
|
517
|
+
const rhelFiles = execSync(findCmd, { encoding: 'utf8' })
|
|
518
|
+
.split('\n')
|
|
519
|
+
.filter((f) => f.trim());
|
|
596
520
|
|
|
597
|
-
|
|
598
|
-
if (otherEngines.length > 0) {
|
|
521
|
+
if (rhelFiles.length === 0) {
|
|
599
522
|
throw new Error(
|
|
600
|
-
|
|
601
|
-
', '
|
|
602
|
-
)} next to ${expectedEngine}.`
|
|
523
|
+
'No rhel-openssl-3.0.x binaries found!\n' +
|
|
524
|
+
'Check that Prisma schemas have binaryTargets = ["native", "rhel-openssl-3.0.x"]'
|
|
603
525
|
);
|
|
604
526
|
}
|
|
605
527
|
|
|
606
|
-
|
|
607
|
-
|
|
528
|
+
const expectedCount = expectedClients.length;
|
|
529
|
+
logSuccess(
|
|
530
|
+
`Found ${rhelFiles.length} rhel-openssl-3.0.x ${
|
|
531
|
+
rhelFiles.length === 1 ? 'binary' : 'binaries'
|
|
532
|
+
} (expected ${expectedCount})`
|
|
533
|
+
);
|
|
608
534
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
535
|
+
// Show the binaries found
|
|
536
|
+
rhelFiles.forEach((file) => {
|
|
537
|
+
const relativePath = path.relative(LAYER_NODE_MODULES, file);
|
|
538
|
+
log(` - ${relativePath}`, 'reset');
|
|
539
|
+
});
|
|
540
|
+
} catch (error) {
|
|
541
|
+
throw new Error(`Binary verification failed: ${error.message}`);
|
|
542
|
+
}
|
|
612
543
|
}
|
|
613
544
|
|
|
614
545
|
/**
|
|
@@ -676,7 +607,7 @@ async function displayLayerSummary() {
|
|
|
676
607
|
log(' - generated/prisma-postgresql (PostgreSQL client)', 'reset');
|
|
677
608
|
log('\nPackages EXCLUDED for minimal size:', 'bright');
|
|
678
609
|
log(' - prisma CLI (excluded - only in dbMigrate function)', 'yellow');
|
|
679
|
-
log(' - @prisma/engines (minimal - only
|
|
610
|
+
log(' - @prisma/engines (minimal - only rhel binary)', 'yellow');
|
|
680
611
|
|
|
681
612
|
log('\nNext steps:', 'bright');
|
|
682
613
|
log(
|
|
@@ -695,14 +626,9 @@ async function displayLayerSummary() {
|
|
|
695
626
|
|
|
696
627
|
/**
|
|
697
628
|
* Main build function
|
|
698
|
-
* @param {Object}
|
|
699
|
-
* @param {Object} options.databaseConfig - Database configuration from AppDefinition.database
|
|
700
|
-
* @param {string} options.prismaBinaryTarget - The engine the deployed architecture loads
|
|
629
|
+
* @param {Object} databaseConfig - Database configuration from AppDefinition.database
|
|
701
630
|
*/
|
|
702
|
-
async function buildPrismaLayer({
|
|
703
|
-
databaseConfig = {},
|
|
704
|
-
prismaBinaryTarget = resolveLambdaArchitecture().prismaBinaryTarget,
|
|
705
|
-
} = {}) {
|
|
631
|
+
async function buildPrismaLayer(databaseConfig = {}) {
|
|
706
632
|
const startTime = Date.now();
|
|
707
633
|
|
|
708
634
|
log('\n' + '='.repeat(60), 'bright');
|
|
@@ -712,11 +638,7 @@ async function buildPrismaLayer({
|
|
|
712
638
|
// Log paths
|
|
713
639
|
log(`Project root: ${PROJECT_ROOT}`, 'reset');
|
|
714
640
|
log(`Core package: ${CORE_PACKAGE_PATH}`, 'reset');
|
|
715
|
-
log(`Layer output: ${LAYER_OUTPUT_PATH}`, 'reset');
|
|
716
|
-
log(`Prisma binary target: ${prismaBinaryTarget}\n`, 'reset');
|
|
717
|
-
const coreVersion = fs.readJsonSync(
|
|
718
|
-
path.join(CORE_PACKAGE_PATH, 'package.json')
|
|
719
|
-
).version;
|
|
641
|
+
log(`Layer output: ${LAYER_OUTPUT_PATH}\n`, 'reset');
|
|
720
642
|
|
|
721
643
|
// Determine which database clients to include
|
|
722
644
|
const clientPackages = getGeneratedClientPackages(databaseConfig);
|
|
@@ -728,13 +650,8 @@ async function buildPrismaLayer({
|
|
|
728
650
|
await copyPrismaPackages(clientPackages); // Copy generated clients from core
|
|
729
651
|
await copyMigrations(clientPackages); // Copy migrations from core
|
|
730
652
|
await removeUnnecessaryFiles(); // Remove source maps, docs, tests (37MB+)
|
|
731
|
-
await
|
|
732
|
-
await
|
|
733
|
-
LAYER_NODE_MODULES,
|
|
734
|
-
prismaBinaryTarget,
|
|
735
|
-
clientPackages,
|
|
736
|
-
coreVersion
|
|
737
|
-
);
|
|
653
|
+
await removeNonRhelBinaries(); // Remove non-Linux binaries
|
|
654
|
+
await verifyRhelBinaries(clientPackages); // Verify query engines present
|
|
738
655
|
await verifyLayerStructure(clientPackages); // Verify minimal runtime structure
|
|
739
656
|
await displayLayerSummary();
|
|
740
657
|
|
|
@@ -781,7 +698,4 @@ module.exports = {
|
|
|
781
698
|
getMigrationSourcePath,
|
|
782
699
|
getMigrationDestinationPath,
|
|
783
700
|
getRequiredLayerPaths,
|
|
784
|
-
engineFilesToRemove,
|
|
785
|
-
verifyTargetBinaries,
|
|
786
|
-
layerBuildInputs,
|
|
787
701
|
};
|
|
@@ -8,9 +8,6 @@ const {
|
|
|
8
8
|
getMigrationsPackages,
|
|
9
9
|
getMigrationSourcePath,
|
|
10
10
|
getMigrationDestinationPath,
|
|
11
|
-
engineFilesToRemove,
|
|
12
|
-
verifyTargetBinaries,
|
|
13
|
-
layerBuildInputs,
|
|
14
11
|
} = require('./build-prisma-layer');
|
|
15
12
|
|
|
16
13
|
// Mock the log function
|
|
@@ -192,100 +189,3 @@ describe('getMigrationDestinationPath()', () => {
|
|
|
192
189
|
);
|
|
193
190
|
});
|
|
194
191
|
});
|
|
195
|
-
|
|
196
|
-
describe('engineFilesToRemove()', () => {
|
|
197
|
-
const files = [
|
|
198
|
-
'libquery_engine-rhel-openssl-3.0.x.so.node',
|
|
199
|
-
'libquery_engine-linux-arm64-openssl-3.0.x.so.node',
|
|
200
|
-
'libquery_engine-debian-openssl-3.0.x.so.node',
|
|
201
|
-
'schema-engine-rhel-openssl-3.0.x',
|
|
202
|
-
'query-engine-linux-arm64-openssl-3.0.x',
|
|
203
|
-
'query_engine_bg.wasm',
|
|
204
|
-
'index.js',
|
|
205
|
-
];
|
|
206
|
-
|
|
207
|
-
it('keeps the rhel engines and the non-engine files for an x86_64 target', () => {
|
|
208
|
-
expect(engineFilesToRemove(files, 'rhel-openssl-3.0.x')).toEqual([
|
|
209
|
-
'libquery_engine-linux-arm64-openssl-3.0.x.so.node',
|
|
210
|
-
'libquery_engine-debian-openssl-3.0.x.so.node',
|
|
211
|
-
'query-engine-linux-arm64-openssl-3.0.x',
|
|
212
|
-
]);
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
it('keeps the linux-arm64 engines and the non-engine files for an arm64 target', () => {
|
|
216
|
-
expect(engineFilesToRemove(files, 'linux-arm64-openssl-3.0.x')).toEqual([
|
|
217
|
-
'libquery_engine-rhel-openssl-3.0.x.so.node',
|
|
218
|
-
'libquery_engine-debian-openssl-3.0.x.so.node',
|
|
219
|
-
'schema-engine-rhel-openssl-3.0.x',
|
|
220
|
-
]);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
describe('verifyTargetBinaries()', () => {
|
|
225
|
-
const fs = require('fs');
|
|
226
|
-
const os = require('os');
|
|
227
|
-
const path = require('path');
|
|
228
|
-
const clients = ['generated/prisma-postgresql', 'generated/prisma-mongodb'];
|
|
229
|
-
let layerNodeModules;
|
|
230
|
-
|
|
231
|
-
const writeEngine = (client, engine) => {
|
|
232
|
-
const dir = path.join(layerNodeModules, client);
|
|
233
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
234
|
-
fs.writeFileSync(path.join(dir, engine), '');
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
beforeEach(() => {
|
|
238
|
-
layerNodeModules = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-prisma-layer-'));
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
afterEach(() => {
|
|
242
|
-
fs.rmSync(layerNodeModules, { recursive: true, force: true });
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it.each([
|
|
246
|
-
['rhel-openssl-3.0.x'],
|
|
247
|
-
['linux-arm64-openssl-3.0.x'],
|
|
248
|
-
])('passes when every client holds only the %s engine', async (target) => {
|
|
249
|
-
for (const client of clients) {
|
|
250
|
-
writeEngine(client, `libquery_engine-${target}.so.node`);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
await expect(
|
|
254
|
-
verifyTargetBinaries(layerNodeModules, target, clients, '2.0.0-next.0')
|
|
255
|
-
).resolves.toBeUndefined();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('fails naming the client, the target and the core version when one client lacks the engine', async () => {
|
|
259
|
-
writeEngine('generated/prisma-postgresql', 'libquery_engine-linux-arm64-openssl-3.0.x.so.node');
|
|
260
|
-
writeEngine('generated/prisma-mongodb', 'libquery_engine-rhel-openssl-3.0.x.so.node');
|
|
261
|
-
|
|
262
|
-
await expect(
|
|
263
|
-
verifyTargetBinaries(layerNodeModules, 'linux-arm64-openssl-3.0.x', clients, '2.0.0-next.105')
|
|
264
|
-
).rejects.toThrow(/prisma-mongodb.*linux-arm64-openssl-3\.0\.x[\s\S]*2\.0\.0-next\.105/);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('fails when a client still holds an engine for another Linux target', async () => {
|
|
268
|
-
writeEngine('generated/prisma-postgresql', 'libquery_engine-rhel-openssl-3.0.x.so.node');
|
|
269
|
-
writeEngine('generated/prisma-postgresql', 'libquery_engine-linux-arm64-openssl-3.0.x.so.node');
|
|
270
|
-
|
|
271
|
-
await expect(
|
|
272
|
-
verifyTargetBinaries(layerNodeModules, 'rhel-openssl-3.0.x', ['generated/prisma-postgresql'], '2.0.0-next.0')
|
|
273
|
-
).rejects.toThrow(/libquery_engine-linux-arm64-openssl-3\.0\.x\.so\.node/);
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
describe('layerBuildInputs()', () => {
|
|
278
|
-
it('names the target, the client set and the core and @prisma/client versions the layer is built from', () => {
|
|
279
|
-
const inputs = layerBuildInputs({
|
|
280
|
-
databaseConfig: { postgres: { enable: true }, mongoDB: { enable: true } },
|
|
281
|
-
prismaBinaryTarget: 'linux-arm64-openssl-3.0.x',
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
expect(inputs).toEqual({
|
|
285
|
-
prismaBinaryTarget: 'linux-arm64-openssl-3.0.x',
|
|
286
|
-
clientPackages: ['generated/prisma-mongodb', 'generated/prisma-postgresql'],
|
|
287
|
-
coreVersion: require('@friggframework/core/package.json').version,
|
|
288
|
-
prismaClientVersion: require('@prisma/client/package.json').version,
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
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.730.f2ba24a.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@babel/eslint-parser": "^7.18.9",
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
|
-
"@friggframework/core": "2.0.0--canary.
|
|
32
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
33
|
-
"@friggframework/test": "2.0.0--canary.
|
|
31
|
+
"@friggframework/core": "2.0.0--canary.730.f2ba24a.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.730.f2ba24a.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.730.f2ba24a.0",
|
|
34
34
|
"@hapi/boom": "^10.0.1",
|
|
35
35
|
"@inquirer/prompts": "^5.3.8",
|
|
36
36
|
"axios": "^1.18.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"validate-npm-package-name": "^5.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
62
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
61
|
+
"@friggframework/eslint-config": "2.0.0--canary.730.f2ba24a.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.730.f2ba24a.0",
|
|
63
63
|
"aws-sdk-client-mock": "^4.1.0",
|
|
64
64
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
65
65
|
"jest": "^30.1.3",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "f2ba24a33f80389cf136570c132f04e7a38c3c72"
|
|
95
95
|
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared cases for every builder whose functions bundle Prisma when the
|
|
3
|
-
* Prisma layer is off.
|
|
4
|
-
* @param {(usePrismaLayer: boolean, architecture?: string) => Promise<Object[]>|Object[]} functionsOf
|
|
5
|
-
* Builds the app and returns its function definitions
|
|
6
|
-
*/
|
|
7
|
-
function itBundlesOnlyTheTargetPrismaEngine(functionsOf) {
|
|
8
|
-
it.each([
|
|
9
|
-
[undefined, 'rhel-openssl-3.0.x', 'linux-arm64-openssl-3.0.x'],
|
|
10
|
-
['x86_64', 'rhel-openssl-3.0.x', 'linux-arm64-openssl-3.0.x'],
|
|
11
|
-
['arm64', 'linux-arm64-openssl-3.0.x', 'rhel-openssl-3.0.x'],
|
|
12
|
-
])(
|
|
13
|
-
'with the layer off and architecture %s, the bundled Prisma keeps only the %s engine',
|
|
14
|
-
async (architecture, target, otherTarget) => {
|
|
15
|
-
for (const fn of await functionsOf(false, architecture)) {
|
|
16
|
-
expect(fn.package.exclude).toEqual(
|
|
17
|
-
expect.arrayContaining([
|
|
18
|
-
'**/libquery_engine-debian*',
|
|
19
|
-
`**/libquery_engine-${otherTarget}*`,
|
|
20
|
-
])
|
|
21
|
-
);
|
|
22
|
-
expect(fn.package.exclude).not.toContain(`**/libquery_engine-${target}*`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
it('with the layer on, adds no engine patterns, since the layer carries the engines', async () => {
|
|
28
|
-
for (const fn of await functionsOf(true, 'arm64')) {
|
|
29
|
-
expect(fn.package.exclude).not.toEqual(
|
|
30
|
-
expect.arrayContaining(['**/libquery_engine-rhel-openssl-3.0.x*'])
|
|
31
|
-
);
|
|
32
|
-
expect(fn.package.exclude).not.toEqual(
|
|
33
|
-
expect.arrayContaining(['**/libquery_engine-debian*'])
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = { itBundlesOnlyTheTargetPrismaEngine };
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Migration worker engines
|
|
3
|
-
*
|
|
4
|
-
* Domain Layer - Hexagonal Architecture
|
|
5
|
-
*
|
|
6
|
-
* The migration worker runs the Prisma CLI, which needs the schema engine
|
|
7
|
-
* and the query engine library for the Lambda architecture it runs on. Both
|
|
8
|
-
* ship from node_modules/@prisma/engines/, where the @prisma/engines
|
|
9
|
-
* postinstall put the deploy host's own engines. This fetches the deployed
|
|
10
|
-
* architecture's pair before packaging, and fails packaging when either is
|
|
11
|
-
* still missing, so a worker can never try to download an engine into the
|
|
12
|
-
* read-only /var/task at cold start.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const fs = require('fs');
|
|
16
|
-
const path = require('path');
|
|
17
|
-
const { execFileSync } = require('child_process');
|
|
18
|
-
const { prismaEngineFileNames, PRISMA_ENGINES_PACKAGE_DIR } = require('../shared/lambda-architectures');
|
|
19
|
-
|
|
20
|
-
function resolveEnginesDir(cwd) {
|
|
21
|
-
const enginesDir = path.join(cwd, PRISMA_ENGINES_PACKAGE_DIR);
|
|
22
|
-
if (!fs.existsSync(path.join(enginesDir, 'scripts', 'postinstall.js'))) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`@prisma/engines was not found at ${enginesDir}.\n` +
|
|
25
|
-
'The app must have prisma installed in its own node_modules, not only in a hoisted parent: ' +
|
|
26
|
-
'the migration worker ships its engines from the app\'s node_modules.'
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
return enginesDir;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Runs the @prisma/engines postinstall for one target. It downloads only
|
|
34
|
-
* the engines that are missing, so the host's own engines stay. The host's
|
|
35
|
-
* pinned engine paths are hidden from it: with them set, the postinstall
|
|
36
|
-
* skips those engines instead of downloading them.
|
|
37
|
-
*/
|
|
38
|
-
function runEnginesPostinstall({ enginesDir, prismaBinaryTarget }) {
|
|
39
|
-
const hostEnv = { ...process.env };
|
|
40
|
-
delete hostEnv.PRISMA_SCHEMA_ENGINE_BINARY;
|
|
41
|
-
delete hostEnv.PRISMA_QUERY_ENGINE_LIBRARY;
|
|
42
|
-
execFileSync(
|
|
43
|
-
process.execPath,
|
|
44
|
-
[path.join(enginesDir, 'scripts', 'postinstall.js')],
|
|
45
|
-
{
|
|
46
|
-
cwd: enginesDir,
|
|
47
|
-
stdio: 'inherit',
|
|
48
|
-
env: { ...hostEnv, PRISMA_CLI_BINARY_TARGETS: prismaBinaryTarget },
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param {Object} options
|
|
55
|
-
* @param {string} options.prismaBinaryTarget - The engine the deployed architecture loads
|
|
56
|
-
* @param {string} [options.cwd] - The app root
|
|
57
|
-
* @param {string} [options.enginesDir] - node_modules/@prisma/engines of the app
|
|
58
|
-
* @param {Function} [options.fetchEngines] - Fetches the target's engines into enginesDir
|
|
59
|
-
* @throws {Error} When either engine is missing after the fetch
|
|
60
|
-
*/
|
|
61
|
-
async function ensureMigrationEngines({
|
|
62
|
-
prismaBinaryTarget,
|
|
63
|
-
cwd = process.cwd(),
|
|
64
|
-
enginesDir = resolveEnginesDir(cwd),
|
|
65
|
-
fetchEngines = runEnginesPostinstall,
|
|
66
|
-
}) {
|
|
67
|
-
const engineNames = Object.values(prismaEngineFileNames(prismaBinaryTarget));
|
|
68
|
-
const missing = () =>
|
|
69
|
-
engineNames.filter((name) => !fs.existsSync(path.join(enginesDir, name)));
|
|
70
|
-
|
|
71
|
-
if (missing().length === 0) {
|
|
72
|
-
console.log(`✓ Prisma ${prismaBinaryTarget} migration engines present in ${enginesDir}`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
console.log(
|
|
77
|
-
`📦 Fetching ${missing().join(', ')} (Prisma ${prismaBinaryTarget}) into ${enginesDir}...`
|
|
78
|
-
);
|
|
79
|
-
fetchEngines({ enginesDir, prismaBinaryTarget });
|
|
80
|
-
|
|
81
|
-
const stillMissing = missing();
|
|
82
|
-
if (stillMissing.length > 0) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
`Prisma migration engines for ${prismaBinaryTarget} are missing after the fetch: ` +
|
|
85
|
-
`${stillMissing.join(', ')} (in ${enginesDir}).\n` +
|
|
86
|
-
"The deploy host must reach Prisma's engine CDN (binaries.prisma.sh) at package time."
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
module.exports = {
|
|
92
|
-
ensureMigrationEngines,
|
|
93
|
-
};
|