@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.
- package/README.md +0 -1
- package/frigg-cli/README.md +31 -123
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
- package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
- package/frigg-cli/build-command/index.js +0 -6
- package/frigg-cli/deploy-command/index.js +0 -6
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +5 -28
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +551 -395
- package/frigg-cli/init-command/index.js +35 -82
- package/frigg-cli/install-command/commit-changes.js +8 -40
- package/frigg-cli/install-command/environment-variables.js +0 -15
- package/frigg-cli/install-command/index.js +21 -96
- package/frigg-cli/install-command/install-package.js +4 -77
- package/frigg-cli/install-command/integration-file.js +11 -20
- package/frigg-cli/install-command/template.js +75 -102
- package/frigg-cli/install-command/validate-package.js +4 -36
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +0 -4
- package/frigg-cli/start-command/start-command.test.js +0 -3
- package/frigg-cli/test/init-command.test.js +2 -9
- package/infrastructure/__tests__/postgres-config.test.js +835 -241
- package/infrastructure/__tests__/template-generation.test.js +8 -36
- package/infrastructure/create-frigg-infrastructure.js +1 -4
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
- package/infrastructure/domains/database/aurora-builder.js +2 -13
- package/infrastructure/domains/database/aurora-builder.test.js +0 -22
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
- package/infrastructure/domains/networking/vpc-builder.js +8 -18
- package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
- package/infrastructure/domains/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -26
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -34
- package/infrastructure/infrastructure-composer.test.js +794 -268
- package/infrastructure/integration.test.js +381 -0
- package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
- package/infrastructure/scripts/build-time-discovery.test.js +3 -18
- package/package.json +8 -10
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
- package/frigg-cli/init-command/deployment-modes.js +0 -7
- package/frigg-cli/init-command/safe-path.js +0 -58
- package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
- package/frigg-cli/install-command/app-definition.js +0 -174
- package/frigg-cli/install-command/resolve-module.js +0 -69
- package/frigg-cli/templates/backend/README.md +0 -267
- package/frigg-cli/templates/backend/env.example +0 -20
- package/frigg-cli/templates/backend/gitignore +0 -10
- package/frigg-cli/templates/backend/index.js +0 -114
- package/frigg-cli/templates/backend/infrastructure.js +0 -20
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
- package/frigg-cli/validate-command/checks/config.js +0 -504
- package/frigg-cli/validate-command/checks/integrations.js +0 -274
- package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
- package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
- package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
- package/frigg-cli/validate-command/format-report.js +0 -60
- package/frigg-cli/validate-command/index.js +0 -151
- package/frigg-cli/validate-command/load-app-definition.js +0 -105
- package/frigg-cli/validate-command/load-module-definition.js +0 -64
- package/frigg-cli/validate-command/schema-issues.js +0 -154
- package/frigg-cli/validate-command/validate-app-definition.js +0 -60
- package/frigg-cli/validate-command/validate-module-definition.js +0 -46
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -281
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
- package/infrastructure/app-definition-schema-contract.test.js +0 -629
- 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
|
-
});
|