@friggframework/devtools 2.0.0--canary.522.923dfae.0 → 2.0.0--canary.540.c5ef83f.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 (119) hide show
  1. package/frigg-cli/README.md +1 -1
  2. package/frigg-cli/__tests__/unit/commands/doctor.test.js +2 -0
  3. package/frigg-cli/__tests__/unit/commands/install.test.js +19 -23
  4. package/frigg-cli/__tests__/unit/dependencies.test.js +2 -2
  5. package/frigg-cli/doctor-command/index.js +16 -17
  6. package/frigg-cli/index.js +6 -21
  7. package/frigg-cli/index.test.js +2 -7
  8. package/frigg-cli/init-command/backend-first-handler.js +42 -124
  9. package/frigg-cli/init-command/index.js +1 -2
  10. package/frigg-cli/init-command/template-handler.js +3 -13
  11. package/frigg-cli/install-command/backend-js.js +3 -3
  12. package/frigg-cli/install-command/environment-variables.js +19 -16
  13. package/frigg-cli/install-command/environment-variables.test.js +13 -12
  14. package/frigg-cli/install-command/index.js +9 -14
  15. package/frigg-cli/install-command/integration-file.js +3 -3
  16. package/frigg-cli/install-command/logger.js +12 -0
  17. package/frigg-cli/install-command/validate-package.js +9 -5
  18. package/frigg-cli/jest.config.js +1 -4
  19. package/frigg-cli/repair-command/index.js +128 -101
  20. package/frigg-cli/start-command/index.js +2 -246
  21. package/frigg-cli/ui-command/index.js +36 -58
  22. package/frigg-cli/utils/repo-detection.js +37 -85
  23. package/infrastructure/docs/iam-policy-templates.md +1 -1
  24. package/infrastructure/domains/networking/vpc-builder.test.js +4 -2
  25. package/infrastructure/domains/networking/vpc-resolver.test.js +1 -1
  26. package/infrastructure/domains/shared/cloudformation-discovery.test.js +7 -4
  27. package/infrastructure/domains/shared/resource-discovery.js +5 -5
  28. package/infrastructure/domains/shared/types/app-definition.js +0 -21
  29. package/infrastructure/domains/shared/types/discovery-result.test.js +1 -1
  30. package/infrastructure/domains/shared/utilities/base-definition-factory.js +1 -10
  31. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +2 -2
  32. package/infrastructure/infrastructure-composer.test.js +2 -2
  33. package/management-ui/README.md +109 -245
  34. package/package.json +7 -8
  35. package/frigg-cli/__tests__/application/use-cases/AddApiModuleToIntegrationUseCase.test.js +0 -326
  36. package/frigg-cli/__tests__/application/use-cases/CreateApiModuleUseCase.test.js +0 -337
  37. package/frigg-cli/__tests__/domain/entities/ApiModule.test.js +0 -373
  38. package/frigg-cli/__tests__/domain/entities/AppDefinition.test.js +0 -313
  39. package/frigg-cli/__tests__/domain/services/IntegrationValidator.test.js +0 -269
  40. package/frigg-cli/__tests__/domain/value-objects/IntegrationName.test.js +0 -82
  41. package/frigg-cli/__tests__/infrastructure/adapters/IntegrationJsUpdater.test.js +0 -408
  42. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemApiModuleRepository.test.js +0 -583
  43. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemAppDefinitionRepository.test.js +0 -314
  44. package/frigg-cli/__tests__/infrastructure/repositories/FileSystemIntegrationRepository.test.js +0 -383
  45. package/frigg-cli/__tests__/unit/commands/init.test.js +0 -406
  46. package/frigg-cli/__tests__/unit/commands/repair.test.js +0 -275
  47. package/frigg-cli/__tests__/unit/start-command/application/RunPreflightChecksUseCase.test.js +0 -411
  48. package/frigg-cli/__tests__/unit/start-command/infrastructure/DatabaseAdapter.test.js +0 -405
  49. package/frigg-cli/__tests__/unit/start-command/infrastructure/DockerAdapter.test.js +0 -496
  50. package/frigg-cli/__tests__/unit/start-command/presentation/InteractivePromptAdapter.test.js +0 -474
  51. package/frigg-cli/__tests__/unit/utils/output.test.js +0 -196
  52. package/frigg-cli/application/use-cases/AddApiModuleToIntegrationUseCase.js +0 -93
  53. package/frigg-cli/application/use-cases/CreateApiModuleUseCase.js +0 -93
  54. package/frigg-cli/application/use-cases/CreateIntegrationUseCase.js +0 -103
  55. package/frigg-cli/container.js +0 -172
  56. package/frigg-cli/docs/OUTPUT_MIGRATION_GUIDE.md +0 -286
  57. package/frigg-cli/domain/entities/ApiModule.js +0 -272
  58. package/frigg-cli/domain/entities/AppDefinition.js +0 -227
  59. package/frigg-cli/domain/entities/Integration.js +0 -198
  60. package/frigg-cli/domain/exceptions/DomainException.js +0 -24
  61. package/frigg-cli/domain/ports/IApiModuleRepository.js +0 -53
  62. package/frigg-cli/domain/ports/IAppDefinitionRepository.js +0 -43
  63. package/frigg-cli/domain/ports/IIntegrationRepository.js +0 -61
  64. package/frigg-cli/domain/services/IntegrationValidator.js +0 -185
  65. package/frigg-cli/domain/value-objects/IntegrationId.js +0 -42
  66. package/frigg-cli/domain/value-objects/IntegrationName.js +0 -60
  67. package/frigg-cli/domain/value-objects/SemanticVersion.js +0 -70
  68. package/frigg-cli/infrastructure/UnitOfWork.js +0 -46
  69. package/frigg-cli/infrastructure/adapters/BackendJsUpdater.js +0 -197
  70. package/frigg-cli/infrastructure/adapters/FileSystemAdapter.js +0 -224
  71. package/frigg-cli/infrastructure/adapters/IntegrationJsUpdater.js +0 -249
  72. package/frigg-cli/infrastructure/adapters/SchemaValidator.js +0 -92
  73. package/frigg-cli/infrastructure/repositories/FileSystemApiModuleRepository.js +0 -373
  74. package/frigg-cli/infrastructure/repositories/FileSystemAppDefinitionRepository.js +0 -116
  75. package/frigg-cli/infrastructure/repositories/FileSystemIntegrationRepository.js +0 -277
  76. package/frigg-cli/package-lock.json +0 -16226
  77. package/frigg-cli/start-command/application/RunPreflightChecksUseCase.js +0 -376
  78. package/frigg-cli/start-command/infrastructure/DatabaseAdapter.js +0 -591
  79. package/frigg-cli/start-command/infrastructure/DockerAdapter.js +0 -306
  80. package/frigg-cli/start-command/presentation/InteractivePromptAdapter.js +0 -329
  81. package/frigg-cli/templates/backend/.env.example +0 -62
  82. package/frigg-cli/templates/backend/.eslintrc.json +0 -12
  83. package/frigg-cli/templates/backend/.prettierrc +0 -6
  84. package/frigg-cli/templates/backend/docker-compose.yml +0 -22
  85. package/frigg-cli/templates/backend/index.js +0 -96
  86. package/frigg-cli/templates/backend/infrastructure.js +0 -12
  87. package/frigg-cli/templates/backend/jest.config.js +0 -17
  88. package/frigg-cli/templates/backend/package.json +0 -50
  89. package/frigg-cli/templates/backend/src/api-modules/.gitkeep +0 -10
  90. package/frigg-cli/templates/backend/src/base/.gitkeep +0 -7
  91. package/frigg-cli/templates/backend/src/integrations/.gitkeep +0 -10
  92. package/frigg-cli/templates/backend/src/integrations/ExampleIntegration.js +0 -65
  93. package/frigg-cli/templates/backend/src/utils/.gitkeep +0 -7
  94. package/frigg-cli/templates/backend/test/setup.js +0 -30
  95. package/frigg-cli/templates/backend/ui-extensions/.gitkeep +0 -0
  96. package/frigg-cli/templates/backend/ui-extensions/README.md +0 -77
  97. package/frigg-cli/utils/__tests__/repo-detection.test.js +0 -436
  98. package/frigg-cli/utils/output.js +0 -382
  99. package/frigg-cli/validate-command/__tests__/adapters/validate-command.test.js +0 -205
  100. package/frigg-cli/validate-command/__tests__/application/validate-app-use-case.test.js +0 -104
  101. package/frigg-cli/validate-command/__tests__/domain/fix-suggestion.test.js +0 -153
  102. package/frigg-cli/validate-command/__tests__/domain/validation-error.test.js +0 -162
  103. package/frigg-cli/validate-command/__tests__/domain/validation-result.test.js +0 -152
  104. package/frigg-cli/validate-command/__tests__/infrastructure/api-module-validator.test.js +0 -332
  105. package/frigg-cli/validate-command/__tests__/infrastructure/app-definition-validator.test.js +0 -191
  106. package/frigg-cli/validate-command/__tests__/infrastructure/integration-class-validator.test.js +0 -146
  107. package/frigg-cli/validate-command/__tests__/infrastructure/template-validation.test.js +0 -155
  108. package/frigg-cli/validate-command/adapters/cli/validate-command.js +0 -199
  109. package/frigg-cli/validate-command/application/use-cases/validate-app-use-case.js +0 -35
  110. package/frigg-cli/validate-command/domain/entities/validation-result.js +0 -74
  111. package/frigg-cli/validate-command/domain/value-objects/fix-suggestion.js +0 -74
  112. package/frigg-cli/validate-command/domain/value-objects/validation-error.js +0 -68
  113. package/frigg-cli/validate-command/infrastructure/validators/api-module-validator.js +0 -181
  114. package/frigg-cli/validate-command/infrastructure/validators/app-definition-validator.js +0 -128
  115. package/frigg-cli/validate-command/infrastructure/validators/integration-class-validator.js +0 -113
  116. package/infrastructure/domains/admin-scripts/admin-script-builder.js +0 -200
  117. package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -499
  118. package/infrastructure/domains/admin-scripts/index.js +0 -5
  119. package/infrastructure/jest.config.js +0 -16
