@friggframework/devtools 2.0.0--canary.643.45b1fbc.0 → 2.0.0--canary.636.7dc8dca.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/infrastructure/README.md +18 -0
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -1
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +31 -0
- package/infrastructure/domains/database/aurora-builder.js +40 -329
- package/infrastructure/domains/database/aurora-builder.test.js +1 -1
- package/infrastructure/domains/database/migration-builder.js +5 -6
- package/infrastructure/domains/database/migration-builder.test.js +28 -0
- package/infrastructure/domains/integration/integration-builder.js +9 -5
- package/infrastructure/domains/integration/integration-builder.test.js +30 -0
- package/infrastructure/domains/networking/vpc-builder.js +6 -97
- package/infrastructure/domains/shared/types/app-definition.js +2 -18
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -2
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +28 -0
- package/infrastructure/domains/shared/utilities/nested-node-modules.js +53 -0
- package/infrastructure/domains/shared/utilities/nested-node-modules.test.js +61 -0
- package/package.json +7 -7
- package/infrastructure/__tests__/aurora-scale-to-zero-connectivity.test.js +0 -356
|
@@ -424,3 +424,31 @@ describe('MigrationBuilder', () => {
|
|
|
424
424
|
});
|
|
425
425
|
});
|
|
426
426
|
|
|
427
|
+
|
|
428
|
+
describe('MigrationBuilder nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
429
|
+
const baseAppDefinition = { database: { postgres: { enable: true } } };
|
|
430
|
+
const workerAndRouter = (result) => [
|
|
431
|
+
result.functions.dbMigrationWorker,
|
|
432
|
+
result.functions.dbMigrationRouter,
|
|
433
|
+
];
|
|
434
|
+
|
|
435
|
+
it('excludes every nested node_modules by default', async () => {
|
|
436
|
+
const result = await new MigrationBuilder().build(baseAppDefinition, {});
|
|
437
|
+
|
|
438
|
+
for (const fn of workerAndRouter(result)) {
|
|
439
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
|
|
444
|
+
const result = await new MigrationBuilder().build(
|
|
445
|
+
{ ...baseAppDefinition, lambda: { keepNestedNodeModules: true } },
|
|
446
|
+
{}
|
|
447
|
+
);
|
|
448
|
+
|
|
449
|
+
for (const fn of workerAndRouter(result)) {
|
|
450
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
451
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
@@ -29,6 +29,9 @@ const {
|
|
|
29
29
|
getIntegrationFunctionNames,
|
|
30
30
|
getAdminFunctionNames,
|
|
31
31
|
} = require('../shared/function-environments');
|
|
32
|
+
const {
|
|
33
|
+
nestedNodeModulesExcludes,
|
|
34
|
+
} = require('../shared/utilities/nested-node-modules');
|
|
32
35
|
|
|
33
36
|
class IntegrationBuilder extends InfrastructureBuilder {
|
|
34
37
|
constructor() {
|
|
@@ -182,8 +185,10 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
182
185
|
usePrismaLayer = true
|
|
183
186
|
) {
|
|
184
187
|
// Create package config first — needed by all Lambda functions including DLQ processor
|
|
185
|
-
const functionPackageConfig =
|
|
186
|
-
|
|
188
|
+
const functionPackageConfig = this.createFunctionPackageConfig(
|
|
189
|
+
usePrismaLayer,
|
|
190
|
+
appDefinition
|
|
191
|
+
);
|
|
187
192
|
|
|
188
193
|
// Create InternalErrorQueue if ownership = STACK
|
|
189
194
|
const shouldCreateInternalErrorQueue =
|
|
@@ -243,7 +248,7 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
243
248
|
/**
|
|
244
249
|
* Create function package exclusion configuration
|
|
245
250
|
*/
|
|
246
|
-
createFunctionPackageConfig(usePrismaLayer = true) {
|
|
251
|
+
createFunctionPackageConfig(usePrismaLayer = true, appDefinition = {}) {
|
|
247
252
|
return {
|
|
248
253
|
exclude: [
|
|
249
254
|
// Exclude AWS SDK (provided by Lambda runtime)
|
|
@@ -260,8 +265,7 @@ class IntegrationBuilder extends InfrastructureBuilder {
|
|
|
260
265
|
]
|
|
261
266
|
: []),
|
|
262
267
|
|
|
263
|
-
|
|
264
|
-
'node_modules/**/node_modules/**',
|
|
268
|
+
...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
|
|
265
269
|
|
|
266
270
|
// Exclude build tools (not needed at runtime)
|
|
267
271
|
'node_modules/esbuild/**',
|
|
@@ -1032,3 +1032,33 @@ describe('IntegrationBuilder', () => {
|
|
|
1032
1032
|
});
|
|
1033
1033
|
});
|
|
1034
1034
|
|
|
1035
|
+
|
|
1036
|
+
describe('IntegrationBuilder nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
1037
|
+
const appDefinition = (lambda) => ({
|
|
1038
|
+
integrations: [{ Definition: { name: 'test', webhooks: true } }],
|
|
1039
|
+
...(lambda && { lambda }),
|
|
1040
|
+
});
|
|
1041
|
+
const packagedFunctions = (result) =>
|
|
1042
|
+
Object.values(result.functions).filter((fn) => fn.package?.exclude);
|
|
1043
|
+
|
|
1044
|
+
it('excludes every nested node_modules by default', async () => {
|
|
1045
|
+
const result = await new IntegrationBuilder().build(appDefinition(), {});
|
|
1046
|
+
|
|
1047
|
+
expect(packagedFunctions(result).length).toBeGreaterThan(0);
|
|
1048
|
+
for (const fn of packagedFunctions(result)) {
|
|
1049
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1050
|
+
}
|
|
1051
|
+
});
|
|
1052
|
+
|
|
1053
|
+
it('keeps nested node_modules when the app opts in, still excluding nested Frigg copies', async () => {
|
|
1054
|
+
const result = await new IntegrationBuilder().build(
|
|
1055
|
+
appDefinition({ keepNestedNodeModules: true }),
|
|
1056
|
+
{}
|
|
1057
|
+
);
|
|
1058
|
+
|
|
1059
|
+
for (const fn of packagedFunctions(result)) {
|
|
1060
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1061
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
@@ -24,31 +24,6 @@ const { createEmptyDiscoveryResult } = require('../shared/types/discovery-result
|
|
|
24
24
|
const { ResourceOwnership } = require('../shared/types/resource-ownership');
|
|
25
25
|
const { isSsmOffloadActive } = require('../parameters/offload-utils');
|
|
26
26
|
|
|
27
|
-
/**
|
|
28
|
-
* ADR-033: NAT-free public database connectivity.
|
|
29
|
-
*
|
|
30
|
-
* When the app opts into `database.postgres.connectivity: 'public'`, Aurora is
|
|
31
|
-
* placed in public subnets with a public endpoint and the app's Lambdas are
|
|
32
|
-
* intentionally left OUTSIDE the VPC so they keep default internet egress and
|
|
33
|
-
* need no NAT Gateway. This function is the single seam that DECOUPLES the
|
|
34
|
-
* Lambda's VPC attachment + NAT from Aurora's networking:
|
|
35
|
-
*
|
|
36
|
-
* - The VpcBuilder still builds the VPC / public subnets / DB subnet group
|
|
37
|
-
* that Aurora requires (Aurora must live in a VPC — an AWS constraint).
|
|
38
|
-
* - But it does NOT emit a NAT Gateway, and it clears `result.vpcConfig` so the
|
|
39
|
-
* composer never sets `provider.vpc` (see infrastructure-composer.js:126) —
|
|
40
|
-
* leaving the Lambda un-attached with normal egress.
|
|
41
|
-
*
|
|
42
|
-
* @param {Object} appDefinition
|
|
43
|
-
* @returns {boolean}
|
|
44
|
-
*/
|
|
45
|
-
function isPublicDatabaseConnectivity(appDefinition) {
|
|
46
|
-
return (
|
|
47
|
-
appDefinition?.database?.postgres?.enable === true &&
|
|
48
|
-
appDefinition?.database?.postgres?.connectivity === 'public'
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
27
|
class VpcBuilder extends InfrastructureBuilder {
|
|
53
28
|
constructor() {
|
|
54
29
|
super();
|
|
@@ -590,86 +565,20 @@ class VpcBuilder extends InfrastructureBuilder {
|
|
|
590
565
|
// Build Subnets based on ownership decision
|
|
591
566
|
this.buildSubnetsFromDecision(decisions.subnets, appDefinition, discoveredResources, result);
|
|
592
567
|
|
|
593
|
-
//
|
|
594
|
-
|
|
595
|
-
// the VPC — so it keeps default internet egress and needs no NAT Gateway.
|
|
596
|
-
// We still built the VPC + public subnets above (Aurora requires them), but
|
|
597
|
-
// we skip the NAT Gateway here and clear vpcConfig below so the composer
|
|
598
|
-
// leaves provider.vpc unset. This is the seam that decouples the Lambda's
|
|
599
|
-
// VPC attachment + NAT from Aurora's networking.
|
|
600
|
-
const publicDbConnectivity = isPublicDatabaseConnectivity(appDefinition);
|
|
601
|
-
|
|
602
|
-
if (publicDbConnectivity) {
|
|
603
|
-
console.log(
|
|
604
|
-
' ⊝ NAT Gateway skipped (database.postgres.connectivity=public — Lambda is not VPC-attached, so no NAT is needed)'
|
|
605
|
-
);
|
|
606
|
-
|
|
607
|
-
// ADR-033: the public subnets Aurora sits in still need an Internet
|
|
608
|
-
// Gateway default route + subnet→route-table associations to be
|
|
609
|
-
// internet-routable. Those are normally emitted only as a SIDE EFFECT
|
|
610
|
-
// of the NAT build (createPublicRouting is called from inside the NAT
|
|
611
|
-
// methods), so skipping NAT would otherwise leave the public subnets on
|
|
612
|
-
// the VPC main route table (local-only) and the public Aurora endpoint
|
|
613
|
-
// unreachable — a green deploy with a dead DB. Decouple the public-subnet
|
|
614
|
-
// routing from NAT here.
|
|
615
|
-
//
|
|
616
|
-
// GUARD: only do this for a Frigg-created (stack) VPC — signalled by the
|
|
617
|
-
// presence of FriggInternetGateway in the template (emitted by
|
|
618
|
-
// buildVpcFromDecision only for STACK ownership). createPublicRouting
|
|
619
|
-
// references { Ref: 'FriggInternetGateway' } and DependsOn
|
|
620
|
-
// 'FriggVPCGatewayAttachment', and associates the stack-created
|
|
621
|
-
// FriggPublicSubnet* — all of which exist only in that case. For a
|
|
622
|
-
// discovered/existing VPC, its public subnets already route to an IGW, so
|
|
623
|
-
// creating our own public route table would be redundant/conflicting.
|
|
624
|
-
if (result.resources.FriggInternetGateway) {
|
|
625
|
-
console.log(
|
|
626
|
-
' → Public-subnet routing (IGW default route + associations) for stack-created VPC'
|
|
627
|
-
);
|
|
628
|
-
this.createPublicRouting(appDefinition, discoveredResources, result);
|
|
629
|
-
} else {
|
|
630
|
-
console.log(
|
|
631
|
-
' ℹ Public connectivity on a discovered/existing VPC — assuming its public subnets already route to an Internet Gateway; not creating conflicting routing'
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
|
-
} else {
|
|
635
|
-
// Build NAT Gateway based on ownership decision
|
|
636
|
-
this.buildNatGatewayFromDecision(decisions.natGateway, appDefinition, discoveredResources, result);
|
|
637
|
-
}
|
|
568
|
+
// Build NAT Gateway based on ownership decision
|
|
569
|
+
this.buildNatGatewayFromDecision(decisions.natGateway, appDefinition, discoveredResources, result);
|
|
638
570
|
|
|
639
|
-
// Build VPC Endpoints based on ownership decisions
|
|
640
|
-
|
|
641
|
-
// endpoints (which give in-VPC functions private AWS access) would be
|
|
642
|
-
// wasted spend — skip them along with the NAT Gateway.
|
|
643
|
-
if (publicDbConnectivity) {
|
|
644
|
-
console.log(
|
|
645
|
-
' ⊝ VPC Endpoints skipped (database.postgres.connectivity=public — Lambda is not VPC-attached)'
|
|
646
|
-
);
|
|
647
|
-
} else {
|
|
648
|
-
this.buildVpcEndpointsFromDecisions(decisions.vpcEndpoints, decisions.securityGroup, appDefinition, discoveredResources, result);
|
|
649
|
-
}
|
|
571
|
+
// Build VPC Endpoints based on ownership decisions
|
|
572
|
+
this.buildVpcEndpointsFromDecisions(decisions.vpcEndpoints, decisions.securityGroup, appDefinition, discoveredResources, result);
|
|
650
573
|
|
|
651
|
-
// Set VPC_ENABLED environment variable
|
|
652
|
-
|
|
653
|
-
// report VPC_ENABLED=false — otherwise /health would misreport isInVpc:true.
|
|
654
|
-
result.environment.VPC_ENABLED = publicDbConnectivity ? 'false' : 'true';
|
|
574
|
+
// Set VPC_ENABLED environment variable
|
|
575
|
+
result.environment.VPC_ENABLED = 'true';
|
|
655
576
|
|
|
656
577
|
console.log(`\n[${this.name}] ✅ VPC infrastructure built successfully`);
|
|
657
578
|
console.log(` - VPC ID: ${result.vpcId || 'from discovery'}`);
|
|
658
579
|
console.log(` - Subnets: ${result.vpcConfig.subnetIds.length}`);
|
|
659
580
|
console.log(` - Security Groups: ${result.vpcConfig.securityGroupIds.length}`);
|
|
660
581
|
|
|
661
|
-
if (publicDbConnectivity) {
|
|
662
|
-
// Do NOT attach the Lambda to the VPC: leaving vpcConfig null means the
|
|
663
|
-
// composer never sets provider.vpc, so the function keeps normal
|
|
664
|
-
// internet egress. The Aurora subnets/DB subnet group built above are
|
|
665
|
-
// still emitted (AuroraBuilder consumes discoveredResources.publicSubnetId*),
|
|
666
|
-
// and the Lambda reaches Aurora over its public endpoint + TLS.
|
|
667
|
-
console.log(
|
|
668
|
-
' ⊝ Lambda VPC attachment skipped (database.postgres.connectivity=public — provider.vpc will be unset)'
|
|
669
|
-
);
|
|
670
|
-
result.vpcConfig = null;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
582
|
return result;
|
|
674
583
|
}
|
|
675
584
|
|
|
@@ -55,26 +55,10 @@
|
|
|
55
55
|
*
|
|
56
56
|
* @property {Object} [config] - Configuration preferences
|
|
57
57
|
* @property {'aurora-postgresql'|'aurora-mysql'} [config.engine] - Database engine
|
|
58
|
-
* @property {number} [config.minCapacity] - Min serverless capacity
|
|
59
|
-
*
|
|
60
|
-
* requires Aurora PostgreSQL 13.15+/14.12+/15.7+/16.3+, and the default 15.13
|
|
61
|
-
* qualifies) OR a value in [0.5, 128]. Values in (0, 0.5) are invalid. (default: 0.5)
|
|
62
|
-
* @property {number} [config.maxCapacity] - Max serverless capacity in ACU, range
|
|
63
|
-
* [0.5, 128] (default: 4)
|
|
64
|
-
* @property {number} [config.secondsUntilAutoPause] - Idle window before a
|
|
65
|
-
* scale-to-zero cluster (minCapacity: 0) pauses to 0 ACU. Integer seconds in
|
|
66
|
-
* [300, 86400]. Only applied when minCapacity === 0 (default: 300)
|
|
58
|
+
* @property {number} [config.minCapacity] - Min serverless capacity (default: 0.5)
|
|
59
|
+
* @property {number} [config.maxCapacity] - Max serverless capacity (default: 1)
|
|
67
60
|
* @property {string} [config.database] - Database name (default: 'frigg')
|
|
68
61
|
* @property {boolean} [config.publiclyAccessible] - Public access (default: false)
|
|
69
|
-
* @property {'vpc'|'public'} [config.connectivity] - Lambda↔Aurora connectivity
|
|
70
|
-
* mode. `'vpc'` (default): Aurora in private subnets, Lambda attached to the VPC,
|
|
71
|
-
* ingress from the Lambda security group (needs a NAT for external egress).
|
|
72
|
-
* `'public'` (NAT-free): Aurora in public subnets with a public endpoint, Lambda
|
|
73
|
-
* left OUTSIDE the VPC (no NAT Gateway, no VPC endpoints), ingress opened to
|
|
74
|
-
* `allowedCidrs`, TLS enforced (sslmode=require). (default: 'vpc')
|
|
75
|
-
* @property {string[]} [config.allowedCidrs] - CIDR blocks allowed to reach Aurora
|
|
76
|
-
* on 5432 when connectivity is 'public'. One ingress rule is emitted per CIDR.
|
|
77
|
-
* (default: ['0.0.0.0/0'] — narrow this for production)
|
|
78
62
|
* @property {boolean} [config.autoCreateCredentials] - Auto-create credentials in Secrets Manager
|
|
79
63
|
*/
|
|
80
64
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const { buildEnvironment } = require('../environment-builder');
|
|
11
|
+
const { nestedNodeModulesExcludes } = require('./nested-node-modules');
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Create base serverless definition with core functions and resources
|
|
@@ -64,8 +65,7 @@ function createBaseDefinition(
|
|
|
64
65
|
'node_modules/prettier/**',
|
|
65
66
|
'node_modules/eslint/**',
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
'node_modules/**/node_modules/**',
|
|
68
|
+
...nestedNodeModulesExcludes(AppDefinition, usePrismaLayer),
|
|
69
69
|
|
|
70
70
|
// Exclude build tools (not needed at runtime)
|
|
71
71
|
'node_modules/esbuild/**',
|
|
@@ -289,3 +289,31 @@ describe('Base Definition Factory', () => {
|
|
|
289
289
|
});
|
|
290
290
|
});
|
|
291
291
|
|
|
292
|
+
|
|
293
|
+
describe('nested node_modules (lambda.keepNestedNodeModules)', () => {
|
|
294
|
+
const build = (appDefinition) => createBaseDefinition(appDefinition, {}, {}, true);
|
|
295
|
+
|
|
296
|
+
it('excludes every nested node_modules from the core function packages by default', () => {
|
|
297
|
+
const result = build({ name: 'test-app' });
|
|
298
|
+
|
|
299
|
+
for (const fn of ['auth', 'user', 'health']) {
|
|
300
|
+
expect(result.functions[fn].package.exclude).toContain('node_modules/**/node_modules/**');
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('keeps nested node_modules when the app opts in, still excluding nested Frigg, AWS SDK and Prisma copies', () => {
|
|
305
|
+
const result = build({ name: 'test-app', lambda: { keepNestedNodeModules: true } });
|
|
306
|
+
|
|
307
|
+
for (const fn of ['auth', 'user', 'health']) {
|
|
308
|
+
const { exclude } = result.functions[fn].package;
|
|
309
|
+
expect(exclude).not.toContain('node_modules/**/node_modules/**');
|
|
310
|
+
expect(exclude).toEqual(
|
|
311
|
+
expect.arrayContaining([
|
|
312
|
+
'node_modules/**/node_modules/@friggframework/**',
|
|
313
|
+
'node_modules/**/node_modules/@aws-sdk/**',
|
|
314
|
+
'node_modules/**/node_modules/@prisma/**',
|
|
315
|
+
])
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nested node_modules packaging patterns
|
|
3
|
+
*
|
|
4
|
+
* Utility Layer - Hexagonal Architecture
|
|
5
|
+
*
|
|
6
|
+
* npm nests a package only when the root copy cannot satisfy the dependant's
|
|
7
|
+
* range. Excluding every nested node_modules from a Lambda package therefore
|
|
8
|
+
* rewires module resolution to whatever is hoisted, and drops a package
|
|
9
|
+
* outright when the root copy is dev-only. Apps opt in to shipping the tree
|
|
10
|
+
* the way npm resolved it with `lambda.keepNestedNodeModules: true`. Nested
|
|
11
|
+
* copies of Frigg packages, the AWS SDK and Prisma stay excluded because the
|
|
12
|
+
* app's single core, the Lambda runtime and the Prisma layer provide them.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const ALL_NESTED_NODE_MODULES = 'node_modules/**/node_modules/**';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {Object} appDefinition
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
21
|
+
function keepsNestedNodeModules(appDefinition = {}) {
|
|
22
|
+
return appDefinition.lambda?.keepNestedNodeModules === true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Package exclude patterns for nested node_modules directories.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} appDefinition
|
|
29
|
+
* @param {boolean} usePrismaLayer - Whether Prisma ships via the Lambda Layer
|
|
30
|
+
* @returns {string[]}
|
|
31
|
+
*/
|
|
32
|
+
function nestedNodeModulesExcludes(appDefinition, usePrismaLayer = true) {
|
|
33
|
+
if (!keepsNestedNodeModules(appDefinition)) {
|
|
34
|
+
return [ALL_NESTED_NODE_MODULES];
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
'node_modules/**/node_modules/@friggframework/**',
|
|
38
|
+
'node_modules/**/node_modules/aws-sdk/**',
|
|
39
|
+
'node_modules/**/node_modules/@aws-sdk/**',
|
|
40
|
+
...(usePrismaLayer
|
|
41
|
+
? [
|
|
42
|
+
'node_modules/**/node_modules/@prisma/**',
|
|
43
|
+
'node_modules/**/node_modules/.prisma/**',
|
|
44
|
+
]
|
|
45
|
+
: []),
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
ALL_NESTED_NODE_MODULES,
|
|
51
|
+
keepsNestedNodeModules,
|
|
52
|
+
nestedNodeModulesExcludes,
|
|
53
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for nested node_modules packaging patterns
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
ALL_NESTED_NODE_MODULES,
|
|
7
|
+
keepsNestedNodeModules,
|
|
8
|
+
nestedNodeModulesExcludes,
|
|
9
|
+
} = require('./nested-node-modules');
|
|
10
|
+
|
|
11
|
+
describe('nestedNodeModulesExcludes', () => {
|
|
12
|
+
it('excludes every nested node_modules by default', () => {
|
|
13
|
+
expect(nestedNodeModulesExcludes({}, true)).toEqual([
|
|
14
|
+
'node_modules/**/node_modules/**',
|
|
15
|
+
]);
|
|
16
|
+
expect(ALL_NESTED_NODE_MODULES).toBe('node_modules/**/node_modules/**');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('keeps nested node_modules when the app opts in, except Frigg, AWS SDK and Prisma copies', () => {
|
|
20
|
+
const appDefinition = { lambda: { keepNestedNodeModules: true } };
|
|
21
|
+
|
|
22
|
+
const excludes = nestedNodeModulesExcludes(appDefinition, true);
|
|
23
|
+
|
|
24
|
+
expect(excludes).not.toContain('node_modules/**/node_modules/**');
|
|
25
|
+
expect(excludes).toEqual([
|
|
26
|
+
'node_modules/**/node_modules/@friggframework/**',
|
|
27
|
+
'node_modules/**/node_modules/aws-sdk/**',
|
|
28
|
+
'node_modules/**/node_modules/@aws-sdk/**',
|
|
29
|
+
'node_modules/**/node_modules/@prisma/**',
|
|
30
|
+
'node_modules/**/node_modules/.prisma/**',
|
|
31
|
+
]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('keeps nested Prisma copies when the app bundles Prisma instead of using the layer', () => {
|
|
35
|
+
const appDefinition = { lambda: { keepNestedNodeModules: true } };
|
|
36
|
+
|
|
37
|
+
const excludes = nestedNodeModulesExcludes(appDefinition, false);
|
|
38
|
+
|
|
39
|
+
expect(excludes).toEqual([
|
|
40
|
+
'node_modules/**/node_modules/@friggframework/**',
|
|
41
|
+
'node_modules/**/node_modules/aws-sdk/**',
|
|
42
|
+
'node_modules/**/node_modules/@aws-sdk/**',
|
|
43
|
+
]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('keepsNestedNodeModules', () => {
|
|
48
|
+
it('is only enabled by the boolean true', () => {
|
|
49
|
+
expect(
|
|
50
|
+
keepsNestedNodeModules({ lambda: { keepNestedNodeModules: true } })
|
|
51
|
+
).toBe(true);
|
|
52
|
+
expect(
|
|
53
|
+
keepsNestedNodeModules({
|
|
54
|
+
lambda: { keepNestedNodeModules: 'true' },
|
|
55
|
+
})
|
|
56
|
+
).toBe(false);
|
|
57
|
+
expect(keepsNestedNodeModules({ lambda: {} })).toBe(false);
|
|
58
|
+
expect(keepsNestedNodeModules({})).toBe(false);
|
|
59
|
+
expect(keepsNestedNodeModules()).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
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.636.7dc8dca.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.636.7dc8dca.0",
|
|
30
|
+
"@friggframework/schemas": "2.0.0--canary.636.7dc8dca.0",
|
|
31
|
+
"@friggframework/test": "2.0.0--canary.636.7dc8dca.0",
|
|
32
32
|
"@hapi/boom": "^10.0.1",
|
|
33
33
|
"@inquirer/prompts": "^5.3.8",
|
|
34
34
|
"axios": "^1.18.0",
|
|
@@ -56,8 +56,8 @@
|
|
|
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.636.7dc8dca.0",
|
|
60
|
+
"@friggframework/prettier-config": "2.0.0--canary.636.7dc8dca.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",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "7dc8dca491feccbc4bc9933b971ac8044155efb3"
|
|
93
93
|
}
|