@friggframework/devtools 2.0.0--canary.400.bed3308.0 → 2.0.0--canary.404.e9d4980.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 (182) hide show
  1. package/frigg-cli/build-command/index.js +3 -18
  2. package/frigg-cli/deploy-command/index.js +3 -19
  3. package/frigg-cli/index.js +1 -73
  4. package/frigg-cli/install-command/index.js +2 -15
  5. package/frigg-cli/start-command/index.js +2 -17
  6. package/infrastructure/create-frigg-infrastructure.js +2 -2
  7. package/infrastructure/serverless-template.js +79 -529
  8. package/package.json +5 -9
  9. package/frigg-cli/.eslintrc.js +0 -141
  10. package/frigg-cli/__tests__/jest.config.js +0 -102
  11. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -483
  12. package/frigg-cli/__tests__/unit/commands/install.test.js +0 -418
  13. package/frigg-cli/__tests__/unit/commands/ui.test.js +0 -592
  14. package/frigg-cli/__tests__/utils/command-tester.js +0 -170
  15. package/frigg-cli/__tests__/utils/mock-factory.js +0 -270
  16. package/frigg-cli/__tests__/utils/test-fixtures.js +0 -463
  17. package/frigg-cli/__tests__/utils/test-setup.js +0 -286
  18. package/frigg-cli/generate-command/__tests__/generate-command.test.js +0 -312
  19. package/frigg-cli/generate-command/azure-generator.js +0 -43
  20. package/frigg-cli/generate-command/gcp-generator.js +0 -47
  21. package/frigg-cli/generate-command/index.js +0 -350
  22. package/frigg-cli/generate-command/terraform-generator.js +0 -555
  23. package/frigg-cli/generate-iam-command.js +0 -115
  24. package/frigg-cli/package.json +0 -75
  25. package/frigg-cli/ui-command/index.js +0 -167
  26. package/frigg-cli/utils/app-resolver.js +0 -319
  27. package/frigg-cli/utils/backend-path.js +0 -38
  28. package/frigg-cli/utils/process-manager.js +0 -199
  29. package/frigg-cli/utils/repo-detection.js +0 -405
  30. package/infrastructure/AWS-DISCOVERY-TROUBLESHOOTING.md +0 -245
  31. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +0 -620
  32. package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +0 -268
  33. package/infrastructure/GENERATE-IAM-DOCS.md +0 -253
  34. package/infrastructure/IAM-POLICY-TEMPLATES.md +0 -176
  35. package/infrastructure/README-TESTING.md +0 -332
  36. package/infrastructure/README.md +0 -421
  37. package/infrastructure/WEBSOCKET-CONFIGURATION.md +0 -105
  38. package/infrastructure/__tests__/fixtures/mock-aws-resources.js +0 -391
  39. package/infrastructure/__tests__/helpers/test-utils.js +0 -277
  40. package/infrastructure/aws-discovery.js +0 -568
  41. package/infrastructure/aws-discovery.test.js +0 -373
  42. package/infrastructure/build-time-discovery.js +0 -206
  43. package/infrastructure/build-time-discovery.test.js +0 -375
  44. package/infrastructure/frigg-deployment-iam-stack.yaml +0 -393
  45. package/infrastructure/iam-generator.js +0 -810
  46. package/infrastructure/iam-generator.test.js +0 -169
  47. package/infrastructure/iam-policy-basic.json +0 -236
  48. package/infrastructure/iam-policy-full.json +0 -305
  49. package/infrastructure/integration.test.js +0 -383
  50. package/infrastructure/run-discovery.js +0 -110
  51. package/infrastructure/serverless-template.test.js +0 -553
  52. package/management-ui/.eslintrc.js +0 -22
  53. package/management-ui/README.md +0 -203
  54. package/management-ui/components.json +0 -21
  55. package/management-ui/index.html +0 -13
  56. package/management-ui/merge-conflict-cleaner.py +0 -371
  57. package/management-ui/package-lock.json +0 -10997
  58. package/management-ui/package.json +0 -76
  59. package/management-ui/postcss.config.js +0 -6
  60. package/management-ui/server/api/backend.js +0 -256
  61. package/management-ui/server/api/cli.js +0 -315
  62. package/management-ui/server/api/codegen.js +0 -663
  63. package/management-ui/server/api/connections.js +0 -857
  64. package/management-ui/server/api/discovery.js +0 -185
  65. package/management-ui/server/api/environment/index.js +0 -1
  66. package/management-ui/server/api/environment/router.js +0 -378
  67. package/management-ui/server/api/environment.js +0 -328
  68. package/management-ui/server/api/integrations.js +0 -479
  69. package/management-ui/server/api/logs.js +0 -248
  70. package/management-ui/server/api/monitoring.js +0 -282
  71. package/management-ui/server/api/open-ide.js +0 -31
  72. package/management-ui/server/api/project.js +0 -553
  73. package/management-ui/server/api/users/sessions.js +0 -371
  74. package/management-ui/server/api/users/simulation.js +0 -254
  75. package/management-ui/server/api/users.js +0 -362
  76. package/management-ui/server/api-contract.md +0 -275
  77. package/management-ui/server/index.js +0 -428
  78. package/management-ui/server/middleware/errorHandler.js +0 -70
  79. package/management-ui/server/middleware/security.js +0 -32
  80. package/management-ui/server/processManager.js +0 -296
  81. package/management-ui/server/server.js +0 -188
  82. package/management-ui/server/services/aws-monitor.js +0 -413
  83. package/management-ui/server/services/npm-registry.js +0 -347
  84. package/management-ui/server/services/template-engine.js +0 -538
  85. package/management-ui/server/utils/cliIntegration.js +0 -220
  86. package/management-ui/server/utils/environment/auditLogger.js +0 -471
  87. package/management-ui/server/utils/environment/awsParameterStore.js +0 -264
  88. package/management-ui/server/utils/environment/encryption.js +0 -278
  89. package/management-ui/server/utils/environment/envFileManager.js +0 -286
  90. package/management-ui/server/utils/import-commonjs.js +0 -28
  91. package/management-ui/server/utils/response.js +0 -83
  92. package/management-ui/server/websocket/handler.js +0 -325
  93. package/management-ui/src/App.jsx +0 -51
  94. package/management-ui/src/assets/FriggLogo.svg +0 -1
  95. package/management-ui/src/components/AppRouter.jsx +0 -65
  96. package/management-ui/src/components/Button.jsx +0 -2
  97. package/management-ui/src/components/Card.jsx +0 -9
  98. package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
  99. package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
  100. package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
  101. package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
  102. package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
  103. package/management-ui/src/components/ErrorBoundary.jsx +0 -73
  104. package/management-ui/src/components/IntegrationCard.jsx +0 -199
  105. package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -490
  106. package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
  107. package/management-ui/src/components/IntegrationStatus.jsx +0 -235
  108. package/management-ui/src/components/Layout.jsx +0 -250
  109. package/management-ui/src/components/LoadingSpinner.jsx +0 -45
  110. package/management-ui/src/components/RepositoryPicker.jsx +0 -248
  111. package/management-ui/src/components/SessionMonitor.jsx +0 -255
  112. package/management-ui/src/components/StatusBadge.jsx +0 -70
  113. package/management-ui/src/components/UserContextSwitcher.jsx +0 -154
  114. package/management-ui/src/components/UserSimulation.jsx +0 -299
  115. package/management-ui/src/components/Welcome.jsx +0 -434
  116. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
  117. package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
  118. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
  119. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
  120. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
  121. package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
  122. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
  123. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
  124. package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
  125. package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
  126. package/management-ui/src/components/codegen/index.js +0 -10
  127. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
  128. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
  129. package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
  130. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
  131. package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
  132. package/management-ui/src/components/connections/index.js +0 -5
  133. package/management-ui/src/components/index.js +0 -21
  134. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
  135. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
  136. package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
  137. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
  138. package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
  139. package/management-ui/src/components/monitoring/index.js +0 -6
  140. package/management-ui/src/components/monitoring/monitoring.css +0 -218
  141. package/management-ui/src/components/theme-provider.jsx +0 -52
  142. package/management-ui/src/components/theme-toggle.jsx +0 -39
  143. package/management-ui/src/components/ui/badge.tsx +0 -36
  144. package/management-ui/src/components/ui/button.test.jsx +0 -56
  145. package/management-ui/src/components/ui/button.tsx +0 -57
  146. package/management-ui/src/components/ui/card.tsx +0 -76
  147. package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
  148. package/management-ui/src/components/ui/select.tsx +0 -157
  149. package/management-ui/src/components/ui/skeleton.jsx +0 -15
  150. package/management-ui/src/hooks/useFrigg.jsx +0 -387
  151. package/management-ui/src/hooks/useSocket.jsx +0 -58
  152. package/management-ui/src/index.css +0 -194
  153. package/management-ui/src/lib/utils.ts +0 -6
  154. package/management-ui/src/main.jsx +0 -10
  155. package/management-ui/src/pages/CodeGeneration.jsx +0 -14
  156. package/management-ui/src/pages/Connections.jsx +0 -252
  157. package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -427
  158. package/management-ui/src/pages/Dashboard.jsx +0 -311
  159. package/management-ui/src/pages/Environment.jsx +0 -314
  160. package/management-ui/src/pages/IntegrationConfigure.jsx +0 -544
  161. package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -479
  162. package/management-ui/src/pages/IntegrationTest.jsx +0 -494
  163. package/management-ui/src/pages/Integrations.jsx +0 -254
  164. package/management-ui/src/pages/Monitoring.jsx +0 -17
  165. package/management-ui/src/pages/Simulation.jsx +0 -155
  166. package/management-ui/src/pages/Users.jsx +0 -492
  167. package/management-ui/src/services/api.js +0 -41
  168. package/management-ui/src/services/apiModuleService.js +0 -193
  169. package/management-ui/src/services/websocket-handlers.js +0 -120
  170. package/management-ui/src/test/api/project.test.js +0 -273
  171. package/management-ui/src/test/components/Welcome.test.jsx +0 -378
  172. package/management-ui/src/test/mocks/server.js +0 -178
  173. package/management-ui/src/test/setup.js +0 -61
  174. package/management-ui/src/test/utils/test-utils.jsx +0 -134
  175. package/management-ui/src/utils/repository.js +0 -98
  176. package/management-ui/src/utils/repository.test.js +0 -118
  177. package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
  178. package/management-ui/tailwind.config.js +0 -63
  179. package/management-ui/tsconfig.json +0 -37
  180. package/management-ui/tsconfig.node.json +0 -10
  181. package/management-ui/vite.config.js +0 -26
  182. package/management-ui/vitest.config.js +0 -38