@@ -1,376 +0,0 @@
1
- /**
2
- * RunPreflightChecksUseCase - Orchestrates pre-flight checks before starting Frigg
3
- *
4
- * Application Layer - Use Case that coordinates multiple infrastructure adapters
5
- * to verify the environment is ready for Frigg to start.
6
- *
7
- * Checks performed:
8
- * 1. DATABASE_URL environment variable exists
9
- * 2. Docker is installed
10
- * 3. Docker daemon is running
11
- * 4. Database is reachable
12
- */
13
-
14
- class RunPreflightChecksUseCase {
15
- constructor({ dockerAdapter, databaseAdapter }) {
16
- this.dockerAdapter = dockerAdapter;
17
- this.databaseAdapter = databaseAdapter;
18
- }
19
-
20
- /**
21
- * Execute all pre-flight checks
22
- * @param {object} options - Options
23
- * @param {string} options.projectPath - Path to the Frigg project
24
- * @returns {Promise<{allPassed: boolean, checks: Array}>}
25
- */
26
- async execute({ projectPath }) {
27
- const checks = [];
28
-
29
- // Check 1: DATABASE_URL exists
30
- const dbUrlCheck = this._checkDatabaseUrl();
31
- checks.push(dbUrlCheck);
32
-
33
- // Short-circuit if DATABASE_URL is missing
34
- if (dbUrlCheck.status === 'failed') {
35
- return { allPassed: false, checks };
36
- }
37
-
38
- // Check 2: Docker is installed
39
- const dockerInstalledCheck = await this._checkDockerInstalled();
40
- checks.push(dockerInstalledCheck);
41
-
42
- // Short-circuit if Docker is not installed
43
- if (dockerInstalledCheck.status === 'failed') {
44
- return { allPassed: false, checks };
45
- }
46
-
47
- // Check 3: Docker is running
48
- const dockerRunningCheck = await this._checkDockerRunning();
49
- checks.push(dockerRunningCheck);
50
-
51
- // Short-circuit if Docker is not running
52
- if (dockerRunningCheck.status === 'failed') {
53
- return { allPassed: false, checks };
54
- }
55
-
56
- // Check 4: Database is reachable
57
- const dbReachableCheck = await this._checkDatabaseReachable(projectPath);
58
- checks.push(dbReachableCheck);
59
-
60
- // Short-circuit if database is not reachable
61
- if (dbReachableCheck.status === 'failed') {
62
- return { allPassed: false, checks };
63
- }
64
-
65
- // Check 5: PostgreSQL migrations (only for PostgreSQL databases)
66
- const dbType = this.databaseAdapter.getDatabaseType(process.env.DATABASE_URL);
67
- if (dbType === 'postgresql') {
68
- const migrationCheck = await this._checkPostgresMigrations(projectPath);
69
- checks.push(migrationCheck);
70
- }
71
-
72
- // Check 6: LocalStack is reachable (only if AWS_ENDPOINT is configured for local)
73
- const localstackCheck = await this._checkLocalStackReachable(projectPath);
74
- if (localstackCheck) {
75
- checks.push(localstackCheck);
76
- }
77
-
78
- const allPassed = checks.every(check => check.status === 'passed');
79
- return { allPassed, checks };
80
- }
81
-
82
- /**
83
- * Check if DATABASE_URL environment variable is set
84
- * @returns {object} Check result
85
- */
86
- _checkDatabaseUrl() {
87
- const databaseUrl = process.env.DATABASE_URL;
88
-
89
- if (!databaseUrl || databaseUrl.trim() === '') {
90
- return {
91
- name: 'database_url',
92
- status: 'failed',
93
- message: 'DATABASE_URL environment variable is not set',
94
- canResolve: true,
95
- resolution: {
96
- type: 'create_env',
97
- prompt: 'Would you like to create a .env file from the template?',
98
- action: 'copy_env_template'
99
- }
100
- };
101
- }
102
-
103
- const dbType = this.databaseAdapter.getDatabaseType(databaseUrl);
104
-
105
- return {
106
- name: 'database_url',
107
- status: 'passed',
108
- message: `DATABASE_URL is configured (${dbType || 'unknown'} database)`,
109
- canResolve: false,
110
- resolution: null
111
- };
112
- }
113
-
114
- /**
115
- * Check if Docker is installed
116
- * @returns {Promise<object>} Check result
117
- */
118
- async _checkDockerInstalled() {
119
- const isInstalled = await this.dockerAdapter.isDockerInstalled();
120
-
121
- if (!isInstalled) {
122
- return {
123
- name: 'docker_installed',
124
- status: 'failed',
125
- message: 'Docker is not installed',
126
- canResolve: false,
127
- resolution: {
128
- type: 'manual',
129
- instructions: 'Please install Docker Desktop from https://www.docker.com/products/docker-desktop'
130
- }
131
- };
132
- }
133
-
134
- return {
135
- name: 'docker_installed',
136
- status: 'passed',
137
- message: 'Docker is installed',
138
- canResolve: false,
139
- resolution: null
140
- };
141
- }
142
-
143
- /**
144
- * Check if Docker daemon is running
145
- * @returns {Promise<object>} Check result
146
- */
147
- async _checkDockerRunning() {
148
- const isRunning = await this.dockerAdapter.isDockerRunning();
149
-
150
- if (!isRunning) {
151
- return {
152
- name: 'docker_running',
153
- status: 'failed',
154
- message: 'Docker is not running. Please start Docker Desktop.',
155
- canResolve: true,
156
- resolution: {
157
- type: 'start_docker',
158
- prompt: 'Would you like to start Docker Desktop?',
159
- action: 'start_docker_desktop'
160
- }
161
- };
162
- }
163
-
164
- return {
165
- name: 'docker_running',
166
- status: 'passed',
167
- message: 'Docker daemon is running',
168
- canResolve: false,
169
- resolution: null
170
- };
171
- }
172
-
173
- /**
174
- * Check if database is reachable
175
- * @param {string} projectPath - Path to project
176
- * @returns {Promise<object>} Check result
177
- */
178
- async _checkDatabaseReachable(projectPath) {
179
- const databaseUrl = process.env.DATABASE_URL;
180
- const result = await this.databaseAdapter.isDatabaseReachable(databaseUrl);
181
-
182
- if (!result.reachable) {
183
- // Check for docker-compose file
184
- const composePath = await this.dockerAdapter.findDockerComposeFile(projectPath);
185
-
186
- if (composePath) {
187
- return {
188
- name: 'database_reachable',
189
- status: 'failed',
190
- message: `Database is not reachable: ${result.error || 'Connection failed'}`,
191
- canResolve: true,
192
- resolution: {
193
- type: 'start_docker_compose',
194
- prompt: 'Would you like to start the database using docker-compose?',
195
- composePath,
196
- action: 'docker_compose_up'
197
- }
198
- };
199
- }
200
-
201
- return {
202
- name: 'database_reachable',
203
- status: 'failed',
204
- message: `Database is not reachable: ${result.error || 'Connection failed'}`,
205
- canResolve: false,
206
- resolution: {
207
- type: 'manual',
208
- instructions: 'Please ensure your database server is running and accessible at the configured DATABASE_URL.'
209
- }
210
- };
211
- }
212
-
213
- return {
214
- name: 'database_reachable',
215
- status: 'passed',
216
- message: `Database is reachable at ${result.host}:${result.port}`,
217
- canResolve: false,
218
- resolution: null
219
- };
220
- }
221
-
222
- /**
223
- * Check if LocalStack is reachable (for local development)
224
- *
225
- * The serverless plugin defaults to http://localhost:4566 for LocalStack
226
- * even if AWS_ENDPOINT isn't set. So we check LocalStack in local dev
227
- * mode by default.
228
- *
229
- * @param {string} projectPath - Path to project
230
- * @returns {Promise<object|null>} Check result, or null if LocalStack check is not applicable
231
- */
232
- async _checkLocalStackReachable(projectPath) {
233
- // Default LocalStack endpoint - same as serverless plugin default
234
- const defaultEndpoint = 'http://localhost:4566';
235
- const awsEndpoint = process.env.AWS_ENDPOINT;
236
-
237
- // If AWS_ENDPOINT is set to a non-local address, skip LocalStack check
238
- if (awsEndpoint) {
239
- const isLocalEndpoint = awsEndpoint.includes('localhost') ||
240
- awsEndpoint.includes('127.0.0.1') ||
241
- awsEndpoint.includes('localstack');
242
-
243
- if (!isLocalEndpoint) {
244
- // Using real AWS, not LocalStack
245
- return null;
246
- }
247
- }
248
-
249
- // Use configured endpoint or default LocalStack endpoint
250
- const endpoint = awsEndpoint || defaultEndpoint;
251
-
252
- // Try to reach LocalStack health endpoint
253
- const result = await this.dockerAdapter.waitForLocalStack({
254
- maxAttempts: 1, // Just one check, not waiting
255
- intervalMs: 0,
256
- endpoint: endpoint
257
- });
258
-
259
- if (!result.ready) {
260
- // Check for docker-compose file
261
- const composePath = await this.dockerAdapter.findDockerComposeFile(projectPath);
262
-
263
- if (composePath) {
264
- return {
265
- name: 'localstack_reachable',
266
- status: 'failed',
267
- message: `LocalStack is not reachable at ${endpoint}`,
268
- canResolve: true,
269
- resolution: {
270
- type: 'start_docker_compose',
271
- prompt: 'Would you like to start LocalStack using docker-compose?',
272
- composePath,
273
- action: 'docker_compose_up'
274
- }
275
- };
276
- }
277
-
278
- return {
279
- name: 'localstack_reachable',
280
- status: 'failed',
281
- message: `LocalStack is not reachable at ${endpoint}`,
282
- canResolve: false,
283
- resolution: {
284
- type: 'manual',
285
- instructions: `Please ensure LocalStack is running at ${endpoint}. You can start it with: docker-compose up -d`
286
- }
287
- };
288
- }
289
-
290
- return {
291
- name: 'localstack_reachable',
292
- status: 'passed',
293
- message: `LocalStack is reachable at ${endpoint}`,
294
- canResolve: false,
295
- resolution: null
296
- };
297
- }
298
-
299
- /**
300
- * Check if PostgreSQL migrations have been applied
301
- * @param {string} projectPath - Path to project
302
- * @returns {Promise<object>} Check result
303
- */
304
- async _checkPostgresMigrations(projectPath) {
305
- const result = await this.databaseAdapter.checkMigrationStatus(projectPath);
306
-
307
- if (result.migrated) {
308
- return {
309
- name: 'postgres_migrations',
310
- status: 'passed',
311
- message: 'PostgreSQL database schema is up to date',
312
- canResolve: false,
313
- resolution: null
314
- };
315
- }
316
-
317
- // Handle Prisma not installed case
318
- if (result.needsInstall) {
319
- return {
320
- name: 'postgres_migrations',
321
- status: 'failed',
322
- message: result.error,
323
- canResolve: false,
324
- resolution: {
325
- type: 'manual',
326
- instructions: 'Run "npm install" or "pnpm install" to properly install Prisma, then try again.'
327
- }
328
- };
329
- }
330
-
331
- // Determine if this is auto-resolvable
332
- const canResolve = result.needsSetup || result.pendingMigrations?.length > 0;
333
-
334
- let message = result.error || 'PostgreSQL migrations have not been applied';
335
- if (result.pendingMigrations?.length > 0) {
336
- message = `${result.pendingMigrations.length} pending migration(s) need to be applied`;
337
- }
338
-
339
- return {
340
- name: 'postgres_migrations',
341
- status: 'failed',
342
- message,
343
- canResolve,
344
- resolution: canResolve ? {
345
- type: 'run_migrations',
346
- prompt: 'Would you like to run database migrations now?',
347
- action: 'prisma_migrate',
348
- pendingMigrations: result.pendingMigrations,
349
- needsSetup: result.needsSetup
350
- } : {
351
- type: 'manual',
352
- instructions: 'Run "frigg db:setup" or "npx prisma migrate dev" to apply database migrations.'
353
- }
354
- };
355
- }
356
-
357
- /**
358
- * Get only the failed checks from a result
359
- * @param {object} result - Result from execute()
360
- * @returns {Array} Failed checks
361
- */
362
- getFailedChecks(result) {
363
- return result.checks.filter(check => check.status === 'failed');
364
- }
365
-
366
- /**
367
- * Get only the checks that can be auto-resolved
368
- * @param {object} result - Result from execute()
369
- * @returns {Array} Resolvable failed checks
370
- */
371
- getResolvableChecks(result) {
372
- return result.checks.filter(check => check.status === 'failed' && check.canResolve);
373
- }
374
- }
375
-
376
- module.exports = { RunPreflightChecksUseCase };