@vee-stack/delta-cli 2.0.4 → 2.0.6
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/dist/analyzer/commands/analyze.js +260 -0
- package/dist/analyzer/commands/config.js +83 -0
- package/dist/analyzer/commands/report.js +38 -0
- package/dist/analyzer/generators/report.generator.js +123 -0
- package/dist/analyzer/index.js +44 -0
- package/dist/analyzer/scanners/project.scanner.js +92 -0
- package/dist/analyzer/validators/contracts.validator.js +42 -0
- package/dist/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/analyzer/validators/observability.validator.js +39 -0
- package/dist/analyzer/validators/performance.validator.js +42 -0
- package/dist/analyzer/validators/security.validator.js +66 -0
- package/dist/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/analyzer/commands/analyze.js +256 -0
- package/dist/apps/cli/src/analyzer/commands/config.js +83 -0
- package/dist/apps/cli/src/analyzer/commands/report.js +38 -0
- package/dist/apps/cli/src/analyzer/generators/report.generator.js +123 -0
- package/dist/apps/cli/src/analyzer/index.js +44 -0
- package/dist/apps/cli/src/analyzer/scanners/project.scanner.js +92 -0
- package/dist/apps/cli/src/analyzer/validators/contracts.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/maintainability.validator.js +40 -0
- package/dist/apps/cli/src/analyzer/validators/observability.validator.js +39 -0
- package/dist/apps/cli/src/analyzer/validators/performance.validator.js +42 -0
- package/dist/apps/cli/src/analyzer/validators/security.validator.js +66 -0
- package/dist/apps/cli/src/analyzer/validators/soc.validator.js +75 -0
- package/dist/apps/cli/src/auth/secure-auth.js +312 -0
- package/dist/apps/cli/src/commands/analyze.js +286 -0
- package/dist/apps/cli/src/commands/auth-new.js +37 -0
- package/dist/apps/cli/src/commands/auth.js +122 -0
- package/dist/apps/cli/src/commands/config.js +49 -0
- package/dist/apps/cli/src/commands/deploy.js +6 -0
- package/dist/apps/cli/src/commands/init.js +47 -0
- package/dist/apps/cli/src/commands/logout.js +23 -0
- package/dist/apps/cli/src/commands/plugins.js +21 -0
- package/dist/apps/cli/src/commands/status.js +80 -0
- package/dist/apps/cli/src/commands/sync.js +6 -0
- package/dist/apps/cli/src/commands/whoami.js +115 -0
- package/dist/apps/cli/src/components/Dashboard.js +168 -0
- package/dist/apps/cli/src/components/DeltaApp.js +56 -0
- package/dist/apps/cli/src/components/UnifiedManager.js +324 -0
- package/dist/apps/cli/src/core/audit.js +184 -0
- package/dist/apps/cli/src/core/completion.js +294 -0
- package/dist/apps/cli/src/core/contracts.js +6 -0
- package/dist/apps/cli/src/core/engine.js +124 -0
- package/dist/apps/cli/src/core/exit-codes.js +71 -0
- package/dist/apps/cli/src/core/hooks.js +181 -0
- package/dist/apps/cli/src/core/index.js +7 -0
- package/dist/apps/cli/src/core/policy.js +115 -0
- package/dist/apps/cli/src/core/profiles.js +161 -0
- package/dist/apps/cli/src/core/wizard.js +203 -0
- package/dist/apps/cli/src/index.js +636 -0
- package/dist/apps/cli/src/interactive/index.js +11 -0
- package/dist/apps/cli/src/plugins/GitStatusPlugin.js +99 -0
- package/dist/apps/cli/src/providers/ai-provider.js +74 -0
- package/dist/apps/cli/src/providers/local-provider.js +302 -0
- package/dist/apps/cli/src/providers/remote-provider.js +100 -0
- package/dist/apps/cli/src/types/api.js +3 -0
- package/dist/apps/cli/src/ui.js +219 -0
- package/dist/apps/cli/src/welcome.js +81 -0
- package/dist/auth/secure-auth.js +418 -0
- package/dist/bundle.js +45 -45
- package/dist/commands/analyze.js +384 -0
- package/dist/commands/auth-new.js +37 -0
- package/dist/commands/auth.js +134 -0
- package/dist/commands/config.js +51 -0
- package/dist/commands/deploy.js +6 -0
- package/dist/commands/init.js +47 -0
- package/dist/commands/logout.js +31 -0
- package/dist/commands/plugins.js +21 -0
- package/dist/commands/status.js +82 -0
- package/dist/commands/sync.js +6 -0
- package/dist/commands/whoami.js +72 -0
- package/dist/components/Dashboard.js +169 -0
- package/dist/components/DeltaApp.js +57 -0
- package/dist/components/UnifiedManager.js +344 -0
- package/dist/core/audit.js +184 -0
- package/dist/core/completion.js +294 -0
- package/dist/core/contracts.js +6 -0
- package/dist/core/engine.js +124 -0
- package/dist/core/exit-codes.js +71 -0
- package/dist/core/hooks.js +181 -0
- package/dist/core/index.js +7 -0
- package/dist/core/policy.js +115 -0
- package/dist/core/profiles.js +161 -0
- package/dist/core/wizard.js +203 -0
- package/dist/index.js +387 -0
- package/dist/interactive/index.js +11 -0
- package/dist/packages/domain/src/constitution/contracts/index.js +43 -0
- package/dist/packages/domain/src/constitution/contracts/ts.rules.js +268 -0
- package/dist/packages/domain/src/constitution/index.js +139 -0
- package/dist/packages/domain/src/constitution/maintainability/index.js +43 -0
- package/dist/packages/domain/src/constitution/maintainability/ts.rules.js +344 -0
- package/dist/packages/domain/src/constitution/observability/index.js +43 -0
- package/dist/packages/domain/src/constitution/observability/ts.rules.js +307 -0
- package/dist/packages/domain/src/constitution/performance/index.js +43 -0
- package/dist/packages/domain/src/constitution/performance/ts.rules.js +325 -0
- package/dist/packages/domain/src/constitution/security/index.js +50 -0
- package/dist/packages/domain/src/constitution/security/ts.rules.js +267 -0
- package/dist/packages/domain/src/constitution/soc/index.js +43 -0
- package/dist/packages/domain/src/constitution/soc/ts.rules.js +360 -0
- package/dist/packages/domain/src/contracts/analysis.contract.js +18 -0
- package/dist/packages/domain/src/contracts/index.js +7 -0
- package/dist/packages/domain/src/contracts/projects.contract.js +18 -0
- package/dist/packages/domain/src/control/registry/rules.registry.js +29 -0
- package/dist/packages/domain/src/control/schemas/policies.js +6 -0
- package/dist/packages/domain/src/core/analysis/discovery.js +163 -0
- package/dist/packages/domain/src/core/analysis/engine.contract.js +298 -0
- package/dist/packages/domain/src/core/analysis/engine.js +77 -0
- package/dist/packages/domain/src/core/analysis/index.js +14 -0
- package/dist/packages/domain/src/core/analysis/orchestrator.js +242 -0
- package/dist/packages/domain/src/core/comparison/engine.js +29 -0
- package/dist/packages/domain/src/core/comparison/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/index.js +5 -0
- package/dist/packages/domain/src/core/documentation/pipeline.js +41 -0
- package/dist/packages/domain/src/core/fs/adapter.js +111 -0
- package/dist/packages/domain/src/core/fs/index.js +5 -0
- package/dist/packages/domain/src/core/parser/unified-parser.js +166 -0
- package/dist/packages/domain/src/index.js +33 -0
- package/dist/packages/domain/src/plugin/registry.js +195 -0
- package/dist/packages/domain/src/plugin/types.js +6 -0
- package/dist/packages/domain/src/ports/analysis.engine.js +7 -0
- package/dist/packages/domain/src/ports/audit.logger.js +7 -0
- package/dist/packages/domain/src/ports/project.repository.js +7 -0
- package/dist/packages/domain/src/rules/index.js +134 -0
- package/dist/packages/domain/src/types/analysis.js +6 -0
- package/dist/packages/domain/src/types/errors.js +53 -0
- package/dist/packages/domain/src/types/fs.js +6 -0
- package/dist/packages/domain/src/types/index.js +7 -0
- package/dist/plugins/GitStatusPlugin.js +93 -0
- package/dist/providers/ai-provider.js +74 -0
- package/dist/providers/local-provider.js +304 -0
- package/dist/providers/remote-provider.js +100 -0
- package/dist/types/api.js +3 -0
- package/dist/ui.js +219 -0
- package/dist/welcome.js +81 -0
- package/package.json +18 -18
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logout Command - Remove stored authentication
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
5
|
+
import { CONFIG_FILE } from './auth.js';
|
|
6
|
+
import { SecureTokenStore } from '../auth/secure-auth.js';
|
|
7
|
+
export async function logoutCommand() {
|
|
8
|
+
try {
|
|
9
|
+
const hasToken = await SecureTokenStore.hasTokens();
|
|
10
|
+
if (!hasToken) {
|
|
11
|
+
console.log('ℹ️ Not currently authenticated');
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
// Clear tokens from keychain and remove config file
|
|
15
|
+
await SecureTokenStore.clearTokens();
|
|
16
|
+
try {
|
|
17
|
+
await fs.unlink(CONFIG_FILE);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// File may not exist, that's fine
|
|
21
|
+
}
|
|
22
|
+
console.log('✅ Successfully logged out');
|
|
23
|
+
console.log(' Authentication data removed');
|
|
24
|
+
process.exit(0);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.error('❌ Error during logout:', error instanceof Error ? error.message : String(error));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { printSuccess, printInfo } from '../ui.js';
|
|
2
|
+
export async function pluginsCommand(options) {
|
|
3
|
+
if (options.list) {
|
|
4
|
+
printInfo('Installed plugins:');
|
|
5
|
+
}
|
|
6
|
+
else if (options.install) {
|
|
7
|
+
printInfo(`Installing plugin: ${options.install}`);
|
|
8
|
+
printSuccess('Plugin installed successfully');
|
|
9
|
+
}
|
|
10
|
+
else if (options.uninstall) {
|
|
11
|
+
printInfo(`Uninstalling plugin: ${options.uninstall}`);
|
|
12
|
+
printSuccess('Plugin uninstalled successfully');
|
|
13
|
+
}
|
|
14
|
+
else if (options.search) {
|
|
15
|
+
printInfo(`Searching for plugins: ${options.search}`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
printInfo('Use --list, --install, --uninstall, or --search');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Status Command - Professional project and connection status
|
|
3
|
+
*/
|
|
4
|
+
import * as fs from 'fs/promises';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { loadConfig } from './auth.js';
|
|
7
|
+
import { SecureTokenStore } from '../auth/secure-auth.js';
|
|
8
|
+
import { icons, startSpinner, stopSpinner, printWelcome, printHeader, printSection, printSuccess, printError, printWarning, printInfo, printKeyValue, printCommandHint, createTable, printDivider, confirm, } from '../ui.js';
|
|
9
|
+
export async function statusCommand(projectPath, _options) {
|
|
10
|
+
const targetPath = path.resolve(projectPath);
|
|
11
|
+
printWelcome();
|
|
12
|
+
printHeader('Project Status Check');
|
|
13
|
+
printKeyValue('Path', targetPath);
|
|
14
|
+
console.log();
|
|
15
|
+
// Check for delta config
|
|
16
|
+
printSection('Project Configuration');
|
|
17
|
+
const configPath = path.join(targetPath, 'delta.config.json');
|
|
18
|
+
try {
|
|
19
|
+
await fs.access(configPath);
|
|
20
|
+
const config = JSON.parse(await fs.readFile(configPath, 'utf-8'));
|
|
21
|
+
printSuccess('Configuration found');
|
|
22
|
+
const configTable = createTable(['Property', 'Value']);
|
|
23
|
+
configTable.push([icons.folder + ' Name', config.name || 'Unnamed'], [icons.folder + ' Type', config.type || 'default'], [icons.gear + ' Version', config.version || 'N/A'], [icons.info + ' Config File', configPath]);
|
|
24
|
+
console.log(configTable.toString());
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
printWarning('No Delta project found');
|
|
28
|
+
printInfo('Initialize a new project:');
|
|
29
|
+
printCommandHint(`delta init ${projectPath}`, 'to create a new project');
|
|
30
|
+
const shouldInit = await confirm('Would you like to initialize now?', true);
|
|
31
|
+
if (shouldInit) {
|
|
32
|
+
console.log();
|
|
33
|
+
printInfo('Run: delta init ' + projectPath);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log();
|
|
37
|
+
printDivider();
|
|
38
|
+
// Check auth status
|
|
39
|
+
printSection('Authentication');
|
|
40
|
+
const auth = await loadConfig();
|
|
41
|
+
const pat = await SecureTokenStore.getAccessToken();
|
|
42
|
+
if (pat) {
|
|
43
|
+
printSuccess('Authenticated');
|
|
44
|
+
printKeyValue('API URL', auth.apiUrl || 'default');
|
|
45
|
+
// Test connection
|
|
46
|
+
const apiUrl = auth.apiUrl || process.env.DELTA_API_URL || 'http://localhost:3000';
|
|
47
|
+
startSpinner('Testing connection...');
|
|
48
|
+
try {
|
|
49
|
+
const response = await fetch(`${apiUrl}/api/me/entitlements`, {
|
|
50
|
+
headers: { 'Authorization': `Bearer ${pat}` },
|
|
51
|
+
});
|
|
52
|
+
if (response.ok) {
|
|
53
|
+
stopSpinner(true, 'Connection active');
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
if (data.success) {
|
|
56
|
+
printKeyValue('User', data.data.user.email);
|
|
57
|
+
printKeyValue('Plan', data.data.user.plan);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
stopSpinner(false, 'Authentication expired');
|
|
62
|
+
printError('Your session has expired');
|
|
63
|
+
printCommandHint('delta login --token <new-pat>', 'to re-authenticate');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
stopSpinner(false, 'API unreachable');
|
|
68
|
+
printError('Cannot connect to Delta API');
|
|
69
|
+
printInfo('Check your internet connection or API URL configuration');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
printError('Not authenticated');
|
|
74
|
+
printInfo('Please login to access cloud features:');
|
|
75
|
+
printCommandHint('delta login --token <pat>', 'to authenticate');
|
|
76
|
+
}
|
|
77
|
+
console.log();
|
|
78
|
+
printDivider();
|
|
79
|
+
printCommandHint('delta analyze', 'to analyze your project');
|
|
80
|
+
printCommandHint('delta whoami', 'to see account details');
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Whoami Command - Professional user info display
|
|
3
|
+
*/
|
|
4
|
+
import { loadConfig } from './auth.js';
|
|
5
|
+
import { SecureTokenStore } from '../auth/secure-auth.js';
|
|
6
|
+
import { icons, startSpinner, stopSpinner, printHeader, printSuccess, printError, printInfo, printCommandHint, createTable, printDivider, } from '../ui.js';
|
|
7
|
+
export async function whoamiCommand(_options) {
|
|
8
|
+
try {
|
|
9
|
+
const config = await loadConfig();
|
|
10
|
+
const pat = await SecureTokenStore.getAccessToken();
|
|
11
|
+
if (!pat) {
|
|
12
|
+
printHeader('Authentication Status');
|
|
13
|
+
printError('Not authenticated');
|
|
14
|
+
console.log();
|
|
15
|
+
printInfo('Please login first:');
|
|
16
|
+
printCommandHint('delta login', 'to authenticate with your PAT');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
printHeader('Loading Account Information');
|
|
20
|
+
startSpinner('Fetching user data...');
|
|
21
|
+
const apiUrl = config.apiUrl || process.env.DELTA_API_URL || 'http://localhost:3000';
|
|
22
|
+
const response = await fetch(`${apiUrl}/api/auth/me`, {
|
|
23
|
+
headers: {
|
|
24
|
+
'Authorization': `Bearer ${pat}`,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
stopSpinner(false);
|
|
30
|
+
if (response.status === 401) {
|
|
31
|
+
printError('Authentication expired or invalid');
|
|
32
|
+
console.log();
|
|
33
|
+
printInfo('Please login again:');
|
|
34
|
+
printCommandHint('delta login --token <new-pat>', 'to re-authenticate');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`API error: ${response.status} ${response.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
const data = await response.json();
|
|
40
|
+
stopSpinner(true);
|
|
41
|
+
console.log();
|
|
42
|
+
const user = data;
|
|
43
|
+
// User Info Section
|
|
44
|
+
printHeader('User Profile');
|
|
45
|
+
const userTable = createTable(['Property', 'Value']);
|
|
46
|
+
userTable.push([icons.user + ' Email', user.email], [icons.user + ' User ID', user.id], [icons.package + ' Plan', formatPlan(user.plan)], [icons.star + ' Role', user.role || user.plan], [icons.info + ' Status', user.status || 'active'], [icons.bullet + ' Created', new Date(user.created_at).toLocaleDateString('en-US')]);
|
|
47
|
+
console.log(userTable.toString());
|
|
48
|
+
printDivider();
|
|
49
|
+
console.log();
|
|
50
|
+
printSuccess('✓ Authenticated successfully');
|
|
51
|
+
console.log();
|
|
52
|
+
printCommandHint('delta analyze', 'to run a code analysis');
|
|
53
|
+
printCommandHint('delta status', 'to check project status');
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
stopSpinner(false);
|
|
58
|
+
console.log();
|
|
59
|
+
printError(error instanceof Error ? error.message : String(error));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function formatPlan(plan) {
|
|
64
|
+
const planColors = {
|
|
65
|
+
'individual_free': '🔷 Free',
|
|
66
|
+
'individual_pro': '💎 Pro',
|
|
67
|
+
'individual_team': '👥 Team',
|
|
68
|
+
'enterprise': '🏢 Enterprise',
|
|
69
|
+
};
|
|
70
|
+
return planColors[plan] || plan;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Enhanced Dashboard Component
|
|
4
|
+
* Visual dashboard with project status, analysis reports, and charts
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useEffect } from 'react';
|
|
7
|
+
import { Box, Text, useApp, useInput } from 'ink';
|
|
8
|
+
import Spinner from 'ink-spinner';
|
|
9
|
+
// Custom Divider component (replacement for ink-divider with type issues)
|
|
10
|
+
const CustomDivider = ({ title }) => (_jsx(Box, { marginY: 1, children: _jsxs(Text, { color: "gray", children: ['─'.repeat(40), title ? ` ${title} ` : '', '─'.repeat(40)] }) }));
|
|
11
|
+
// Sparkline chart component
|
|
12
|
+
const Sparkline = ({ data, width = 20 }) => {
|
|
13
|
+
if (data.length === 0)
|
|
14
|
+
return _jsx(Text, { dimColor: true, children: "no data" });
|
|
15
|
+
const max = Math.max(...data, 1);
|
|
16
|
+
const min = Math.min(...data, 0);
|
|
17
|
+
const range = max - min || 1;
|
|
18
|
+
const bars = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
|
|
19
|
+
const normalized = data.map(v => {
|
|
20
|
+
const idx = Math.floor(((v - min) / range) * (bars.length - 1));
|
|
21
|
+
return bars[Math.min(idx, bars.length - 1)];
|
|
22
|
+
});
|
|
23
|
+
// Truncate or pad to width
|
|
24
|
+
const display = normalized.slice(-width);
|
|
25
|
+
while (display.length < width) {
|
|
26
|
+
display.unshift(bars[0]);
|
|
27
|
+
}
|
|
28
|
+
return _jsx(Text, { color: "cyan", children: display.join('') });
|
|
29
|
+
};
|
|
30
|
+
// Progress bar component
|
|
31
|
+
const ProgressBar = ({ value, max, width = 20 }) => {
|
|
32
|
+
const percentage = Math.min(Math.max(value / max, 0), 1);
|
|
33
|
+
const filled = Math.floor(percentage * width);
|
|
34
|
+
const empty = width - filled;
|
|
35
|
+
const bar = '█'.repeat(filled) + '░'.repeat(empty);
|
|
36
|
+
const color = percentage > 0.7 ? 'red' : percentage > 0.4 ? 'yellow' : 'green';
|
|
37
|
+
return (_jsxs(Text, { children: [_jsx(Text, { color: color, children: bar }), _jsxs(Text, { dimColor: true, children: [" ", Math.round(percentage * 100), "%"] })] }));
|
|
38
|
+
};
|
|
39
|
+
// Status indicator
|
|
40
|
+
const StatusIndicator = ({ status }) => {
|
|
41
|
+
const icons = { ok: '✅', warning: '⚠️', error: '❌' };
|
|
42
|
+
const colors = { ok: 'green', warning: 'yellow', error: 'red' };
|
|
43
|
+
return _jsx(Text, { color: colors[status], children: icons[status] });
|
|
44
|
+
};
|
|
45
|
+
// Project row component
|
|
46
|
+
const ProjectRow = ({ project, isSelected }) => {
|
|
47
|
+
const timeAgo = project.lastAnalyze
|
|
48
|
+
? formatTimeAgo(project.lastAnalyze)
|
|
49
|
+
: 'never';
|
|
50
|
+
const totalFindings = project.findings.high + project.findings.medium + project.findings.low;
|
|
51
|
+
const findingsColor = project.findings.high > 0 ? 'red' : project.findings.medium > 0 ? 'yellow' : 'green';
|
|
52
|
+
return (_jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsx(Box, { width: 3, children: isSelected ? _jsx(Text, { color: "cyan", children: "\u276F" }) : _jsx(Text, { children: " " }) }), _jsx(Box, { width: 12, children: _jsx(StatusIndicator, { status: project.status }) }), _jsx(Box, { width: 20, children: _jsx(Text, { bold: isSelected, children: project.name }) }), _jsx(Box, { width: 12, children: _jsx(Text, { dimColor: true, children: timeAgo }) }), _jsx(Box, { width: 10, children: _jsxs(Text, { color: findingsColor, children: [totalFindings, " (", project.findings.high, "H)"] }) }), _jsx(Box, { width: 10, children: _jsxs(Text, { dimColor: true, children: [project.duration, "ms"] }) })] }));
|
|
53
|
+
};
|
|
54
|
+
// Stats box component
|
|
55
|
+
const StatsBox = ({ stats }) => {
|
|
56
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "\uD83D\uDCCA Usage Statistics" }), _jsx(Box, { children: _jsxs(Box, { flexDirection: "row", gap: 4, children: [_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Total Commands" }), _jsx(Text, { bold: true, children: stats.totalCommands })] }), _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Success Rate" }), _jsxs(Text, { bold: true, color: stats.successRate > 80 ? 'green' : 'yellow', children: [stats.successRate, "%"] }), _jsx(Sparkline, { data: [stats.successRate, 100 - stats.successRate], width: 10 })] }), _jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "Avg Duration" }), _jsxs(Text, { bold: true, children: [stats.avgDuration, "ms"] })] })] }) }), _jsxs(Box, { children: [_jsx(Text, { dimColor: true, children: "Most Used: " }), _jsx(Text, { children: stats.mostUsed.join(', ') || 'none' })] })] }));
|
|
57
|
+
};
|
|
58
|
+
// Findings chart
|
|
59
|
+
const FindingsChart = ({ projects }) => {
|
|
60
|
+
const totalFindings = projects.reduce((sum, p) => sum + p.findings.high + p.findings.medium + p.findings.low, 0);
|
|
61
|
+
const highCount = projects.reduce((sum, p) => sum + p.findings.high, 0);
|
|
62
|
+
const mediumCount = projects.reduce((sum, p) => sum + p.findings.medium, 0);
|
|
63
|
+
const lowCount = projects.reduce((sum, p) => sum + p.findings.low, 0);
|
|
64
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "\uD83D\uDD0D Findings Distribution" }), _jsxs(Box, { marginY: 1, flexDirection: "column", gap: 1, children: [_jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsx(Box, { width: 10, children: _jsx(Text, { color: "red", children: "High:" }) }), _jsx(ProgressBar, { value: highCount, max: Math.max(totalFindings, 1), width: 25 }), _jsxs(Text, { color: "red", children: [" ", highCount] })] }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsx(Box, { width: 10, children: _jsx(Text, { color: "yellow", children: "Medium:" }) }), _jsx(ProgressBar, { value: mediumCount, max: Math.max(totalFindings, 1), width: 25 }), _jsxs(Text, { color: "yellow", children: [" ", mediumCount] })] }), _jsxs(Box, { flexDirection: "row", gap: 2, children: [_jsx(Box, { width: 10, children: _jsx(Text, { color: "green", children: "Low:" }) }), _jsx(ProgressBar, { value: lowCount, max: Math.max(totalFindings, 1), width: 25 }), _jsxs(Text, { color: "green", children: [" ", lowCount] })] })] })] }));
|
|
65
|
+
};
|
|
66
|
+
// Mock data generator
|
|
67
|
+
const generateMockData = () => {
|
|
68
|
+
const projects = [
|
|
69
|
+
{
|
|
70
|
+
name: 'MyApp',
|
|
71
|
+
path: './myapp',
|
|
72
|
+
status: 'ok',
|
|
73
|
+
lastAnalyze: new Date(Date.now() - 2 * 60 * 1000),
|
|
74
|
+
findings: { high: 0, medium: 2, low: 14 },
|
|
75
|
+
duration: 1250,
|
|
76
|
+
filesAnalyzed: 42,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'WebApp',
|
|
80
|
+
path: './webapp',
|
|
81
|
+
status: 'warning',
|
|
82
|
+
lastAnalyze: new Date(Date.now() - 10 * 60 * 1000),
|
|
83
|
+
findings: { high: 2, medium: 3, low: 8 },
|
|
84
|
+
duration: 890,
|
|
85
|
+
filesAnalyzed: 28,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'API Server',
|
|
89
|
+
path: './api',
|
|
90
|
+
status: 'ok',
|
|
91
|
+
lastAnalyze: new Date(Date.now() - 30 * 60 * 1000),
|
|
92
|
+
findings: { high: 0, medium: 0, low: 5 },
|
|
93
|
+
duration: 2100,
|
|
94
|
+
filesAnalyzed: 156,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'Frontend',
|
|
98
|
+
path: './frontend',
|
|
99
|
+
status: 'error',
|
|
100
|
+
lastAnalyze: new Date(Date.now() - 60 * 60 * 1000),
|
|
101
|
+
findings: { high: 5, medium: 12, low: 20 },
|
|
102
|
+
duration: 3400,
|
|
103
|
+
filesAnalyzed: 203,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
const stats = {
|
|
107
|
+
totalCommands: 127,
|
|
108
|
+
successRate: 94,
|
|
109
|
+
avgDuration: 1450,
|
|
110
|
+
mostUsed: ['analyze', 'status', 'init'],
|
|
111
|
+
};
|
|
112
|
+
return { projects, stats };
|
|
113
|
+
};
|
|
114
|
+
// Helper function
|
|
115
|
+
const formatTimeAgo = (date) => {
|
|
116
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1000);
|
|
117
|
+
if (seconds < 60)
|
|
118
|
+
return `${seconds}s ago`;
|
|
119
|
+
const minutes = Math.floor(seconds / 60);
|
|
120
|
+
if (minutes < 60)
|
|
121
|
+
return `${minutes}m ago`;
|
|
122
|
+
const hours = Math.floor(minutes / 60);
|
|
123
|
+
if (hours < 24)
|
|
124
|
+
return `${hours}h ago`;
|
|
125
|
+
return `${Math.floor(hours / 24)}d ago`;
|
|
126
|
+
};
|
|
127
|
+
// Main Dashboard Component
|
|
128
|
+
export const EnhancedDashboard = () => {
|
|
129
|
+
const { exit } = useApp();
|
|
130
|
+
const [loading, setLoading] = useState(true);
|
|
131
|
+
const [data, setData] = useState(null);
|
|
132
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
133
|
+
const [showDetail, setShowDetail] = useState(false);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
// Simulate loading data
|
|
136
|
+
const timer = setTimeout(() => {
|
|
137
|
+
setData(generateMockData());
|
|
138
|
+
setLoading(false);
|
|
139
|
+
}, 800);
|
|
140
|
+
return () => clearTimeout(timer);
|
|
141
|
+
}, []);
|
|
142
|
+
useInput((input, key) => {
|
|
143
|
+
if (key.escape || input === 'q') {
|
|
144
|
+
exit();
|
|
145
|
+
}
|
|
146
|
+
if (key.return && data) {
|
|
147
|
+
setShowDetail(true);
|
|
148
|
+
}
|
|
149
|
+
if (key.upArrow && data) {
|
|
150
|
+
setSelectedIndex(i => Math.max(0, i - 1));
|
|
151
|
+
}
|
|
152
|
+
if (key.downArrow && data) {
|
|
153
|
+
setSelectedIndex(i => Math.min(data.projects.length - 1, i + 1));
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
if (loading) {
|
|
157
|
+
return (_jsxs(Box, { flexDirection: "column", alignItems: "center", padding: 2, children: [_jsx(Text, { color: "cyan", children: _jsx(Spinner, { type: "dots" }) }), _jsx(Text, { children: " Loading dashboard data..." })] }));
|
|
158
|
+
}
|
|
159
|
+
if (!data) {
|
|
160
|
+
return (_jsx(Box, { padding: 2, children: _jsx(Text, { color: "red", children: "Failed to load dashboard data" }) }));
|
|
161
|
+
}
|
|
162
|
+
if (showDetail) {
|
|
163
|
+
const project = data.projects[selectedIndex];
|
|
164
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Text, { bold: true, color: "cyan", children: ["\uD83D\uDCC1 Project Details: ", project.name] }), _jsx(CustomDivider, {}), _jsxs(Box, { flexDirection: "column", gap: 1, marginY: 1, children: [_jsxs(Text, { children: ["Path: ", _jsx(Text, { color: "cyan", children: project.path })] }), _jsxs(Text, { children: ["Status: ", _jsx(StatusIndicator, { status: project.status })] }), _jsxs(Text, { children: ["Files Analyzed: ", _jsx(Text, { bold: true, children: project.filesAnalyzed })] }), _jsxs(Text, { children: ["Duration: ", _jsxs(Text, { bold: true, children: [project.duration, "ms"] })] }), _jsxs(Text, { children: ["Last Analysis: ", project.lastAnalyze?.toLocaleString() || 'never'] })] }), _jsxs(Box, { marginY: 1, children: [_jsx(Text, { bold: true, children: "Findings:" }), _jsxs(Box, { flexDirection: "row", gap: 4, children: [_jsxs(Text, { color: "red", children: ["High: ", project.findings.high] }), _jsxs(Text, { color: "yellow", children: ["Medium: ", project.findings.medium] }), _jsxs(Text, { color: "green", children: ["Low: ", project.findings.low] })] })] }), _jsx(Box, { marginTop: 2, children: _jsx(Text, { dimColor: true, children: "Press Esc or Q to go back" }) })] }));
|
|
165
|
+
}
|
|
166
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { bold: true, color: "cyan", backgroundColor: "gray", children: [' ', " Delta CLI Dashboard ", ' '] }) }), _jsxs(Box, { flexDirection: "row", gap: 2, marginBottom: 1, children: [_jsx(Box, { width: "50%", children: _jsx(StatsBox, { stats: data.stats }) }), _jsx(Box, { width: "50%", children: _jsx(FindingsChart, { projects: data.projects }) })] }), _jsx(CustomDivider, { title: "Projects" }), _jsxs(Box, { flexDirection: "row", gap: 2, marginY: 1, children: [_jsx(Box, { width: 3, children: _jsx(Text, { children: " " }) }), _jsx(Box, { width: 12, children: _jsx(Text, { dimColor: true, children: "Status" }) }), _jsx(Box, { width: 20, children: _jsx(Text, { dimColor: true, children: "Name" }) }), _jsx(Box, { width: 12, children: _jsx(Text, { dimColor: true, children: "Last" }) }), _jsx(Box, { width: 10, children: _jsx(Text, { dimColor: true, children: "Findings" }) }), _jsx(Box, { width: 10, children: _jsx(Text, { dimColor: true, children: "Duration" }) })] }), _jsx(Box, { flexDirection: "column", children: data.projects.map((project, index) => (_jsx(ProjectRow, { project: project, isSelected: index === selectedIndex }, project.name))) }), _jsx(Box, { marginTop: 2, children: _jsx(Text, { dimColor: true, children: "\u2191\u2193 Navigate \u2022 Enter Details \u2022 Q/Esc Exit" }) })] }));
|
|
167
|
+
};
|
|
168
|
+
export default EnhancedDashboard;
|
|
169
|
+
//# sourceMappingURL=Dashboard.js.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { Box, Text, useApp } from 'ink';
|
|
4
|
+
import SelectInput from 'ink-select-input';
|
|
5
|
+
import Spinner from 'ink-spinner';
|
|
6
|
+
// Custom Divider component (replacement for ink-divider with type issues)
|
|
7
|
+
const CustomDivider = ({ title }) => (_jsx(Box, { marginY: 1, children: _jsxs(Text, { color: "gray", children: ['─'.repeat(40), title ? ` ${title} ` : '', '─'.repeat(40)] }) }));
|
|
8
|
+
import { EnhancedDashboard } from './Dashboard.js';
|
|
9
|
+
// Delta Logo Component
|
|
10
|
+
export const DeltaLogo = () => {
|
|
11
|
+
const [frame, setFrame] = useState(0);
|
|
12
|
+
const frames = ['◐', '◓', '◑', '◒'];
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const timer = setInterval(() => {
|
|
15
|
+
setFrame((f) => (f + 1) % frames.length);
|
|
16
|
+
}, 100);
|
|
17
|
+
return () => clearInterval(timer);
|
|
18
|
+
}, []);
|
|
19
|
+
return (_jsxs(Box, { flexDirection: "column", alignItems: "center", padding: 1, children: [_jsxs(Text, { children: [_jsx(Text, { color: "cyan", children: "\u2554\u2550\u2550\u2550" }), _jsx(Text, { color: "magenta", children: "DELTA" }), _jsx(Text, { color: "cyan", children: "\u2550\u2550\u2550\u2557" })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { dimColor: true, children: [frames[frame], " Next-gen code analysis"] }) })] }));
|
|
20
|
+
};
|
|
21
|
+
// Main App Component
|
|
22
|
+
export const DeltaApp = () => {
|
|
23
|
+
const { exit } = useApp();
|
|
24
|
+
const [currentView, setCurrentView] = useState('menu');
|
|
25
|
+
const menuItems = [
|
|
26
|
+
{ label: '📊 Dashboard', value: 'dashboard' },
|
|
27
|
+
{ label: '🔍 Analyze', value: 'analyze' },
|
|
28
|
+
{ label: '☁️ Sync', value: 'sync' },
|
|
29
|
+
{ label: '⚙️ Settings', value: 'settings' },
|
|
30
|
+
{ label: '❌ Exit', value: 'exit' },
|
|
31
|
+
];
|
|
32
|
+
const handleSelect = (item) => {
|
|
33
|
+
if (item.value === 'exit') {
|
|
34
|
+
exit();
|
|
35
|
+
}
|
|
36
|
+
else if (item.value === 'dashboard') {
|
|
37
|
+
setCurrentView('dashboard');
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if (currentView === 'dashboard') {
|
|
41
|
+
return _jsx(EnhancedDashboard, {});
|
|
42
|
+
}
|
|
43
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(DeltaLogo, {}), _jsx(Box, { marginTop: 1, marginBottom: 1, children: _jsx(CustomDivider, { title: "Main Menu" }) }), _jsx(Box, { children: _jsx(SelectInput, { items: menuItems, onSelect: handleSelect }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Press Enter to select \u2022 Q to quit" }) })] }));
|
|
44
|
+
};
|
|
45
|
+
// Loading Screen
|
|
46
|
+
export const LoadingScreen = ({ message = 'Loading...' }) => {
|
|
47
|
+
return (_jsxs(Box, { flexDirection: "column", alignItems: "center", padding: 2, children: [_jsx(Text, { color: "cyan", children: _jsx(Spinner, { type: "dots" }) }), _jsxs(Text, { children: [" ", message] })] }));
|
|
48
|
+
};
|
|
49
|
+
// Error Display
|
|
50
|
+
export const ErrorDisplay = ({ error }) => {
|
|
51
|
+
return (_jsx(Box, { flexDirection: "column", padding: 1, children: _jsxs(Text, { bold: true, color: "red", children: ["\u274C Error: ", error.message] }) }));
|
|
52
|
+
};
|
|
53
|
+
// Success Message
|
|
54
|
+
export const SuccessMessage = ({ message }) => {
|
|
55
|
+
return (_jsx(Box, { padding: 1, children: _jsxs(Text, { color: "green", children: ["\u2713 ", message] }) }));
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=DeltaApp.js.map
|