@friggframework/devtools 2.0.0--canary.658.e11f3b0.0 → 2.0.0--canary.737.83b4e17.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/README.md +115 -31
- package/frigg-cli/__tests__/unit/commands/build.test.js +3 -0
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +33 -24
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +10 -6
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +18 -0
- package/frigg-cli/__tests__/unit/commands/init.test.js +688 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +601 -341
- package/frigg-cli/__tests__/unit/commands/ui.test.js +31 -30
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +92 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +6 -2
- package/frigg-cli/build-command/index.js +6 -0
- package/frigg-cli/deploy-command/index.js +6 -0
- package/frigg-cli/generate-command/index.js +1 -0
- package/frigg-cli/generate-iam-command.js +1 -0
- package/frigg-cli/index.js +22 -5
- package/frigg-cli/init-command/backend-first-handler.js +395 -551
- package/frigg-cli/init-command/deployment-modes.js +7 -0
- package/frigg-cli/init-command/index.js +82 -35
- package/frigg-cli/init-command/safe-path.js +58 -0
- package/frigg-cli/init-command/scaffold-dependencies.js +202 -0
- package/frigg-cli/install-command/app-definition.js +174 -0
- package/frigg-cli/install-command/commit-changes.js +40 -8
- package/frigg-cli/install-command/environment-variables.js +15 -0
- package/frigg-cli/install-command/index.js +96 -21
- package/frigg-cli/install-command/install-package.js +77 -4
- package/frigg-cli/install-command/integration-file.js +20 -11
- package/frigg-cli/install-command/resolve-module.js +69 -0
- package/frigg-cli/install-command/template.js +102 -75
- package/frigg-cli/install-command/validate-package.js +36 -4
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +4 -0
- package/frigg-cli/start-command/start-command.test.js +3 -0
- package/frigg-cli/templates/backend/README.md +267 -0
- package/frigg-cli/templates/backend/env.example +20 -0
- package/frigg-cli/templates/backend/gitignore +10 -0
- package/frigg-cli/templates/backend/index.js +114 -0
- package/frigg-cli/templates/backend/infrastructure.js +20 -0
- package/frigg-cli/test/init-command.test.js +9 -2
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +63 -0
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +133 -0
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +443 -0
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +262 -0
- package/frigg-cli/validate-command/checks/config.js +504 -0
- package/frigg-cli/validate-command/checks/integrations.js +274 -0
- package/frigg-cli/validate-command/format-report.js +58 -0
- package/frigg-cli/validate-command/index.js +107 -0
- package/frigg-cli/validate-command/load-app-definition.js +105 -0
- package/frigg-cli/validate-command/schema-issues.js +154 -0
- package/frigg-cli/validate-command/validate-app-definition.js +60 -0
- package/infrastructure/README.md +32 -5
- package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +39 -0
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +284 -0
- package/infrastructure/__tests__/postgres-config.test.js +245 -836
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +151 -0
- package/infrastructure/__tests__/scoped-environment.test.js +3 -0
- package/infrastructure/__tests__/ssm-preload-node-options.test.js +3 -0
- package/infrastructure/__tests__/template-generation.test.js +39 -8
- package/infrastructure/app-definition-schema-contract.test.js +634 -0
- package/infrastructure/create-frigg-infrastructure.js +4 -1
- package/infrastructure/create-frigg-infrastructure.test.js +51 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +80 -98
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +8 -2
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +52 -6
- package/infrastructure/domains/database/aurora-builder.js +13 -2
- package/infrastructure/domains/database/aurora-builder.test.js +22 -0
- package/infrastructure/domains/database/migration-builder.js +21 -2
- package/infrastructure/domains/database/migration-builder.test.js +61 -6
- package/infrastructure/domains/database/migration-engines.js +93 -0
- package/infrastructure/domains/database/migration-engines.test.js +142 -0
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
- package/infrastructure/domains/integration/integration-builder.js +2 -0
- package/infrastructure/domains/integration/integration-builder.test.js +22 -6
- package/infrastructure/domains/networking/vpc-builder.js +18 -8
- package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
- package/infrastructure/domains/security/iam-generator.js +112 -5
- package/infrastructure/domains/security/iam-generator.test.js +94 -0
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
- package/infrastructure/domains/shared/environment-builder.js +31 -5
- package/infrastructure/domains/shared/environment-builder.test.js +93 -7
- package/infrastructure/domains/shared/lambda-architectures.js +113 -0
- package/infrastructure/domains/shared/lambda-architectures.test.js +164 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +39 -3
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +85 -5
- 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 +92 -12
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +158 -6
- package/infrastructure/infrastructure-composer.js +12 -1
- package/infrastructure/infrastructure-composer.test.js +339 -794
- package/infrastructure/scripts/build-prisma-layer.js +136 -50
- package/infrastructure/scripts/build-prisma-layer.test.js +128 -7
- package/infrastructure/scripts/build-time-discovery.test.js +18 -3
- package/package.json +12 -10
- package/frigg-cli/index.test.js +0 -158
- package/infrastructure/integration.test.js +0 -381
|
@@ -34,6 +34,9 @@
|
|
|
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');
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* Find @friggframework/core package, handling workspace hoisting
|
|
@@ -93,6 +96,31 @@ function getGeneratedClientPackages(databaseConfig = {}) {
|
|
|
93
96
|
return packages;
|
|
94
97
|
}
|
|
95
98
|
|
|
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
|
+
|
|
96
124
|
function getMigrationsPackages(clientPackages) {
|
|
97
125
|
return clientPackages.map((pkg) => ({
|
|
98
126
|
dbType: pkg.replace('generated/prisma-', ''),
|
|
@@ -158,15 +186,34 @@ const CORE_PACKAGE_PATH = findCorePackage(PROJECT_ROOT);
|
|
|
158
186
|
const LAYER_OUTPUT_PATH = path.join(PROJECT_ROOT, 'layers/prisma');
|
|
159
187
|
const LAYER_NODE_MODULES = path.join(LAYER_OUTPUT_PATH, 'nodejs/node_modules');
|
|
160
188
|
|
|
161
|
-
// Binary patterns
|
|
189
|
+
// Binary patterns no Lambda architecture runs
|
|
162
190
|
const BINARY_PATTERNS_TO_REMOVE = [
|
|
163
191
|
'*darwin*',
|
|
164
192
|
'*debian*',
|
|
165
|
-
'*linux-arm*',
|
|
166
193
|
'*linux-musl*',
|
|
167
194
|
'*windows*',
|
|
168
195
|
];
|
|
169
196
|
|
|
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
|
+
|
|
170
217
|
// Files to remove for size optimization
|
|
171
218
|
const FILES_TO_REMOVE = [
|
|
172
219
|
'*.map', // Source maps (37MB savings)
|
|
@@ -276,21 +323,15 @@ async function installPrismaPackages() {
|
|
|
276
323
|
await fs.writeJson(packageJsonPath, layerPackageJson, { spaces: 2 });
|
|
277
324
|
logSuccess('Created layer package.json');
|
|
278
325
|
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
log('Installing @prisma/client
|
|
326
|
+
// The runtime client has no engine postinstall; the query engines come
|
|
327
|
+
// from the generated clients copied out of @friggframework/core.
|
|
328
|
+
log('Installing @prisma/client...');
|
|
282
329
|
try {
|
|
283
|
-
const env = {
|
|
284
|
-
...process.env,
|
|
285
|
-
PRISMA_CLI_BINARY_TARGETS: 'rhel-openssl-3.0.x',
|
|
286
|
-
};
|
|
287
|
-
|
|
288
330
|
execSync('npm install --omit=dev --no-package-lock', {
|
|
289
331
|
cwd: path.join(LAYER_OUTPUT_PATH, 'nodejs'),
|
|
290
332
|
stdio: 'inherit',
|
|
291
|
-
env,
|
|
292
333
|
});
|
|
293
|
-
logSuccess('Prisma packages installed
|
|
334
|
+
logSuccess('Prisma packages installed');
|
|
294
335
|
} catch (error) {
|
|
295
336
|
throw new Error(`Failed to install Prisma packages: ${error.message}`);
|
|
296
337
|
}
|
|
@@ -466,23 +507,40 @@ async function removeUnnecessaryFiles() {
|
|
|
466
507
|
}
|
|
467
508
|
|
|
468
509
|
/**
|
|
469
|
-
* Remove
|
|
510
|
+
* Remove engine binaries the deployed architecture does not load
|
|
511
|
+
* @param {string} prismaBinaryTarget - The engine the deployed architecture loads
|
|
470
512
|
*/
|
|
471
|
-
async function
|
|
472
|
-
logStep(7,
|
|
513
|
+
async function removeForeignBinaries(prismaBinaryTarget) {
|
|
514
|
+
logStep(7, `Removing engine binaries other than ${prismaBinaryTarget}`);
|
|
473
515
|
|
|
474
516
|
let removedCount = 0;
|
|
475
517
|
let totalSize = 0;
|
|
476
518
|
|
|
477
|
-
|
|
519
|
+
const findPatterns = [
|
|
520
|
+
...BINARY_PATTERNS_TO_REMOVE,
|
|
521
|
+
...ENGINE_FILE_PREFIXES.map((prefix) => `${prefix}*`),
|
|
522
|
+
];
|
|
523
|
+
for (const pattern of findPatterns) {
|
|
478
524
|
try {
|
|
479
525
|
// Find files matching the pattern
|
|
480
526
|
const findCmd = `find "${LAYER_NODE_MODULES}" -name "${pattern}" 2>/dev/null || true`;
|
|
481
527
|
const files = execSync(findCmd, { encoding: 'utf8' })
|
|
482
528
|
.split('\n')
|
|
483
529
|
.filter((f) => f.trim());
|
|
530
|
+
const foreign = new Set(
|
|
531
|
+
engineFilesToRemove(
|
|
532
|
+
files.map((f) => path.basename(f)),
|
|
533
|
+
prismaBinaryTarget
|
|
534
|
+
)
|
|
535
|
+
);
|
|
484
536
|
|
|
485
537
|
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
|
+
}
|
|
486
544
|
if (await fs.pathExists(file)) {
|
|
487
545
|
const stats = await fs.stat(file);
|
|
488
546
|
totalSize += stats.size;
|
|
@@ -498,48 +556,59 @@ async function removeNonRhelBinaries() {
|
|
|
498
556
|
if (removedCount > 0) {
|
|
499
557
|
const sizeMB = (totalSize / (1024 * 1024)).toFixed(2);
|
|
500
558
|
logSuccess(
|
|
501
|
-
`Removed ${removedCount}
|
|
559
|
+
`Removed ${removedCount} foreign binaries (saved ${sizeMB} MB)`
|
|
502
560
|
);
|
|
503
561
|
} else {
|
|
504
|
-
log('No
|
|
562
|
+
log('No foreign binaries found to remove');
|
|
505
563
|
}
|
|
506
564
|
}
|
|
507
565
|
|
|
508
566
|
/**
|
|
509
|
-
* Verify
|
|
510
|
-
*
|
|
567
|
+
* Verify each generated client holds the target query engine and no other
|
|
568
|
+
* Linux engine
|
|
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
|
|
511
573
|
*/
|
|
512
|
-
async function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
574
|
+
async function verifyTargetBinaries(
|
|
575
|
+
layerNodeModules,
|
|
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
|
+
: [];
|
|
520
588
|
|
|
521
|
-
if (
|
|
589
|
+
if (!files.includes(expectedEngine)) {
|
|
522
590
|
throw new Error(
|
|
523
|
-
|
|
524
|
-
|
|
591
|
+
`Binary verification failed: ${pkg} has no ${expectedEngine}.\n` +
|
|
592
|
+
`@friggframework/core ${coreVersion} did not generate the ${prismaBinaryTarget} engine. ` +
|
|
593
|
+
`Upgrade to a core release whose Prisma schemas list ${prismaBinaryTarget} in binaryTargets.`
|
|
525
594
|
);
|
|
526
595
|
}
|
|
527
596
|
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
597
|
+
const otherEngines = engineFilesToRemove(files, prismaBinaryTarget);
|
|
598
|
+
if (otherEngines.length > 0) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
`Binary verification failed: ${pkg} still holds ${otherEngines.join(
|
|
601
|
+
', '
|
|
602
|
+
)} next to ${expectedEngine}.`
|
|
603
|
+
);
|
|
604
|
+
}
|
|
534
605
|
|
|
535
|
-
|
|
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}`);
|
|
606
|
+
log(` - ${pkg}/${expectedEngine}`, 'reset');
|
|
542
607
|
}
|
|
608
|
+
|
|
609
|
+
logSuccess(
|
|
610
|
+
`Each of ${clientPackages.length} client(s) holds only ${expectedEngine}`
|
|
611
|
+
);
|
|
543
612
|
}
|
|
544
613
|
|
|
545
614
|
/**
|
|
@@ -607,7 +676,7 @@ async function displayLayerSummary() {
|
|
|
607
676
|
log(' - generated/prisma-postgresql (PostgreSQL client)', 'reset');
|
|
608
677
|
log('\nPackages EXCLUDED for minimal size:', 'bright');
|
|
609
678
|
log(' - prisma CLI (excluded - only in dbMigrate function)', 'yellow');
|
|
610
|
-
log(' - @prisma/engines (minimal - only
|
|
679
|
+
log(' - @prisma/engines (minimal - only the target engine)', 'yellow');
|
|
611
680
|
|
|
612
681
|
log('\nNext steps:', 'bright');
|
|
613
682
|
log(
|
|
@@ -626,9 +695,14 @@ async function displayLayerSummary() {
|
|
|
626
695
|
|
|
627
696
|
/**
|
|
628
697
|
* Main build function
|
|
629
|
-
* @param {Object}
|
|
698
|
+
* @param {Object} options
|
|
699
|
+
* @param {Object} options.databaseConfig - Database configuration from AppDefinition.database
|
|
700
|
+
* @param {string} options.prismaBinaryTarget - The engine the deployed architecture loads
|
|
630
701
|
*/
|
|
631
|
-
async function buildPrismaLayer(
|
|
702
|
+
async function buildPrismaLayer({
|
|
703
|
+
databaseConfig = {},
|
|
704
|
+
prismaBinaryTarget = resolveLambdaArchitecture().prismaBinaryTarget,
|
|
705
|
+
} = {}) {
|
|
632
706
|
const startTime = Date.now();
|
|
633
707
|
|
|
634
708
|
log('\n' + '='.repeat(60), 'bright');
|
|
@@ -638,7 +712,11 @@ async function buildPrismaLayer(databaseConfig = {}) {
|
|
|
638
712
|
// Log paths
|
|
639
713
|
log(`Project root: ${PROJECT_ROOT}`, 'reset');
|
|
640
714
|
log(`Core package: ${CORE_PACKAGE_PATH}`, 'reset');
|
|
641
|
-
log(`Layer output: ${LAYER_OUTPUT_PATH}
|
|
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;
|
|
642
720
|
|
|
643
721
|
// Determine which database clients to include
|
|
644
722
|
const clientPackages = getGeneratedClientPackages(databaseConfig);
|
|
@@ -650,8 +728,13 @@ async function buildPrismaLayer(databaseConfig = {}) {
|
|
|
650
728
|
await copyPrismaPackages(clientPackages); // Copy generated clients from core
|
|
651
729
|
await copyMigrations(clientPackages); // Copy migrations from core
|
|
652
730
|
await removeUnnecessaryFiles(); // Remove source maps, docs, tests (37MB+)
|
|
653
|
-
await
|
|
654
|
-
await
|
|
731
|
+
await removeForeignBinaries(prismaBinaryTarget); // Keep only the target's engines
|
|
732
|
+
await verifyTargetBinaries(
|
|
733
|
+
LAYER_NODE_MODULES,
|
|
734
|
+
prismaBinaryTarget,
|
|
735
|
+
clientPackages,
|
|
736
|
+
coreVersion
|
|
737
|
+
);
|
|
655
738
|
await verifyLayerStructure(clientPackages); // Verify minimal runtime structure
|
|
656
739
|
await displayLayerSummary();
|
|
657
740
|
|
|
@@ -698,4 +781,7 @@ module.exports = {
|
|
|
698
781
|
getMigrationSourcePath,
|
|
699
782
|
getMigrationDestinationPath,
|
|
700
783
|
getRequiredLayerPaths,
|
|
784
|
+
engineFilesToRemove,
|
|
785
|
+
verifyTargetBinaries,
|
|
786
|
+
layerBuildInputs,
|
|
701
787
|
};
|
|
@@ -8,6 +8,9 @@ const {
|
|
|
8
8
|
getMigrationsPackages,
|
|
9
9
|
getMigrationSourcePath,
|
|
10
10
|
getMigrationDestinationPath,
|
|
11
|
+
engineFilesToRemove,
|
|
12
|
+
verifyTargetBinaries,
|
|
13
|
+
layerBuildInputs,
|
|
11
14
|
} = require('./build-prisma-layer');
|
|
12
15
|
|
|
13
16
|
// Mock the log function
|
|
@@ -143,14 +146,35 @@ describe('getMigrationsPackages()', () => {
|
|
|
143
146
|
});
|
|
144
147
|
|
|
145
148
|
describe('getMigrationSourcePath()', () => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
+
// getMigrationSourcePath() returns the first search path whose
|
|
150
|
+
// prisma-<dbType>/migrations directory exists on disk, so the test needs a
|
|
151
|
+
// real directory rather than a made-up absolute path.
|
|
152
|
+
const fs = require('fs');
|
|
153
|
+
const os = require('os');
|
|
154
|
+
const path = require('path');
|
|
155
|
+
let tmpRoot;
|
|
156
|
+
|
|
157
|
+
beforeEach(() => {
|
|
158
|
+
tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-prisma-layer-'));
|
|
159
|
+
});
|
|
149
160
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
afterEach(() => {
|
|
162
|
+
fs.rmSync(tmpRoot, { recursive: true, force: true });
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('should return the migrations path of the first search path that has one', () => {
|
|
166
|
+
const missing = path.join(tmpRoot, 'missing');
|
|
167
|
+
const core = path.join(tmpRoot, 'packages', 'core');
|
|
168
|
+
const expected = path.join(core, 'prisma-postgresql', 'migrations');
|
|
169
|
+
fs.mkdirSync(expected, { recursive: true });
|
|
170
|
+
|
|
171
|
+
const sourcePath = getMigrationSourcePath([missing, core], 'postgresql');
|
|
172
|
+
expect(sourcePath).toBe(expected);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should return null when no search path has migrations for the database type', () => {
|
|
176
|
+
const sourcePath = getMigrationSourcePath([tmpRoot], 'postgresql');
|
|
177
|
+
expect(sourcePath).toBeNull();
|
|
154
178
|
});
|
|
155
179
|
});
|
|
156
180
|
|
|
@@ -168,3 +192,100 @@ describe('getMigrationDestinationPath()', () => {
|
|
|
168
192
|
);
|
|
169
193
|
});
|
|
170
194
|
});
|
|
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
|
+
});
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
// SKIPPED: BuildTimeDiscovery lazily requires './aws-discovery', which was
|
|
5
|
+
// deleted in the hexagonal infrastructure refactor (7b36f0f4). Discovery now
|
|
6
|
+
// lives in domains/shared/resource-discovery.js + providers/aws-provider-adapter.js,
|
|
7
|
+
// and nothing in devtools, the CLI or the serverless plugin invokes
|
|
8
|
+
// build-time-discovery.js / run-discovery.js any more, so this suite cannot load
|
|
9
|
+
// its subject. Either port BuildTimeDiscovery to gatherDiscoveredResources() and
|
|
10
|
+
// rewrite these tests, or delete the dead module and this suite.
|
|
11
|
+
// Tracked in https://github.com/friggframework/frigg/issues/708
|
|
12
|
+
let BuildTimeDiscovery;
|
|
13
|
+
let runBuildTimeDiscovery;
|
|
14
|
+
let AWSDiscovery;
|
|
5
15
|
|
|
6
16
|
// Mock dependencies
|
|
7
17
|
jest.mock('fs');
|
|
8
18
|
// Mock will be updated when tests are rewritten for new provider architecture
|
|
9
19
|
// jest.mock('./aws-discovery');
|
|
10
20
|
|
|
11
|
-
describe('BuildTimeDiscovery', () => {
|
|
21
|
+
describe.skip('BuildTimeDiscovery', () => {
|
|
22
|
+
beforeAll(() => {
|
|
23
|
+
({ BuildTimeDiscovery, runBuildTimeDiscovery } = require('./build-time-discovery'));
|
|
24
|
+
({ AWSDiscovery } = require('./aws-discovery'));
|
|
25
|
+
});
|
|
26
|
+
|
|
12
27
|
let buildTimeDiscovery;
|
|
13
28
|
let mockAWSDiscovery;
|
|
14
29
|
const originalEnv = process.env;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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.737.83b4e17.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"frigg-cli/",
|
|
10
|
+
"frigg-cli/templates/",
|
|
10
11
|
"infrastructure/",
|
|
11
12
|
"migrations/",
|
|
12
13
|
"management-ui/dist/",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"@aws-sdk/client-cloudformation": "^3.705.0",
|
|
19
20
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
20
21
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
22
|
+
"@aws-sdk/client-lambda": "^3.714.0",
|
|
21
23
|
"@aws-sdk/client-rds": "^3.906.0",
|
|
22
24
|
"@aws-sdk/client-s3": "^3.917.0",
|
|
23
25
|
"@aws-sdk/client-secrets-manager": "^3.906.0",
|
|
@@ -26,13 +28,13 @@
|
|
|
26
28
|
"@babel/eslint-parser": "^7.18.9",
|
|
27
29
|
"@babel/parser": "^7.25.3",
|
|
28
30
|
"@babel/traverse": "^7.25.3",
|
|
29
|
-
"@friggframework/core": "2.0.0--canary.
|
|
30
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
31
|
-
"@friggframework/test": "2.0.0--canary.
|
|
31
|
+
"@friggframework/core": "2.0.0--canary.737.83b4e17.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.737.83b4e17.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.737.83b4e17.0",
|
|
32
34
|
"@hapi/boom": "^10.0.1",
|
|
33
35
|
"@inquirer/prompts": "^5.3.8",
|
|
34
36
|
"axios": "^1.18.0",
|
|
35
|
-
"body-parser": "^1.20.
|
|
37
|
+
"body-parser": "^1.20.9",
|
|
36
38
|
"chalk": "^4.1.2",
|
|
37
39
|
"commander": "^12.1.0",
|
|
38
40
|
"cors": "^2.8.5",
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
"eslint-plugin-markdown": "^3.0.0",
|
|
45
47
|
"eslint-plugin-no-only-tests": "^3.0.0",
|
|
46
48
|
"eslint-plugin-yaml": "^0.5.0",
|
|
47
|
-
"express": "^4.22.
|
|
49
|
+
"express": "^4.22.3",
|
|
48
50
|
"express-async-handler": "^1.2.0",
|
|
49
51
|
"fs-extra": "^11.2.0",
|
|
50
52
|
"js-yaml": "^4.1.0",
|
|
@@ -56,12 +58,12 @@
|
|
|
56
58
|
"validate-npm-package-name": "^5.0.0"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
60
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
61
|
+
"@friggframework/eslint-config": "2.0.0--canary.737.83b4e17.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.737.83b4e17.0",
|
|
61
63
|
"aws-sdk-client-mock": "^4.1.0",
|
|
62
64
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
63
65
|
"jest": "^30.1.3",
|
|
64
|
-
"osls": "^3.
|
|
66
|
+
"osls": "^3.78.0",
|
|
65
67
|
"prettier": "^2.7.1",
|
|
66
68
|
"serverless-dotenv-plugin": "^6.0.0",
|
|
67
69
|
"serverless-esbuild": "^1.54.3",
|
|
@@ -89,5 +91,5 @@
|
|
|
89
91
|
"publishConfig": {
|
|
90
92
|
"access": "public"
|
|
91
93
|
},
|
|
92
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "83b4e17ac7ec4481bd8143508a2a532e399fcce8"
|
|
93
95
|
}
|