@friggframework/devtools 2.0.0--canary.704.6a606c3.0 → 2.0.0--canary.707.2702ff3.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 -14
- package/frigg-cli/README.md +30 -83
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -594
- package/frigg-cli/__tests__/unit/commands/provider-dispatch.test.js +140 -0
- package/frigg-cli/__tests__/unit/dependencies.test.js +5 -3
- package/frigg-cli/build-command/index.js +32 -1
- package/frigg-cli/db-setup-command/index.js +25 -0
- package/frigg-cli/deploy-command/index.js +50 -2
- package/frigg-cli/doctor-command/index.js +7 -0
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +7 -1
- package/frigg-cli/index.js +4 -12
- package/frigg-cli/init-command/backend-first-handler.js +554 -397
- 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 +3 -3
- package/frigg-cli/repair-command/index.js +7 -0
- package/frigg-cli/start-command/index.js +58 -0
- package/frigg-cli/test/init-command.test.js +2 -9
- package/frigg-cli/utils/provider-helper.js +80 -0
- package/infrastructure/README.md +4 -22
- package/infrastructure/__tests__/compose-extension-prisma.test.js +168 -0
- package/infrastructure/__tests__/create-frigg-infrastructure-provider.test.js +64 -0
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +335 -0
- package/infrastructure/__tests__/template-generation.test.js +7 -0
- package/infrastructure/compose-extension-prisma.js +73 -0
- package/infrastructure/create-frigg-infrastructure.js +14 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +48 -56
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -76
- package/infrastructure/domains/database/aurora-builder.js +2 -13
- package/infrastructure/domains/database/aurora-builder.test.js +0 -22
- package/infrastructure/domains/database/migration-builder.js +175 -182
- package/infrastructure/domains/database/migration-builder.test.js +5 -36
- package/infrastructure/domains/integration/integration-builder.js +61 -65
- package/infrastructure/domains/integration/integration-builder.test.js +8 -73
- package/infrastructure/domains/parameters/offload-utils.js +1 -0
- package/infrastructure/domains/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/environment-builder.js +12 -1
- package/infrastructure/domains/shared/environment-builder.test.js +20 -0
- package/infrastructure/domains/shared/types/app-definition.js +15 -1
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +152 -93
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +111 -117
- package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
- package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
- package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +10 -0
- package/infrastructure/infrastructure-composer.js +13 -1
- package/infrastructure/infrastructure-composer.test.js +10 -3
- package/infrastructure/provider-build.js +126 -0
- package/infrastructure/scripts/build-prisma-layer.js +32 -5
- package/infrastructure/scripts/build-prisma-layer.test.js +35 -0
- package/package.json +8 -13
- package/test/npm-install-guard.js +104 -0
- package/test/npm-install-guard.test.js +53 -0
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- package/frigg-cli/__tests__/unit/utils/node-version.test.js +0 -66
- 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/utils/node-version.js +0 -51
- package/infrastructure/__tests__/package-patterns-composition.test.js +0 -153
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
- package/infrastructure/domains/shared/utilities/framework-version.js +0 -14
- package/infrastructure/domains/shared/utilities/framework-version.test.js +0 -27
- package/infrastructure/domains/shared/utilities/package-patterns.js +0 -35
- package/infrastructure/domains/shared/utilities/package-patterns.test.js +0 -112
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
const { InfrastructureBuilder, ValidationResult } = require('../shared/base-builder');
|
|
17
17
|
const { isScopedEnvironmentActive } = require('../shared/function-environments');
|
|
18
18
|
const { nestedNodeModulesExcludes } = require('../shared/utilities/nested-node-modules');
|
|
19
|
-
const { toPackagePatterns } = require('../shared/utilities/package-patterns');
|
|
20
19
|
|
|
21
20
|
class AdminScriptBuilder extends InfrastructureBuilder {
|
|
22
21
|
constructor() {
|
|
@@ -142,12 +141,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
createAdminScriptQueue(result, appDefinition) {
|
|
145
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
146
|
-
result.custom.AdminScriptQueue = '${self:service}-${self:provider.stage}-AdminScriptQueue';
|
|
147
144
|
result.resources.AdminScriptQueue = {
|
|
148
145
|
Type: 'AWS::SQS::Queue',
|
|
149
146
|
Properties: {
|
|
150
|
-
QueueName: '${self:
|
|
147
|
+
QueueName: '${self:service}-${self:provider.stage}-AdminScriptQueue',
|
|
151
148
|
MessageRetentionPeriod: 86400, // 1 day
|
|
152
149
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
153
150
|
RedrivePolicy: {
|
|
@@ -267,12 +264,10 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
267
264
|
}
|
|
268
265
|
|
|
269
266
|
createReportQueue(result, appDefinition) {
|
|
270
|
-
// Registered under custom so the serverless plugin creates it in LocalStack offline
|
|
271
|
-
result.custom.ReportQueue = '${self:service}-${self:provider.stage}-ReportQueue';
|
|
272
267
|
result.resources.ReportQueue = {
|
|
273
268
|
Type: 'AWS::SQS::Queue',
|
|
274
269
|
Properties: {
|
|
275
|
-
QueueName: '${self:
|
|
270
|
+
QueueName: '${self:service}-${self:provider.stage}-ReportQueue',
|
|
276
271
|
MessageRetentionPeriod: 86400, // 1 day
|
|
277
272
|
VisibilityTimeout: 900, // 15 minutes (Lambda max)
|
|
278
273
|
RedrivePolicy: {
|
|
@@ -398,55 +393,52 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
398
393
|
skipEsbuildPackageConfig(appDefinition, usePrismaLayer) {
|
|
399
394
|
const tlsCAFile = appDefinition?.database?.documentDB?.tlsCAFile;
|
|
400
395
|
return {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
'**/*.spec.js',
|
|
448
|
-
],
|
|
449
|
-
}),
|
|
396
|
+
include: [
|
|
397
|
+
// Handlers connect to the DB, so ship the DocumentDB CA cert.
|
|
398
|
+
...(tlsCAFile ? [tlsCAFile.replace(/^\.\//, '')] : []),
|
|
399
|
+
],
|
|
400
|
+
exclude: [
|
|
401
|
+
'node_modules/aws-sdk/**',
|
|
402
|
+
'node_modules/@aws-sdk/**',
|
|
403
|
+
...(usePrismaLayer
|
|
404
|
+
? [
|
|
405
|
+
'node_modules/@prisma/**',
|
|
406
|
+
'node_modules/.prisma/**',
|
|
407
|
+
'node_modules/prisma/**',
|
|
408
|
+
'node_modules/@friggframework/core/generated/**',
|
|
409
|
+
]
|
|
410
|
+
: []),
|
|
411
|
+
...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
|
|
412
|
+
'node_modules/@friggframework/test/**',
|
|
413
|
+
'node_modules/@friggframework/eslint-config/**',
|
|
414
|
+
'node_modules/@friggframework/prettier-config/**',
|
|
415
|
+
'node_modules/jest/**',
|
|
416
|
+
'node_modules/prettier/**',
|
|
417
|
+
'node_modules/eslint/**',
|
|
418
|
+
'node_modules/esbuild/**',
|
|
419
|
+
'node_modules/@esbuild/**',
|
|
420
|
+
'node_modules/typescript/**',
|
|
421
|
+
'node_modules/webpack/**',
|
|
422
|
+
'node_modules/osls/**',
|
|
423
|
+
'node_modules/serverless-esbuild/**',
|
|
424
|
+
'node_modules/serverless-jetpack/**',
|
|
425
|
+
'node_modules/serverless-offline/**',
|
|
426
|
+
'node_modules/serverless-offline-sqs/**',
|
|
427
|
+
'node_modules/serverless-dotenv-plugin/**',
|
|
428
|
+
'node_modules/serverless-kms-grants/**',
|
|
429
|
+
// Never deploy secrets or the lockfile.
|
|
430
|
+
'.env',
|
|
431
|
+
'.env.*',
|
|
432
|
+
'**/.env',
|
|
433
|
+
'**/.env.*',
|
|
434
|
+
'.frigg-credentials.json',
|
|
435
|
+
'package-lock.json',
|
|
436
|
+
'test/**',
|
|
437
|
+
'layers/**',
|
|
438
|
+
'coverage/**',
|
|
439
|
+
'**/*.test.js',
|
|
440
|
+
'**/*.spec.js',
|
|
441
|
+
],
|
|
450
442
|
};
|
|
451
443
|
}
|
|
452
444
|
|
|
@@ -168,21 +168,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
168
168
|
expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
|
|
172
|
-
const appDefinition = {
|
|
173
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
177
|
-
|
|
178
|
-
expect(result.custom.AdminScriptQueue).toBe(
|
|
179
|
-
'${self:service}-${self:provider.stage}-AdminScriptQueue'
|
|
180
|
-
);
|
|
181
|
-
expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
|
|
182
|
-
'${self:custom.AdminScriptQueue}'
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
171
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
187
172
|
const appDefinition = {
|
|
188
173
|
adminScripts: [
|
|
@@ -285,11 +270,11 @@ describe('AdminScriptBuilder', () => {
|
|
|
285
270
|
result.functions.adminScriptExecutor,
|
|
286
271
|
result.functions.adminScriptRouter,
|
|
287
272
|
]) {
|
|
288
|
-
expect(fn.package.
|
|
273
|
+
expect(fn.package.exclude).toEqual(
|
|
289
274
|
expect.arrayContaining([
|
|
290
|
-
'
|
|
291
|
-
'
|
|
292
|
-
'
|
|
275
|
+
'node_modules/aws-sdk/**',
|
|
276
|
+
'node_modules/@aws-sdk/**',
|
|
277
|
+
'node_modules/@prisma/**',
|
|
293
278
|
])
|
|
294
279
|
);
|
|
295
280
|
}
|
|
@@ -636,21 +621,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
636
621
|
});
|
|
637
622
|
|
|
638
623
|
describe('reports (ReportQueue + reportExecutor)', () => {
|
|
639
|
-
it('registers ReportQueue under custom so frigg start creates it locally', async () => {
|
|
640
|
-
const appDefinition = {
|
|
641
|
-
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
645
|
-
|
|
646
|
-
expect(result.custom.ReportQueue).toBe(
|
|
647
|
-
'${self:service}-${self:provider.stage}-ReportQueue'
|
|
648
|
-
);
|
|
649
|
-
expect(result.resources.ReportQueue.Properties.QueueName).toBe(
|
|
650
|
-
'${self:custom.ReportQueue}'
|
|
651
|
-
);
|
|
652
|
-
});
|
|
653
|
-
|
|
654
624
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
655
625
|
const appDefinition = {
|
|
656
626
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
@@ -1029,7 +999,7 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1029
999
|
const result = await new AdminScriptBuilder().build(appDefinition(), {});
|
|
1030
1000
|
|
|
1031
1001
|
for (const fn of executorAndRouter(result)) {
|
|
1032
|
-
expect(fn.package.
|
|
1002
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1033
1003
|
}
|
|
1034
1004
|
});
|
|
1035
1005
|
|
|
@@ -1040,47 +1010,8 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1040
1010
|
);
|
|
1041
1011
|
|
|
1042
1012
|
for (const fn of executorAndRouter(result)) {
|
|
1043
|
-
expect(fn.package.
|
|
1044
|
-
expect(fn.package.
|
|
1013
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1014
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1045
1015
|
}
|
|
1046
1016
|
});
|
|
1047
1017
|
});
|
|
1048
|
-
|
|
1049
|
-
describe('AdminScriptBuilder function package patterns (ADR-050)', () => {
|
|
1050
|
-
it('emits package.patterns, never include/exclude, on every skipEsbuild function', async () => {
|
|
1051
|
-
const result = await new AdminScriptBuilder().build(
|
|
1052
|
-
{
|
|
1053
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
1054
|
-
reports: [{ Definition: { name: 'test-report' } }],
|
|
1055
|
-
},
|
|
1056
|
-
{}
|
|
1057
|
-
);
|
|
1058
|
-
|
|
1059
|
-
const packaged = Object.entries(result.functions).filter(([, fn]) => fn.package);
|
|
1060
|
-
expect(packaged.map(([name]) => name)).toEqual(
|
|
1061
|
-
expect.arrayContaining(['adminScriptExecutor', 'adminScriptRouter'])
|
|
1062
|
-
);
|
|
1063
|
-
for (const [, fn] of packaged) {
|
|
1064
|
-
expect(fn.package).not.toHaveProperty('include');
|
|
1065
|
-
expect(fn.package).not.toHaveProperty('exclude');
|
|
1066
|
-
expect(fn.package.patterns.every((p) => p.startsWith('!'))).toBe(true);
|
|
1067
|
-
expect(fn.package.patterns).toEqual(
|
|
1068
|
-
expect.arrayContaining(['!node_modules/aws-sdk/**', '!.env', '!test/**'])
|
|
1069
|
-
);
|
|
1070
|
-
}
|
|
1071
|
-
});
|
|
1072
|
-
|
|
1073
|
-
it('re-adds the DocumentDB CA file after every exclude', async () => {
|
|
1074
|
-
const result = await new AdminScriptBuilder().build(
|
|
1075
|
-
{
|
|
1076
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
1077
|
-
database: { documentDB: { tlsCAFile: './global-bundle.pem' } },
|
|
1078
|
-
},
|
|
1079
|
-
{}
|
|
1080
|
-
);
|
|
1081
|
-
|
|
1082
|
-
const { patterns } = result.functions.adminScriptExecutor.package;
|
|
1083
|
-
expect(patterns[patterns.length - 1]).toBe('global-bundle.pem');
|
|
1084
|
-
expect(patterns.slice(0, -1).every((p) => p.startsWith('!'))).toBe(true);
|
|
1085
|
-
});
|
|
1086
|
-
});
|
|
@@ -64,18 +64,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// management='external': the app brings its own PostgreSQL (any
|
|
70
|
-
// provider) and connects through DATABASE_URL. Frigg creates and
|
|
71
|
-
// discovers no database resources and needs no VPC for it. This
|
|
72
|
-
// check precedes managementMode, which otherwise always manages
|
|
73
|
-
// Aurora. Migrations still run (MigrationBuilder) against DATABASE_URL.
|
|
74
|
-
if (postgres?.management === 'external') {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return postgres?.enable === true;
|
|
67
|
+
return appDefinition.database?.postgres?.enable === true;
|
|
79
68
|
}
|
|
80
69
|
|
|
81
70
|
getDependencies() {
|
|
@@ -93,7 +82,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
93
82
|
const dbConfig = appDefinition.database.postgres;
|
|
94
83
|
|
|
95
84
|
// Validate management mode
|
|
96
|
-
const validModes = ['discover', 'managed', 'use-existing'
|
|
85
|
+
const validModes = ['discover', 'managed', 'use-existing'];
|
|
97
86
|
const management = dbConfig.management || 'discover';
|
|
98
87
|
if (!validModes.includes(management)) {
|
|
99
88
|
result.addError(`Invalid database.postgres.management: "${management}"`);
|
|
@@ -42,28 +42,6 @@ describe('AuroraBuilder', () => {
|
|
|
42
42
|
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it('should return false when Postgres is external (bring your own DATABASE_URL)', () => {
|
|
46
|
-
const appDefinition = {
|
|
47
|
-
database: {
|
|
48
|
-
postgres: { enable: true, management: 'external' },
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return false for external Postgres even with managementMode=managed', () => {
|
|
56
|
-
const appDefinition = {
|
|
57
|
-
managementMode: 'managed',
|
|
58
|
-
vpcIsolation: 'isolated',
|
|
59
|
-
database: {
|
|
60
|
-
postgres: { enable: true, management: 'external' },
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
45
|
it('should return false when database is not defined', () => {
|
|
68
46
|
const appDefinition = {};
|
|
69
47
|
|