@friggframework/devtools 2.0.0--canary.704.6a606c3.0 → 2.0.0--canary.703.12b980b.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/deploy-subscriptions-step.test.js +35 -0
- 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/dependencies.test.js +5 -3
- package/frigg-cli/deploy-command/index.js +3 -0
- package/frigg-cli/deploy-command/subscriptions-step.js +44 -0
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +6 -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/test/init-command.test.js +2 -9
- package/infrastructure/README.md +0 -20
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +46 -50
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +7 -46
- 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/define-integration-provisioning.test.js +59 -0
- package/infrastructure/domains/integration/integration-builder.js +80 -65
- package/infrastructure/domains/integration/integration-builder.test.js +30 -73
- package/infrastructure/domains/scheduler/trigger-builder.js +114 -0
- package/infrastructure/domains/scheduler/trigger-builder.test.js +82 -0
- package/infrastructure/domains/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/function-environments.js +9 -1
- package/infrastructure/domains/shared/function-environments.test.js +14 -0
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +124 -83
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +26 -116
- package/infrastructure/domains/shared/utilities/logging-config.js +4 -3
- package/infrastructure/domains/shared/utilities/logging-config.test.js +2 -1
- package/infrastructure/infrastructure-composer.js +2 -0
- package/infrastructure/infrastructure-composer.test.js +3 -3
- package/package.json +8 -13
- 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
|
@@ -1,117 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
* Source for a new integration class (`src/integrations/<Name>Integration.js`)
|
|
3
|
-
* that wraps one installed API module.
|
|
4
|
-
*
|
|
5
|
-
* It follows the current IntegrationBase contract: a static `Definition`
|
|
6
|
-
* (name, version, display, `modules: { <key>: { definition } }`) and event
|
|
7
|
-
* handlers registered on `this.events` in the constructor. Calls to the API
|
|
8
|
-
* module go through `this.<key>.api.<method>()`.
|
|
9
|
-
*/
|
|
1
|
+
const path = require('path');
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (/^[0-9]/.test(identifier)) {
|
|
23
|
-
identifier = `Module${identifier}`;
|
|
24
|
-
}
|
|
25
|
-
return identifier;
|
|
26
|
-
}
|
|
3
|
+
function getIntegrationTemplate(apiModuleName, backendPath, ApiClass) {
|
|
4
|
+
// Find the sample data method
|
|
5
|
+
const apiMethods = Object.getOwnPropertyNames(ApiClass.prototype);
|
|
6
|
+
const sampleDataMethod =
|
|
7
|
+
apiMethods.find(
|
|
8
|
+
(method) =>
|
|
9
|
+
method.toLowerCase().includes('search') ||
|
|
10
|
+
method.toLowerCase().includes('list') ||
|
|
11
|
+
method.toLowerCase().includes('get')
|
|
12
|
+
) || 'searchDeals';
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const words = String(moduleName)
|
|
31
|
-
.split(/[^A-Za-z0-9]+/)
|
|
32
|
-
.filter(Boolean);
|
|
33
|
-
if (words.length === 0) {
|
|
34
|
-
return 'module';
|
|
35
|
-
}
|
|
36
|
-
const key = words
|
|
37
|
-
.map((word, i) =>
|
|
38
|
-
i === 0
|
|
39
|
-
? word.charAt(0).toLowerCase() + word.slice(1)
|
|
40
|
-
: word.charAt(0).toUpperCase() + word.slice(1)
|
|
41
|
-
)
|
|
42
|
-
.join('');
|
|
43
|
-
return /^[0-9]/.test(key) ? `module${key}` : key;
|
|
44
|
-
}
|
|
14
|
+
return `const { get, IntegrationBase, Options } = require('@friggframework/core');
|
|
15
|
+
const { Definition: ${apiModuleName}Module, Config: defaultConfig } = require('@friggframework/api-module-${apiModuleName.toLowerCase()}');
|
|
45
16
|
|
|
46
|
-
|
|
17
|
+
class ${apiModuleName}Integration extends IntegrationBase {
|
|
18
|
+
static Config = {
|
|
19
|
+
name: defaultConfig.name || '${apiModuleName.toLowerCase()}',
|
|
20
|
+
version: '1.0.0',
|
|
21
|
+
supportedVersions: ['1.0.0'],
|
|
22
|
+
events: ['SEARCH_DEALS'],
|
|
23
|
+
};
|
|
47
24
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
className,
|
|
62
|
-
packageName,
|
|
63
|
-
moduleName,
|
|
64
|
-
label,
|
|
65
|
-
description,
|
|
66
|
-
detailsUrl,
|
|
67
|
-
icon,
|
|
68
|
-
categories,
|
|
69
|
-
}) {
|
|
70
|
-
const moduleKey = toModuleKey(moduleName);
|
|
71
|
-
const moduleVar = `${moduleKey}Module`;
|
|
72
|
-
const category = Array.isArray(categories) ? categories.join(', ') : '';
|
|
25
|
+
static Options =
|
|
26
|
+
new Options({
|
|
27
|
+
module: ${apiModuleName}Module,
|
|
28
|
+
integrations: [${apiModuleName}Module],
|
|
29
|
+
display: {
|
|
30
|
+
name: defaultConfig.displayName || '${apiModuleName}',
|
|
31
|
+
description: defaultConfig.description || 'Sales & CRM, Marketing',
|
|
32
|
+
category: defaultConfig.category || 'Sales & CRM, Marketing',
|
|
33
|
+
detailsUrl: defaultConfig.detailsUrl || 'https://www.${apiModuleName.toLowerCase()}.com',
|
|
34
|
+
icon: defaultConfig.icon || 'https://friggframework.org/assets/img/${apiModuleName.toLowerCase()}.jpeg',
|
|
35
|
+
},
|
|
36
|
+
hasUserConfig: true,
|
|
37
|
+
});
|
|
73
38
|
|
|
74
|
-
|
|
75
|
-
|
|
39
|
+
static modules = {
|
|
40
|
+
${apiModuleName.toLowerCase()}: ${apiModuleName}Module,
|
|
41
|
+
}
|
|
76
42
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
43
|
+
/**
|
|
44
|
+
* HANDLE EVENTS
|
|
45
|
+
*/
|
|
46
|
+
async receiveNotification(notifier, event, object = null) {
|
|
47
|
+
if (event === 'SEARCH_DEALS') {
|
|
48
|
+
return this.target.api.searchDeals(object);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
83
51
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
52
|
+
/**
|
|
53
|
+
* ALL CUSTOM/OPTIONAL METHODS FOR AN INTEGRATION MANAGER
|
|
54
|
+
*/
|
|
55
|
+
async getSampleData() {
|
|
56
|
+
const res = await this.target.api.${sampleDataMethod}();
|
|
57
|
+
return { data: res };
|
|
58
|
+
}
|
|
91
59
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
60
|
+
/**
|
|
61
|
+
* ALL REQUIRED METHODS FOR AN INTEGRATION MANAGER
|
|
62
|
+
*/
|
|
63
|
+
async onCreate(params) {
|
|
64
|
+
// Validate that we have all of the data we need
|
|
65
|
+
// Set integration status as makes sense. Default ENABLED
|
|
66
|
+
// TODO turn this into a validateConfig method/function
|
|
67
|
+
this.record.status = 'ENABLED';
|
|
68
|
+
await this.record.save();
|
|
69
|
+
return this.record;
|
|
70
|
+
}
|
|
98
71
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
72
|
+
async onUpdate(params) {
|
|
73
|
+
const newConfig = get(params, 'config');
|
|
74
|
+
const oldConfig = this.record.config;
|
|
75
|
+
// Just save whatever
|
|
76
|
+
this.record.markModified('config');
|
|
77
|
+
await this.record.save();
|
|
78
|
+
return this.validateConfig();
|
|
79
|
+
}
|
|
103
80
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// Map event names to handlers, e.g.
|
|
108
|
-
// GET_SAMPLE_DATA: { handler: this.getSampleData.bind(this) },
|
|
109
|
-
};
|
|
81
|
+
async getConfigOptions() {
|
|
82
|
+
const options = {}
|
|
83
|
+
return options;
|
|
110
84
|
}
|
|
111
85
|
}
|
|
112
86
|
|
|
113
|
-
module.exports = ${
|
|
114
|
-
`;
|
|
87
|
+
module.exports = ${apiModuleName}Integration;`;
|
|
115
88
|
}
|
|
116
89
|
|
|
117
|
-
module.exports = { getIntegrationTemplate
|
|
90
|
+
module.exports = { getIntegrationTemplate };
|
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
2
|
const axios = require('axios');
|
|
3
3
|
const { logError } = require('./logger');
|
|
4
4
|
const { checkbox } = require('@inquirer/prompts');
|
|
5
5
|
|
|
6
|
-
const API_MODULE_PREFIX = '@friggframework/api-module-';
|
|
7
|
-
|
|
8
6
|
async function searchPackages(apiModuleName) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'npm',
|
|
13
|
-
['search', `${API_MODULE_PREFIX}${apiModuleName}`, '--json'],
|
|
14
|
-
{ encoding: 'utf8' }
|
|
15
|
-
);
|
|
16
|
-
if (result.error) {
|
|
17
|
-
throw result.error;
|
|
18
|
-
}
|
|
19
|
-
if (result.status !== 0) {
|
|
20
|
-
throw new Error(`npm search failed: ${result.stderr || result.status}`);
|
|
21
|
-
}
|
|
22
|
-
// npm search is a full-text search; keep only Frigg API modules.
|
|
23
|
-
return JSON.parse(result.stdout || '[]').filter(
|
|
24
|
-
(pkg) => pkg && pkg.name && pkg.name.startsWith(API_MODULE_PREFIX)
|
|
25
|
-
);
|
|
7
|
+
const searchCommand = `npm search @friggframework/api-module-${apiModuleName} --json`;
|
|
8
|
+
const result = execSync(searchCommand, { encoding: 'utf8' });
|
|
9
|
+
return JSON.parse(result);
|
|
26
10
|
}
|
|
27
11
|
|
|
28
12
|
async function checkPackageExists(packageName) {
|
|
@@ -74,21 +58,6 @@ const searchAndSelectPackage = async (apiModuleName) => {
|
|
|
74
58
|
};
|
|
75
59
|
});
|
|
76
60
|
|
|
77
|
-
// Without a terminal to prompt on, take the exact match
|
|
78
|
-
// (`frigg install hubspot` -> @friggframework/api-module-hubspot).
|
|
79
|
-
if (!process.stdin.isTTY) {
|
|
80
|
-
const exact = `${API_MODULE_PREFIX}${apiModuleName}`;
|
|
81
|
-
if (filteredResults.some((pkg) => pkg.name === exact)) {
|
|
82
|
-
return [exact];
|
|
83
|
-
}
|
|
84
|
-
logError(
|
|
85
|
-
`No exact match for ${exact}, and there is no terminal to choose from: ${filteredResults
|
|
86
|
-
.map((pkg) => pkg.name)
|
|
87
|
-
.join(', ')}`
|
|
88
|
-
);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
61
|
const selectedPackages = await checkbox({
|
|
93
62
|
message: 'Select the packages to install:',
|
|
94
63
|
choices,
|
|
@@ -99,7 +68,6 @@ const searchAndSelectPackage = async (apiModuleName) => {
|
|
|
99
68
|
};
|
|
100
69
|
|
|
101
70
|
module.exports = {
|
|
102
|
-
API_MODULE_PREFIX,
|
|
103
71
|
validatePackageExists,
|
|
104
72
|
checkPackageExists,
|
|
105
73
|
searchPackages,
|
package/frigg-cli/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lodash": "4.18.1",
|
|
27
27
|
"node-cache": "^5.1.2",
|
|
28
28
|
"open": "^8.4.2",
|
|
29
|
-
"osls": "^
|
|
29
|
+
"osls": "^3.58.0",
|
|
30
30
|
"semver": "^7.6.0",
|
|
31
31
|
"validate-npm-package-name": "^5.0.0"
|
|
32
32
|
},
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
},
|
|
56
56
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": "
|
|
58
|
+
"node": ">=18"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|
|
@@ -123,19 +123,12 @@ describe('Init Command', () => {
|
|
|
123
123
|
);
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
it('
|
|
127
|
-
// The flags `frigg init` registers and initCommand forwards
|
|
128
|
-
// (see init-command/index.js). `yes` is the non-interactive flag
|
|
129
|
-
// (`--yes`: accept defaults, no prompts); `install: false` and
|
|
130
|
-
// `git: false` are what `--no-install` / `--no-git` produce. The
|
|
131
|
-
// old `frontend` option is gone: init scaffolds a backend only.
|
|
126
|
+
it('should pass options to BackendFirstHandler', async () => {
|
|
132
127
|
const options = {
|
|
133
128
|
force: true,
|
|
134
129
|
verbose: true,
|
|
135
130
|
mode: 'standalone',
|
|
136
|
-
|
|
137
|
-
install: false,
|
|
138
|
-
git: false
|
|
131
|
+
frontend: false
|
|
139
132
|
};
|
|
140
133
|
|
|
141
134
|
await initCommand(mockProjectName, options);
|
package/infrastructure/README.md
CHANGED
|
@@ -207,26 +207,6 @@ STAGE=production
|
|
|
207
207
|
SERVICE_NAME=my-frigg-app
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
-
## Packaging (osls 4)
|
|
211
|
-
|
|
212
|
-
The composed definition targets osls `^4.4.0`
|
|
213
|
-
([ADR-050](../../../docs/architecture-decisions/050-osls-4.md)):
|
|
214
|
-
|
|
215
|
-
- `frameworkVersion` is `OSLS_FRAMEWORK_VERSION` (`^4.4.0`,
|
|
216
|
-
`domains/shared/utilities/framework-version.js`). It is the single place the version is set.
|
|
217
|
-
- Every packaged function gets `package.patterns`, built by `toPackagePatterns({ include, exclude })`
|
|
218
|
-
(`domains/shared/utilities/package-patterns.js`): excludes negated first, then includes. Builders
|
|
219
|
-
keep plain include/exclude lists and pass them through the helper; never emit
|
|
220
|
-
`package.include`/`package.exclude`. `nestedNodeModulesExcludes()` output goes through the same
|
|
221
|
-
helper.
|
|
222
|
-
- `useDotenv: true` is emitted only for `osls offline` (`frigg start`); otherwise the key is absent.
|
|
223
|
-
- `custom.esbuild.exclude` is a serverless-esbuild option and stays as it is.
|
|
224
|
-
|
|
225
|
-
`__tests__/package-patterns-composition.test.js` walks every function of a fully featured
|
|
226
|
-
definition and fails if any of these rules is broken. Size budget: each function under 100 MB
|
|
227
|
-
unzipped, function + layers under 200 MB (Lambda's hard limit is 250 MB); see
|
|
228
|
-
[the measurements](../../../docs/reference/aws-sdk-v3-osls-migration.md#package-size-budget).
|
|
229
|
-
|
|
230
210
|
## Lambda Layers
|
|
231
211
|
|
|
232
212
|
### Prisma Layer
|
|
@@ -11,30 +11,10 @@ Frigg Framework supports automatic provisioning of Amazon Aurora Serverless v2 P
|
|
|
11
11
|
- **Aurora Serverless v2**: Cost-efficient auto-scaling database (0.5-1.0 ACU default)
|
|
12
12
|
- **VPC Integration**: Deployed in same private subnets as Lambda functions
|
|
13
13
|
- **Secrets Manager**: Automatic credential management and rotation
|
|
14
|
-
- **Management Modes**: discover, create-new, use-existing
|
|
14
|
+
- **Three Management Modes**: discover, create-new, use-existing
|
|
15
15
|
- **Security**: Private subnet deployment with security group isolation
|
|
16
16
|
- **High Availability**: Multi-AZ deployment with automatic failover
|
|
17
17
|
|
|
18
|
-
### Bring your own PostgreSQL (`management: 'external'`)
|
|
19
|
-
|
|
20
|
-
To connect to a PostgreSQL that Frigg does not manage (any hosted provider, or
|
|
21
|
-
a database you run yourself), set `management: 'external'`. Frigg then creates
|
|
22
|
-
and discovers no database resources (no RDS/Aurora, no Secrets Manager secret)
|
|
23
|
-
and needs no VPC for the database; the app connects through `DATABASE_URL`.
|
|
24
|
-
This check takes precedence over a top-level `managementMode`. The migration
|
|
25
|
-
infrastructure is still composed, so migrations run against `DATABASE_URL`.
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
const appDefinition = {
|
|
29
|
-
vpc: { enable: false },
|
|
30
|
-
database: { postgres: { enable: true, management: 'external' } },
|
|
31
|
-
environment: { DATABASE_URL: true }, // read from the shell that runs `frigg deploy` (not .env)
|
|
32
|
-
};
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Use `sslmode=require` in the URL. This is the default for apps scaffolded by
|
|
36
|
-
`frigg init`.
|
|
37
|
-
|
|
38
18
|
---
|
|
39
19
|
|
|
40
20
|
## Configuration Schema
|
|
@@ -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() {
|
|
@@ -398,55 +397,52 @@ class AdminScriptBuilder extends InfrastructureBuilder {
|
|
|
398
397
|
skipEsbuildPackageConfig(appDefinition, usePrismaLayer) {
|
|
399
398
|
const tlsCAFile = appDefinition?.database?.documentDB?.tlsCAFile;
|
|
400
399
|
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
|
-
}),
|
|
400
|
+
include: [
|
|
401
|
+
// Handlers connect to the DB, so ship the DocumentDB CA cert.
|
|
402
|
+
...(tlsCAFile ? [tlsCAFile.replace(/^\.\//, '')] : []),
|
|
403
|
+
],
|
|
404
|
+
exclude: [
|
|
405
|
+
'node_modules/aws-sdk/**',
|
|
406
|
+
'node_modules/@aws-sdk/**',
|
|
407
|
+
...(usePrismaLayer
|
|
408
|
+
? [
|
|
409
|
+
'node_modules/@prisma/**',
|
|
410
|
+
'node_modules/.prisma/**',
|
|
411
|
+
'node_modules/prisma/**',
|
|
412
|
+
'node_modules/@friggframework/core/generated/**',
|
|
413
|
+
]
|
|
414
|
+
: []),
|
|
415
|
+
...nestedNodeModulesExcludes(appDefinition, usePrismaLayer),
|
|
416
|
+
'node_modules/@friggframework/test/**',
|
|
417
|
+
'node_modules/@friggframework/eslint-config/**',
|
|
418
|
+
'node_modules/@friggframework/prettier-config/**',
|
|
419
|
+
'node_modules/jest/**',
|
|
420
|
+
'node_modules/prettier/**',
|
|
421
|
+
'node_modules/eslint/**',
|
|
422
|
+
'node_modules/esbuild/**',
|
|
423
|
+
'node_modules/@esbuild/**',
|
|
424
|
+
'node_modules/typescript/**',
|
|
425
|
+
'node_modules/webpack/**',
|
|
426
|
+
'node_modules/osls/**',
|
|
427
|
+
'node_modules/serverless-esbuild/**',
|
|
428
|
+
'node_modules/serverless-jetpack/**',
|
|
429
|
+
'node_modules/serverless-offline/**',
|
|
430
|
+
'node_modules/serverless-offline-sqs/**',
|
|
431
|
+
'node_modules/serverless-dotenv-plugin/**',
|
|
432
|
+
'node_modules/serverless-kms-grants/**',
|
|
433
|
+
// Never deploy secrets or the lockfile.
|
|
434
|
+
'.env',
|
|
435
|
+
'.env.*',
|
|
436
|
+
'**/.env',
|
|
437
|
+
'**/.env.*',
|
|
438
|
+
'.frigg-credentials.json',
|
|
439
|
+
'package-lock.json',
|
|
440
|
+
'test/**',
|
|
441
|
+
'layers/**',
|
|
442
|
+
'coverage/**',
|
|
443
|
+
'**/*.test.js',
|
|
444
|
+
'**/*.spec.js',
|
|
445
|
+
],
|
|
450
446
|
};
|
|
451
447
|
}
|
|
452
448
|
|
|
@@ -285,11 +285,11 @@ describe('AdminScriptBuilder', () => {
|
|
|
285
285
|
result.functions.adminScriptExecutor,
|
|
286
286
|
result.functions.adminScriptRouter,
|
|
287
287
|
]) {
|
|
288
|
-
expect(fn.package.
|
|
288
|
+
expect(fn.package.exclude).toEqual(
|
|
289
289
|
expect.arrayContaining([
|
|
290
|
-
'
|
|
291
|
-
'
|
|
292
|
-
'
|
|
290
|
+
'node_modules/aws-sdk/**',
|
|
291
|
+
'node_modules/@aws-sdk/**',
|
|
292
|
+
'node_modules/@prisma/**',
|
|
293
293
|
])
|
|
294
294
|
);
|
|
295
295
|
}
|
|
@@ -1029,7 +1029,7 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1029
1029
|
const result = await new AdminScriptBuilder().build(appDefinition(), {});
|
|
1030
1030
|
|
|
1031
1031
|
for (const fn of executorAndRouter(result)) {
|
|
1032
|
-
expect(fn.package.
|
|
1032
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/**');
|
|
1033
1033
|
}
|
|
1034
1034
|
});
|
|
1035
1035
|
|
|
@@ -1040,47 +1040,8 @@ describe('AdminScriptBuilder nested node_modules (lambda.keepNestedNodeModules)'
|
|
|
1040
1040
|
);
|
|
1041
1041
|
|
|
1042
1042
|
for (const fn of executorAndRouter(result)) {
|
|
1043
|
-
expect(fn.package.
|
|
1044
|
-
expect(fn.package.
|
|
1043
|
+
expect(fn.package.exclude).not.toContain('node_modules/**/node_modules/**');
|
|
1044
|
+
expect(fn.package.exclude).toContain('node_modules/**/node_modules/@friggframework/**');
|
|
1045
1045
|
}
|
|
1046
1046
|
});
|
|
1047
1047
|
});
|
|
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
|
|