@friggframework/devtools 2.0.0--canary.705.f070722.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/frigg-cli/README.md +31 -115
- 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 -22
- 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/checks/config.js +0 -504
- package/frigg-cli/validate-command/checks/integrations.js +0 -274
- package/frigg-cli/validate-command/format-report.js +0 -58
- package/frigg-cli/validate-command/index.js +0 -107
- package/frigg-cli/validate-command/load-app-definition.js +0 -105
- package/frigg-cli/validate-command/schema-issues.js +0 -154
- package/frigg-cli/validate-command/validate-app-definition.js +0 -60
- 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
package/frigg-cli/README.md
CHANGED
|
@@ -10,68 +10,29 @@ The Frigg CLI provides tools for building, deploying, and managing serverless in
|
|
|
10
10
|
|
|
11
11
|
### Core Commands
|
|
12
12
|
|
|
13
|
-
#### `frigg init [
|
|
13
|
+
#### `frigg init [options]`
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
**Status:** To be documented (command may not be merged yet)
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Initialize a new Frigg application with scaffolding and configuration.
|
|
18
18
|
|
|
19
|
+
**Usage:**
|
|
19
20
|
```bash
|
|
20
|
-
frigg init
|
|
21
|
-
frigg init my-app
|
|
22
|
-
frigg init
|
|
23
|
-
frigg init my-app --mode embedded # add to an existing project (./frigg-integration)
|
|
24
|
-
npx @friggframework/devtools init my-app --yes # without a global install
|
|
21
|
+
frigg init
|
|
22
|
+
frigg init my-app
|
|
23
|
+
frigg init --template typescript
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
**What it does:**
|
|
28
|
-
|
|
29
|
-
1. Validates the project name and `--mode`, and checks that the target directory is
|
|
30
|
-
empty (only `.git`, `.gitignore`, `README.md` and `.DS_Store` may exist) before asking anything else
|
|
31
|
-
2. Copies the backend template: `index.js` (app definition, named after the project),
|
|
32
|
-
`infrastructure.js`, `README.md`, `.gitignore`, `.env.example` (also seeded into `.env`)
|
|
33
|
-
3. Writes `package.json` with:
|
|
34
|
-
- scripts: `start` (`frigg start`), `build` (`frigg build`), `deploy` (`frigg deploy`),
|
|
35
|
-
`db:setup` (`frigg db:setup`), `test` (`jest --passWithNoTests`)
|
|
36
|
-
- dependencies: `@friggframework/core`, `@prisma/client`, `prisma`
|
|
37
|
-
- devDependencies: `@friggframework/devtools`, `@friggframework/serverless-plugin`,
|
|
38
|
-
`osls`, and the serverless plugins the composed definition loads
|
|
39
|
-
- Frigg package versions match the devtools that ran `init` (a prerelease is pinned exactly)
|
|
40
|
-
4. Validates the generated app definition against the app-definition schema (problems
|
|
41
|
-
are printed as warnings; `frigg start`, `build` and `deploy` do not validate)
|
|
42
|
-
5. Optionally initializes git and runs `npm install`
|
|
43
|
-
6. Prints next steps. API modules picked in the interactive prompt are not wired in
|
|
44
|
-
automatically; the next steps list a `frigg install <module>` command for each
|
|
45
|
-
|
|
46
|
-
In `embedded` mode the backend is written to `./frigg-integration` inside the target
|
|
47
|
-
directory, which may already contain your application. Git is not initialized.
|
|
27
|
+
- TBD - Full documentation pending implementation merge
|
|
48
28
|
|
|
49
29
|
**Options:**
|
|
30
|
+
- TBD
|
|
50
31
|
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
- `-y, --yes` - Accept the default for every prompt. Implied when stdin is not a TTY
|
|
54
|
-
- `--no-install` - Skip `npm install`
|
|
55
|
-
- `--no-git` - Skip `git init` and the initial commit
|
|
56
|
-
- `-f, --force` - Scaffold into a non-empty directory and overwrite an existing `README.md`/`.gitignore`
|
|
57
|
-
- `-v, --verbose` - Verbose output
|
|
58
|
-
|
|
59
|
-
**Next steps after `init`:**
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
cd my-app
|
|
63
|
-
docker run --name frigg-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:16
|
|
64
|
-
npm run db:setup
|
|
65
|
-
npm start
|
|
66
|
-
```
|
|
32
|
+
**Example Output:**
|
|
33
|
+
- TBD
|
|
67
34
|
|
|
68
|
-
|
|
69
|
-
idle: no VPC, NAT gateway or database cluster (`vpc: { enable: false }`,
|
|
70
|
-
`database.postgres.management: 'external'`), field-level encryption with a per-stage
|
|
71
|
-
KMS key ($1/month, about $3/month after its first two yearly rotations), 14-day log
|
|
72
|
-
retention, and the app connecting to a PostgreSQL you host through `DATABASE_URL`.
|
|
73
|
-
`frigg deploy` reads `DATABASE_URL` from the shell that runs it, not from `.env`. The
|
|
74
|
-
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.
|
|
75
36
|
|
|
76
37
|
---
|
|
77
38
|
|
|
@@ -86,36 +47,28 @@ frigg install salesforce
|
|
|
86
47
|
frigg install stripe
|
|
87
48
|
```
|
|
88
49
|
|
|
89
|
-
Run it in the app directory (the one with `package.json` and `index.js`).
|
|
90
|
-
|
|
91
50
|
**What it does:**
|
|
92
|
-
- Searches
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- Resolves the installed module from the app directory and writes
|
|
98
|
-
`src/integrations/<Label>Integration.js`: an `IntegrationBase` subclass whose
|
|
99
|
-
`Definition.modules` wraps the module (an existing file is kept)
|
|
100
|
-
- Registers the class in your app definition: in `index.js` it adds the
|
|
101
|
-
`require` and the first entry of the `integrations` array. When it cannot do
|
|
102
|
-
that safely (no single `integrations: [...]` array literal, or the file does not
|
|
103
|
-
parse) it changes nothing and prints the two lines to add by hand. Older apps
|
|
104
|
-
with a `backend.js` are updated there instead
|
|
105
|
-
- Commits the files it changed (`git commit -- <files>`, so nothing else you have
|
|
106
|
-
staged is included) when the app is in a git repository; otherwise leaves them
|
|
107
|
-
in the working tree
|
|
108
|
-
- Lists the environment variables the module reads (from its `definition.js`)
|
|
109
|
-
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
|
|
110
56
|
|
|
111
57
|
**Options:**
|
|
112
|
-
- None
|
|
58
|
+
- None currently (could add `--version`, `--registry` in future)
|
|
113
59
|
|
|
114
|
-
**Example:**
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
|
119
72
|
```
|
|
120
73
|
|
|
121
74
|
---
|
|
@@ -157,41 +110,6 @@ Found 5 modules matching "crm"
|
|
|
157
110
|
|
|
158
111
|
---
|
|
159
112
|
|
|
160
|
-
#### `frigg validate [options]`
|
|
161
|
-
|
|
162
|
-
Validate the app definition (`index.js`) before you build or deploy it (ADR-051).
|
|
163
|
-
|
|
164
|
-
**Usage:**
|
|
165
|
-
```bash
|
|
166
|
-
frigg validate # schema + runtime checks
|
|
167
|
-
frigg validate --stage prod # also the stage checks (encryption, deploy-time environment)
|
|
168
|
-
frigg validate --json # machine-readable report for CI
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**What it does:**
|
|
172
|
-
1. Loads `index.js` the way `frigg build` does (current directory, or the nearest `backend/`)
|
|
173
|
-
2. Validates it against the app-definition schema: unknown keys (with "did you mean"), types, and the values the infrastructure builders accept
|
|
174
|
-
3. Checks what the schema cannot: integration classes (static `Definition` with a valid, unique `name`, `version`, `modules`, and API module definitions that pass core's checks), an enabled database, management settings that conflict or lack ids, encryption (`aes` keys in `environment`, KMS key source, stages that never encrypt), a user config with which login works, `'ssm'` entries without `ssm.enable`, and keys that have no effect
|
|
175
|
-
4. Prints each problem with its JSON pointer and a fix; exits `1` when there are errors
|
|
176
|
-
|
|
177
|
-
**Example output:**
|
|
178
|
-
```
|
|
179
|
-
Validating /path/to/backend/index.js (stage: prod)
|
|
180
|
-
error /encrpytion Unknown key "encrpytion": nothing in Frigg reads it.
|
|
181
|
-
fix: Did you mean "encryption"?
|
|
182
|
-
error /database/postgres/management /database/postgres/management is "create-new", which is not an allowed value.
|
|
183
|
-
fix: Use one of: "discover", "managed", "use-existing".
|
|
184
|
-
warning /custom custom is not read by Frigg: it has no effect.
|
|
185
|
-
fix: Remove it.
|
|
186
|
-
✗ 2 error(s), 1 warning(s)
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
`--json` prints `{ valid, source, stage, errors, warnings }`; each issue is `{ severity, code, pointer, message, hint }`.
|
|
190
|
-
|
|
191
|
-
`frigg build` and `frigg deploy` run the same validation first and stop on errors (`--skip-validate` bypasses it, with a loud warning). `frigg start` runs it and only warns. `frigg init` validates the generated app the same way.
|
|
192
|
-
|
|
193
|
-
---
|
|
194
|
-
|
|
195
113
|
#### `frigg start [options]`
|
|
196
114
|
|
|
197
115
|
Start local development server with hot reload.
|
|
@@ -205,7 +123,7 @@ frigg start --frontend
|
|
|
205
123
|
```
|
|
206
124
|
|
|
207
125
|
**What it does:**
|
|
208
|
-
1. Validates DATABASE_URL environment variable
|
|
126
|
+
1. Validates DATABASE_URL environment variable
|
|
209
127
|
2. Detects database type (MongoDB or PostgreSQL)
|
|
210
128
|
3. Checks Prisma client generation status
|
|
211
129
|
4. Tests database connection
|
|
@@ -264,12 +182,10 @@ frigg deploy --region us-west-2
|
|
|
264
182
|
frigg deploy --force
|
|
265
183
|
frigg deploy --skip-env-validation
|
|
266
184
|
frigg deploy --skip-doctor # Skip health check (not recommended)
|
|
267
|
-
frigg deploy --skip-validate # Skip app definition validation (not recommended)
|
|
268
185
|
frigg deploy --no-interactive # CI/CD mode (no prompts, auto-repair safe issues)
|
|
269
186
|
```
|
|
270
187
|
|
|
271
188
|
**What it does:**
|
|
272
|
-
0. **Validates the app definition** (`frigg validate`) and stops on errors, unless `--skip-validate`
|
|
273
189
|
1. **Runs health check** (`frigg doctor`) to detect infrastructure issues
|
|
274
190
|
2. **Auto-repairs safe issues** (or prompts for confirmation in interactive mode)
|
|
275
191
|
3. **Fails if critical issues found** (unless `--skip-doctor` flag used)
|
|
@@ -14,9 +14,6 @@ jest.mock('child_process', () => ({
|
|
|
14
14
|
spawnSync: jest.fn()
|
|
15
15
|
}));
|
|
16
16
|
|
|
17
|
-
// The app definition validation step is tested in validate-command/.
|
|
18
|
-
jest.mock('../../../validate-command', () => ({ preflightValidation: jest.fn(() => true) }));
|
|
19
|
-
|
|
20
17
|
// Require after mocks
|
|
21
18
|
const { spawnSync } = require('child_process');
|
|
22
19
|
const { buildCommand } = require('../../../build-command');
|
|
@@ -10,25 +10,14 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
// Mock dependencies BEFORE requiring modules
|
|
13
|
-
// The app definition validation step is tested in validate-command/.
|
|
14
|
-
jest.mock('../../../validate-command', () => ({ preflightValidation: jest.fn(() => true) }));
|
|
15
|
-
|
|
16
13
|
jest.mock('child_process', () => ({
|
|
17
14
|
spawn: jest.fn()
|
|
18
15
|
}));
|
|
19
16
|
|
|
20
|
-
// Partial mock: only existsSync is stubbed, the rest of fs stays real (a
|
|
21
|
-
// bare { existsSync } mock breaks any dependency that reads fs.constants).
|
|
22
17
|
jest.mock('fs', () => ({
|
|
23
|
-
...jest.requireActual('fs'),
|
|
24
18
|
existsSync: jest.fn()
|
|
25
19
|
}));
|
|
26
20
|
|
|
27
|
-
// The post-deployment health check calls the doctor command (real AWS).
|
|
28
|
-
jest.mock('../../../doctor-command', () => ({
|
|
29
|
-
doctorCommand: jest.fn().mockResolvedValue(undefined)
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
21
|
// Require after mocks
|
|
33
22
|
const { spawn } = require('child_process');
|
|
34
23
|
const fs = require('fs');
|
|
@@ -39,8 +28,6 @@ describe('CLI Command: deploy', () => {
|
|
|
39
28
|
let consoleWarnSpy;
|
|
40
29
|
let consoleErrorSpy;
|
|
41
30
|
let mockChildProcess;
|
|
42
|
-
let childOutcome;
|
|
43
|
-
let exitSpy;
|
|
44
31
|
|
|
45
32
|
beforeEach(() => {
|
|
46
33
|
jest.clearAllMocks();
|
|
@@ -50,18 +37,10 @@ describe('CLI Command: deploy', () => {
|
|
|
50
37
|
consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation();
|
|
51
38
|
consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
|
|
52
39
|
|
|
53
|
-
// Mock child process
|
|
54
|
-
// emits `childOutcome` (default: a clean exit) once its handler is wired.
|
|
55
|
-
childOutcome = { event: 'close', value: 0 };
|
|
40
|
+
// Mock child process
|
|
56
41
|
mockChildProcess = {
|
|
57
|
-
on: jest.fn(
|
|
58
|
-
if (event === childOutcome.event) {
|
|
59
|
-
setImmediate(() => handler(childOutcome.value));
|
|
60
|
-
}
|
|
61
|
-
return mockChildProcess;
|
|
62
|
-
})
|
|
42
|
+
on: jest.fn()
|
|
63
43
|
};
|
|
64
|
-
exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
|
65
44
|
|
|
66
45
|
// Mock successful spawn by default
|
|
67
46
|
spawn.mockReturnValue(mockChildProcess);
|
|
@@ -74,7 +53,6 @@ describe('CLI Command: deploy', () => {
|
|
|
74
53
|
consoleLogSpy.mockRestore();
|
|
75
54
|
consoleWarnSpy.mockRestore();
|
|
76
55
|
consoleErrorSpy.mockRestore();
|
|
77
|
-
exitSpy.mockRestore();
|
|
78
56
|
});
|
|
79
57
|
|
|
80
58
|
describe('Success Cases', () => {
|
|
@@ -300,30 +278,43 @@ describe('CLI Command: deploy', () => {
|
|
|
300
278
|
});
|
|
301
279
|
|
|
302
280
|
describe('Error Handling', () => {
|
|
303
|
-
it('should log
|
|
304
|
-
|
|
281
|
+
it('should log error when spawn fails', async () => {
|
|
282
|
+
const testError = new Error('Spawn failed');
|
|
283
|
+
|
|
284
|
+
await deployCommand({ stage: 'dev' });
|
|
305
285
|
|
|
306
|
-
|
|
286
|
+
// Simulate error event
|
|
287
|
+
const errorHandler = mockChildProcess.on.mock.calls.find(
|
|
288
|
+
call => call[0] === 'error'
|
|
289
|
+
)[1];
|
|
290
|
+
errorHandler(testError);
|
|
307
291
|
|
|
308
292
|
expect(consoleErrorSpy).toHaveBeenCalledWith('Error executing command: Spawn failed');
|
|
309
293
|
});
|
|
310
294
|
|
|
311
|
-
it('should log
|
|
312
|
-
childOutcome = { event: 'close', value: 1 };
|
|
313
|
-
|
|
295
|
+
it('should log when child process exits with non-zero code', async () => {
|
|
314
296
|
await deployCommand({ stage: 'dev' });
|
|
315
297
|
|
|
298
|
+
// Simulate close event with error code
|
|
299
|
+
const closeHandler = mockChildProcess.on.mock.calls.find(
|
|
300
|
+
call => call[0] === 'close'
|
|
301
|
+
)[1];
|
|
302
|
+
closeHandler(1);
|
|
303
|
+
|
|
316
304
|
expect(consoleLogSpy).toHaveBeenCalledWith('Child process exited with code 1');
|
|
317
|
-
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
318
305
|
});
|
|
319
306
|
|
|
320
307
|
it('should NOT log when child process exits with zero code', async () => {
|
|
321
308
|
await deployCommand({ stage: 'dev' });
|
|
322
309
|
|
|
310
|
+
// Simulate close event with success code
|
|
311
|
+
const closeHandler = mockChildProcess.on.mock.calls.find(
|
|
312
|
+
call => call[0] === 'close'
|
|
313
|
+
)[1];
|
|
314
|
+
closeHandler(0);
|
|
315
|
+
|
|
323
316
|
// Should not log exit message for success
|
|
324
317
|
expect(consoleLogSpy).not.toHaveBeenCalledWith('Child process exited with code 0');
|
|
325
|
-
expect(exitSpy).not.toHaveBeenCalled();
|
|
326
|
-
expect(consoleLogSpy).toHaveBeenCalledWith('\n✓ Deployment completed successfully!');
|
|
327
318
|
});
|
|
328
319
|
});
|
|
329
320
|
});
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
* Tests stack listing, selection, and health check orchestration
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
// with the binding babel-plugin-jest-hoist (Jest 30) injects into the module.
|
|
8
|
-
const { describe, test, expect, beforeEach } = require('@jest/globals');
|
|
6
|
+
const { describe, test, expect, jest, beforeEach } = require('@jest/globals');
|
|
9
7
|
|
|
10
8
|
describe('Doctor Command - Stack Listing and Selection', () => {
|
|
11
9
|
let mockCloudFormationClient;
|
|
@@ -140,27 +138,25 @@ describe('Doctor Command - Stack Listing and Selection', () => {
|
|
|
140
138
|
{
|
|
141
139
|
name: 'production-stack',
|
|
142
140
|
status: 'UPDATE_COMPLETE',
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
createdTime: new Date(2024, 0, 15),
|
|
146
|
-
updatedTime: new Date(2024, 9, 20),
|
|
141
|
+
createdTime: new Date('2024-01-15'),
|
|
142
|
+
updatedTime: new Date('2024-10-20'),
|
|
147
143
|
},
|
|
148
144
|
{
|
|
149
145
|
name: 'dev-stack',
|
|
150
146
|
status: 'CREATE_COMPLETE',
|
|
151
|
-
createdTime: new Date(2024
|
|
147
|
+
createdTime: new Date('2024-10-01'),
|
|
152
148
|
updatedTime: null,
|
|
153
149
|
},
|
|
154
150
|
];
|
|
155
151
|
|
|
156
152
|
const expectedChoices = [
|
|
157
153
|
{
|
|
158
|
-
name:
|
|
154
|
+
name: '✓ production-stack (UPDATE_COMPLETE) - Updated: 10/20/2024',
|
|
159
155
|
value: 'production-stack',
|
|
160
156
|
description: 'Status: UPDATE_COMPLETE',
|
|
161
157
|
},
|
|
162
158
|
{
|
|
163
|
-
name:
|
|
159
|
+
name: '✓ dev-stack (CREATE_COMPLETE) - Created: 10/1/2024',
|
|
164
160
|
value: 'dev-stack',
|
|
165
161
|
description: 'Status: CREATE_COMPLETE',
|
|
166
162
|
},
|
|
@@ -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
|
});
|