@friggframework/devtools 2.0.0--canary.398.7664c46.0 → 2.0.0--canary.400.bed3308.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/frigg-cli/.eslintrc.js +141 -0
- package/frigg-cli/__tests__/jest.config.js +102 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
- package/frigg-cli/__tests__/utils/command-tester.js +170 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +286 -0
- package/frigg-cli/build-command/index.js +15 -2
- package/frigg-cli/deploy-command/index.js +15 -2
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +350 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/index.js +66 -4
- package/frigg-cli/install-command/index.js +15 -2
- package/frigg-cli/package.json +75 -0
- package/frigg-cli/start-command/index.js +17 -2
- package/frigg-cli/ui-command/index.js +167 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +38 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +43 -19
- package/infrastructure/IAM-POLICY-TEMPLATES.md +1 -1
- package/infrastructure/frigg-deployment-iam-stack.yaml +16 -2
- package/infrastructure/iam-generator.js +129 -6
- package/infrastructure/iam-policy-basic.json +29 -5
- package/infrastructure/iam-policy-full.json +28 -5
- package/infrastructure/serverless-template.js +209 -3
- package/infrastructure/serverless-template.test.js +12 -0
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +203 -0
- package/management-ui/components.json +21 -0
- package/management-ui/{dist/index.html → index.html} +1 -2
- package/management-ui/merge-conflict-cleaner.py +371 -0
- package/management-ui/package-lock.json +10997 -0
- package/management-ui/package.json +76 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +479 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +553 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +428 -0
- package/management-ui/server/middleware/errorHandler.js +70 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +188 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +51 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +2 -0
- package/management-ui/src/components/Card.jsx +9 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +199 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +490 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +235 -0
- package/management-ui/src/components/Layout.jsx +250 -0
- package/management-ui/src/components/LoadingSpinner.jsx +45 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +255 -0
- package/management-ui/src/components/StatusBadge.jsx +70 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +154 -0
- package/management-ui/src/components/UserSimulation.jsx +299 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +387 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +194 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +427 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +544 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +479 -0
- package/management-ui/src/pages/IntegrationTest.jsx +494 -0
- package/management-ui/src/pages/Integrations.jsx +254 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +5 -5
- package/management-ui/dist/assets/index-CbM64Oba.js +0 -1221
- package/management-ui/dist/assets/index-CkvseXTC.css +0 -1
- /package/management-ui/{dist/assets/FriggLogo-B7Xx8ZW1.svg → src/assets/FriggLogo.svg} +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
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,15 +1,30 @@
|
|
|
1
1
|
const { spawn } = require('node:child_process');
|
|
2
2
|
const path = require('node:path');
|
|
3
|
+
const { AppResolver } = require('../utils/app-resolver');
|
|
3
4
|
|
|
4
|
-
function startCommand(options) {
|
|
5
|
+
async function startCommand(options) {
|
|
5
6
|
if (options.verbose) {
|
|
6
7
|
console.log('Verbose mode enabled');
|
|
7
8
|
console.log('Options:', options);
|
|
8
9
|
}
|
|
9
10
|
console.log('Starting backend and optional frontend...');
|
|
11
|
+
|
|
10
12
|
// Suppress AWS SDK warning message about maintenance mode
|
|
11
13
|
process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = 1;
|
|
12
|
-
|
|
14
|
+
|
|
15
|
+
// Resolve app path using AppResolver
|
|
16
|
+
const appResolver = new AppResolver();
|
|
17
|
+
let backendPath;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
backendPath = await appResolver.resolveAppPath(options);
|
|
21
|
+
if (options.verbose) {
|
|
22
|
+
console.log('Resolved app path:', backendPath);
|
|
23
|
+
}
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error('Error:', error.message);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
13
28
|
console.log(`Starting backend in ${backendPath}...`);
|
|
14
29
|
const infrastructurePath = 'infrastructure.js';
|
|
15
30
|
const command = 'serverless';
|
|
@@ -0,0 +1,167 @@
|
|
|
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 };
|
|
@@ -0,0 +1,319 @@
|
|
|
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 };
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
};
|