@friggframework/devtools 2.0.0--canary.701.32f702a.0 → 2.0.0--canary.662.6d3931c.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +0 -1
  2. package/frigg-cli/README.md +31 -123
  3. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
  4. package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
  5. package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
  6. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
  7. package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
  8. package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
  9. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
  10. package/frigg-cli/build-command/index.js +0 -6
  11. package/frigg-cli/deploy-command/index.js +0 -6
  12. package/frigg-cli/generate-command/index.js +0 -1
  13. package/frigg-cli/generate-iam-command.js +0 -1
  14. package/frigg-cli/index.js +5 -28
  15. package/frigg-cli/index.test.js +158 -0
  16. package/frigg-cli/init-command/backend-first-handler.js +551 -395
  17. package/frigg-cli/init-command/index.js +35 -82
  18. package/frigg-cli/install-command/commit-changes.js +8 -40
  19. package/frigg-cli/install-command/environment-variables.js +0 -15
  20. package/frigg-cli/install-command/index.js +21 -96
  21. package/frigg-cli/install-command/install-package.js +4 -77
  22. package/frigg-cli/install-command/integration-file.js +11 -20
  23. package/frigg-cli/install-command/template.js +75 -102
  24. package/frigg-cli/install-command/validate-package.js +4 -36
  25. package/frigg-cli/package.json +1 -1
  26. package/frigg-cli/start-command/index.js +0 -4
  27. package/frigg-cli/start-command/start-command.test.js +0 -3
  28. package/frigg-cli/test/init-command.test.js +2 -9
  29. package/infrastructure/__tests__/postgres-config.test.js +835 -241
  30. package/infrastructure/__tests__/template-generation.test.js +8 -36
  31. package/infrastructure/create-frigg-infrastructure.js +1 -4
  32. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
  33. package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
  34. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
  35. package/infrastructure/domains/database/aurora-builder.js +2 -13
  36. package/infrastructure/domains/database/aurora-builder.test.js +0 -22
  37. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
  38. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
  39. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
  40. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
  41. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
  42. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
  43. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
  44. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
  45. package/infrastructure/domains/networking/vpc-builder.js +8 -18
  46. package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
  47. package/infrastructure/domains/security/iam-generator.js +5 -112
  48. package/infrastructure/domains/security/iam-generator.test.js +0 -94
  49. package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
  50. package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -26
  51. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -34
  52. package/infrastructure/infrastructure-composer.test.js +794 -268
  53. package/infrastructure/integration.test.js +381 -0
  54. package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
  55. package/infrastructure/scripts/build-time-discovery.test.js +3 -18
  56. package/package.json +8 -10
  57. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
  58. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
  59. package/frigg-cli/init-command/deployment-modes.js +0 -7
  60. package/frigg-cli/init-command/safe-path.js +0 -58
  61. package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
  62. package/frigg-cli/install-command/app-definition.js +0 -174
  63. package/frigg-cli/install-command/resolve-module.js +0 -69
  64. package/frigg-cli/templates/backend/README.md +0 -267
  65. package/frigg-cli/templates/backend/env.example +0 -20
  66. package/frigg-cli/templates/backend/gitignore +0 -10
  67. package/frigg-cli/templates/backend/index.js +0 -114
  68. package/frigg-cli/templates/backend/infrastructure.js +0 -20
  69. package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
  70. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
  71. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
  72. package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
  73. package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
  74. package/frigg-cli/validate-command/checks/config.js +0 -504
  75. package/frigg-cli/validate-command/checks/integrations.js +0 -274
  76. package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
  77. package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
  78. package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
  79. package/frigg-cli/validate-command/format-report.js +0 -60
  80. package/frigg-cli/validate-command/index.js +0 -151
  81. package/frigg-cli/validate-command/load-app-definition.js +0 -105
  82. package/frigg-cli/validate-command/load-module-definition.js +0 -64
  83. package/frigg-cli/validate-command/schema-issues.js +0 -154
  84. package/frigg-cli/validate-command/validate-app-definition.js +0 -60
  85. package/frigg-cli/validate-command/validate-module-definition.js +0 -46
  86. package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -281
  87. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
  88. package/infrastructure/app-definition-schema-contract.test.js +0 -629
  89. package/infrastructure/create-frigg-infrastructure.test.js +0 -51
