@friggframework/devtools 2.0.0--canary.400.bed3308.0 → 2.0.0--canary.400.545e7a8.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 (167) hide show
  1. package/frigg-cli/build-command/index.js +2 -15
  2. package/frigg-cli/deploy-command/index.js +2 -15
  3. package/frigg-cli/index.js +4 -66
  4. package/frigg-cli/install-command/index.js +2 -15
  5. package/frigg-cli/start-command/index.js +2 -17
  6. package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +19 -43
  7. package/infrastructure/IAM-POLICY-TEMPLATES.md +1 -1
  8. package/infrastructure/frigg-deployment-iam-stack.yaml +2 -16
  9. package/infrastructure/iam-generator.js +6 -129
  10. package/infrastructure/iam-policy-basic.json +5 -29
  11. package/infrastructure/iam-policy-full.json +5 -28
  12. package/infrastructure/serverless-template.js +3 -190
  13. package/infrastructure/serverless-template.test.js +0 -12
  14. package/management-ui/dist/assets/index-CbM64Oba.js +1221 -0
  15. package/management-ui/dist/assets/index-CkvseXTC.css +1 -0
  16. package/management-ui/{index.html → dist/index.html} +2 -1
  17. package/package.json +5 -5
  18. package/frigg-cli/.eslintrc.js +0 -141
  19. package/frigg-cli/__tests__/jest.config.js +0 -102
  20. package/frigg-cli/__tests__/unit/commands/build.test.js +0 -483
  21. package/frigg-cli/__tests__/unit/commands/install.test.js +0 -418
  22. package/frigg-cli/__tests__/unit/commands/ui.test.js +0 -592
  23. package/frigg-cli/__tests__/utils/command-tester.js +0 -170
  24. package/frigg-cli/__tests__/utils/mock-factory.js +0 -270
  25. package/frigg-cli/__tests__/utils/test-fixtures.js +0 -463
  26. package/frigg-cli/__tests__/utils/test-setup.js +0 -286
  27. package/frigg-cli/generate-command/__tests__/generate-command.test.js +0 -312
  28. package/frigg-cli/generate-command/azure-generator.js +0 -43
  29. package/frigg-cli/generate-command/gcp-generator.js +0 -47
  30. package/frigg-cli/generate-command/index.js +0 -350
  31. package/frigg-cli/generate-command/terraform-generator.js +0 -555
  32. package/frigg-cli/package.json +0 -75
  33. package/frigg-cli/ui-command/index.js +0 -167
  34. package/frigg-cli/utils/app-resolver.js +0 -319
  35. package/frigg-cli/utils/backend-path.js +0 -38
  36. package/frigg-cli/utils/process-manager.js +0 -199
  37. package/frigg-cli/utils/repo-detection.js +0 -405
  38. package/management-ui/.eslintrc.js +0 -22
  39. package/management-ui/README.md +0 -203
  40. package/management-ui/components.json +0 -21
  41. package/management-ui/merge-conflict-cleaner.py +0 -371
  42. package/management-ui/package-lock.json +0 -10997
  43. package/management-ui/package.json +0 -76
  44. package/management-ui/postcss.config.js +0 -6
  45. package/management-ui/server/api/backend.js +0 -256
  46. package/management-ui/server/api/cli.js +0 -315
  47. package/management-ui/server/api/codegen.js +0 -663
  48. package/management-ui/server/api/connections.js +0 -857
  49. package/management-ui/server/api/discovery.js +0 -185
  50. package/management-ui/server/api/environment/index.js +0 -1
  51. package/management-ui/server/api/environment/router.js +0 -378
  52. package/management-ui/server/api/environment.js +0 -328
  53. package/management-ui/server/api/integrations.js +0 -479
  54. package/management-ui/server/api/logs.js +0 -248
  55. package/management-ui/server/api/monitoring.js +0 -282
  56. package/management-ui/server/api/open-ide.js +0 -31
  57. package/management-ui/server/api/project.js +0 -553
  58. package/management-ui/server/api/users/sessions.js +0 -371
  59. package/management-ui/server/api/users/simulation.js +0 -254
  60. package/management-ui/server/api/users.js +0 -362
  61. package/management-ui/server/api-contract.md +0 -275
  62. package/management-ui/server/index.js +0 -428
  63. package/management-ui/server/middleware/errorHandler.js +0 -70
  64. package/management-ui/server/middleware/security.js +0 -32
  65. package/management-ui/server/processManager.js +0 -296
  66. package/management-ui/server/server.js +0 -188
  67. package/management-ui/server/services/aws-monitor.js +0 -413
  68. package/management-ui/server/services/npm-registry.js +0 -347
  69. package/management-ui/server/services/template-engine.js +0 -538
  70. package/management-ui/server/utils/cliIntegration.js +0 -220
  71. package/management-ui/server/utils/environment/auditLogger.js +0 -471
  72. package/management-ui/server/utils/environment/awsParameterStore.js +0 -264
  73. package/management-ui/server/utils/environment/encryption.js +0 -278
  74. package/management-ui/server/utils/environment/envFileManager.js +0 -286
  75. package/management-ui/server/utils/import-commonjs.js +0 -28
  76. package/management-ui/server/utils/response.js +0 -83
  77. package/management-ui/server/websocket/handler.js +0 -325
  78. package/management-ui/src/App.jsx +0 -51
  79. package/management-ui/src/components/AppRouter.jsx +0 -65
  80. package/management-ui/src/components/Button.jsx +0 -2
  81. package/management-ui/src/components/Card.jsx +0 -9
  82. package/management-ui/src/components/EnvironmentCompare.jsx +0 -400
  83. package/management-ui/src/components/EnvironmentEditor.jsx +0 -372
  84. package/management-ui/src/components/EnvironmentImportExport.jsx +0 -469
  85. package/management-ui/src/components/EnvironmentSchema.jsx +0 -491
  86. package/management-ui/src/components/EnvironmentSecurity.jsx +0 -463
  87. package/management-ui/src/components/ErrorBoundary.jsx +0 -73
  88. package/management-ui/src/components/IntegrationCard.jsx +0 -199
  89. package/management-ui/src/components/IntegrationCardEnhanced.jsx +0 -490
  90. package/management-ui/src/components/IntegrationExplorer.jsx +0 -379
  91. package/management-ui/src/components/IntegrationStatus.jsx +0 -235
  92. package/management-ui/src/components/Layout.jsx +0 -250
  93. package/management-ui/src/components/LoadingSpinner.jsx +0 -45
  94. package/management-ui/src/components/RepositoryPicker.jsx +0 -248
  95. package/management-ui/src/components/SessionMonitor.jsx +0 -255
  96. package/management-ui/src/components/StatusBadge.jsx +0 -70
  97. package/management-ui/src/components/UserContextSwitcher.jsx +0 -154
  98. package/management-ui/src/components/UserSimulation.jsx +0 -299
  99. package/management-ui/src/components/Welcome.jsx +0 -434
  100. package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +0 -637
  101. package/management-ui/src/components/codegen/APIModuleSelector.jsx +0 -227
  102. package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +0 -247
  103. package/management-ui/src/components/codegen/CodePreviewEditor.jsx +0 -316
  104. package/management-ui/src/components/codegen/DynamicModuleForm.jsx +0 -271
  105. package/management-ui/src/components/codegen/FormBuilder.jsx +0 -737
  106. package/management-ui/src/components/codegen/IntegrationGenerator.jsx +0 -855
  107. package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +0 -797
  108. package/management-ui/src/components/codegen/SchemaBuilder.jsx +0 -303
  109. package/management-ui/src/components/codegen/TemplateSelector.jsx +0 -586
  110. package/management-ui/src/components/codegen/index.js +0 -10
  111. package/management-ui/src/components/connections/ConnectionConfigForm.jsx +0 -362
  112. package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +0 -182
  113. package/management-ui/src/components/connections/ConnectionTester.jsx +0 -200
  114. package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +0 -292
  115. package/management-ui/src/components/connections/OAuthFlow.jsx +0 -204
  116. package/management-ui/src/components/connections/index.js +0 -5
  117. package/management-ui/src/components/index.js +0 -21
  118. package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +0 -222
  119. package/management-ui/src/components/monitoring/LambdaMetrics.jsx +0 -169
  120. package/management-ui/src/components/monitoring/MetricsChart.jsx +0 -197
  121. package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +0 -393
  122. package/management-ui/src/components/monitoring/SQSMetrics.jsx +0 -246
  123. package/management-ui/src/components/monitoring/index.js +0 -6
  124. package/management-ui/src/components/monitoring/monitoring.css +0 -218
  125. package/management-ui/src/components/theme-provider.jsx +0 -52
  126. package/management-ui/src/components/theme-toggle.jsx +0 -39
  127. package/management-ui/src/components/ui/badge.tsx +0 -36
  128. package/management-ui/src/components/ui/button.test.jsx +0 -56
  129. package/management-ui/src/components/ui/button.tsx +0 -57
  130. package/management-ui/src/components/ui/card.tsx +0 -76
  131. package/management-ui/src/components/ui/dropdown-menu.tsx +0 -199
  132. package/management-ui/src/components/ui/select.tsx +0 -157
  133. package/management-ui/src/components/ui/skeleton.jsx +0 -15
  134. package/management-ui/src/hooks/useFrigg.jsx +0 -387
  135. package/management-ui/src/hooks/useSocket.jsx +0 -58
  136. package/management-ui/src/index.css +0 -194
  137. package/management-ui/src/lib/utils.ts +0 -6
  138. package/management-ui/src/main.jsx +0 -10
  139. package/management-ui/src/pages/CodeGeneration.jsx +0 -14
  140. package/management-ui/src/pages/Connections.jsx +0 -252
  141. package/management-ui/src/pages/ConnectionsEnhanced.jsx +0 -427
  142. package/management-ui/src/pages/Dashboard.jsx +0 -311
  143. package/management-ui/src/pages/Environment.jsx +0 -314
  144. package/management-ui/src/pages/IntegrationConfigure.jsx +0 -544
  145. package/management-ui/src/pages/IntegrationDiscovery.jsx +0 -479
  146. package/management-ui/src/pages/IntegrationTest.jsx +0 -494
  147. package/management-ui/src/pages/Integrations.jsx +0 -254
  148. package/management-ui/src/pages/Monitoring.jsx +0 -17
  149. package/management-ui/src/pages/Simulation.jsx +0 -155
  150. package/management-ui/src/pages/Users.jsx +0 -492
  151. package/management-ui/src/services/api.js +0 -41
  152. package/management-ui/src/services/apiModuleService.js +0 -193
  153. package/management-ui/src/services/websocket-handlers.js +0 -120
  154. package/management-ui/src/test/api/project.test.js +0 -273
  155. package/management-ui/src/test/components/Welcome.test.jsx +0 -378
  156. package/management-ui/src/test/mocks/server.js +0 -178
  157. package/management-ui/src/test/setup.js +0 -61
  158. package/management-ui/src/test/utils/test-utils.jsx +0 -134
  159. package/management-ui/src/utils/repository.js +0 -98
  160. package/management-ui/src/utils/repository.test.js +0 -118
  161. package/management-ui/src/workflows/phase2-integration-workflows.js +0 -884
  162. package/management-ui/tailwind.config.js +0 -63
  163. package/management-ui/tsconfig.json +0 -37
  164. package/management-ui/tsconfig.node.json +0 -10
  165. package/management-ui/vite.config.js +0 -26
  166. package/management-ui/vitest.config.js +0 -38
  167. /package/management-ui/{src/assets/FriggLogo.svg → dist/assets/FriggLogo-B7Xx8ZW1.svg} +0 -0
@@ -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
- };