@@ -1,75 +0,0 @@
1
- {
2
- "name": "@friggframework/cli",
3
- "version": "1.0.0",
4
- "description": "Frigg Framework CLI for serverless application development",
5
- "main": "index.js",
6
- "bin": {
7
- "frigg": "./index.js"
8
- },
9
- "scripts": {
10
- "test": "jest --config __tests__/jest.config.js",
11
- "test:watch": "jest --config __tests__/jest.config.js --watch",
12
- "test:coverage": "jest --config __tests__/jest.config.js --coverage",
13
- "test:unit": "jest --config __tests__/jest.config.js --testPathPattern=unit",
14
- "test:integration": "jest --config __tests__/jest.config.js --testPathPattern=integration",
15
- "test:e2e": "jest --config __tests__/jest.config.js --testPathPattern=e2e",
16
- "test:ci": "jest --config __tests__/jest.config.js --coverage --ci --watchAll=false",
17
- "lint": "eslint *.js **/*.js --ignore-pattern node_modules --ignore-pattern __tests__",
18
- "lint:fix": "eslint *.js **/*.js --ignore-pattern node_modules --ignore-pattern __tests__ --fix",
19
- "typecheck": "echo 'No TypeScript files to check'",
20
- "pretest": "npm run lint",
21
- "posttest": "npm run test:coverage"
22
- },
23
- "keywords": [
24
- "frigg",
25
- "framework",
26
- "cli",
27
- "serverless",
28
- "aws",
29
- "lambda",
30
- "api",
31
- "integration"
32
- ],
33
- "author": "Frigg Framework Team",
34
- "license": "MIT",
35
- "dependencies": {
36
- "commander": "^11.0.0",
37
- "@friggframework/core": "workspace:*"
38
- },
39
- "devDependencies": {
40
- "jest": "^29.7.0",
41
- "jest-junit": "^16.0.0",
42
- "jest-sonar-reporter": "^2.0.0",
43
- "eslint": "^8.57.0",
44
- "eslint-config-standard": "^17.1.0",
45
- "eslint-plugin-import": "^2.29.0",
46
- "eslint-plugin-node": "^11.1.0",
47
- "eslint-plugin-promise": "^6.1.0"
48
- },
49
- "engines": {
50
- "node": ">=18.0.0",
51
- "npm": ">=9.0.0"
52
- },
53
- "repository": {
54
- "type": "git",
55
- "url": "git+https://github.com/friggframework/frigg.git",
56
- "directory": "packages/devtools/frigg-cli"
57
- },
58
- "bugs": {
59
- "url": "https://github.com/friggframework/frigg/issues"
60
- },
61
- "homepage": "https://github.com/friggframework/frigg#readme",
62
- "files": [
63
- "*.js",
64
- "install-command/",
65
- "build-command/",
66
- "deploy-command/",
67
- "generate-command/",
68
- "ui-command/",
69
- "utils/",
70
- "README.md"
71
- ],
72
- "publishConfig": {
73
- "access": "public"
74
- }
75
- }
@@ -1,167 +0,0 @@
1
- const open = require('open');
2
- const chalk = require('chalk');
3
- const path = require('path');
4
- const ProcessManager = require('../utils/process-manager');
5
- const { AppResolver } = require('../utils/app-resolver');
6
- const {
7
- getCurrentRepositoryInfo,
8
- discoverFriggRepositories,
9
- promptRepositorySelection,
10
- formatRepositoryInfo
11
- } = require('../utils/repo-detection');
12
-
13
- async function uiCommand(options) {
14
- const { port = 3001, open: shouldOpen = true, repo: specifiedRepo, dev = false } = options;
15
-
16
- let targetRepo = null;
17
- let workingDirectory = process.cwd();
18
-
19
- // Check if new app path options are provided
20
- if (options.appPath || options.config || options.app || process.env.FRIGG_APP_PATH) {
21
- // Use AppResolver for new path resolution
22
- const appResolver = new AppResolver();
23
- try {
24
- workingDirectory = await appResolver.resolveAppPath(options);
25
- targetRepo = { path: workingDirectory, name: path.basename(workingDirectory) };
26
- console.log(chalk.green(`✓ Resolved Frigg application: ${workingDirectory}`));
27
- } catch (error) {
28
- console.error(chalk.red('Error:'), error.message);
29
- process.exit(1);
30
- }
31
- } else if (specifiedRepo) {
32
- // Legacy repo option support
33
- const repoPath = path.resolve(specifiedRepo);
34
- console.log(chalk.blue(`Using specified repository: ${repoPath}`));
35
- workingDirectory = repoPath;
36
- targetRepo = { path: repoPath, name: path.basename(repoPath) };
37
- } else {
38
- // Check if we're already in a Frigg repository
39
- console.log(chalk.blue('Detecting Frigg repository...'));
40
- const currentRepo = await getCurrentRepositoryInfo();
41
-
42
- if (currentRepo) {
43
- console.log(chalk.green(` Found Frigg repository: ${formatRepositoryInfo(currentRepo)}`));
44
- if (currentRepo.currentSubPath) {
45
- console.log(chalk.gray(` Currently in subdirectory: ${currentRepo.currentSubPath}`));
46
- }
47
- targetRepo = currentRepo;
48
- workingDirectory = currentRepo.path;
49
- } else {
50
- // Discover Frigg repositories
51
- console.log(chalk.yellow('Current directory is not a Frigg repository.'));
52
- console.log(chalk.blue('Searching for Frigg repositories...'));
53
-
54
- const discoveredRepos = await discoverFriggRepositories();
55
-
56
- if (discoveredRepos.length === 0) {
57
- console.log(chalk.red('No Frigg repositories found. Please create one first.'));
58
- process.exit(1);
59
- }
60
-
61
- // For UI command, we'll let the UI handle repository selection
62
- // Set a placeholder and pass the discovered repos via environment
63
- targetRepo = {
64
- name: 'Multiple Repositories Available',
65
- path: process.cwd(),
66
- isMultiRepo: true,
67
- availableRepos: discoveredRepos
68
- };
69
- workingDirectory = process.cwd();
70
-
71
- console.log(chalk.blue(`Found ${discoveredRepos.length} Frigg repositories. You'll be able to select one in the UI.`));
72
- }
73
- }
74
-
75
- console.log(chalk.blue('=� Starting Frigg Management UI...'));
76
-
77
- const processManager = new ProcessManager();
78
-
79
- try {
80
- const managementUiPath = path.join(__dirname, '../../management-ui');
81
-
82
- // Check if we're in development mode
83
- // For CLI usage, we prefer development mode unless explicitly set to production
84
- const fs = require('fs');
85
- const isDevelopment = dev || process.env.NODE_ENV !== 'production';
86
-
87
- if (isDevelopment) {
88
- const env = {
89
- ...process.env,
90
- VITE_API_URL: `http://localhost:${port}`,
91
- PORT: port,
92
- PROJECT_ROOT: workingDirectory,
93
- REPOSITORY_INFO: JSON.stringify(targetRepo),
94
- AVAILABLE_REPOSITORIES: targetRepo.isMultiRepo ? JSON.stringify(targetRepo.availableRepos) : null
95
- };
96
-
97
- // Start backend server
98
- processManager.spawnProcess(
99
- 'backend',
100
- 'npm',
101
- ['run', 'server'],
102
- { cwd: managementUiPath, env }
103
- );
104
-
105
- // Start frontend dev server
106
- processManager.spawnProcess(
107
- 'frontend',
108
- 'npm',
109
- ['run', 'dev'],
110
- { cwd: managementUiPath, env }
111
- );
112
-
113
- // Wait for servers to start
114
- await new Promise(resolve => setTimeout(resolve, 2000));
115
-
116
- // Display clean status
117
- processManager.printStatus(
118
- 'http://localhost:5173',
119
- `http://localhost:${port}`,
120
- targetRepo.name
121
- );
122
-
123
- // Open browser if requested
124
- if (shouldOpen) {
125
- setTimeout(() => {
126
- open('http://localhost:5173');
127
- }, 1000);
128
- }
129
-
130
- } else {
131
- // Production mode - just start the backend server
132
- const { FriggManagementServer } = await import('../../management-ui/server/index.js');
133
-
134
- const server = new FriggManagementServer({
135
- port,
136
- projectRoot: workingDirectory,
137
- repositoryInfo: targetRepo,
138
- availableRepositories: targetRepo.isMultiRepo ? targetRepo.availableRepos : null
139
- });
140
- await server.start();
141
-
142
- processManager.printStatus(
143
- `http://localhost:${port}`,
144
- `http://localhost:${port}/api`,
145
- targetRepo.name
146
- );
147
-
148
- if (shouldOpen) {
149
- setTimeout(() => {
150
- open(`http://localhost:${port}`);
151
- }, 1000);
152
- }
153
- }
154
-
155
- // Keep the process running
156
- process.stdin.resume();
157
-
158
- } catch (error) {
159
- console.error(chalk.red('Failed to start Management UI:'), error.message);
160
- if (error.code === 'EADDRINUSE') {
161
- console.log(chalk.yellow(`Port ${port} is already in use. Try using a different port with --port <number>`));
162
- }
163
- process.exit(1);
164
- }
165
- }
166
-
167
- module.exports = { uiCommand };
@@ -1,319 +0,0 @@
1
- const fs = require('fs').promises;
2
- const path = require('path');
3
- const os = require('os');
4
-
5
- class AppResolver {
6
- constructor() {
7
- this.cache = new Map();
8
- }
9
-
10
- async resolveAppPath(options = {}) {
11
- const cacheKey = JSON.stringify(options);
12
- if (this.cache.has(cacheKey)) {
13
- return this.cache.get(cacheKey);
14
- }
15
-
16
- let resolvedPath;
17
-
18
- // Priority 1: Explicit flags (--app-path, --config, --app)
19
- if (options.appPath || options.config || options.app) {
20
- const explicitPath = options.appPath || options.config || options.app;
21
- resolvedPath = await this.validateAndResolvePath(explicitPath);
22
- if (resolvedPath) {
23
- this.cache.set(cacheKey, resolvedPath);
24
- return resolvedPath;
25
- }
26
- throw new Error(`Invalid app path specified: ${explicitPath}`);
27
- }
28
-
29
- // Priority 2: Environment variable
30
- if (process.env.FRIGG_APP_PATH) {
31
- resolvedPath = await this.validateAndResolvePath(process.env.FRIGG_APP_PATH);
32
- if (resolvedPath) {
33
- this.cache.set(cacheKey, resolvedPath);
34
- return resolvedPath;
35
- }
36
- console.warn(`Warning: FRIGG_APP_PATH environment variable points to invalid path: ${process.env.FRIGG_APP_PATH}`);
37
- }
38
-
39
- // Priority 3: Current directory auto-detection (backward compatibility)
40
- resolvedPath = await this.autoDetectFriggApp();
41
- if (resolvedPath) {
42
- this.cache.set(cacheKey, resolvedPath);
43
- return resolvedPath;
44
- }
45
-
46
- // Priority 4: Search common development directories
47
- resolvedPath = await this.searchCommonDirectories();
48
- if (resolvedPath) {
49
- this.cache.set(cacheKey, resolvedPath);
50
- return resolvedPath;
51
- }
52
-
53
- throw new Error('No Frigg application found. Use --app-path to specify the application directory.');
54
- }
55
-
56
- async validateAndResolvePath(inputPath) {
57
- if (!inputPath) return null;
58
-
59
- // Handle different path formats
60
- let resolvedPath;
61
- if (inputPath.startsWith('~/')) {
62
- resolvedPath = path.join(os.homedir(), inputPath.slice(2));
63
- } else if (path.isAbsolute(inputPath)) {
64
- resolvedPath = inputPath;
65
- } else {
66
- resolvedPath = path.resolve(process.cwd(), inputPath);
67
- }
68
-
69
- try {
70
- const stats = await fs.stat(resolvedPath);
71
- if (!stats.isDirectory()) {
72
- // If it's a file, check if it's a config file and use its directory
73
- if (await this.isConfigFile(resolvedPath)) {
74
- resolvedPath = path.dirname(resolvedPath);
75
- } else {
76
- return null;
77
- }
78
- }
79
-
80
- // Validate that this is a Frigg application
81
- if (await this.isFriggApplication(resolvedPath)) {
82
- return resolvedPath;
83
- }
84
- } catch (error) {
85
- // Path doesn't exist or is not accessible
86
- return null;
87
- }
88
-
89
- return null;
90
- }
91
-
92
- async isConfigFile(filePath) {
93
- const basename = path.basename(filePath);
94
- const configFiles = [
95
- 'frigg.config.js',
96
- 'frigg.config.json',
97
- '.friggrc',
98
- '.friggrc.js',
99
- '.friggrc.json',
100
- 'package.json'
101
- ];
102
-
103
- return configFiles.includes(basename);
104
- }
105
-
106
- async isFriggApplication(dirPath) {
107
- try {
108
- // Check for package.json with Frigg dependencies
109
- const packageJsonPath = path.join(dirPath, 'package.json');
110
- try {
111
- const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8');
112
- const packageJson = JSON.parse(packageJsonContent);
113
-
114
- // Check for @friggframework dependencies
115
- const deps = {
116
- ...packageJson.dependencies,
117
- ...packageJson.devDependencies,
118
- ...packageJson.peerDependencies
119
- };
120
-
121
- if (Object.keys(deps).some(dep => dep.startsWith('@friggframework/'))) {
122
- return true;
123
- }
124
-
125
- // Check for frigg scripts
126
- if (packageJson.scripts) {
127
- const scriptNames = Object.keys(packageJson.scripts);
128
- if (scriptNames.some(script => script.includes('frigg'))) {
129
- return true;
130
- }
131
- }
132
- } catch (error) {
133
- // package.json doesn't exist or is invalid, continue checking other indicators
134
- }
135
-
136
- // Check for Frigg configuration files
137
- const configFiles = [
138
- 'frigg.config.js',
139
- 'frigg.config.json',
140
- '.friggrc',
141
- '.friggrc.js',
142
- '.friggrc.json'
143
- ];
144
-
145
- for (const configFile of configFiles) {
146
- try {
147
- await fs.access(path.join(dirPath, configFile));
148
- return true;
149
- } catch (error) {
150
- // File doesn't exist, continue
151
- }
152
- }
153
-
154
- // Check for Frigg-specific directories
155
- const friggDirectories = [
156
- '.frigg',
157
- 'frigg-modules',
158
- 'api-modules'
159
- ];
160
-
161
- for (const friggDir of friggDirectories) {
162
- try {
163
- const dirStat = await fs.stat(path.join(dirPath, friggDir));
164
- if (dirStat.isDirectory()) {
165
- return true;
166
- }
167
- } catch (error) {
168
- // Directory doesn't exist, continue
169
- }
170
- }
171
-
172
- // Check for serverless.yml with Frigg references
173
- try {
174
- const serverlessPath = path.join(dirPath, 'serverless.yml');
175
- const serverlessContent = await fs.readFile(serverlessPath, 'utf8');
176
- if (serverlessContent.includes('frigg') || serverlessContent.includes('Frigg')) {
177
- return true;
178
- }
179
- } catch (error) {
180
- // serverless.yml doesn't exist or can't be read
181
- }
182
-
183
- // Check for infrastructure.js (common in Frigg apps)
184
- try {
185
- await fs.access(path.join(dirPath, 'infrastructure.js'));
186
- return true;
187
- } catch (error) {
188
- // infrastructure.js doesn't exist
189
- }
190
-
191
- return false;
192
- } catch (error) {
193
- return false;
194
- }
195
- }
196
-
197
- async autoDetectFriggApp() {
198
- // Start from current directory and search up to 3 levels
199
- let currentDir = process.cwd();
200
-
201
- for (let i = 0; i < 3; i++) {
202
- if (await this.isFriggApplication(currentDir)) {
203
- return currentDir;
204
- }
205
-
206
- const parentDir = path.dirname(currentDir);
207
- if (parentDir === currentDir) {
208
- // Reached filesystem root
209
- break;
210
- }
211
- currentDir = parentDir;
212
- }
213
-
214
- return null;
215
- }
216
-
217
- async searchCommonDirectories() {
218
- const commonDirs = [
219
- path.join(os.homedir(), 'Documents'),
220
- path.join(os.homedir(), 'Projects'),
221
- path.join(os.homedir(), 'Development'),
222
- path.join(os.homedir(), 'dev'),
223
- path.join(os.homedir(), 'workspace')
224
- ];
225
-
226
- for (const baseDir of commonDirs) {
227
- try {
228
- const friggApp = await this.searchDirectoryRecursively(baseDir, 3);
229
- if (friggApp) {
230
- return friggApp;
231
- }
232
- } catch (error) {
233
- // Directory doesn't exist or can't be accessed, continue
234
- }
235
- }
236
-
237
- return null;
238
- }
239
-
240
- async searchDirectoryRecursively(dirPath, maxDepth) {
241
- if (maxDepth <= 0) return null;
242
-
243
- try {
244
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
245
-
246
- // First check if current directory is a Frigg app
247
- if (await this.isFriggApplication(dirPath)) {
248
- return dirPath;
249
- }
250
-
251
- // Then search subdirectories
252
- for (const entry of entries) {
253
- if (!entry.isDirectory()) continue;
254
-
255
- // Skip common directories that shouldn't contain Frigg apps
256
- const skipDirs = ['node_modules', '.git', 'dist', 'build', '.next', 'coverage'];
257
- if (skipDirs.includes(entry.name)) continue;
258
-
259
- const subDirPath = path.join(dirPath, entry.name);
260
- const result = await this.searchDirectoryRecursively(subDirPath, maxDepth - 1);
261
- if (result) {
262
- return result;
263
- }
264
- }
265
- } catch (error) {
266
- // Directory can't be read, skip
267
- }
268
-
269
- return null;
270
- }
271
-
272
- async loadAppConfig(appPath) {
273
- const configPaths = [
274
- path.join(appPath, 'frigg.config.js'),
275
- path.join(appPath, 'frigg.config.json'),
276
- path.join(appPath, '.friggrc.js'),
277
- path.join(appPath, '.friggrc.json'),
278
- path.join(appPath, '.friggrc')
279
- ];
280
-
281
- for (const configPath of configPaths) {
282
- try {
283
- const stats = await fs.stat(configPath);
284
- if (stats.isFile()) {
285
- if (configPath.endsWith('.js')) {
286
- delete require.cache[require.resolve(configPath)];
287
- return require(configPath);
288
- } else {
289
- const content = await fs.readFile(configPath, 'utf8');
290
- return JSON.parse(content);
291
- }
292
- }
293
- } catch (error) {
294
- // Config file doesn't exist or can't be read, continue
295
- }
296
- }
297
-
298
- // Fallback to package.json frigg configuration
299
- try {
300
- const packageJsonPath = path.join(appPath, 'package.json');
301
- const packageJsonContent = await fs.readFile(packageJsonPath, 'utf8');
302
- const packageJson = JSON.parse(packageJsonContent);
303
-
304
- if (packageJson.frigg) {
305
- return packageJson.frigg;
306
- }
307
- } catch (error) {
308
- // package.json doesn't exist or doesn't have frigg config
309
- }
310
-
311
- return {};
312
- }
313
-
314
- clearCache() {
315
- this.cache.clear();
316
- }
317
- }
318
-
319
- module.exports = { AppResolver };
@@ -1,38 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const PACKAGE_JSON = 'package.json';
4
-
5
- function findNearestBackendPackageJson() {
6
- let currentDir = process.cwd();
7
-
8
- // First check if we're in production by looking for package.json in the current directory
9
- const rootPackageJson = path.join(currentDir, PACKAGE_JSON);
10
- if (fs.existsSync(rootPackageJson)) {
11
- // In production environment, check for index.js in the same directory
12
- const indexJs = path.join(currentDir, 'index.js');
13
- if (fs.existsSync(indexJs)) {
14
- return rootPackageJson;
15
- }
16
- }
17
-
18
- // If not found at root or not in production, look for it in the backend directory
19
- while (currentDir !== path.parse(currentDir).root) {
20
- const packageJsonPath = path.join(currentDir, 'backend', PACKAGE_JSON);
21
- if (fs.existsSync(packageJsonPath)) {
22
- return packageJsonPath;
23
- }
24
- currentDir = path.dirname(currentDir);
25
- }
26
- return null;
27
- }
28
-
29
- function validateBackendPath(backendPath) {
30
- if (!backendPath) {
31
- throw new Error('Could not find a backend package.json file.');
32
- }
33
- }
34
-
35
- module.exports = {
36
- findNearestBackendPackageJson,
37
- validateBackendPath,
38
- };