@friggframework/devtools 2.0.0--canary.704.79d9a63.0 → 2.0.0--canary.686.e94de4d.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 (46) hide show
  1. package/README.md +0 -14
  2. package/frigg-cli/README.md +0 -6
  3. package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +140 -0
  4. package/frigg-cli/__tests__/unit/dependencies.test.js +5 -3
  5. package/frigg-cli/build-command/index.js +32 -1
  6. package/frigg-cli/deploy-command/index.js +50 -2
  7. package/frigg-cli/doctor-command/index.js +7 -0
  8. package/frigg-cli/generate-iam-command.js +7 -0
  9. package/frigg-cli/index.js +0 -3
  10. package/frigg-cli/package.json +3 -3
  11. package/frigg-cli/repair-command/index.js +7 -0
  12. package/frigg-cli/start-command/index.js +58 -0
  13. package/frigg-cli/utils/provider-helper.js +80 -0
  14. package/infrastructure/README.md +4 -22
  15. package/infrastructure/__tests__/create-frigg-infrastructure-provider.test.js +64 -0
  16. package/infrastructure/__tests__/management-api-gateway-routes.test.js +335 -0
  17. package/infrastructure/__tests__/template-generation.test.js +7 -0
  18. package/infrastructure/create-frigg-infrastructure.js +14 -0
  19. package/infrastructure/domains/admin-scripts/admin-script-builder.js +48 -56
  20. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -76
  21. package/infrastructure/domains/database/migration-builder.js +175 -182
  22. package/infrastructure/domains/database/migration-builder.test.js +5 -36
  23. package/infrastructure/domains/integration/integration-builder.js +61 -65
  24. package/infrastructure/domains/integration/integration-builder.test.js +8 -73
  25. package/infrastructure/domains/parameters/offload-utils.js +1 -0
  26. package/infrastructure/domains/shared/environment-builder.js +12 -1
  27. package/infrastructure/domains/shared/environment-builder.test.js +20 -0
  28. package/infrastructure/domains/shared/types/app-definition.js +15 -1
  29. package/infrastructure/domains/shared/utilities/base-definition-factory.js +150 -86
  30. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +111 -96
  31. package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
  32. package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
  33. package/infrastructure/infrastructure-composer.test.js +10 -3
  34. package/infrastructure/provider-build.js +119 -0
  35. package/infrastructure/scripts/build-prisma-layer.js +32 -5
  36. package/infrastructure/scripts/build-prisma-layer.test.js +35 -0
  37. package/package.json +8 -11
  38. package/test/npm-install-guard.js +104 -0
  39. package/test/npm-install-guard.test.js +53 -0
  40. package/frigg-cli/__tests__/unit/utils/node-version.test.js +0 -66
  41. package/frigg-cli/utils/node-version.js +0 -51
  42. package/infrastructure/__tests__/package-patterns-composition.test.js +0 -153
  43. package/infrastructure/domains/shared/utilities/framework-version.js +0 -14
  44. package/infrastructure/domains/shared/utilities/framework-version.test.js +0 -27
  45. package/infrastructure/domains/shared/utilities/package-patterns.js +0 -35
  46. package/infrastructure/domains/shared/utilities/package-patterns.test.js +0 -112
@@ -5,7 +5,6 @@
5
5
  */
6
6
 
7
7
  const { createBaseDefinition } = require('./base-definition-factory');
8
- const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
9
8
 
