@friggframework/devtools 2.0.0-next.127 → 2.0.0-next.128

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.
Files changed (32) hide show
  1. package/infrastructure/README.md +32 -5
  2. package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +39 -0
  3. package/infrastructure/__tests__/management-api-gateway-routes.test.js +3 -0
  4. package/infrastructure/__tests__/postgres-config.test.js +3 -0
  5. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +3 -0
  6. package/infrastructure/__tests__/scoped-environment.test.js +3 -0
  7. package/infrastructure/__tests__/ssm-preload-node-options.test.js +3 -0
  8. package/infrastructure/__tests__/template-generation.test.js +3 -0
  9. package/infrastructure/app-definition-schema-contract.test.js +5 -0
  10. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -0
  11. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +22 -6
  12. package/infrastructure/domains/database/migration-builder.js +21 -2
  13. package/infrastructure/domains/database/migration-builder.test.js +61 -6
  14. package/infrastructure/domains/database/migration-engines.js +93 -0
  15. package/infrastructure/domains/database/migration-engines.test.js +142 -0
  16. package/infrastructure/domains/integration/integration-builder.js +2 -0
  17. package/infrastructure/domains/integration/integration-builder.test.js +22 -6
  18. package/infrastructure/domains/shared/environment-builder.js +31 -5
  19. package/infrastructure/domains/shared/environment-builder.test.js +93 -7
  20. package/infrastructure/domains/shared/lambda-architectures.js +113 -0
  21. package/infrastructure/domains/shared/lambda-architectures.test.js +164 -0
  22. package/infrastructure/domains/shared/utilities/base-definition-factory.js +13 -1
  23. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +51 -4
  24. package/infrastructure/domains/shared/utilities/nested-node-modules.js +6 -5
  25. package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +20 -26
  26. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +92 -12
  27. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +158 -6
  28. package/infrastructure/infrastructure-composer.js +12 -1
  29. package/infrastructure/infrastructure-composer.test.js +71 -0
  30. package/infrastructure/scripts/build-prisma-layer.js +136 -50
  31. package/infrastructure/scripts/build-prisma-layer.test.js +100 -0
  32. package/package.json +7 -7
@@ -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
@@ -189,3 +192,100 @@ describe('getMigrationDestinationPath()', () => {
189
192
  );
190
193
  });
191
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
+ });
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-next.127",
4
+ "version": "2.0.0-next.128",
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-next.127",
32
- "@friggframework/schemas": "2.0.0-next.127",
33
- "@friggframework/test": "2.0.0-next.127",
31
+ "@friggframework/core": "2.0.0-next.128",
32
+ "@friggframework/schemas": "2.0.0-next.128",
33
+ "@friggframework/test": "2.0.0-next.128",
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-next.127",
62
- "@friggframework/prettier-config": "2.0.0-next.127",
61
+ "@friggframework/eslint-config": "2.0.0-next.128",
62
+ "@friggframework/prettier-config": "2.0.0-next.128",
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": "e6796e46e531d2eb18d801ae9ace8cebdc93be03"
94
+ "gitHead": "c116a4803d205e5b54a59d56d8b163ab43d66205"
95
95
  }