@friggframework/devtools 2.0.0--canary.705.9cfd819.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 +83 -30
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +18 -0
- package/frigg-cli/__tests__/unit/commands/init.test.js +688 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +594 -341
- 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/generate-command/index.js +1 -0
- package/frigg-cli/generate-iam-command.js +1 -0
- package/frigg-cli/index.js +12 -4
- package/frigg-cli/init-command/backend-first-handler.js +397 -554
- package/frigg-cli/init-command/deployment-modes.js +7 -0
- package/frigg-cli/init-command/index.js +82 -35
- package/frigg-cli/init-command/safe-path.js +58 -0
- package/frigg-cli/init-command/scaffold-dependencies.js +202 -0
- package/frigg-cli/install-command/app-definition.js +174 -0
- package/frigg-cli/install-command/commit-changes.js +40 -8
- package/frigg-cli/install-command/environment-variables.js +15 -0
- package/frigg-cli/install-command/index.js +96 -21
- package/frigg-cli/install-command/install-package.js +77 -4
- package/frigg-cli/install-command/integration-file.js +20 -11
- package/frigg-cli/install-command/resolve-module.js +69 -0
- package/frigg-cli/install-command/template.js +102 -75
- package/frigg-cli/install-command/validate-package.js +36 -4
- package/frigg-cli/package.json +3 -3
- package/frigg-cli/templates/backend/README.md +267 -0
- package/frigg-cli/templates/backend/env.example +20 -0
- package/frigg-cli/templates/backend/gitignore +10 -0
- package/frigg-cli/templates/backend/index.js +114 -0
- package/frigg-cli/templates/backend/infrastructure.js +20 -0
- package/frigg-cli/test/init-command.test.js +9 -2
- 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/__tests__/scaffold-default-infrastructure.test.js +148 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +21 -1
- 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/aurora-builder.js +13 -2
- package/infrastructure/domains/database/aurora-builder.test.js +22 -0
- 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/security/iam-generator.js +112 -5
- package/infrastructure/domains/security/iam-generator.test.js +94 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +83 -124
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +116 -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 +13 -8
|
@@ -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);
|
|
@@ -121,6 +122,27 @@ describe('Base Definition Factory', () => {
|
|
|
121
122
|
expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
|
|
122
123
|
});
|
|
123
124
|
|
|
125
|
+
it('alarms on the HTTP API 5xx metric of the API osls creates', () => {
|
|
126
|
+
// The Frigg functions use `httpApi` events, so osls creates an
|
|
127
|
+
// API Gateway v2 HTTP API (logical ID HttpApi) with only the
|
|
128
|
+
// `$default` stage. HTTP APIs publish `5xx` (REST APIs publish
|
|
129
|
+
// `5XXError`) with the ApiId dimension; a Stage dimension set to
|
|
130
|
+
// the deploy stage name would never match `$default`.
|
|
131
|
+
const result = createBaseDefinition({}, {}, {});
|
|
132
|
+
const usesHttpApi = Object.values(result.functions).some((fn) =>
|
|
133
|
+
(fn.events || []).some((event) => event.httpApi)
|
|
134
|
+
);
|
|
135
|
+
expect(usesHttpApi).toBe(true);
|
|
136
|
+
|
|
137
|
+
const alarm = result.resources.Resources.ApiGatewayAlarm5xx;
|
|
138
|
+
expect(alarm.Properties).toMatchObject({
|
|
139
|
+
Namespace: 'AWS/ApiGateway',
|
|
140
|
+
MetricName: '5xx',
|
|
141
|
+
Dimensions: [{ Name: 'ApiId', Value: { Ref: 'HttpApi' } }],
|
|
142
|
+
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
124
146
|
it('should include base IAM permissions', () => {
|
|
125
147
|
const result = createBaseDefinition({}, {}, {});
|
|
126
148
|
|
|
@@ -236,12 +258,75 @@ describe('Base Definition Factory', () => {
|
|
|
236
258
|
expect(result.package.individually).toBe(true);
|
|
237
259
|
});
|
|
238
260
|
|
|
239
|
-
|
|
240
|
-
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({}, {}, {});
|
|
281
|
+
|
|
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;
|
|
241
319
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
+
});
|
|
245
330
|
});
|
|
246
331
|
|
|
247
332
|
describe('usePrismaLayer configuration', () => {
|
|
@@ -250,12 +335,12 @@ describe('Base Definition Factory', () => {
|
|
|
250
335
|
|
|
251
336
|
expect(result.layers.prisma).toBeDefined();
|
|
252
337
|
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
253
|
-
expect(result.functions.auth.package.
|
|
338
|
+
expect(result.functions.auth.package.patterns).toEqual(
|
|
254
339
|
expect.arrayContaining([
|
|
255
|
-
'node_modules/@prisma/**',
|
|
256
|
-
'node_modules/.prisma/**',
|
|
257
|
-
'node_modules/prisma/**',
|
|
258
|
-
'node_modules/@friggframework/core/generated/**',
|
|
340
|
+
'!node_modules/@prisma/**',
|
|
341
|
+
'!node_modules/.prisma/**',
|
|
342
|
+
'!node_modules/prisma/**',
|
|
343
|
+
'!node_modules/@friggframework/core/generated/**',
|
|
259
344
|
])
|
|
260
345
|
);
|
|
261
346
|
expect(result.custom.esbuild.external).toEqual(
|
|
@@ -268,12 +353,12 @@ describe('Base Definition Factory', () => {
|
|
|
268
353
|
|
|
269
354
|
expect(result.layers).toEqual({});
|
|
270
355
|
expect(result.functions.auth.layers).toBeUndefined();
|
|
271
|
-
expect(result.functions.auth.package.
|
|
356
|
+
expect(result.functions.auth.package.patterns).not.toEqual(
|
|
272
357
|
expect.arrayContaining([
|
|
273
|
-
'node_modules/@prisma/**',
|
|
274
|
-
'node_modules/.prisma/**',
|
|
275
|
-
'node_modules/prisma/**',
|
|
276
|
-
'node_modules/@friggframework/core/generated/**',
|
|
358
|
+
'!node_modules/@prisma/**',
|
|
359
|
+
'!node_modules/.prisma/**',
|
|
360
|
+
'!node_modules/prisma/**',
|
|
361
|
+
'!node_modules/@friggframework/core/generated/**',
|
|
277
362
|
])
|
|
278
363
|
);
|
|
279
364
|
expect(result.custom.esbuild.external).not.toEqual(
|
|
@@ -297,7 +382,7 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
297
382
|
const result = build({ name: 'test-app' });
|
|
298
383
|
|
|
299
384
|
for (const fn of ['auth', 'user', 'health']) {
|
|
300
|
-
expect(result.functions[fn].package.
|
|
385
|
+
expect(result.functions[fn].package.patterns).toContain('!node_modules/**/node_modules/**');
|
|
301
386
|
}
|
|
302
387
|
});
|
|
303
388
|
|
|
@@ -305,13 +390,13 @@ describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
|
305
390
|
const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
|
|
306
391
|
|
|
307
392
|
for (const fn of ['auth', 'user', 'health']) {
|
|
308
|
-
const {
|
|
309
|
-
expect(
|
|
310
|
-
expect(
|
|
393
|
+
const { patterns } = result.functions[fn].package;
|
|
394
|
+
expect(patterns).not.toContain('!node_modules/**/node_modules/**');
|
|
395
|
+
expect(patterns).toEqual(
|
|
311
396
|
expect.arrayContaining([
|
|
312
|
-
'node_modules/**/node_modules/@friggframework/**',
|
|
313
|
-
'node_modules/**/node_modules/@aws-sdk/**',
|
|
314
|
-
'node_modules/**/node_modules/@prisma/**',
|
|
397
|
+
'!node_modules/**/node_modules/@friggframework/**',
|
|
398
|
+
'!node_modules/**/node_modules/@aws-sdk/**',
|
|
399
|
+
'!node_modules/**/node_modules/@prisma/**',
|
|
315
400
|
])
|
|
316
401
|
);
|
|
317
402
|
}
|
|
@@ -327,14 +412,14 @@ describe('logging (ADR-048)', () => {
|
|
|
327
412
|
|
|
328
413
|
expect(result.provider.logs).toBeUndefined();
|
|
329
414
|
expect(result.provider.logRetentionInDays).toBeUndefined();
|
|
330
|
-
expect(result.frameworkVersion).toBe(
|
|
415
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
331
416
|
});
|
|
332
417
|
|
|
333
418
|
it('validates logging.level but leaves the Lambda log format and frameworkVersion alone by default', () => {
|
|
334
419
|
const result = build({ level: 'warn' });
|
|
335
420
|
|
|
336
421
|
expect(result.provider.logs).toBeUndefined();
|
|
337
|
-
expect(result.frameworkVersion).toBe(
|
|
422
|
+
expect(result.frameworkVersion).toBe(OSLS_FRAMEWORK_VERSION);
|
|
338
423
|
});
|
|
339
424
|
|
|
340
425
|
it.each(['verbose', 'warning', '', 3])('throws on unknown level %p', (level) => {
|
|
@@ -346,7 +431,12 @@ describe('logging (ADR-048)', () => {
|
|
|
346
431
|
|
|
347
432
|
expect(result.provider.logRetentionInDays).toBe(30);
|
|
348
433
|
expect(result.provider.logs).toBeUndefined();
|
|
349
|
-
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');
|
|
350
440
|
});
|
|
351
441
|
|
|
352
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 };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the function package patterns helper (ADR-050)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const { toPackagePatterns } = require('./package-patterns');
|
|
6
|
+
const { nestedNodeModulesExcludes } = require('./nested-node-modules');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The ordered list osls 3 built in resolveFilePathsFromPatterns for a function
|
|
10
|
+
* that set `package.include` / `package.exclude` (no service-level patterns,
|
|
11
|
+
* which Frigg never emits, and before the dev-dependency patterns that both
|
|
12
|
+
* versions append identically).
|
|
13
|
+
*/
|
|
14
|
+
function osls3FunctionOrder({ include = [], exclude = [] }) {
|
|
15
|
+
const patterns = [];
|
|
16
|
+
exclude.forEach((p) => patterns.push(p.charAt(0) !== '!' ? `!${p}` : p.substring(1)));
|
|
17
|
+
include.forEach((p) => patterns.push(p));
|
|
18
|
+
return patterns;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The ordered list osls 3 and osls 4 build for a function that sets
|
|
23
|
+
* `package.patterns`: the patterns go in include position, unchanged.
|
|
24
|
+
*/
|
|
25
|
+
function patternsFunctionOrder(patterns) {
|
|
26
|
+
return [...patterns];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('toPackagePatterns', () => {
|
|
30
|
+
const cases = [
|
|
31
|
+
{
|
|
32
|
+
name: 'excludes first (negated), then includes',
|
|
33
|
+
lists: {
|
|
34
|
+
include: ['ca.pem'],
|
|
35
|
+
exclude: ['node_modules/aws-sdk/**', '.env'],
|
|
36
|
+
},
|
|
37
|
+
expected: ['!node_modules/aws-sdk/**', '!.env', 'ca.pem'],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'an exclude that already starts with ! becomes an include in exclude position',
|
|
41
|
+
lists: {
|
|
42
|
+
include: [],
|
|
43
|
+
exclude: ['node_modules/**', '!node_modules/keep/**'],
|
|
44
|
+
},
|
|
45
|
+
expected: ['!node_modules/**', 'node_modules/keep/**'],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'an include re-adds a path that an exclude removed',
|
|
49
|
+
lists: {
|
|
50
|
+
include: ['config/ca.pem'],
|
|
51
|
+
exclude: ['config/**'],
|
|
52
|
+
},
|
|
53
|
+
expected: ['!config/**', 'config/ca.pem'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'empty lists',
|
|
57
|
+
lists: { include: [], exclude: [] },
|
|
58
|
+
expected: [],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'only excludes',
|
|
62
|
+
lists: { exclude: ['test/**'] },
|
|
63
|
+
expected: ['!test/**'],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'only includes',
|
|
67
|
+
lists: { include: ['ca.pem'] },
|
|
68
|
+
expected: ['ca.pem'],
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
it.each(cases)('$name', ({ lists, expected }) => {
|
|
73
|
+
const patterns = toPackagePatterns(lists);
|
|
74
|
+
expect(patterns).toEqual(expected);
|
|
75
|
+
// Same evaluation order osls 3 applied to include/exclude.
|
|
76
|
+
expect(patternsFunctionOrder(patterns)).toEqual(osls3FunctionOrder(lists));
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('returns an empty list when called with no arguments', () => {
|
|
80
|
+
expect(toPackagePatterns()).toEqual([]);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('does not mutate its inputs', () => {
|
|
84
|
+
const exclude = ['a/**'];
|
|
85
|
+
const include = ['b'];
|
|
86
|
+
toPackagePatterns({ include, exclude });
|
|
87
|
+
expect(exclude).toEqual(['a/**']);
|
|
88
|
+
expect(include).toEqual(['b']);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('with nestedNodeModulesExcludes output', () => {
|
|
92
|
+
it('negates the single catch-all glob by default', () => {
|
|
93
|
+
const exclude = nestedNodeModulesExcludes({}, true);
|
|
94
|
+
expect(toPackagePatterns({ exclude })).toEqual([
|
|
95
|
+
'!node_modules/**/node_modules/**',
|
|
96
|
+
]);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('negates every scoped glob when keepNestedNodeModules is set', () => {
|
|
100
|
+
const appDefinition = { lambda: { keepNestedNodeModules: true } };
|
|
101
|
+
const exclude = nestedNodeModulesExcludes(appDefinition, true);
|
|
102
|
+
const patterns = toPackagePatterns({ exclude });
|
|
103
|
+
|
|
104
|
+
expect(patterns).toEqual(exclude.map((p) => `!${p}`));
|
|
105
|
+
expect(patterns).toContain('!node_modules/**/node_modules/@friggframework/**');
|
|
106
|
+
expect(patterns).not.toContain('!node_modules/**/node_modules/**');
|
|
107
|
+
expect(patternsFunctionOrder(patterns)).toEqual(
|
|
108
|
+
osls3FunctionOrder({ exclude })
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -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('^4.4.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('^4.4.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('^4.4.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,12 +1,13 @@
|
|
|
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.704.6a606c3.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"frigg-cli/",
|
|
10
|
+
"frigg-cli/templates/",
|
|
10
11
|
"infrastructure/",
|
|
11
12
|
"migrations/",
|
|
12
13
|
"management-ui/dist/",
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"@aws-sdk/client-cloudformation": "^3.705.0",
|
|
19
20
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
20
21
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
22
|
+
"@aws-sdk/client-lambda": "^3.714.0",
|
|
21
23
|
"@aws-sdk/client-rds": "^3.906.0",
|
|
22
24
|
"@aws-sdk/client-s3": "^3.917.0",
|
|
23
25
|
"@aws-sdk/client-secrets-manager": "^3.906.0",
|
|
@@ -26,9 +28,9 @@
|
|
|
26
28
|
"@babel/eslint-parser": "^7.18.9",
|
|
27
29
|
"@babel/parser": "^7.25.3",
|
|
28
30
|
"@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.
|
|
31
|
+
"@friggframework/core": "2.0.0--canary.704.6a606c3.0",
|
|
32
|
+
"@friggframework/schemas": "2.0.0--canary.704.6a606c3.0",
|
|
33
|
+
"@friggframework/test": "2.0.0--canary.704.6a606c3.0",
|
|
32
34
|
"@hapi/boom": "^10.0.1",
|
|
33
35
|
"@inquirer/prompts": "^5.3.8",
|
|
34
36
|
"axios": "^1.18.0",
|
|
@@ -56,12 +58,12 @@
|
|
|
56
58
|
"validate-npm-package-name": "^5.0.0"
|
|
57
59
|
},
|
|
58
60
|
"devDependencies": {
|
|
59
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
60
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
61
|
+
"@friggframework/eslint-config": "2.0.0--canary.704.6a606c3.0",
|
|
62
|
+
"@friggframework/prettier-config": "2.0.0--canary.704.6a606c3.0",
|
|
61
63
|
"aws-sdk-client-mock": "^4.1.0",
|
|
62
64
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
63
65
|
"jest": "^30.1.3",
|
|
64
|
-
"osls": "^
|
|
66
|
+
"osls": "^4.4.0",
|
|
65
67
|
"prettier": "^2.7.1",
|
|
66
68
|
"serverless-dotenv-plugin": "^6.0.0",
|
|
67
69
|
"serverless-esbuild": "^1.54.3",
|
|
@@ -70,6 +72,9 @@
|
|
|
70
72
|
"serverless-offline-sqs": "^8.0.0",
|
|
71
73
|
"serverless-plugin-monorepo": "^0.11.0"
|
|
72
74
|
},
|
|
75
|
+
"engines": {
|
|
76
|
+
"node": "^22.13.0 || >=24"
|
|
77
|
+
},
|
|
73
78
|
"scripts": {
|
|
74
79
|
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
|
|
75
80
|
"test": "jest --passWithNoTests # TODO"
|
|
@@ -89,5 +94,5 @@
|
|
|
89
94
|
"publishConfig": {
|
|
90
95
|
"access": "public"
|
|
91
96
|
},
|
|
92
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "6a606c35cd01084a4c498809d312d77e219b2f81"
|
|
93
98
|
}
|