@friggframework/devtools 2.0.0--canary.731.1c0b281.0 → 2.0.0--canary.730.541f199.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.
Files changed (28) hide show
  1. package/infrastructure/README.md +0 -27
  2. package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -3
  3. package/infrastructure/__tests__/postgres-config.test.js +0 -3
  4. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -3
  5. package/infrastructure/__tests__/scoped-environment.test.js +0 -3
  6. package/infrastructure/__tests__/ssm-preload-node-options.test.js +0 -3
  7. package/infrastructure/__tests__/template-generation.test.js +0 -3
  8. package/infrastructure/app-definition-schema-contract.test.js +0 -5
  9. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -2
  10. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -16
  11. package/infrastructure/domains/database/migration-builder.js +2 -21
  12. package/infrastructure/domains/database/migration-builder.test.js +0 -55
  13. package/infrastructure/domains/integration/integration-builder.js +0 -2
  14. package/infrastructure/domains/integration/integration-builder.test.js +0 -16
  15. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -13
  16. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +0 -47
  17. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +12 -92
  18. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +6 -158
  19. package/infrastructure/infrastructure-composer.js +1 -12
  20. package/infrastructure/infrastructure-composer.test.js +0 -71
  21. package/infrastructure/scripts/build-prisma-layer.js +50 -136
  22. package/infrastructure/scripts/build-prisma-layer.test.js +0 -100
  23. package/package.json +7 -7
  24. package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +0 -39
  25. package/infrastructure/domains/database/migration-engines.js +0 -93
  26. package/infrastructure/domains/database/migration-engines.test.js +0 -142
  27. package/infrastructure/domains/shared/lambda-architectures.js +0 -113
  28. package/infrastructure/domains/shared/lambda-architectures.test.js +0 -164
