@friggframework/devtools 2.0.0--canary.731.ffe61d3.0 → 2.0.0--canary.656.6eb85ab.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 (102) hide show
  1. package/frigg-cli/README.md +31 -115
  2. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
  3. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
  4. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  5. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  6. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  7. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  8. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  9. package/frigg-cli/build-command/index.js +0 -6
  10. package/frigg-cli/deploy-command/index.js +0 -6
  11. package/frigg-cli/generate-command/index.js +0 -1
  12. package/frigg-cli/generate-iam-command.js +0 -1
  13. package/frigg-cli/index.js +5 -22
  14. package/frigg-cli/index.test.js +158 -0
  15. package/frigg-cli/init-command/backend-first-handler.js +551 -395
  16. package/frigg-cli/init-command/index.js +35 -82
  17. package/frigg-cli/install-command/commit-changes.js +8 -40
  18. package/frigg-cli/install-command/environment-variables.js +0 -15
  19. package/frigg-cli/install-command/index.js +21 -96
  20. package/frigg-cli/install-command/install-package.js +4 -77
  21. package/frigg-cli/install-command/integration-file.js +11 -20
  22. package/frigg-cli/install-command/template.js +75 -102
  23. package/frigg-cli/install-command/validate-package.js +4 -36
  24. package/frigg-cli/package.json +1 -1
  25. package/frigg-cli/start-command/index.js +0 -4
  26. package/frigg-cli/start-command/start-command.test.js +0 -3
  27. package/frigg-cli/test/init-command.test.js +2 -9
  28. package/infrastructure/README.md +5 -32
  29. package/infrastructure/__tests__/postgres-config.test.js +836 -245
  30. package/infrastructure/__tests__/scoped-environment.test.js +0 -3
  31. package/infrastructure/__tests__/ssm-preload-node-options.test.js +0 -3
  32. package/infrastructure/__tests__/template-generation.test.js +8 -39
  33. package/infrastructure/create-frigg-infrastructure.js +1 -4
  34. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
  35. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -8
  36. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +6 -52
  37. package/infrastructure/domains/database/aurora-builder.js +2 -13
  38. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  39. package/infrastructure/domains/database/migration-builder.js +2 -21
  40. package/infrastructure/domains/database/migration-builder.test.js +6 -61
  41. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  42. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  43. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  44. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  45. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  46. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  47. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  48. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  49. package/infrastructure/domains/integration/integration-builder.js +0 -2
  50. package/infrastructure/domains/integration/integration-builder.test.js +6 -22
  51. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  52. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  53. package/infrastructure/domains/security/iam-generator.js +5 -112
  54. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  55. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  56. package/infrastructure/domains/shared/environment-builder.js +5 -31
  57. package/infrastructure/domains/shared/environment-builder.test.js +7 -93
  58. package/infrastructure/domains/shared/utilities/base-definition-factory.js +3 -39
  59. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +5 -85
  60. package/infrastructure/domains/shared/utilities/nested-node-modules.js +5 -6
  61. package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +26 -20
  62. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +12 -92
  63. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +6 -158
  64. package/infrastructure/infrastructure-composer.js +1 -12
  65. package/infrastructure/infrastructure-composer.test.js +794 -339
  66. package/infrastructure/integration.test.js +381 -0
  67. package/infrastructure/scripts/build-prisma-layer.js +50 -136
  68. package/infrastructure/scripts/build-prisma-layer.test.js +7 -128
  69. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  70. package/package.json +10 -12
  71. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  72. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
  73. package/frigg-cli/init-command/deployment-modes.js +0 -7
  74. package/frigg-cli/init-command/safe-path.js +0 -58
  75. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  76. package/frigg-cli/install-command/app-definition.js +0 -174
  77. package/frigg-cli/install-command/resolve-module.js +0 -69
  78. package/frigg-cli/templates/backend/README.md +0 -267
  79. package/frigg-cli/templates/backend/env.example +0 -20
  80. package/frigg-cli/templates/backend/gitignore +0 -10
  81. package/frigg-cli/templates/backend/index.js +0 -114
  82. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  83. package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
  84. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
  85. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
  86. package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
  87. package/frigg-cli/validate-command/checks/config.js +0 -504
  88. package/frigg-cli/validate-command/checks/integrations.js +0 -274
  89. package/frigg-cli/validate-command/format-report.js +0 -58
  90. package/frigg-cli/validate-command/index.js +0 -107
  91. package/frigg-cli/validate-command/load-app-definition.js +0 -105
  92. package/frigg-cli/validate-command/schema-issues.js +0 -154
  93. package/frigg-cli/validate-command/validate-app-definition.js +0 -60
  94. package/infrastructure/__tests__/helpers/bundled-prisma-engine-excludes.js +0 -39
  95. package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -284
  96. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -151
  97. package/infrastructure/app-definition-schema-contract.test.js +0 -634
  98. package/infrastructure/create-frigg-infrastructure.test.js +0 -51
  99. package/infrastructure/domains/database/migration-engines.js +0 -93
  100. package/infrastructure/domains/database/migration-engines.test.js +0 -142
  101. package/infrastructure/domains/shared/lambda-architectures.js +0 -113
  102. package/infrastructure/domains/shared/lambda-architectures.test.js +0 -164
