@friggframework/devtools 2.0.0--canary.702.ef0dc8c.0 → 2.0.0--canary.710.7cfcf12.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.
Files changed (86) hide show
  1. package/README.md +0 -1
  2. package/frigg-cli/README.md +78 -76
  3. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
  4. package/frigg-cli/__tests__/unit/commands/deploy.test.js +30 -27
  5. package/frigg-cli/__tests__/unit/commands/doctor.test.js +10 -6
  6. package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +18 -0
  7. package/frigg-cli/__tests__/unit/commands/init.test.js +688 -0
  8. package/frigg-cli/__tests__/unit/commands/install.test.js +601 -341
  9. package/frigg-cli/__tests__/unit/commands/ui.test.js +31 -30
  10. package/frigg-cli/__tests__/unit/dependencies.test.js +6 -2
  11. package/frigg-cli/build-command/index.js +0 -6
  12. package/frigg-cli/deploy-command/index.js +0 -6
  13. package/frigg-cli/generate-command/index.js +1 -0
  14. package/frigg-cli/generate-iam-command.js +1 -0
  15. package/frigg-cli/index.js +10 -23
  16. package/frigg-cli/init-command/backend-first-handler.js +395 -531
  17. package/frigg-cli/init-command/deployment-modes.js +7 -0
  18. package/frigg-cli/init-command/index.js +82 -35
  19. package/frigg-cli/init-command/safe-path.js +58 -0
  20. package/frigg-cli/init-command/scaffold-dependencies.js +202 -0
  21. package/frigg-cli/install-command/app-definition.js +174 -0
  22. package/frigg-cli/install-command/commit-changes.js +40 -8
  23. package/frigg-cli/install-command/environment-variables.js +15 -0
  24. package/frigg-cli/install-command/index.js +96 -21
  25. package/frigg-cli/install-command/install-package.js +77 -4
  26. package/frigg-cli/install-command/integration-file.js +20 -11
  27. package/frigg-cli/install-command/resolve-module.js +69 -0
  28. package/frigg-cli/install-command/template.js +102 -75
  29. package/frigg-cli/install-command/validate-package.js +36 -4
  30. package/frigg-cli/package.json +1 -1
  31. package/frigg-cli/start-command/index.js +0 -4
  32. package/frigg-cli/start-command/start-command.test.js +0 -3
  33. package/frigg-cli/templates/backend/README.md +267 -0
  34. package/frigg-cli/templates/backend/env.example +20 -0
  35. package/frigg-cli/templates/backend/gitignore +10 -0
  36. package/frigg-cli/templates/backend/index.js +114 -0
  37. package/frigg-cli/templates/backend/infrastructure.js +20 -0
  38. package/frigg-cli/test/init-command.test.js +9 -2
  39. package/infrastructure/__tests__/postgres-config.test.js +241 -835
  40. package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +148 -0
  41. package/infrastructure/__tests__/template-generation.test.js +36 -8
  42. package/infrastructure/create-frigg-infrastructure.js +1 -4
  43. package/infrastructure/docs/POSTGRES-CONFIGURATION.md +118 -60
  44. package/infrastructure/domains/database/aurora-builder.js +13 -2
  45. package/infrastructure/domains/database/aurora-builder.test.js +22 -0
  46. package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +12 -8
  47. package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +19 -7
  48. package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +12 -8
  49. package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +17 -18
  50. package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +12 -2
  51. package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +8 -1
  52. package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +4 -2
  53. package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +10 -0
  54. package/infrastructure/domains/networking/vpc-builder.js +18 -8
  55. package/infrastructure/domains/networking/vpc-builder.test.js +26 -12
  56. package/infrastructure/domains/security/iam-generator.js +112 -5
  57. package/infrastructure/domains/security/iam-generator.test.js +94 -0
  58. package/infrastructure/domains/shared/cloudformation-discovery.test.js +36 -6
  59. package/infrastructure/domains/shared/utilities/base-definition-factory.js +7 -2
  60. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +21 -0
  61. package/infrastructure/infrastructure-composer.test.js +268 -794
  62. package/infrastructure/scripts/build-prisma-layer.test.js +28 -7
  63. package/infrastructure/scripts/build-time-discovery.test.js +18 -3
  64. package/package.json +10 -8
  65. package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
  66. package/frigg-cli/index.test.js +0 -158
  67. package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
  68. package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
  69. package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -326
  70. package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -241
  71. package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
  72. package/frigg-cli/validate-command/checks/config.js +0 -468
  73. package/frigg-cli/validate-command/checks/integrations.js +0 -274
  74. package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
  75. package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
  76. package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
  77. package/frigg-cli/validate-command/format-report.js +0 -60
  78. package/frigg-cli/validate-command/index.js +0 -151
  79. package/frigg-cli/validate-command/load-app-definition.js +0 -93
  80. package/frigg-cli/validate-command/load-module-definition.js +0 -64
  81. package/frigg-cli/validate-command/schema-issues.js +0 -154
  82. package/frigg-cli/validate-command/validate-app-definition.js +0 -60
  83. package/frigg-cli/validate-command/validate-module-definition.js +0 -46
  84. package/infrastructure/app-definition-schema-contract.test.js +0 -607
  85. package/infrastructure/create-frigg-infrastructure.test.js +0 -51
  86. package/infrastructure/integration.test.js +0 -381