@@ -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.731.1c0b281.0",
4
+ "version": "2.0.0--canary.730.541f199.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.731.1c0b281.0",
32
- "@friggframework/schemas": "2.0.0--canary.731.1c0b281.0",
33
- "@friggframework/test": "2.0.0--canary.731.1c0b281.0",
31
+ "@friggframework/core": "2.0.0--canary.730.541f199.0",
32
+ "@friggframework/schemas": "2.0.0--canary.730.541f199.0",
33
+ "@friggframework/test": "2.0.0--canary.730.541f199.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.731.1c0b281.0",
62
- "@friggframework/prettier-config": "2.0.0--canary.731.1c0b281.0",
61
+ "@friggframework/eslint-config": "2.0.0--canary.730.541f199.0",
62
+ "@friggframework/prettier-config": "2.0.0--canary.730.541f199.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": "1c0b281b7ee4a47cff0a73cc2736a380a839517b"
94
+ "gitHead": "541f1999903bcfbc049dee0a97c0b1d1047143e6"
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
- };
@@ -1,142 +0,0 @@
1
- const fs = require('fs');
2
- const os = require('os');
3
- const path = require('path');
4
- const { ensureMigrationEngines } = require('./migration-engines');
5
-
6
- describe('ensureMigrationEngines()', () => {
7
- const target = 'linux-arm64-openssl-3.0.x';
8
- const schemaEngine = `schema-engine-${target}`;
9
- const queryEngineLibrary = `libquery_engine-${target}.so.node`;
10
- let enginesDir;
11
-
12
- const writeEngines = (...names) => {
13
- for (const name of names) {
14
- fs.writeFileSync(path.join(enginesDir, name), '');
15
- }
16
- };
17
-
18
- beforeEach(() => {
19
- enginesDir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-prisma-engines-'));
20
- });
21
-
22
- afterEach(() => {
23
- fs.rmSync(enginesDir, { recursive: true, force: true });
24
- });
25
-
26
- it('fetches nothing when both engines for the target are already present', async () => {
27
- writeEngines(schemaEngine, queryEngineLibrary);
28
- const fetchEngines = jest.fn();
29
-
30
- await ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines });
31
-
32
- expect(fetchEngines).not.toHaveBeenCalled();
33
- });
34
-
35
- it('fetches the target engines into the engines directory when one is missing', async () => {
36
- writeEngines(schemaEngine);
37
- const fetchEngines = jest.fn(({ enginesDir: dir }) => {
38
- fs.writeFileSync(path.join(dir, queryEngineLibrary), '');
39
- });
40
-
41
- await ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines });
42
-
43
- expect(fetchEngines).toHaveBeenCalledWith({ enginesDir, prismaBinaryTarget: target });
44
- });
45
-
46
- it.each([
47
- ['the schema engine', [queryEngineLibrary], schemaEngine],
48
- ['the query engine library', [schemaEngine], queryEngineLibrary],
49
- ['both engines', [], `${schemaEngine}, ${queryEngineLibrary}`],
50
- ])('fails packaging naming %s when the fetch leaves it missing', async (_, present, missing) => {
51
- writeEngines(...present);
52
- const fetchEngines = jest.fn();
53
-
54
- await expect(
55
- ensureMigrationEngines({ prismaBinaryTarget: target, enginesDir, fetchEngines })
56
- ).rejects.toThrow(missing);
57
- });
58
-
59
- describe('resolving the engines directory from cwd', () => {
60
- let root;
61
-
62
- const installEngines = (dir) => {
63
- const engines = path.join(dir, 'node_modules', '@prisma', 'engines');
64
- fs.mkdirSync(path.join(engines, 'scripts'), { recursive: true });
65
- fs.writeFileSync(path.join(engines, 'scripts', 'postinstall.js'), '');
66
- return engines;
67
- };
68
-
69
- beforeEach(() => {
70
- root = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-app-root-'));
71
- });
72
-
73
- afterEach(() => {
74
- fs.rmSync(root, { recursive: true, force: true });
75
- });
76
-
77
- it("uses the engines in the app's own node_modules", async () => {
78
- const appDir = path.join(root, 'app');
79
- const appEngines = installEngines(appDir);
80
- fs.writeFileSync(path.join(appEngines, schemaEngine), '');
81
- fs.writeFileSync(path.join(appEngines, queryEngineLibrary), '');
82
- const fetchEngines = jest.fn();
83
-
84
- await ensureMigrationEngines({ prismaBinaryTarget: target, cwd: appDir, fetchEngines });
85
-
86
- expect(fetchEngines).not.toHaveBeenCalled();
87
- });
88
-
89
- it('fails with a readable error when only a parent directory has the engines', async () => {
90
- installEngines(root);
91
- const appDir = path.join(root, 'app');
92
- fs.mkdirSync(appDir);
93
- const fetchEngines = jest.fn();
94
-
95
- const failure = ensureMigrationEngines({
96
- prismaBinaryTarget: target,
97
- cwd: appDir,
98
- fetchEngines,
99
- });
100
-
101
- await expect(failure).rejects.toThrow(/prisma.*own node_modules.*hoisted parent/is);
102
- await expect(failure).rejects.not.toHaveProperty('code', 'MODULE_NOT_FOUND');
103
- expect(fetchEngines).not.toHaveBeenCalled();
104
- });
105
- });
106
-
107
- describe('running the @prisma/engines postinstall', () => {
108
- const pinnedEngineVars = ['PRISMA_SCHEMA_ENGINE_BINARY', 'PRISMA_QUERY_ENGINE_LIBRARY'];
109
- let appDir;
110
- let seenEnvPath;
111
-
112
- beforeEach(() => {
113
- appDir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-app-'));
114
- const engines = path.join(appDir, 'node_modules', '@prisma', 'engines');
115
- fs.mkdirSync(path.join(engines, 'scripts'), { recursive: true });
116
- seenEnvPath = path.join(appDir, 'seen-env.json');
117
- fs.writeFileSync(
118
- path.join(engines, 'scripts', 'postinstall.js'),
119
- `const fs = require('fs');
120
- fs.writeFileSync(${JSON.stringify(seenEnvPath)}, JSON.stringify(process.env));
121
- for (const name of ${JSON.stringify([schemaEngine, queryEngineLibrary])}) fs.writeFileSync(name, '');`
122
- );
123
- });
124
-
125
- afterEach(() => {
126
- fs.rmSync(appDir, { recursive: true, force: true });
127
- pinnedEngineVars.forEach((name) => delete process.env[name]);
128
- });
129
-
130
- it("hides the host's pinned engine paths, so the postinstall does not skip the download", async () => {
131
- pinnedEngineVars.forEach((name) => {
132
- process.env[name] = `/host/${name}`;
133
- });
134
-
135
- await ensureMigrationEngines({ prismaBinaryTarget: target, cwd: appDir });
136
-
137
- const seenEnv = JSON.parse(fs.readFileSync(seenEnvPath, 'utf-8'));
138
- expect(seenEnv.PRISMA_CLI_BINARY_TARGETS).toBe(target);
139
- pinnedEngineVars.forEach((name) => expect(seenEnv).not.toHaveProperty(name));
140
- });
141
- });
142
- });
@@ -1,113 +0,0 @@
1
- /**
2
- * Lambda architectures and the Prisma engine each one runs.
3
- *
4
- * The registry keys are the AWS architecture names, so they go into
5
- * `provider.architecture` and the layer `compatibleArchitectures` as they
6
- * are. Every architecture-dependent value (layer build, layer cache key,
7
- * migration worker engines, package excludes) reads from here.
8
- */
9
-
10
- const LAMBDA_ARCHITECTURES = {
11
- x86_64: { prismaBinaryTarget: 'rhel-openssl-3.0.x' },
12
- arm64: { prismaBinaryTarget: 'linux-arm64-openssl-3.0.x' },
13
- };
14
-
15
- const DEFAULT_LAMBDA_ARCHITECTURE = 'x86_64';
16
-
17
- /**
18
- * @param {Object} appDefinition
19
- * @returns {{ name: string, prismaBinaryTarget: string, explicit: boolean }}
20
- * `explicit` is false when the app definition does not set `architecture`,
21
- * so callers can leave the template unchanged for existing apps.
22
- * @throws {Error} on an architecture the registry does not know
23
- */
24
- function resolveLambdaArchitecture(appDefinition = {}) {
25
- const explicit = appDefinition.architecture !== undefined;
26
- const name = explicit
27
- ? appDefinition.architecture
28
- : DEFAULT_LAMBDA_ARCHITECTURE;
29
- const entry = LAMBDA_ARCHITECTURES[name];
30
- if (!entry) {
31
- throw new Error(
32
- `Unknown Lambda architecture '${name}'. ` +
33
- `Set architecture to one of: ${Object.keys(
34
- LAMBDA_ARCHITECTURES
35
- ).join(', ')}`
36
- );
37
- }
38
- return { name, prismaBinaryTarget: entry.prismaBinaryTarget, explicit };
39
- }
40
-
41
- /** Where the migration worker's engines live, relative to the app root and to /var/task. */
42
- const PRISMA_ENGINES_PACKAGE_DIR = 'node_modules/@prisma/engines';
43
-
44
- /**
45
- * The two engine files `prisma migrate` needs for a target, as
46
- * @prisma/engines names them.
47
- * @param {string} prismaBinaryTarget
48
- * @returns {{ schemaEngine: string, queryEngineLibrary: string }}
49
- */
50
- function prismaEngineFileNames(prismaBinaryTarget) {
51
- return {
52
- schemaEngine: `schema-engine-${prismaBinaryTarget}`,
53
- queryEngineLibrary: `libquery_engine-${prismaBinaryTarget}.so.node`,
54
- };
55
- }
56
-
57
- const PRISMA_ENGINE_FILE_PREFIXES = [
58
- 'libquery_engine-',
59
- 'query-engine-',
60
- 'query_engine-',
61
- 'schema-engine-',
62
- ];
63
-
64
- const HOST_PLATFORM_ENGINE_TOKENS = [
65
- 'darwin',
66
- 'debian',
67
- 'linux-musl',
68
- 'windows',
69
- ];
70
-
71
- /**
72
- * Package exclude patterns for every Prisma engine file the named
73
- * architecture does not load: the deploy host's own platforms and the other
74
- * Lambda architectures. Each pattern starts with an engine file prefix, so a
75
- * runtime dependency that only has a platform word in its name is kept.
76
- * @param {string} name - A registry key
77
- * @returns {string[]}
78
- */
79
- function foreignPrismaEngineExcludes(name) {
80
- const foreignTokens = [
81
- ...HOST_PLATFORM_ENGINE_TOKENS,
82
- ...Object.entries(LAMBDA_ARCHITECTURES)
83
- .filter(([other]) => other !== name)
84
- .map(([, { prismaBinaryTarget }]) => prismaBinaryTarget),
85
- ];
86
- return PRISMA_ENGINE_FILE_PREFIXES.flatMap((prefix) =>
87
- foreignTokens.map((token) => `**/${prefix}${token}*`)
88
- );
89
- }
90
-
91
- /**
92
- * Package exclude patterns for a function that bundles Prisma itself. With
93
- * the Prisma layer on, the layer carries the engines and nothing is added.
94
- * @param {Object} appDefinition
95
- * @param {boolean} usePrismaLayer
96
- * @returns {string[]}
97
- */
98
- function bundledPrismaEngineExcludes(appDefinition, usePrismaLayer) {
99
- return usePrismaLayer
100
- ? []
101
- : foreignPrismaEngineExcludes(resolveLambdaArchitecture(appDefinition).name);
102
- }
103
-
104
- module.exports = {
105
- LAMBDA_ARCHITECTURES,
106
- DEFAULT_LAMBDA_ARCHITECTURE,
107
- resolveLambdaArchitecture,
108
- PRISMA_ENGINE_FILE_PREFIXES,
109
- PRISMA_ENGINES_PACKAGE_DIR,
110
- prismaEngineFileNames,
111
- foreignPrismaEngineExcludes,
112
- bundledPrismaEngineExcludes,
113
- };