@@ -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
- };
@@ -1,164 +0,0 @@
1
- const micromatch = require('micromatch');
2
- const {
3
- LAMBDA_ARCHITECTURES,
4
- resolveLambdaArchitecture,
5
- prismaEngineFileNames,
6
- foreignPrismaEngineExcludes,
7
- bundledPrismaEngineExcludes,
8
- } = require('./lambda-architectures');
9
-
10
- describe('resolveLambdaArchitecture()', () => {
11
- it('resolves to x86_64 with the rhel engine when the key is unset', () => {
12
- expect(resolveLambdaArchitecture({})).toEqual({
13
- name: 'x86_64',
14
- prismaBinaryTarget: 'rhel-openssl-3.0.x',
15
- explicit: false,
16
- });
17
- });
18
-
19
- it('resolves an explicit x86_64', () => {
20
- expect(resolveLambdaArchitecture({ architecture: 'x86_64' })).toEqual({
21
- name: 'x86_64',
22
- prismaBinaryTarget: 'rhel-openssl-3.0.x',
23
- explicit: true,
24
- });
25
- });
26
-
27
- it('resolves arm64 to the linux-arm64 engine', () => {
28
- expect(resolveLambdaArchitecture({ architecture: 'arm64' })).toEqual({
29
- name: 'arm64',
30
- prismaBinaryTarget: 'linux-arm64-openssl-3.0.x',
31
- explicit: true,
32
- });
33
- });
34
-
35
- it('throws on an unknown architecture, naming the accepted ones', () => {
36
- expect(() =>
37
- resolveLambdaArchitecture({ architecture: 'aarch64' })
38
- ).toThrow(/aarch64.*x86_64.*arm64/);
39
- });
40
-
41
- it('uses the AWS architecture names as registry keys', () => {
42
- expect(Object.keys(LAMBDA_ARCHITECTURES)).toEqual(['x86_64', 'arm64']);
43
- });
44
- });
45
-
46
- describe('prismaEngineFileNames()', () => {
47
- it('names the schema engine and the query engine library the migrate CLI needs for a target', () => {
48
- expect(prismaEngineFileNames('linux-arm64-openssl-3.0.x')).toEqual({
49
- schemaEngine: 'schema-engine-linux-arm64-openssl-3.0.x',
50
- queryEngineLibrary: 'libquery_engine-linux-arm64-openssl-3.0.x.so.node',
51
- });
52
- });
53
- });
54
-
55
- describe('foreignPrismaEngineExcludes()', () => {
56
- const matches = (name, filePath) =>
57
- micromatch([filePath], foreignPrismaEngineExcludes(name), {
58
- dot: true,
59
- }).length > 0;
60
-
61
- const foreignEngineFiles = {
62
- x86_64: [
63
- 'node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node',
64
- 'node_modules/@prisma/engines/schema-engine-darwin-arm64',
65
- 'node_modules/.prisma/client/query_engine-windows.dll.node',
66
- 'node_modules/@prisma/engines/query-engine-debian-openssl-3.0.x',
67
- 'node_modules/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node',
68
- 'node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node',
69
- 'node_modules/@prisma/engines/schema-engine-linux-arm64-openssl-3.0.x',
70
- 'node_modules/@prisma/engines/libquery_engine-linux-arm64-openssl-3.0.x.so.node',
71
- ],
72
- arm64: [
73
- 'node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node',
74
- 'node_modules/.prisma/client/query_engine-windows.dll.node',
75
- 'node_modules/@prisma/engines/libquery_engine-linux-musl-openssl-3.0.x.so.node',
76
- 'node_modules/@prisma/engines/schema-engine-rhel-openssl-3.0.x',
77
- 'node_modules/@prisma/engines/libquery_engine-rhel-openssl-3.0.x.so.node',
78
- ],
79
- };
80
-
81
- const targetEngineFiles = {
82
- x86_64: [
83
- 'node_modules/@prisma/engines/schema-engine-rhel-openssl-3.0.x',
84
- 'node_modules/@prisma/engines/libquery_engine-rhel-openssl-3.0.x.so.node',
85
- ],
86
- arm64: [
87
- 'node_modules/@prisma/engines/schema-engine-linux-arm64-openssl-3.0.x',
88
- 'node_modules/@prisma/engines/libquery_engine-linux-arm64-openssl-3.0.x.so.node',
89
- ],
90
- };
91
-
92
- const nonEngineFiles = [
93
- 'node_modules/is-windows/index.js',
94
- 'node_modules/is-windows/package.json',
95
- 'node_modules/darwin-utils/lib/index.js',
96
- 'node_modules/some-pkg/lib/debian-release.js',
97
- 'node_modules/some-pkg/linux-musl-detect.js',
98
- 'node_modules/@prisma/engines/query_engine_bg.wasm',
99
- 'node_modules/.prisma/client/query_engine_bg.js',
100
- 'node_modules/some-pkg/dist/linux-arm64-notes.js',
101
- 'src/handlers/windows-handler.js',
102
- ];
103
-
104
- it.each(['x86_64', 'arm64'])(
105
- 'matches every foreign engine file for %s',
106
- (name) => {
107
- foreignEngineFiles[name].forEach((file) =>
108
- expect({ name, file, hit: matches(name, file) }).toEqual({
109
- name,
110
- file,
111
- hit: true,
112
- })
113
- );
114
- }
115
- );
116
-
117
- it.each(['x86_64', 'arm64'])(
118
- 'keeps the engine files of the %s target',
119
- (name) => {
120
- targetEngineFiles[name].forEach((file) =>
121
- expect({ file, hit: matches(name, file) }).toEqual({
122
- file,
123
- hit: false,
124
- })
125
- );
126
- }
127
- );
128
-
129
- it.each(['x86_64', 'arm64'])(
130
- 'keeps runtime files that only share a platform word with an engine for %s',
131
- (name) => {
132
- nonEngineFiles.forEach((file) =>
133
- expect({ file, hit: matches(name, file) }).toEqual({
134
- file,
135
- hit: false,
136
- })
137
- );
138
- }
139
- );
140
-
141
- it('never uses negation', () => {
142
- ['x86_64', 'arm64'].forEach((name) =>
143
- foreignPrismaEngineExcludes(name).forEach((pattern) =>
144
- expect(pattern.startsWith('!')).toBe(false)
145
- )
146
- );
147
- });
148
- });
149
-
150
- describe('bundledPrismaEngineExcludes()', () => {
151
- it('adds nothing when the Prisma layer carries the engines', () => {
152
- expect(bundledPrismaEngineExcludes({ architecture: 'arm64' }, true)).toEqual([]);
153
- });
154
-
155
- it.each([
156
- [{}, 'x86_64'],
157
- [{ architecture: 'x86_64' }, 'x86_64'],
158
- [{ architecture: 'arm64' }, 'arm64'],
159
- ])('with the layer off, excludes the engines %j does not load', (appDefinition, name) => {
160
- expect(bundledPrismaEngineExcludes(appDefinition, false)).toEqual(
161
- foreignPrismaEngineExcludes(name)
162
- );
163
- });
164
- });