@@ -1,148 +0,0 @@
1
- /**
2
- * The app scaffolded by `frigg init` must deploy with no always-on AWS cost.
3
- *
4
- * Scaffolds the backend template, loads its Definition and composes it the way
5
- * `frigg deploy` does (AWS discovery stubbed), then asserts the template has
6
- * no VPC, NAT gateway, Elastic IP, VPC endpoint or RDS/Aurora resource, that
7
- * no Lambda is attached to a VPC, and that field-level encryption still gets
8
- * its KMS key.
9
- */
10
-
11
- const os = require('os');
12
- const path = require('path');
13
- const fs = require('fs-extra');
14
-
15
- jest.mock('../domains/shared/resource-discovery', () => ({
16
- ...jest.requireActual('../domains/shared/resource-discovery'),
17
- gatherDiscoveredResources: jest.fn(),
18
- }));
19
- jest.mock('../domains/shared/utilities/prisma-layer-manager', () => ({
20
- ensurePrismaLayerExists: jest.fn().mockResolvedValue(undefined),
21
- }));
22
-
23
- const {
24
- gatherDiscoveredResources,
25
- } = require('../domains/shared/resource-discovery');
26
- const { composeServerlessDefinition } = require('../infrastructure-composer');
27
- const BackendFirstHandler = require('../../frigg-cli/init-command/backend-first-handler');
28
-
29
- const FORBIDDEN_RESOURCE_TYPES = [
30
- 'AWS::EC2::VPC',
31
- 'AWS::EC2::NatGateway',
32
- 'AWS::EC2::EIP',
33
- 'AWS::EC2::VPCEndpoint',
34
- 'AWS::RDS::DBCluster',
35
- 'AWS::RDS::DBInstance',
36
- 'AWS::RDS::DBSubnetGroup',
37
- ];
38
-
39
- // An account that already holds a default VPC, subnets, a NAT gateway and an
40
- // Aurora cluster: none of it may leak into the scaffolded app's template.
41
- const BUSY_ACCOUNT_DISCOVERY = {
42
- defaultVpcId: 'vpc-123456',
43
- vpcCidr: '172.31.0.0/16',
44
- defaultSecurityGroupId: 'sg-123456',
45
- privateSubnetId1: 'subnet-123456',
46
- privateSubnetId2: 'subnet-789012',
47
- publicSubnetId1: 'subnet-public-1',
48
- publicSubnetId2: 'subnet-public-2',
49
- defaultRouteTableId: 'rtb-123456',
50
- existingNatGatewayId: 'nat-default123',
51
- auroraClusterEndpoint: 'c.cluster-abc123.us-east-1.rds.amazonaws.com',
52
- auroraPort: 5432,
53
- auroraEngine: 'aurora-postgresql',
54
- };
55
-
56
- describe('frigg init default infrastructure', () => {
57
- let tmpDir;
58
- let Definition;
59
- let logSpy;
60
-
61
- beforeAll(async () => {
62
- logSpy = jest.spyOn(console, 'log').mockImplementation();
63
- tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-default-infra-'));
64
- const target = path.join(tmpDir, 'demo-app');
65
- await new BackendFirstHandler(target, {
66
- yes: true,
67
- install: false,
68
- git: false,
69
- }).initialize();
70
- ({ Definition } = require(path.join(target, 'index.js')));
71
- });
72
-
73
- afterAll(() => {
74
- fs.removeSync(tmpDir);
75
- logSpy.mockRestore();
76
- });
77
-
78
- beforeEach(() => {
79
- delete process.env.FRIGG_SKIP_AWS_DISCOVERY;
80
- process.argv = ['node', 'test'];
81
- });
82
-
83
- const compose = async (discovery) => {
84
- gatherDiscoveredResources.mockResolvedValue(discovery);
85
- // The composer mutates nested parts of the definition.
86
- return composeServerlessDefinition(
87
- JSON.parse(JSON.stringify(Definition))
88
- );
89
- };
90
-
91
- const resourceTypes = (definition) =>
92
- Object.values(definition.resources.Resources).map((r) => r.Type);
93
-
94
- it('passes the app-definition schema', () => {
95
- const { validateAppDefinition } = require('@friggframework/schemas');
96
- expect(validateAppDefinition(Definition).valid).toBe(true);
97
- });
98
-
99
- it.each([
100
- ['an empty account', {}],
101
- ['an account with existing VPC/NAT/Aurora', BUSY_ACCOUNT_DISCOVERY],
102
- ])('composes no always-on resources in %s', async (_label, discovery) => {
103
- const definition = await compose(discovery);
104
- const types = resourceTypes(definition);
105
-
106
- for (const forbidden of FORBIDDEN_RESOURCE_TYPES) {
107
- expect(types).not.toContain(forbidden);
108
- }
109
-
110
- // No Lambda is attached to a VPC.
111
- expect(definition.provider.vpc).toBeUndefined();
112
- for (const fn of Object.values(definition.functions)) {
113
- expect(fn.vpc).toBeUndefined();
114
- }
115
- for (const resource of Object.values(definition.resources.Resources)) {
116
- expect(resource.Properties?.VpcConfig).toBeUndefined();
117
- }
118
- });
119
-
120
- it('keeps field-level encryption on with a per-stage KMS key', async () => {
121
- const definition = await compose({});
122
-
123
- expect(definition.resources.Resources.FriggKMSKey.Type).toBe(
124
- 'AWS::KMS::Key'
125
- );
126
- expect(definition.provider.environment.KMS_KEY_ARN).toEqual({
127
- 'Fn::GetAtt': ['FriggKMSKey', 'Arn'],
128
- });
129
- });
130
-
131
- it('connects to the external database through DATABASE_URL', async () => {
132
- const definition = await compose({});
133
-
134
- expect(definition.provider.environment.DATABASE_URL).toBe(
135
- "${env:DATABASE_URL, ''}"
136
- );
137
- expect(definition.provider.environment.DB_TYPE).toBe('postgresql');
138
- expect(definition.resources.Resources.FriggDBSecret).toBeUndefined();
139
- });
140
-
141
- it('expires Lambda logs after 14 days', async () => {
142
- // Without provider.logRetentionInDays, osls creates log groups that
143
- // never expire, so CloudWatch storage grows forever.
144
- const definition = await compose({});
145
-
146
- expect(definition.provider.logRetentionInDays).toBe(14);
147
- });
148
- });