@friggframework/devtools 2.0.0--canary.702.047d3c4.0 → 2.0.0--canary.701.2571e69.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 +1 -46
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +0 -3
- package/frigg-cli/build-command/index.js +0 -6
- package/frigg-cli/deploy-command/index.js +0 -6
- package/frigg-cli/index.js +1 -19
- package/frigg-cli/init-command/backend-first-handler.js +46 -25
- package/frigg-cli/start-command/index.js +0 -4
- package/frigg-cli/start-command/start-command.test.js +0 -3
- package/infrastructure/create-frigg-infrastructure.js +1 -4
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -60
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +6 -2
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +30 -0
- package/package.json +7 -7
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
- 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 -326
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -241
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
- package/frigg-cli/validate-command/checks/config.js +0 -468
- 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 -93
- 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/app-definition-schema-contract.test.js +0 -607
- package/infrastructure/create-frigg-infrastructure.test.js +0 -51
|
@@ -168,6 +168,21 @@ 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
|
+
|
|
171
186
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
172
187
|
const appDefinition = {
|
|
173
188
|
adminScripts: [
|
|
@@ -621,6 +636,21 @@ describe('AdminScriptBuilder', () => {
|
|
|
621
636
|
});
|
|
622
637
|
|
|
623
638
|
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
|
+
|
|
624
654
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
625
655
|
const appDefinition = {
|
|
626
656
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
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.701.2571e69.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.701.2571e69.0",
|
|
30
|
+
"@friggframework/schemas": "2.0.0--canary.701.2571e69.0",
|
|
31
|
+
"@friggframework/test": "2.0.0--canary.701.2571e69.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.701.2571e69.0",
|
|
60
|
+
"@friggframework/prettier-config": "2.0.0--canary.701.2571e69.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": "2571e692e406f3d39977c865685639b9e895345f"
|
|
93
93
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* build and deploy validate the app definition first and stop on errors;
|
|
3
|
-
* start validates and only warns (ADR-051).
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// child_process and node:child_process are one module to jest: one mock.
|
|
7
|
-
const mockChildProcess = {
|
|
8
|
-
spawnSync: jest.fn(() => ({ status: 0 })),
|
|
9
|
-
spawn: jest.fn(),
|
|
10
|
-
};
|
|
11
|
-
jest.mock('child_process', () => mockChildProcess);
|
|
12
|
-
jest.mock('node:child_process', () => mockChildProcess);
|
|
13
|
-
jest.mock('../../../validate-command', () => ({
|
|
14
|
-
preflightValidation: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
jest.mock('../../../doctor-command', () => ({ doctorCommand: jest.fn() }));
|
|
17
|
-
jest.mock('../../../utils/database-validator', () => ({
|
|
18
|
-
validateDatabaseUrl: jest.fn(() => ({ valid: true })),
|
|
19
|
-
getDatabaseType: jest.fn(() => ({ dbType: 'postgresql' })),
|
|
20
|
-
checkPrismaClientGenerated: jest.fn(() => ({ generated: true })),
|
|
21
|
-
}));
|
|
22
|
-
jest.mock('dotenv', () => ({ config: jest.fn() }));
|
|
23
|
-
|
|
24
|
-
const childProcess = mockChildProcess;
|
|
25
|
-
const nodeChildProcess = mockChildProcess;
|
|
26
|
-
const { preflightValidation } = require('../../../validate-command');
|
|
27
|
-
const { buildCommand } = require('../../../build-command');
|
|
28
|
-
const { deployCommand } = require('../../../deploy-command');
|
|
29
|
-
const { startCommand } = require('../../../start-command');
|
|
30
|
-
|
|
31
|
-
describe('validation before build, deploy and start', () => {
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
jest.clearAllMocks();
|
|
34
|
-
jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
35
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
36
|
-
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
37
|
-
jest.spyOn(process, 'exit').mockImplementation(() => {});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
afterEach(() => jest.restoreAllMocks());
|
|
41
|
-
|
|
42
|
-
it('build validates first and fails on errors', async () => {
|
|
43
|
-
preflightValidation.mockReturnValue(false);
|
|
44
|
-
|
|
45
|
-
await buildCommand({ stage: 'prod' });
|
|
46
|
-
|
|
47
|
-
expect(preflightValidation).toHaveBeenCalledWith({
|
|
48
|
-
command: 'build',
|
|
49
|
-
options: { stage: 'prod' },
|
|
50
|
-
failOnErrors: true,
|
|
51
|
-
});
|
|
52
|
-
expect(childProcess.spawnSync).not.toHaveBeenCalled();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('build packages after a passing validation', async () => {
|
|
56
|
-
preflightValidation.mockReturnValue(true);
|
|
57
|
-
|
|
58
|
-
await buildCommand({ stage: 'prod' });
|
|
59
|
-
|
|
60
|
-
expect(childProcess.spawnSync).toHaveBeenCalled();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('deploy validates first and fails on errors', async () => {
|
|
64
|
-
preflightValidation.mockReturnValue(false);
|
|
65
|
-
|
|
66
|
-
await deployCommand({ stage: 'prod', skipValidate: false });
|
|
67
|
-
|
|
68
|
-
expect(preflightValidation).toHaveBeenCalledWith({
|
|
69
|
-
command: 'deploy',
|
|
70
|
-
options: { stage: 'prod', skipValidate: false },
|
|
71
|
-
failOnErrors: true,
|
|
72
|
-
});
|
|
73
|
-
expect(childProcess.spawn).not.toHaveBeenCalled();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('start validates and only warns', async () => {
|
|
77
|
-
preflightValidation.mockReturnValue(true);
|
|
78
|
-
nodeChildProcess.spawn.mockReturnValue({ on: jest.fn() });
|
|
79
|
-
const previous = process.env.DATABASE_URL;
|
|
80
|
-
process.env.DATABASE_URL = 'postgresql://localhost/frigg';
|
|
81
|
-
|
|
82
|
-
await startCommand({ stage: 'dev' });
|
|
83
|
-
|
|
84
|
-
process.env.DATABASE_URL = previous;
|
|
85
|
-
expect(preflightValidation).toHaveBeenCalledWith({
|
|
86
|
-
command: 'start',
|
|
87
|
-
options: { stage: 'dev' },
|
|
88
|
-
failOnErrors: false,
|
|
89
|
-
});
|
|
90
|
-
expect(nodeChildProcess.spawn).toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `frigg init` validates the generated app with the same code path as
|
|
3
|
-
* `frigg validate`, and never fails because of it (ADR-051).
|
|
4
|
-
*/
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
|
|
9
|
-
jest.mock('@inquirer/prompts', () => ({}));
|
|
10
|
-
|
|
11
|
-
const BackendFirstHandler = require('../../init-command/backend-first-handler');
|
|
12
|
-
|
|
13
|
-
function writeApp(source) {
|
|
14
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'frigg-init-'));
|
|
15
|
-
fs.writeFileSync(path.join(dir, 'package.json'), '{"name":"backend"}');
|
|
16
|
-
fs.writeFileSync(path.join(dir, 'index.js'), source);
|
|
17
|
-
return dir;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('frigg init validation', () => {
|
|
21
|
-
const dirs = [];
|
|
22
|
-
let log;
|
|
23
|
-
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
log = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
jest.restoreAllMocks();
|
|
30
|
-
for (const dir of dirs.splice(0))
|
|
31
|
-
fs.rmSync(dir, { recursive: true, force: true });
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('validates the real generated definition, not a stand-in', async () => {
|
|
35
|
-
const dir = writeApp(
|
|
36
|
-
"module.exports = { Definition: { integrations: [], database: { postgres: { enable: true, management: 'create-new' } } } };"
|
|
37
|
-
);
|
|
38
|
-
dirs.push(dir);
|
|
39
|
-
const handler = new BackendFirstHandler(dir, {});
|
|
40
|
-
|
|
41
|
-
const ok = await handler.validateGeneratedAppDefinition(
|
|
42
|
-
path.join(dir, 'index.js')
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
expect(ok).toBe(false);
|
|
46
|
-
expect(log.mock.calls.flat().join('\n')).toContain(
|
|
47
|
-
'/database/postgres/management'
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('stays quiet before npm install, when index.js cannot load its dependencies', async () => {
|
|
52
|
-
const dir = writeApp(
|
|
53
|
-
"require('@friggframework/api-module-does-not-exist');"
|
|
54
|
-
);
|
|
55
|
-
dirs.push(dir);
|
|
56
|
-
const handler = new BackendFirstHandler(dir, {});
|
|
57
|
-
|
|
58
|
-
await expect(
|
|
59
|
-
handler.validateGeneratedAppDefinition(path.join(dir, 'index.js'))
|
|
60
|
-
).resolves.toBe(true);
|
|
61
|
-
expect(log).not.toHaveBeenCalled();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const { checkIntegrations } = require('../checks/integrations');
|
|
2
|
-
|
|
3
|
-
class FakeApi {
|
|
4
|
-
static requesterType = 'oauth2';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const moduleDefinition = () => ({
|
|
8
|
-
moduleName: 'acme',
|
|
9
|
-
API: FakeApi,
|
|
10
|
-
requiredAuthMethods: {
|
|
11
|
-
getToken: async () => {},
|
|
12
|
-
getEntityDetails: async () => {},
|
|
13
|
-
getCredentialDetails: async () => {},
|
|
14
|
-
testAuthRequest: async () => {},
|
|
15
|
-
apiPropertiesToPersist: { credential: [], entity: [] },
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function integrationClass(definition) {
|
|
20
|
-
return class Integration {
|
|
21
|
-
static Definition = definition;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const goodIntegration = () =>
|
|
26
|
-
integrationClass({
|
|
27
|
-
name: 'acme',
|
|
28
|
-
version: '1.0.0',
|
|
29
|
-
modules: { acme: { definition: moduleDefinition() } },
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const codes = (issues) =>
|
|
33
|
-
issues.map((i) => `${i.severity}:${i.code}:${i.pointer}`);
|
|
34
|
-
|
|
35
|
-
describe('checkIntegrations', () => {
|
|
36
|
-
it('accepts a well-formed integration class', () => {
|
|
37
|
-
expect(
|
|
38
|
-
checkIntegrations({ integrations: [goodIntegration()] })
|
|
39
|
-
).toEqual([]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('warns when the app lists no integrations', () => {
|
|
43
|
-
expect(codes(checkIntegrations({ integrations: [] }))).toEqual([
|
|
44
|
-
'warning:no-integrations:/integrations',
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('rejects an entry that is not a class', () => {
|
|
49
|
-
expect(
|
|
50
|
-
codes(
|
|
51
|
-
checkIntegrations({
|
|
52
|
-
integrations: [{ Definition: { name: 'x' } }],
|
|
53
|
-
})
|
|
54
|
-
)
|
|
55
|
-
).toEqual(['error:integration-not-a-class:/integrations/0']);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('rejects a class without a static Definition', () => {
|
|
59
|
-
class Bare {}
|
|
60
|
-
expect(codes(checkIntegrations({ integrations: [Bare] }))).toEqual([
|
|
61
|
-
'error:integration-definition-missing:/integrations/0/Definition',
|
|
62
|
-
]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('requires a valid name and modules, and warns on a missing version', () => {
|
|
66
|
-
const Cls = integrationClass({ name: '1 bad name' });
|
|
67
|
-
expect(codes(checkIntegrations({ integrations: [Cls] }))).toEqual([
|
|
68
|
-
'error:integration-name-invalid:/integrations/0/Definition/name',
|
|
69
|
-
'warning:integration-version-missing:/integrations/0/Definition/version',
|
|
70
|
-
'error:integration-modules-missing:/integrations/0/Definition/modules',
|
|
71
|
-
]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('reports duplicate integration names', () => {
|
|
75
|
-
expect(
|
|
76
|
-
codes(
|
|
77
|
-
checkIntegrations({
|
|
78
|
-
integrations: [goodIntegration(), goodIntegration()],
|
|
79
|
-
})
|
|
80
|
-
)
|
|
81
|
-
).toEqual([
|
|
82
|
-
'error:integration-name-duplicate:/integrations/1/Definition/name',
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('checks module definitions the way Module.validateDefinition does', () => {
|
|
87
|
-
const definition = moduleDefinition();
|
|
88
|
-
delete definition.requiredAuthMethods.getToken;
|
|
89
|
-
delete definition.moduleName;
|
|
90
|
-
const Cls = integrationClass({
|
|
91
|
-
name: 'acme',
|
|
92
|
-
version: '1',
|
|
93
|
-
modules: { acme: { definition }, other: {} },
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
expect(codes(checkIntegrations({ integrations: [Cls] }))).toEqual([
|
|
97
|
-
'error:module-name-missing:/integrations/0/Definition/modules/acme/definition/moduleName',
|
|
98
|
-
'error:module-auth-method-missing:/integrations/0/Definition/modules/acme/definition/requiredAuthMethods/getToken',
|
|
99
|
-
'error:module-definition-missing:/integrations/0/Definition/modules/other/definition',
|
|
100
|
-
]);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it('does not require getToken for non-OAuth2 modules', () => {
|
|
104
|
-
const definition = moduleDefinition();
|
|
105
|
-
definition.API = class {
|
|
106
|
-
static requesterType = 'apiKey';
|
|
107
|
-
};
|
|
108
|
-
delete definition.requiredAuthMethods.getToken;
|
|
109
|
-
const Cls = integrationClass({
|
|
110
|
-
name: 'acme',
|
|
111
|
-
version: '1',
|
|
112
|
-
modules: { acme: { definition } },
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
expect(checkIntegrations({ integrations: [Cls] })).toEqual([]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('warns that a module rateLimit is not applied', () => {
|
|
119
|
-
const definition = {
|
|
120
|
-
...moduleDefinition(),
|
|
121
|
-
rateLimit: { requests: 10, period: 'second' },
|
|
122
|
-
};
|
|
123
|
-
const Cls = integrationClass({
|
|
124
|
-
name: 'acme',
|
|
125
|
-
version: '1',
|
|
126
|
-
modules: { acme: { definition } },
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
expect(codes(checkIntegrations({ integrations: [Cls] }))).toEqual([
|
|
130
|
-
'warning:module-rate-limit-ignored:/integrations/0/Definition/modules/acme/definition/rateLimit',
|
|
131
|
-
]);
|
|
132
|
-
});
|
|
133
|
-
});
|