@friggframework/devtools 2.0.0--canary.704.79d9a63.0 → 2.0.0--canary.680.daae24e.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/README.md +0 -14
- package/frigg-cli/README.md +0 -6
- package/frigg-cli/__tests__/unit/dependencies.test.js +5 -3
- package/frigg-cli/index.js +0 -3
- package/frigg-cli/package.json +3 -3
- package/infrastructure/README.md +4 -22
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +335 -0
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +48 -56
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -76
- package/infrastructure/domains/database/migration-builder.js +175 -182
- package/infrastructure/domains/database/migration-builder.test.js +5 -36
- package/infrastructure/domains/integration/integration-builder.js +61 -65
- package/infrastructure/domains/integration/integration-builder.test.js +8 -73
- package/infrastructure/domains/parameters/offload-utils.js +1 -0
- package/infrastructure/domains/shared/environment-builder.js +12 -1
- package/infrastructure/domains/shared/environment-builder.test.js +20 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +148 -86
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +87 -96
- package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
- package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
- package/infrastructure/infrastructure-composer.test.js +3 -3
- package/package.json +8 -11
- package/frigg-cli/__tests__/unit/utils/node-version.test.js +0 -66
- package/frigg-cli/utils/node-version.js +0 -51
- package/infrastructure/__tests__/package-patterns-composition.test.js +0 -153
- package/infrastructure/domains/shared/utilities/framework-version.js +0 -14
- package/infrastructure/domains/shared/utilities/framework-version.test.js +0 -27
- package/infrastructure/domains/shared/utilities/package-patterns.js +0 -35
- 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(
|
|
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,67 @@ 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(
|
|
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
|
+
]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('drops the v1 routes when managementApi.v1 is false, keeping the OAuth redirect', () => {
|
|
149
|
+
const result = createBaseDefinition({ managementApi: { v1: false } }, {}, {});
|
|
150
|
+
const routes = result.functions.auth.events.map(
|
|
151
|
+
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
152
|
+
);
|
|
153
|
+
expect(routes).not.toContain('ANY /api/integrations');
|
|
154
|
+
expect(routes).not.toContain('ANY /api/authorize');
|
|
155
|
+
expect(routes).not.toContain('ANY /api/entity');
|
|
156
|
+
expect(routes).toContain('GET /api/integrations/redirect/{appId}');
|
|
157
|
+
expect(routes).toContain('ANY /api/v2/integrations');
|
|
99
158
|
});
|
|
100
159
|
|
|
101
160
|
it('should NOT include legacy dbMigrate function', () => {
|
|
@@ -237,75 +296,12 @@ describe('Base Definition Factory', () => {
|
|
|
237
296
|
expect(result.package.individually).toBe(true);
|
|
238
297
|
});
|
|
239
298
|
|
|
240
|
-
|
|
241
|
-
const
|
|
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
|
-
});
|
|
299
|
+
it('should enable dotenv only in offline mode', () => {
|
|
300
|
+
const result = createBaseDefinition({}, {}, {});
|
|
302
301
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
result.functions.auth.package.patterns.every((p) => p.startsWith('!'))
|
|
307
|
-
).toBe(true);
|
|
308
|
-
});
|
|
302
|
+
// useDotenv is conditional - only true when process.argv includes 'offline'
|
|
303
|
+
expect(result.useDotenv).toBeDefined();
|
|
304
|
+
expect(typeof result.useDotenv).toBe('boolean');
|
|
309
305
|
});
|
|
310
306
|
|
|
311
307
|
describe('usePrismaLayer configuration', () => {
|
|
@@ -314,12 +310,12 @@ describe('Base Definition Factory', () => {
|
|
|
314
310
|
|
|
315
311
|
expect(result.layers.prisma).toBeDefined();
|
|
316
312
|
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
317
|
-
expect(result.functions.auth.package.
|
|
313
|
+
expect(result.functions.auth.package.exclude).toEqual(
|
|
318
314
|
expect.arrayContaining([
|
|
319
|
-
'
|
|
320
|
-
'
|
|
321
|
-
'
|
|
322
|
-
'
|
|
315
|
+
'node_modules/@prisma/**',
|
|
316
|
+
'node_modules/.prisma/**',
|
|
317
|
+
'node_modules/prisma/**',
|
|
318
|
+
'node_modules/@friggframework/core/generated/**',
|
|
323
319
|
])
|
|
324
320
|
);
|
|
325
321
|
expect(result.custom.esbuild.external).toEqual(
|
|
@@ -332,12 +328,12 @@ describe('Base Definition Factory', () => {
|
|
|
332
328
|
|
|
333
329
|
expect(result.layers).toEqual({});
|
|
334
330
|
expect(result.functions.auth.layers).toBeUndefined();
|
|
335
|
-
expect(result.functions.auth.package.
|
|
331
|
+
expect(result.functions.auth.package.exclude).not.toEqual(
|
|
336
332
|
expect.arrayContaining([
|
|
337
|
-
'
|
|
338
|
-
'
|
|
339
|
-
'
|
|
340
|
-
'
|
|
333
|
+
'node_modules/@prisma/**',
|
|
334
|
+
'node_modules/.prisma/**',
|
|
335
|
+
'node_modules/prisma/**',
|
|
336
|
+
'node_modules/@friggframework/core/generated/**',
|
|
341
337
|
])
|
|
342
338
|
);
|
|
343
339
|
expect(result.custom.esbuild.external).not.toEqual(
|
|
@@ -361,7 +357,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
361
357
|
const result = build({ name: 'test-app' });
|
|
362
358
|
|
|
363
359
|
for (const fn of ['auth', 'user', 'health']) {
|
|
364
|
-
expect(result.functions[fn].package.
|
|
360
|
+
expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
|
|
365
361
|
}
|
|
366
362
|
});
|
|
367
363
|
|
|
@@ -369,13 +365,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
369
365
|
const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
|
|
370
366
|
|
|
371
367
|
for (const fn of ['auth', 'user', 'health']) {
|
|
372
|
-
const {
|
|
373
|
-
expect(
|
|
374
|
-
expect(
|
|
368
|
+
const { exclude } = result.functions[fn].package;
|
|
369
|
+
expect(exclude).not.toContain('node_modules/**/node_modules/**');
|
|
370
|
+
expect(exclude).toEqual(
|
|
375
371
|
expect.arrayContaining([
|
|
376
|
-
'
|
|
377
|
-
'
|
|
378
|
-
'
|
|
372
|
+
'node_modules/**/node_modules/@friggframework/**',
|
|
373
|
+
'node_modules/**/node_modules/@aws-sdk/**',
|
|
374
|
+
'node_modules/**/node_modules/@prisma/**',
|
|
379
375
|
])
|
|
380
376
|
);
|
|
381
377
|
}
|
|
@@ -391,14 +387,14 @@ describe('logging (ADR-048)', () => {
|
|
|
391
387
|
|
|
392
388
|
expect(result.provider.logs).toBeUndefined();
|
|
393
389
|
expect(result.provider.logRetentionInDays).toBeUndefined();
|
|
394
|
-
expect(result.frameworkVersion).toBe(
|
|
390
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
395
391
|
});
|
|
396
392
|
|
|
397
393
|
it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
|
|
398
394
|
const result = build({ level: 'warn' });
|
|
399
395
|
|
|
400
396
|
expect(result.provider.logs).toBeUndefined();
|
|
401
|
-
expect(result.frameworkVersion).toBe(
|
|
397
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
402
398
|
});
|
|
403
399
|
|
|
404
400
|
it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
|
|
@@ -410,12 +406,7 @@ describe('logging (ADR-048)', () => {
|
|
|
410
406
|
|
|
411
407
|
expect(result.provider.logRetentionInDays).toBe(30);
|
|
412
408
|
expect(result.provider.logs).toBeUndefined();
|
|
413
|
-
expect(result.frameworkVersion).toBe(
|
|
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');
|
|
409
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
419
410
|
});
|
|
420
411
|
|
|
421
412
|
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
|
|
10
|
-
|
|
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
|
|
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: {
|
|
@@ -153,7 +153,7 @@ describe('composeServerlessDefinition', () => {
|
|
|
153
153
|
expect(result.provider.runtime).toBe('nodejs22.x');
|
|
154
154
|
expect(result.provider.region).toBe('us-east-1');
|
|
155
155
|
expect(result.provider.stage).toBe('${opt:stage}');
|
|
156
|
-
expect(result.frameworkVersion).toBe('
|
|
156
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it('should use default service name when name not provided', async () => {
|
|
@@ -245,7 +245,7 @@ describe('composeServerlessDefinition', () => {
|
|
|
245
245
|
logging: { level: 'debug', retentionInDays: 30 },
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
-
expect(result.frameworkVersion).toBe('
|
|
248
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
249
249
|
expect(result.provider.logs).toBeUndefined();
|
|
250
250
|
expect(result.provider.logRetentionInDays).toBe(30);
|
|
251
251
|
expect(result.provider.environment.FRIGG_LOG_LEVEL).toBe('DEBUG');
|
|
@@ -275,7 +275,7 @@ describe('composeServerlessDefinition', () => {
|
|
|
275
275
|
it('changes nothing when logging is absent', async () => {
|
|
276
276
|
const result = await composeServerlessDefinition({ integrations: [] });
|
|
277
277
|
|
|
278
|
-
expect(result.frameworkVersion).toBe('
|
|
278
|
+
expect(result.frameworkVersion).toBe('>=3.17.0');
|
|
279
279
|
expect(result.provider.logs).toBeUndefined();
|
|
280
280
|
expect(result.provider.logRetentionInDays).toBeUndefined();
|
|
281
281
|
expect(result.provider.environment).not.toHaveProperty('FRIGG_LOG_LEVEL');
|
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.
|
|
4
|
+
"version": "2.0.0--canary.680.daae24e.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.
|
|
30
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
31
|
-
"@friggframework/test": "2.0.0--canary.
|
|
29
|
+
"@friggframework/core": "2.0.0--canary.680.daae24e.0",
|
|
30
|
+
"@friggframework/schemas": "2.0.0--canary.680.daae24e.0",
|
|
31
|
+
"@friggframework/test": "2.0.0--canary.680.daae24e.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.
|
|
60
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
59
|
+
"@friggframework/eslint-config": "2.0.0--canary.680.daae24e.0",
|
|
60
|
+
"@friggframework/prettier-config": "2.0.0--canary.680.daae24e.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": "^
|
|
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": "
|
|
92
|
+
"gitHead": "daae24ec9d6b03c59759b6b42f6f99369b683981"
|
|
96
93
|
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
SUPPORTED_NODE_RANGE,
|
|
3
|
-
checkNodeVersion,
|
|
4
|
-
enforceNodeVersion,
|
|
5
|
-
} = require('../../../utils/node-version');
|
|
6
|
-
|
|
7
|
-
describe('Node.js host version check (ADR-050)', () => {
|
|
8
|
-
it('uses the engines.node range from package.json', () => {
|
|
9
|
-
expect(SUPPORTED_NODE_RANGE).toBe(require('../../../package.json').engines.node);
|
|
10
|
-
expect(SUPPORTED_NODE_RANGE).toBe('^22.13.0 || >=24');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it.each([
|
|
14
|
-
['22.13.0', true],
|
|
15
|
-
['v22.20.1', true],
|
|
16
|
-
['24.0.0', true],
|
|
17
|
-
['v24.10.0', true],
|
|
18
|
-
['25.1.0', true],
|
|
19
|
-
['22.12.0', false],
|
|
20
|
-
['v22.11.0', false],
|
|
21
|
-
['23.5.0', false],
|
|
22
|
-
['v23.11.1', false],
|
|
23
|
-
['20.19.0', false],
|
|
24
|
-
['18.20.0', false],
|
|
25
|
-
])('Node %s supported: %s', (version, supported) => {
|
|
26
|
-
expect(checkNodeVersion(version).supported).toBe(supported);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('explains the supported range and the fix when unsupported', () => {
|
|
30
|
-
const { message } = checkNodeVersion('v23.5.0');
|
|
31
|
-
expect(message).toContain('Node.js v23.5.0');
|
|
32
|
-
expect(message).toContain('^22.13.0 || >=24');
|
|
33
|
-
expect(message).toContain('Node 23');
|
|
34
|
-
expect(message).toContain('FRIGG_SKIP_NODE_VERSION_CHECK');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('prints the message and exits 1 on an unsupported host', () => {
|
|
38
|
-
const log = jest.fn();
|
|
39
|
-
const exit = jest.fn();
|
|
40
|
-
const ok = enforceNodeVersion({ version: '23.5.0', env: {}, log, exit });
|
|
41
|
-
expect(ok).toBe(false);
|
|
42
|
-
expect(log).toHaveBeenCalledWith(expect.stringContaining('does not support Node.js'));
|
|
43
|
-
expect(exit).toHaveBeenCalledWith(1);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('continues silently on a supported host', () => {
|
|
47
|
-
const log = jest.fn();
|
|
48
|
-
const exit = jest.fn();
|
|
49
|
-
expect(enforceNodeVersion({ version: '24.10.0', env: {}, log, exit })).toBe(true);
|
|
50
|
-
expect(log).not.toHaveBeenCalled();
|
|
51
|
-
expect(exit).not.toHaveBeenCalled();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it('can be bypassed with FRIGG_SKIP_NODE_VERSION_CHECK=true', () => {
|
|
55
|
-
const exit = jest.fn();
|
|
56
|
-
expect(
|
|
57
|
-
enforceNodeVersion({
|
|
58
|
-
version: '23.5.0',
|
|
59
|
-
env: { FRIGG_SKIP_NODE_VERSION_CHECK: 'true' },
|
|
60
|
-
log: jest.fn(),
|
|
61
|
-
exit,
|
|
62
|
-
})
|
|
63
|
-
).toBe(true);
|
|
64
|
-
expect(exit).not.toHaveBeenCalled();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Node.js host version check for the Frigg CLI.
|
|
3
|
-
*
|
|
4
|
-
* osls 4 supports `^20.19.0 || ^22.13.0 || >=24`; Frigg's floor is Node 22, so
|
|
5
|
-
* the CLI runs on `^22.13.0 || >=24` (ADR-050). Node 23 and Node 22.0-22.12 are
|
|
6
|
-
* excluded. The range is read from this package's `engines.node`, so the check
|
|
7
|
-
* and the published metadata cannot drift.
|
|
8
|
-
*/
|
|
9
|
-
const semver = require('semver');
|
|
10
|
-
const { engines } = require('../package.json');
|
|
11
|
-
|
|
12
|
-
const SUPPORTED_NODE_RANGE = engines.node;
|
|
13
|
-
const SKIP_ENV = 'FRIGG_SKIP_NODE_VERSION_CHECK';
|
|
14
|
-
|
|
15
|
-
function checkNodeVersion(version = process.versions.node, range = SUPPORTED_NODE_RANGE) {
|
|
16
|
-
const coerced = semver.coerce(version);
|
|
17
|
-
if (coerced && semver.satisfies(coerced, range)) {
|
|
18
|
-
return { supported: true, version, range };
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
supported: false,
|
|
22
|
-
version,
|
|
23
|
-
range,
|
|
24
|
-
message: [
|
|
25
|
-
`Frigg CLI does not support Node.js v${String(version).replace(/^v/, '')}.`,
|
|
26
|
-
`Supported versions: ${range} (the range osls 4 supports at or above Frigg's Node 22 floor).`,
|
|
27
|
-
'Node 23 and Node 22.0-22.12 are not supported. Install Node 22.13+ or Node 24+, for example `nvm install 24`.',
|
|
28
|
-
`To run anyway, set ${SKIP_ENV}=true (osls may fail).`,
|
|
29
|
-
].join('\n'),
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Print a clear error and exit when the host Node.js is unsupported.
|
|
35
|
-
* @returns {boolean} true when the CLI may continue
|
|
36
|
-
*/
|
|
37
|
-
function enforceNodeVersion({
|
|
38
|
-
version = process.versions.node,
|
|
39
|
-
env = process.env,
|
|
40
|
-
log = console.error,
|
|
41
|
-
exit = process.exit,
|
|
42
|
-
} = {}) {
|
|
43
|
-
if (env[SKIP_ENV] === 'true') return true;
|
|
44
|
-
const result = checkNodeVersion(version);
|
|
45
|
-
if (result.supported) return true;
|
|
46
|
-
log(result.message);
|
|
47
|
-
exit(1);
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = { SUPPORTED_NODE_RANGE, checkNodeVersion, enforceNodeVersion };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Composer-level guard for ADR-050 (osls 4).
|
|
3
|
-
*
|
|
4
|
-
* osls 4 rejects package.include / package.exclude at every level and only
|
|
5
|
-
* accepts `useDotenv: true` (or no key). Walk every function of a fully
|
|
6
|
-
* featured composed definition and assert Frigg emits neither.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const { composeServerlessDefinition } = require('../infrastructure-composer');
|
|
10
|
-
|
|
11
|
-
jest.mock('../domains/shared/resource-discovery', () => {
|
|
12
|
-
const originalModule = jest.requireActual('../domains/shared/resource-discovery');
|
|
13
|
-
return {
|
|
14
|
-
...originalModule,
|
|
15
|
-
gatherDiscoveredResources: jest.fn().mockResolvedValue({
|
|
16
|
-
defaultVpcId: 'vpc-123456',
|
|
17
|
-
defaultSecurityGroupId: 'sg-123456',
|
|
18
|
-
privateSubnetId1: 'subnet-123456',
|
|
19
|
-
privateSubnetId2: 'subnet-789012',
|
|
20
|
-
defaultKmsKeyId:
|
|
21
|
-
'arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012',
|
|
22
|
-
auroraClusterEndpoint: 'test-cluster.cluster-abc123.us-east-1.rds.amazonaws.com',
|
|
23
|
-
auroraPort: 5432,
|
|
24
|
-
}),
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const featuredApp = () => ({
|
|
29
|
-
name: 'featured-app',
|
|
30
|
-
provider: 'aws',
|
|
31
|
-
vpc: { enable: true },
|
|
32
|
-
encryption: { useDefaultKMSForFieldLevelEncryption: true },
|
|
33
|
-
database: {
|
|
34
|
-
postgres: { enable: true },
|
|
35
|
-
documentDB: { tlsCAFile: './global-bundle.pem' },
|
|
36
|
-
},
|
|
37
|
-
adminScripts: [{ Definition: { name: 'fixThings' } }],
|
|
38
|
-
reports: [{ Definition: { name: 'usageReport' } }],
|
|
39
|
-
integrations: [
|
|
40
|
-
{
|
|
41
|
-
Definition: {
|
|
42
|
-
name: 'hubspot',
|
|
43
|
-
webhooks: true,
|
|
44
|
-
extensions: {
|
|
45
|
-
hubspotWebhooks: {
|
|
46
|
-
extension: {
|
|
47
|
-
name: 'hubspot-webhooks',
|
|
48
|
-
routes: [
|
|
49
|
-
{
|
|
50
|
-
path: '/webhooks',
|
|
51
|
-
method: 'POST',
|
|
52
|
-
event: 'HUBSPOT_WEBHOOK_RECEIVED',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
events: {
|
|
56
|
-
HUBSPOT_WEBHOOK_RECEIVED: {
|
|
57
|
-
type: 'LIFE_CYCLE_EVENT',
|
|
58
|
-
handler: () => {},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
handlers: {},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
{ Definition: { name: 'slack' } },
|
|
68
|
-
],
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe('composed definition is valid for osls 4 packaging (ADR-050)', () => {
|
|
72
|
-
const originalArgv = process.argv;
|
|
73
|
-
|
|
74
|
-
beforeEach(() => {
|
|
75
|
-
delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
afterEach(() => {
|
|
79
|
-
process.argv = originalArgv;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('no function, the service or a layer carries package.include or package.exclude', async () => {
|
|
83
|
-
process.argv = ['node', 'osls', 'package', '--stage', 'prod'];
|
|
84
|
-
const definition = await composeServerlessDefinition(featuredApp());
|
|
85
|
-
|
|
86
|
-
expect(definition.package).not.toHaveProperty('include');
|
|
87
|
-
expect(definition.package).not.toHaveProperty('exclude');
|
|
88
|
-
for (const layer of Object.values(definition.layers || {})) {
|
|
89
|
-
expect(layer.package?.include).toBeUndefined();
|
|
90
|
-
expect(layer.package?.exclude).toBeUndefined();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const functionNames = Object.keys(definition.functions);
|
|
94
|
-
expect(functionNames).toEqual(
|
|
95
|
-
expect.arrayContaining([
|
|
96
|
-
'auth',
|
|
97
|
-
'user',
|
|
98
|
-
'health',
|
|
99
|
-
'hubspot',
|
|
100
|
-
'hubspotWebhook',
|
|
101
|
-
'hubspot__hubspotWebhooks',
|
|
102
|
-
'hubspotQueueWorker',
|
|
103
|
-
'slack',
|
|
104
|
-
'slackQueueWorker',
|
|
105
|
-
'dlqProcessor',
|
|
106
|
-
'dbMigrationWorker',
|
|
107
|
-
'dbMigrationRouter',
|
|
108
|
-
'adminScriptExecutor',
|
|
109
|
-
'adminScriptRouter',
|
|
110
|
-
])
|
|
111
|
-
);
|
|
112
|
-
|
|
113
|
-
for (const [name, fn] of Object.entries(definition.functions)) {
|
|
114
|
-
if (!fn.package) continue;
|
|
115
|
-
expect({ name, include: fn.package.include }).toEqual({ name, include: undefined });
|
|
116
|
-
expect({ name, exclude: fn.package.exclude }).toEqual({ name, exclude: undefined });
|
|
117
|
-
expect(Array.isArray(fn.package.patterns)).toBe(true);
|
|
118
|
-
|
|
119
|
-
// Excludes first, then includes: once a positive pattern appears,
|
|
120
|
-
// no negated pattern may follow it.
|
|
121
|
-
const firstInclude = fn.package.patterns.findIndex((p) => !p.startsWith('!'));
|
|
122
|
-
if (firstInclude !== -1) {
|
|
123
|
-
expect(
|
|
124
|
-
fn.package.patterns.slice(firstInclude).every((p) => !p.startsWith('!'))
|
|
125
|
-
).toBe(true);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// The skipEsbuild core and admin functions re-add the DocumentDB CA file.
|
|
130
|
-
for (const name of ['auth', 'user', 'health', 'adminScriptExecutor', 'adminScriptRouter']) {
|
|
131
|
-
const { patterns } = definition.functions[name].package;
|
|
132
|
-
expect(patterns[patterns.length - 1]).toBe('global-bundle.pem');
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it.each([['package'], ['deploy']])('never emits useDotenv for `osls %s`', async (command) => {
|
|
137
|
-
process.argv = ['node', 'osls', command, '--stage', 'prod'];
|
|
138
|
-
const definition = await composeServerlessDefinition(featuredApp());
|
|
139
|
-
|
|
140
|
-
expect(definition).not.toHaveProperty('useDotenv');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('emits useDotenv: true for `osls offline`', async () => {
|
|
144
|
-
process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
|
|
145
|
-
process.env.FRIGG_SKIP_AWS_DISCOVERY = 'true';
|
|
146
|
-
try {
|
|
147
|
-
const definition = await composeServerlessDefinition(featuredApp());
|
|
148
|
-
expect(definition.useDotenv).toBe(true);
|
|
149
|
-
} finally {
|
|
150
|
-
delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* osls framework version
|
|
3
|
-
*
|
|
4
|
-
* Utility Layer - Hexagonal Architecture
|
|
5
|
-
*
|
|
6
|
-
* The single `frameworkVersion` every composed definition emits (ADR-050).
|
|
7
|
-
* It matches the osls range in devtools and frigg-cli, so an app whose own
|
|
8
|
-
* package.json still resolves osls 3 fails at once with
|
|
9
|
-
* FRAMEWORK_VERSION_MISMATCH instead of packaging a different artifact.
|
|
10
|
-
* It subsumes the ADR-048 LoggingConfig floor (>=3.58.0).
|
|
11
|
-
*/
|
|
12
|
-
const OSLS_FRAMEWORK_VERSION = '^4.4.0';
|
|
13
|
-
|
|
14
|
-
module.exports = { OSLS_FRAMEWORK_VERSION };
|