10
9
  describe('Base Definition Factory', () => {
11
10
  beforeEach(() => {
@@ -24,7 +23,7 @@ describe('Base Definition Factory', () => {
24
23
  const result = createBaseDefinition(appDefinition, appEnvironmentVars, discoveredResources);
25
24
 
26
25
  expect(result.service).toBe('test-app');
27
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
26
+ expect(result.frameworkVersion).toBe('>=3.17.0');
28
27
  expect(result.provider.name).toBe('aws');
29
28
  expect(result.provider.runtime).toBe('nodejs22.x');
30
29
  expect(result.provider.timeout).toBe(29);
@@ -95,7 +94,91 @@ describe('Base Definition Factory', () => {
95
94
 
96
95
  expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
97
96
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
98
- expect(result.functions.auth.events).toHaveLength(3);
97
+ expect(
98
+ result.functions.auth.events.map(
99
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
100
+ )
101
+ ).toEqual([
102
+ // v1 (deprecated, ADR-053)
103
+ 'ANY /api/integrations',
104
+ 'ANY /api/integrations/{proxy+}',
105
+ 'ANY /api/authorize',
106
+ 'ANY /api/entity',
107
+ 'ANY /api/entity/{proxy+}',
108
+ 'ANY /api/entities/{proxy+}',
109
+ // v2, per resource: never ANY /api/v2/{proxy+}, which would
110
+ // shadow /api/v2/reports on the admin-scripts Lambda
111
+ 'ANY /api/v2/integrations',
112
+ 'ANY /api/v2/integrations/{proxy+}',
113
+ 'ANY /api/v2/entities',
114
+ 'ANY /api/v2/entities/{proxy+}',
115
+ 'ANY /api/v2/credentials',
116
+ 'ANY /api/v2/credentials/{proxy+}',
117
+ 'ANY /api/v2/authorize',
118
+ ]);
119
+ });
120
+
121
+ it('takes the Management API routes from the core route registry', () => {
122
+ const { getGatewayRoutes } = require('@friggframework/core/management-api/route-registry');
123
+ const result = createBaseDefinition({}, {}, {});
124
+ const declared = (fn) =>
125
+ result.functions[fn].events
126
+ .map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
127
+ .filter((route) => route.includes('/api/'));
128
+ const registry = (fn) =>
129
+ getGatewayRoutes()
130
+ .filter((r) => r.function === fn)
131
+ .map((r) => `${r.method} ${r.path}`);
132
+ expect(declared('auth')).toEqual(registry('auth'));
133
+ expect(declared('health')).toEqual(registry('health'));
134
+ });
135
+
136
+ it('serves /api/meta from the DB-free health function', () => {
137
+ const result = createBaseDefinition({}, {}, {});
138
+ expect(
139
+ result.functions.health.events.map((e) => `${e.httpApi.method} ${e.httpApi.path}`)
140
+ ).toEqual([
141
+ 'GET /health',
142
+ 'GET /health/{proxy+}',
143
+ 'GET /api/meta',
144
+ 'GET /api/meta/{proxy+}',
145
+ // Redirects to /api/meta/openapi/v2.json (ADR-053 docs path)
146
+ 'GET /api/docs',
147
+ ]);
148
+ });
149
+
150
+ it('routes each core extension admin path (and below) to the auth function', () => {
151
+ const result = createBaseDefinition(
152
+ {
153
+ coreExtensions: [
154
+ { name: 'db-credentials', routes: { path: '/admin/oauth-credentials' } },
155
+ { name: 'no-routes' },
156
+ ],
157
+ },
158
+ {},
159
+ {}
160
+ );
161
+ const routes = result.functions.auth.events.map(
162
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
163
+ );
164
+ expect(routes).toContain('ANY /admin/oauth-credentials');
165
+ expect(routes).toContain('ANY /admin/oauth-credentials/{proxy+}');
166
+ // Never a catch-all that would shadow /admin/scripts or /admin/db-migrate.
167
+ expect(routes).not.toContain('ANY /admin/{proxy+}');
168
+ // The HTTP queue route is for hosts without SQS, never AWS.
169
+ expect(JSON.stringify(result.functions)).not.toContain('/admin/queue');
170
+ });
171
+
172
+ it('drops the v1 routes when managementApi.v1 is false, keeping the OAuth redirect', () => {
173
+ const result = createBaseDefinition({ managementApi: { v1: false } }, {}, {});
174
+ const routes = result.functions.auth.events.map(
175
+ (e) => `${e.httpApi.method} ${e.httpApi.path}`
176
+ );
177
+ expect(routes).not.toContain('ANY /api/integrations');
178
+ expect(routes).not.toContain('ANY /api/authorize');
179
+ expect(routes).not.toContain('ANY /api/entity');
180
+ expect(routes).toContain('GET /api/integrations/redirect/{appId}');
181
+ expect(routes).toContain('ANY /api/v2/integrations');
99
182
  });
100
183
 
101
184
  it('should NOT include legacy dbMigrate function', () => {
@@ -237,75 +320,12 @@ describe('Base Definition Factory', () => {
237
320
  expect(result.package.individually).toBe(true);
238
321
  });
239
322
 
240
- describe('useDotenv (ADR-050)', () => {
241
- const originalArgv = process.argv;
242
- afterEach(() => {
243
- process.argv = originalArgv;
244
- });
245
-
246
- it.each([['package'], ['deploy'], ['print']])(
247
- 'omits useDotenv for `osls %s` (osls 4 only accepts true)',
248
- (command) => {
249
- process.argv = ['node', 'osls', command, '--stage', 'prod'];
250
- const result = createBaseDefinition({}, {}, {});
251
-
252
- expect(result).not.toHaveProperty('useDotenv');
253
- expect(result.plugins).not.toContain('serverless-dotenv-plugin');
254
- }
255
- );
256
-
257
- it('sets useDotenv: true for `osls offline`', () => {
258
- process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
259
- const result = createBaseDefinition({}, {}, {});
260
-
261
- expect(result.useDotenv).toBe(true);
262
- expect(result.plugins).toContain('serverless-dotenv-plugin');
263
- });
264
- });
265
-
266
- describe('function package patterns (ADR-050)', () => {
267
- it('emits package.patterns and no include/exclude on auth, user and health', () => {
268
- const result = createBaseDefinition({}, {}, {});
269
-
270
- for (const fn of ['auth', 'user', 'health']) {
271
- const pkg = result.functions[fn].package;
272
- expect(pkg).not.toHaveProperty('include');
273
- expect(pkg).not.toHaveProperty('exclude');
274
- expect(Array.isArray(pkg.patterns)).toBe(true);
275
- expect(pkg.patterns).toEqual(
276
- expect.arrayContaining([
277
- '!node_modules/aws-sdk/**',
278
- '!node_modules/@aws-sdk/**',
279
- '!.env',
280
- '!**/.env.*',
281
- '!package-lock.json',
282
- '!test/**',
283
- '!layers/**',
284
- ])
285
- );
286
- // No exclude pattern removes src/: handlers load the app definition from it.
287
- expect(pkg.patterns).not.toContain('!src/**');
288
- }
289
- });
290
-
291
- it('puts the DocumentDB CA file after every exclude so it is re-added', () => {
292
- const result = createBaseDefinition(
293
- { database: { documentDB: { tlsCAFile: './certs/global-bundle.pem' } } },
294
- {},
295
- {}
296
- );
297
- const { patterns } = result.functions.auth.package;
298
-
299
- expect(patterns[patterns.length - 1]).toBe('certs/global-bundle.pem');
300
- expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
301
- });
323
+ it('should enable dotenv only in offline mode', () => {
324
+ const result = createBaseDefinition({}, {}, {});
302
325
 
303
- it('emits only negated excludes when no CA file is configured', () => {
304
- const result = createBaseDefinition({}, {}, {});
305
- expect(
306
- result.functions.auth.package.patterns.every((p) => p.startsWith('!'))
307
- ).toBe(true);
308
- });
326
+ // useDotenv is conditional - only true when process.argv includes 'offline'
327
+ expect(result.useDotenv).toBeDefined();
328
+ expect(typeof result.useDotenv).toBe('boolean');
309
329
  });
310
330
 
311
331
  describe('usePrismaLayer configuration', () => {
@@ -314,12 +334,12 @@ describe('Base Definition Factory', () => {
314
334
 
315
335
  expect(result.layers.prisma).toBeDefined();
316
336
  expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
317
- expect(result.functions.auth.package.patterns).toEqual(
337
+ expect(result.functions.auth.package.exclude).toEqual(
318
338
  expect.arrayContaining([
319
- '!node_modules/@prisma/**',
320
- '!node_modules/.prisma/**',
321
- '!node_modules/prisma/**',
322
- '!node_modules/@friggframework/core/generated/**',
339
+ 'node_modules/@prisma/**',
340
+ 'node_modules/.prisma/**',
341
+ 'node_modules/prisma/**',
342
+ 'node_modules/@friggframework/core/generated/**',
323
343
  ])
324
344
  );
325
345
  expect(result.custom.esbuild.external).toEqual(
@@ -332,12 +352,12 @@ describe('Base Definition Factory', () => {
332
352
 
333
353
  expect(result.layers).toEqual({});
334
354
  expect(result.functions.auth.layers).toBeUndefined();
335
- expect(result.functions.auth.package.patterns).not.toEqual(
355
+ expect(result.functions.auth.package.exclude).not.toEqual(
336
356
  expect.arrayContaining([
337
- '!node_modules/@prisma/**',
338
- '!node_modules/.prisma/**',
339
- '!node_modules/prisma/**',
340
- '!node_modules/@friggframework/core/generated/**',
357
+ 'node_modules/@prisma/**',
358
+ 'node_modules/.prisma/**',
359
+ 'node_modules/prisma/**',
360
+ 'node_modules/@friggframework/core/generated/**',
341
361
  ])
342
362
  );
343
363
  expect(result.custom.esbuild.external).not.toEqual(
@@ -361,7 +381,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
361
381
  const result = build({ name: 'test-app' });
362
382
 
363
383
  for (const fn of ['auth', 'user', 'health']) {
364
- expect(result.functions[fn].package.patterns).toContain('!node_modules/**/node_modules/**');
384
+ expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
365
385
  }
366
386
  });
367
387
 
@@ -369,13 +389,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
369
389
  const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
370
390
 
371
391
  for (const fn of ['auth', 'user', 'health']) {
372
- const { patterns } = result.functions[fn].package;
373
- expect(patterns).not.toContain('!node_modules/**/node_modules/**');
374
- expect(patterns).toEqual(
392
+ const { exclude } = result.functions[fn].package;
393
+ expect(exclude).not.toContain('node_modules/**/node_modules/**');
394
+ expect(exclude).toEqual(
375
395
  expect.arrayContaining([
376
- '!node_modules/**/node_modules/@friggframework/**',
377
- '!node_modules/**/node_modules/@aws-sdk/**',
378
- '!node_modules/**/node_modules/@prisma/**',
396
+ 'node_modules/**/node_modules/@friggframework/**',
397
+ 'node_modules/**/node_modules/@aws-sdk/**',
398
+ 'node_modules/**/node_modules/@prisma/**',
379
399
  ])
380
400
  );
381
401
  }
@@ -391,14 +411,14 @@ describe('logging (ADR-048)', () => {
391
411
 
392
412
  expect(result.provider.logs).toBeUndefined();
393
413
  expect(result.provider.logRetentionInDays).toBeUndefined();
394
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
414
+ expect(result.frameworkVersion).toBe('>=3.17.0');
395
415
  });
396
416
 
397
417
  it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
398
418
  const result = build({ level: 'warn' });
399
419
 
400
420
  expect(result.provider.logs).toBeUndefined();
401
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
421
+ expect(result.frameworkVersion).toBe('>=3.17.0');
402
422
  });
403
423
 
404
424
  it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
@@ -410,12 +430,7 @@ describe('logging (ADR-048)', () => {
410
430
 
411
431
  expect(result.provider.logRetentionInDays).toBe(30);
412
432
  expect(result.provider.logs).toBeUndefined();
413
- expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
414
- });
415
-
416
- it('keeps the single osls frameworkVersion even when the Lambda LoggingConfig is on (ADR-050)', () => {
417
- const result = build({ level: 'warn' });
418
- expect(result.frameworkVersion).toBe('^4.4.0');
433
+ expect(result.frameworkVersion).toBe('>=3.17.0');
419
434
  });
420
435
 
421
436
  it('accepts 1096, which CloudWatch allows but the osls schema omits', () => {
@@ -6,8 +6,8 @@ const RETENTION_DAYS = [
6
6
  2192, 2557, 2922, 3288, 3653,
7
7
  ];
8
8
 
9
- // provider.logs.lambda compiles to LoggingConfig from osls 3.58.0; the base
10
- // definition's single frameworkVersion (^4.4.0, ADR-050) already covers it.
9
+ // First osls version that compiles provider.logs.lambda into LoggingConfig.
10
+ const LOGGING_CONFIG_FRAMEWORK_VERSION = '>=3.58.0';
11
11
 
12
12
  // ADR-048 Open question 3: off until the Phase 0 spike proves Lambda JSON mode
13
13
  // keeps direct fd 1 lines intact. Until then Lambda stays on Text and
@@ -39,7 +39,7 @@ function validateRetentionInDays(retentionInDays) {
39
39
  *
40
40
  * @param {Object} [logging] - appDefinition.logging
41
41
  * @param {{ lambdaJson?: boolean }} [options]
42
- * @returns {{ provider?: Object }}
42
+ * @returns {{ frameworkVersion?: string, provider?: Object }}
43
43
  */
44
44
  function buildLoggingProviderConfig(
45
45
  logging,
@@ -53,6 +53,7 @@ function buildLoggingProviderConfig(
53
53
  if (logging.level !== undefined) {
54
54
  const level = normalizeLogLevel(logging.level);
55
55
  if (lambdaJson) {
56
+ result.frameworkVersion = LOGGING_CONFIG_FRAMEWORK_VERSION;
56
57
  provider.logs = {
57
58
  lambda: {
58
59
  logFormat: 'JSON',
@@ -18,8 +18,9 @@ describe('buildLoggingProviderConfig (ADR-048)', () => {
18
18
  const build = (logging) =>
19
19
  buildLoggingProviderConfig(logging, { lambdaJson: true });
20
20
 
21
- it('maps level to provider.logs.lambda and leaves frameworkVersion to the base definition (ADR-050)', () => {
21
+ it('maps level to provider.logs.lambda and sets frameworkVersion >=3.58.0', () => {
22
22
  expect(build({ level: 'warn' })).toEqual({
23
+ frameworkVersion: '>=3.58.0',
23
24
  provider: {
24
25
  logs: {
25
26
  lambda: {
@@ -2,6 +2,13 @@ const {
2
2
  composeServerlessDefinition,
3
3
  applySsmPreloadNodeOptions,
4
4
  } = require('./infrastructure-composer');
5
+ // Composing must not build the real Prisma layer: that runs npm install
6
+ // under packages/devtools, and two workers doing it at once once pruned the
7
+ // repository's root node_modules (test/npm-install-guard.js).
8
+ jest.mock('./domains/shared/utilities/prisma-layer-manager', () => ({
9
+ ensurePrismaLayerExists: jest.fn(async () => {}),
10
+ }));
11
+
5
12
  const {
6
13
  SSM_PRELOAD_NODE_OPTIONS,
7
14
  } = require('./domains/parameters/offload-utils');
@@ -153,7 +160,7 @@ describe('composeServerlessDefinition', () => {
153
160
  expect(result.provider.runtime).toBe('nodejs22.x');
154
161
  expect(result.provider.region).toBe('us-east-1');
155
162
  expect(result.provider.stage).toBe('${opt:stage}');
156
- expect(result.frameworkVersion).toBe('^4.4.0');
163
+ expect(result.frameworkVersion).toBe('>=3.17.0');
157
164
  });
158
165
 
159
166
  it('should use default service name when name not provided', async () => {
@@ -245,7 +252,7 @@ describe('composeServerlessDefinition', () => {
245
252
  logging: { level: 'debug', retentionInDays: 30 },
246
253
  });
247
254
 
248
- expect(result.frameworkVersion).toBe('^4.4.0');
255
+ expect(result.frameworkVersion).toBe('>=3.17.0');
249
256
  expect(result.provider.logs).toBeUndefined();
250
257
  expect(result.provider.logRetentionInDays).toBe(30);
251
258
  expect(result.provider.environment.FRIGG_LOG_LEVEL).toBe('DEBUG');
@@ -275,7 +282,7 @@ describe('composeServerlessDefinition', () => {
275
282
  it('changes nothing when logging is absent', async () => {
276
283
  const result = await composeServerlessDefinition({ integrations: [] });
277
284
 
278
- expect(result.frameworkVersion).toBe('^4.4.0');
285
+ expect(result.frameworkVersion).toBe('>=3.17.0');
279
286
  expect(result.provider.logs).toBeUndefined();
280
287
  expect(result.provider.logRetentionInDays).toBeUndefined();
281
288
  expect(result.provider.environment).not.toHaveProperty('FRIGG_LOG_LEVEL');
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Build for a non-AWS provider (friggframework/frigg#545, 302ab9ba /
3
+ * c8705715).
4
+ *
5
+ * Instead of the serverless/CloudFormation pipeline, the provider plugin
6
+ * (resolved from appDefinition.provider) does the build:
7
+ * 1. validate(appDefinition) - errors abort, warnings print
8
+ * 2. generateConfig(appDefinition) - e.g. netlify.toml
9
+ * 3. getFunctionEntryPoints(appDefinition) - written to <project>/netlify/functions
10
+ * 4. getLibEntryPoints(appDefinition) - written to <project>/netlify/lib
11
+ *
12
+ * <project> is the directory that holds backend/: the generated entry points
13
+ * require '../../backend/...', so they must sit beside it. #545 had two
14
+ * copies of this, and the CLI one wrote into the backend directory itself,
15
+ * where those relative requires do not resolve.
16
+ *
17
+ * Shared by createFriggInfrastructure() (`node infrastructure.js package`,
18
+ * what a backend's `npm run build` runs) and `frigg build`.
19
+ */
20
+ const path = require('path');
21
+ const fs = require('fs');
22
+
23
+ const CONFIG_FILE_NAMES = { netlify: 'netlify.toml' };
24
+
25
+ /**
26
+ * @param {Object} params
27
+ * @param {Object} params.appDefinition
28
+ * @param {string} params.backendDir - directory containing the backend's index.js
29
+ * @param {Object} [params.provider] - resolved plugin; defaults to resolveProvider(appDefinition)
30
+ * @param {boolean} [params.verbose]
31
+ * @param {Function} [params.exit] - called with 1 on validation errors (default process.exit)
32
+ * @returns {{ projectDir: string, written: string[] }}
33
+ */
34
+ function buildWithProvider({
35
+ appDefinition,
36
+ backendDir,
37
+ provider,
38
+ verbose = false,
39
+ exit = (code) => process.exit(code),
40
+ }) {
41
+ const providerName = appDefinition.provider;
42
+ const plugin =
43
+ provider ||
44
+ require('@friggframework/core/providers/resolve-provider').resolveProvider(
45
+ appDefinition
46
+ );
47
+ const projectDir = path.dirname(path.resolve(backendDir));
48
+ const written = [];
49
+
50
+ console.log(`Building for ${providerName} provider (skipping AWS infrastructure)...`);
51
+
52
+ if (typeof plugin.validate === 'function') {
53
+ const validation = plugin.validate(appDefinition);
54
+ if (validation.errors?.length > 0) {
55
+ console.error(`\nValidation errors for ${providerName}:`);
56
+ for (const error of validation.errors) {
57
+ console.error(` - ${error}`);
58
+ }
59
+ exit(1);
60
+ return { projectDir, written };
61
+ }
62
+ for (const warning of validation.warnings || []) {
63
+ console.warn(` Warning: ${warning}`);
64
+ }
65
+ }
66
+
67
+ const write = (filePath, content) => {
68
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
69
+ fs.writeFileSync(filePath, content, 'utf-8');
70
+ written.push(filePath);
71
+ if (verbose) console.log(` Written ${path.relative(projectDir, filePath)}`);
72
+ };
73
+
74
+ if (typeof plugin.generateConfig === 'function') {
75
+ const fileName = CONFIG_FILE_NAMES[providerName] || `${providerName}.config`;
76
+ write(path.join(projectDir, fileName), plugin.generateConfig(appDefinition));
77
+ console.log(` Written ${fileName}`);
78
+ }
79
+
80
+ if (typeof plugin.getFunctionEntryPoints === 'function') {
81
+ const entryPoints = plugin.getFunctionEntryPoints(appDefinition);
82
+ for (const [fileName, content] of Object.entries(entryPoints)) {
83
+ write(path.join(projectDir, 'netlify', 'functions', fileName), content);
84
+ }
85
+ console.log(` Generated ${Object.keys(entryPoints).length} function entry points`);
86
+ }
87
+
88
+ if (typeof plugin.getLibEntryPoints === 'function') {
89
+ const libEntryPoints = plugin.getLibEntryPoints(appDefinition);
90
+ for (const [fileName, content] of Object.entries(libEntryPoints)) {
91
+ write(path.join(projectDir, 'netlify', 'lib', fileName), content);
92
+ }
93
+ console.log(` Generated ${Object.keys(libEntryPoints).length} lib entry points`);
94
+ }
95
+
96
+ if (typeof plugin.generateEnvTemplate === 'function') {
97
+ const missing = Object.entries(plugin.generateEnvTemplate(appDefinition)).filter(
98
+ ([key]) => !process.env[key]
99
+ );
100
+ if (missing.length > 0) {
101
+ console.log('\n Environment variables not set locally (configure them on the platform):');
102
+ for (const [key] of missing) console.log(` - ${key}`);
103
+ }
104
+ }
105
+
106
+ console.log(`\nBuild complete for ${providerName}.`);
107
+ return { projectDir, written };
108
+ }
109
+
110
+ /**
111
+ * True when the app definition names a provider other than AWS.
112
+ * @param {Object} [appDefinition]
113
+ */
114
+ function isNonAwsProvider(appDefinition) {
115
+ const name = appDefinition?.provider;
116
+ return Boolean(name) && name !== 'aws';
117
+ }
118
+
119
+ module.exports = { buildWithProvider, isNonAwsProvider };
@@ -249,6 +249,36 @@ async function createLayerStructure() {
249
249
  logSuccess(`Created ${LAYER_NODE_MODULES}`);
250
250
  }
251
251
 
252
+ /**
253
+ * Run `npm install --omit=dev` confined to the layer directory.
254
+ *
255
+ * npm resolves its project root by walking up from cwd to the nearest
256
+ * package.json. If the layer's package.json is missing when npm starts (a
257
+ * concurrent build cleaned the directory, as two jest workers composing at
258
+ * once did), npm walked up into the enclosing workspace and ran
259
+ * `install --omit=dev` there, pruning the devDependencies (jest, jest-util)
260
+ * out of the repository's root node_modules. So: the package.json must exist,
261
+ * and `--prefix` pins npm's root to the layer directory while
262
+ * `--workspaces=false` stops it acting on an enclosing workspace.
263
+ *
264
+ * @param {string} layerNodejsDir - absolute path of <layer>/nodejs
265
+ * @param {Object} [options]
266
+ * @param {Object} [options.env]
267
+ * @param {Function} [options.exec] - execSync stand-in (tests)
268
+ */
269
+ function runLayerInstall(layerNodejsDir, { env = process.env, exec = execSync } = {}) {
270
+ const manifest = path.join(layerNodejsDir, 'package.json');
271
+ if (!fs.existsSync(manifest)) {
272
+ throw new Error(
273
+ `Refusing to run npm install: ${manifest} does not exist (npm would install into an enclosing project)`
274
+ );
275
+ }
276
+ exec(
277
+ `npm install --omit=dev --no-package-lock --workspaces=false --prefix ${JSON.stringify(layerNodejsDir)}`,
278
+ { cwd: layerNodejsDir, stdio: 'inherit', env }
279
+ );
280
+ }
281
+
252
282
  /**
253
283
  * Install Prisma client directly into layer (RUNTIME ONLY - NO CLI)
254
284
  *
@@ -285,11 +315,7 @@ async function installPrismaPackages() {
285
315
  PRISMA_CLI_BINARY_TARGETS: 'rhel-openssl-3.0.x',
286
316
  };
287
317
 
288
- execSync('npm install --omit=dev --no-package-lock', {
289
- cwd: path.join(LAYER_OUTPUT_PATH, 'nodejs'),
290
- stdio: 'inherit',
291
- env,
292
- });
318
+ runLayerInstall(path.join(LAYER_OUTPUT_PATH, 'nodejs'), { env });
293
319
  logSuccess('Prisma packages installed with Lambda binary target');
294
320
  } catch (error) {
295
321
  throw new Error(`Failed to install Prisma packages: ${error.message}`);
@@ -693,6 +719,7 @@ if (require.main === module) {
693
719
 
694
720
  module.exports = {
695
721
  buildPrismaLayer,
722
+ runLayerInstall,
696
723
  getGeneratedClientPackages,
697
724
  getMigrationsPackages,
698
725
  getMigrationSourcePath,
@@ -168,3 +168,38 @@ describe('getMigrationDestinationPath()', () => {
168
168
  );
169
169
  });
170
170
  });
171
+
172
+
173
+ describe('runLayerInstall', () => {
174
+ const fs = require('fs');
175
+ const os = require('os');
176
+ const path = require('path');
177
+ const { runLayerInstall } = require('./build-prisma-layer');
178
+
179
+ it('refuses when the layer package.json is missing (npm would walk up into the workspace)', () => {
180
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'layer-'));
181
+ const exec = jest.fn();
182
+ try {
183
+ expect(() => runLayerInstall(dir, { exec })).toThrow(/Refusing to run npm install/);
184
+ expect(exec).not.toHaveBeenCalled();
185
+ } finally {
186
+ fs.rmSync(dir, { recursive: true, force: true });
187
+ }
188
+ });
189
+
190
+ it('pins npm to the layer directory and off any enclosing workspace', () => {
191
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'layer-'));
192
+ fs.writeFileSync(path.join(dir, 'package.json'), '{}');
193
+ const exec = jest.fn();
194
+ try {
195
+ runLayerInstall(dir, { exec, env: { X: '1' } });
196
+ const [command, options] = exec.mock.calls[0];
197
+ expect(command).toContain('npm install --omit=dev');
198
+ expect(command).toContain('--workspaces=false');
199
+ expect(command).toContain(`--prefix ${JSON.stringify(dir)}`);
200
+ expect(options).toMatchObject({ cwd: dir, env: { X: '1' } });
201
+ } finally {
202
+ fs.rmSync(dir, { recursive: true, force: true });
203
+ }
204
+ });
205
+ });
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.704.79d9a63.0",
4
+ "version": "2.0.0--canary.686.e94de4d.0",
5
5
  "bin": {
6
6
  "frigg": "./frigg-cli/index.js"
7
7
  },
@@ -26,9 +26,9 @@
26
26
  "@babel/eslint-parser": "^7.18.9",
27
27
  "@babel/parser": "^7.25.3",
28
28
  "@babel/traverse": "^7.25.3",
29
- "@friggframework/core": "2.0.0--canary.704.79d9a63.0",
30
- "@friggframework/schemas": "2.0.0--canary.704.79d9a63.0",
31
- "@friggframework/test": "2.0.0--canary.704.79d9a63.0",
29
+ "@friggframework/core": "2.0.0--canary.686.e94de4d.0",
30
+ "@friggframework/schemas": "2.0.0--canary.686.e94de4d.0",
31
+ "@friggframework/test": "2.0.0--canary.686.e94de4d.0",
32
32
  "@hapi/boom": "^10.0.1",
33
33
  "@inquirer/prompts": "^5.3.8",
34
34
  "axios": "^1.18.0",
@@ -56,12 +56,12 @@
56
56
  "validate-npm-package-name": "^5.0.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@friggframework/eslint-config": "2.0.0--canary.704.79d9a63.0",
60
- "@friggframework/prettier-config": "2.0.0--canary.704.79d9a63.0",
59
+ "@friggframework/eslint-config": "2.0.0--canary.686.e94de4d.0",
60
+ "@friggframework/prettier-config": "2.0.0--canary.686.e94de4d.0",
61
61
  "aws-sdk-client-mock": "^4.1.0",
62
62
  "aws-sdk-client-mock-jest": "^4.1.0",
63
63
  "jest": "^30.1.3",
64
- "osls": "^4.4.0",
64
+ "osls": "^3.58.0",
65
65
  "prettier": "^2.7.1",
66
66
  "serverless-dotenv-plugin": "^6.0.0",
67
67
  "serverless-esbuild": "^1.54.3",
@@ -70,9 +70,6 @@
70
70
  "serverless-offline-sqs": "^8.0.0",
71
71
  "serverless-plugin-monorepo": "^0.11.0"
72
72
  },
73
- "engines": {
74
- "node": "^22.13.0 || >=24"
75
- },
76
73
  "scripts": {
77
74
  "lint:fix": "prettier --write --loglevel error . && eslint . --fix",
78
75
  "test": "jest --passWithNoTests # TODO"
@@ -92,5 +89,5 @@
92
89
  "publishConfig": {
93
90
  "access": "public"
94
91
  },
95
- "gitHead": "79d9a635432643710e9fb815cf16453d01f7e12c"
92
+ "gitHead": "e94de4d57240076018ab43ee47ac0ecc5cab0cbb"
96
93
  }