@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
package/README.md
CHANGED
|
@@ -12,20 +12,6 @@ The devtools package includes the following main components:
|
|
|
12
12
|
4. Local runner and deploy tooling
|
|
13
13
|
5. Infrastructure
|
|
14
14
|
|
|
15
|
-
## Requirements
|
|
16
|
-
|
|
17
|
-
- Node.js `^22.13.0 || >=24` on the machine that runs `frigg` (Node 23 and Node 22.0–22.12
|
|
18
|
-
are not supported by osls; the CLI exits with a message). Lambda functions run on
|
|
19
|
-
`nodejs22.x`.
|
|
20
|
-
- [osls](https://github.com/oss-serverless/osls) `^4.4.0` (installed with the CLI). Frigg
|
|
21
|
-
2.0.1 moved from osls 3 to osls 4; see
|
|
22
|
-
[ADR-050](../../docs/architecture-decisions/050-osls-4.md) and the
|
|
23
|
-
[upgrade notes](../../docs/reference/aws-sdk-v3-osls-migration.md#osls-4-frigg-201).
|
|
24
|
-
|
|
25
|
-
If your `infrastructure.js` wrapper changes the composed definition, use
|
|
26
|
-
`package.patterns` (never `package.include`/`package.exclude`), do not set
|
|
27
|
-
`useDotenv: false`, and do not pin `frameworkVersion` to 3.x. osls 4 rejects all three.
|
|
28
|
-
|
|
29
15
|
## Frigg CLI
|
|
30
16
|
|
|
31
17
|
The Frigg CLI is a command-line interface tool that helps developers manage and install API modules in their Frigg projects.
|
package/frigg-cli/README.md
CHANGED
|
@@ -6,78 +6,33 @@ The Frigg CLI provides tools for building, deploying, and managing serverless in
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
**Requirements:** Node.js `^22.13.0 || >=24`. The CLI drives
|
|
10
|
-
[osls](https://github.com/oss-serverless/osls) `^4.4.0` (Frigg 2.0.1+,
|
|
11
|
-
[ADR-050](../../../docs/architecture-decisions/050-osls-4.md)); osls refuses Node 23 and
|
|
12
|
-
Node 22.0–22.12, so the CLI checks the version first and exits with a message. Set
|
|
13
|
-
`FRIGG_SKIP_NODE_VERSION_CHECK=true` to skip the CLI check.
|
|
14
|
-
|
|
15
9
|
## Command Reference
|
|
16
10
|
|
|
17
11
|
### Core Commands
|
|
18
12
|
|
|
19
|
-
#### `frigg init [
|
|
13
|
+
#### `frigg init [options]`
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
**Status:** To be documented (command may not be merged yet)
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
Initialize a new Frigg application with scaffolding and configuration.
|
|
24
18
|
|
|
19
|
+
**Usage:**
|
|
25
20
|
```bash
|
|
26
|
-
frigg init
|
|
27
|
-
frigg init my-app
|
|
28
|
-
frigg init
|
|
29
|
-
frigg init my-app --mode embedded # add to an existing project (./frigg-integration)
|
|
30
|
-
npx @friggframework/devtools init my-app --yes # without a global install
|
|
21
|
+
frigg init
|
|
22
|
+
frigg init my-app
|
|
23
|
+
frigg init --template typescript
|
|
31
24
|
```
|
|
32
25
|
|
|
33
26
|
**What it does:**
|
|
34
|
-
|
|
35
|
-
1. Validates the project name and `--mode`, and checks that the target directory is
|
|
36
|
-
empty (only `.git`, `.gitignore`, `README.md` and `.DS_Store` may exist) before asking anything else
|
|
37
|
-
2. Copies the backend template: `index.js` (app definition, named after the project),
|
|
38
|
-
`infrastructure.js`, `README.md`, `.gitignore`, `.env.example` (also seeded into `.env`)
|
|
39
|
-
3. Writes `package.json` with:
|
|
40
|
-
- scripts: `start` (`frigg start`), `build` (`frigg build`), `deploy` (`frigg deploy`),
|
|
41
|
-
`db:setup` (`frigg db:setup`), `test` (`jest --passWithNoTests`)
|
|
42
|
-
- dependencies: `@friggframework/core`, `@prisma/client`, `prisma`
|
|
43
|
-
- devDependencies: `@friggframework/devtools`, `@friggframework/serverless-plugin`,
|
|
44
|
-
`osls`, and the serverless plugins the composed definition loads
|
|
45
|
-
- Frigg package versions match the devtools that ran `init` (a prerelease is pinned exactly)
|
|
46
|
-
4. Validates the generated app definition against the app-definition schema (problems
|
|
47
|
-
are printed as warnings; `frigg start`, `build` and `deploy` do not validate)
|
|
48
|
-
5. Optionally initializes git and runs `npm install`
|
|
49
|
-
6. Prints next steps. API modules picked in the interactive prompt are not wired in
|
|
50
|
-
automatically; the next steps list a `frigg install <module>` command for each
|
|
51
|
-
|
|
52
|
-
In `embedded` mode the backend is written to `./frigg-integration` inside the target
|
|
53
|
-
directory, which may already contain your application. Git is not initialized.
|
|
27
|
+
- TBD - Full documentation pending implementation merge
|
|
54
28
|
|
|
55
29
|
**Options:**
|
|
30
|
+
- TBD
|
|
56
31
|
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
- `-y, --yes` - Accept the default for every prompt. Implied when stdin is not a TTY
|
|
60
|
-
- `--no-install` - Skip `npm install`
|
|
61
|
-
- `--no-git` - Skip `git init` and the initial commit
|
|
62
|
-
- `-f, --force` - Scaffold into a non-empty directory and overwrite an existing `README.md`/`.gitignore`
|
|
63
|
-
- `-v, --verbose` - Verbose output
|
|
64
|
-
|
|
65
|
-
**Next steps after `init`:**
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
cd my-app
|
|
69
|
-
docker run --name frigg-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:16
|
|
70
|
-
npm run db:setup
|
|
71
|
-
npm start
|
|
72
|
-
```
|
|
32
|
+
**Example Output:**
|
|
33
|
+
- TBD
|
|
73
34
|
|
|
74
|
-
|
|
75
|
-
idle: no VPC, NAT gateway or database cluster (`vpc: { enable: false }`,
|
|
76
|
-
`database.postgres.management: 'external'`), field-level encryption with a per-stage
|
|
77
|
-
KMS key ($1/month, about $3/month after its first two yearly rotations), 14-day log
|
|
78
|
-
retention, and the app connecting to a PostgreSQL you host through `DATABASE_URL`.
|
|
79
|
-
`frigg deploy` reads `DATABASE_URL` from the shell that runs it, not from `.env`. The
|
|
80
|
-
generated `README.md` lists every resource, the security model and the other options.
|
|
35
|
+
> **Note**: This command may be part of an upcoming release. Documentation will be updated once the implementation is merged to the main branch.
|
|
81
36
|
|
|
82
37
|
---
|
|
83
38
|
|
|
@@ -92,36 +47,28 @@ frigg install salesforce
|
|
|
92
47
|
frigg install stripe
|
|
93
48
|
```
|
|
94
49
|
|
|
95
|
-
Run it in the app directory (the one with `package.json` and `index.js`).
|
|
96
|
-
|
|
97
50
|
**What it does:**
|
|
98
|
-
- Searches
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- Resolves the installed module from the app directory and writes
|
|
104
|
-
`src/integrations/<Label>Integration.js`: an `IntegrationBase` subclass whose
|
|
105
|
-
`Definition.modules` wraps the module (an existing file is kept)
|
|
106
|
-
- Registers the class in your app definition: in `index.js` it adds the
|
|
107
|
-
`require` and the first entry of the `integrations` array. When it cannot do
|
|
108
|
-
that safely (no single `integrations: [...]` array literal, or the file does not
|
|
109
|
-
parse) it changes nothing and prints the two lines to add by hand. Older apps
|
|
110
|
-
with a `backend.js` are updated there instead
|
|
111
|
-
- Commits the files it changed (`git commit -- <files>`, so nothing else you have
|
|
112
|
-
staged is included) when the app is in a git repository; otherwise leaves them
|
|
113
|
-
in the working tree
|
|
114
|
-
- Lists the environment variables the module reads (from its `definition.js`)
|
|
115
|
-
that are not in `.env`, and offers to add them when run in a terminal
|
|
51
|
+
- Searches the api-module-library for the specified integration
|
|
52
|
+
- Installs the npm package (@friggframework/api-module-{name})
|
|
53
|
+
- Adds integration to your app definition
|
|
54
|
+
- Configures OAuth flows and webhooks if applicable
|
|
55
|
+
- Creates integration-specific environment variable placeholders
|
|
116
56
|
|
|
117
57
|
**Options:**
|
|
118
|
-
- None
|
|
58
|
+
- None currently (could add `--version`, `--registry` in future)
|
|
119
59
|
|
|
120
|
-
**Example:**
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
60
|
+
**Example Output:**
|
|
61
|
+
```
|
|
62
|
+
🔍 Finding integration module: hubspot
|
|
63
|
+
✓ Found @friggframework/api-module-hubspot@2.0.5
|
|
64
|
+
📦 Installing package...
|
|
65
|
+
✓ Package installed successfully
|
|
66
|
+
🔧 Configuring integration in app definition...
|
|
67
|
+
✓ Integration configured
|
|
68
|
+
⚙️ Next steps:
|
|
69
|
+
1. Set HUBSPOT_CLIENT_ID in your environment
|
|
70
|
+
2. Set HUBSPOT_CLIENT_SECRET in your environment
|
|
71
|
+
3. Run 'frigg start' to test locally
|
|
125
72
|
```
|
|
126
73
|
|
|
127
74
|
---
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-deploy webhook subscription step: add-only by default, prune on request, never fails the deploy.
|
|
3
|
+
*/
|
|
4
|
+
const { reconcileSubscriptionsAfterDeploy } = require('../../../deploy-command/subscriptions-step');
|
|
5
|
+
|
|
6
|
+
describe('reconcileSubscriptionsAfterDeploy', () => {
|
|
7
|
+
let log;
|
|
8
|
+
beforeEach(() => { log = jest.spyOn(console, 'log').mockImplementation(() => {}); });
|
|
9
|
+
afterEach(() => log.mockRestore());
|
|
10
|
+
|
|
11
|
+
const result = { extension: 'hubspot-webhooks', created: ['deal.creation'], removed: [], kept: [], remove: ['company.deletion'] };
|
|
12
|
+
const define = (impl) => ({ reconcileAppSubscriptions: jest.fn(impl || (async () => [result])) });
|
|
13
|
+
|
|
14
|
+
it('runs add-only without a database by default', async () => {
|
|
15
|
+
const d = define();
|
|
16
|
+
const integrations = [function A() {}];
|
|
17
|
+
await reconcileSubscriptionsAfterDeploy({ integrations }, {}, { define: d });
|
|
18
|
+
expect(d.reconcileAppSubscriptions).toHaveBeenCalledWith({ integrations, listInstallations: null, prune: false });
|
|
19
|
+
expect(log.mock.calls.flat().join('\n')).toMatch(/1 not needed by any binding \(kept; --prune-subscriptions removes them\)/);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('prunes with --prune-subscriptions', async () => {
|
|
23
|
+
const d = define();
|
|
24
|
+
await reconcileSubscriptionsAfterDeploy({ integrations: [] }, { pruneSubscriptions: true }, { define: d });
|
|
25
|
+
expect(d.reconcileAppSubscriptions.mock.calls[0][0].prune).toBe(true);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('is skipped with --skip-subscriptions, and a failure never fails the deploy', async () => {
|
|
29
|
+
const d = define();
|
|
30
|
+
expect(await reconcileSubscriptionsAfterDeploy({}, { skipSubscriptions: true }, { define: d })).toBeNull();
|
|
31
|
+
expect(d.reconcileAppSubscriptions).not.toHaveBeenCalled();
|
|
32
|
+
const failing = define(async () => { throw new Error('provider down'); });
|
|
33
|
+
await expect(reconcileSubscriptionsAfterDeploy({ integrations: [] }, {}, { define: failing })).resolves.toBeNull();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -94,22 +94,4 @@ describe('CLI Command: generate-iam', () => {
|
|
|
94
94
|
'arn:aws:kms:*:${AWS::AccountId}:key/*'
|
|
95
95
|
);
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
it("grants the app's own resources, named after Definition.name", async () => {
|
|
99
|
-
jest.doMock(
|
|
100
|
-
mockAppDefinitionPath,
|
|
101
|
-
() => ({ Definition: { name: 'my-app' } }),
|
|
102
|
-
{ virtual: true }
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
await generateIamCommand({});
|
|
106
|
-
|
|
107
|
-
const [, generatedYaml] = fs.writeFile.mock.calls[0];
|
|
108
|
-
expect(generatedYaml).toContain(
|
|
109
|
-
'arn:aws:cloudformation:*:${AWS::AccountId}:stack/*my-app*/*'
|
|
110
|
-
);
|
|
111
|
-
expect(generatedYaml).toContain(
|
|
112
|
-
'arn:aws:lambda:*:${AWS::AccountId}:function:*my-app*'
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
97
|
});
|