@@ -33,6 +33,17 @@ const {
33
33
  } = require('../../../utils/repo-detection');
34
34
  const { uiCommand } = require('../../../ui-command');
35
35
 
36
+ // uiCommand waits 2 s for the dev servers and opens the browser 1 s later.
37
+ // Drive those timers with fake time instead of sleeping for real (the real
38
+ // waits made this suite take ~40 s and tripped the 5 s default timeout).
39
+ const STARTUP_AND_BROWSER_DELAY_MS = 3100;
40
+
41
+ async function runUi(options) {
42
+ const done = uiCommand(options);
43
+ await jest.advanceTimersByTimeAsync(STARTUP_AND_BROWSER_DELAY_MS);
44
+ return done;
45
+ }
46
+
36
47
  describe('CLI Command: ui', () => {
37
48
  let consoleLogSpy;
38
49
  let consoleErrorSpy;
@@ -43,6 +54,7 @@ describe('CLI Command: ui', () => {
43
54
 
44
55
  beforeEach(() => {
45
56
  jest.clearAllMocks();
57
+ jest.useFakeTimers();
46
58
 
47
59
  // Mock console methods
48
60
  consoleLogSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -75,6 +87,7 @@ describe('CLI Command: ui', () => {
75
87
  });
76
88
 
77
89
  afterEach(() => {
90
+ jest.useRealTimers();
78
91
  consoleLogSpy.mockRestore();
79
92
  consoleErrorSpy.mockRestore();
80
93
  processExitSpy.mockRestore();
@@ -84,7 +97,7 @@ describe('CLI Command: ui', () => {
84
97
 
85
98
  describe('Repository Detection', () => {
86
99
  it('should use specified repo path when provided', async () => {
87
- await uiCommand({ repo: '/custom/repo', port: 3001, open: false });
100
+ await runUi({ repo: '/custom/repo', port: 3001, open: false });
88
101
 
89
102
  expect(consoleLogSpy).toHaveBeenCalledWith(
90
103
  expect.stringContaining('Using specified repository')
@@ -92,7 +105,7 @@ describe('CLI Command: ui', () => {
92
105
  });
93
106
 
94
107
  it('should detect current Frigg repository', async () => {
95
- await uiCommand({ port: 3001, open: false });
108
+ await runUi({ port: 3001, open: false });
96
109
 
97
110
  expect(getCurrentRepositoryInfo).toHaveBeenCalled();
98
111
  expect(consoleLogSpy).toHaveBeenCalledWith(
@@ -107,7 +120,7 @@ describe('CLI Command: ui', () => {
107
120
  currentSubPath: 'packages/backend'
108
121
  });
109
122
 
110
- await uiCommand({ port: 3001, open: false });
123
+ await runUi({ port: 3001, open: false });
111
124
 
112
125
  expect(consoleLogSpy).toHaveBeenCalledWith(
113
126
  expect.stringContaining('Currently in subdirectory: packages/backend')
@@ -121,7 +134,7 @@ describe('CLI Command: ui', () => {
121
134
  { path: '/repos/frigg-2', name: 'frigg-2' }
122
135
  ]);
123
136
 
124
- await uiCommand({ port: 3001, open: false });
137
+ await runUi({ port: 3001, open: false });
125
138
 
126
139
  expect(discoverFriggRepositories).toHaveBeenCalled();
127
140
  expect(consoleLogSpy).toHaveBeenCalledWith(
@@ -133,7 +146,7 @@ describe('CLI Command: ui', () => {
133
146
  getCurrentRepositoryInfo.mockResolvedValue(null);
134
147
  discoverFriggRepositories.mockResolvedValue([]);
135
148
 
136
- await uiCommand({ port: 3001, open: false });
149
+ await runUi({ port: 3001, open: false });
137
150
 
138
151
  expect(consoleLogSpy).toHaveBeenCalledWith(
139
152
  expect.stringContaining('No Frigg repositories found')
@@ -144,7 +157,7 @@ describe('CLI Command: ui', () => {
144
157
 
145
158
  describe('Development Mode', () => {
146
159
  it('should spawn backend and frontend in dev mode', async () => {
147
- await uiCommand({ port: 3001, open: false, dev: true });
160
+ await runUi({ port: 3001, open: false, dev: true });
148
161
 
149
162
  expect(mockProcessManager.spawnProcess).toHaveBeenCalledTimes(2);
150
163
  expect(mockProcessManager.spawnProcess).toHaveBeenCalledWith(
@@ -168,7 +181,7 @@ describe('CLI Command: ui', () => {
168
181
  });
169
182
 
170
183
  it('should use default port 3001', async () => {
171
- await uiCommand({ open: false, dev: true });
184
+ await runUi({ open: false, dev: true });
172
185
 
173
186
  expect(mockProcessManager.spawnProcess).toHaveBeenCalledWith(
174
187
  expect.any(String),
@@ -181,7 +194,7 @@ describe('CLI Command: ui', () => {
181
194
  });
182
195
 
183
196
  it('should use custom port when specified', async () => {
184
- await uiCommand({ port: 4000, open: false, dev: true });
197
+ await runUi({ port: 4000, open: false, dev: true });
185
198
 
186
199
  expect(mockProcessManager.spawnProcess).toHaveBeenCalledWith(
187
200
  expect.any(String),
@@ -197,10 +210,7 @@ describe('CLI Command: ui', () => {
197
210
  });
198
211
 
199
212
  it('should print status with correct URLs', async () => {
200
- await uiCommand({ port: 3001, open: false, dev: true });
201
-
202
- // Wait for startup delay (testing async behavior, not mocks)
203
- await new Promise(resolve => setTimeout(resolve, 2100));
213
+ await runUi({ port: 3001, open: false, dev: true });
204
214
 
205
215
  // Verify printStatus called with exact URLs
206
216
  expect(mockProcessManager.printStatus).toHaveBeenCalledWith(
@@ -211,20 +221,14 @@ describe('CLI Command: ui', () => {
211
221
  });
212
222
 
213
223
  it('should open browser when open=true', async () => {
214
- await uiCommand({ port: 3001, open: true, dev: true });
215
-
216
- // Wait for startup + browser delay (testing async behavior, not mocks)
217
- await new Promise(resolve => setTimeout(resolve, 3100));
224
+ await runUi({ port: 3001, open: true, dev: true });
218
225
 
219
226
  // Verify browser opened with correct URL
220
227
  expect(open).toHaveBeenCalledWith('http://localhost:5173');
221
228
  });
222
229
 
223
230
  it('should NOT open browser when open=false', async () => {
224
- await uiCommand({ port: 3001, open: false, dev: true });
225
-
226
- // Wait for startup delay (testing async behavior, not mocks)
227
- await new Promise(resolve => setTimeout(resolve, 3100));
231
+ await runUi({ port: 3001, open: false, dev: true });
228
232
 
229
233
  // Verify browser was not opened
230
234
  expect(open).not.toHaveBeenCalled();
@@ -237,7 +241,7 @@ describe('CLI Command: ui', () => {
237
241
  currentSubPath: null
238
242
  });
239
243
 
240
- await uiCommand({ port: 3001, open: false, dev: true });
244
+ await runUi({ port: 3001, open: false, dev: true });
241
245
 
242
246
  expect(mockProcessManager.spawnProcess).toHaveBeenCalledWith(
243
247
  expect.any(String),
@@ -252,7 +256,7 @@ describe('CLI Command: ui', () => {
252
256
  });
253
257
 
254
258
  it('should set REPOSITORY_INFO as JSON string with correct structure', async () => {
255
- await uiCommand({ port: 3001, open: false, dev: true });
259
+ await runUi({ port: 3001, open: false, dev: true });
256
260
 
257
261
  const call = mockProcessManager.spawnProcess.mock.calls[0];
258
262
  const env = call[3].env;
@@ -275,7 +279,7 @@ describe('CLI Command: ui', () => {
275
279
  { path: '/repos/frigg-1', name: 'frigg-1' }
276
280
  ]);
277
281
 
278
- await uiCommand({ port: 3001, open: false, dev: true });
282
+ await runUi({ port: 3001, open: false, dev: true });
279
283
 
280
284
  const call = mockProcessManager.spawnProcess.mock.calls[0];
281
285
  const env = call[3].env;
@@ -299,7 +303,7 @@ describe('CLI Command: ui', () => {
299
303
  throw error;
300
304
  });
301
305
 
302
- await uiCommand({ port: 3001, open: false, dev: true });
306
+ await runUi({ port: 3001, open: false, dev: true });
303
307
 
304
308
  expect(consoleErrorSpy).toHaveBeenCalledWith(
305
309
  expect.stringContaining('Failed to start Management UI'),
@@ -316,7 +320,7 @@ describe('CLI Command: ui', () => {
316
320
  throw new Error('Generic startup error');
317
321
  });
318
322
 
319
- await uiCommand({ port: 3001, open: false, dev: true });
323
+ await runUi({ port: 3001, open: false, dev: true });
320
324
 
321
325
  expect(consoleErrorSpy).toHaveBeenCalledWith(
322
326
  expect.stringContaining('Failed to start Management UI'),
@@ -328,16 +332,13 @@ describe('CLI Command: ui', () => {
328
332
 
329
333
  describe('Process Management', () => {
330
334
  it('should create ProcessManager instance', async () => {
331
- await uiCommand({ port: 3001, open: false, dev: true });
335
+ await runUi({ port: 3001, open: false, dev: true });
332
336
 
333
337
  expect(ProcessManager).toHaveBeenCalled();
334
338
  });
335
339
 
336
340
  it('should keep process running with stdin.resume', async () => {
337
- await uiCommand({ port: 3001, open: false, dev: true });
338
-
339
- // Wait for startup delay (testing async behavior, not mocks)
340
- await new Promise(resolve => setTimeout(resolve, 2100));
341
+ await runUi({ port: 3001, open: false, dev: true });
341
342
 
342
343
  // Verify stdin.resume called to keep process alive
343
344
  expect(stdinResumeSpy).toHaveBeenCalled();
@@ -51,8 +51,12 @@ describe('frigg-cli dependencies', () => {
51
51
  expect(packageJson.dependencies.commander).toBeDefined();
52
52
  });
53
53
 
54
- it('should have @friggframework/devtools for infrastructure', () => {
55
- expect(packageJson.dependencies['@friggframework/devtools']).toBeDefined();
54
+ // frigg-cli ships inside @friggframework/devtools (14236100), so
55
+ // devtools is a peer, not a runtime dependency — a hard dependency
56
+ // would make the package depend on itself.
57
+ it('should declare @friggframework/devtools as a peer dependency for infrastructure', () => {
58
+ expect(packageJson.peerDependencies['@friggframework/devtools']).toBeDefined();
59
+ expect(packageJson.dependencies['@friggframework/devtools']).toBeUndefined();
56
60
  });
57
61
  });
58
62
 
@@ -1,15 +1,9 @@
1
1
  const { spawnSync } = require('child_process');
2
2
  const path = require('path');
3
- const { preflightValidation } = require('../validate-command');
4
3
 
5
4
  async function buildCommand(options) {
6
5
  console.log('Building the serverless application...');
7
6
 
8
- // Validate the app definition first (ADR-051); errors stop the build.
9
- if (!preflightValidation({ command: 'build', options, failOnErrors: true })) {
10
- return;
11
- }
12
-
13
7
  // Suppress AWS SDK warning message about maintenance mode
14
8
  process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = '1';
15
9
 
@@ -4,7 +4,6 @@ const fs = require('fs');
4
4
 
5
5
  // Import doctor command for post-deployment health check
6
6
  const { doctorCommand } = require('../doctor-command');
7
- const { preflightValidation } = require('../validate-command');
8
7
 
9
8
  // Configuration constants
10
9
  const PATHS = {
@@ -313,11 +312,6 @@ async function pushOffloadedParametersOrAbort(appDefinition, options) {
313
312
  async function deployCommand(options) {
314
313
  console.log('Deploying the serverless application...');
315
314
 
316
- // Validate the app definition first (ADR-051); errors stop the deploy.
317
- if (!preflightValidation({ command: 'deploy', options, failOnErrors: true })) {
318
- return;
319
- }
320
-
321
315
  const appDefinition = loadAppDefinition();
322
316
  const environment = validateAndBuildEnvironment(appDefinition, options);
323
317
 
@@ -118,6 +118,7 @@ async function generateCommand(options = {}) {
118
118
  if (options.format === 'cloudformation') {
119
119
  template = await generateCloudFormationTemplate({
120
120
  appName,
121
+ serviceName: appDefinition.name || 'create-frigg-app',
121
122
  features,
122
123
  userPrefix: options.user || 'frigg-deployment-user',
123
124
  stackName: options.stackName || 'frigg-deployment-iam',
@@ -62,6 +62,7 @@ async function generateIamCommand(options = {}) {
62
62
  // Use the summary already extracted above (line 44)
63
63
  const cloudFormationYaml = generateIAMCloudFormation({
64
64
  appName: summary.appName,
65
+ serviceName: summary.serviceName,
65
66
  features: summary.features,
66
67
  userPrefix: deploymentUserName,
67
68
  stackName,
@@ -87,16 +87,20 @@ const { doctorCommand } = require('./doctor-command');
87
87
  const { repairCommand } = require('./repair-command');
88
88
  const { authCommand } = require('./auth-command');
89
89
  const { ssmPushCommand } = require('./ssm-command');
90
- const { validateCommand } = require('./validate-command');
91
90
 
92
91
  const program = new Command();
93
92
 
94
93
  program
95
- .command('init [templateName]')
94
+ .command('init [projectName]')
96
95
  .description('Initialize a new Frigg application')
97
- .option('-t, --template <template>', 'template to use', 'backend-only')
98
- .option('-n, --name <name>', 'project name')
99
- .option('-d, --directory <directory>', 'target directory')
96
+ .option('-n, --name <name>', 'project name (alternative to the positional argument)')
97
+ .option('-m, --mode <mode>', 'deployment mode: standalone or embedded')
98
+ .option('-y, --yes', 'accept the default for every prompt (implied when stdin is not a TTY)')
99
+ .option('--no-install', 'skip installing dependencies')
100
+ .option('--no-git', 'skip initializing a git repository')
101
+ .option('-f, --force', 'scaffold into a non-empty directory and overwrite README.md')
102
+ .option('-v, --verbose', 'enable verbose output')
103
+ .option('-t, --template <template>', 'legacy template (no longer supported)')
100
104
  .action(initCommand);
101
105
 
102
106
  program
@@ -109,30 +113,14 @@ program
109
113
  .description('Run the backend and optional frontend')
110
114
  .option('-s, --stage <stage>', 'deployment stage', 'dev')
111
115
  .option('-v, --verbose', 'enable verbose output')
112
- .option('--skip-validate', 'skip app definition validation')
113
116
  .action(startCommand);
114
117
 
115
- program
116
- .command('validate [target]')
117
- .description(
118
- 'Validate the app definition (index.js), or an API module Definition with --module / module'
119
- )
120
- .option(
121
- '--module',
122
- 'validate an API module Definition in the current directory (also: frigg validate module)'
123
- )
124
- .option('-s, --stage <stage>', 'also run the checks for this stage (encryption, deploy-time environment)')
125
- .option('--json', 'print the report as JSON')
126
- .option('-v, --verbose', 'enable verbose output')
127
- .action((target, options) => validateCommand({ ...options, target }));
128
-
129
118
  program
130
119
  .command('build')
131
120
  .description('Build the serverless application')
132
121
  .option('-s, --stage <stage>', 'deployment stage', 'dev')
133
122
  .option('-v, --verbose', 'enable verbose output')
134
123
  .option('-p, --production', 'build for production (enables AWS discovery)')
135
- .option('--skip-validate', 'skip app definition validation (not recommended)')
136
124
  .action(buildCommand);
137
125
 
138
126
  program
@@ -142,7 +130,6 @@ program
142
130
  .option('-v, --verbose', 'enable verbose output')
143
131
  .option('-f, --force', 'force deployment (bypasses caching for layers and functions)')
144
132
  .option('--skip-doctor', 'skip post-deployment health check')
145
- .option('--skip-validate', 'skip app definition validation (not recommended)')
146
133
  .action(deployCommand);
147
134
 
148
135
  program
@@ -238,4 +225,4 @@ authProgram
238
225
 
239
226
  program.parse(process.argv);
240
227
 
241
- module.exports = { initCommand, installCommand, startCommand, buildCommand, deployCommand, validateCommand, generateIamCommand, uiCommand, dbSetupCommand, doctorCommand, repairCommand, authCommand, ssmPushCommand };
228
+ module.exports = { initCommand, installCommand, startCommand, buildCommand, deployCommand, generateIamCommand, uiCommand, dbSetupCommand, doctorCommand, repairCommand, authCommand, ssmPushCommand };