@friggframework/devtools 2.0.0--canary.639.cf7e091.0 → 2.0.0--canary.704.6a606c3.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 +14 -0
- package/frigg-cli/README.md +6 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +3 -5
- package/frigg-cli/__tests__/unit/utils/node-version.test.js +66 -0
- package/frigg-cli/index.js +3 -0
- package/frigg-cli/package.json +3 -3
- package/frigg-cli/utils/node-version.js +51 -0
- package/infrastructure/README.md +20 -0
- package/infrastructure/__tests__/package-patterns-composition.test.js +153 -0
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +50 -46
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +46 -7
- package/infrastructure/domains/database/migration-builder.js +182 -175
- package/infrastructure/domains/database/migration-builder.test.js +36 -5
- package/infrastructure/domains/integration/integration-builder.js +65 -61
- package/infrastructure/domains/integration/integration-builder.test.js +73 -8
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +76 -122
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +95 -26
- package/infrastructure/domains/shared/utilities/framework-version.js +14 -0
- package/infrastructure/domains/shared/utilities/framework-version.test.js +27 -0
- package/infrastructure/domains/shared/utilities/logging-config.js +3 -4
- package/infrastructure/domains/shared/utilities/logging-config.test.js +1 -2
- package/infrastructure/domains/shared/utilities/package-patterns.js +35 -0
- package/infrastructure/domains/shared/utilities/package-patterns.test.js +112 -0
- package/infrastructure/infrastructure-composer.test.js +3 -3
- package/package.json +11 -8
|
@@ -886,8 +886,8 @@ describe('IntegrationBuilder', () => {
|
|
|
886
886
|
const result = await integrationBuilder.build(appDefinition, {});
|
|
887
887
|
|
|
888
888
|
expect(result.functions.testWebhook.package).toBeDefined();
|
|
889
|
-
expect(result.functions.testWebhook.package.
|
|
890
|
-
expect(result.functions.testWebhook.package.
|
|
889
|
+
expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/aws-sdk/**');
|
|
890
|
+
expect(result.functions.testWebhook.package.patterns).toContain('!node_modules/@prisma/**');
|
|
891
891
|
});
|
|
892
892
|
});
|
|
893
893
|
|
|
@@ -982,8 +982,8 @@ describe('IntegrationBuilder', () => {
|
|
|
982
982
|
expect(result.functions.asana.layers).toBeUndefined();
|
|
983
983
|
expect(result.functions.asanaQueueWorker.layers).toBeUndefined();
|
|
984
984
|
expect(result.functions.asanaWebhook.layers).toBeUndefined();
|
|
985
|
-
expect(result.functions.asana.package.
|
|
986
|
-
expect.arrayContaining(['node_modules/@prisma/**'])
|
|
985
|
+
expect(result.functions.asana.package.patterns).not.toEqual(
|
|
986
|
+
expect.arrayContaining(['!node_modules/@prisma/**'])
|
|
987
987
|
);
|
|
988
988
|
});
|
|
989
989
|
});
|
|
@@ -1091,14 +1091,14 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1091
1091
|
...(lambda && { lambda }),
|
|
1092
1092
|
});
|
|
1093
1093
|
const packagedFunctions = (result) =>
|
|
1094
|
-
Object.values(result.functions).filter((fn) => fn.package?.
|
|
1094
|
+
Object.values(result.functions).filter((fn) => fn.package?.patterns);
|
|
1095
1095
|
|
|
1096
1096
|
it('excludes every nested node_modules by default', async () => {
|
|
1097
1097
|
const result = await new IntegrationBuilder().build(appDefinition(), {});
|
|
1098
1098
|
|
|
1099
1099
|
expect(packagedFunctions(result).length).toBeGreaterThan(0);
|
|
1100
1100
|
for (const fn of packagedFunctions(result)) {
|
|
1101
|
-
expect(fn.package.
|
|
1101
|
+
expect(fn.package.patterns).toContain('!node_modules/**/node_modules/**');
|
|
1102
1102
|
}
|
|
1103
1103
|
});
|
|
1104
1104
|
|
|
@@ -1109,8 +1109,73 @@ describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1109
1109
|
);
|
|
1110
1110
|
|
|
1111
1111
|
for (const fn of packagedFunctions(result)) {
|
|
1112
|
-
expect(fn.package.
|
|
1113
|
-
expect(fn.package.
|
|
1112
|
+
expect(fn.package.patterns).not.toContain('!node_modules/**/node_modules/**');
|
|
1113
|
+
expect(fn.package.patterns).toContain('!node_modules/**/node_modules/@friggframework/**');
|
|
1114
|
+
}
|
|
1115
|
+
});
|
|
1116
|
+
});
|
|
1117
|
+
|
|
1118
|
+
describe('IntegrationBuilder function package patterns (ADR-050)', () => {
|
|
1119
|
+
const appDefinition = {
|
|
1120
|
+
integrations: [
|
|
1121
|
+
{
|
|
1122
|
+
Definition: {
|
|
1123
|
+
name: 'hubspot',
|
|
1124
|
+
webhooks: true,
|
|
1125
|
+
extensions: {
|
|
1126
|
+
hubspotWebhooks: {
|
|
1127
|
+
extension: {
|
|
1128
|
+
name: 'hubspot-webhooks',
|
|
1129
|
+
routes: [
|
|
1130
|
+
{
|
|
1131
|
+
path: '/webhooks',
|
|
1132
|
+
method: 'POST',
|
|
1133
|
+
event: 'HUBSPOT_WEBHOOK_RECEIVED',
|
|
1134
|
+
},
|
|
1135
|
+
],
|
|
1136
|
+
events: {
|
|
1137
|
+
HUBSPOT_WEBHOOK_RECEIVED: {
|
|
1138
|
+
type: 'LIFE_CYCLE_EVENT',
|
|
1139
|
+
handler: () => {},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
},
|
|
1143
|
+
handlers: {},
|
|
1144
|
+
},
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
1147
|
+
},
|
|
1148
|
+
],
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
it('emits package.patterns, never include/exclude, on every function it packages', async () => {
|
|
1152
|
+
const result = await new IntegrationBuilder().build(appDefinition, {});
|
|
1153
|
+
|
|
1154
|
+
const expected = [
|
|
1155
|
+
'hubspot',
|
|
1156
|
+
'hubspotWebhook',
|
|
1157
|
+
'hubspot__hubspotWebhooks',
|
|
1158
|
+
'hubspotQueueWorker',
|
|
1159
|
+
'dlqProcessor',
|
|
1160
|
+
];
|
|
1161
|
+
for (const name of expected) {
|
|
1162
|
+
const pkg = result.functions[name]?.package;
|
|
1163
|
+
expect(pkg).toBeDefined();
|
|
1164
|
+
expect(pkg).not.toHaveProperty('include');
|
|
1165
|
+
expect(pkg).not.toHaveProperty('exclude');
|
|
1166
|
+
// Integration functions only exclude, so every pattern is negated.
|
|
1167
|
+
expect(pkg.patterns.length).toBeGreaterThan(0);
|
|
1168
|
+
expect(pkg.patterns.every((p) => p.startsWith('!'))).toBe(true);
|
|
1169
|
+
expect(pkg.patterns).toEqual(
|
|
1170
|
+
expect.arrayContaining([
|
|
1171
|
+
'!node_modules/aws-sdk/**',
|
|
1172
|
+
'!node_modules/@prisma/**',
|
|
1173
|
+
'!node_modules/**/node_modules/**',
|
|
1174
|
+
'!node_modules/osls/**',
|
|
1175
|
+
'!test/**',
|
|
1176
|
+
])
|
|
1177
|
+
);
|
|
1178
|
+
expect(pkg.patterns).not.toContain('!src/**');
|
|
1114
1179
|
}
|
|
1115
1180
|
});
|
|
1116
1181
|
});
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
const { buildEnvironment } = require('../environment-builder');
|
|
11
11
|
const { nestedNodeModulesExcludes } = require('./nested-node-modules');
|
|
12
|
+
const { toPackagePatterns } = require('./package-patterns');
|
|
12
13
|
const { buildLoggingProviderConfig } = require('./logging-config');
|
|
14
|
+
const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Create base serverless definition with core functions and resources
|
|
@@ -37,143 +39,95 @@ function createBaseDefinition(
|
|
|
37
39
|
const loggingConfig = buildLoggingProviderConfig(AppDefinition.logging);
|
|
38
40
|
|
|
39
41
|
// Package config for handlers that skip esbuild (need node_modules dependencies)
|
|
40
|
-
// Include backend src/ and index.js since handlers load the app definition
|
|
42
|
+
// Include backend src/ and index.js since handlers load the app definition.
|
|
43
|
+
// osls 4 only reads package.patterns (ADR-050): excludes first, then includes.
|
|
41
44
|
const skipEsbuildPackageConfig = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// Exclude AWS SDK (provided by Lambda runtime)
|
|
59
|
-
'node_modules/aws-sdk/**',
|
|
60
|
-
'node_modules/@aws-sdk/**',
|
|
61
|
-
|
|
62
|
-
// Exclude dev/test dependencies
|
|
63
|
-
'node_modules/@friggframework/test/**',
|
|
64
|
-
'node_modules/@friggframework/eslint-config/**',
|
|
65
|
-
'node_modules/@friggframework/prettier-config/**',
|
|
66
|
-
'node_modules/jest/**',
|
|
67
|
-
'node_modules/prettier/**',
|
|
68
|
-
'node_modules/eslint/**',
|
|
69
|
-
|
|
70
|
-
...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
|
|
71
|
-
|
|
72
|
-
// Exclude build tools (not needed at runtime)
|
|
73
|
-
'node_modules/esbuild/**',
|
|
74
|
-
'node_modules/@esbuild/**',
|
|
75
|
-
'node_modules/typescript/**',
|
|
76
|
-
'node_modules/webpack/**',
|
|
77
|
-
'node_modules/osls/**',
|
|
78
|
-
'node_modules/serverless-esbuild/**',
|
|
79
|
-
'node_modules/serverless-jetpack/**',
|
|
80
|
-
'node_modules/serverless-offline/**',
|
|
81
|
-
'node_modules/serverless-offline-sqs/**',
|
|
82
|
-
'node_modules/serverless-dotenv-plugin/**',
|
|
83
|
-
'node_modules/serverless-kms-grants/**',
|
|
84
|
-
// Note: DO NOT exclude serverless-http - it's a runtime dependency!
|
|
85
|
-
|
|
86
|
-
// Exclude local dev files and environment files (NEVER deploy .env files!)
|
|
87
|
-
'.env',
|
|
88
|
-
'.env.*',
|
|
89
|
-
'.env.local',
|
|
90
|
-
'.env.*.local',
|
|
91
|
-
'**/.env',
|
|
92
|
-
'**/.env.*',
|
|
93
|
-
'deploy.log',
|
|
94
|
-
'.env.backup',
|
|
95
|
-
'docker-compose.yml',
|
|
96
|
-
'jest.config.js',
|
|
97
|
-
'jest.unit.config.js',
|
|
98
|
-
'.eslintrc.json',
|
|
99
|
-
'.prettierrc',
|
|
100
|
-
'.prettierignore',
|
|
101
|
-
'.markdownlintignore',
|
|
102
|
-
'package-lock.json',
|
|
103
|
-
|
|
104
|
-
// Exclude test files and layers (keep src/ - needed for app definition and integrations)
|
|
105
|
-
'test/**',
|
|
106
|
-
'layers/**',
|
|
107
|
-
'coverage/**',
|
|
108
|
-
// Note: DO NOT exclude src/** - handlers need src/integrations and src/api-modules at runtime
|
|
109
|
-
'**/*.test.js',
|
|
110
|
-
'**/*.spec.js',
|
|
111
|
-
'**/.claude-flow/**',
|
|
112
|
-
'**/.swarm/**',
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
// Function-level package config to exclude Prisma and AWS SDK
|
|
117
|
-
const functionPackageConfig = {
|
|
118
|
-
exclude: [
|
|
119
|
-
// Exclude AWS SDK (already in Lambda runtime or externalized by esbuild)
|
|
120
|
-
'node_modules/aws-sdk/**',
|
|
121
|
-
'node_modules/@aws-sdk/**',
|
|
45
|
+
patterns: toPackagePatterns({
|
|
46
|
+
// Explicitly include project files that handlers need
|
|
47
|
+
include: [
|
|
48
|
+
// Include DocumentDB TLS certificate if configured
|
|
49
|
+
...(AppDefinition.database?.documentDB?.tlsCAFile
|
|
50
|
+
? [AppDefinition.database.documentDB.tlsCAFile.replace(/^\.\//, '')]
|
|
51
|
+
: []),
|
|
52
|
+
],
|
|
53
|
+
exclude: [
|
|
54
|
+
// Exclude Prisma (provided via Lambda Layer)
|
|
55
|
+
...(usePrismaLayer ? [
|
|
56
|
+
'node_modules/@prisma/**',
|
|
57
|
+
'node_modules/.prisma/**',
|
|
58
|
+
'node_modules/prisma/**',
|
|
59
|
+
'node_modules/@friggframework/core/generated/**',
|
|
60
|
+
] : []),
|
|
122
61
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
'node_modules/@
|
|
126
|
-
'node_modules/.prisma/**',
|
|
127
|
-
'node_modules/prisma/**',
|
|
128
|
-
'node_modules/@friggframework/core/generated/**',
|
|
129
|
-
] : []),
|
|
62
|
+
// Exclude AWS SDK (provided by Lambda runtime)
|
|
63
|
+
'node_modules/aws-sdk/**',
|
|
64
|
+
'node_modules/@aws-sdk/**',
|
|
130
65
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
66
|
+
// Exclude dev/test dependencies
|
|
67
|
+
'node_modules/@friggframework/test/**',
|
|
68
|
+
'node_modules/@friggframework/eslint-config/**',
|
|
69
|
+
'node_modules/@friggframework/prettier-config/**',
|
|
70
|
+
'node_modules/jest/**',
|
|
71
|
+
'node_modules/prettier/**',
|
|
72
|
+
'node_modules/eslint/**',
|
|
134
73
|
|
|
135
|
-
|
|
136
|
-
'.env',
|
|
137
|
-
'.env.*',
|
|
138
|
-
'.env.local',
|
|
139
|
-
'.env.*.local',
|
|
140
|
-
'**/.env',
|
|
141
|
-
'**/.env.*',
|
|
74
|
+
...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
|
|
142
75
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
76
|
+
// Exclude build tools (not needed at runtime)
|
|
77
|
+
'node_modules/esbuild/**',
|
|
78
|
+
'node_modules/@esbuild/**',
|
|
79
|
+
'node_modules/typescript/**',
|
|
80
|
+
'node_modules/webpack/**',
|
|
81
|
+
'node_modules/osls/**',
|
|
82
|
+
'node_modules/serverless-esbuild/**',
|
|
83
|
+
'node_modules/serverless-jetpack/**',
|
|
84
|
+
'node_modules/serverless-offline/**',
|
|
85
|
+
'node_modules/serverless-offline-sqs/**',
|
|
86
|
+
'node_modules/serverless-dotenv-plugin/**',
|
|
87
|
+
'node_modules/serverless-kms-grants/**',
|
|
88
|
+
// Note: DO NOT exclude serverless-http - it's a runtime dependency!
|
|
152
89
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
90
|
+
// Exclude local dev files and environment files (NEVER deploy .env files!)
|
|
91
|
+
'.env',
|
|
92
|
+
'.env.*',
|
|
93
|
+
'.env.local',
|
|
94
|
+
'.env.*.local',
|
|
95
|
+
'**/.env',
|
|
96
|
+
'**/.env.*',
|
|
97
|
+
'deploy.log',
|
|
98
|
+
'.env.backup',
|
|
99
|
+
'docker-compose.yml',
|
|
100
|
+
'jest.config.js',
|
|
101
|
+
'jest.unit.config.js',
|
|
102
|
+
'.eslintrc.json',
|
|
103
|
+
'.prettierrc',
|
|
104
|
+
'.prettierignore',
|
|
105
|
+
'.markdownlintignore',
|
|
106
|
+
'package-lock.json',
|
|
159
107
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
108
|
+
// Exclude test files and layers (keep src/ - needed for app definition and integrations)
|
|
109
|
+
'test/**',
|
|
110
|
+
'layers/**',
|
|
111
|
+
'coverage/**',
|
|
112
|
+
// Note: DO NOT exclude src/** - handlers need src/integrations and src/api-modules at runtime
|
|
113
|
+
'**/*.test.js',
|
|
114
|
+
'**/*.spec.js',
|
|
115
|
+
'**/.claude-flow/**',
|
|
116
|
+
'**/.swarm/**',
|
|
117
|
+
],
|
|
118
|
+
}),
|
|
166
119
|
};
|
|
167
120
|
|
|
168
121
|
return {
|
|
169
|
-
frameworkVersion:
|
|
122
|
+
frameworkVersion: OSLS_FRAMEWORK_VERSION,
|
|
170
123
|
service: AppDefinition.name || 'create-frigg-app',
|
|
171
124
|
package: {
|
|
172
125
|
individually: true,
|
|
173
126
|
},
|
|
174
127
|
// Only use .env for local development (offline mode)
|
|
175
|
-
// Production deployments should use environment vars from infrastructure
|
|
176
|
-
useDotenv:
|
|
128
|
+
// Production deployments should use environment vars from infrastructure.
|
|
129
|
+
// Emitted only when true: osls 4 accepts `useDotenv: true` or no key (ADR-050).
|
|
130
|
+
...(process.argv.includes('offline') && { useDotenv: true }),
|
|
177
131
|
provider: {
|
|
178
132
|
name: AppDefinition.provider || 'aws',
|
|
179
133
|
...(process.env.AWS_PROFILE && { profile: process.env.AWS_PROFILE }),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
const { createBaseDefinition } = require('./base-definition-factory');
|
|
8
|
+
const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
|
|
8
9
|
|
|
9
10
|
describe('Base Definition Factory', () => {
|
|
10
11
|
beforeEach(() => {
|
|
@@ -23,7 +24,7 @@ describe('Base Definition Factory', () => {
|
|
|
23
24
|
const result = createBaseDefinition(appDefinition, appEnvironmentVars, discoveredResources);
|
|
24
25
|
|
|
25
26
|
expect(result.service).toBe('test-app');
|
|
26
|
-
expect(result.frameworkVersion).toBe(
|
|
27
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
27
28
|
expect(result.provider.name).toBe('aws');
|
|
28
29
|
expect(result.provider.runtime).toBe('nodejs22.x');
|
|
29
30
|
expect(result.provider.timeout).toBe(29);
|
|
@@ -257,12 +258,75 @@ describe('Base Definition Factory', () => {
|
|
|
257
258
|
expect(result.package.individually).toBe(true);
|
|
258
259
|
});
|
|
259
260
|
|
|
260
|
-
|
|
261
|
-
const
|
|
261
|
+
describe('useDotenv (ADR-050)', () => {
|
|
262
|
+
const originalArgv = process.argv;
|
|
263
|
+
afterEach(() => {
|
|
264
|
+
process.argv = originalArgv;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it.each([['package'], ['deploy'], ['print']])(
|
|
268
|
+
'omits useDotenv for `osls %s` (osls 4 only accepts true)',
|
|
269
|
+
(command) => {
|
|
270
|
+
process.argv = ['node', 'osls', command, '--stage', 'prod'];
|
|
271
|
+
const result = createBaseDefinition({}, {}, {});
|
|
272
|
+
|
|
273
|
+
expect(result).not.toHaveProperty('useDotenv');
|
|
274
|
+
expect(result.plugins).not.toContain('serverless-dotenv-plugin');
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
it('sets useDotenv: true for `osls offline`', () => {
|
|
279
|
+
process.argv = ['node', 'osls', 'offline', '--stage', 'dev'];
|
|
280
|
+
const result = createBaseDefinition({}, {}, {});
|
|
262
281
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
282
|
+
expect(result.useDotenv).toBe(true);
|
|
283
|
+
expect(result.plugins).toContain('serverless-dotenv-plugin');
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe('function package patterns (ADR-050)', () => {
|
|
288
|
+
it('emits package.patterns and no include/exclude on auth, user and health', () => {
|
|
289
|
+
const result = createBaseDefinition({}, {}, {});
|
|
290
|
+
|
|
291
|
+
for (const fn of ['auth', 'user', 'health']) {
|
|
292
|
+
const pkg = result.functions[fn].package;
|
|
293
|
+
expect(pkg).not.toHaveProperty('include');
|
|
294
|
+
expect(pkg).not.toHaveProperty('exclude');
|
|
295
|
+
expect(Array.isArray(pkg.patterns)).toBe(true);
|
|
296
|
+
expect(pkg.patterns).toEqual(
|
|
297
|
+
expect.arrayContaining([
|
|
298
|
+
'!node_modules/aws-sdk/**',
|
|
299
|
+
'!node_modules/@aws-sdk/**',
|
|
300
|
+
'!.env',
|
|
301
|
+
'!**/.env.*',
|
|
302
|
+
'!package-lock.json',
|
|
303
|
+
'!test/**',
|
|
304
|
+
'!layers/**',
|
|
305
|
+
])
|
|
306
|
+
);
|
|
307
|
+
// No exclude pattern removes src/: handlers load the app definition from it.
|
|
308
|
+
expect(pkg.patterns).not.toContain('!src/**');
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('puts the DocumentDB CA file after every exclude so it is re-added', () => {
|
|
313
|
+
const result = createBaseDefinition(
|
|
314
|
+
{ database: { documentDB: { tlsCAFile: './certs/global-bundle.pem' } } },
|
|
315
|
+
{},
|
|
316
|
+
{}
|
|
317
|
+
);
|
|
318
|
+
const { patterns } = result.functions.auth.package;
|
|
319
|
+
|
|
320
|
+
expect(patterns[patterns.length - 1]).toBe('certs/global-bundle.pem');
|
|
321
|
+
expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('emits only negated excludes when no CA file is configured', () => {
|
|
325
|
+
const result = createBaseDefinition({}, {}, {});
|
|
326
|
+
expect(
|
|
327
|
+
result.functions.auth.package.patterns.every((p) => p.startsWith('!'))
|
|
328
|
+
).toBe(true);
|
|
329
|
+
});
|
|
266
330
|
});
|
|
267
331
|
|
|
268
332
|
describe('usePrismaLayer configuration', () => {
|
|
@@ -271,12 +335,12 @@ describe('Base Definition Factory', () => {
|
|
|
271
335
|
|
|
272
336
|
expect(result.layers.prisma).toBeDefined();
|
|
273
337
|
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
274
|
-
expect(result.functions.auth.package.
|
|
338
|
+
expect(result.functions.auth.package.patterns).toEqual(
|
|
275
339
|
expect.arrayContaining([
|
|
276
|
-
'node_modules/@prisma/**',
|
|
277
|
-
'node_modules/.prisma/**',
|
|
278
|
-
'node_modules/prisma/**',
|
|
279
|
-
'node_modules/@friggframework/core/generated/**',
|
|
340
|
+
'!node_modules/@prisma/**',
|
|
341
|
+
'!node_modules/.prisma/**',
|
|
342
|
+
'!node_modules/prisma/**',
|
|
343
|
+
'!node_modules/@friggframework/core/generated/**',
|
|
280
344
|
])
|
|
281
345
|
);
|
|
282
346
|
expect(result.custom.esbuild.external).toEqual(
|
|
@@ -289,12 +353,12 @@ describe('Base Definition Factory', () => {
|
|
|
289
353
|
|
|
290
354
|
expect(result.layers).toEqual({});
|
|
291
355
|
expect(result.functions.auth.layers).toBeUndefined();
|
|
292
|
-
expect(result.functions.auth.package.
|
|
356
|
+
expect(result.functions.auth.package.patterns).not.toEqual(
|
|
293
357
|
expect.arrayContaining([
|
|
294
|
-
'node_modules/@prisma/**',
|
|
295
|
-
'node_modules/.prisma/**',
|
|
296
|
-
'node_modules/prisma/**',
|
|
297
|
-
'node_modules/@friggframework/core/generated/**',
|
|
358
|
+
'!node_modules/@prisma/**',
|
|
359
|
+
'!node_modules/.prisma/**',
|
|
360
|
+
'!node_modules/prisma/**',
|
|
361
|
+
'!node_modules/@friggframework/core/generated/**',
|
|
298
362
|
])
|
|
299
363
|
);
|
|
300
364
|
expect(result.custom.esbuild.external).not.toEqual(
|
|
@@ -318,7 +382,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
318
382
|
const result = build({ name: 'test-app' });
|
|
319
383
|
|
|
320
384
|
for (const fn of ['auth', 'user', 'health']) {
|
|
321
|
-
expect(result.functions[fn].package.
|
|
385
|
+
expect(result.functions[fn].package.patterns).toContain('!node_modules/**/node_modules/**');
|
|
322
386
|
}
|
|
323
387
|
});
|
|
324
388
|
|
|
@@ -326,13 +390,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
326
390
|
const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
|
|
327
391
|
|
|
328
392
|
for (const fn of ['auth', 'user', 'health']) {
|
|
329
|
-
const {
|
|
330
|
-
expect(
|
|
331
|
-
expect(
|
|
393
|
+
const { patterns } = result.functions[fn].package;
|
|
394
|
+
expect(patterns).not.toContain('!node_modules/**/node_modules/**');
|
|
395
|
+
expect(patterns).toEqual(
|
|
332
396
|
expect.arrayContaining([
|
|
333
|
-
'node_modules/**/node_modules/@friggframework/**',
|
|
334
|
-
'node_modules/**/node_modules/@aws-sdk/**',
|
|
335
|
-
'node_modules/**/node_modules/@prisma/**',
|
|
397
|
+
'!node_modules/**/node_modules/@friggframework/**',
|
|
398
|
+
'!node_modules/**/node_modules/@aws-sdk/**',
|
|
399
|
+
'!node_modules/**/node_modules/@prisma/**',
|
|
336
400
|
])
|
|
337
401
|
);
|
|
338
402
|
}
|
|
@@ -348,14 +412,14 @@ describe('logging (ADR-048)', () => {
|
|
|
348
412
|
|
|
349
413
|
expect(result.provider.logs).toBeUndefined();
|
|
350
414
|
expect(result.provider.logRetentionInDays).toBeUndefined();
|
|
351
|
-
expect(result.frameworkVersion).toBe(
|
|
415
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
352
416
|
});
|
|
353
417
|
|
|
354
418
|
it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
|
|
355
419
|
const result = build({ level: 'warn' });
|
|
356
420
|
|
|
357
421
|
expect(result.provider.logs).toBeUndefined();
|
|
358
|
-
expect(result.frameworkVersion).toBe(
|
|
422
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
359
423
|
});
|
|
360
424
|
|
|
361
425
|
it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
|
|
@@ -367,7 +431,12 @@ describe('logging (ADR-048)', () => {
|
|
|
367
431
|
|
|
368
432
|
expect(result.provider.logRetentionInDays).toBe(30);
|
|
369
433
|
expect(result.provider.logs).toBeUndefined();
|
|
370
|
-
expect(result.frameworkVersion).toBe(
|
|
434
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('keeps the single osls frameworkVersion even when the Lambda LoggingConfig is on (ADR-050)', () => {
|
|
438
|
+
const result = build({ level: 'warn' });
|
|
439
|
+
expect(result.frameworkVersion).toBe('^4.4.0');
|
|
371
440
|
});
|
|
372
441
|
|
|
373
442
|
it('accepts 1096, which CloudWatch allows but the osls schema omits', () => {
|
|
@@ -0,0 +1,14 @@
|
|
|
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 };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { OSLS_FRAMEWORK_VERSION } = require('./framework-version');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
|
|
4
|
+
describe('OSLS_FRAMEWORK_VERSION (ADR-050)', () => {
|
|
5
|
+
it('is the osls 4 range Frigg targets', () => {
|
|
6
|
+
expect(OSLS_FRAMEWORK_VERSION).toBe('^4.4.0');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it.each([
|
|
10
|
+
['4.4.0', true],
|
|
11
|
+
['4.9.1', true],
|
|
12
|
+
['4.3.9', false],
|
|
13
|
+
['3.78.0', false],
|
|
14
|
+
['5.0.0', false],
|
|
15
|
+
])('osls %s satisfies it: %s', (version, expected) => {
|
|
16
|
+
// osls compares frameworkVersion with semver.satisfies and fails
|
|
17
|
+
// with FRAMEWORK_VERSION_MISMATCH otherwise.
|
|
18
|
+
expect(semver.satisfies(version, OSLS_FRAMEWORK_VERSION)).toBe(expected);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('matches the osls range devtools and frigg-cli depend on', () => {
|
|
22
|
+
const devtools = require('../../../../package.json');
|
|
23
|
+
const cli = require('../../../../frigg-cli/package.json');
|
|
24
|
+
expect(devtools.devDependencies.osls).toBe(OSLS_FRAMEWORK_VERSION);
|
|
25
|
+
expect(cli.dependencies.osls).toBe(OSLS_FRAMEWORK_VERSION);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -6,8 +6,8 @@ const RETENTION_DAYS = [
|
|
|
6
6
|
2192, 2557, 2922, 3288, 3653,
|
|
7
7
|
];
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
|
|
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.
|
|
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 {{
|
|
42
|
+
* @returns {{ provider?: Object }}
|
|
43
43
|
*/
|
|
44
44
|
function buildLoggingProviderConfig(
|
|
45
45
|
logging,
|
|
@@ -53,7 +53,6 @@ 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;
|
|
57
56
|
provider.logs = {
|
|
58
57
|
lambda: {
|
|
59
58
|
logFormat: 'JSON',
|
|
@@ -18,9 +18,8 @@ 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 leaves frameworkVersion to the base definition (ADR-050)', () => {
|
|
22
22
|
expect(build({ level: 'warn' })).toEqual({
|
|
23
|
-
frameworkVersion: '>=3.58.0',
|
|
24
23
|
provider: {
|
|
25
24
|
logs: {
|
|
26
25
|
lambda: {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function package patterns
|
|
3
|
+
*
|
|
4
|
+
* Utility Layer - Hexagonal Architecture
|
|
5
|
+
*
|
|
6
|
+
* osls 4 rejects `package.include` / `package.exclude` and only reads
|
|
7
|
+
* `package.patterns` (ADR-050). Builders keep their include and exclude lists
|
|
8
|
+
* and pass them through this helper, so one place owns the negation.
|
|
9
|
+
*
|
|
10
|
+
* osls resolves a function's files with `resolveFilePathsFromPatterns`: an
|
|
11
|
+
* ordered list evaluated last-match-wins. On osls 3 a function `exclude` was
|
|
12
|
+
* placed (negated) ahead of the function `include`. Frigg emits no
|
|
13
|
+
* service-level include, exclude or patterns, so `[!exclude..., include...]`
|
|
14
|
+
* reproduces the osls 3 order exactly, and is valid on osls 3 and osls 4.
|
|
15
|
+
*
|
|
16
|
+
* An exclude that already starts with `!` was treated by osls 3 as an include
|
|
17
|
+
* in exclude position; it is emitted un-negated in the same position here.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {Object} [lists]
|
|
22
|
+
* @param {string[]} [lists.include] - Globs to (re-)add after the excludes
|
|
23
|
+
* @param {string[]} [lists.exclude] - Globs to remove
|
|
24
|
+
* @returns {string[]} Value for `package.patterns`
|
|
25
|
+
*/
|
|
26
|
+
function toPackagePatterns({ include = [], exclude = [] } = {}) {
|
|
27
|
+
return [
|
|
28
|
+
...exclude.map((pattern) =>
|
|
29
|
+
pattern.startsWith('!') ? pattern.slice(1) : `!${pattern}`
|
|
30
|
+
),
|
|
31
|
+
...include,
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = { toPackagePatterns };
|